Skip to content

Commit

Permalink
fix: timeouts of waiting on extensions complete installation Recommen…
Browse files Browse the repository at this point in the history
…dedExtensions test

Signed-off-by: mdolhalo <[email protected]>
  • Loading branch information
mdolhalo committed Sep 15, 2023
1 parent e38c24d commit 0d9f9cc
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 115 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
4 changes: 3 additions & 1 deletion tests/e2e/constants/PLUGIN_TEST_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ export const PLUGIN_TEST_CONSTANTS: { TS_SAMPLE_LIST: string } = {
/**
* dashboard samples to check in RecommendedExtensions.spec.ts
*/
TS_SAMPLE_LIST: process.env.TS_SAMPLE_LIST || 'Node.js MongoDB,Node.js Express'
TS_SAMPLE_LIST:
process.env.TS_SAMPLE_LIST ||
'Node.js MongoDB,Node.js Express,Java 11 with Lombok,Java 11 with Quarkus,Python,.NET,C/C++,Go,PHP,Ansible'
};
2 changes: 1 addition & 1 deletion tests/e2e/constants/TIMEOUT_CONSTANTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const TIMEOUT_CONSTANTS: {
// -------------------------------------------- EDITOR --------------------------------------------

/**
* timeout for inetractions with editor tab - wait, click, select, "8 000" by default.
* timeout for interactions with editor tab - wait, click, select, "8 000" by default.
*/
TS_EDITOR_TAB_INTERACTION_TIMEOUT: Number(process.env.TS_OPEN_PROJECT_TREE_TIMEOUT) || 8_000,

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"
}
}
75 changes: 31 additions & 44 deletions tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import { CheCodeLocatorLoader } from '../../pageobjects/ide/CheCodeLocatorLoader
import { expect } from 'chai';
import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
import { PLUGIN_TEST_CONSTANTS } from '../../constants/PLUGIN_TEST_CONSTANTS';
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { PLUGIN_TEST_CONSTANTS } from '../../constants/PLUGIN_TEST_CONSTANTS';

const samples: string[] = PLUGIN_TEST_CONSTANTS.TS_SAMPLE_LIST.split(',');

