From 2b203eea3b9a38b482f30d55640d7e9fd6b6a697 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Fri, 5 Apr 2024 04:17:20 +0300 Subject: [PATCH] chore: hermione -> testplane --- AUTHORS | 2 +- CONTRIBUTING.md | 4 +- README.md | 22 +++++----- lib/config/index.js | 4 +- lib/index.js | 14 +++---- package-lock.json | 8 ++-- package.json | 13 +++--- test/lib/index.js | 100 ++++++++++++++++++++++---------------------- 8 files changed, 84 insertions(+), 83 deletions(-) diff --git a/AUTHORS b/AUTHORS index 750ad6e..5bf41ee 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,4 +1,4 @@ -The following authors have created the source code of "hermione-safari-commands" +The following authors have created the source code of "@testplane/safari-commands" published and distributed by YANDEX LLC as the owner: Dmitriy Dudkevich diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d3690f1..41240b5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ New contributions are welcomed. Follow this guide if you want to make one. Follow [Github guide](https://help.github.com/articles/creating-a-pull-request) to fork a repo and create a pull request. -All bug fixes and new features should go to the [`master`](https://github.com/gemini-testing/hermione-safari-commands/tree/master) branch. +All bug fixes and new features should go to the [`master`](https://github.com/gemini-testing/testplane-safari-commands/tree/master) branch. ## Commit messages @@ -36,7 +36,7 @@ If you are fixing the bug, add a test that fails without your patch and passes w When submitting an issue please do following: -1. [Search](https://github.com/gemini-testing/hermione-safari-commands/issues) for same issues on github in order to prevent duplicates +1. [Search](https://github.com/gemini-testing/testplane-safari-commands/issues) for same issues on github in order to prevent duplicates 2. Provide the most detailed issue description so we will additional info to work with Note that if no response for contributors questions will be provided in 1 week then issue may be considered as irrelevant/resolved and may be closed. diff --git a/README.md b/README.md index 5563ca0..87c760e 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -# hermione-safari-commands +# @testplane/safari-commands -[![NPM version](https://img.shields.io/npm/v/hermione-safari-commands.svg?style=flat)](https://www.npmjs.org/package/hermione-safari-commands) -[![Build Status](https://travis-ci.org/gemini-testing/hermione-safari-commands.svg?branch=master)](https://travis-ci.org/gemini-testing/hermione-safari-commands) +[![NPM version](https://img.shields.io/npm/v/@testplane/safari-commands.svg?style=flat)](https://www.npmjs.org/package/@testplane/safari-commands) +[![Build Status](https://travis-ci.org/gemini-testing/testplane-safari-commands.svg?branch=master)](https://travis-ci.org/gemini-testing/testplane-safari-commands) -Plugin for [hermione](https://github.com/gemini-testing/hermione) which is intended to add/wrap browser commands in order to work properly with the iOS safari browser. +Plugin for [Testplane](https://github.com/gemini-testing/testplane) which is intended to add/wrap browser commands in order to work properly with the iOS safari browser. -You can read more about hermione plugins [here](https://github.com/gemini-testing/hermione#plugins). +You can read more about Testplane plugins [here](https://github.com/gemini-testing/testplane#plugins). ## Installation ```bash -npm install hermione-safari-commands +npm install @testplane/safari-commands ``` ## Usage @@ -34,16 +34,16 @@ Plugin has following configuration: Also there is ability to override plugin parameters by CLI options or environment variables (see [configparser](https://github.com/gemini-testing/configparser)). -Use `hermione_safari_commands_` prefix for the environment variables and `--hermione-safari-commands-` for the cli options. +Use `testplane_safari_commands_` prefix for the environment variables and `--testplane-safari-commands-` for the cli options. -Add plugin to your `hermione` config file: +Add plugin to your `testplane` config file: ```js module.exports = { // ... system: { plugins: { - 'hermione-safari-commands': { + '@testplane/safari-commands': { enabled: true, browsers: { safari13: { @@ -82,9 +82,9 @@ module.exports = { ### Existing safari commands: Wrappers over existing commands: -* **url** - wrapper over wdio "url" in order to wait until the page is completely open (used timeout from [`hermione.pageLoadTimeout`](https://github.com/gemini-testing/hermione#pageloadtimeout) or `30000` ms). In [appium-xcuitest-driver](https://github.com/appium/appium-xcuitest-driver) page is open with using the `xcrun` utility - `xcrun simctl openurl` which just tells the simulator to open the page and does not wait anything; +* **url** - wrapper over wdio "url" in order to wait until the page is completely open (used timeout from [`testplane.pageLoadTimeout`](https://github.com/gemini-testing/testplane#pageloadtimeout) or `30000` ms). In [appium-xcuitest-driver](https://github.com/appium/appium-xcuitest-driver) page is open with using the `xcrun` utility - `xcrun simctl openurl` which just tells the simulator to open the page and does not wait anything; * **click** - replaces wdio "click" in order to perform real touch click (by default it emits only events on passed element). Should be used with **touch** command; -* **screenshot** - wrapper of wdio "screenshot" in order to cut the native elements from the final image ([calibration](https://github.com/gemini-testing/hermione#calibrate) must be turned off); +* **screenshot** - wrapper of wdio "screenshot" in order to cut the native elements from the final image ([calibration](https://github.com/gemini-testing/testplane#calibrate) must be turned off); * **orientation** - wrapper of wdio "orientation" in order to recalculate size of native elements for "screenshot" command (turns on automatically when you specify a screenshot command); * **swipe** - replaces wdio "swipe" in order to perform swipe by coordinates in native context; * **touch** - replaces wdio "touch" in order to perform touch click by coordinates in native context; diff --git a/lib/config/index.js b/lib/config/index.js index fde51e5..d71c6af 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -10,8 +10,8 @@ const thr = (str) => { const {root, map, section, option} = configParser; -const ENV_PREFIX = 'hermione_safari_commands_'; -const CLI_PREFIX = '--hermione-safari-commands-'; +const ENV_PREFIX = 'testplane_safari_commands_'; +const CLI_PREFIX = '--testplane-safari-commands-'; const assertType = (name, validationFn, type) => { return (v) => !validationFn(v) && thr(`"${name}" option must be ${type}, but got ${typeof v}`); diff --git a/lib/index.js b/lib/index.js index b25d380..5cd470a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -7,15 +7,15 @@ const {WEB_VIEW_CTX} = require('./command-helpers/test-context'); const {getNativeLocators} = require('./native-locators'); const {getElementUtils} = require('./command-helpers/element-utils'); -module.exports = (hermione, opts) => { +module.exports = (testplane, opts) => { const pluginConfig = parseConfig(opts); if (!pluginConfig.enabled) { return; } - if (!hermione.isWorker()) { - hermione.on(hermione.events.SESSION_START, async (browser, {browserId}) => { + if (!testplane.isWorker()) { + testplane.on(testplane.events.SESSION_START, async (browser, {browserId}) => { if (_.isEmpty(getBrowserPluginCfg(pluginConfig, browserId))) { return; } @@ -37,14 +37,14 @@ module.exports = (hermione, opts) => { return; } - hermione.on(hermione.events.NEW_BROWSER, (browser, {browserId}) => { + testplane.on(testplane.events.NEW_BROWSER, (browser, {browserId}) => { const {commands = [], nativeElementsSize} = getBrowserPluginCfg(pluginConfig, browserId); if (_.isEmpty(commands)) { return; } - const broConfig = hermione.config.forBrowser(browserId); + const broConfig = testplane.config.forBrowser(browserId); if (commands.includes('screenshot') && !commands.includes('orientation')) { commands.push('orientation'); @@ -61,13 +61,13 @@ module.exports = (hermione, opts) => { }); }); - hermione.on(hermione.events.AFTER_TESTS_READ, (collection) => { + testplane.on(testplane.events.AFTER_TESTS_READ, (collection) => { collection.eachRootSuite((root, browserId) => { if (_.isEmpty(getBrowserPluginCfg(pluginConfig, browserId))) { return; } - const {testsPerSession} = hermione.config.forBrowser(browserId); + const {testsPerSession} = testplane.config.forBrowser(browserId); const isTestRunsInOneSession = testsPerSession === 1; if (isTestRunsInOneSession) { diff --git a/package-lock.json b/package-lock.json index 513cb89..1f047ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "hermione-safari-commands", - "version": "2.1.0", + "name": "@testplane/safari-commands", + "version": "0.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "hermione-safari-commands", - "version": "2.0.0", + "name": "@testplane/safari-commands", + "version": "0.0.1", "license": "MIT", "dependencies": { "gemini-configparser": "^1.3.0", diff --git a/package.json b/package.json index a30b91b..d891e6e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "hermione-safari-commands", - "version": "2.1.0", - "description": "Plugin for hermione to add/wrap browser commands for iOS safari", + "name": "@testplane/safari-commands", + "version": "0.0.1", + "description": "Plugin for Testplane to add/wrap browser commands for iOS safari", "main": "lib/index.js", "scripts": { "lint": "eslint .", @@ -14,9 +14,10 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/gemini-testing/hermione-safari-commands.git" + "url": "git+https://github.com/gemini-testing/testplane-safari-commands.git" }, "keywords": [ + "testplane", "hermione", "plugin", "safari", @@ -25,9 +26,9 @@ "author": "Dmitriy Dudkevich ", "license": "MIT", "bugs": { - "url": "https://github.com/gemini-testing/hermione-safari-commands/issues" + "url": "https://github.com/gemini-testing/testplane-safari-commands/issues" }, - "homepage": "https://github.com/gemini-testing/hermione-safari-commands#readme", + "homepage": "https://github.com/gemini-testing/testplant-safari-commands#readme", "dependencies": { "gemini-configparser": "^1.3.0", "lodash": "^4.17.15", diff --git a/test/lib/index.js b/test/lib/index.js index dc38238..40edbb5 100644 --- a/test/lib/index.js +++ b/test/lib/index.js @@ -12,25 +12,25 @@ const {mkConfig_, mkBrowser_} = require('../utils'); describe('plugin', () => { let initialDocument, plugin, getElementUtils, getNativeLocators; - const mkHermione_ = (opts = {}) => { + const mkTestplane_ = (opts = {}) => { opts = _.defaults(opts, { proc: 'master', browsers: {} }); - const hermione = new EventEmitter2(); + const testplane = new EventEmitter2(); - hermione.events = { + testplane.events = { NEW_BROWSER: 'newBrowser', SESSION_START: 'sessionStart', AFTER_TESTS_READ: 'afterTestsRead' }; - hermione.isWorker = sinon.stub().returns(opts.proc === 'worker'); - hermione.config = { + testplane.isWorker = sinon.stub().returns(opts.proc === 'worker'); + testplane.config = { forBrowser: (id) => opts.browsers[id] || {desiredCapabilities: {}} }; - return hermione; + return testplane; }; beforeEach(() => { @@ -62,20 +62,20 @@ describe('plugin', () => { }); it('should do nothing if plugin is disabled', () => { - const hermione = mkHermione_(); - sinon.spy(hermione, 'on'); + const testplane = mkTestplane_(); + sinon.spy(testplane, 'on'); - plugin(hermione, mkConfig_({enabled: false})); + plugin(testplane, mkConfig_({enabled: false})); - assert.notCalled(hermione.on); + assert.notCalled(testplane.on); }); describe('master process', () => { describe('"SESSION_START" event', () => { it('should do nothing if browser does not exist in plugin config', async () => { - const hermione = mkHermione_({proc: 'master'}); + const testplane = mkTestplane_({proc: 'master'}); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: { b1: { commands: [] @@ -84,15 +84,15 @@ describe('plugin', () => { })); const browser = mkBrowser_(); - await hermione.emitAsync(hermione.events.SESSION_START, browser, {browserId: 'b2'}); + await testplane.emitAsync(testplane.events.SESSION_START, browser, {browserId: 'b2'}); assert.notCalled(browser.execute); }); it('should create fake input and focus on it for plugin browsers', async () => { - const hermione = mkHermione_({proc: 'master'}); + const testplane = mkTestplane_({proc: 'master'}); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: { b1: { commands: [] @@ -111,7 +111,7 @@ describe('plugin', () => { browser.execute.firstCall.args[0](); }); - await hermione.emitAsync(hermione.events.SESSION_START, browser, {browserId: 'b1'}); + await testplane.emitAsync(testplane.events.SESSION_START, browser, {browserId: 'b1'}); assert.calledWith(document.createElement, 'input'); assert.calledWith(fakeInput.setAttribute, 'type', 'text'); @@ -120,9 +120,9 @@ describe('plugin', () => { }); it('should save web view context in session options', async () => { - const hermione = mkHermione_({proc: 'master'}); + const testplane = mkTestplane_({proc: 'master'}); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: { b1: { commands: [] @@ -133,7 +133,7 @@ describe('plugin', () => { const browser = mkBrowser_(); browser.getContexts.resolves([NATIVE_CONTEXT, 'WEBVIEW_12345']); - await hermione.emitAsync(hermione.events.SESSION_START, browser, {browserId: 'b1'}); + await testplane.emitAsync(testplane.events.SESSION_START, browser, {browserId: 'b1'}); assert.calledOnceWith(browser.extendOptions, {[WEB_VIEW_CTX]: 'WEBVIEW_12345'}); }); @@ -142,10 +142,10 @@ describe('plugin', () => { describe('worker process', () => { it('should not subscribe on "SESSION_START" event', () => { - const hermione = mkHermione_({proc: 'worker'}); - sinon.spy(hermione, 'on'); + const testplane = mkTestplane_({proc: 'worker'}); + sinon.spy(testplane, 'on'); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: { b1: { commands: [] @@ -153,14 +153,14 @@ describe('plugin', () => { } })); - assert.isTrue(hermione.on.neverCalledWith(hermione.events.SESSION_START)); + assert.isTrue(testplane.on.neverCalledWith(testplane.events.SESSION_START)); }); describe('"NEW_BROWSER" event', () => { it('should throws if passed command is not implemented', () => { - const hermione = mkHermione_({proc: 'worker'}); + const testplane = mkTestplane_({proc: 'worker'}); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: { b1: { commands: ['non_existent_cmd'] @@ -169,14 +169,14 @@ describe('plugin', () => { })); assert.throws(() => { - hermione.emit(hermione.events.NEW_BROWSER, {}, {browserId: 'b1'}); + testplane.emit(testplane.events.NEW_BROWSER, {}, {browserId: 'b1'}); }, TypeError, 'Can not find "non_existent_cmd" command'); }); it('should not throw if created browser is not specified in config', () => { - const hermione = mkHermione_({proc: 'worker'}); + const testplane = mkTestplane_({proc: 'worker'}); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: { b1: { commands: ['some-command'] @@ -185,21 +185,21 @@ describe('plugin', () => { })); assert.doesNotThrow(() => { - hermione.emit(hermione.events.NEW_BROWSER, {}, {browserId: 'non-wrapped-bro'}); + testplane.emit(testplane.events.NEW_BROWSER, {}, {browserId: 'non-wrapped-bro'}); }); }); it('should call passed command', () => { const browser = mkBrowser_(); const browserConfig = {foo: 'bar', desiredCapabilities: {}}; - const hermione = mkHermione_({ + const testplane = mkTestplane_({ proc: 'worker', browsers: { b1: browserConfig } }); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: { b1: { commands: ['swipe'] @@ -210,7 +210,7 @@ describe('plugin', () => { getNativeLocators.returns({some: 'locators'}); getElementUtils.returns({some: 'utils'}); - hermione.emit(hermione.events.NEW_BROWSER, browser, {browserId: 'b1'}); + testplane.emit(testplane.events.NEW_BROWSER, browser, {browserId: 'b1'}); assert.calledOnceWith(commands.swipe, browser, {config: browserConfig, elementUtils: {some: 'utils'}, nativeLocators: {some: 'locators'}}); @@ -219,14 +219,14 @@ describe('plugin', () => { describe('"orientation" command is not specified in config', () => { it('should not wrap "orientation" if "screenshot" command is not specified', () => { const browser = mkBrowser_(); - const hermione = mkHermione_({ + const testplane = mkTestplane_({ proc: 'worker', browsers: { b1: {} } }); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: { b1: { commands: ['swipe'] @@ -234,7 +234,7 @@ describe('plugin', () => { } })); - hermione.emit(hermione.events.NEW_BROWSER, browser, {browserId: 'b1'}); + testplane.emit(testplane.events.NEW_BROWSER, browser, {browserId: 'b1'}); assert.notCalled(commands.orientation); }); @@ -242,14 +242,14 @@ describe('plugin', () => { it('should wrap "orientation" if "screenshot" command is specified', () => { const browser = mkBrowser_(); const browserConfig = {foo: 'bar'}; - const hermione = mkHermione_({ + const testplane = mkTestplane_({ proc: 'worker', browsers: { b1: browserConfig } }); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: { b1: { commands: ['screenshot'] @@ -259,7 +259,7 @@ describe('plugin', () => { getNativeLocators.returns({some: 'locators'}); getElementUtils.returns({some: 'utils'}); - hermione.emit(hermione.events.NEW_BROWSER, browser, {browserId: 'b1'}); + testplane.emit(testplane.events.NEW_BROWSER, browser, {browserId: 'b1'}); assert.calledOnceWith(commands.orientation, browser, {config: browserConfig, nativeLocators: {some: 'locators'}, elementUtils: {some: 'utils'}}); @@ -269,14 +269,14 @@ describe('plugin', () => { describe('"orientation" command is specified in config', () => { it('should not wrap "orientation" again even if "screenshot" command is specified', () => { const browser = mkBrowser_(); - const hermione = mkHermione_({ + const testplane = mkTestplane_({ proc: 'worker', browsers: { b1: {} } }); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: { b1: { commands: ['orientation', 'screenshot'] @@ -284,7 +284,7 @@ describe('plugin', () => { } })); - hermione.emit(hermione.events.NEW_BROWSER, browser, {browserId: 'b1'}); + testplane.emit(testplane.events.NEW_BROWSER, browser, {browserId: 'b1'}); assert.calledOnce(commands.orientation); }); @@ -300,12 +300,12 @@ describe('plugin', () => { }); it('for browsers that not specified in plugin config', () => { - const hermione = mkHermione_({proc: 'worker'}); - plugin(hermione, mkConfig_({ + const testplane = mkTestplane_({proc: 'worker'}); + plugin(testplane, mkConfig_({ browsers: {b1: {}} })); - hermione.emit(hermione.events.AFTER_TESTS_READ, { + testplane.emit(testplane.events.AFTER_TESTS_READ, { eachRootSuite: (cb) => cb(rootSuite, 'b2') }); @@ -313,17 +313,17 @@ describe('plugin', () => { }); it('if test runs in one session', () => { - const hermione = mkHermione_({ + const testplane = mkTestplane_({ proc: 'worker', browsers: { b1: {testsPerSession: 1} } }); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: {b1: {}} })); - hermione.emit(hermione.events.AFTER_TESTS_READ, { + testplane.emit(testplane.events.AFTER_TESTS_READ, { eachRootSuite: (cb) => cb(rootSuite, 'b1') }); @@ -332,18 +332,18 @@ describe('plugin', () => { }); it('should change web view context in "beforeEach" hook', async () => { - const hermione = mkHermione_({ + const testplane = mkTestplane_({ proc: 'worker', browsers: { b1: {testsPerSession: 2} } }); - plugin(hermione, mkConfig_({ + plugin(testplane, mkConfig_({ browsers: {b1: {}} })); const rootSuite = {beforeEach: sinon.spy().named('beforeEach')}; - hermione.emit(hermione.events.AFTER_TESTS_READ, { + testplane.emit(testplane.events.AFTER_TESTS_READ, { eachRootSuite: (cb) => cb(rootSuite, 'b1') });