Skip to content

Commit

Permalink
Fix timeouts and refresh editor in 'Recommended extensions' test (#22174
Browse files Browse the repository at this point in the history
)

Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
  • Loading branch information
dmytro-ndp authored Apr 25, 2023
1 parent d6b1d77 commit 7156932
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/constants/TimeoutConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,6 @@ export const TimeoutConstants: any = {
/**
* Common timeout for plugins.
*/
TS_COMMON_PLUGIN_TEST_TIMEOUT: Number(process.env.TS_COMMON_PLUGIN_TEST_TIMEOUT) || 15_000
TS_COMMON_PLUGIN_TEST_TIMEOUT: Number(process.env.TS_COMMON_PLUGIN_TEST_TIMEOUT) || 30_000

};
6 changes: 5 additions & 1 deletion tests/e2e/pageobjects/dashboard/Workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { CLASSES } from '../../configs/inversify.types';
import { By, WebElement } from 'selenium-webdriver';
import { Logger } from '../../utils/Logger';
import { TimeoutConstants } from '../../constants/TimeoutConstants';
import { TestConstants } from '../../constants/TestConstants';

export enum WorkspaceStatusUI {
Running = 'green',
Expand Down Expand Up @@ -163,9 +164,12 @@ export class Workspaces {
async waitWorkspaceListItemAbcence(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
Logger.debug(`Workspaces.waitWorkspaceListItemAbcence "${workspaceName}"`);

const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
const attempts: number = Math.ceil(timeout / polling);

const workspaceListItemLocator: By = By.xpath(this.getWorkspaceListItemLocator(workspaceName));

await this.driverHelper.waitDisappearance(workspaceListItemLocator, timeout);
await this.driverHelper.waitDisappearance(workspaceListItemLocator, attempts, polling);
}

async getAllCreatedWorkspacesNames(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<string[]> {
Expand Down
21 changes: 18 additions & 3 deletions tests/e2e/specs/dashboard-samples/RecomendedExtentions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { CheCodeLocatorLoader } from '../../pageobjects/ide/CheCodeLocatorLoader
import { expect } from 'chai';
import { TimeoutConstants } from '../../constants/TimeoutConstants';
import { TestConstants } from '../../constants/TestConstants';
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';

const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
Expand All @@ -42,6 +43,7 @@ const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);

const webCheCodeLocators: Locators = new CheCodeLocatorLoader().webCheCodeLocators;
const samples: any = TestConstants.TS_SAMPLE_LIST.split(',');
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);

suite(`Check if recommended extensions installed for ${samples}`, async function (): Promise<void> {
let projectSection: ViewSection;
Expand Down Expand Up @@ -102,38 +104,51 @@ suite(`Check if recommended extensions installed for ${samples}`, async function
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();
Logger.debug(`extensionsView?.getContent().getSections(): get current section.`);
[extensionSection] = await extensionsView?.getContent().getSections() as ExtensionsViewSection[];
});

test(`Wait until extensions starts installation`, async function (): Promise<void> {
test(`Let extensions complete installation`, async function (): Promise<void> {
Logger.info(`Time for extensions installation TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT=${TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT}`);
await driverHelper.wait(TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT);
browserTabsUtil.refreshPage();
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
});

test(`Check if extensions is installed and enabled`, async function (): Promise<void> {
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[];

Logger.info(`Check if recommendedExtensions.recommendations are installed: ${recommendedExtensions.recommendations}.`);
for (const extension of recommendedExtensions.recommendations) {
Logger.debug(`extensionSection.findItem(${extension}).`);
await extensionSection.findItem(extension);

Logger.debug(`extensionsView?.getContent().getSections(): switch to marketplace section.`);
const [marketplaceSection]: ExtensionsViewSection[] = await extensionsView?.getContent().getSections() as ExtensionsViewSection[];
await driverHelper.waitVisibility(webCheCodeLocators.ExtensionsViewSection.items, TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT);

Logger.debug(`marketplaceSection.getVisibleItems(): get first item.`);
const [firstFoundItem]: ExtensionsViewItem[] = await marketplaceSection.getVisibleItems();

Logger.debug(`firstFoundItem?.isInstalled()`);
const isInstalled: boolean = await firstFoundItem?.isInstalled() as boolean;

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

Logger.debug(`firstFoundItem.manage(): get context menu.`);
const extensionManageMenu: ContextMenu = await firstFoundItem.manage();

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

Logger.debug(`extensionMenuItemLabels: ${extensionMenuItemLabels}.`);
expect(extensionMenuItemLabels).contains('Disable').and.not.contains('Enable');
}
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/utils/CheReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class CheReporter extends mocha.reporters.Spec {
TS_SELENIUM_LOG_LEVEL: ${TestConstants.TS_SELENIUM_LOG_LEVEL}
TS_SELENIUM_LAUNCH_FULLSCREEN: ${TestConstants.TS_SELENIUM_LAUNCH_FULLSCREEN}
TS_COMMON_DASHBOARD_WAIT_TIMEOUT: ${TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT}
TS_SELENIUM_START_WORKSPACE_TIMEOUT: ${TimeoutConstants.TS_SELENIUM_START_WORKSPACE_TIMEOUT}
TS_WAIT_LOADER_PRESENCE_TIMEOUT: ${TimeoutConstants.TS_WAIT_LOADER_PRESENCE_TIMEOUT}
TS_SAMPLE_LIST: ${TestConstants.TS_SAMPLE_LIST}
${process.env.MOCHA_DIRECTORY ? 'MOCHA_DIRECTORY: ' + process.env.MOCHA_DIRECTORY : 'MOCHA_DRIRECTORY is not set'}
${process.env.USERSTORY ? 'USERSTORY: ' + process.env.USERSTORY : 'USERSTORY is not set'}
`;
Expand Down

0 comments on commit 7156932

Please sign in to comment.