Skip to content

Commit

Permalink
feat: check links to documentation page in Dashboard
Browse files Browse the repository at this point in the history
Signed-off-by: mdolhalo <[email protected]>
  • Loading branch information
mdolhalo committed Sep 15, 2023
1 parent e38c24d commit 6835a01
Show file tree
Hide file tree
Showing 14 changed files with 358 additions and 102 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = {
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-var-requires': 'off',
Expand Down
16 changes: 16 additions & 0 deletions tests/e2e/constants/BASE_TEST_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export enum Platform {
}

export const BASE_TEST_CONSTANTS: {
IS_PRODUCT_DOCUMENTATION_RELEASED: any;
TESTING_APPLICATION_VERSION: string;
TS_DEBUG_MODE: boolean;
TS_PLATFORM: string;
TS_SELENIUM_RESPONSE_INTERCEPTOR: boolean;
Expand All @@ -31,6 +33,20 @@ export const BASE_TEST_CONSTANTS: {
*/
TS_SELENIUM_BASE_URL: !process.env.TS_SELENIUM_BASE_URL ? 'http://sample-url' : process.env.TS_SELENIUM_BASE_URL.replace(/\/$/, ''),

/**
* testing application version
*/
TESTING_APPLICATION_VERSION: process.env.TESTING_APPLICATION_VERSION || '3.8',

/**
* is "https://access.redhat.com/documentation/en-us/red_hat_openshift_dev_spaces/{TESTING_APPLICATION_VERSION}/" available online
* false by default
*/
IS_PRODUCT_DOCUMENTATION_RELEASED: process.env.IS_PRODUCT_DOCUMENTATION_RELEASED === 'true',

/**
* is cluster disconnected of online
*/
IS_CLUSTER_DISCONNECTED: (): boolean => BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('airgap'),

/**
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export * from './constants/API_TEST_CONSTANTS';
export * from './constants/BASE_TEST_CONSTANTS';
export * from './constants/CHROME_DRIVER_CONSTANTS';
export * from './constants/FACTORY_TEST_CONSTANTS';
export * from './constants/MOCHA_CONSTANTS';
export * from './constants/MONACO_CONSTANTS';
export * from './constants/OAUTH_CONSTANTS';
export * from './constants/PLUGIN_TEST_CONSTANTS';
Expand Down
120 changes: 60 additions & 60 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
{
"name": "@eclipse-che/che-e2e",
"version": "7.75.0-SNAPSHOT",
"description": "",
"main": "dist/index.js",
"scripts": {
"lint": "eslint --fix .",
"prettier": "prettier --config .prettierrc.json . --write",
"tsc": "rm -rf ./dist && ./configs/sh-scripts/generateIndex.sh && tsc -p .",
"test": "./configs/sh-scripts/initDefaultValues.sh npm run lint && npm run tsc && export USERSTORY=$USERSTORY && mocha --config dist/configs/mocharc.js",
"driver-less-test": "export TS_USE_WEB_DRIVER_FOR_TEST=false && npm run test",
"cleanup-docker": "if [ $(docker ps -a | grep -c selenium-e2e) -gt 0 ]; then docker rm -f $(docker ps --filter \"name=selenium-e2e\" -aq); fi;",
"test-docker": "npm run cleanup-docker && docker run -it --shm-size=2g -p 5920:5920 --name selenium-e2e -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL eclipse/che-e2e:nightly",
"test-docker-mount-e2e": "npm run cleanup-docker && docker run -it --shm-size=2g -p 5920:5920 --name selenium-e2e -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL -v $(pwd):/tmp/e2e:Z eclipse/che-e2e:nightly",
"test-all-devfiles": " ./configs/sh-scripts/initDefaultValues.sh && ./configs/sh-scripts/initDevfileTests.sh",
"devfile-acceptance-test-suite": "./configs/sh-scripts/initDefaultValues.sh npm run lint && npm run tsc && export TS_USE_WEB_DRIVER_FOR_TEST=false && mocha 'dist/specs/api/*.js' --config dist/configs/mocharc.js --delay --grep 'Devfile acceptance test suite'"
},
"author": "Ihor Okhrimenko ([email protected])",
"license": "ISC",
"devDependencies": {
"@eclipse-che/che-devworkspace-generator": "next",
"@types/chai": "^4.3.4",
"@types/clone-deep": "^4.0.1",
"@types/mocha": "5.2.6",
"@types/node": "11.13.4",
"@types/rimraf": "2.0.2",
"@types/selenium-webdriver": "4.1.3",
"@types/shelljs": "^0.8.11",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/eslint-plugin-tslint": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"axios": "^0.25.0",
"chai": "^4.3.4",
"chromedriver": "^114.0.2",
"clone-deep": "^4.0.1",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-jsdoc": "^46.5.0",
"eslint-plugin-prettier": "^5.0.0",
"husky": "^8.0.3",
"mocha": "^9.1.3",
"monaco-page-objects": "3.1.0",
"prettier": "^3.0.2",
"rimraf": "2.6.2",
"selenium-webdriver": "4.4.0",
"shelljs": "^0.8.5",
"ts-node": "^10.9.1",
"typescript": "4.9.4",
"vscode-extension-tester-locators": "3.1.0",
"yaml": "^2.2.2"
},
"dependencies": {
"@eclipse-che/api": "latest",
"inversify": "6.0.1",
"reflect-metadata": "0.1.13",
"@eclipse-che/che-devworkspace-generator": "7.75.0-SNAPSHOT"
},
"resolutions": {
"minimist": "^1.2.5"
}
"name": "@eclipse-che/che-e2e",
"version": "7.75.0-SNAPSHOT",
"description": "",
"main": "dist/index.js",
"scripts": {
"lint": "eslint --fix .",
"prettier": "prettier --config .prettierrc.json . --write",
"tsc": "rm -rf ./dist && ./configs/sh-scripts/generateIndex.sh && tsc -p .",
"test": "./configs/sh-scripts/initDefaultValues.sh npm run lint && npm run tsc && export USERSTORY=$USERSTORY && mocha --config dist/configs/mocharc.js",
"driver-less-test": "export TS_USE_WEB_DRIVER_FOR_TEST=false && npm run test",
"cleanup-docker": "if [ $(docker ps -a | grep -c selenium-e2e) -gt 0 ]; then docker rm -f $(docker ps --filter \"name=selenium-e2e\" -aq); fi;",
"test-docker": "npm run cleanup-docker && docker run -it --shm-size=2g -p 5920:5920 --name selenium-e2e -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL eclipse/che-e2e:nightly",
"test-docker-mount-e2e": "npm run cleanup-docker && docker run -it --shm-size=2g -p 5920:5920 --name selenium-e2e -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL -v $(pwd):/tmp/e2e:Z eclipse/che-e2e:nightly",
"test-all-devfiles": " ./configs/sh-scripts/initDefaultValues.sh && ./configs/sh-scripts/initDevfileTests.sh",
"devfile-acceptance-test-suite": "./configs/sh-scripts/initDefaultValues.sh npm run lint && npm run tsc && export TS_USE_WEB_DRIVER_FOR_TEST=false && mocha 'dist/specs/api/*.js' --config dist/configs/mocharc.js --delay --grep 'Devfile acceptance test suite'"
},
"author": "Ihor Okhrimenko ([email protected])",
"license": "ISC",
"devDependencies": {
"@eclipse-che/che-devworkspace-generator": "next",
"@types/chai": "^4.3.4",
"@types/clone-deep": "^4.0.1",
"@types/mocha": "5.2.6",
"@types/node": "11.13.4",
"@types/rimraf": "2.0.2",
"@types/selenium-webdriver": "4.1.3",
"@types/shelljs": "^0.8.11",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/eslint-plugin-tslint": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"axios": "^0.25.0",
"chai": "^4.3.4",
"chromedriver": "^114.0.2",
"clone-deep": "^4.0.1",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-jsdoc": "^46.5.0",
"eslint-plugin-prettier": "^5.0.0",
"husky": "^8.0.3",
"mocha": "^9.1.3",
"monaco-page-objects": "3.1.0",
"prettier": "^3.0.2",
"rimraf": "2.6.2",
"selenium-webdriver": "4.4.0",
"shelljs": "^0.8.5",
"ts-node": "^10.9.1",
"typescript": "4.9.4",
"vscode-extension-tester-locators": "3.1.0",
"yaml": "^2.2.2"
},
"dependencies": {
"@eclipse-che/api": "latest",
"inversify": "6.0.1",
"reflect-metadata": "0.1.13",
"@eclipse-che/che-devworkspace-generator": "7.75.0-SNAPSHOT"
},
"resolutions": {
"minimist": "^1.2.5"
}
}
4 changes: 2 additions & 2 deletions tests/e2e/pageobjects/dashboard/CreateWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class CreateWorkspace {

Logger.debug(`sampleName: "${sampleName}"`);

const sampleLocator: By = this.getSampleLocatorWithSpecificEditor(sampleName);
const sampleLocator: By = this.getSampleWithSpecificEditorLocator(sampleName);
await this.driverHelper.waitAndClick(sampleLocator, timeout);
}

Expand All @@ -80,7 +80,7 @@ export class CreateWorkspace {
return By.xpath(`//div[text()=\'${sampleName}\']//parent::article//button`);
}

private getSampleLocatorWithSpecificEditor(sampleName: string): By {
private getSampleWithSpecificEditorLocator(sampleName: string): By {
let editor: string = '';
switch (process.env.TS_SELENIUM_EDITOR) {
case 'che-code':
Expand Down
64 changes: 63 additions & 1 deletion tests/e2e/pageobjects/dashboard/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,22 @@ export class Dashboard {
private static readonly LOADER_ALERT: By = By.xpath('//*[@data-testid="loader-alert"]');
private static readonly LOGOUT_BUTTON: By = By.xpath('//button[text()="Logout"]');
private static readonly USER_SETTINGS_DROPDOWN: By = By.xpath('//header//button/span[text()!=""]//parent::button');
private static readonly INFO_DROPDOWN_BUTTON: By = By.xpath('//button[@aria-label="About Menu"]');
private static readonly ABOUT_DIALOG_WINDOW_CLOSE_BUTTON: By = By.xpath('//button[@aria-label="Close Dialog"]');
private static readonly EXISTING_WORKSPACE_FOUND_ALERT: By = By.xpath('//h4[text()="Existing workspace found"]');
private static readonly CREATE_NEW_WORKSPACE_LINK: By = By.xpath('//button[text()="Create a new workspace"]');
private static readonly ABOUT_DIALOG_ITEM_DATA_TEST_IDS: any = {
serverVersion: 'server-version',
dashboardVersion: 'dashboard-version',
browserName: 'browser-name',
browserOs: 'browser-os',
browserVersion: 'browser-version',
username: 'username'
};

constructor(
@inject(CLASSES.DriverHelper)
private readonly driverHelper: DriverHelper,
readonly driverHelper: DriverHelper,
@inject(CLASSES.Workspaces) private readonly workspaces: Workspaces
) {}

Expand Down Expand Up @@ -71,6 +81,44 @@ export class Dashboard {
await this.waitPage();
}

async openAboutMenu(): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(Dashboard.INFO_DROPDOWN_BUTTON);
}

async selectAboutMenuItem(text: string): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(this.getAboutMenuItemButtonLocator(text));
}

async waitAboutDialogWindowMenuElements(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
Logger.debug();

for (const testId of Object.values(Dashboard.ABOUT_DIALOG_ITEM_DATA_TEST_IDS)) {
const workspaceDetailsTabLocator: By = this.getAboutDialogWindowItemLocator(<string>testId);

await this.driverHelper.waitVisibility(workspaceDetailsTabLocator, timeout);
}
}

async getApplicationVersionFromAboutDialogWindow(): Promise<string> {
Logger.debug();

return await this.driverHelper.waitAndGetText(
this.getAboutDialogWindowItemLocator(Dashboard.ABOUT_DIALOG_ITEM_DATA_TEST_IDS.serverVersion)
);
}

async getUsernameFromAboutDialogWindow(): Promise<string> {
Logger.debug();

return await this.driverHelper.waitAndGetText(
this.getAboutDialogWindowItemLocator(Dashboard.ABOUT_DIALOG_ITEM_DATA_TEST_IDS.username)
);
}

async waitPage(timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise<void> {
Logger.debug();

Expand Down Expand Up @@ -109,6 +157,12 @@ export class Dashboard {
await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING);
}

async closeAboutDialogWindow(): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(Dashboard.ABOUT_DIALOG_WINDOW_CLOSE_BUTTON);
}

async waitExistingWorkspaceFoundAlert(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
Logger.debug();

Expand All @@ -129,4 +183,12 @@ export class Dashboard {
await this.driverHelper.waitAndClick(Dashboard.LOGOUT_BUTTON, timeout);
await this.driverHelper.waitDisappearance(Dashboard.USER_SETTINGS_DROPDOWN, timeout);
}

private getAboutMenuItemButtonLocator(text: string): By {
return By.xpath(`//li/button[text()="${text}"]`);
}

private getAboutDialogWindowItemLocator(itemDataTestId: string): By {
return By.xpath(`//dd[@data-testid="${itemDataTestId}"]`);
}
}
15 changes: 13 additions & 2 deletions tests/e2e/pageobjects/dashboard/Workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class Workspaces {
);
private static readonly DELETE_CONFIRMATION_CHECKBOX: By = By.xpath('//input[@data-testid="confirmation-checkbox"]');
private static readonly CONFIRMATION_WINDOW: By = By.xpath('//div[@aria-label="Delete workspaces confirmation window"]');
private static readonly LEARN_MORE_DOC_LINK: By = By.xpath('//div/p/a');

constructor(
@inject(CLASSES.DriverHelper)
Expand Down Expand Up @@ -80,13 +81,13 @@ export class Workspaces {
await this.driverHelper.waitVisibility(this.getWorkspaceStatusLocator(workspaceName, WorkspaceStatusUI.Stopped), timeout);
}

async clickWorkspaceListItem(
async clickWorkspaceListItemLink(
workspaceName: string,
timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT
): Promise<void> {
Logger.debug(`"${workspaceName}"`);

await this.driverHelper.waitAndClick(this.getWorkspaceListItemLocator(workspaceName), timeout);
await this.driverHelper.waitAndClick(this.getOpenWorkspaceDetailsLinkLocator(workspaceName), timeout);
}

async clickActionsButton(workspaceName: string): Promise<void> {
Expand Down Expand Up @@ -206,6 +207,12 @@ export class Workspaces {
return workspaceNames;
}

async getLearnMoreDocumentationLink(): Promise<string> {
Logger.debug();

return await this.driverHelper.waitAndGetElementAttribute(Workspaces.LEARN_MORE_DOC_LINK, 'href');
}

private getWorkspaceListItemLocator(workspaceName: string): By {
return By.xpath(`//tr[td//a[text()='${workspaceName}']]`);
}
Expand Down Expand Up @@ -235,4 +242,8 @@ export class Workspaces {
private getOpenButtonLocator(workspaceName: string): By {
return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName).value}//td[@data-key=5]//a[text()='Open']`);
}

private getOpenWorkspaceDetailsLinkLocator(workspaceName: string): By {
return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName).value}//a[text()='${workspaceName}']`);
}
}
Loading

0 comments on commit 6835a01

Please sign in to comment.