From 5953507c7dae49b33de4642e5f947e9996d30fb7 Mon Sep 17 00:00:00 2001 From: Christian Fritsch Date: Fri, 12 Jul 2024 14:55:46 +0200 Subject: [PATCH] Remove nightwatch tests --- docs/contributing.md | 43 ---- tests/src/Nightwatch/.eslintrc.json | 45 ---- .../src/Nightwatch/Commands/autoFillField.js | 134 ------------ .../src/Nightwatch/Commands/autoFillFields.js | 27 --- tests/src/Nightwatch/Commands/fillCKEditor.js | 32 --- .../Nightwatch/Commands/fillEntityBrowser.js | 66 ------ .../src/Nightwatch/Commands/paragraphs/add.js | 53 ----- .../Commands/paragraphs/addImage.js | 101 --------- .../Commands/paragraphs/addInstagram.js | 36 ---- .../Nightwatch/Commands/paragraphs/addText.js | 36 ---- .../Commands/paragraphs/autoCreate.js | 33 --- .../Commands/performance/endMark.js | 40 ---- .../Commands/performance/endMeasurement.js | 30 --- .../Commands/performance/setLabel.js | 24 --- .../Commands/performance/startMark.js | 35 ---- .../Commands/performance/startMeasurement.js | 78 ------- .../Commands/performance/waitBrowser.js | 53 ----- .../Commands/scrollInViewAndClick.js | 19 -- .../Commands/scrollIntoMiddleOfView.js | 48 ----- .../Commands/select2/selectValue.js | 37 ---- .../Nightwatch/Commands/select2/setValue.js | 28 --- tests/src/Nightwatch/Tests/ArticleCreate.js | 196 ------------------ .../src/Nightwatch/Tests/AutoCompleteField.js | 57 ----- .../Tests/ContentOverviewFiltering.js | 53 ----- .../Nightwatch/Tests/CreateMostUsedContent.js | 90 -------- .../Nightwatch/Tests/EditMostUsedContent.js | 62 ------ .../SearchApiContentOverviewFiltering.js | 58 ------ tests/src/Nightwatch/config.js | 52 ----- tests/src/Nightwatch/utils.js | 89 -------- 29 files changed, 1655 deletions(-) delete mode 100644 tests/src/Nightwatch/.eslintrc.json delete mode 100644 tests/src/Nightwatch/Commands/autoFillField.js delete mode 100644 tests/src/Nightwatch/Commands/autoFillFields.js delete mode 100644 tests/src/Nightwatch/Commands/fillCKEditor.js delete mode 100644 tests/src/Nightwatch/Commands/fillEntityBrowser.js delete mode 100644 tests/src/Nightwatch/Commands/paragraphs/add.js delete mode 100644 tests/src/Nightwatch/Commands/paragraphs/addImage.js delete mode 100644 tests/src/Nightwatch/Commands/paragraphs/addInstagram.js delete mode 100644 tests/src/Nightwatch/Commands/paragraphs/addText.js delete mode 100644 tests/src/Nightwatch/Commands/paragraphs/autoCreate.js delete mode 100644 tests/src/Nightwatch/Commands/performance/endMark.js delete mode 100644 tests/src/Nightwatch/Commands/performance/endMeasurement.js delete mode 100644 tests/src/Nightwatch/Commands/performance/setLabel.js delete mode 100644 tests/src/Nightwatch/Commands/performance/startMark.js delete mode 100644 tests/src/Nightwatch/Commands/performance/startMeasurement.js delete mode 100644 tests/src/Nightwatch/Commands/performance/waitBrowser.js delete mode 100644 tests/src/Nightwatch/Commands/scrollInViewAndClick.js delete mode 100644 tests/src/Nightwatch/Commands/scrollIntoMiddleOfView.js delete mode 100644 tests/src/Nightwatch/Commands/select2/selectValue.js delete mode 100644 tests/src/Nightwatch/Commands/select2/setValue.js delete mode 100644 tests/src/Nightwatch/Tests/ArticleCreate.js delete mode 100644 tests/src/Nightwatch/Tests/AutoCompleteField.js delete mode 100644 tests/src/Nightwatch/Tests/ContentOverviewFiltering.js delete mode 100644 tests/src/Nightwatch/Tests/CreateMostUsedContent.js delete mode 100644 tests/src/Nightwatch/Tests/EditMostUsedContent.js delete mode 100644 tests/src/Nightwatch/Tests/SearchApiContentOverviewFiltering.js delete mode 100644 tests/src/Nightwatch/config.js delete mode 100644 tests/src/Nightwatch/utils.js diff --git a/docs/contributing.md b/docs/contributing.md index 8047b2cb2..92a695c82 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -214,49 +214,6 @@ php ./core/scripts/db-tools.php dump-database-d8-mysql | gzip > thunder.sql.gz export thunderDumpFile=/path/to/thunder.sql.gz ``` -### How to run the NightwatchJS performance tests - -1. You need to install [Yarn](https://yarnpkg.com). Please check the installation documentation for it. -2. You have to install `thunder/thunder_performance_measurement` package. To do that, execute the following command in - your project root directory: `composer require thunder/thunder_performance_measurement:dev-master --dev` and enable - the module by executing: `drush en thunder_performance_measurement` in your `docroot` directory. -3. You need to install [Elastic APM Node.js Agent](https://www.npmjs.com/package/elastic-apm-node) in Drupal Core node - packages. To do that go to your `docroot/core` directory and execute the following - command: `yarn add elastic-apm-node --dev` -4. You have to adjust your `.env` file inside `docroot/core` directory. You can copy the `.env.example` to `.env` and - edit it accordingly. Thunder tests require the following environment variables: `DRUPAL_TEST_BASE_URL` - , `THUNDER_BRANCH`, `THUNDER_SITE_HOSTNAME` and `THUNDER_APM_URL`. The `THUNDER_BRANCH` is the branch name where - tests are executing, for example, `8.x-4.x`. The `THUNDER_SITE_HOSTNAME` is the hostname where tests are executing, - for example, `thunder.dev`. The `THUNDER_APM_URL` is URL to Elastic APM Server, for example, `http://localhost:8200`. -5. After that, you can run NightwatchJS tests by executing the following command inside `docroot/core` - directory: `yarn test:nightwatch `. Here is an - example: `yarn test:nightwatch ../profiles/contrib/thunder/tests/src/Nightwatch/Tests/CreateMostUsedContent.js` - -#### If you have a problem with outdated chromedriver - -Drupal core does not update javascript dependencies so fast and chromedriver may be outdated and unable to work with -chrome installed on the system. You can provide chrome that can be used by chromedriver inside a docker container. You -can do it with the following command: - -```bash -docker run --name selenium_chrome -d -P -p 6000:5900 -p 4444:4444 --shm-size 256m --add-host="thunder.dd:172.16.123.1" selenium/standalone-chrome-debug:3.141.59-selenium -``` - -You have to find what is correct docker image tag for the chrome version you need. To do that you have to take a look -at [selenium docker releases](https://github.com/SeleniumHQ/docker-selenium/releases). This workflow is similar to PHP -JavaScript tests and for additional information, you can take a look at **How to run the tests** section. - -After you have running chrome in docker, you have also to change environment variables in `.env` file. The following -environment variable should be set: - -```bash -DRUPAL_TEST_WEBDRIVER_PORT=4444 -DRUPAL_TEST_WEBDRIVER_PATH_PREFIX=/wd/hub -DRUPAL_TEST_CHROMEDRIVER_AUTOSTART=false -``` - -You can copy/paste this section to the bottom of your `.env` file. - ## Documentation To help with the documentation, please run: diff --git a/tests/src/Nightwatch/.eslintrc.json b/tests/src/Nightwatch/.eslintrc.json deleted file mode 100644 index e3d505cad..000000000 --- a/tests/src/Nightwatch/.eslintrc.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "extends": [ - "airbnb", - "plugin:prettier/recommended" - ], - "root": true, - "env": { - "browser": true, - "es6": true, - "node": true - }, - "globals": { - "Drupal": true, - "drupalSettings": true, - "drupalTranslations": true, - "domready": true, - "jQuery": true, - "_": true, - "matchMedia": true, - "Backbone": true, - "Modernizr": true, - "CKEDITOR": true - }, - "rules": { - "prettier/prettier": "error", - "consistent-return": ["off"], - "no-underscore-dangle": ["off"], - "max-nested-callbacks": ["warn", 3], - "import/no-mutable-exports": ["warn"], - "no-plusplus": ["warn", { - "allowForLoopAfterthoughts": true - }], - "no-param-reassign": ["off"], - "no-prototype-builtins": ["off"], - "valid-jsdoc": ["warn", { - "prefer": { - "returns": "return", - "property": "prop" - }, - "requireReturn": false - }], - "no-unused-vars": ["warn"], - "operator-linebreak": ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }] - } -} diff --git a/tests/src/Nightwatch/Commands/autoFillField.js b/tests/src/Nightwatch/Commands/autoFillField.js deleted file mode 100644 index 9f4ed5759..000000000 --- a/tests/src/Nightwatch/Commands/autoFillField.js +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @file - * Automatically fill field with some random data. - * - * TODO: We should fill fields with some meaningful data! - * - * This provides a custom command, .autoFillField() - * - * @param {string} fieldName - * The filed name. - * @param {{type: string}} fieldInfo - * The filed information object. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function autoFillField(fieldName, fieldInfo) { - const browser = this; - - // eslint-disable-next-line no-console - console.log(`Auto fill field: ${fieldName}`); - - const fieldIdPart = fieldName.replace(/[_[]/g, '-').replace(/]/g, ''); - - switch (fieldInfo.type) { - // Text field. - case 'string_textfield': - case 'string_textarea': { - const stringFieldXPath = `//*[starts-with(@id, "edit-${fieldIdPart}-0-value")]`; - - browser.clearValue(stringFieldXPath); - browser.setValue( - stringFieldXPath, - `Some text ${Math.random().toString(36)}`, - ); - - return browser; - } - - case 'text_textarea': { - browser - .waitForElementVisible( - `//*[starts-with(@id, "cke_edit-${fieldIdPart}-0-value")]//iframe`, - 10000, - ) - .fillCKEditor( - `//*[starts-with(@id, "edit-${fieldIdPart}-0-value")]`, - 'Lorem ipsum dolor sit amet, cu choro iudico expetenda qui, sale assum instructior per an. His ne regione oporteat detraxit, integre intellegat definiebas mel id. Mutat persequeris definitiones nec at. Eu est legere facilis partiendo, ad sed sensibus posidonium. Insolens argumentum an pri. Mea at tritani nostrum recteque, et viris interpretaris vis.', - ); - - return browser; - } - - // Number field. - case 'number': { - const numberFieldXPath = `//*[starts-with(@id, "edit-${fieldIdPart}-0-value")]`; - - browser.clearValue(numberFieldXPath); - browser.setValue(numberFieldXPath, '1'); - - return browser; - } - - // Select options. - case 'options_select': - browser.click(`//*[starts-with(@id, "edit-${fieldIdPart}")]/option[2]`); - - return browser; - - // Default Auto-Complete widget. - case 'entity_reference_autocomplete': - browser - .clearValue(`//*[@id="edit-${fieldIdPart}-0-target-id"]`) - .setValue(`//*[@id="edit-${fieldIdPart}-0-target-id"]`, 'b') - .waitForElementVisible('//*[@id="ui-id-1"]', 10000) - .click('//*[@id="ui-id-1"]/*[1]/a'); - - return browser; - - // Select2 Auto-Complete widget. - case 'select2_entity_reference': - browser.select2.selectValue(fieldName, 'b', 1, 10000); - - return browser; - - // Entity browser widget. - case 'entity_browser_entity_reference': - browser.fillEntityBrowser( - fieldName, - fieldInfo.settings.entity_browser, - fieldInfo.settings.selection_mode, - ); - - return browser; - - // Paragraphs widget. - case 'paragraphs': - browser.paragraphs.autoCreate(fieldName, fieldInfo); - - return browser; - - // Inline entity form. - case 'inline_entity_form_simple': - if (typeof fieldInfo.inline_entity_form !== 'object') { - browser.perform(() => { - // eslint-disable-next-line no-console - console.log( - '\x1b[31m\x1b[1m%s\x1b[0m', - `Inline entity form information is not provided for field: ${fieldName}.`, - ); - }); - - return browser; - } - - browser.autoFillFields( - fieldInfo.inline_entity_form, - `${fieldName}[0][inline_entity_form]`, - ); - - return browser; - - default: - browser.perform(() => { - // eslint-disable-next-line no-console - console.log( - '\x1b[31m\x1b[1m%s\x1b[0m', - `Unsupported widget type: ${fieldInfo.type}`, - ); - }); - } - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/autoFillFields.js b/tests/src/Nightwatch/Commands/autoFillFields.js deleted file mode 100644 index 7c678f0b1..000000000 --- a/tests/src/Nightwatch/Commands/autoFillFields.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @file - * Automatically fill multiple fields with some random data. - * - * This provides a custom command, .autoFillFields() - * - * @param {{type: string}[]} fields - * The field information objects. - * @param {string} parent - * The parent path. Fe. "field_paragraphs[0][subform]" - * - * @return {object} - * The 'browser' object. - */ -exports.command = function autoFillFields(fields, parent = '') { - const browser = this; - const fieldNames = Object.keys(fields); - - fieldNames.forEach((fieldName) => { - browser.autoFillField( - parent.length === 0 ? fieldName : `${parent}[${fieldName}]`, - fields[fieldName], - ); - }); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/fillCKEditor.js b/tests/src/Nightwatch/Commands/fillCKEditor.js deleted file mode 100644 index 0e9b51048..000000000 --- a/tests/src/Nightwatch/Commands/fillCKEditor.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file - * Sets tag for element. It can be existing tag or new one. - * - * This provides a custom command, .fillCKEditor() - * - * @param {string} selector - * The element selector. - * @param {string} value - * The HTML value that will be filled to CKEditor. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function fillCKEditor(selector, value) { - const browser = this; - - browser.executeAsync( - // eslint-disable-next-line prefer-arrow-callback - function inBrowser(selectorInBrowser, valueInBrowser, done) { - const elem = document.evaluate(selectorInBrowser, document).iterateNext(); - - CKEDITOR.instances[jQuery(elem)[0].id].insertHtml(valueInBrowser); - - done(); - }, - [selector, value], - () => {}, - ); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/fillEntityBrowser.js b/tests/src/Nightwatch/Commands/fillEntityBrowser.js deleted file mode 100644 index fbd153a36..000000000 --- a/tests/src/Nightwatch/Commands/fillEntityBrowser.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file - * Automatically fill entity browser field widget in modal dialog. - * - * This provides a custom command, .fillEntityBrowser() - * - * TODO: Extend to accept list of entities to select. - * - * @param {string} fieldName - * The filed name. - * @param {string} entityBrowserName - * The entity browser name. - * @param {string} selectionMode - * The entity browser selection mode. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function fillEntityBrowser( - fieldName, - entityBrowserName, - selectionMode, -) { - const browser = this; - - const fieldIdPart = fieldName.replace(/[_[]/g, '-').replace(/]/g, ''); - const entityBrowserNameIdPart = entityBrowserName - .replace(/[_[]/g, '-') - .replace(/]/g, ''); - - // Handle multi and single select entity browser. - const submitSelector = - selectionMode === 'selection_edit' - ? '//*[starts-with(@id, "edit-use-selected")]' - : '//*[@id = "edit-submit"]'; - - browser - .scrollInViewAndClick( - `//*[starts-with(@id, "edit-${fieldIdPart}-entity-browser-entity-browser-open-modal")]`, - ) - .waitForElementVisible( - `//*[@id="entity_browser_iframe_${entityBrowserName}"]`, - 10000, - ) - .frame(`entity_browser_iframe_${entityBrowserName}`) - .waitForElementVisible( - `//*[@id="entity-browser-${entityBrowserNameIdPart}-form"]/div[1]/div[2]`, - 10000, - ) - .waitForElementVisible( - `//*[@id="entity-browser-${entityBrowserNameIdPart}-form"]/div[1]/div[2]/div[1]`, - 10000, - ) - .click( - `//*[@id="entity-browser-${entityBrowserNameIdPart}-form"]/div[1]/div[2]/div[1]`, - ) - .waitForElementVisible(submitSelector, 10000) - .click(submitSelector) - .frame() - .waitForElementVisible( - `//*[starts-with(@id, "edit-${fieldIdPart}-current-items-0")]`, - 10000, - ); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/paragraphs/add.js b/tests/src/Nightwatch/Commands/paragraphs/add.js deleted file mode 100644 index bc8c970c4..000000000 --- a/tests/src/Nightwatch/Commands/paragraphs/add.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file - * Create empty paragraph for defined paragraph type. - * - * This provides a custom command, .paragraphs.add() - * - * @param {string} fieldName - * The paragraphs field name. - * @param {string} type - * The paragraphs type. - * @param {int} position - * The position where paragraph should be added. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function add(fieldName, type, position) { - const browser = this; - - if (position < 1) { - browser.perform(() => { - // eslint-disable-next-line no-console - console.log( - '\x1b[31m\x1b[1m%s\x1b[0m', - `Paragraph position has to be 1 or bigger. Following value is provided: ${position}.`, - ); - }); - - return browser; - } - - const fieldNameId = fieldName.replace(/_/g, '-'); - const addButtonPosition = position * 2 - 1; - - browser - .scrollIntoMiddleOfView( - `//table[contains(@id, "${fieldNameId}-values")]/tbody/tr[${addButtonPosition}]//input`, - ) - .click( - `//table[contains(@id, "${fieldNameId}-values")]/tbody/tr[${addButtonPosition}]//input`, - ) - .click( - `//div[contains(@class, "ui-dialog-content")]/*[contains(@class, "paragraphs-add-dialog-list")]//*[@name="${fieldName}_${type}_add_more"]`, - ) - .waitForElementVisible( - `//table[contains(@id, "${fieldNameId}-values")]/tbody/tr[${ - addButtonPosition + 1 - }]//div[contains(@class, "ajax-new-content")]`, - 10000, - ); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/paragraphs/addImage.js b/tests/src/Nightwatch/Commands/paragraphs/addImage.js deleted file mode 100644 index 803a3218c..000000000 --- a/tests/src/Nightwatch/Commands/paragraphs/addImage.js +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file - * Create image paragraph. - * - * This provides a custom command, .paragraphs.addImage() - * - * Config can be following: - * { - * selectIndex: , - * uploadImage: '' - * } - * - * @param {string} fieldName - * The paragraphs field name. - * @param {int} position - * The position where paragraph should be added. - * @param {object} config - * The config for image paragraph. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function addImage(fieldName, position, config) { - const browser = this; - - const fieldNameId = fieldName.replace(/_/g, '-'); - const paragraphPosition = position * 2; - - browser.paragraphs.add(fieldName, 'image', position); - - browser - .waitForElementVisible( - `//table[contains(@id, "${fieldNameId}-values")]/tbody/tr[${paragraphPosition}]//*[contains(@id, "subform-field-image-entity-browser-entity-browser-open-modal")]`, - 10000, - ) - .click( - `//table[contains(@id, "${fieldNameId}-values")]/tbody/tr[${paragraphPosition}]//*[contains(@id, "subform-field-image-entity-browser-entity-browser-open-modal")]`, - ) - .waitForElementVisible( - '//*[@id="entity_browser_iframe_image_browser"]', - 10000, - ) - .frame('entity_browser_iframe_image_browser'); - - // Make selection of provided image index. - if (config.selectIndex) { - const { selectIndex } = config; - - browser - .waitForElementVisible( - `//*[@id="entity-browser-image-browser-form"]/div[1]/div[2]/div[${selectIndex}]/div[1]/span/img`, - 10000, - ) - .click( - `//*[@id="entity-browser-image-browser-form"]/div[1]/div[2]/div[${selectIndex}]`, - ); - } - - // Upload image and use it. - if (config.uploadImage) { - browser - .click('//a[text()="Import image"]') - .waitForElementVisible('//*[@id="edit-upload"]/div/a', 10000) - .executeAsync( - // eslint-disable-next-line prefer-arrow-callback - function inBrowser(done) { - const elem = document - .evaluate('//input[@type="file"]', document) - .iterateNext(); - - // Make upload field visible!!! This is workaround, so that we can - // use browser.setValue() later, to upload file. - jQuery(elem) - .show(0) - .css('visibility', 'visible') - .width(200) - .height(30) - .removeAttr('multiple'); - - done(); - }, - [], - () => {}, - ) - .setValue('//input[@type="file"]', config.uploadImage) - .waitForElementVisible( - '//*[contains(@id, "ajax-wrapper--")]/div/div/div[1]/div[1]/div/img', - 10000, - ); - } - - browser - .click('//*[@id="edit-submit"]') - .frame() - .waitForElementVisible( - `//table[contains(@id, "${fieldNameId}-values")]/tbody/tr[${paragraphPosition}]//img`, - 10000, - ); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/paragraphs/addInstagram.js b/tests/src/Nightwatch/Commands/paragraphs/addInstagram.js deleted file mode 100644 index 59e49c846..000000000 --- a/tests/src/Nightwatch/Commands/paragraphs/addInstagram.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file - * Create Instagram paragraph with provided URL. - * - * This provides a custom command, .paragraphs.addInstagram() - * - * @param {string} fieldName - * The paragraphs field name. - * @param {int} position - * The position where paragraph should be added. - * @param {string} url - * The URL for Instagram paragraph. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function addInstagram(fieldName, position, url) { - const browser = this; - - const fieldNameId = fieldName.replace(/_/g, '-'); - const paragraphPosition = position * 2; - - browser.paragraphs.add(fieldName, 'instagram', position); - - browser - .waitForElementVisible( - `//table[contains(@id, "${fieldNameId}-values")]/tbody/tr[${paragraphPosition}]//input[contains(@id, "subform-field-media-0-inline-entity-form-field-url-0-uri")]`, - 10000, - ) - .setValue( - `//table[contains(@id, "${fieldNameId}-values")]/tbody/tr[${paragraphPosition}]//input[contains(@id, "subform-field-media-0-inline-entity-form-field-url-0-uri")]`, - url, - ); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/paragraphs/addText.js b/tests/src/Nightwatch/Commands/paragraphs/addText.js deleted file mode 100644 index 818b07379..000000000 --- a/tests/src/Nightwatch/Commands/paragraphs/addText.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file - * Create text paragraph with provided HTML code. - * - * This provides a custom command, .paragraphs.addText() - * - * @param {string} fieldName - * The paragraphs field name. - * @param {int} position - * The position where paragraph should be added. - * @param {string} html - * The html for text paragraph. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function addText(fieldName, position, html) { - const browser = this; - - const fieldNameId = fieldName.replace(/_/g, '-'); - const paragraphPosition = position * 2; - - browser.paragraphs.add(fieldName, 'text', position); - - browser - .waitForElementVisible( - `//table[contains(@id, "${fieldNameId}-values")]/tbody/tr[${paragraphPosition}]//*[contains(@id, "subform-field-text-0-value")]//iframe`, - 10000, - ) - .fillCKEditor( - `//table[contains(@id, "${fieldNameId}-values")]/tbody/tr[${paragraphPosition}]//*[contains(@name, "[subform][field_text][0][value]")]`, - html, - ); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/paragraphs/autoCreate.js b/tests/src/Nightwatch/Commands/paragraphs/autoCreate.js deleted file mode 100644 index a7406761a..000000000 --- a/tests/src/Nightwatch/Commands/paragraphs/autoCreate.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file - * Create paragraphs for list of bundles and related fields. - * - * This provides a custom command, .paragraphs.autoCreate() - * - * @param {string} fieldName - * The paragraphs field name. - * @param {string} paragraphs - * The list of paragraph types and their fields. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function autoCreate(fieldName, paragraphs) { - const browser = this; - - const { target_type_distribution: paragraphBundles } = paragraphs; - let position = 1; - - Object.keys(paragraphBundles).forEach((bundleName) => { - const { instances, fields } = paragraphBundles[bundleName]; - - for (let i = 0; i < instances; i++) { - browser.paragraphs.add(fieldName, bundleName, position); - browser.autoFillFields(fields, `${fieldName}[${position - 1}][subform]`); - - position += 1; - } - }); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/performance/endMark.js b/tests/src/Nightwatch/Commands/performance/endMark.js deleted file mode 100644 index 7ef8d12f7..000000000 --- a/tests/src/Nightwatch/Commands/performance/endMark.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file - * Ends last performance measurement mark. - * - * This provides a custom command, .performance.endMark() - * - * @return {object} - * The 'browser' object. - */ -exports.command = function endMark() { - const browser = this; - - browser.performance.waitBrowser().perform(() => { - let span = browser.globals.apmSpans.pop(); - - if (!span) { - return; - } - - span.end(); - - // Set spanId to current active span, if there is any. - span = browser.globals.apmSpans.pop(); - - if (!span) { - return; - } - - browser.setCookie({ - domain: browser.globals.apmDomain, - httpOnly: false, - name: 'spanId', - path: '/', - value: span.id, - }); - browser.globals.apmSpans.push(span); - }); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/performance/endMeasurement.js b/tests/src/Nightwatch/Commands/performance/endMeasurement.js deleted file mode 100644 index 85727e3f4..000000000 --- a/tests/src/Nightwatch/Commands/performance/endMeasurement.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @file - * Ends performance measurement for a test. - * - * This provides a custom command, .performance.endMeasurement() - * - * @return {object} - * The 'browser' object. - */ -exports.command = function endMeasurement() { - const browser = this; - - browser.performance.waitBrowser(); - - browser - .perform(() => { - let span = browser.globals.apmSpans.pop(); - - while (span) { - span.end(); - - span = browser.globals.apmSpans.pop(); - } - }) - .perform(() => { - browser.globals.apmTrans.end(); - }); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/performance/setLabel.js b/tests/src/Nightwatch/Commands/performance/setLabel.js deleted file mode 100644 index eaed0d203..000000000 --- a/tests/src/Nightwatch/Commands/performance/setLabel.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @file - * Sets labels for performance test execution. - * - * This provides a custom command, .performance.setLabel() - * - * @param {string} name - * The label name. - * @param {string} value - * The label value. - * - * @return {object} - * The 'browser' object. - */ - -exports.command = function setLabel(name, value) { - const browser = this; - - browser.perform(() => { - browser.globals.apmTrans.setLabel(name, value); - }); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/performance/startMark.js b/tests/src/Nightwatch/Commands/performance/startMark.js deleted file mode 100644 index dda405f06..000000000 --- a/tests/src/Nightwatch/Commands/performance/startMark.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @file - * Sets performance measurement mark. - * - * This provides a custom command, .performance.startMark() - * - * @param {string} markName - * The mark name used for naming of time spans. - * - * @return {object} - * The 'browser' object. - */ - -exports.command = function startMark(markName) { - const browser = this; - - browser.perform(() => { - const span = browser.globals.apmTrans.startSpan(markName); - - span.setLabel('branch', process.env.THUNDER_BRANCH); - span.setLabel('test', browser.currentTest.name); - - browser.globals.apmSpans.push(span); - - browser.setCookie({ - domain: browser.globals.apmDomain, - httpOnly: false, - name: 'spanId', - path: '/', - value: span.id, - }); - }); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/performance/startMeasurement.js b/tests/src/Nightwatch/Commands/performance/startMeasurement.js deleted file mode 100644 index 073e0e93e..000000000 --- a/tests/src/Nightwatch/Commands/performance/startMeasurement.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file - * Start performance measurement for test. - * - * This provides a custom command, .performance.startMeasurement() - * - * @param {string} serverUrl - * The Elastic APM server URL. - * @param {string} serviceName - * The service name used to display time spans inside Kibana APM. - * @param {string} transactionName - * The transaction name used for tagging logged data. - * @param {string} domain - * The testing host domain name. - * - * @return {object} - * The 'browser' object. - */ - -exports.command = function startMeasurement( - serverUrl, - transactionName, - domain, -) { - const browser = this; - - browser.perform(() => { - if (!browser.apm.isStarted()) { - browser.apm.start({ serverUrl, serviceName: 'NightwatchJS - Test' }); - } - - browser.globals.apmDomain = domain; - browser.globals.apmTrans = browser.apm.startTransaction( - transactionName, - 'test', - ); - browser.globals.apmSpans = []; - - browser - // We need to open some URL before set cookie. - .drupalRelativeURL('/') - .setCookie({ - domain, - httpOnly: false, - path: '/', - name: 'traceId', - value: browser.globals.apmTrans.traceId, - }) - .setCookie({ - domain, - httpOnly: false, - path: '/', - name: 'serverUrl', - value: serverUrl, - }); - - // Label set on Node.JS APM agent should be also set for Browser APM agent. - browser.performance - .setLabel('branch', process.env.THUNDER_BRANCH) - .setCookie({ - domain, - httpOnly: false, - path: '/', - name: 'branchTag', - value: process.env.THUNDER_BRANCH, - }) - .performance.setLabel('test', browser.currentTest.name) - .setCookie({ - domain, - httpOnly: false, - path: '/', - name: 'testTag', - value: browser.currentTest.name, - }); - }); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/performance/waitBrowser.js b/tests/src/Nightwatch/Commands/performance/waitBrowser.js deleted file mode 100644 index 09c4a6c7d..000000000 --- a/tests/src/Nightwatch/Commands/performance/waitBrowser.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file - * Waits for browser performance metrics to be sent. - * - * This provides a custom command, .performance.waitBrowser() - * - * @param {int} maxWait - * The maximum time for waiting for browser to send data to APM Server. - * Default to 10000 ms. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function waitBrowser(maxWait) { - const browser = this; - - maxWait = maxWait || 10000; - - browser.timeoutsAsyncScript(maxWait).executeAsync( - // eslint-disable-next-line prefer-arrow-callback - function inBrowser(done) { - const checkBrowserTransaction = () => { - if (typeof elasticApm === 'undefined') { - setTimeout(checkBrowserTransaction, 100); - - return; - } - - const transaction = window.elasticApm.getCurrentTransaction(); - if (!transaction) { - setTimeout(checkBrowserTransaction, 100); - - return; - } - - if (transaction.type === 'page-load' && !transaction.ended) { - setTimeout(checkBrowserTransaction, 100); - - return; - } - - // TODO: Ensure that not page-load transactions are also sent before navigating to new page! - setTimeout(done, 0); - }; - - setTimeout(checkBrowserTransaction, 200); - }, - [], - () => {}, - ); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/scrollInViewAndClick.js b/tests/src/Nightwatch/Commands/scrollInViewAndClick.js deleted file mode 100644 index 9db8e3940..000000000 --- a/tests/src/Nightwatch/Commands/scrollInViewAndClick.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @file - * Helper function to scroll element in center of page and click it. - * - * This provides a custom command, .scrollInViewAndClick() - * - * @param {string} selector - * The XPATH selector for the element. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function scrollInViewAndClick(selector) { - const browser = this; - - browser.scrollIntoMiddleOfView(selector).click(selector); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/scrollIntoMiddleOfView.js b/tests/src/Nightwatch/Commands/scrollIntoMiddleOfView.js deleted file mode 100644 index 11f32e071..000000000 --- a/tests/src/Nightwatch/Commands/scrollIntoMiddleOfView.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file - * Scroll element into center of the screen, so that it's visible and clickable. - * - * NOTE: This function works only with XPATH!!! - * - * This provides a custom command, .scrollIntoMiddleOfView() - * - * @param {string} selector - * The XPATH selector for element. - * - * @return {object} - * The 'browser' object. - */ -exports.command = function scrollIntoMiddleOfView(selector) { - const browser = this; - - browser.executeAsync( - // eslint-disable-next-line prefer-arrow-callback - function inBrowser(selectorInBrowser, done) { - const elem = document.evaluate(selectorInBrowser, document).iterateNext(); - const viewPortHeight = Math.max( - document.documentElement.clientHeight, - window.innerHeight || 0, - ); - const element = jQuery(elem); - const scrollTop = element.offset().top - viewPortHeight / 2; - const scrollableParent = jQuery.isFunction(element.scrollParent) - ? element.scrollParent() - : []; - if ( - scrollableParent.length > 0 && - scrollableParent[0] !== document && - scrollableParent[0] !== document.body - ) { - scrollableParent[0].scrollTop = scrollTop; - } else { - window.scroll(0, scrollTop); - } - - done(); - }, - [selector], - () => {}, - ); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/select2/selectValue.js b/tests/src/Nightwatch/Commands/select2/selectValue.js deleted file mode 100644 index bd1e86c35..000000000 --- a/tests/src/Nightwatch/Commands/select2/selectValue.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file - * Select an element after search. - * - * This provides a custom command, .select2.selectValue() - * - * @param {string} field - * The field name. - * @param {string} search - * The element to search for. - * @param {int} index - * The index to select from list after search. - * @param {int} searchWait - * The wait time for search result in milliseconds. Default: 5000 - * - * @return {object} - * The 'browser' object. - */ -exports.command = function selectValue( - field, - search, - index, - searchWait = 5000, -) { - const browser = this; - const fieldIdPart = field.replace(/_/g, '-'); - - browser - .setValue(`//*[@id="edit-${fieldIdPart}-wrapper"]//input`, search) - .waitForElementVisible( - `//*[@id="select2-edit-${fieldIdPart}-results"]/li[${index}]`, - searchWait, - ) - .click(`//*[@id="select2-edit-${fieldIdPart}-results"]/li[${index}]`); - - return browser; -}; diff --git a/tests/src/Nightwatch/Commands/select2/setValue.js b/tests/src/Nightwatch/Commands/select2/setValue.js deleted file mode 100644 index af03871a5..000000000 --- a/tests/src/Nightwatch/Commands/select2/setValue.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @file - * Sets tag for element. It can be existing tag or new one. - * - * This provides a custom command, .select2.setValue() - * - * @param {string} field - * The element selector. - * @param {string} name - * The tag name. - * @param {string} waitFor - * The element selector that should be waited for. - * @param {int} wait - * The wait time in milliseconds. Default: 5000 - * - * @return {object} - * The 'browser' object. - */ -exports.command = function setValue(field, name, waitFor, wait = 5000) { - const browser = this; - - browser - .setValue(field, name) - .waitForElementVisible(waitFor, wait) - .keys([browser.Keys.ENTER]); - - return browser; -}; diff --git a/tests/src/Nightwatch/Tests/ArticleCreate.js b/tests/src/Nightwatch/Tests/ArticleCreate.js deleted file mode 100644 index 13b13c800..000000000 --- a/tests/src/Nightwatch/Tests/ArticleCreate.js +++ /dev/null @@ -1,196 +0,0 @@ -/** - * @file - * Testing of an article creation with 15 paragraphs. - */ - -/** - * Module "elastic-apm-node" has to be installed for core. - * - * You can use Yarn command for that: yarn add elastic-apm-node --dev - * and it will install that module with it's requirements. - * - * We are using "process.cwd()" to get core directory. - */ -// eslint-disable-next-line import/no-dynamic-require -const apm = require(`${process.cwd()}/node_modules/elastic-apm-node`); - -module.exports = { - '@tags': ['Thunder'], - before(browser, done) { - browser.apm = apm; - - done(); - }, - createAnArticleWithParagraphs(browser) { - browser - .resizeWindow(1024, 1024) - .performance.startMeasurement( - process.env.THUNDER_APM_URL, - 'Create an article with paragraphs', - `.${process.env.THUNDER_SITE_HOSTNAME}`, - ) - .performance.startMark('full task') - .performance.startMark('login') - .drupalLogin({ name: 'test-editor', password: 'test-editor' }) - .performance.endMark() - - .performance.startMark('create article') - .drupalRelativeURL('/node/add/article') - // Start using XPATH!!! - .useXpath() - .waitForElementVisible('//*[@id="field-paragraphs-values"]', 1000) - // Set base vaues for an Article. - .performance.startMark('create article basic fields') - .click('//*[@id="edit-field-channel"]/option[3]') - .setValue( - '//*[@id="edit-title-0-value"]', - 'Lorem Cat Sum 10. Reasons why cats ipsum', - ) - .setValue( - '//*[@id="edit-field-seo-title-0-value"]', - `10 Reasons why cats ${Math.random().toString(36)}`, - ) - .select2.setValue( - '//*[@id="edit-field-tags-wrapper"]//input', - 'Performance', - '//*[@id="select2-edit-field-tags-results"]/li[contains(@class, "highlighted")]', - ) - .select2.setValue( - '//*[@id="edit-field-tags-wrapper"]//input', - 'Testing', - '//*[@id="select2-edit-field-tags-results"]/li[contains(@class, "highlighted")]', - ) - .select2.setValue( - '//*[@id="edit-field-tags-wrapper"]//input', - 'Cats', - '//*[@id="select2-edit-field-tags-results"]/li[contains(@class, "highlighted")]', - ) - .performance.endMark() - - // Set teaser information for an Article. - .performance.startMark('create article teaser information') - .setValue( - '//*[@id="edit-field-teaser-text-0-value"]', - 'The cat (Felis catus) is a small carnivorous mammal. It is the only domesticated species in the family Felidae and often referred to as the domestic cat to distinguish it from wild members of the family. The cat is either a house cat, kept as a pet, or a feral cat, freely ranging and avoiding human contact.[5] A house cat is valued by humans for companionship and for its ability to hunt rodents. About 60 cat breeds are recognized by various cat registries.', - ) - .click( - '//*[@id="edit-field-teaser-media-entity-browser-entity-browser-open-modal"]', - ) - .waitForElementVisible( - '//*[@id="entity_browser_iframe_image_browser"]', - 10000, - ) - .frame('entity_browser_iframe_image_browser') - .waitForElementVisible( - '//*[@id="entity-browser-image-browser-form"]/div[1]/div[2]/div[13]/div[1]/span/img', - 10000, - ) - .click( - '//*[@id="entity-browser-image-browser-form"]/div[1]/div[2]/div[13]', - ) - .click('//*[@id="edit-submit"]') - .frame() - .waitForElementVisible( - '//*[contains(@id, "edit-field-teaser-media-current-items-0")]/article/div/img', - 10000, - ) - .performance.endMark() - - // Create paragraphs for an Article. - .performance.startMark('create paragraphs') - .performance.startMark('create paragraphs - set 1') - .paragraphs.addText( - 'field_paragraphs', - 1, - '

