Skip to content

Commit

Permalink
Merge pull request #17793 from ScrewTSW/17702-feature-fix-project-tre…
Browse files Browse the repository at this point in the history
…e-and-project-import-logic

Fix project tree and project import logic
  • Loading branch information
ScrewTSW authored Sep 7, 2020
2 parents c2872c5 + 53955d3 commit 9f6c80f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions tests/e2e/pageobjects/ide/ProjectTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ export class ProjectTree {
async openProjectTreeContainer(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('ProjectTree.openProjectTreeContainer');

const selectedExplorerButtonLocator: By = By.css(Ide.SELECTED_EXPLORER_BUTTON_CSS);
const explorerButtonActiveLocator: By = this.getLeftToolbarButtonActiveLocator(LeftToolbarButton.Explorer);
Logger.trace(`ProjectTree.openProjectTreeContainer waitLeftToolbarButtonPresence`);
await this.ide.waitLeftToolbarButton(LeftToolbarButton.Explorer, timeout);

const isButtonEnabled: boolean = await this.driverHelper.waitVisibilityBoolean(selectedExplorerButtonLocator);
Logger.trace(`ProjectTree.openProjectTreeContainer leftToolbarButtonEnabled:${isButtonEnabled}`);
if (!isButtonEnabled) {
const isButtonActive: boolean = await this.driverHelper.waitVisibilityBoolean(explorerButtonActiveLocator);
Logger.trace(`ProjectTree.openProjectTreeContainer leftToolbarButtonActive:${isButtonActive}`);
if (!isButtonActive) {
await this.ide.waitAndClickLeftToolbarButton(LeftToolbarButton.Explorer, timeout);
}

Expand Down Expand Up @@ -267,7 +267,8 @@ export class ProjectTree {
const rootSubitemLocator: By = By.css(this.getTreeItemCssLocator(`${projectName}/${rootSubItem}`));

for (let i = 0; i < attempts; i++) {
const isProjectFolderVisible = await this.driverHelper.waitVisibilityBoolean(rootItemLocator, 1, visibilityItemPolling);
// do five checks of the item in one fifth of the time given for root folder item (was causing frequent reloads of the workspace)
const isProjectFolderVisible = await this.driverHelper.waitVisibilityBoolean(rootItemLocator, 5, visibilityItemPolling / 5);

if (!isProjectFolderVisible) {
Logger.trace(`ProjectTree.waitProjectImported project not located, reloading page.`);
Expand All @@ -283,7 +284,8 @@ export class ProjectTree {
await this.expandItem(rootItem);
await this.waitItemExpanded(rootItem);

const isRootSubItemVisible = await this.driverHelper.waitVisibilityBoolean(rootSubitemLocator, 1, visibilityItemPolling);
// do five checks of the item in one fifth of the time given for root folder item (was causing frequent reloads of the workspace)
const isRootSubItemVisible = await this.driverHelper.waitVisibilityBoolean(rootSubitemLocator, 5, visibilityItemPolling / 5);

if (!isRootSubItemVisible) {
Logger.trace(`ProjectTree.waitProjectImported sub-items not found, reloading page.`);
Expand Down Expand Up @@ -336,6 +338,11 @@ export class ProjectTree {
return attribute.split(splitDelimeter)[0] + splitDelimeter;
}

private getLeftToolbarButtonActiveLocator(buttonTitle: String): By {
return By.xpath(`//div[@id='theia-left-content-panel']//ul[@class='p-TabBar-content']` +
`//li[@title[contains(.,'${buttonTitle}')] and contains(@id, 'shell-tab') and contains(@class, 'p-mod-current')]`);
}

private async getItemCss(itemPath: string): Promise<string> {
const entry: string = await this.getWorkspacePathEntry();
return `div[id='${entry}/projects/${itemPath}']`;
Expand Down

0 comments on commit 9f6c80f

Please sign in to comment.