Skip to content

Commit

Permalink
Fix up factory E2E test to avoid 'Restricted' mode (#22672)
Browse files Browse the repository at this point in the history
* Add method to manage 'trust' workspace box
* Update E2E tests of factory flow
  • Loading branch information
artaleks9 authored Nov 16, 2023
1 parent 677d4d6 commit ddec5bf
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ export class CheCodeLocatorLoader extends LocatorLoader {
},
TreeItem: {
projectFolderItem: By.xpath('.//div[contains(@class, "rootfolder-icon projects-name-dir")]')
},
ScmView: {
manageWorkspaceTrust: By.xpath('.//a[@class="monaco-button monaco-text-button"]'),
modifiedFile: By.xpath('//div[@class="monaco-list-row" and contains(@aria-label, "Modified")]')
},
Workbench: {
workspaceTrustButton: By.xpath('//a[@role="button" and text()="Trust"]')
}
}
};
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/specs/factory/Factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ suite(
const scmView: NewScmView = new NewScmView();
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.inputField);
[scmProvider, ...rest] = await scmView.getProviders();
if (scmProvider === undefined) {
await projectAndFileTests.performManageWorkspaceTrustBox();
[scmProvider, ...rest] = await scmView.getProviders();
}
Logger.debug(`scmView.getProviders: "${JSON.stringify(scmProvider)}, ${rest}"`);
});

Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ suite(
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.inputField);
let rest: SingleScmProvider[];
[scmProvider, ...rest] = await scmView.getProviders();
if (scmProvider === undefined) {
await projectAndFileTests.performManageWorkspaceTrustBox();
[scmProvider, ...rest] = await scmView.getProviders();
}
Logger.debug(`scmView.getProviders: "${JSON.stringify(scmProvider)}, ${rest}"`);
});

Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ suite(
const scmView: NewScmView = new NewScmView();
await driverHelper.waitVisibility(webCheCodeLocators.ScmView.inputField);
[scmProvider, ...rest] = await scmView.getProviders();
if (scmProvider === undefined) {
await projectAndFileTests.performManageWorkspaceTrustBox();
[scmProvider, ...rest] = await scmView.getProviders();
}
Logger.debug(`scmView.getProviders: "${JSON.stringify(scmProvider)}, ${rest}"`);
});

Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/tests-library/ProjectAndFileTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,32 @@ export class ProjectAndFileTests {
}
}

/**
* manage to 'Trusted' Workspace Mode, when the trust author dialog does not appear
* the "Manage Workspace Trust" box is appeared in Source Control View
*/
async performManageWorkspaceTrustBox(): Promise<void> {
Logger.debug();

try {
await this.driverHelper.waitAndClick(
(this.cheCodeLocatorLoader.webCheCodeLocators.ScmView as any).manageWorkspaceTrust,
TIMEOUT_CONSTANTS.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT
);
await this.driverHelper.waitAndClick(
(this.cheCodeLocatorLoader.webCheCodeLocators.Workbench as any).workspaceTrustButton,
TIMEOUT_CONSTANTS.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT
);
await this.driverHelper.waitAndClick(
(this.cheCodeLocatorLoader.webCheCodeLocators.ScmView as any).modifiedFile,
TIMEOUT_CONSTANTS.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT
);
} catch (err) {
Logger.error(`Manage Workspace Trust box was not shown: ${err}`);
throw err;
}
}

/**
* find an ViewSection with project tree.
* @returns Promise resolving to ViewSection object
Expand Down

0 comments on commit ddec5bf

Please sign in to comment.