1: Lorem ipsum dolor sit amet

an est tacimates molestiae, vel eu animal suscipit. Populo accusam ad has, cu libris disputando voluptatibus ius, feugiat nusquam instructior id pro?

Vel possim invidunt ex, est facer erant phaedrum ea? Ei ancillae detraxit mei, antiopam euripidis vim in? Vel ea amet movet fastidii. Magna oratio molestie eum ea, ius cu odio cibo?

', - ) - .paragraphs.addImage('field_paragraphs', 2, { - selectIndex: 14, - }) - .paragraphs.addInstagram( - 'field_paragraphs', - 3, - 'https://www.instagram.com/p/BtlH0ysgGLs/?utm_source=ig_web_copy_link', - ) - .performance.endMark() - - .performance.startMark('create paragraphs - set 2') - .paragraphs.addText( - 'field_paragraphs', - 4, - '

2: Ex cotidieque intellegebat nec

quo cu quis ridens, ei cibo omnes complectitur duo. Cu sed deleniti indoctum assueverit. Elit eligendi senserit eu nam. Velit delectus ut cum, no vim habeo veniam mentitum, eos id eros senserit.

', - ) - .paragraphs.addImage('field_paragraphs', 5, { - selectIndex: 13, - }) - .paragraphs.addInstagram( - 'field_paragraphs', - 6, - 'https://www.instagram.com/p/BtSRBAgAYod/?utm_source=ig_web_copy_link', - ) - .performance.endMark() - - .performance.startMark('create paragraphs - set 3') - .paragraphs.addText( - 'field_paragraphs', - 7, - '

