diff --git a/tests/e2e/configs/mocharc.ts b/tests/e2e/configs/mocharc.ts index cbd793d69a16..c4ee63d4ab9c 100644 --- a/tests/e2e/configs/mocharc.ts +++ b/tests/e2e/configs/mocharc.ts @@ -21,8 +21,9 @@ module.exports = { timeout: MOCHA_CONSTANTS.MOCHA_DEFAULT_TIMEOUT, slow: 60000, reporter: 'mocha-multi-reporters', - reporterOptions: 'configFile=configs/reporters-config.json', + reporterOptions: 'configFile=configs/reporters.config.js', ui: 'tdd', + extension: ['js', 'cjs', 'mjs'], require: ['dist/specs/MochaHooks.js', 'ts-node/register'], bail: MOCHA_CONSTANTS.MOCHA_BAIL, 'full-trace': true, diff --git a/tests/e2e/configs/reporters-config.json b/tests/e2e/configs/reporters-config.json deleted file mode 100644 index 82a75b921ddc..000000000000 --- a/tests/e2e/configs/reporters-config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "reporterEnabled": "allure-mocha,dist/utils/CheReporter.js", - "allureMochaReporterOptions": { - "resultsDir": ".allure-results" - } -} diff --git a/tests/e2e/configs/reporters.config.js b/tests/e2e/configs/reporters.config.js new file mode 100644 index 000000000000..c73c9b1da5c7 --- /dev/null +++ b/tests/e2e/configs/reporters.config.js @@ -0,0 +1,42 @@ +/** ******************************************************************* + * copyright (c) 2023 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ +const { REPORTER_CONSTANTS } = require('../constants/REPORTER_CONSTANTS'); +const { BASE_TEST_CONSTANTS } = require('../constants/BASE_TEST_CONSTANTS'); + +module.exports = { + reporterEnabled: REPORTER_CONSTANTS.REPORTERS_ENABLED(), + allureMochaReporterOptions: { + resultsDir: '.allure-results' + }, + reportportalAgentJsMochaReporterOptions: { + apiKey: REPORTER_CONSTANTS.RP_API_KEY, + endpoint: REPORTER_CONSTANTS.PR_ENDPOINT(), + project: REPORTER_CONSTANTS.RP_PROJECT(), + launch: `${REPORTER_CONSTANTS.RP_LAUNCH_NAME}`, + attributes: [ + { + key: 'build', + value: `${BASE_TEST_CONSTANTS.TESTING_APPLICATION_VERSION}` + }, + { + value: BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME() + }, + { + key: 'url', + value: BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL + } + ], + rerun: REPORTER_CONSTANTS.RP_RERUN(), + rerunOf: REPORTER_CONSTANTS.RP_RERUN_UUID, + restClientConfig: { + timeout: 1200000 + } + } +}; diff --git a/tests/e2e/constants/BASE_TEST_CONSTANTS.ts b/tests/e2e/constants/BASE_TEST_CONSTANTS.ts index 886219f18a86..ed1891b8ae2f 100644 --- a/tests/e2e/constants/BASE_TEST_CONSTANTS.ts +++ b/tests/e2e/constants/BASE_TEST_CONSTANTS.ts @@ -30,6 +30,7 @@ export const BASE_TEST_CONSTANTS: { TS_SELENIUM_PROJECT_ROOT_FILE_NAME: string; TS_SELENIUM_REQUEST_INTERCEPTOR: boolean; TS_SELENIUM_RESPONSE_INTERCEPTOR: boolean; + TESTING_APPLICATION_NAME: () => string; } = { /** * base URL of the application which should be checked @@ -51,6 +52,17 @@ export const BASE_TEST_CONSTANTS: { */ TEST_ENVIRONMENT: process.env.TEST_ENVIRONMENT || '', + /** + * application name (DevSpaces or Che) + */ + TESTING_APPLICATION_NAME: (): string => { + return BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('devspaces') + ? 'devspaces' + : BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('che') + ? 'che' + : 'default'; + }, + /** * testing application version */ diff --git a/tests/e2e/constants/MOCHA_CONSTANTS.ts b/tests/e2e/constants/MOCHA_CONSTANTS.ts index 04a0fbc6c703..3b513a64a324 100644 --- a/tests/e2e/constants/MOCHA_CONSTANTS.ts +++ b/tests/e2e/constants/MOCHA_CONSTANTS.ts @@ -26,7 +26,7 @@ export const MOCHA_CONSTANTS: { MOCHA_DELAYED_SUITE: process.env.MOCHA_DELAYED_SUITE === 'true', - MOCHA_DEFAULT_TIMEOUT: process.env.MOCHA_DEFAULT_TIMEOUT || 420000, + MOCHA_DEFAULT_TIMEOUT: Number(process.env.MOCHA_DEFAULT_TIMEOUT) || 420000, MOCHA_RETRIES: process.env.MOCHA_RETRIES || BASE_TEST_CONSTANTS.TEST_ENVIRONMENT === '' ? 0 : 2, diff --git a/tests/e2e/constants/REPORTER_CONSTANTS.ts b/tests/e2e/constants/REPORTER_CONSTANTS.ts index b9b566585a64..152a46825738 100644 --- a/tests/e2e/constants/REPORTER_CONSTANTS.ts +++ b/tests/e2e/constants/REPORTER_CONSTANTS.ts @@ -7,14 +7,28 @@ * * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ +import { BASE_TEST_CONSTANTS } from './BASE_TEST_CONSTANTS'; + export const REPORTER_CONSTANTS: { + DELETE_SCREENCAST_IF_TEST_PASS: boolean; + PR_ENDPOINT(): string; + PR_IS_LOCAL_SERVER: boolean; + REPORTERS_ENABLED(): string; + RP_API_KEY: string; + RP_PROJECT(): string; + RP_RERUN(): boolean; + RP_RERUN_UUID: string | undefined; + RP_LAUNCH_NAME: string; + RP_USER: string; + RP_USE_PERSONAL: boolean; + SAVE_ALLURE_REPORT_DATA: boolean; + SAVE_PR_REPORT_DATA: boolean; TS_SELENIUM_DELAY_BETWEEN_SCREENSHOTS: number; - TS_SELENIUM_REPORT_FOLDER: string; TS_SELENIUM_EXECUTION_SCREENCAST: boolean; - TS_SELENIUM_PRINT_TIMEOUT_VARIABLES: string | boolean; TS_SELENIUM_LOAD_TEST_REPORT_FOLDER: string; TS_SELENIUM_LOG_LEVEL: string; - DELETE_SCREENCAST_IF_TEST_PASS: boolean; + TS_SELENIUM_PRINT_TIMEOUT_VARIABLES: string | boolean; + TS_SELENIUM_REPORT_FOLDER: string; } = { /** * path to folder with load tests execution report. @@ -44,10 +58,89 @@ export const REPORTER_CONSTANTS: { /** * log level settings, possible variants: 'INFO' (by default), 'DEBUG', 'TRACE'. */ - TS_SELENIUM_LOG_LEVEL: process.env.TS_SELENIUM_LOG_LEVEL || 'INFO', + TS_SELENIUM_LOG_LEVEL: process.env.TS_SELENIUM_LOG_LEVEL || 'TRACE', /** * print all timeout variables when tests launch, default to false */ - TS_SELENIUM_PRINT_TIMEOUT_VARIABLES: process.env.TS_SELENIUM_PRINT_TIMEOUT_VARIABLES || false + TS_SELENIUM_PRINT_TIMEOUT_VARIABLES: process.env.TS_SELENIUM_PRINT_TIMEOUT_VARIABLES === 'true', + + /** + * use local Allure reporter, default to false + */ + SAVE_ALLURE_REPORT_DATA: process.env.SAVE_ALLURE_REPORT_DATA === 'true', + + /** + * use ReportPortal reporter, default to true + */ + SAVE_PR_REPORT_DATA: process.env.SAVE_PR_REPORT_DATA !== 'false', + + /** + * list of enabler reporters + */ + REPORTERS_ENABLED: (): string => { + let reporters: string = 'dist/utils/CheReporter.js'; + if (REPORTER_CONSTANTS.SAVE_ALLURE_REPORT_DATA) { + reporters += ',allure-mocha'; + } + if (REPORTER_CONSTANTS.SAVE_PR_REPORT_DATA) { + reporters += ',@reportportal/agent-js-mocha'; + } + return reporters; + }, + + /** + * reportPortal app key or user token + */ + RP_API_KEY: process.env.RP_API_KEY || '', + + /** + * user name on ReportPortal + */ + RP_USER: process.env.RP_USER || process.env.USER || 'superadmin', + + /** + * launch name to save report + */ + RP_LAUNCH_NAME: process.env.RP_LAUNCH_NAME || 'Test run', + + /** + * launch name to save report + */ + RP_RERUN_UUID: process.env.RP_RERUN_UUID || undefined, + + /** + * is launch rerun + */ + RP_RERUN: (): boolean => !!REPORTER_CONSTANTS.RP_RERUN_UUID, + + /** + * is local or online server to use + */ + PR_IS_LOCAL_SERVER: process.env.PR_IS_LOCAL_SERVER !== 'false', + + /** + * url with endpoints where ReportPortal is + */ + PR_ENDPOINT: (): string => { + return process.env.PR_ENDPOINT || REPORTER_CONSTANTS.PR_IS_LOCAL_SERVER + ? 'http://localhost:8080/api/v1' + : 'https://reportportal-crw.apps.ocp-c1.prod.psi.redhat.com/api/v1'; + }, + + /** + * use personal project to save launch, if false launch will be send to devspaces or che project, true by default + */ + RP_USE_PERSONAL: process.env.RP_USE_PERSONAL !== 'false', + + /** + * project name to save launch + */ + RP_PROJECT: (): string => { + const project: string = + BASE_TEST_CONSTANTS.TEST_ENVIRONMENT !== '' && REPORTER_CONSTANTS.RP_USE_PERSONAL + ? `${REPORTER_CONSTANTS.RP_USER}_personal` + : BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME(); + return process.env.RP_PROJECT || project; + } }; diff --git a/tests/e2e/constants/TIMEOUT_CONSTANTS.ts b/tests/e2e/constants/TIMEOUT_CONSTANTS.ts index a3af150a4eae..3c7d42552ccf 100644 --- a/tests/e2e/constants/TIMEOUT_CONSTANTS.ts +++ b/tests/e2e/constants/TIMEOUT_CONSTANTS.ts @@ -8,25 +8,23 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ export const TIMEOUT_CONSTANTS: { - TS_FIND_EXTENSION_TEST_TIMEOUT: number; - TS_SELENIUM_WORKSPACE_STATUS_POLLING: number; + TS_CLICK_DASHBOARD_ITEM_TIMEOUT: number; TS_COMMON_DASHBOARD_WAIT_TIMEOUT: number; - TS_EXPAND_PROJECT_TREE_ITEM_TIMEOUT: number; - TS_DIALOG_WINDOW_DEFAULT_TIMEOUT: number; + TS_COMMON_PLUGIN_TEST_TIMEOUT: number; TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT: number; + TS_DIALOG_WINDOW_DEFAULT_TIMEOUT: number; + TS_EDITOR_TAB_INTERACTION_TIMEOUT: number; + TS_EXPAND_PROJECT_TREE_ITEM_TIMEOUT: number; + TS_FIND_EXTENSION_TEST_TIMEOUT: number; + TS_IDE_LOAD_TIMEOUT: number; TS_SELENIUM_CLICK_ON_VISIBLE_ITEM: number; TS_SELENIUM_DEFAULT_ATTEMPTS: number; - TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS: number; - TS_SELENIUM_WAIT_FOR_URL: number; TS_SELENIUM_DEFAULT_POLLING: number; - TS_IDE_LOAD_TIMEOUT: number; + TS_SELENIUM_LOAD_PAGE_TIMEOUT: number; + TS_SELENIUM_START_WORKSPACE_TIMEOUT: number; + TS_SELENIUM_WAIT_FOR_URL: number; TS_WAIT_LOADER_ABSENCE_TIMEOUT: number; TS_WAIT_LOADER_PRESENCE_TIMEOUT: number; - TS_SELENIUM_START_WORKSPACE_TIMEOUT: number; - TS_SELENIUM_LOAD_PAGE_TIMEOUT: number; - TS_CLICK_DASHBOARD_ITEM_TIMEOUT: number; - TS_COMMON_PLUGIN_TEST_TIMEOUT: number; - TS_EDITOR_TAB_INTERACTION_TIMEOUT: number; } = { /** * default amount of tries, "5" by default. @@ -45,16 +43,6 @@ export const TIMEOUT_CONSTANTS: { */ TS_SELENIUM_WAIT_FOR_URL: Number(process.env.TS_SELENIUM_WAIT_FOR_URL) || 10_000, - /** - * amount of tries for checking workspace status. - */ - TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS: Number(process.env.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS) || 90, - - /** - * delay in milliseconds between checking workspace status tries. - */ - TS_SELENIUM_WORKSPACE_STATUS_POLLING: Number(process.env.TS_SELENIUM_WORKSPACE_STATUS_POLLING) || 10000, - /** * wait between workspace started and IDE ready to be used, "20 000" by default. */ diff --git a/tests/e2e/package-lock.json b/tests/e2e/package-lock.json index 853112e2c1b1..553c8227f624 100644 --- a/tests/e2e/package-lock.json +++ b/tests/e2e/package-lock.json @@ -15,6 +15,7 @@ }, "devDependencies": { "@eclipse-che/che-devworkspace-generator": "next", + "@reportportal/agent-js-mocha": "^5.0.3", "@types/chai": "^4.3.4", "@types/clone-deep": "^4.0.1", "@types/mocha": "5.2.6", @@ -266,6 +267,24 @@ "node": ">=4" } }, + "node_modules/@babel/runtime": { + "version": "7.23.1", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.1.tgz", + "integrity": "sha512-hC2v6p8ZSI/W0HUzh3V8C5g+NwSKzKPtJwSpTjwl0o297GP9+ZLQSkdvHz46CM3LqyoXxq+5G9komY+eSqSO0g==", + "dev": true, + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/runtime/node_modules/regenerator-runtime": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz", + "integrity": "sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==", + "dev": true + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -512,6 +531,193 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/@reportportal/agent-js-mocha": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@reportportal/agent-js-mocha/-/agent-js-mocha-5.0.3.tgz", + "integrity": "sha512-QxR2yUJJ3cq0xOwQEa0/PqYZKbqV8j0JiT1rqku0VCYYhT0jvZARsz81IWjRuq6ZLZC2kQtAYIOwdEd6kd0pqA==", + "dev": true, + "dependencies": { + "@reportportal/client-javascript": "^5.0.12", + "mocha": "^10.2.0" + }, + "engines": { + "node": ">=10.x" + } + }, + "node_modules/@reportportal/agent-js-mocha/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@reportportal/agent-js-mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@reportportal/agent-js-mocha/node_modules/mocha": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "dev": true, + "dependencies": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/@reportportal/agent-js-mocha/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/@reportportal/agent-js-mocha/node_modules/nanoid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "dev": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/@reportportal/agent-js-mocha/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/@reportportal/agent-js-mocha/node_modules/workerpool": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", + "dev": true + }, + "node_modules/@reportportal/client-javascript": { + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/@reportportal/client-javascript/-/client-javascript-5.0.13.tgz", + "integrity": "sha512-HMW5i7PR90SnxTQwhWud7AaIuSzoiDL+m3XTWOtR35yliJIzNJca04HfM8W/J3afYdH6SrhUC4ItmEL654KTPw==", + "dev": true, + "dependencies": { + "axios": "^0.27.2", + "axios-retry": "^3.4.0", + "glob": "^7.2.3", + "ini": "^2.0.0", + "uniqid": "^5.4.0", + "uuid": "^9.0.0" + }, + "engines": { + "node": ">=10.x" + } + }, + "node_modules/@reportportal/client-javascript/node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/@reportportal/client-javascript/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/@reportportal/client-javascript/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@reportportal/client-javascript/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@testim/chrome-version": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/@testim/chrome-version/-/chrome-version-1.1.4.tgz", @@ -1148,6 +1354,16 @@ "follow-redirects": "^1.14.7" } }, + "node_modules/axios-retry": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-3.8.0.tgz", + "integrity": "sha512-CfIsQyWNc5/AE7x/UEReRUadiBmQeoBpSEC+4QyGLJMswTsP1tz0GW2YYPnE7w9+ESMef5zOgLDFpHynNyEZ1w==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.15.4", + "is-retry-allowed": "^2.2.0" + } + }, "node_modules/babel-code-frame": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", @@ -3069,6 +3285,15 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "node_modules/ini": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ini/-/ini-2.0.0.tgz", + "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/interpret": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", @@ -3275,6 +3500,18 @@ "node": ">=0.10.0" } }, + "node_modules/is-retry-allowed": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-2.2.0.tgz", + "integrity": "sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", @@ -5317,6 +5554,12 @@ "node": ">=4.2.0" } }, + "node_modules/uniqid": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/uniqid/-/uniqid-5.4.0.tgz", + "integrity": "sha512-38JRbJ4Fj94VmnC7G/J/5n5SC7Ab46OM5iNtSstB/ko3l1b5g7ALt4qzHFgGciFkyiRNtDXtLNb+VsxtMSE77A==", + "dev": true + }, "node_modules/universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", diff --git a/tests/e2e/package.json b/tests/e2e/package.json index 6deba53d638c..8a09b24e9d73 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -22,12 +22,7 @@ "license": "ISC", "devDependencies": { "@eclipse-che/che-devworkspace-generator": "next", - "allure-decorators": "^2.4.0", - "allure-js-commons": "^2.4.0", - "allure-mocha": "^2.4.0", - "mocha-multi-reporters": "^1.5.1", - "allure-commandline": "^2.22.1", - "mocha-allure-reporter": "^1.4.0", + "@reportportal/agent-js-mocha": "^5.0.3", "@types/chai": "^4.3.4", "@types/clone-deep": "^4.0.1", "@types/mocha": "5.2.6", @@ -38,6 +33,10 @@ "@typescript-eslint/eslint-plugin": "^6.4.1", "@typescript-eslint/eslint-plugin-tslint": "^6.1.0", "@typescript-eslint/parser": "^6.1.0", + "allure-commandline": "^2.22.1", + "allure-decorators": "^2.4.0", + "allure-js-commons": "^2.4.0", + "allure-mocha": "^2.4.0", "axios": "^0.25.0", "chai": "^4.3.4", "chrome-har": "^0.13.2", @@ -48,9 +47,11 @@ "eslint-plugin-header": "^3.1.1", "eslint-plugin-jsdoc": "^46.5.0", "eslint-plugin-prettier": "^5.0.0", - "inversify-inject-decorators": "^3.1.0", "husky": "^8.0.3", + "inversify-inject-decorators": "^3.1.0", "mocha": "^9.1.3", + "mocha-allure-reporter": "^1.4.0", + "mocha-multi-reporters": "^1.5.1", "monaco-page-objects": "3.9.1", "prettier": "^3.0.2", "rimraf": "2.6.2", diff --git a/tests/e2e/specs/MochaHooks.ts b/tests/e2e/specs/MochaHooks.ts index 1e1677885d17..bdd93a86ba3d 100644 --- a/tests/e2e/specs/MochaHooks.ts +++ b/tests/e2e/specs/MochaHooks.ts @@ -25,6 +25,7 @@ import { CHROME_DRIVER_CONSTANTS } from '../constants/CHROME_DRIVER_CONSTANTS'; import { decorate, injectable, unmanaged } from 'inversify'; import { Main } from '@eclipse-che/che-devworkspace-generator/lib/main'; import { LocatorLoader } from 'monaco-page-objects/out/locators/loader'; +import { REPORTER_CONSTANTS } from '../constants/REPORTER_CONSTANTS'; const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); let latestWorkspace: string = ''; @@ -69,15 +70,15 @@ exports.mochaHooks = { if (BASE_TEST_CONSTANTS.TS_DEBUG_MODE) { for (const [timeout, seconds] of Object.entries(TIMEOUT_CONSTANTS)) { Object.defineProperty(TIMEOUT_CONSTANTS, timeout, { - value: seconds * 100 + value: seconds * 2 }); } } } ], afterEach: [ - async function (this: Mocha.Context): Promise { - if (this.currentTest?.state === 'failed') { + async function saveAllureAttachments(this: Mocha.Context): Promise { + if (REPORTER_CONSTANTS.SAVE_ALLURE_REPORT_DATA && this.currentTest?.state === 'failed') { try { const screenshot: string = await driverHelper.getDriver().takeScreenshot(); allure.attachment('Screenshot', Buffer.from(screenshot, 'base64'), 'image/png'); diff --git a/tests/e2e/specs/api/EmptyWorkspaceAPI.spec.ts b/tests/e2e/specs/api/EmptyWorkspaceAPI.spec.ts index a3ee0d27bce6..7a508ec91e9e 100644 --- a/tests/e2e/specs/api/EmptyWorkspaceAPI.spec.ts +++ b/tests/e2e/specs/api/EmptyWorkspaceAPI.spec.ts @@ -71,10 +71,6 @@ suite('Empty workspace API test', function (): void { BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME ); }); - - suiteTeardown('Delete cloned project', function (): void { - containerTerminal.removeFolder(`${clonedProjectName}`); - }); }); suiteTeardown('Delete workspace', function (): void { diff --git a/tests/e2e/tests-library/LoginTests.ts b/tests/e2e/tests-library/LoginTests.ts index 0896c86129e3..4bbc2fa6e4e9 100644 --- a/tests/e2e/tests-library/LoginTests.ts +++ b/tests/e2e/tests-library/LoginTests.ts @@ -41,7 +41,10 @@ export class LoginTests { loginIntoOcpConsole(): void { test('Login into ocp console', async (): Promise => { - const openshiftConsoleUrl: string = BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.replace('devspaces', 'console-openshift-console'); + const openshiftConsoleUrl: string = BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.replace( + BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME(), + 'console-openshift-console' + ); await this.browserTabsUtil.navigateTo(openshiftConsoleUrl); await this.ocpLoginPage.login(); await this.browserTabsUtil.maximize(); diff --git a/tests/e2e/tsconfig.json b/tests/e2e/tsconfig.json index ece61f742c06..7357caec767e 100644 --- a/tests/e2e/tsconfig.json +++ b/tests/e2e/tsconfig.json @@ -13,5 +13,5 @@ "noImplicitReturns": false, "sourceMap": true }, - "include": [".eslintrc.js", "**/*.ts", "**/**/*.ts"] + "include": [".eslintrc.js", "**/*.ts", "**/**/*.ts", "**/reporters.config.js"] } diff --git a/tests/e2e/utils/DevWorkspaceConfigurationHelper.ts b/tests/e2e/utils/DevWorkspaceConfigurationHelper.ts index 44e2539aee00..54d131eded46 100644 --- a/tests/e2e/utils/DevWorkspaceConfigurationHelper.ts +++ b/tests/e2e/utils/DevWorkspaceConfigurationHelper.ts @@ -56,6 +56,7 @@ export class DevWorkspaceConfigurationHelper { async generateDevfileContext(): Promise { Logger.debug(); + if (!this.params.projects) { this.params.projects = []; } @@ -71,6 +72,7 @@ export class DevWorkspaceConfigurationHelper { // write templates and then DevWorkspace in a single file getDevWorkspaceConfigurationYamlAsString(context: DevfileContext): string { Logger.debug(); + const allContentArray: any[] = context.devWorkspaceTemplates.map((template: V1alpha2DevWorkspaceTemplate): string => YAML.stringify(template) ); @@ -80,7 +82,7 @@ export class DevWorkspaceConfigurationHelper { } getDevWorkspaceConfigurationsAsYaml(allContentString: string): string { - Logger.debug(`${this.constructor.name}.${this.getDevWorkspaceConfigurationsAsYaml.name}`); + Logger.debug(); const content: any = {}; const contentArray: string[] = allContentString.split('---\n'); contentArray.forEach((e: any): void => { @@ -97,6 +99,7 @@ export class DevWorkspaceConfigurationHelper { return content; } patchDevWorkspaceConfigWithBuildContainerAttribute(devfileContextDevWorkspace: any): void { + Logger.debug(); devfileContextDevWorkspace.spec.template.attributes = YAML.parse(` controller.devfile.io/devworkspace-config: name: devworkspace-config diff --git a/tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts b/tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts index 94767a6870d7..49046af21bc5 100644 --- a/tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts +++ b/tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts @@ -46,14 +46,14 @@ export class KubernetesCommandLineToolsExecutor implements IKubernetesCommandLin } get namespace(): string | undefined { - this._namespace = - this._namespace !== undefined - ? this._namespace - : BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('devspaces') - ? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-devspaces' - : BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('che') - ? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-che' - : 'default'; + if (!this._namespace) { + const applicationName: string = BASE_TEST_CONSTANTS.TESTING_APPLICATION_NAME(); + if (applicationName === 'default') { + this._namespace = applicationName; + } else { + this._namespace = OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-' + applicationName; + } + } return this._namespace; }