Skip to content

Commit

Permalink
fix(test): start POC test for booster terminal test
Browse files Browse the repository at this point in the history
  • Loading branch information
ldimaggi committed Feb 28, 2018
1 parent ca23e56 commit 661f305
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ee_tests/protractorTS.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ let conf: Config = {
chetest: ['src/specs/**/quickstart_che.spec.js'],
analyticstest: ['src/specs/**/quickstart_analytic.spec.js'],

boosterterminaltest: ['src/specs/**/quickstart_che2.spec.js'],

logintest: ['src/specs/**/quickstart_login.spec.js'],
boosterTest: ['src/specs/**/booster_pipeline.spec.js'],
importTest: ['src/specs/**/workshop-import-to-space.spec.js'],
Expand Down
5 changes: 5 additions & 0 deletions ee_tests/src/specs/page_objects/login.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class LoginPage extends BasePage {
passwordInput = new ui.TextInput($('#password'), 'password');
loginButton = new ui.Button($('#kc-login'), 'Login');
everythingOnPage = element(by.xpath('.//*'));
alertContent = element(by.xpath('.//*[contains(@class,\'alert-content\')]'));

/* Social media login options */
githubLoginButton = $('#social-github');
Expand Down Expand Up @@ -47,6 +48,10 @@ export class LoginPage extends BasePage {
await this.loginButton.clickWhenReady();

this.debug('... Login: input details and click Login - OK');

let theText = await this.everythingOnPage.getText();
support.info ('Text on login page = ' + theText);
await expect(this.alertContent.isPresent()).toBe(false);

let mainDashboard = new MainDashboardPage()
await mainDashboard.open()
Expand Down
12 changes: 11 additions & 1 deletion ee_tests/src/specs/page_objects/space_cheworkspace.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,25 @@ export class SpaceCheWorkspacePage extends AppPage {

// tslint:disable:max-line-length

/* Main Menu Panel run button */
/* Main Menu Panel run/debug buttons */
mainMenuRunButton = new Button ($('#gwt-debug-command_toolbar-button_Run'), 'Che Main Menu Run Button');
mainMenuDebugButton = new Button ($('#gwt-debug-command_toolbar-button_Debug'), 'Che Main Menu Debug Button');

/* Main Menu Panel run button run selection */
mainMenuRunButtonRunSelection = new Button (element(by.xpath('.//*[contains(@class,\'gwt-PopupPanel GDPEHSMCJAB\')]')), 'Che Main Menu Run Selection Button');

/* Main Menu Panel debug button debug selection */
mainMenuDebugButtonDebugSelection = new Button (element(by.xpath('.//*[contains(@class,\'gwt-PopupPanel GDPEHSMCJAB\')]')), 'Che Main Menu Run Selection Button');

/* Bottom Panel run tab */
bottomPanelRunTab = new Button (element(by.xpath('.//*[contains(@class,\'GDPEHSMCKHC\')][contains(text(),\'run\')]')), 'Che Bottom Panel Run Tab');

/* Bottom Panel terminal tab */
bottomPanelTerminalTab = new Button (element(by.xpath('.//*[contains(@class,\'GDPEHSMCKHC\')][contains(text(),\'Terminal\')]')), 'Che Bottom Panel Terminal Tab');

bottomPanelTerminal = new TextInput (element(by.xpath('.//*[@id=\'gwt-debug-Terminal\']')));
// bottomPanelTerminal = element(by.xpath('(.//*[contains (@class,\'xterm-rows\')]/div)[1]'));

/* Bottom Panel title */
bottomPanelOutputTitles = element.all(by.xpath('.//*[contains(@class,\'GJ5I-CRBHRB GJ5I-CRBCRB\')]'));

Expand Down
134 changes: 134 additions & 0 deletions ee_tests/src/specs/quickstart_che2.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { browser, Key, ExpectedConditions as until, $, $$ } from 'protractor';
import * as support from './support';
import { Quickstart } from './support/quickstart';
import { TextInput, Button } from './ui';

import { LandingPage } from './page_objects/landing.page';
import { SpaceDashboardPage } from './page_objects/space_dashboard.page';
import { SpaceChePage } from './page_objects/space_che.page';
import { SpaceCheWorkspacePage } from './page_objects/space_cheworkspace.page';
import { MainDashboardPage } from './page_objects/main_dashboard.page';

let globalSpaceName: string;

/* Tests to verify the build pipeline */

describe('Creating new quickstart in OSIO', () => {
let dashboardPage: MainDashboardPage;

beforeEach(async () => {
await support.desktopTestSetup();
let login = new support.LoginInteraction();
dashboardPage = await login.run();

let userProfilePage = await dashboardPage.gotoUserProfile();
support.debug(">>> Go to user's Profile Page - OK");
support.debug('>>> Go to Edit Profile Page');
let editProfilePage = await userProfilePage.gotoEditProfile();
support.debug('>>> Go to Edit Profile Page - OK');
support.debug('>>> Go to Reset Env Page');
let cleanupEnvPage = await editProfilePage.gotoResetEnvironment();
support.debug('>>> Go to Reset Env Page - OK');

await cleanupEnvPage.cleanup(browser.params.login.user);

});

afterEach( async () => {
await browser.sleep(support.DEFAULT_WAIT);

support.writeScreenshot('target/screenshots/che_final_' + globalSpaceName + '.png');
support.info('\n ============ End of test reached ============ \n');
// support.info('\n ============ End of test reached, logging out ============ \n');
/* Logout is causing random failures on prod-preview - possibky due to navigating browser windows? */
// await dashboardPage.logout();
});

/* Simple test - accept all defaults for new quickstarts */

it('Create a new space, new ' + browser.params.quickstart.name + ' quickstart, run its pipeline', async () => {
let quickstart = new Quickstart(browser.params.quickstart.name);
let spaceName = support.newSpaceName();
globalSpaceName = spaceName;
let spaceDashboardPage = await dashboardPage.createNewSpace(spaceName);

let wizard = await spaceDashboardPage.addToSpace();

support.info('Creating quickstart: ' + quickstart.name);
await wizard.newQuickstartProject({ project: quickstart.name });
await spaceDashboardPage.ready();

/* This statement does not reliably wait for the modal dialog to disappear:
await browser.wait(until.not(until.visibilityOf(spaceDashboardPage.modalFade)), support.LONGEST_WAIT);
The above statement fails with this error: Failed: unknown error: Element <a id="spacehome-pipelines-title"
href="/username/spaceName/create/pipelines">...</a> is not clickable at point (725, 667). Other element would
receive the click: <modal-container class="modal fade" role="dialog" tabindex="-1" style="display:
block;">...</modal-container>
The only reliable way to avoid this is a sleep statement: await browser.sleep(5000); */
await browser.sleep(5000);

/* Open Che display page */

// tslint:disable:max-line-length
await spaceDashboardPage.codebasesSectionTitle.clickWhenReady();

let spaceChePage = new SpaceChePage();
await spaceChePage.createCodebase.clickWhenReady(support.LONGEST_WAIT);

/* A new browser window is opened when Che opens - switch to that new window now */
let handles = await browser.getAllWindowHandles();
support.debug('Number of browser tabs before = ' + handles.length);

handles = await browser.getAllWindowHandles();
while (handles.length < 2) {
support.info ('***Waiting for Che browser window to open***');
await browser.sleep (3000);
handles = await browser.getAllWindowHandles();
}

support.debug('Number of browser tabs after = ' + handles.length);
support.writeScreenshot('target/screenshots/che_workspace_parta_' + spaceName + '.png');

/* Switch to the Che browser window */
await browser.switchTo().window(handles[1]);

let spaceCheWorkSpacePage = new SpaceCheWorkspacePage();
support.writeScreenshot('target/screenshots/che_workspace_partb_' + spaceName + '.png');

let projectInCheTree = new Button(spaceCheWorkSpacePage.recentProjectRootByName(spaceName), 'Project in Che Tree');
await projectInCheTree.untilPresent(support.LONGEST_WAIT);
support.writeScreenshot('target/screenshots/che_workspace_partc_' + spaceName + '.png');

expect(await spaceCheWorkSpacePage.recentProjectRootByName(spaceName).getText()).toContain(spaceName);

// Defer this test to speed up test execution as hourly ee test
// await spaceCheWorkSpacePage.mainMenuRunButton.clickWhenReady(support.LONGEST_WAIT);
//
// await spaceCheWorkSpacePage.mainMenuRunButtonRunSelection.clickWhenReady(support.LONGEST_WAIT);
// await spaceCheWorkSpacePage.bottomPanelRunTab.clickWhenReady(support.LONGEST_WAIT);
//
// await browser.wait(until.textToBePresentInElement(spaceCheWorkSpacePage.bottomPanelCommandConsoleLines, 'Succeeded in deploying verticle'), support.LONGER_WAIT);
// let textStr = await spaceCheWorkSpacePage.bottomPanelCommandConsoleLines.getText();
// support.info('Output from run = ' + textStr);
// expect(await spaceCheWorkSpacePage.bottomPanelCommandConsoleLines.getText()).toContain('Succeeded in deploying verticle');

/* Open the terminal window and execute a command */
await spaceCheWorkSpacePage.bottomPanelTerminalTab.clickWhenReady();
// await browser.driver.actions().mouseDown(spaceCheWorkSpacePage.bottomPanelTerminal).click().sendKeys(' ls -la').perform();
// await browser.driver.actions().mouseDown(spaceCheWorkSpacePage.bottomPanelTerminal).click().sendKeys(Key.ENTER).perform();
await support.printTerminal(spaceCheWorkSpacePage, 'ls -la');
await support.printTerminal(spaceCheWorkSpacePage, 'cd ' + spaceName);
await support.printTerminal(spaceCheWorkSpacePage, 'ls -la');
await support.printTerminal(spaceCheWorkSpacePage, 'mvn install');
await browser.sleep(support.DEFAULT_WAIT);

let theText = await spaceCheWorkSpacePage.bottomPanelTerminal.getText();
support.info ('retrieved text = ' + theText);

/* Switch back to the OSIO browser window */
await browser.switchTo().window(handles[0]);
});

});
17 changes: 15 additions & 2 deletions ee_tests/src/specs/support/core.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { browser } from 'protractor';
import { browser, Key } from 'protractor';
import * as fs from 'fs';
import { SpacePipelinePage } from '../page_objects/space_pipeline.page';

import { SpaceCheWorkspacePage } from '../page_objects/space_cheworkspace.page';

export enum BrowserMode {
Phone,
Expand Down Expand Up @@ -34,6 +34,19 @@ export async function setBrowserMode(mode: BrowserMode) {
}
}


/* Print text to the Che Terminal window */
// tslint:disable:max-line-length
export async function printTerminal (spaceCheWorkspacePage: SpaceCheWorkspacePage, textToPrint: string) {
//await browser.sleep(10000);
await browser.driver.actions().mouseDown(spaceCheWorkspacePage.bottomPanelTerminal).click().sendKeys(textToPrint).perform();
//await browser.sleep(10000);
await browser.driver.actions().mouseDown(spaceCheWorkspacePage.bottomPanelTerminal).click().sendKeys(Key.ENTER).perform();
//await browser.sleep(10000);
}
// tslint:enable:max-line-length


/*
* Display the contents of the Jenkins build log.
*/
Expand Down

0 comments on commit 661f305

Please sign in to comment.