diff --git a/tests/e2e/pageobjects/dashboard/Dashboard.ts b/tests/e2e/pageobjects/dashboard/Dashboard.ts index beda2f7dc43f..15b001a459d6 100644 --- a/tests/e2e/pageobjects/dashboard/Dashboard.ts +++ b/tests/e2e/pageobjects/dashboard/Dashboard.ts @@ -163,7 +163,7 @@ export class Dashboard { await this.driverHelper.waitAndClick(Dashboard.ABOUT_DIALOG_WINDOW_CLOSE_BUTTON); } - async waitExistingWorkspaceFoundAlert(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { + async waitExistingWorkspaceFoundAlert(timeout: number = TIMEOUT_CONSTANTS.TS_WAIT_LOADER_PRESENCE_TIMEOUT): Promise { Logger.debug(); await this.driverHelper.waitVisibility(Dashboard.EXISTING_WORKSPACE_FOUND_ALERT, timeout); diff --git a/tests/e2e/specs/SmokeTest.spec.ts b/tests/e2e/specs/SmokeTest.spec.ts index 4a5f08bf76f6..7782843b3578 100644 --- a/tests/e2e/specs/SmokeTest.spec.ts +++ b/tests/e2e/specs/SmokeTest.spec.ts @@ -7,13 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ -import { SideBarView, ViewItem, ViewSection } from 'monaco-page-objects'; +import { ViewSection } from 'monaco-page-objects'; import { ProjectAndFileTests } from '../tests-library/ProjectAndFileTests'; import { CLASSES } from '../configs/inversify.types'; import { e2eContainer } from '../configs/inversify.config'; import { WorkspaceHandlingTests } from '../tests-library/WorkspaceHandlingTests'; import { registerRunningWorkspace } from './MochaHooks'; -import { Logger } from '../utils/Logger'; import { LoginTests } from '../tests-library/LoginTests'; import { StringUtil } from '../utils/StringUtil'; import { FACTORY_TEST_CONSTANTS } from '../constants/FACTORY_TEST_CONSTANTS'; @@ -45,15 +44,15 @@ suite('The SmokeTest userstory', function (): void { }); test('Check a project folder has been created', async function (): Promise { const projectName: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_PROJECT_NAME || StringUtil.getProjectNameFromGitUrl(factoryUrl); - projectSection = (await new SideBarView().getContent().getSections())[0]; // get the (WORKSPACE) section from the sidebar - contains project content - expect(await projectSection.findItem(projectName)).not.eqls(undefined); + projectSection = await projectAndFileTests.getProjectViewSession(); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, projectName), 'Project folder was not imported').not + .undefined; }); test('Check the project files was imported', async function (): Promise { - Logger.debug(`projectSection.findItem: find ${BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME}`); - const isFileImported: ViewItem | undefined = await projectSection.findItem( - BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME - ); - expect(isFileImported).not.eqls(undefined); + expect( + await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME), + 'Project files were not imported' + ).not.undefined; }); test('Stop the workspace', async function (): Promise { await workspaceHandlingTests.stopWorkspace(WorkspaceHandlingTests.getWorkspaceName()); diff --git a/tests/e2e/specs/dashboard-samples/Quarkus.spec.ts b/tests/e2e/specs/dashboard-samples/Quarkus.spec.ts index acd20f07092d..b54c2bc8fafd 100644 --- a/tests/e2e/specs/dashboard-samples/Quarkus.spec.ts +++ b/tests/e2e/specs/dashboard-samples/Quarkus.spec.ts @@ -8,16 +8,16 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ -import { SideBarView, ViewSection } from 'monaco-page-objects'; +import { ViewSection } from 'monaco-page-objects'; import { registerRunningWorkspace } from '../MochaHooks'; import { LoginTests } from '../../tests-library/LoginTests'; import { e2eContainer } from '../../configs/inversify.config'; import { CLASSES } from '../../configs/inversify.types'; import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests'; import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests'; -import { Logger } from '../../utils/Logger'; import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS'; import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; +import { expect } from 'chai'; const stackName: string = 'Java 11 with Quarkus'; @@ -28,7 +28,6 @@ suite(`The ${stackName} userstory`, function (): void { const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); let projectSection: ViewSection; - const projectName: string = 'quarkus-quickstarts'; loginTests.loginIntoChe(); @@ -50,13 +49,19 @@ suite(`The ${stackName} userstory`, function (): void { }); test('Check a project folder has been created', async function (): Promise { - projectSection = await new SideBarView().getContent().getSection(projectName); - Logger.debug(`new SideBarView().getContent().getSection: get ${projectName}`); + projectSection = await projectAndFileTests.getProjectViewSession(); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, projectName), 'Project folder was not imported').not.undefined; + }); + + test('Accept the project as a trusted one', async function (): Promise { + await projectAndFileTests.performTrustAuthorDialog(); }); test('Check the project files was imported', async function (): Promise { - await projectSection.findItem(BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME); - Logger.debug(`projectSection.findItem: find ${BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME}`); + expect( + await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME, 2), + 'Project files were not imported' + ).not.undefined; }); test('Stop the workspace', async function (): Promise { @@ -67,5 +72,6 @@ suite(`The ${stackName} userstory`, function (): void { test('Delete the workspace', async function (): Promise { await workspaceHandlingTests.removeWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); + loginTests.logoutFromChe(); }); diff --git a/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts b/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts index a60ee7427b05..39054dd13ef0 100644 --- a/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts +++ b/tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts @@ -74,8 +74,9 @@ for (const sample of samples) { }); test('Check the project files were imported', async function (): Promise { - const [projectSection]: ViewSection[] = await new SideBarView().getContent().getSections(); - expect(await projectSection.findItem(pathToExtensionsListFileName), 'Files not imported').not.undefined; + 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 { @@ -83,11 +84,8 @@ for (const sample of samples) { }); test(`Get recommended extensions list from ${extensionsListFileName}`, async function (): Promise { - Logger.debug('projectSection.findItem(item))?.select(): expand .vscode folder and open extensions.json.'); - [projectSection] = await new SideBarView().getContent().getSections(); - await (await projectSection.findItem(pathToExtensionsListFileName))?.select(); - await driverHelper.waitVisibility(webCheCodeLocators.DefaultTreeItem.ctor(extensionsListFileName)); - await (await projectSection.findItem(extensionsListFileName))?.select(); + await (await projectAndFileTests.getProjectTreeItem(projectSection, pathToExtensionsListFileName))?.select(); + await (await projectAndFileTests.getProjectTreeItem(projectSection, extensionsListFileName, 3))?.select(); Logger.debug(`EditorView().openEditor(${extensionsListFileName})`); const editor: TextEditor = (await new EditorView().openEditor(extensionsListFileName)) as TextEditor; await driverHelper.waitVisibility(webCheCodeLocators.Editor.inputArea); @@ -185,7 +183,7 @@ for (const sample of samples) { const isInstalled: boolean = (await itemWithRightNameAndPublisher?.isInstalled()) as boolean; Logger.debug(`itemWithRightNameAndPublisher?.isInstalled(): ${isInstalled}.`); - expect(isInstalled, `Extension ${extension.name} not installed`).is.true; + expect(isInstalled, `Extension ${extension.name} not installed`).to.be.true; Logger.debug('itemWithRightNameAndPublisher.manage(): get context menu.'); const extensionManageMenu: ContextMenu = await (itemWithRightNameAndPublisher as ExtensionsViewItem).manage(); diff --git a/tests/e2e/specs/devconsole-intergration/DevConsoleIntegration.spec.ts b/tests/e2e/specs/devconsole-intergration/DevConsoleIntegration.spec.ts index 3b150d70e936..05b037a45196 100644 --- a/tests/e2e/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +++ b/tests/e2e/specs/devconsole-intergration/DevConsoleIntegration.spec.ts @@ -8,7 +8,7 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ -import { SideBarView, ViewItem, ViewSection } from 'monaco-page-objects'; +import { ViewSection } from 'monaco-page-objects'; import { registerRunningWorkspace } from '../MochaHooks'; import { LoginTests } from '../../tests-library/LoginTests'; import { e2eContainer } from '../../configs/inversify.config'; @@ -88,9 +88,15 @@ suite('DevConsole Integration', function (): void { test('Check if project and files imported', async function (): Promise { const applicationSourceProjectName: string = StringUtil.getProjectNameFromGitUrl(gitImportRepo); - const projectSection: ViewSection = await new SideBarView().getContent().getSection(applicationSourceProjectName); - const isFileImported: ViewItem | undefined = await projectSection.findItem(BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME); - expect(isFileImported).not.eqls(undefined); + const projectSection: ViewSection = await projectAndFileTests.getProjectViewSession(); + expect( + await projectAndFileTests.getProjectTreeItem(projectSection, applicationSourceProjectName), + 'Project folder was not imported' + ).not.undefined; + expect( + await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME), + 'Project files were not imported' + ).not.undefined; }); test('Stop and delete the workspace by API', async function (): Promise { diff --git a/tests/e2e/specs/factory/Factory.spec.ts b/tests/e2e/specs/factory/Factory.spec.ts index ba5b4ad0d632..f5af702f4211 100644 --- a/tests/e2e/specs/factory/Factory.spec.ts +++ b/tests/e2e/specs/factory/Factory.spec.ts @@ -17,11 +17,9 @@ import { EditorView, Locators, NewScmView, - SideBarView, SingleScmProvider, TextEditor, ViewControl, - ViewItem, ViewSection } from 'monaco-page-objects'; import { expect } from 'chai'; @@ -92,20 +90,20 @@ suite( test('Check if a project folder has been created', async function (): Promise { testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL); Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`); - projectSection = await new SideBarView().getContent().getSection(testRepoProjectName); - }); - - test('Check if the project files were imported', async function (): Promise { - const label: string = BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME; - Logger.debug(`projectSection.findItem: find ${label}`); - const isFileImported: ViewItem | undefined = await projectSection.findItem(label); - expect(isFileImported).not.eqls(undefined); + projectSection = await projectAndFileTests.getProjectViewSession(); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, testRepoProjectName), 'Project folder was not imported').not + .undefined; }); test('Accept the project as a trusted one', async function (): Promise { await projectAndFileTests.performTrustAuthorDialog(); }); + test('Check if the project files were imported', async function (): Promise { + const label: string = BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME; + expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were not imported').not.undefined; + }); + test('Make changes to the file', async function (): Promise { Logger.debug(`projectSection.openItem: "${fileToChange}"`); await projectSection.openItem(fileToChange); @@ -186,7 +184,7 @@ suite( webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel), 'aria-disabled' ); - expect(isCommitButtonDisabled).eql('true'); + expect(isCommitButtonDisabled).to.be.true; }); test('Stop the workspace', async function (): Promise { diff --git a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts index 36a5314c51ed..e2110c093a63 100644 --- a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts +++ b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts @@ -18,11 +18,9 @@ import { Locators, ModalDialog, NewScmView, - SideBarView, SingleScmProvider, TextEditor, ViewControl, - ViewItem, ViewSection } from 'monaco-page-objects'; import { expect } from 'chai'; @@ -116,8 +114,9 @@ suite( test('Check if a project folder has been created', async function (): Promise { testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL); - Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`); - projectSection = await new SideBarView().getContent().getSection(testRepoProjectName); + projectSection = await projectAndFileTests.getProjectViewSession(); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, testRepoProjectName), 'Project folder was not imported') + .not.undefined; }); test('Accept the project as a trusted one', async function (): Promise { @@ -125,10 +124,8 @@ suite( }); test('Check if the project files were imported', async function (): Promise { - Logger.debug(`projectSection.findItem: find ${label}`); - const isFileImported: ViewItem | undefined = await projectSection.findItem(label); - // projectSection.findItem(label) can return undefined but test will goes on - expect(isFileImported).not.eqls(undefined); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were not imported').not + .undefined; }); test('Make changes to the file', async function (): Promise { @@ -243,7 +240,7 @@ suite( webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel), 'aria-disabled' ); - expect(isCommitButtonDisabled).eql('true'); + expect(isCommitButtonDisabled).to.be.true; }); test('Stop the workspace', async function (): Promise { diff --git a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts index 1fba8c181ffc..4a0bf2ba649d 100644 --- a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts +++ b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts @@ -18,11 +18,9 @@ import { Locators, ModalDialog, NewScmView, - SideBarView, SingleScmProvider, TextEditor, ViewControl, - ViewItem, ViewSection } from 'monaco-page-objects'; import { expect } from 'chai'; @@ -99,8 +97,9 @@ suite( test('Check if a project folder has been created', async function (): Promise { testRepoProjectName = StringUtil.getProjectNameFromGitUrl(FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL); - Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`); - projectSection = await new SideBarView().getContent().getSection(testRepoProjectName); + projectSection = await projectAndFileTests.getProjectViewSession(); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, testRepoProjectName), 'Project folder was not imported').not + .undefined; }); test('Accept the project as a trusted one', async function (): Promise { @@ -116,15 +115,12 @@ suite( }); test('Check that project files were not imported', async function (): Promise { - const isFileImported: ViewItem | undefined = await projectSection.findItem(label); - expect(isFileImported).eqls(undefined); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were found').to.be.undefined; }); } else { test('Check if the project files were imported', async function (): Promise { - Logger.debug(`projectSection.findItem: find ${label}`); - const isFileImported: ViewItem | undefined = await projectSection.findItem(label); - // projectSection.findItem(label) can return undefined but test will goes on - expect(isFileImported).not.eqls(undefined); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, label), 'Project files were not imported').not + .undefined; }); test('Make changes to the file', async function (): Promise { @@ -231,7 +227,7 @@ suite( webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel), 'aria-disabled' ); - expect(isCommitButtonDisabled).eql('true'); + expect(isCommitButtonDisabled).to.be.true; }); } diff --git a/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.ts b/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.ts index 93ff27967884..0d52d9600535 100644 --- a/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.ts +++ b/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.ts @@ -8,7 +8,7 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ import { e2eContainer } from '../../configs/inversify.config'; -import { ViewSection, SideBarView, ViewItem } from 'monaco-page-objects'; +import { ViewSection } from 'monaco-page-objects'; import { CLASSES } from '../../configs/inversify.types'; import { expect } from 'chai'; import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests'; @@ -42,9 +42,12 @@ suite('"Start workspace with existed workspace name" test', function (): void { test('Wait workspace readiness and project folder has been created', async function (): Promise { await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); - projectSection = await new SideBarView().getContent().getSection(projectName); - const isFileImported: ViewItem | undefined = await projectSection.findItem(BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME); - expect(isFileImported).not.eqls(undefined); + projectSection = await projectAndFileTests.getProjectViewSession(); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, projectName), 'Project folder was not imported').not.undefined; + expect( + await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME), + 'Project files were not imported' + ).not.undefined; }); test('Stop created workspace', async function (): Promise { @@ -65,9 +68,12 @@ suite('"Start workspace with existed workspace name" test', function (): void { test('Wait the second workspace readiness and project folder has been created', async function (): Promise { await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); - projectSection = await new SideBarView().getContent().getSection(projectName); - const isFileImported: ViewItem | undefined = await projectSection.findItem(BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME); - expect(isFileImported).not.eqls(undefined); + projectSection = await projectAndFileTests.getProjectViewSession(); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, projectName), 'Project folder was not imported').not.undefined; + expect( + await projectAndFileTests.getProjectTreeItem(projectSection, BASE_TEST_CONSTANTS.TS_SELENIUM_PROJECT_ROOT_FILE_NAME), + 'Project files were not imported' + ).not.undefined; }); test(`Stop all created ${stackName} workspaces`, async function (): Promise { diff --git a/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts b/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts index 6da46f31dc73..0b2d827659dd 100644 --- a/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts +++ b/tests/e2e/specs/miscellaneous/KubedockPodmanTest.spec.ts @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ -import { SideBarView, ViewSection } from 'monaco-page-objects'; +import { ViewSection } from 'monaco-page-objects'; import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests'; import { CLASSES } from '../../configs/inversify.types'; import { e2eContainer } from '../../configs/inversify.config'; @@ -66,8 +66,8 @@ suite('Check possibility to manage containers within a workspace with kubedock a }); test('Check the project files were imported', async function (): Promise { - const [projectSection]: ViewSection[] = await new SideBarView().getContent().getSections(); - expect(await projectSection.findItem('Dockerfile'), 'Files not imported').not.undefined; + const projectSection: ViewSection = await projectAndFileTests.getProjectViewSession(); + expect(await projectAndFileTests.getProjectTreeItem(projectSection, 'Dockerfile'), 'Files not imported').not.undefined; }); test('Create and check container runs using kubedock and podman', function (): void { diff --git a/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts b/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts index 42ae5786c682..76cb3798e172 100644 --- a/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts +++ b/tests/e2e/specs/miscellaneous/WorkspaceWithParent.spec.ts @@ -9,7 +9,7 @@ **********************************************************************/ import { e2eContainer } from '../../configs/inversify.config'; import { ShellExecutor } from '../../utils/ShellExecutor'; -import { InputBox, QuickOpenBox, QuickPickItem, SideBarView, ViewItem, ViewSection, Workbench } from 'monaco-page-objects'; +import { InputBox, QuickOpenBox, QuickPickItem, ViewItem, ViewSection, Workbench } from 'monaco-page-objects'; import { CLASSES } from '../../configs/inversify.types'; import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests'; import { LoginTests } from '../../tests-library/LoginTests'; @@ -32,9 +32,14 @@ suite('Workspace using a parent test suite', function (): void { const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get( CLASSES.KubernetesCommandLineToolsExecutor ); + let podName: string = ''; + + suiteSetup(function (): void { + kubernetesCommandLineToolsExecutor.loginToOcp(); + }); + loginTests.loginIntoChe(); - kubernetesCommandLineToolsExecutor.loginToOcp(); test('Create a workspace using a parent', async function (): Promise { const factoryUrl: string = `${BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL}/dashboard/#https://github.com/testsfactory/parentDevfile`; @@ -47,12 +52,12 @@ suite('Workspace using a parent test suite', function (): void { }); test('Check cloning of the test project', async function (): Promise { - const expectedProjectItems: string[] = ['.devfile.yaml', 'parent.yaml', 'README.md']; - const visibleContent: ViewSection = await new SideBarView().getContent().getSection('parentdevfile'); + const expectedProjectItems: string[] = ['.devfile.yaml', 'parent.yaml', 'README.md', 'parentdevfile']; + const visibleContent: ViewSection = await projectAndFileTests.getProjectViewSession(); for (const expectedProjectItem of expectedProjectItems) { - const visibleItem: ViewItem | undefined = await visibleContent.findItem(expectedProjectItem); - expect(visibleItem).not.equal(undefined); + const visibleItem: ViewItem | undefined = await projectAndFileTests.getProjectTreeItem(visibleContent, expectedProjectItem); + expect(visibleItem).not.undefined; } }); @@ -76,20 +81,20 @@ suite('Workspace using a parent test suite', function (): void { const containerNames: string = shellExecutor.executeArbitraryShellScript( `${API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL} get pod ${podName} --output jsonpath=\'{.spec.containers[*].name}\'` ); - expect(containerNames).contain('tools'); - expect(containerNames).contains('che-gateway'); + expect(containerNames).contains('tools').and.contains('che-gateway'); const initContainerName: string = shellExecutor.executeArbitraryShellScript( `${API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL} get pod ${podName} --output jsonpath=\'{.spec.initContainers[].name}\'` ); - expect(initContainerName).contain('che-code-injector'); + expect(initContainerName).contains('che-code-injector'); }); test('Check expected environment variables', function (): void { const envList: string = shellExecutor.executeArbitraryShellScript( `${API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL} exec -i ${podName} -c tools -- sh -c env` ); - expect(envList).contain('DEVFILE_ENV_VAR=true').and.contain('PARENT_ENV_VAR=true'); + expect(envList).contains('DEVFILE_ENV_VAR=true').and.contains('PARENT_ENV_VAR=true'); }); + loginTests.logoutFromChe(); }); diff --git a/tests/e2e/tests-library/ProjectAndFileTests.ts b/tests/e2e/tests-library/ProjectAndFileTests.ts index 5f5320fdd977..ccc1e54d2911 100644 --- a/tests/e2e/tests-library/ProjectAndFileTests.ts +++ b/tests/e2e/tests-library/ProjectAndFileTests.ts @@ -15,7 +15,7 @@ import { CLASSES } from '../configs/inversify.types'; import { Logger } from '../utils/Logger'; import { TIMEOUT_CONSTANTS } from '../constants/TIMEOUT_CONSTANTS'; import { CheCodeLocatorLoader } from '../pageobjects/ide/CheCodeLocatorLoader'; -import { Workbench } from 'monaco-page-objects'; +import { SideBarView, ViewContent, ViewItem, ViewSection, Workbench } from 'monaco-page-objects'; @injectable() export class ProjectAndFileTests { @@ -45,13 +45,16 @@ export class ProjectAndFileTests { async performTrustAuthorDialog(): Promise { Logger.debug(); // sometimes the trust dialog does not appear at first time, for avoiding this problem we send click event for activating - await new Workbench().click(); + const workbench: Workbench = new Workbench(); + await workbench.click(); + await this.driverHelper.waitAndClick( this.cheCodeLocatorLoader.webCheCodeLocators.WelcomeContent.button, TIMEOUT_CONSTANTS.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT ); try { + await workbench.click(); await this.driverHelper.waitAndClick( this.cheCodeLocatorLoader.webCheCodeLocators.WelcomeContent.button, TIMEOUT_CONSTANTS.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT @@ -60,4 +63,43 @@ export class ProjectAndFileTests { Logger.info('Second welcome content dialog box was not shown'); } } + + async getProjectViewSession(): Promise { + Logger.debug(); + + await this.driverHelper.waitVisibility( + this.cheCodeLocatorLoader.webCheCodeLocators.DefaultTreeSection.itemRow, + TIMEOUT_CONSTANTS.TS_EXPAND_PROJECT_TREE_ITEM_TIMEOUT + ); + + const viewContent: ViewContent = new SideBarView().getContent(); + const [projectSection]: ViewSection[] = await viewContent.getSections(); + return projectSection; + } + + async getProjectTreeItem(projectSection: ViewSection, item: string, itemLevel: number = 2): Promise { + Logger.debug(`${item}`); + + let projectTreeItem: ViewItem | undefined; + await this.driverHelper.waitVisibility( + this.cheCodeLocatorLoader.webCheCodeLocators.ScmView.itemLevel(itemLevel), + TIMEOUT_CONSTANTS.TS_EXPAND_PROJECT_TREE_ITEM_TIMEOUT + ); + + try { + projectTreeItem = await projectSection.findItem(item, itemLevel); + if (!projectTreeItem) { + try { + await projectSection.collapse(); + projectTreeItem = await projectSection.findItem(item, itemLevel); + } catch (e) { + Logger.warn(JSON.stringify(e)); + } + } + } catch (e) { + Logger.warn(JSON.stringify(e)); + } + + return projectTreeItem; + } }