Skip to content

Commit

Permalink
[Happy Path] Fix of issue #14141 (Sometimes the "Happy path" test fai…
Browse files Browse the repository at this point in the history
…ls when click on "Start debug" button) (#14180)


Signed-off-by: Ihor Okhrimenko <iokhrime@redhat.com>
  • Loading branch information
Ohrimenko1988 authored Aug 12, 2019
1 parent dd6ee43 commit c31a25e
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion e2e/files/happy-path/containers-happy-path.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ spec:
image: mariolet/petclinic:d2831f9b
resources:
requests:
memory: 1000Mi
memory: 2000Mi
ports:
- containerPort: 8080
---
Expand Down
18 changes: 15 additions & 3 deletions e2e/pageobjects/ide/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,20 @@ export class Editor {
async waitTabWithSavedStatus(tabTitle: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
const unsavedTabLocator: By = this.getTabWithUnsavedStatus(tabTitle);

await this.driverHelper.waitDisappearanceWithTimeout(unsavedTabLocator, timeout);
await this.waitTab(tabTitle, timeout);
await this.driverHelper.getDriver().wait(async () => {
try {
await this.driverHelper.waitDisappearanceWithTimeout(unsavedTabLocator, TestConstants.TS_SELENIUM_DEFAULT_POLLING);
await this.waitTab(tabTitle, timeout);
return true;
} catch (err) {
if (!(err instanceof error.TimeoutError)) {
throw err;
}

console.log(`The editor tab with title "${tabTitle}" has unsaved status, wait once again`);
}
}, timeout);

}

async waitEditorOpened(editorTabTitle: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Expand Down Expand Up @@ -190,7 +202,7 @@ export class Editor {
}
}

public async performKeyCombination(editorTabTitle: string, text: string) {
async performKeyCombination(editorTabTitle: string, text: string) {
const interactionContainerLocator: By = this.getEditorActionArreaLocator(editorTabTitle);

await this.driverHelper.type(interactionContainerLocator, text);
Expand Down
4 changes: 2 additions & 2 deletions e2e/pageobjects/ide/Ide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DriverHelper } from '../../utils/DriverHelper';
import { injectable, inject } from 'inversify';
import { CLASSES } from '../../inversify.types';
import { TestConstants } from '../../TestConstants';
import { By, WebElement, error, until } from 'selenium-webdriver';
import { By, WebElement, error } from 'selenium-webdriver';
import { TestWorkspaceUtil, WorkspaceStatus } from '../../utils/workspace/TestWorkspaceUtil';

export enum RightToolbarButton {
Expand Down Expand Up @@ -66,7 +66,7 @@ export class Ide {

await this.driverHelper.wait(TestConstants.TS_SELENIUM_DEFAULT_POLLING);
}
});
}, timeout);
}

async waitNotificationAndConfirm(notificationText: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Expand Down
4 changes: 2 additions & 2 deletions e2e/pageobjects/ide/ProjectTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DriverHelper } from '../../utils/DriverHelper';
import { CLASSES } from '../../inversify.types';
import { Ide, RightToolbarButton } from './Ide';
import { TestConstants } from '../../TestConstants';
import { By } from 'selenium-webdriver';
import { By, error } from 'selenium-webdriver';
import { Editor } from './Editor';

@injectable()
Expand Down Expand Up @@ -175,7 +175,7 @@ export class ProjectTree {
return;
}

throw new Error('Exceeded the maximum number of checking attempts, project has not been imported');
throw new error.TimeoutError('Exceeded the maximum number of checking attempts, project has not been imported');
}

