diff --git a/tests/e2e/specs/dashboard-samples/StartWorkspaceUsingVSCodeDesktopSshEditor.spec.ts b/tests/e2e/specs/dashboard-samples/StartWorkspaceUsingVSCodeDesktopSshEditor.spec.ts index 6cd78af489f..d507d99ab55 100644 --- a/tests/e2e/specs/dashboard-samples/StartWorkspaceUsingVSCodeDesktopSshEditor.spec.ts +++ b/tests/e2e/specs/dashboard-samples/StartWorkspaceUsingVSCodeDesktopSshEditor.spec.ts @@ -8,10 +8,6 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ -import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor'; -import fs from 'fs'; -import path from 'path'; -import YAML from 'yaml'; import { e2eContainer } from '../../configs/inversify.config'; import { CLASSES } from '../../configs/inversify.types'; import { LoginTests } from '../../tests-library/LoginTests'; @@ -21,22 +17,23 @@ import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTes import { expect } from 'chai'; import { Logger } from '../../utils/Logger'; import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS'; +import { DriverHelper } from '../../utils/DriverHelper'; +import { By } from 'selenium-webdriver'; suite('Check Visual Studio Code (desktop) (SSH) with all samples', function (): void { this.timeout(6000000); const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); - const pathToSampleFile: string = path.resolve('resources/default-devfile.yaml'); - const workspaceName: string = YAML.parse(fs.readFileSync(pathToSampleFile, 'utf8')).metadata.name; - const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get( - CLASSES.KubernetesCommandLineToolsExecutor - ); - kubernetesCommandLineToolsExecutor.workspaceName = workspaceName; const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); + const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); const vsCodeDesktopSshEditor: string = '//*[@id="editor-selector-card-che-incubator/che-code-sshd/latest"]'; - const titlexPath: string = '/html/body/h1'; + + const useExtensionSwitcher: string = '//label[@class="switch"]'; + const useExtensionPageId: string = '//div[@id="docs-parent"]'; + + const titlexPath: string = '//div[@class="header-title"]'; const ocPortForwardxPath: string = '//*[@id="port-forward"]'; const sshKeyxPath: string = '//*[@id="key"]'; const sshKonfigxPath: string = '//*[@id="config"]'; @@ -65,19 +62,19 @@ suite('Check Visual Studio Code (desktop) (SSH) with all samples', function (): 'https://gh.crw-qe.com/test-automation-only/ubi9-based-sample-public/tree/ubi9-minimal' ]; - async function deleteWorkspace(): Promise { - await dashboard.openDashboard(); - await browserTabsUtil.closeAllTabsExceptCurrent(); - await dashboard.stopAndRemoveWorkspaceByUI(WorkspaceHandlingTests.getWorkspaceName()); - WorkspaceHandlingTests.clearWorkspaceName(); - } - suiteSetup('Login into Che', async function (): Promise { await loginTests.loginIntoChe(); }); + async function clickOnElementByXpath(xpath: string): Promise { + Logger.debug(); + await driverHelper.waitAndClick(By.xpath(xpath)); + } + async function testWorkspaceStartup(sampleNameOrUrl: string, isUrl: boolean): Promise { await dashboard.openDashboard(); + await dashboard.clickCreateWorkspaceButton(); + if (isUrl) { await workspaceHandlingTests.createAndOpenWorkspaceWithSpecificEditorAndGitUrl( vsCodeDesktopSshEditor, @@ -92,6 +89,10 @@ suite('Check Visual Studio Code (desktop) (SSH) with all samples', function (): ); } + const useExtensionPageText: string = await workspaceHandlingTests.getTextFromUIElementByXpath(useExtensionPageId); + expect(useExtensionPageText).contains('Install the following VS Code extensions'); + // toggle UseExtension switcher + await clickOnElementByXpath(useExtensionSwitcher); // check title const headerText: string = await workspaceHandlingTests.getTextFromUIElementByXpath(titlexPath); expect('Workspace ' + WorkspaceHandlingTests.getWorkspaceName() + ' is running').equal(headerText); @@ -109,8 +110,6 @@ suite('Check Visual Studio Code (desktop) (SSH) with all samples', function (): .and.contains('Port') .and.contains('IdentityFile') .and.contains('UserKnownHostsFile'); - - await deleteWorkspace(); } test('Test start of VSCode (desktop) (SSH) with default Samples', async function (): Promise { @@ -132,12 +131,17 @@ suite('Check Visual Studio Code (desktop) (SSH) with all samples', function (): } }); - suiteTeardown('Delete DevWorkspace', async function (): Promise { - Logger.info('Deleting DevWorkspace... After all.'); + teardown('Delete DevWorkspace', async function (): Promise { + Logger.info('Delete DevWorkspace. After each test.'); + await dashboard.openDashboard(); await browserTabsUtil.closeAllTabsExceptCurrent(); + if (WorkspaceHandlingTests.getWorkspaceName() !== 'undefined') { + Logger.info('Workspace name is defined. Deleting workspace...'); await dashboard.deleteStoppedWorkspaceByUI(WorkspaceHandlingTests.getWorkspaceName()); } + + WorkspaceHandlingTests.clearWorkspaceName(); }); });