Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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"]';
Expand Down Expand Up @@ -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<void> {
await dashboard.openDashboard();
await browserTabsUtil.closeAllTabsExceptCurrent();
await dashboard.stopAndRemoveWorkspaceByUI(WorkspaceHandlingTests.getWorkspaceName());
WorkspaceHandlingTests.clearWorkspaceName();
}

suiteSetup('Login into Che', async function (): Promise<void> {
await loginTests.loginIntoChe();
});

async function clickOnElementByXpath(xpath: string): Promise<void> {
Logger.debug();
await driverHelper.waitAndClick(By.xpath(xpath));
}

async function testWorkspaceStartup(sampleNameOrUrl: string, isUrl: boolean): Promise<void> {
await dashboard.openDashboard();
await dashboard.clickCreateWorkspaceButton();

if (isUrl) {
await workspaceHandlingTests.createAndOpenWorkspaceWithSpecificEditorAndGitUrl(
vsCodeDesktopSshEditor,
Expand All @@ -92,6 +89,10 @@ suite('Check Visual Studio Code (desktop) (SSH) with all samples', function ():
);
}

Comment thread
olkornii marked this conversation as resolved.
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);
Expand All @@ -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<void> {
Expand All @@ -132,12 +131,17 @@ suite('Check Visual Studio Code (desktop) (SSH) with all samples', function ():
}
});

suiteTeardown('Delete DevWorkspace', async function (): Promise<void> {
Logger.info('Deleting DevWorkspace... After all.');
teardown('Delete DevWorkspace', async function (): Promise<void> {
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();
});
});
Loading