3: Ne cum copiosae praesent, feugait quaestio inciderint eos ad.

Odio salutatus constituto eam ea. Mel zril cotidieque dissentiunt ea, erant inimicus convenire sit cu, ea nam oratio vituperatoribus. Noster invenire instructior ex pro. Duo ad mutat fierent.

', - ) - .paragraphs.addImage('field_paragraphs', 8, { - selectIndex: 12, - }) - .paragraphs.addInstagram( - 'field_paragraphs', - 9, - 'https://www.instagram.com/p/BtH8DB3g3GL/?utm_source=ig_web_copy_link', - ) - .performance.endMark() - - .performance.startMark('create paragraphs - set 4') - .paragraphs.addText( - 'field_paragraphs', - 10, - '

4: Commune accumsan deleniti ad duo, cum cibo lorem delicatissimi ex!

Cum mundi nostro forensibus id. At eos elitr fabulas intellegebat! Eleifend praesent mea no, id stet deseruisse pro!

', - ) - .paragraphs.addImage('field_paragraphs', 11, { - selectIndex: 13, - }) - .paragraphs.addInstagram( - 'field_paragraphs', - 12, - 'https://www.instagram.com/p/Btv_rtKF8mU/?utm_source=ig_web_copy_link', - ) - .performance.endMark() - - .performance.startMark('create paragraphs - set 5') - .paragraphs.addText( - 'field_paragraphs', - 13, - '

