Skip to content

Commit

Permalink
Dialog changed to notification during command run, fixing scala (ecli…
Browse files Browse the repository at this point in the history
  • Loading branch information
Katka92 authored Nov 13, 2020
1 parent 220a7e5 commit b7c71e0
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 38 deletions.
1 change: 1 addition & 0 deletions tests/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export * from './pageobjects/login/MultiUserLoginPage';
export * from './pageobjects/login/OcpUserLoginPage';
export * from './pageobjects/login/RegularUserOcpCheLoginPage';
export * from './pageobjects/login/SingleUserLoginPage';
export * from './pageobjects/login/UpdateAccountInformationPage';
export * from './pageobjects/openshift/CheLoginPage';
export * from './pageobjects/openshift/OcpLoginPage';
export * from './pageobjects/openshift/OcpWebConsolePage';
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/pageobjects/login/UpdateAccountInformationPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ export class UpdateAccountInformationPage {
await this.driverHelper.enterValue(By.id('password'), password, timeout);
}

async clickLogInButton(timeout: number){
async clickLogInButton(timeout: number) {
Logger.debug('UpdateAccountInformationPage.clickLogInButton');

await this.driverHelper.waitAndClick(By.id('kc-login'), timeout);
}

async clickToAllowSelectedPermissionsButton(timeout: number){
async clickToAllowSelectedPermissionsButton(timeout: number) {
Logger.debug('UpdateAccountInformationPage.clickToAllowSelectedPermissionsButton');

await this.driverHelper.waitAndClick(By.xpath('//input[@name=\'approve\']'), timeout);
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/tests/devfiles/DotNetCore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const stack : string = '.NET Core';
const updateDependenciesTaskName: string = 'update dependencies';
const buildTaskName: string = 'build';
const runTaskName: string = 'run';
const runTaskNameExpectedString: string = 'A process is now listening on port 5000.';
const runTaskNameExpectedString: string = 'Process 5000-tcp is now listening on port 5000. Open it ?';

suite(`${stack} test`, async () => {
suite(`Test ${stack}`, async () => {
suite (`Create ${stack} workspace`, async () => {
workspaceHandling.createAndOpenWorkspace(stack);
projectAndFileTests.waitWorkspaceReadinessNoSubfolder(workspaceSampleName);
Expand All @@ -50,7 +50,7 @@ suite(`${stack} test`, async () => {
});

suite('Run .NET Core example application', async () => {
codeExecutionTests.runTaskWithDialogShellAndOpenLink(runTaskName, runTaskNameExpectedString , 30_000);
codeExecutionTests.runTaskWithNotification(runTaskName, runTaskNameExpectedString , 30_000);
});

suite('Language server validation', async () => {
Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/tests/devfiles/Go.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const workspaceRootFolderName: string = 'github.com';
const fileFolderPath: string = `${workspaceSampleName}/${workspaceRootFolderName}/golang/example/outyet`;
const fileName: string = `main.go`;

const taskTestOutyet: string = '1.3 Test outyet';
const taskRunServer: string = '1.1 Run outyet';
// const taskStopServer: string = 'stop outyet';
const taskExpectedDialogText: string = 'A process is now listening on port 8080';
const taskStopServer: string = '1.2 Stop outyet';
const taskTestOutyet: string = '1.3 Test outyet';
const notificationText: string = 'Process 8080-tcp is now listening on port 8080. Open it ?';

suite(`${workspaceStack} test`, async () => {

Expand All @@ -52,8 +52,8 @@ suite(`${workspaceStack} test`, async () => {
});

suite('Run golang example server', async () => {
codeExecutionHelper.runTaskWithDialogShellAndOpenLink(taskRunServer, taskExpectedDialogText, 40_000);
// codeExecutionHelper.runTask(taskStopServer, 5_000); // stop outyet task causes the server to die with exit code 143 https://github.com/eclipse/che/issues/17005
codeExecutionHelper.runTaskWithNotification(taskRunServer, notificationText, 40_000);
codeExecutionHelper.runTask(taskStopServer, 5_000);
});

suite(`'Language server validation'`, async () => {
Expand Down
18 changes: 9 additions & 9 deletions tests/e2e/tests/devfiles/JavaSpringBoot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import 'reflect-metadata';
import { WorkspaceNameHandler} from '../..';
import { WorkspaceNameHandler } from '../..';
import * as projectAndFileTests from '../../testsLibrary/ProjectAndFileTests';
import * as commonLsTests from '../../testsLibrary/LsTests';
import * as workspaceHandling from '../../testsLibrary/WorksapceHandlingTests';
import * as codeExecutionTests from '../../testsLibrary/CodeExecutionTests';

const stack : string = 'Java Spring Boot';
const stack: string = 'Java Spring Boot';
const workspaceSampleName: string = 'java-web-spring';
const workspaceRootFolderName: string = 'src';
const fileFolderPath: string = `${workspaceSampleName}/${workspaceRootFolderName}/main/java/org/springframework/samples/petclinic`;
const tabTitle: string = 'PetClinicApplication.java';
const codeNavigationClassName: string = 'SpringApplication.class';
const buildTaskName: string = 'maven build';
const runTaskName: string = 'run webapp';
const runTaskExpectedDialogue: string = 'A process is now listening on port 8080.';
const runTaskExpectedDialogue: string = 'Process 8080-tcp is now listening on port 8080. Open it ?';

suite(`${stack} test`, async () => {
suite (`Create ${stack} workspace`, async () => {
suite(`Create ${stack} workspace`, async () => {
workspaceHandling.createAndOpenWorkspace(stack);
projectAndFileTests.waitWorkspaceReadiness(workspaceSampleName, workspaceRootFolderName);
});
Expand All @@ -41,7 +41,7 @@ suite(`${stack} test`, async () => {
});

suite('Validation of workspace execution', async () => {
codeExecutionTests.runTaskWithDialogShellAndOpenLink(runTaskName, runTaskExpectedDialogue, 30_000);
codeExecutionTests.runTaskWithNotification(runTaskName, runTaskExpectedDialogue, 30_000);
codeExecutionTests.closeTerminal(runTaskName);
});

Expand All @@ -52,15 +52,15 @@ suite(`${stack} test`, async () => {
commonLsTests.suggestionInvoking(tabTitle, 32, 23, 'run(Class<?>');
});

suite ('Stopping and deleting the workspace', async () => {
suite('Stopping and deleting the workspace', async () => {
let workspaceName = 'not defined';
suiteSetup( async () => {
suiteSetup(async () => {
workspaceName = await WorkspaceNameHandler.getNameFromUrl();
});
test (`Stop worksapce`, async () => {
test(`Stop worksapce`, async () => {
await workspaceHandling.stopWorkspace(workspaceName);
});
test (`Remove workspace`, async () => {
test(`Remove workspace`, async () => {
await workspaceHandling.removeWorkspace(workspaceName);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tests/devfiles/NodeJS.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const fileName: string = `app.js`;

const taskDownloadDependencies: string = 'download dependencies';
const taskRunWebApp: string = 'run the web app';
const taskExpectedDialogText: string = 'A process is now listening on port 3000';
const taskExpectedDialogText: string = 'Process nodejs is now listening on port 3000. Open it ?';

suite(`${workspaceStack} test`, async () => {

Expand All @@ -42,7 +42,7 @@ suite(`${workspaceStack} test`, async () => {
});

suite('Run nodejs application', async () => {
codeExecutionHelper.runTaskWithDialogShellAndOpenLink(taskRunWebApp, taskExpectedDialogText, 30_000);
codeExecutionHelper.runTaskWithNotification(taskRunWebApp, taskExpectedDialogText, 30_000);
});

suite(`'Language server validation'`, async () => {
Expand Down
9 changes: 4 additions & 5 deletions tests/e2e/tests/devfiles/PHPSimple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const tabTitle: string = 'index.php';
// const codeNavigationClassName: string = 'RouterImpl.class';
const depTaskName: string = 'Configure Apache Web Server DocumentRoot';
const buildTaskName: string = 'Start Apache Web Server';
const buildTaskLinkExpectedText: string = 'A process is now listening on port 8080.';
const stack: string = 'PHP Simple';

suite(`${stack} test`, async () => {
Expand All @@ -42,17 +41,17 @@ suite(`${stack} test`, async () => {
codeExecutionTests.runTask(depTaskName, 30_000);
});

suite('Validation of project build', async () => {
codeExecutionTests.runTask(buildTaskName, 30_000);
});

suite('Language server validation', async () => {
commonLsTests.errorHighlighting(tabTitle, `error_text;`, 14);
commonLsTests.suggestionInvoking(tabTitle, 14, 26, '$test');
commonLsTests.autocomplete(tabTitle, 15, 5, 'phpinfo');
// commonLsTests.codeNavigation(tabTitle, 19, 7, codeNavigationClassName); // there is no codenavigation in the php simple stack (no object oriented code)
});

suite('Validation of project build', async () => {
codeExecutionTests.runTaskWithDialogShellAndOpenLink(buildTaskName, buildTaskLinkExpectedText, 30_000);
});

suite ('Stopping and deleting the workspace', async () => {
let workspaceName = 'not defined';
suiteSetup( async () => {
Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/tests/devfiles/PythonDjango.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ const taskSetUpVenv: string = 'set up venv';
const taskInstallDependencies: string = 'install dependencies';
const taskMigrate: string = 'migrate';
const taskRunServer: string = 'run server';
const taskExpectedDialogText: string = 'A process is now listening on port 7000';
const taskCustomUrlSubpath: string = '/api/';
const taskExpectedDialogText: string = 'Process django is now listening on port 7000. Open it ?';

suite(`${workspaceStack} test`, async () => {

Expand All @@ -47,7 +46,7 @@ suite(`${workspaceStack} test`, async () => {
});

suite('Run django server', async () => {
codeExecutionHelper.runTaskWithDialogShellDjangoWorkaround(taskRunServer, taskExpectedDialogText, taskCustomUrlSubpath, 30_000);
codeExecutionHelper.runTaskWithNotification(taskRunServer, taskExpectedDialogText, 30_000);
});

suite ('Stopping and deleting the workspace', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/tests/devfiles/Quarkus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ suite(`${workspaceStack} test`, async () => {
codeExecutionHelper.closeTerminal(taskPackageNative);
});
suite('Start Quarkus Native application', async () => {
codeExecutionHelper.runTaskInputText(taskStartNative, 'Test User' + Key.ENTER, 90_000);
codeExecutionHelper.runTaskInputText(taskStartNative, 'Enter your name', 'Test User' + Key.ENTER, 90_000);
});

suite(`'Language server validation'`, async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/tests/devfiles/Scala.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ suite(`${stack} test`, async () => {
suite('Validation of commands', async () => {
codeExecutionTests.runTask(compileTaskkName, 240_000);
codeExecutionTests.closeTerminal(compileTaskkName);
codeExecutionTests.runTask(runTaskName, 120_000);
codeExecutionTests.runTaskInputText(runTaskName, '[info] running org.eclipse.che.examples.HelloWorld', 'Test User', 120_000);
codeExecutionTests.closeTerminal(runTaskName);
codeExecutionTests.runTask(testTaskName, 120_000);
codeExecutionTests.closeTerminal(testTaskName);
});

suite('Language server validation', async () => {
commonLsTests.errorHighlighting(tabTitle, 'Abc:', 21);
commonLsTests.suggestionInvoking(tabTitle, 15, 17, 'Console scala');
commonLsTests.autocomplete(tabTitle, 14, 26, 'che: String');
// commonLsTests.suggestionInvoking(tabTitle, 15, 31, 'Console scala');
commonLsTests.autocomplete(tabTitle, 25, 28, 'name: String');
// commonLsTests.codeNavigation(tabTitle, 19, 7, codeNavigationClassName, 30_000); // not working
});

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/tests/login/LinkCheAndOcpUsers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/

import { TestConstants, DriverHelper, CLASSES, ICheLoginPage, TYPES } from '../..';
import { TestConstants, DriverHelper, CLASSES, TYPES } from '../..';
import { e2eContainer } from '../../inversify.config';
import { IOcpLoginPage } from '../../pageobjects/login/IOcpLoginPage';
import { UpdateAccountInformationPage } from '../../pageobjects/login/UpdateAccountInformationPage';
Expand Down
14 changes: 11 additions & 3 deletions tests/e2e/testsLibrary/CodeExecutionTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { CLASSES, Terminal, TopMenu, Ide, DialogWindow, DriverHelper } from '..';
import { e2eContainer } from '../inversify.config';
import Axios from 'axios';
import { TimeoutConstants } from '../TimeoutConstants';
import { Key } from 'selenium-webdriver';

const terminal: Terminal = e2eContainer.get(CLASSES.Terminal);
const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu);
Expand All @@ -26,12 +26,13 @@ export function runTask(taskName: string, timeout: number) {
});
}

export function runTaskInputText(taskName: string, inputText: string, timeout: number) {
export function runTaskInputText(taskName: string, waitedText: string, inputText: string, timeout: number) {
test(`Run command '${taskName}' expecting dialog shell`, async () => {
await topMenu.runTask(taskName);
await terminal.waitText(taskName, 'Enter your name', TimeoutConstants.TS_SELENIUM_TERMINAL_DEFAULT_TIMEOUT);
await terminal.waitText(taskName, waitedText, timeout);
await terminal.clickOnTab(taskName);
await terminal.type(taskName, inputText);
await terminal.type(taskName, Key.ENTER);
await terminal.waitIconSuccess(taskName, timeout);
});
}
Expand Down Expand Up @@ -69,6 +70,13 @@ export function runTaskWithDialogShellAndClose(taskName: string, expectedDialogT
});
}

export function runTaskWithNotification(taskName: string, notificationText: string, timeout: number) {
test(`Run command '${taskName}' expecting notification pops up`, async () => {
await topMenu.runTask(taskName);
await ide.waitNotification(notificationText, timeout);
});
}

export function closeTerminal(taskName: string) {
test('Close the terminal tasks', async () => {
await ide.closeAllNotifications();
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utils/DriverHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class DriverHelper {
}
}

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

public async waitPresence(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
Expand Down

0 comments on commit b7c71e0

Please sign in to comment.