Skip to content
Merged
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
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 @@ -25,18 +21,14 @@ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
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 vsCodeDesktopSshEditor: string = '//*[@id="editor-selector-card-che-incubator/che-code-sshd/latest"]';
const titlexPath: string = '/html/body/h1';
const useExtensionSwitcher: string = '//div[@class="toggle-input"]';

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 @@ -92,6 +84,10 @@ suite('Check Visual Studio Code (desktop) (SSH) with all samples', function ():
);
}

Comment thread
olkornii marked this conversation as resolved.
// toggle UseExtension switcher if needed
if (!(await workspaceHandlingTests.checkElementExistsByXpath(ocPortForwardxPath))) {
Comment thread
dmytro-ndp marked this conversation as resolved.
Outdated
await workspaceHandlingTests.clickOnElementByXpath(useExtensionSwitcher);
}
// check title
const headerText: string = await workspaceHandlingTests.getTextFromUIElementByXpath(titlexPath);
expect('Workspace ' + WorkspaceHandlingTests.getWorkspaceName() + ' is running').equal(headerText);
Expand Down
15 changes: 15 additions & 0 deletions tests/e2e/tests-library/WorkspaceHandlingTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,21 @@ export class WorkspaceHandlingTests {
return await this.driverHelper.getDriver().findElement(By.xpath(xpath)).getText();
}

async clickOnElementByXpath(xpath: string): Promise<void> {
Logger.debug('Click on xPath: ' + xpath);
Comment thread
olkornii marked this conversation as resolved.
Outdated
await this.driverHelper.waitAndClick(By.xpath(xpath));
}

async checkElementExistsByXpath(xpath: string): Promise<boolean> {
Comment thread
olkornii marked this conversation as resolved.
Outdated
Logger.debug('Check if element exists');
try {
await this.driverHelper.waitVisibility(By.xpath(xpath));
} catch (error) {
return false;
}
return true;
}

private async waitForControlXpath(xPathToWait: string, polling: number): Promise<void> {
await this.browserTabsUtil.waitAndSwitchToAnotherWindow(WorkspaceHandlingTests.parentGUID, TIMEOUT_CONSTANTS.TS_IDE_LOAD_TIMEOUT);
await this.obtainWorkspaceNameFromStartingPage();
Expand Down
Loading