5: Ex persecuti argumentum pri, phaedrum cotidieque mel te?

Vix choro nusquam molestiae eu. Pro ei prodesset honestatis, an duo omnes dictas meliore. Fastidii reformidans sea ne. Modus mucius per et, audiam partiendo eu sea! Eam ea augue signiferumque.

', - ) - .paragraphs.addImage('field_paragraphs', 14, { - selectIndex: 14, - }) - .paragraphs.addInstagram( - 'field_paragraphs', - 15, - 'https://www.instagram.com/p/BtSRBAgAYod/?utm_source=ig_web_copy_link', - ) - - // End creation of paragraphs - // Close: create paragraphs - set 5. - .performance.endMark() - // Close: create paragraphs. - .performance.endMark() - - // Submit form. - .click('//*[@id="edit-submit"]') - .waitForElementVisible( - '//*[@id="block-thunder-base-content"]/div/article/div/div[1]/div[13]/div/div/p[1]/strong/span', - 60000, - ) - .performance.endMeasurement(); - - browser.end(); - }, -}; diff --git a/tests/src/Nightwatch/Tests/AutoCompleteField.js b/tests/src/Nightwatch/Tests/AutoCompleteField.js deleted file mode 100644 index 0d9220c70..000000000 --- a/tests/src/Nightwatch/Tests/AutoCompleteField.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file - * Testing of auto-complete field. - */ - -// eslint-disable-next-line import/no-dynamic-require -const apm = require(`${process.cwd()}/node_modules/elastic-apm-node`); -const thunderUtils = require('../utils'); - -module.exports = { - '@tags': ['Thunder', 'Thunder_Base_Set'], - before(browser, done) { - browser.apm = apm; - - // Get site information for field with autocomplete field. - thunderUtils.setSiteInfo( - 'test-admin', - 'test-admin', - { - rule: 'number_of_fields', - index: 3, - }, - browser, - done, - ); - }, - autoCompleteField(browser) { - const { bundle } = browser._site_info; - - browser - .resizeWindow(1024, 1024) - .performance.startMeasurement( - process.env.THUNDER_APM_URL, - 'Auto complete field', - `.${process.env.THUNDER_SITE_HOSTNAME}`, - ) - .drupalLogin({ name: 'test-admin', password: 'test-admin' }) - .useXpath(); - - browser - .drupalRelativeURL(`/node/add/${bundle}`) - .waitForElementVisible('//*[@id="edit-submit"]', 1000); - - browser.performance - .startMark('Select a first value') - .select2.selectValue('field_22', 'bund', 2, 10000) - .performance.endMark(); - - browser.performance - .startMark('Select a second value') - .select2.selectValue('field_22', 'bund', 4, 10000) - .performance.endMark(); - - browser.performance.endMeasurement(); - browser.end(); - }, -}; diff --git a/tests/src/Nightwatch/Tests/ContentOverviewFiltering.js b/tests/src/Nightwatch/Tests/ContentOverviewFiltering.js deleted file mode 100644 index 629f5aeaa..000000000 --- a/tests/src/Nightwatch/Tests/ContentOverviewFiltering.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file - * Testing of content overview filtering. - */ - -// eslint-disable-next-line import/no-dynamic-require -const apm = require(`${process.cwd()}/node_modules/elastic-apm-node`); - -module.exports = { - '@tags': ['Thunder', 'Thunder_Base_Set'], - before(browser, done) { - browser.apm = apm; - - done(); - }, - contentOverviewFiltering(browser) { - browser - .resizeWindow(1024, 1024) - .performance.startMeasurement( - process.env.THUNDER_APM_URL, - 'Filtering of content overview', - `.${process.env.THUNDER_SITE_HOSTNAME}`, - ) - .performance.startMark('full task') - .performance.startMark('login') - .drupalLogin({ name: 'test-admin', password: 'test-admin' }) - // End "login". - .performance.endMark() - .performance.startMark('Open content overview page') - .drupalRelativeURL('/admin/t0_node_bundle_0') - .useXpath() - .waitForElementPresent( - '//*[@id="block-thunder-admin-content"]/div/div/nav/ul/li[1]/a', - ) - // End "Open content overview page". - .performance.endMark() - .performance.startMark('Filter by type') - .setValue('//*[@id="edit-type"]', 'bundle_6') - .click('//*[@id="edit-submit-t0-node-bundle-0"]') - .waitForElementPresent( - '//*[@id="block-thunder-admin-content"]/div/div/nav[@class="pager"]/ul/li[1]/a[contains(@href, "bundle_6")]', - ) - // End "Filter by type". - .performance.endMark() - // End full task. - .performance.endMark(); - - // End measurement transaction for whole test. - browser.performance.endMeasurement(); - - browser.end(); - }, -}; diff --git a/tests/src/Nightwatch/Tests/CreateMostUsedContent.js b/tests/src/Nightwatch/Tests/CreateMostUsedContent.js deleted file mode 100644 index 45f46f39d..000000000 --- a/tests/src/Nightwatch/Tests/CreateMostUsedContent.js +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file - * Testing of content creation for most used bundle type. - */ - -/** - * Module "elastic-apm-node" has to be installed for core. - * - * You can use Yarn command for that: yarn add elastic-apm-node --dev - * and it will install that module with it's requirements. - * - * We are using "process.cwd()" to get core directory. - */ - -// eslint-disable-next-line import/no-dynamic-require -const apm = require(`${process.cwd()}/node_modules/elastic-apm-node`); -const thunderUtils = require('../utils'); -const thunderConfig = require('../config'); - -module.exports = { - '@tags': ['Thunder', 'Thunder_Base_Set'], - before(browser, done) { - browser.apm = apm; - - // Get site information. - thunderUtils.setSiteInfo( - 'test-admin', - 'test-admin', - { - rule: 'count', - index: 0, - percent_of_instances_threshold: 50, - }, - browser, - done, - ); - }, - createMostUsedContent(browser) { - const { bundle, fields } = browser._site_info; - - // Discover test set name for current test. - const testSetName = thunderUtils.getTestSetName( - browser._site_info, - browser.currentTest.name, - ); - - // We have to filter returned fields, because we always have 100% threshold. - const filteredFields = thunderUtils.filterObject( - fields, - thunderConfig.createMostUsedContent[testSetName].fieldsToFill, - ); - - browser - .resizeWindow(1024, 1024) - .performance.startMeasurement( - process.env.THUNDER_APM_URL, - 'Create new most used content (min)', - `.${process.env.THUNDER_SITE_HOSTNAME}`, - ) - .performance.startMark('full task') - .performance.startMark('login') - .drupalLogin({ name: 'test-admin', password: 'test-admin' }) - .performance.endMark() - - .performance.startMark('create new most used content') - .drupalRelativeURL(`/node/add/${bundle}`) - // Start using XPATH!!! - .useXpath() - .waitForElementVisible('//*[@id="edit-submit"]', 10000) - - // Fill fields for content bundle. - .performance.startMark('fill fields') - .autoFillFields(filteredFields) - .performance.endMark(); - - // Close mark and save newly created content entity. - browser.performance - .endMark() - - // Submit form. - .click('//*[@id="edit-submit"]') - .waitForElementVisible( - '//*[@id="block-thunder-base-page-title"]/div[2]/h1/span', - 60000, - ) - .performance.endMeasurement(); - - browser.end(); - }, -}; diff --git a/tests/src/Nightwatch/Tests/EditMostUsedContent.js b/tests/src/Nightwatch/Tests/EditMostUsedContent.js deleted file mode 100644 index 328ba8a3a..000000000 --- a/tests/src/Nightwatch/Tests/EditMostUsedContent.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @file - * Testing of editing for most used bundle type. - */ - -// eslint-disable-next-line import/no-dynamic-require -const apm = require(`${process.cwd()}/node_modules/elastic-apm-node`); -const thunderUtils = require('../utils'); - -module.exports = { - '@tags': ['Thunder', 'Thunder_Base_Set'], - before(browser, done) { - browser.apm = apm; - - // Get site information. - thunderUtils.setSiteInfo( - 'test-admin', - 'test-admin', - { - rule: 'count', - index: 0, - }, - browser, - done, - ); - }, - editMostUsedContent(browser) { - const { bundle, fields } = browser._site_info; - - browser - .resizeWindow(1024, 1024) - .performance.startMeasurement( - process.env.THUNDER_APM_URL, - 'Edit most used content (min)', - `.${process.env.THUNDER_SITE_HOSTNAME}`, - ) - .drupalLogin({ name: 'test-admin', password: 'test-admin' }) - .useXpath() - .drupalRelativeURL(`/admin/content?type=${bundle}`) - - .performance.startMark('full task') - .performance.startMark('load form') - .click( - '(//li[contains(@class,"dropbutton-action")])[1]//a[contains(@href, "edit")]', - ) - .waitForElementVisible('//*[@id="edit-submit"]', 1000) - .performance.endMark() // "load form" task. - - .autoFillFields(fields) - - .performance.startMark('submit save form') - .click('//*[@id="edit-submit"]') - .waitForElementVisible('//*[@id="block-thunder-admin-content"]', 10000) - .performance.endMark() // "submit save form" task. - - .performance.endMark() // "full task" task. - - .performance.endMeasurement(); - - browser.end(); - }, -}; diff --git a/tests/src/Nightwatch/Tests/SearchApiContentOverviewFiltering.js b/tests/src/Nightwatch/Tests/SearchApiContentOverviewFiltering.js deleted file mode 100644 index 65b2d33bc..000000000 --- a/tests/src/Nightwatch/Tests/SearchApiContentOverviewFiltering.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file - * Testing of content overview filtering with a search api based view. - */ - -// eslint-disable-next-line import/no-dynamic-require -const apm = require(`${process.cwd()}/node_modules/elastic-apm-node`); - -module.exports = { - '@tags': ['Thunder', 'Thunder_Base_Set'], - before(browser, done) { - browser.apm = apm; - - done(); - }, - searchApiContentOverviewFiltering(browser) { - browser - .resizeWindow(1024, 1024) - .performance.startMeasurement( - process.env.THUNDER_APM_URL, - 'Filtering of content overview', - `.${process.env.THUNDER_SITE_HOSTNAME}`, - ) - .performance.startMark('full task') - .performance.startMark('login') - .drupalLogin({ name: 'test-admin', password: 'test-admin' }) - // End "login". - .performance.endMark() - .performance.startMark('Open content overview page') - .drupalRelativeURL('/admin/t1_node_bundle_0/node') - .useXpath() - .waitForElementPresent( - '//*[@id="block-thunder-admin-content"]/div/div/nav/ul/li[1]/a', - ) - // End "Open content overview page". - .performance.endMark() - .performance.startMark('Filter by type') - .moveToElement('//*[@id="block-t1-node-bundle-0-type"]', 10, 10) - .click( - '//*[@id="block-t1-node-bundle-0-type"]/div/span/span[1]/span/span[2]/b', - ) - .click( - '//*[@class="select2-results__options"]/li[contains(@data-select2-id, "bundle_6")]', - ) - .waitForElementPresent( - '//*[@id="block-thunder-admin-content"]/div/div[contains(@class, "view-t1-node-bundle-0")]/nav[@class="pager"]/ul/li[1]/a[contains(@href, "bundle_6")]', - ) - // End "Filter by type". - .performance.endMark() - // End full task. - .performance.endMark(); - - // End measurement transaction for whole test. - browser.performance.endMeasurement(); - - browser.end(); - }, -}; diff --git a/tests/src/Nightwatch/config.js b/tests/src/Nightwatch/config.js deleted file mode 100644 index 279692339..000000000 --- a/tests/src/Nightwatch/config.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Configuration for Thunder Nightwatch tests. - */ - -module.exports = { - createMostUsedContent: { - testSetFootprint: { - // Order of test sets is important, because first matched will be used. - Thunder_Base_Set: [ - ['fields', 'field_13', 'third_party_settings', 'paragraphs_features'], - ], - Thunder: [['bundle']], - }, - Thunder_Base_Set: { - fieldsToFill: { - title: true, // required - field_2: true, // required - field_13: { - bundle_0: { - field_4: true, - field_6: true, - }, - bundle_2: { - field_4: true, - field_7: true, - field_12: true, - }, - bundle_4: { - field_4: true, - field_12: { - name: true, - field_1: true, - field_2: true, - }, - }, - bundle_8: { - field_4: true, - field_7: true, - }, - }, // optional - paragraphs - field_18: true, // required - field_23: true, // required - }, - }, - Thunder: { - fieldsToFill: { - title: true, - body: true, - }, - }, - }, -}; diff --git a/tests/src/Nightwatch/utils.js b/tests/src/Nightwatch/utils.js deleted file mode 100644 index 64131c68e..000000000 --- a/tests/src/Nightwatch/utils.js +++ /dev/null @@ -1,89 +0,0 @@ -// eslint-disable-next-line import/no-dynamic-require -const request = require(`${process.cwd()}/node_modules/request`); -const thunderConfig = require('./config'); - -module.exports = { - setSiteInfo(adminUser, adminPass, queryParams, browser, browserDoneCallback) { - const baseUrl = process.env.DRUPAL_TEST_BASE_URL; - - request( - { - url: `${baseUrl}/user/login?_format=json`, - method: 'POST', - body: JSON.stringify({ name: adminUser, pass: adminPass }), - headers: { - 'Content-type': 'application/json', - }, - jar: true, - }, - () => { - request( - { - url: `${baseUrl}/thunder-performance-measurement/site-info`, - qs: queryParams, - jar: true, - }, - (error, response, body) => { - const { data } = JSON.parse(body); - - browser._site_info = data; - - browserDoneCallback(); - }, - ); - }, - ); - }, - - /** - * Find test set name based on defined footprint in config. - * - * @param {object} data - * The site info object. - * @param {string} testName - * The test name. - * - * @return {string|undefined} - * Returns found test set name. - */ - getTestSetName(data, testName) { - const { testSetFootprint } = thunderConfig[testName]; - - return Object.keys(testSetFootprint).find((testSetName) => - testSetFootprint[testSetName].find( - (objectPath) => - objectPath.reduce( - (obj, key) => (obj && obj[key] ? obj[key] : null), - data, - ) !== null, - ), - ); - }, - - filterObject(data, filterBy) { - return Object.keys(data).reduce((result, key) => { - if (Object.keys(filterBy).includes(key)) { - result[key] = data[key]; - } - - // Filter nested objects only if we have nested filter definition. - if (typeof filterBy[key] !== 'object') { - return result; - } - - // Filter custom sub-from fields. - ['target_type_distribution', 'fields', 'inline_entity_form'].forEach( - (filterKey) => { - if (typeof data[key][filterKey] === 'object') { - result[key][filterKey] = this.filterObject( - data[key][filterKey], - filterBy[key], - ); - } - }, - ); - - return result; - }, {}); - }, -};