Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace hermione tokens #895

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

KuznetsovRoman
Copy link
Member

@KuznetsovRoman KuznetsovRoman commented Apr 2, 2024

What is done

Changed hermione to testplane in all necessary places.

Public api change list:

  • Instead of HERMIONE_SETS and HERMIONE_SKIP_BROWSERS env vars, you can use TESTPLANE_ analogs
  • screenshotsDir default value changed. But if default value is used and there is "hermione/screens" directory, but no "testplane/screens" (new default) directory, deprecated path will be chosen
  • added copy of "hermione*"-stuff, marked all hermione* stuff as deprecated

@KuznetsovRoman KuznetsovRoman force-pushed the kr/rebranding/code_tokens branch from 822056e to d3f3776 Compare April 2, 2024 23:30
@@ -862,7 +862,7 @@ If you want to extend testplane.ctx typings, you could use module augmentation:
import type { TestplaneCtx } from "testplane";

declare module "testplane" {
interface HermioneCtx {
interface TestplaneCtx {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed interface name in README.
You can still use HermioneCtx though

"name": "hermione",
"version": "8.7.2",
"name": "testplane",
"version": "0.0.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first ready version will be marked as 0.1.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to change to 0.1.0 in the file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be made automatically. With npm run release

@@ -72,6 +69,6 @@ export abstract class BaseHermione extends AsyncEmitter {
}

protected _loadPlugins(): void {
pluginsLoader.load(this, this.config.plugins, PREFIX);
pluginsLoader.load(this, this.config.plugins, "hermione-");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using hard-coded "hermione-" here, because it no longer depends on package.json-s name, and we are not planning to add ability to use implicit plugin names in Testplane.

Comment on lines +126 to +129
/**
* @deprecated Use `testplaneCtx` instead
*/
hermioneCtx: ExecutionThreadToolCtx;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This label would style every usage with strikethrough with specific label:
Screenshot 2024-04-03 at 02 34 59

Comment on lines +192 to +200
map: (value, _, __, { isSetByUser }) => {
const deprecatedScreensPath = "hermione/screens";

if (!isSetByUser && fs.existsSync(deprecatedScreensPath) && !fs.existsSync(value)) {
return deprecatedScreensPath;
}

return value;
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If user uses default value, we check for "hermione/screens" folder. If it exists, and "testplane/screens" does not, switch to "hermione/screens"

Only works when default value is untouched, and new default directory does not exist, but old one - does

Comment on lines +39 to +40
global.testplane = toolGlobals;
global.hermione = toolGlobals;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all public api instances of hermione* are also exported as copies (with Object.is equality) for testplane*

@@ -528,6 +529,66 @@ describe("config browser-options", () => {
assert.equal(config.browsers.b1.screenshotsDir, "/some/dir");
assert.equal(config.browsers.b2.screenshotsDir, "/screens");
});

it("should fallback default value to hermione/screens, if it exists and default dir not exists", () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New logic tests added in this file

Comment on lines 9 to 23
it("should parse comma seperated env value", () => {
process.env.foo = "a, b,c";

assert.deepEqual(env.parseCommaSeparatedValue("foo"), ["a", "b", "c"]);
const { key, value } = env.parseCommaSeparatedValue("foo");
assert.deepEqual(value, ["a", "b", "c"]);
assert.equal(key, "foo");
});

it("should fallback to other env keys", () => {
process.env.foo = "a, b,c";

const { key, value } = env.parseCommaSeparatedValue(["bar", "foo"]);
assert.deepEqual(value, ["a", "b", "c"]);
assert.equal(key, "foo");
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And these ones

Comment on lines +99 to 104
// testplane does not support its own plugin prefixes.
it("should load plugins with deprecated hermione prefix", () => {
Testplane.create();

assert.calledWith(pluginsLoader.load, sinon.match.any, sinon.match.any, "hermione-");
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loading plugins with implicit "testplane-" or "@testplane/" would not be supported.

Comment on lines +53 to +56
Testplane = proxyquire("src/testplane", {
"./reporters": { initReporters },
}).Hermione;
"./signal-handler": signalHandler,
}).Testplane;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, after renaming, signalHandler was interfering from other files, so one tests was failing, when launched with all other test files.

@KuznetsovRoman KuznetsovRoman self-assigned this Apr 3, 2024
@miripiruni miripiruni self-requested a review April 3, 2024 13:18
screenshotsDir: option({
defaultValue: defaultFactory("screenshotsDir"),
validate: value => {
if (!_.isString(value) && !_.isFunction(value)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest not using lodash where possible.

if (typeof value === "string" || typeof value === "function") {
    return;
}

throw new Error('"screenshotsDir" must be a string or function');

@KuznetsovRoman KuznetsovRoman force-pushed the kr/rebranding/code_tokens branch from d3f3776 to 068df03 Compare April 8, 2024 11:48
@KuznetsovRoman KuznetsovRoman force-pushed the kr/rebranding/code_tokens branch from 068df03 to a23643b Compare April 8, 2024 11:53
@KuznetsovRoman KuznetsovRoman merged commit bbbbd1e into rebranding Apr 8, 2024
2 checks passed
@KuznetsovRoman KuznetsovRoman deleted the kr/rebranding/code_tokens branch April 8, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants