Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
23 changes: 23 additions & 0 deletions tests/e2e/pageobjects/dashboard/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class Dashboard {
};
private static readonly CONTINUE_WITH_DEFAULT_DEVFILE_BUTTON: By = By.xpath('//button[text()="Continue with default devfile"]');
private static readonly OPEN_EXISTING_WORKSPACE_LINK: By = By.xpath('//button[text()="Open the existing workspace"]');
private static readonly CHOOSE_EDITOR_MENU: By = By.xpath('//*[@id="accordion-item-selector"]');

constructor(
@inject(CLASSES.DriverHelper)
Expand All @@ -62,6 +63,16 @@ export class Dashboard {
await this.workspaces.waitWorkspaceWithStoppedStatus(workspaceName);
}

async forceStopWorkspaceByUI(workspaceName: string): Promise<void> {
Logger.debug(`"${workspaceName}"`);

await this.clickWorkspacesButton();
await this.workspaces.waitPage();
await this.workspaces.waitWorkspaceListItem(workspaceName);
await this.workspaces.stopWorkspaceByActionsButton(workspaceName);
await this.workspaces.waitWorkspaceWithStoppedStatus(workspaceName);
}

async deleteStoppedWorkspaceByUI(workspaceName: string): Promise<void> {
Logger.debug(`"${workspaceName}"`);

Expand Down Expand Up @@ -220,6 +231,18 @@ export class Dashboard {
await this.driverHelper.waitAndClick(Dashboard.CONTINUE_WITH_DEFAULT_DEVFILE_BUTTON, timeout);
}

async openChooseEditorMenu(timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
Logger.debug('open "choose Editor" menu');

await this.driverHelper.waitAndClick(Dashboard.CHOOSE_EDITOR_MENU, timeout);
}

async chooseEditor(editor: string, timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
Logger.debug('select Editor. Editor: ' + editor);

await this.driverHelper.waitAndClick(By.xpath(editor), timeout);
}

private getAboutMenuItemButtonLocator(text: string): By {
return By.xpath(`//li/button[text()="${text}"]`);
}
Expand Down
90 changes: 90 additions & 0 deletions tests/e2e/specs/dashboard-samples/EditorSampleVSCode.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Logger } from '../../utils/Logger';
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';
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
import { expect } from 'chai';

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 vsCodeEditor: string = '//*[@id="editor-selector-card-che-incubator/che-code-sshd/latest"]';
const titlexPath: string = '/html/body/h1';

const samplesForCheck: string[] = [
'Empty Workspace',
'JBoss EAP 8.0',
'Java Lombok',
'Node.js Express',
'Python',
'Quarkus REST API',
'.NET',
'Ansible',
'C/C++',
'Go',
'PHP'
];

const urlsForCheck: string[] = [
'https://github.com/crw-qe/quarkus-api-example-public/tree/ubi8-latest',
'https://github.com/crw-qe/ubi9-based-sample-public/tree/ubi9-minimal'
];

async function deleteWorkspace(): Promise<void> {
await dashboard.openDashboard();
await browserTabsUtil.closeAllTabsExceptCurrent();
await dashboard.forceStopWorkspaceByUI(WorkspaceHandlingTests.getWorkspaceName());
await dashboard.deleteStoppedWorkspaceByUI(WorkspaceHandlingTests.getWorkspaceName());
}

async function testVSCode(sampleOrUrl: string, isUrl: boolean): Promise<void> {
Logger.debug(sampleOrUrl);
await dashboard.openDashboard();
await workspaceHandlingTests.createAndOpenWorkspaceWithSpecificEditorAndSample(vsCodeEditor, sampleOrUrl, isUrl, titlexPath);

const headerText: string = await workspaceHandlingTests.getTextFromWorkspaceElement(titlexPath);
expect('Workspace ' + WorkspaceHandlingTests.getWorkspaceName() + ' is running').equal(headerText);

await deleteWorkspace();
}

suiteSetup('Login into OC', function (): void {
kubernetesCommandLineToolsExecutor.loginToOcp();
});

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

test('Test VSCode (desktop) (SSH) with default Samples', async function (): Promise<void> {
for (const sampleName of samplesForCheck) {
await testVSCode(sampleName, false);
}
});

test('Test VSCode (desktop) (SSH) with ubi', async function (): Promise<void> {
for (const url of urlsForCheck) {
await testVSCode(url, true);
}
});

suiteTeardown('Delete default DevWorkspace', function (): void {
kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
});
});
32 changes: 32 additions & 0 deletions tests/e2e/tests-library/WorkspaceHandlingTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,38 @@ export class WorkspaceHandlingTests {
Logger.info('Start workspace progress description: ' + alertDescription);
}

async createAndOpenWorkspaceWithSpecificEditorAndSample(
editor: string,
sample: string,
isUrl: boolean = false,
xPathForVerify: string
): Promise<void> {
Logger.debug('Create and open workspace with specific Editor and Sample. Sample ' + editor);
await this.selectEditor(editor);

if (isUrl) {
await this.createWorkspace.importFromGitUsingUI(sample);
} else {
await this.createWorkspace.clickOnSampleNoEditorSelection(sample);
}

await this.browserTabsUtil.waitAndSwitchToAnotherWindow(WorkspaceHandlingTests.parentGUID, TIMEOUT_CONSTANTS.TS_IDE_LOAD_TIMEOUT);
await this.obtainWorkspaceNameFromStartingPage();

await this.driverHelper.waitVisibility(By.xpath(xPathForVerify), TIMEOUT_CONSTANTS.TS_SELENIUM_START_WORKSPACE_TIMEOUT);
}

async selectEditor(editor: string): Promise<void> {
Logger.debug('select Editor. Editor: ' + editor);
await this.dashboard.openChooseEditorMenu();
await this.dashboard.chooseEditor(editor);
}

async getTextFromWorkspaceElement(xpath: string): Promise<string> {
Logger.debug('returning text from xPath: ' + xpath);
return await this.driverHelper.getDriver().findElement(By.xpath(xpath)).getText();
}

private async getWorkspaceAlertDescription(): Promise<string> {
try {
return await this.driverHelper.getDriver().findElement(WorkspaceHandlingTests.WORKSPACE_ALERT_DESCRIPTION).getText();
Expand Down