From b489639191e2f1ed2efd42233786dc813f02c5a1 Mon Sep 17 00:00:00 2001 From: Maksym Musiienko Date: Tue, 30 Jan 2024 16:13:21 +0200 Subject: [PATCH] Fix WorkspaceWithParent test (#22795) * add stabilization parts to the test --- tests/e2e/constants/BASE_TEST_CONSTANTS.ts | 4 ++-- .../miscellaneous/WorkspaceWithParent.spec.ts | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/e2e/constants/BASE_TEST_CONSTANTS.ts b/tests/e2e/constants/BASE_TEST_CONSTANTS.ts index 86b38cd0cdb..5f9b320d124 100644 --- a/tests/e2e/constants/BASE_TEST_CONSTANTS.ts +++ b/tests/e2e/constants/BASE_TEST_CONSTANTS.ts @@ -66,8 +66,8 @@ export const BASE_TEST_CONSTANTS: { return BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('devspaces') ? 'devspaces' : BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('che') - ? 'che' - : 'default'; + ? 'che' + : 'default'; }, /** * testing application version diff --git a/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts b/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts index 14efe97b5dc..9e927d61014 100644 --- a/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts +++ b/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts @@ -22,6 +22,8 @@ import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTes import { registerRunningWorkspace } from '../MochaHooks'; import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor'; import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil'; +import { DriverHelper } from '../../utils/DriverHelper'; +import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS'; suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void { const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests); @@ -34,6 +36,8 @@ suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMEN const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get( CLASSES.KubernetesCommandLineToolsExecutor ); + const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); + let podName: string = ''; suiteSetup(function (): void { @@ -51,6 +55,9 @@ suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMEN await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); + // add 10 sec timeout for waiting for finishing animation of all IDE parts (Welcome parts. bottom widgets. etc.) + // using 10 sec easier than performing of finishing animation a all elements + await driverHelper.wait(TIMEOUT_CONSTANTS.TS_SELENIUM_WAIT_FOR_URL); await projectAndFileTests.performTrustAuthorDialog(); }); @@ -68,8 +75,12 @@ suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMEN await input.setText('>Tasks: Run Task'); const runTaskItem: QuickPickItem | undefined = await input.findQuickPick('Tasks: Run Task'); await runTaskItem?.click(); + // pause for avoiding StaleElement exception. It is easier solution than try/catch or writing separate function for this + await driverHelper.wait(TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING); const devFileTask: QuickPickItem | undefined = await input.findQuickPick('devfile'); await devFileTask?.click(); + // pause for avoiding StaleElement exception. It is easier solution than try/catch or writing separate function for this + await driverHelper.wait(TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING); const firstExpectedQuickPick: QuickPickItem | undefined = await input.findQuickPick('1. This command from the devfile'); const secondExpectedQuickPick: QuickPickItem | undefined = await input.findQuickPick('2. This command from the parent'); expect(firstExpectedQuickPick).not.undefined; @@ -77,16 +88,16 @@ suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMEN }); test('Check expected containers in the parent POD', function (): void { - const getPodNameCommand: string = `${API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL} get pods -n ${BASE_TEST_CONSTANTS.TEST_NAMESPACE} --selector=controller.devfile.io/devworkspace_name=sample-using-parent --output jsonpath=\'{.items[0].metadata.name}\'`; + const getPodNameCommand: string = `${API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL} get pods -n ${kubernetesCommandLineToolsExecutor.namespace} --selector=controller.devfile.io/devworkspace_name=sample-using-parent --output jsonpath=\'{.items[0].metadata.name}\'`; podName = shellExecutor.executeArbitraryShellScript(getPodNameCommand); const containerNames: string = shellExecutor.executeArbitraryShellScript( - `${API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL} get pod ${podName} -n ${BASE_TEST_CONSTANTS.TEST_NAMESPACE} --output jsonpath=\'{.spec.containers[*].name}\'` + `${API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL} get pod ${podName} -n ${kubernetesCommandLineToolsExecutor.namespace} --output jsonpath=\'{.spec.containers[*].name}\'` ); expect(containerNames).contains('tools').and.contains('che-gateway'); const initContainerName: string = shellExecutor.executeArbitraryShellScript( - `${API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL} get pod ${podName} -n ${BASE_TEST_CONSTANTS.TEST_NAMESPACE} --output jsonpath=\'{.spec.initContainers[].name}\'` + `${API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL} get pod ${podName} -n ${kubernetesCommandLineToolsExecutor.namespace} --output jsonpath=\'{.spec.initContainers[].name}\'` ); expect(initContainerName).contains('che-code-injector'); });