diff --git a/tests/e2e/specs/dashboard-samples/Documentation.spec.ts b/tests/e2e/specs/dashboard-samples/Documentation.spec.ts index bf02990af6e..a06d3910877 100644 --- a/tests/e2e/specs/dashboard-samples/Documentation.spec.ts +++ b/tests/e2e/specs/dashboard-samples/Documentation.spec.ts @@ -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(); diff --git a/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts b/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts index 71f5c6d8670..0a3757691ac 100644 --- a/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts +++ b/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts @@ -98,6 +98,8 @@ for (const sample of samples) { const [pathToExtensionsListFileName, extensionsListFileName]: string[] = ['.vscode', 'extensions.json']; + let vsCodeFolderItemLevel: number = 2; + let recommendedExtensions: any = { recommendations: [] }; @@ -123,28 +125,48 @@ for (const sample of samples) { await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); }); + test('Accept the project as a trusted one', async function (): Promise { + await projectAndFileTests.performTrustAuthorDialog(); + }); + test('Check the project files were imported', async function (): Promise { // 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 { - 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 { // 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); diff --git a/tests/e2e/utils/BrowserTabsUtil.ts b/tests/e2e/utils/BrowserTabsUtil.ts index 2168cbb2c08..85cc6b6fdc9 100644 --- a/tests/e2e/utils/BrowserTabsUtil.ts +++ b/tests/e2e/utils/BrowserTabsUtil.ts @@ -76,14 +76,21 @@ export class BrowserTabsUtil { async getCurrentUrl(): Promise { 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 {