Skip to content

Commit

Permalink
Merge pull request eclipse-che#17371 from ScrewTSW/16343-feature-refa…
Browse files Browse the repository at this point in the history
…ctor-ts-selenium-timeout-logic

Refactor timeout logic in DriverHelper class
  • Loading branch information
ScrewTSW authored Aug 4, 2020
2 parents 6963118 + 794c696 commit 506c0c0
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 70 deletions.
7 changes: 5 additions & 2 deletions tests/e2e/pageobjects/ide/ProjectTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,10 @@ export class ProjectTree {
const rootSubitemLocator: By = By.css(this.getTreeItemCssLocator(`${projectName}/${rootSubItem}`));

for (let i = 0; i < attempts; i++) {
const isProjectFolderVisible = await this.driverHelper.waitVisibilityBoolean(rootItemLocator, attempts, visibilityItemPolling);
const isProjectFolderVisible = await this.driverHelper.waitVisibilityBoolean(rootItemLocator, 1, visibilityItemPolling);

if (!isProjectFolderVisible) {
Logger.trace(`ProjectTree.waitProjectImported project not located, reloading page.`);
await this.driverHelper.reloadPage();
await this.driverHelper.wait(triesPolling);
await this.ide.waitAndSwitchToIdeFrame();
Expand All @@ -276,12 +277,14 @@ export class ProjectTree {
continue;
}

Logger.trace(`ProjectTree.waitProjectImported project found, waiting for sub-items`);
await this.expandItem(rootItem);
await this.waitItemExpanded(rootItem);

const isRootSubItemVisible = await this.driverHelper.waitVisibilityBoolean(rootSubitemLocator, attempts, visibilityItemPolling);
const isRootSubItemVisible = await this.driverHelper.waitVisibilityBoolean(rootSubitemLocator, 1, visibilityItemPolling);

if (!isRootSubItemVisible) {
Logger.trace(`ProjectTree.waitProjectImported sub-items not found, reloading page.`);
await this.driverHelper.reloadPage();
await this.driverHelper.wait(triesPolling);
await this.ide.waitAndSwitchToIdeFrame();
Expand Down
38 changes: 19 additions & 19 deletions tests/e2e/tests/e2e_happy_path/HappyPath.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ suite('Validation of workspace start', async () => {
});

test('Wait until project is imported', async () => {
await projectTree.openProjectTreeContainer();
await projectTree.openProjectTreeContainer(10_000);
await projectTree.waitProjectImported(projectName, 'src');
});

Expand All @@ -96,7 +96,7 @@ suite('Language server validation', async () => {
await ide.waitStatusBarContains('Activating Language Support for Java');
}

await ide.waitStatusBarTextAbsence('Activating Language Support for Java', 1800000);
await ide.waitStatusBarTextAbsence('Activating Language Support for Java', 900_000);
await checkJavaPathCompletion();
});

Expand All @@ -117,7 +117,7 @@ suite('Language server validation', async () => {
test('Suggestion', async () => {
await editor.moveCursorToLineAndChar(javaFileName, 32, 21);
await editor.pressControlSpaceCombination(javaFileName);
await editor.waitSuggestionWithScrolling(javaFileName, 'run(Class<?> primarySource, String... args) : ConfigurableApplicationContext', 120000);
await editor.waitSuggestionWithScrolling(javaFileName, 'run(Class<?> primarySource, String... args) : ConfigurableApplicationContext', 120_000);
});

test('Codenavigation', async () => {
Expand Down Expand Up @@ -153,21 +153,21 @@ suite('Validation of workspace build and run', async () => {
// workaround for issue: https://github.com/eclipse/che/issues/14771

// await projectTree.expandPathAndOpenFileInAssociatedWorkspace(projectName, 'build-output.txt');
await projectTree.expandPathAndOpenFile(projectName, 'result-build-output.txt', 220000);
await projectTree.expandPathAndOpenFile(projectName, 'result-build-output.txt', 220_000);
await editor.waitText('result-build-output.txt', '[INFO] BUILD SUCCESS');
// await editor.followAndWaitForText('build-output.txt', '[INFO] BUILD SUCCESS', 300000, 10000);
});

test('Run application', async () => {
await topMenu.runTask('run');
await ide.waitNotificationAndConfirm('A new process is now listening on port 8080', 120000);
applicationUrl = await ide.getApplicationUrlFromNotification('Redirect is now enabled on port 8080', 120000);
await ide.waitNotificationAndOpenLink('Redirect is now enabled on port 8080', 120000);
await ide.waitNotificationAndConfirm('A new process is now listening on port 8080', 120_000);
applicationUrl = await ide.getApplicationUrlFromNotification('Redirect is now enabled on port 8080', 120_000);
await ide.waitNotificationAndOpenLink('Redirect is now enabled on port 8080', 120_000);
});

test('Check the running application', async () => {
await previewWidget.waitApplicationOpened(applicationUrl, 60000);
await previewWidget.waitContentAvailable(SpringAppLocators.springTitleLocator, 60000, 10000);
await previewWidget.waitApplicationOpened(applicationUrl, 60_000);
await previewWidget.waitContentAvailable(SpringAppLocators.springTitleLocator, 60_000, 10_000);
});

test('Close preview widget', async () => {
Expand Down Expand Up @@ -201,7 +201,7 @@ suite('Display source code changes in the running application', async () => {
test('Build application with changes', async () => {
await topMenu.runTask('build');
await projectTree.collapseProjectTree(projectName + '/src', 'main');
await projectTree.expandPathAndOpenFile(projectName, 'result-build.txt', 300000);
await projectTree.expandPathAndOpenFile(projectName, 'result-build.txt', 300_000);
await editor.waitText('result-build.txt', '[INFO] BUILD SUCCESS');

// workaround for issue: https://github.com/eclipse/che/issues/14771
Expand All @@ -217,14 +217,14 @@ suite('Display source code changes in the running application', async () => {

test('Run application with changes', async () => {
await topMenu.runTask('run-with-changes');
await ide.waitNotificationAndConfirm('A new process is now listening on port 8080', 120000);
applicationUrl = await ide.getApplicationUrlFromNotification('Redirect is now enabled on port 8080', 120000);
await ide.waitNotificationAndOpenLink('Redirect is now enabled on port 8080', 120000);
await ide.waitNotificationAndConfirm('A new process is now listening on port 8080', 120_000);
applicationUrl = await ide.getApplicationUrlFromNotification('Redirect is now enabled on port 8080', 120_000);
await ide.waitNotificationAndOpenLink('Redirect is now enabled on port 8080', 120_000);
});

test('Check changes are displayed', async () => {
await previewWidget.waitApplicationOpened(applicationUrl, 60000);
await previewWidget.waitContentAvailable(SpringAppLocators.springTitleLocator, 60000, 10000);
await previewWidget.waitApplicationOpened(applicationUrl, 60_000);
await previewWidget.waitContentAvailable(SpringAppLocators.springTitleLocator, 60_000, 10_000);
await checkErrorMessageInApplicationController();
});

Expand All @@ -250,13 +250,13 @@ suite('Validation of debug functionality', async () => {

test('Launch debug', async () => {
await topMenu.runTask('run-debug');
await ide.waitNotificationAndConfirm('A new process is now listening on port 8080', 180000);
applicationUrl = await ide.getApplicationUrlFromNotification('Redirect is now enabled on port 8080', 180000);
await ide.waitNotificationAndOpenLink('Redirect is now enabled on port 8080', 180000);
await ide.waitNotificationAndConfirm('A new process is now listening on port 8080', 180_000);
applicationUrl = await ide.getApplicationUrlFromNotification('Redirect is now enabled on port 8080', 180_000);
await ide.waitNotificationAndOpenLink('Redirect is now enabled on port 8080', 180_000);
});

test('Check content of the launched application', async () => {
await previewWidget.waitApplicationOpened(applicationUrl, 60000);
await previewWidget.waitApplicationOpened(applicationUrl, 60_000);
await previewWidget.waitAndSwitchToWidgetFrame();
await previewWidget.waitAndClick(SpringAppLocators.springHomeButtonLocator);
await driverHelper.getDriver().switchTo().defaultContent();
Expand Down
Loading

0 comments on commit 506c0c0

Please sign in to comment.