Expand All @@ -50,7 +50,6 @@ suite(`Check if recommended extensions installed for ${samples}`, function (): v

let projectSection: ViewSection;
let extensionsView: SideBarView | undefined;
let extensionSection: ExtensionsViewSection;

const extensionsListFileName: string = 'extensions.json';
let recommendedExtensions: any = {
Expand Down Expand Up @@ -80,7 +79,7 @@ suite(`Check if recommended extensions installed for ${samples}`, function (): v
const label: string = BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME;
Logger.debug(`projectSection.findItem: find ${label}`);
const isFileImported: ViewItem | undefined = await projectSection.findItem(label);
expect(isFileImported).not.eqls(undefined);
expect(isFileImported).not.undefined;
try {
const buttonYesITrustTheAuthors: string = 'Yes, I trust the authors';
await driverHelper.waitVisibility(
Expand Down Expand Up @@ -113,95 +112,83 @@ suite(`Check if recommended extensions installed for ${samples}`, function (): v
return { publisher, name };
}
);
Logger.info(`Recommended extension for this workspace:\n${JSON.stringify(recommendedExtensions.recommendations)}.`);
Logger.debug(`Recommended extension for this workspace:\n${JSON.stringify(recommendedExtensions.recommendations)}.`);
expect(recommendedExtensions.recommendations).not.empty;
});

test('Open "Extensions" view section', async function (): Promise<void> {
Logger.debug('ActivityBar().getViewControl("Extensions"))?.openView(): open Extensions view.');
extensionsView = await (await new ActivityBar().getViewControl('Extensions'))?.openView();
expect(extensionsView).not.undefined;
});

test('Let extensions complete installation', async function (): Promise<void> {
Logger.info(
Logger.debug(
`Time for extensions installation TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT=${TIMEOUT_CONSTANTS.TS_COMMON_PLUGIN_TEST_TIMEOUT}`
);
await driverHelper.wait(TIMEOUT_CONSTANTS.TS_COMMON_PLUGIN_TEST_TIMEOUT);
});

test('Check if extensions are installed and enabled', async function (): Promise<void> {
this.retries(10);
Logger.debug('ActivityBar().getViewControl("Extensions"))?.openView(): open Extensions view.');
extensionsView = await (await new ActivityBar().getViewControl('Extensions'))?.openView();

Logger.debug('extensionsView?.getContent().getSections(): get current section.');
[extensionSection] = (await extensionsView?.getContent().getSections()) as ExtensionsViewSection[];
await driverHelper.waitAllPresence(
webCheCodeLocators.ExtensionsViewSection.itemTitle,
TIMEOUT_CONSTANTS.TS_EDITOR_TAB_INTERACTION_TIMEOUT
);
// timeout 15 seconds per extensions
this.test?.timeout((TIMEOUT_CONSTANTS.TS_COMMON_PLUGIN_TEST_TIMEOUT / 2) * recommendedExtensions.recommendations.length);

for (const extension of recommendedExtensions.recommendations) {
Logger.info(`Check if ${JSON.stringify(extension)} are installed.`);

Logger.debug(`extensionSection.findItem(${extension.name}).`);
await extensionSection.findItem(extension.name);

// check if extension require reload the page
if (await driverHelper.isVisible((webCheCodeLocators.ExtensionsViewSection as any).requireReloadButton)) {
Logger.debug('Extension require reload the editor. Refreshing the page..');
const isReloadRequired: boolean = await driverHelper.isVisible(
(webCheCodeLocators.ExtensionsViewSection as any).requireReloadButton
);
Logger.debug(`Is extensions require reload the editor: ${isReloadRequired}`);
if (isReloadRequired) {
Logger.debug('Refreshing the page..');
await browserTabsUtil.refreshPage();
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
Logger.debug('ActivityBar().getViewControl("Extensions"))?.openView(): open Extensions view.');
Logger.debug('ActivityBar().getViewControl("Extensions"))?.openView(): reopen Extensions view.');
extensionsView = await (await new ActivityBar().getViewControl('Extensions'))?.openView();
Logger.debug('extensionsView?.getContent().getSections(): get current section.');
[extensionSection] = (await extensionsView?.getContent().getSections()) as ExtensionsViewSection[];
await driverHelper.waitAllPresence(
webCheCodeLocators.ExtensionsViewSection.itemTitle,
TIMEOUT_CONSTANTS.TS_EDITOR_TAB_INTERACTION_TIMEOUT
);
Logger.debug(`extensionSection.findItem(${extension.name}).`);
await extensionSection.findItem(extension.name);
expect(extensionsView).not.undefined;
}

Logger.debug('extensionsView?.getContent().getSections(): switch to marketplace section.');
Logger.debug('extensionsView.getContent().getSections(): get current extensions section to search the extension.');
const [extensionSection]: ExtensionsViewSection[] = (await extensionsView
?.getContent()
.getSections()) as ExtensionsViewSection[];
await driverHelper.waitVisibility(webCheCodeLocators.ExtensionsViewSection.items);

Logger.debug(`extensionSection.findItem(${extension.name})`);
await extensionSection.findItem(extension.name);
Logger.debug('extensionsView.getContent().getSections(): switch to marketplace section.');
const [marketplaceSection]: ExtensionsViewSection[] = (await extensionsView
?.getContent()
.getSections()) as ExtensionsViewSection[];
await driverHelper.waitVisibility(
webCheCodeLocators.ExtensionsViewSection.items,
TIMEOUT_CONSTANTS.TS_EDITOR_TAB_INTERACTION_TIMEOUT
);

Logger.debug('marketplaceSection.getVisibleItems(): get all found items.');
Logger.debug('marketplaceSection.getVisibleItems()');
const allFinedItems: ExtensionsViewItem[] = await marketplaceSection.getVisibleItems();

let itemWithRightNameAndPublisher: ExtensionsViewItem | undefined;
expect(allFinedItems).not.empty;
let itemWithRightNameAndPublisher: ExtensionsViewItem | undefined = undefined;
for (const item of allFinedItems) {
Logger.debug(`Try to find extension published by ${extension.publisher}.`);
if ((await item.getAuthor()) === extension.publisher) {
itemWithRightNameAndPublisher = item;
Logger.debug(`Extension was found: ${await itemWithRightNameAndPublisher?.getTitle()}`);
break;
}
if (itemWithRightNameAndPublisher === undefined) {
Logger.error(`Extension with publisher as ${extension.publisher} was not found.`);
}
expect(itemWithRightNameAndPublisher).not.undefined;
}

Logger.debug('itemWithRightNameAndPublisher?.isInstalled()');
const isInstalled: boolean = (await itemWithRightNameAndPublisher?.isInstalled()) as boolean;

Logger.debug(`itemWithRightNameAndPublisher?.isInstalled(): ${isInstalled}.`);
expect(isInstalled).eqls(true);
expect(isInstalled).is.true;

Logger.debug('itemWithRightNameAndPublisher.manage(): get context menu.');
const extensionManageMenu: ContextMenu = await (itemWithRightNameAndPublisher as ExtensionsViewItem).manage();

Logger.debug('extensionManageMenu.getItems(): get menu items.');
const extensionMenuItems: ContextMenuItem[] = await extensionManageMenu.getItems();
let extensionMenuItemLabels: string = '';
Logger.trace('extensionMenuItems -> item.getLabel(): get menu items names.');
for (const item of extensionMenuItems) {
Logger.trace('extensionMenuItems -> item.getLabel(): get menu items names.');
extensionMenuItemLabels += (await item.getLabel()) + ' ';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS';
const stackName: string = BASE_TEST_CONSTANTS.TS_SELENIUM_DASHBOARD_SAMPLE_NAME || 'Python';
const projectName: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_PROJECT_NAME || 'python-hello-world';

suite(`"Start workspace with existed workspace name" test`, function (): void {
suite('"Start workspace with existed workspace name" test', function (): void {
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
Expand All @@ -47,11 +47,11 @@ suite(`"Start workspace with existed workspace name" test`, function (): void {
expect(isFileImported).not.eqls(undefined);
});

test(`Stop created workspace`, async function (): Promise<void> {
test('Stop created workspace', async function (): Promise<void> {
existedWorkspaceName = WorkspaceHandlingTests.getWorkspaceName();
await workspaceHandlingTests.stopWorkspace(existedWorkspaceName);
await browserTabsUtil.closeAllTabsExceptCurrent();
});
});

test(`Create new workspace from the same ${stackName} stack`, async function (): Promise<void> {
existedWorkspaceName = WorkspaceHandlingTests.getWorkspaceName();
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"compilerOptions": {
"skipLibCheck": true,
"target": "es2017",
"target": "es2021",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"outDir": "dist",
"lib": ["es2017", "dom"],
"lib": ["es2021", "dom"],
"types": ["reflect-metadata", "@types/mocha", "@types/node"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
Expand Down
15 changes: 12 additions & 3 deletions tests/e2e/utils/DriverHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,21 @@ export class DriverHelper {
);
}

async waitAllVisibility(locators: Array<By>, timeout: number): Promise<void> {
async waitAllVisibilityBoolean(
locators: Array<By>,
timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
): Promise<boolean> {
Logger.trace(`${locators}`);

for (const elementLocator of locators) {
await this.waitVisibility(elementLocator, timeout);
try {
for (const elementLocator of locators) {
await this.waitVisibilityBoolean(elementLocator, timeout);
}
} catch (e) {
Logger.error(e as string);
return false;
}
return true;
}

async waitDisappearance(
Expand Down

0 comments on commit 0d9f9cc

Please sign in to comment.