Skip to content

Commit

Permalink
Adapt RecommendedExtensions test to "JBoss EAP 8.0" sample; stabilize…
Browse files Browse the repository at this point in the history
… "Documentation" test (#23226)

Signed-off-by: Dmytro Nochevnov <[email protected]>
  • Loading branch information
dmytro-ndp authored Nov 5, 2024
1 parent 2d10027 commit bb74bd0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
3 changes: 3 additions & 0 deletions tests/e2e/specs/dashboard-samples/Documentation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ suite(`Check links to documentation page in Dashboard ${BASE_TEST_CONSTANTS.TEST
await dashboard.selectAboutMenuItem(link.text);
await browserTabsUtil.waitAndSwitchToAnotherWindow(parentGUID);
const currentUrl: string = await browserTabsUtil.getCurrentUrl();

Logger.trace(`Current URL: ${currentUrl}`);

expect(link.href, `${link.href} not includes ${currentUrl}`).oneOf([currentUrl, currentUrl + '/']);
await browserTabsUtil.switchToWindow(parentGUID);
await browserTabsUtil.closeAllTabsExceptCurrent();
Expand Down
40 changes: 31 additions & 9 deletions tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ for (const sample of samples) {

const [pathToExtensionsListFileName, extensionsListFileName]: string[] = ['.vscode', 'extensions.json'];

let vsCodeFolderItemLevel: number = 2;

let recommendedExtensions: any = {
recommendations: []
};
Expand All @@ -123,28 +125,48 @@ for (const sample of samples) {
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
});

test('Accept the project as a trusted one', async function (): Promise<void> {
await projectAndFileTests.performTrustAuthorDialog();
});

test('Check the project files were imported', async function (): Promise<void> {
// add TS_IDE_LOAD_TIMEOUT timeout for waiting for finishing animation of all IDE parts (Welcome parts. bottom widgets. etc.)
// using TS_IDE_LOAD_TIMEOUT easier than performing of finishing animation all elements
await driverHelper.wait(TIMEOUT_CONSTANTS.TS_IDE_LOAD_TIMEOUT);
projectSection = await projectAndFileTests.getProjectViewSession();
expect(await projectAndFileTests.getProjectTreeItem(projectSection, pathToExtensionsListFileName), 'Files not imported').not
.undefined;
});

test('Accept the project as a trusted one', async function (): Promise<void> {
await projectAndFileTests.performTrustAuthorDialog();
try {
// try using project level 2, as in samples from https://github.com/devspaces-samples/
expect(
await projectAndFileTests.getProjectTreeItem(projectSection, pathToExtensionsListFileName, vsCodeFolderItemLevel),
'Files not imported'
).not.undefined;
} catch (err) {
Logger.debug(
'Try using project level 1, as in samples with a defined metadata.projectType in the devfile.yaml, such as JBoss EAP.'
);
vsCodeFolderItemLevel = vsCodeFolderItemLevel - 1;
expect(
await projectAndFileTests.getProjectTreeItem(projectSection, pathToExtensionsListFileName, vsCodeFolderItemLevel),
'Files not imported'
).not.undefined;
}
});

test(`Get recommended extensions list from ${extensionsListFileName}`, async function (): Promise<void> {
// sometimes the Trust Dialog does not appear as expected - as result we need to execute "projectAndFileTests.performManageWorkspaceTrustBox()" method. In this case.
try {
await (await projectAndFileTests.getProjectTreeItem(projectSection, pathToExtensionsListFileName))?.select();
await (
await projectAndFileTests.getProjectTreeItem(projectSection, pathToExtensionsListFileName, vsCodeFolderItemLevel)
)?.select();
} catch (err) {
await projectAndFileTests.performManageWorkspaceTrustBox();
await (await projectAndFileTests.getProjectTreeItem(projectSection, pathToExtensionsListFileName))?.select();
await (
await projectAndFileTests.getProjectTreeItem(projectSection, pathToExtensionsListFileName, vsCodeFolderItemLevel)
)?.select();
}
await (await projectAndFileTests.getProjectTreeItem(projectSection, extensionsListFileName, 3))?.select();
await (
await projectAndFileTests.getProjectTreeItem(projectSection, extensionsListFileName, vsCodeFolderItemLevel + 1)
)?.select();
Logger.debug(`EditorView().openEditor(${extensionsListFileName})`);
const editor: TextEditor = (await new EditorView().openEditor(extensionsListFileName)) as TextEditor;
await driverHelper.waitVisibility(webCheCodeLocators.Editor.inputArea);
Expand Down
19 changes: 13 additions & 6 deletions tests/e2e/utils/BrowserTabsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,21 @@ export class BrowserTabsUtil {
async getCurrentUrl(): Promise<string> {
Logger.trace();

let currentUrl: string = '';
try {
currentUrl = await this.driverHelper.getDriver().getCurrentUrl();
} catch (e) {
Logger.trace('cannot get current url');
const maxAttempts: number = 5;
let attempts: number = 0;
while (attempts < maxAttempts) {
try {
return await this.driverHelper.getDriver().getCurrentUrl();
} catch (e) {
Logger.trace(`Attempt ${attempts + 1} failed: cannot get current url`);

attempts++;

await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_SELENIUM_WAIT_FOR_URL);
}
}

return currentUrl;
throw new Error('Max attempts reached: cannot get current url');
}

async waitURL(expectedUrl: string, timeout: number): Promise<void> {
Expand Down

0 comments on commit bb74bd0

Please sign in to comment.