Skip to content

Commit

Permalink
fix(test): Initial test for executing test from mvn in Che workspace …
Browse files Browse the repository at this point in the history
…terminal shell
  • Loading branch information
ldimaggi committed Mar 2, 2018
1 parent 6f34243 commit 8d1cc8a
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 4 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_cheterminal.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
1 change: 1 addition & 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('(.//*)[1]'));
alertContent = element(by.xpath('.//*[contains(@class,\'alert-content\')]'));

/* Social media login options */
githubLoginButton = $('#social-github');
Expand Down
16 changes: 14 additions & 2 deletions 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,24 @@ 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\']')));

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

Expand All @@ -34,9 +43,12 @@ export class SpaceCheWorkspacePage extends AppPage {
bottomPanelOutputPreview = element.all(by.xpath('.//*[contains(text(),\'preview:\')]/following-sibling::a[contains(text(),\'http://\')]'));

/* Bottom Panel command console lines of text */
// bottomPanelCommandConsoleLines = element.all(by.xpath('.//*[@id=\'gwt-debug-commandConsoleScrollPanel\']/pre')).last();
bottomPanelCommandConsoleLines = element(by.xpath('.//*[@id=\'gwt-debug-consolesPanel\']'));

/* Bottom Panel terminal tab console lines of text */
bottomPanelTerminalConsoleLines = element.all(by.xpath(".//*[contains(@class,'xterm-rows')]"));
bottomPanelTerminalConsoleLastLine = element.all(by.xpath(".//*[contains(@class,'xterm-rows')]/div")).last();

recentProjectRootByName (projectName: string): ElementFinder {
let xpathString = './/*[@id=\'gwt-debug-projectTree\']/div[contains(@name,\'' + projectName + '\')]';
return element(by.xpath(xpathString));
Expand Down
106 changes: 106 additions & 0 deletions ee_tests/src/specs/quickstart_cheterminal.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
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 Che in OSIO */

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');
await dashboardPage.logout();
});

/* Accept all defaults for new quickstarts */

// tslint:disable:max-line-length
it('Create a new space, new ' + browser.params.quickstart.name + ' quickstart, create Che workspace, run maven in the workspace', 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();

/* Open Che display page */
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);
await browser.wait(windowCount(2), support.DEFAULT_WAIT);
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);

/* Open the terminal window and execute command */
await spaceCheWorkSpacePage.bottomPanelTerminalTab.clickWhenReady();
await support.printTerminal(spaceCheWorkSpacePage, 'cd ' + spaceName);
await support.printTerminal(spaceCheWorkSpacePage, 'mvn clean install -Popenshift,openshift-it');

await browser.wait(until.textToBePresentInElement(spaceCheWorkSpacePage.bottomPanelTerminal, 'BUILD SUCCESS'), support.LONGER_WAIT);
await expect(spaceCheWorkSpacePage.bottomPanelTerminal.getText()).toContain('BUILD SUCCESS');
await expect(spaceCheWorkSpacePage.bottomPanelTerminal.getText()).not.toContain('BUILD FAILURE');

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


function windowCount (count: number) {
return function () {
return browser.getAllWindowHandles().then(function (handles) {
return handles.length === count;
});
};
}

});
16 changes: 14 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,18 @@ export async function setBrowserMode(mode: BrowserMode) {
}
}


/* Print text to the Che Terminal window - a 2nd RETURN char is used to make the text easier to read */
// tslint:disable:max-line-length
export async function printTerminal (spaceCheWorkspacePage: SpaceCheWorkspacePage, textToPrint: string) {
await browser.driver.actions().mouseDown(spaceCheWorkspacePage.bottomPanelTerminal).click().sendKeys(' ').perform();
await browser.driver.actions().mouseDown(spaceCheWorkspacePage.bottomPanelTerminal).click().sendKeys(textToPrint).perform();
await browser.driver.actions().mouseDown(spaceCheWorkspacePage.bottomPanelTerminal).click().sendKeys(Key.ENTER).perform();
await browser.driver.actions().mouseDown(spaceCheWorkspacePage.bottomPanelTerminal).click().sendKeys(Key.ENTER).perform();
}
// tslint:enable:max-line-length


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

0 comments on commit 8d1cc8a

Please sign in to comment.