diff --git a/e2e/files/happy-path/happy-path-workspace.yaml b/e2e/files/happy-path/happy-path-workspace.yaml index 69972bad149..6ab3ebac108 100644 --- a/e2e/files/happy-path/happy-path-workspace.yaml +++ b/e2e/files/happy-path/happy-path-workspace.yaml @@ -27,9 +27,7 @@ components: app.kubernetes.io/component: database - type: dockerimage alias: maven-container - image: bujhtr5555/maven-with-artifacts:latest - command: ["sleep"] - args: ["infinity"] + image: quay.io/eclipse/happy-path:nightly env: - name: MAVEN_CONFIG value: /home/user/.m2 @@ -50,8 +48,7 @@ commands: actions: - type: exec component: maven-container - command: mkdir -p /projects/petclinic/?/.m2 && cp -r /.m2/* /projects/petclinic/?/.m2 && cd /projects/petclinic && mvn package >> build-output.txt && tail -n 40 /projects/petclinic/build-output.txt | grep 'BUILD SUCCESS' > /projects/petclinic/result-build-output.txt - workdir: /projects/petclinic + command: cd /projects/petclinic && mvn package >> build-output.txt && tail -n 40 /projects/petclinic/build-output.txt | grep 'BUILD SUCCESS' > /projects/petclinic/result-build-output.txt - name: run actions: - type: exec diff --git a/e2e/pageobjects/ide/Editor.ts b/e2e/pageobjects/ide/Editor.ts index 1055e5bb041..c81a2de175a 100644 --- a/e2e/pageobjects/ide/Editor.ts +++ b/e2e/pageobjects/ide/Editor.ts @@ -40,18 +40,31 @@ export class Editor { await this.driverHelper.waitDisappearanceWithTimeout(By.css(Editor.SUGGESTION_WIDGET_BODY_CSS)); } - public async scrollAndSearchSuggestion(editorTabTitle: string, suggestionLocator: By, timeout: number = 10000) { + public async waitSuggestion(editorTabTitle: string, + suggestionText: string, + timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) { + + Logger.debug(`Editor.waitSuggestion tabTitle: "${editorTabTitle}" suggestion: "${suggestionText}"`); + + const suggestionLocator: By = this.getSuggestionLineXpathLocator(suggestionText); + await this.driverHelper.getDriver().wait(async () => { - await this.waitSuggestionContainer(); - if (await this.driverHelper.isVisible(suggestionLocator)) { + try { + await this.driverHelper.waitVisibility(suggestionLocator, 5000); return true; - } + } catch (err) { + if (!(err instanceof error.TimeoutError)) { + throw err; + } - await this.performKeyCombination(editorTabTitle, Key.ARROW_DOWN); + await this.pressEscapeButton(editorTabTitle); + await this.waitSuggestionContainerClosed(); + await this.pressControlSpaceCombination(editorTabTitle); + } }, timeout); } - public async waitSuggestion(editorTabTitle: string, + public async waitSuggestionWithScrolling(editorTabTitle: string, suggestionText: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) { @@ -407,6 +420,22 @@ export class Editor { perform(); } + private async scrollAndSearchSuggestion(editorTabTitle: string, suggestionLocator: By, timeout: number = 10000) { + await this.driverHelper.getDriver().wait(async () => { + const loadingLocator: By = this.getSuggestionLineXpathLocator('Loading'); + + await this.waitSuggestionContainer(); + await this.driverHelper.waitDisappearance(loadingLocator); + await this.driverHelper.wait(1000); + + if (await this.driverHelper.isVisible(suggestionLocator)) { + return true; + } + + await this.performKeyCombination(editorTabTitle, Key.ARROW_DOWN); + }, timeout); + } + private getTabWithUnsavedStatus(tabTitle: string): By { return By.xpath(`//div[text()='${tabTitle}']/parent::li[contains(@class, 'theia-mod-dirty')]`); } diff --git a/e2e/pageobjects/ide/ProjectTree.ts b/e2e/pageobjects/ide/ProjectTree.ts index 4d7a7e72f96..cfbf24c7252 100644 --- a/e2e/pageobjects/ide/ProjectTree.ts +++ b/e2e/pageobjects/ide/ProjectTree.ts @@ -26,6 +26,41 @@ export class ProjectTree { @inject(CLASSES.Ide) private readonly ide: Ide, @inject(CLASSES.Editor) private readonly editor: Editor) { } + async clickCollapseAllButton() { + Logger.debug('ProjectTree.clickCollapseAllButton'); + + const collapseAllButtonLocator: By = By.css('div.theia-sidepanel-toolbar div.collapse-all'); + await this.driverHelper.waitAndClick(collapseAllButtonLocator); + } + + async waitTreeCollapsed(projectName: string, rootSubItem: string) { + Logger.debug(`ProjectTree.waitTreeCollapsed project: "${projectName}", subitem: "${rootSubItem}"`); + + const rootSubitemLocator: By = By.css(this.getTreeItemCssLocator(`${projectName}/${rootSubItem}`)); + await this.driverHelper.waitDisappearanceWithTimeout(rootSubitemLocator); + } + + async collapseProjectTree(projectName: string, rootSubItem: string) { + Logger.debug(`ProjectTree.collapseProjectTree project: "${projectName}", subitem: "${rootSubItem}"`); + + await this.clickCollapseAllButton(); + await this.waitTreeCollapsed(projectName, rootSubItem); + } + + async waitAssociatedWorkspaceProjectTreeCollapsed(projectName: string, expandedRootItem: string) { + Logger.debug(`ProjectTree.waitTreeCollapsed project name: "${projectName}", expanded root item: "${expandedRootItem}"`); + + // const rootSubitemLocator: By = By.css(this.getTreeItemCssLocator(`${projectName}/${expandedRootItem}`)); + await this.waitItemCollapsed(`${projectName}/${expandedRootItem}`); + } + + async collapseAssociatedWorkspaceProjectTree(projectName: string, rootSubItem: string) { + Logger.debug(`ProjectTree.collapseProjectTree project: "${projectName}", subitem: "${rootSubItem}"`); + + await this.clickCollapseAllButton(); + await this.waitTreeCollapsed(projectName, rootSubItem); + } + async openProjectTreeContainer(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) { Logger.debug('ProjectTree.openProjectTreeContainer'); diff --git a/e2e/tests/e2e/JavaVertx.spec.ts b/e2e/tests/e2e/JavaVertx.spec.ts index 8d48cf7129e..0256aba9836 100644 --- a/e2e/tests/e2e/JavaVertx.spec.ts +++ b/e2e/tests/e2e/JavaVertx.spec.ts @@ -95,7 +95,7 @@ suite('Java Vert.x test', async () => { await editor.waitTabFocused(tabTitle); await editor.moveCursorToLineAndChar(tabTitle, 19, 11); await editor.pressControlSpaceCombination(tabTitle); - await editor.waitSuggestion(tabTitle, 'cancelTimer(long arg0) : boolean'); + await editor.waitSuggestionWithScrolling(tabTitle, 'cancelTimer(long arg0) : boolean'); }); test('Error highlighting', async () => { @@ -109,7 +109,7 @@ suite('Java Vert.x test', async () => { await editor.moveCursorToLineAndChar(tabTitle, 18, 15); await editor.pressControlSpaceCombination(tabTitle); await editor.waitSuggestionContainer(); - await editor.waitSuggestion(tabTitle, 'Vertx - io.vertx.core'); + await editor.waitSuggestionWithScrolling(tabTitle, 'Vertx - io.vertx.core'); }); test('Codenavigation', async () => { diff --git a/e2e/tests/e2e/WorkspaceCreationAndLsInitialization.spec.ts b/e2e/tests/e2e/WorkspaceCreationAndLsInitialization.spec.ts index b0ae8cb02dc..e7049039627 100644 --- a/e2e/tests/e2e/WorkspaceCreationAndLsInitialization.spec.ts +++ b/e2e/tests/e2e/WorkspaceCreationAndLsInitialization.spec.ts @@ -79,7 +79,7 @@ suite('E2E', async () => { await editor.waitTabFocused(tabTitle); await editor.moveCursorToLineAndChar(tabTitle, 6, 20); await editor.pressControlSpaceCombination(tabTitle); - await editor.waitSuggestion(tabTitle, 'append(CharSequence csq, int start, int end) : PrintStream'); + await editor.waitSuggestionWithScrolling(tabTitle, 'append(CharSequence csq, int start, int end) : PrintStream'); }); }); diff --git a/e2e/tests/e2e_happy_path/HappyPath.spec.ts b/e2e/tests/e2e_happy_path/HappyPath.spec.ts index 798cc8bdad8..2c3840231f6 100644 --- a/e2e/tests/e2e_happy_path/HappyPath.spec.ts +++ b/e2e/tests/e2e_happy_path/HappyPath.spec.ts @@ -116,7 +116,7 @@ suite('Language server validation', async () => { test('Suggestion', async () => { await editor.moveCursorToLineAndChar(javaFileName, 32, 27); await editor.pressControlSpaceCombination(javaFileName); - await editor.waitSuggestion(javaFileName, 'run(Class primarySource, String... args) : ConfigurableApplicationContext', 120000); + await editor.waitSuggestionWithScrolling(javaFileName, 'run(Class primarySource, String... args) : ConfigurableApplicationContext', 120000); }); @@ -148,8 +148,8 @@ suite('Validation of workspace build and run', async () => { test('Build application', async () => { await runTask('build-file-output'); - //workaround for issue: https://github.com/eclipse/che/issues/14771 - + // workaround for issue: https://github.com/eclipse/che/issues/14771 + // await projectTree.expandPathAndOpenFileInAssociatedWorkspace(projectName, 'build-output.txt'); await projectTree.expandPathAndOpenFileInAssociatedWorkspace(projectName, 'result-build-output.txt', 220000); await editor.waitText('result-build-output.txt', '[INFO] BUILD SUCCESS'); @@ -193,10 +193,11 @@ suite('Display source code changes in the running application', async () => { test('Build application with changes', async () => { await runTask('build'); + await projectTree.collapseAssociatedWorkspaceProjectTree(projectName + '/src', 'main'); await projectTree.expandPathAndOpenFileInAssociatedWorkspace(projectName, 'result-build.txt', 300000); await editor.waitText('result-build.txt', '[INFO] BUILD SUCCESS'); - - //workaround for issue: https://github.com/eclipse/che/issues/14771 + + // workaround for issue: https://github.com/eclipse/che/issues/14771 /*await projectTree.expandPathAndOpenFileInAssociatedWorkspace(projectName, 'build.txt'); await editor.waitEditorAvailable('build.txt');