From 754c2c8f095ffef3f2a5af40008e35c1ee5cdc97 Mon Sep 17 00:00:00 2001 From: Ihor Okhrimenko Date: Tue, 11 May 2021 19:28:29 +0300 Subject: [PATCH] Rework plugin tests for the openshift CI (#19785) --- tests/e2e/TestConstants.ts | 7 ++++++- tests/e2e/package.json | 1 + .../e2e/pageobjects/ide/plugins/PluginsView.ts | 2 +- .../tests/plugins/InstallPluginUsingUI.spec.ts | 8 +++++++- tests/e2e/tests/plugins/JavaPlugin.spec.ts | 16 +++++++++------- tests/e2e/tests/plugins/PhpPlugin.spec.ts | 14 ++++++++------ tests/e2e/tests/plugins/PythonPlugin.spec.ts | 15 ++++++++------- .../e2e/tests/plugins/TypescriptPlugin.spec.ts | 14 ++++++++------ .../plugins/VscodeKubernetesPlugin.spec.ts | 15 ++++++++------- .../plugins/VscodeShellcheckPlugin.spec.ts | 18 +++++++++--------- .../e2e/tests/plugins/VscodeValePlugin.spec.ts | 17 +++++++++++------ .../e2e/tests/plugins/VscodeXmlPlugin.spec.ts | 16 +++++++++++----- .../e2e/tests/plugins/VscodeYamlPlugin.spec.ts | 15 ++++++++++----- 13 files changed, 97 insertions(+), 61 deletions(-) diff --git a/tests/e2e/TestConstants.ts b/tests/e2e/TestConstants.ts index 990ba0d84a..466b6bbfce 100644 --- a/tests/e2e/TestConstants.ts +++ b/tests/e2e/TestConstants.ts @@ -228,6 +228,11 @@ export const TestConstants = { /** * This variable specifies that run test is used for load testing and that all artifacts will be sent to ftp client. */ - TS_LOAD_TESTS: process.env.TS_LOAD_TESTS || 'false' + TS_LOAD_TESTS: process.env.TS_LOAD_TESTS || 'false', + + /** + * This variable determines whether to delete the workspace after the test or leave the workspace running. + */ + TS_DELETE_PLUGINS_TEST_WORKSPACE: process.env.TS_DELETE_PLUGINS_TEST_WORKSPACE || 'true' }; diff --git a/tests/e2e/package.json b/tests/e2e/package.json index 3e946d308b..c0d6031d40 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -25,6 +25,7 @@ "tsc": "tsc -p .", "init-mocha-opts": "tsc && mocha --opts mocha-single-devfile.opts --spec dist/tests/login/Login.spec.js", "test-plugin": "npm run init-mocha-opts -- --spec dist/tests/plugins/${USERSTORY}.spec.js", + "test-plugin-ci": "export TS_DELETE_PLUGINS_TEST_WORKSPACE=false && npm run init-mocha-opts -- --spec dist/tests/plugins/${USERSTORY}.spec.js", "test-all-plugins": "tsc && mocha --opts mocha-all-plugins.opts" }, "author": "Ihor Okhrimenko (iokhrime@redhat.com)", diff --git a/tests/e2e/pageobjects/ide/plugins/PluginsView.ts b/tests/e2e/pageobjects/ide/plugins/PluginsView.ts index 16dc1decdb..84ad7e2e79 100644 --- a/tests/e2e/pageobjects/ide/plugins/PluginsView.ts +++ b/tests/e2e/pageobjects/ide/plugins/PluginsView.ts @@ -72,7 +72,7 @@ export class PluginsView { // it will cause to the random result for (let i: number = 0; i < text.length; i++) { await this.driverHelper.type(PluginsView.SEARCH_FIELD_LOCATOR, text.charAt(i), timeout); - await this.driverHelper.wait(1000); + await this.driverHelper.wait(2000); } } diff --git a/tests/e2e/tests/plugins/InstallPluginUsingUI.spec.ts b/tests/e2e/tests/plugins/InstallPluginUsingUI.spec.ts index e287fe3541..de950c62ff 100644 --- a/tests/e2e/tests/plugins/InstallPluginUsingUI.spec.ts +++ b/tests/e2e/tests/plugins/InstallPluginUsingUI.spec.ts @@ -18,6 +18,7 @@ import { TestWorkspaceUtil } from '../../utils/workspace/TestWorkspaceUtil'; import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; import { PluginsView } from '../../pageobjects/ide/plugins/PluginsView'; import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests'; +import { Logger } from '../../utils/Logger'; const ide: Ide = e2eContainer.get(CLASSES.Ide); const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree); @@ -67,7 +68,12 @@ suite(`The 'InstallPluginUsingUI' test`, async () => { suite('Stopping and deleting the workspace', async () => { test(`Stop and remove workspace`, async () => { - await workspaceHandling.stopAndRemoveWorkspace(workspaceName); + if (TestConstants.TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true') { + await workspaceHandling.stopAndRemoveWorkspace(workspaceName); + return; + } + + Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`); }); }); diff --git a/tests/e2e/tests/plugins/JavaPlugin.spec.ts b/tests/e2e/tests/plugins/JavaPlugin.spec.ts index f3f5c92e4e..9bc156a2d7 100644 --- a/tests/e2e/tests/plugins/JavaPlugin.spec.ts +++ b/tests/e2e/tests/plugins/JavaPlugin.spec.ts @@ -20,6 +20,7 @@ import { Key } from 'selenium-webdriver'; import { Editor } from '../../pageobjects/ide/Editor'; import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests'; import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests'; +import { Logger } from '../../utils/Logger'; const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests); @@ -86,14 +87,15 @@ suite(`The 'JavaPlugin' test`, async () => { }); suite('Stopping and deleting the workspace', async () => { - let workspaceName = 'not defined'; - suiteSetup(async () => { - workspaceName = await WorkspaceNameHandler.getNameFromUrl(); + test('Stop and remove workspace', async () => { + if (TestConstants.TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true') { + let workspaceName = await WorkspaceNameHandler.getNameFromUrl(); + await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + return; + } + + Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`); }); - test(`Stop and remove workspace`, async () => { - await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); - }); }); - }); diff --git a/tests/e2e/tests/plugins/PhpPlugin.spec.ts b/tests/e2e/tests/plugins/PhpPlugin.spec.ts index f5bcbbad7a..f5b7890c2d 100644 --- a/tests/e2e/tests/plugins/PhpPlugin.spec.ts +++ b/tests/e2e/tests/plugins/PhpPlugin.spec.ts @@ -21,6 +21,7 @@ import { TopMenu } from '../../pageobjects/ide/TopMenu'; import { DebugView } from '../../pageobjects/ide/DebugView'; import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests'; +import { Logger } from '../../utils/Logger'; const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); const ide: Ide = e2eContainer.get(CLASSES.Ide); @@ -94,13 +95,14 @@ suite(`The 'PhpPlugin' tests`, async () => { }); suite('Stopping and deleting the workspace', async () => { - test(`Stop and remove workspace`, async () => { - let workspaceName = 'not defined'; - suiteSetup(async () => { - workspaceName = await WorkspaceNameHandler.getNameFromUrl(); - }); + test('Stop and remove workspace', async () => { + if (TestConstants.TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true') { + let workspaceName = await WorkspaceNameHandler.getNameFromUrl(); + await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + return; + } - await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`); }); }); }); diff --git a/tests/e2e/tests/plugins/PythonPlugin.spec.ts b/tests/e2e/tests/plugins/PythonPlugin.spec.ts index 2f52956e27..e2a54366fd 100644 --- a/tests/e2e/tests/plugins/PythonPlugin.spec.ts +++ b/tests/e2e/tests/plugins/PythonPlugin.spec.ts @@ -19,6 +19,7 @@ import { ProjectTree } from '../../pageobjects/ide/ProjectTree'; import { Key } from 'selenium-webdriver'; import { Editor } from '../../pageobjects/ide/Editor'; import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests'; +import { Logger } from '../../utils/Logger'; const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); @@ -71,14 +72,14 @@ suite(`The 'PythonPlugin' test`, async () => { }); suite('Stopping and deleting the workspace', async () => { - let workspaceName = 'not defined'; - suiteSetup(async () => { - workspaceName = await WorkspaceNameHandler.getNameFromUrl(); - }); + test('Stop and remove workspace', async () => { + if (TestConstants.TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true') { + let workspaceName = await WorkspaceNameHandler.getNameFromUrl(); + await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + return; + } - test(`Stop and remove workspace`, async () => { - await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`); }); }); - }); diff --git a/tests/e2e/tests/plugins/TypescriptPlugin.spec.ts b/tests/e2e/tests/plugins/TypescriptPlugin.spec.ts index 904c955019..45df1c4b13 100644 --- a/tests/e2e/tests/plugins/TypescriptPlugin.spec.ts +++ b/tests/e2e/tests/plugins/TypescriptPlugin.spec.ts @@ -24,6 +24,7 @@ import { DebugView } from '../../pageobjects/ide/DebugView'; import { Terminal } from '../../pageobjects/ide/Terminal'; import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests'; +import { Logger } from '../../utils/Logger'; const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); @@ -154,13 +155,14 @@ suite(`The 'TypescriptPlugin and Node-debug' tests`, async () => { }); suite('Stopping and deleting the workspace', async () => { - let workspaceName = 'not defined'; - suiteSetup(async () => { - workspaceName = await WorkspaceNameHandler.getNameFromUrl(); - }); + test('Stop and remove workspace', async () => { + if (TestConstants.TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true') { + let workspaceName = await WorkspaceNameHandler.getNameFromUrl(); + await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + return; + } - test(`Stop and remove workspace`, async () => { - await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`); }); }); }); diff --git a/tests/e2e/tests/plugins/VscodeKubernetesPlugin.spec.ts b/tests/e2e/tests/plugins/VscodeKubernetesPlugin.spec.ts index cf74a022fa..ea5e33f943 100644 --- a/tests/e2e/tests/plugins/VscodeKubernetesPlugin.spec.ts +++ b/tests/e2e/tests/plugins/VscodeKubernetesPlugin.spec.ts @@ -19,6 +19,7 @@ import { PreferencesHandler } from '../../utils/PreferencesHandler'; import { KubernetesPlugin } from '../../pageobjects/ide/plugins/KubernetesPlugin'; import { ProjectTree } from '../../pageobjects/ide/ProjectTree'; import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests'; +import { Logger } from '../../utils/Logger'; const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); @@ -62,14 +63,14 @@ suite(`The 'VscodeKubernetesPlugin' test`, async () => { }); suite('Stopping and deleting the workspace', async () => { - let workspaceName = 'not defined'; - suiteSetup(async () => { - workspaceName = await WorkspaceNameHandler.getNameFromUrl(); - }); + test('Stop and remove workspace', async () => { + if (TestConstants.TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true') { + let workspaceName = await WorkspaceNameHandler.getNameFromUrl(); + await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + return; + } - test(`Stop and remowe workspace`, async () => { - await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`); }); }); - }); diff --git a/tests/e2e/tests/plugins/VscodeShellcheckPlugin.spec.ts b/tests/e2e/tests/plugins/VscodeShellcheckPlugin.spec.ts index 26c9e3dbe5..aac23cce67 100644 --- a/tests/e2e/tests/plugins/VscodeShellcheckPlugin.spec.ts +++ b/tests/e2e/tests/plugins/VscodeShellcheckPlugin.spec.ts @@ -20,6 +20,7 @@ import { Editor } from '../../pageobjects/ide/Editor'; import { ProjectTree } from '../../pageobjects/ide/ProjectTree'; import { Key } from 'selenium-webdriver'; import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests'; +import { Logger } from '../../utils/Logger'; const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); @@ -35,8 +36,7 @@ const subRootFolder: string = 'app'; const pathToFile: string = `${sampleName}`; const fileName: string = 'test.sh'; -// skipped until issue: https://github.com/eclipse/che/issues/19376 resolved -suite.skip(`The 'VscodeShellcheckPlugin' test`, async () => { +suite(`The 'VscodeShellcheckPlugin' test`, async () => { suite('Create workspace', async () => { test('Set shellcheck path', async () => { const shellcheckExecutablePathPropertyName: string = 'shellcheck.executablePath'; @@ -86,14 +86,14 @@ suite.skip(`The 'VscodeShellcheckPlugin' test`, async () => { }); suite('Stopping and deleting the workspace', async () => { - let workspaceName = 'not defined'; - suiteSetup(async () => { - workspaceName = await WorkspaceNameHandler.getNameFromUrl(); - }); + test('Stop and remove workspace', async () => { + if (TestConstants.TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true') { + let workspaceName = await WorkspaceNameHandler.getNameFromUrl(); + await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + return; + } - test(`Stop and remowe workspace`, async () => { - await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`); }); }); - }); diff --git a/tests/e2e/tests/plugins/VscodeValePlugin.spec.ts b/tests/e2e/tests/plugins/VscodeValePlugin.spec.ts index 21723b955e..1624ed26e3 100644 --- a/tests/e2e/tests/plugins/VscodeValePlugin.spec.ts +++ b/tests/e2e/tests/plugins/VscodeValePlugin.spec.ts @@ -10,7 +10,6 @@ import { Key } from 'selenium-webdriver'; import { e2eContainer } from '../../inversify.config'; -import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; import { CLASSES } from '../../inversify.types'; import { Ide } from '../../pageobjects/ide/Ide'; import { ProjectTree } from '../../pageobjects/ide/ProjectTree'; @@ -20,14 +19,15 @@ import { TestConstants } from '../../TestConstants'; import { TimeoutConstants } from '../../TimeoutConstants'; import { WorkspaceNameHandler } from '../../utils/WorkspaceNameHandler'; import { Terminal } from '../../pageobjects/ide/Terminal'; - -const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); +import { Logger } from '../../utils/Logger'; +import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests'; const ide: Ide = e2eContainer.get(CLASSES.Ide); const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree); const editor: Editor = e2eContainer.get(CLASSES.Editor); const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); const terminal: Terminal = e2eContainer.get(CLASSES.Terminal); +const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); let workspaceName: string = ''; @@ -75,9 +75,14 @@ suite('The "VscodeValePlugin" userstory', async () => { }); - suite('Delete workspace', async () => { - test('Delete workspace', async () => { - await dashboard.stopAndRemoveWorkspaceByUI(workspaceName); + suite('Stopping and deleting the workspace', async () => { + test('Stop and remove workspace', async () => { + if (TestConstants.TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true') { + await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + return; + } + + Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`); }); }); }); diff --git a/tests/e2e/tests/plugins/VscodeXmlPlugin.spec.ts b/tests/e2e/tests/plugins/VscodeXmlPlugin.spec.ts index 11ff8e454e..846acaaf1a 100644 --- a/tests/e2e/tests/plugins/VscodeXmlPlugin.spec.ts +++ b/tests/e2e/tests/plugins/VscodeXmlPlugin.spec.ts @@ -11,7 +11,6 @@ import { Key } from 'selenium-webdriver'; import { e2eContainer } from '../../inversify.config'; import { WorkspaceNameHandler } from '../../utils/WorkspaceNameHandler'; -import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; import { Ide } from '../../pageobjects/ide/Ide'; import { CLASSES } from '../../inversify.types'; import { ProjectTree } from '../../pageobjects/ide/ProjectTree'; @@ -19,13 +18,14 @@ import { Editor } from '../../pageobjects/ide/Editor'; import { DriverHelper } from '../../utils/DriverHelper'; import { TestConstants } from '../../TestConstants'; import { TimeoutConstants } from '../../TimeoutConstants'; - -const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); +import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests'; +import { Logger } from '../../utils/Logger'; const ide: Ide = e2eContainer.get(CLASSES.Ide); const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree); const editor: Editor = e2eContainer.get(CLASSES.Editor); const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); +const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); let workspaceName: string = ''; @@ -104,8 +104,14 @@ suite('The "VscodeXmlPlugin" userstory', async () => { }); suite('Delete workspace', async () => { - test('Delete workspace', async () => { - await dashboard.stopAndRemoveWorkspaceByUI(workspaceName); + test('Stop and remove workspace', async () => { + if (TestConstants.TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true') { + await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + return; + } + + Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`); }); }); + }); diff --git a/tests/e2e/tests/plugins/VscodeYamlPlugin.spec.ts b/tests/e2e/tests/plugins/VscodeYamlPlugin.spec.ts index 04f36002ea..47aa3f916d 100644 --- a/tests/e2e/tests/plugins/VscodeYamlPlugin.spec.ts +++ b/tests/e2e/tests/plugins/VscodeYamlPlugin.spec.ts @@ -10,7 +10,6 @@ import { Key } from 'selenium-webdriver'; import { e2eContainer } from '../../inversify.config'; -import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; import { CLASSES } from '../../inversify.types'; import { Ide } from '../../pageobjects/ide/Ide'; import { ProjectTree } from '../../pageobjects/ide/ProjectTree'; @@ -20,14 +19,15 @@ import { PreferencesHandler } from '../../utils/PreferencesHandler'; import { TestConstants } from '../../TestConstants'; import { TimeoutConstants } from '../../TimeoutConstants'; import { WorkspaceNameHandler } from '../../utils/WorkspaceNameHandler'; - -const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); +import { Logger } from '../../utils/Logger'; +import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests'; const ide: Ide = e2eContainer.get(CLASSES.Ide); const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree); const editor: Editor = e2eContainer.get(CLASSES.Editor); const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); const preferencesHandler: PreferencesHandler = e2eContainer.get(CLASSES.PreferencesHandler); +const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); let workspaceName: string = ''; @@ -101,8 +101,13 @@ suite('The "VscodeYamlPlugin" userstory', async () => { }); suite('Delete workspace', async () => { - test('Delete workspace', async () => { - await dashboard.stopAndRemoveWorkspaceByUI(workspaceName); + test('Stop and remove workspace', async () => { + if (TestConstants.TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true') { + await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName); + return; + } + + Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`); }); }); });