private getItemCss(itemPath: string): string {
Expand Down
3 changes: 1 addition & 2 deletions e2e/tests/e2e_happy_path/HappyPath.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ suite('Validation of debug functionality', async () => {
await editor.clickOnSuggestion('Java: Launch Program in Current File');
await editor.waitTabWithUnsavedStatus('launch.json');
await editor.waitText('launch.json', '\"name\": \"Debug (Launch) - Current File\"');
await editor.performKeyCombination('launch.json', Key.chord(Key.CONTROL, 's'));

await editor.waitTabWithSavedStatus('launch.json');
});

Expand Down Expand Up @@ -289,7 +289,6 @@ async function checkJavaPathCompletion() {
await editor.performKeyCombination(classPathFilename, Key.DELETE);

await editor.type(classPathFilename, classpathText, 1);
await editor.performKeyCombination(classPathFilename, Key.chord(Key.CONTROL, 's'));
await editor.waitTabWithSavedStatus(classPathFilename);
}

Expand Down
24 changes: 12 additions & 12 deletions e2e/utils/DriverHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum visibility checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
throw new error.TimeoutError(`Exceeded maximum visibility checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
}

public async waitPresence(elementLocator: By, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT): Promise<WebElement> {
Expand All @@ -117,7 +117,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum presence checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
throw new error.TimeoutError(`Exceeded maximum presence checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
}

public async waitAllPresence(elementLocator: By, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT): Promise<Array<WebElement>> {
Expand All @@ -138,7 +138,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum presence checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
throw new error.TimeoutError(`Exceeded maximum presence checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
}

public async waitAllVisibility(locators: Array<By>, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Expand All @@ -154,7 +154,7 @@ export class DriverHelper {
const isDisappeared = await this.waitDisappearanceBoolean(elementLocator, attempts, polling);

if (!isDisappeared) {
throw new Error(`Waiting attempts exceeded, element '${elementLocator}' is still visible`);
throw new error.TimeoutError(`Waiting attempts exceeded, element '${elementLocator}' is still visible`);
}
}

Expand Down Expand Up @@ -202,7 +202,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum clicking attempts, the '${elementLocator}' element is not clickable`);
throw new error.TimeoutError(`Exceeded maximum clicking attempts, the '${elementLocator}' element is not clickable`);

}

Expand All @@ -229,7 +229,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum gettin of the '${attribute}' attribute attempts, from the '${elementLocator}' element`);
throw new error.TimeoutError(`Exceeded maximum gettin of the '${attribute}' attribute attempts, from the '${elementLocator}' element`);
}

public async waitAndGetCssValue(elementLocator: By,
Expand All @@ -255,7 +255,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum gettin of the '${cssAttribute}' css attribute attempts, from the '${elementLocator}' element`);
throw new error.TimeoutError(`Exceeded maximum gettin of the '${cssAttribute}' css attribute attempts, from the '${elementLocator}' element`);
}

public async waitAttributeValue(elementLocator: By,
Expand Down Expand Up @@ -292,7 +292,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
}

public async typeToInvisible(elementLocator: By, text: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Expand All @@ -315,7 +315,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
}

public async clear(elementLocator: By, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Expand All @@ -338,7 +338,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`);
throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`);
}

public async enterValue(elementLocator: By, text: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Expand Down Expand Up @@ -373,7 +373,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum text obtaining attempts, from the '${elementLocator}' element`);
throw new error.TimeoutError(`Exceeded maximum text obtaining attempts, from the '${elementLocator}' element`);
}

public async waitAndGetValue(elementLocator: By, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT): Promise<string> {
Expand Down Expand Up @@ -429,7 +429,7 @@ export class DriverHelper {
}
}

throw new Error(`Exceeded maximum mouse move attempts, for the '${elementLocator}' element`);
throw new error.TimeoutError(`Exceeded maximum mouse move attempts, for the '${elementLocator}' element`);
}

getDriver(): ThenableWebDriver {
Expand Down
5 changes: 3 additions & 2 deletions e2e/utils/workspace/TestWorkspaceUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { DriverHelper } from '../DriverHelper';
import { CLASSES } from '../../inversify.types';
import 'reflect-metadata';
import * as rm from 'typed-rest-client/RestClient';
import { error } from 'selenium-webdriver';

export enum WorkspaceStatus {
RUNNING = 'RUNNING',
Expand Down Expand Up @@ -48,7 +49,7 @@ export class TestWorkspaceUtil {
await this.driverHelper.wait(polling);
}

throw new Error(`Exceeded the maximum number of checking attempts, workspace status is different to '${expectedWorkspaceStatus}'`);
throw new error.TimeoutError(`Exceeded the maximum number of checking attempts, workspace status is different to '${expectedWorkspaceStatus}'`);
}

public async waitPluginAdding(namespace: string, workspaceName: string, pluginId: string) {
Expand All @@ -72,7 +73,7 @@ export class TestWorkspaceUtil {
}

if (i === attempts - 1) {
throw new Error(`Exceeded maximum tries attempts, the '${pluginId}' plugin is not present in the workspace runtime.`);
throw new error.TimeoutError(`Exceeded maximum tries attempts, the '${pluginId}' plugin is not present in the workspace runtime.`);
}

await this.driverHelper.wait(polling);
Expand Down

0 comments on commit c31a25e

Please sign in to comment.