Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
fix(tests) : Update UI tests to run on both Agile and SDD template pa…
Browse files Browse the repository at this point in the history
…rallelly (#2747)
  • Loading branch information
Raunak1203 authored and jarifibrahim committed Aug 23, 2018
1 parent 8e7d61b commit 51bacb6
Show file tree
Hide file tree
Showing 16 changed files with 474 additions and 314 deletions.
11 changes: 9 additions & 2 deletions src/tests/mixins/logging.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { browser } from 'protractor';
import { debug, info } from '../support';

export class Logging {
name: string = '';

log(action: string, ...msg: string[]) {
let className = this.constructor.name;
info(`${action}: ${className}('${this.name}')`, ...msg);
info(`${action}: ${browser.browserName} ${className}('${this.name}')`, ...msg);
}

debug(context: string, ...msg: string[]) {
let className = this.constructor.name;
debug(`... ${className}('${this.name}'): ${context}`, ...msg);
debug(`${browser.browserName} ${className}('${this.name}'): ${context}`, ...msg);
}

fail(action: string, ...msg: string[]) {
let className = this.constructor.name;
/* to display errors in red */
console.error('\x1b[31m%s', `${action}: ${browser.browserName} ${className}('${this.name}')`, ...msg, '\x1b[0m');
}
}
9 changes: 8 additions & 1 deletion src/tests/page_objects/planner/planner.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ export class PlannerPage extends AppPage {
}

async resetState() {
await this.sidePanel.clickScenarios();
if (await browser.browserName === 'browserSDD') {
await this.sidePanel.clickWorkItemGroup('Scenarios');
} else if (await browser.browserName === 'browserAgile') {
await this.sidePanel.clickWorkItemGroup('Work Items');
} else {
support.debug('browser Name not defined');
}

await $('body').sendKeys(Key.ESCAPE);
}
}
12 changes: 8 additions & 4 deletions src/tests/specs/collaboratorTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ describe('Planner Collaborator Tests:', () => {
let planner: PlannerPage;
let planner1: PlannerPage;
let c = new support.Constants();
let testData;

beforeAll(async () => {
await support.desktopTestSetup();
planner = new PlannerPage(browser.baseUrl);
await planner.openInBrowser();
let url = await browser.getCurrentUrl();
testData = c.browserName[browser.browserName];
let URL = '';
/* Run tests against production or prod-preview */
if (url.startsWith('https://openshift.io')) {
Expand All @@ -28,7 +30,7 @@ describe('Planner Collaborator Tests:', () => {
});

beforeEach(async () => {
await planner.ready();
await planner.workItemList.ready();
await planner.workItemList.overlay.untilHidden();
});

Expand All @@ -49,9 +51,11 @@ describe('Planner Collaborator Tests:', () => {
});

it('Non collaborator should Comment and Save', async () => {
await planner1.workItemList.clickWorkItem('Work Item 3');
await planner1.quickPreview.addCommentAndSave(c.comment);
expect(await planner1.quickPreview.getComments()).toContain(c.comment);
let comment = 'new comment';
/* to avoid workitem conflict should comment on 2 different workitem */
await planner1.workItemList.clickWorkItem(testData.commentCollaboratorTest);
await planner1.quickPreview.addCommentAndSave(comment);
expect(await planner1.quickPreview.getComments()).toContain(comment);
});

it('Non collaborator should not be able to update Area ', async () => {
Expand Down
73 changes: 39 additions & 34 deletions src/tests/specs/detailPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import * as support from '../support';
describe('Detail View test: ', () => {
let planner: PlannerPage;
let c = new support.Constants();
let testData;

beforeAll(async () => {
await support.desktopTestSetup();
planner = new PlannerPage(browser.baseUrl);
await planner.openInBrowser();
await planner.waitUntilUrlContains('typegroup');
await planner.ready();
testData = await c.browserName[browser.browserName];
});

beforeEach(async () => {
Expand All @@ -26,13 +27,14 @@ describe('Detail View test: ', () => {
});

it('should open detail view and apply label', async () => {
let workitemname = {'title': 'detail page test'};
let workitemname = {'title': 'detail page test'},
label = 'sample_label_1';
await planner.createWorkItem(workitemname);
await planner.workItemList.openDetailPage(workitemname.title);
await planner.waitUntilUrlContains('detail');
await planner.detailPage.titleInput.untilTextIsPresentInValue(workitemname.title);
await planner.detailPage.addLabel(c.label);
expect(await planner.detailPage.getLabels()).toContain(c.label);
await planner.detailPage.addLabel(label);
expect(await planner.detailPage.getLabels()).toContain(label);
});

it('should update title and description', async () => {
Expand All @@ -52,62 +54,65 @@ describe('Detail View test: ', () => {
});

it('should associate workitem with an Area', async () => {
await planner.workItemList.openDetailPage(c.workItemTitle2);
let workItemTitle2 = 'Workitem_Title_2';
await planner.workItemList.openDetailPage(workItemTitle2);
await planner.waitUntilUrlContains('detail');
await planner.detailPage.titleInput.untilTextIsPresentInValue(c.workItemTitle2);
await planner.detailPage.addArea(c.dropdownareaTitle1);
expect(await planner.detailPage.getArea()).toBe(c.areaTitle1);
await planner.detailPage.titleInput.untilTextIsPresentInValue(workItemTitle2);
await planner.detailPage.addArea(testData.dropdownareaTitle1);
expect(await planner.detailPage.getArea()).toBe(testData.areaTitle1);
});

it('should associate workitem with an Iteration', async () => {
await planner.workItemList.openDetailPage(c.workItemTitle2);
let workItemTitle2 = 'Workitem_Title_2';
await planner.workItemList.openDetailPage(workItemTitle2);
await planner.waitUntilUrlContains('detail');
await planner.detailPage.titleInput.untilTextIsPresentInValue(c.workItemTitle2);
await planner.detailPage.addIteration(c.dropdownIteration1);
expect(await planner.detailPage.getIteration()).toBe(c.iteration1);
await planner.detailPage.titleInput.untilTextIsPresentInValue(workItemTitle2);
await planner.detailPage.addIteration(testData.dropdownIteration1);
expect(await planner.detailPage.getIteration()).toBe(testData.iteration1);
});

it('should add comment', async () => {
await planner.workItemList.openDetailPage(c.workItemTitle2);
let workItemTitle2 = 'Workitem_Title_2',
comment = 'new comment';
await planner.workItemList.openDetailPage(workItemTitle2);
await planner.waitUntilUrlContains('detail');
await planner.detailPage.titleInput.untilTextIsPresentInValue(c.workItemTitle2);
await planner.detailPage.addCommentAndSave(c.comment);
expect(await planner.detailPage.getComments()).toContain(c.comment);
await planner.detailPage.titleInput.untilTextIsPresentInValue(workItemTitle2);
await planner.detailPage.addCommentAndSave(comment);
expect(await planner.detailPage.getComments()).toContain(comment);
});

it('should link a workitem', async () => {
let linkType = 'blocks',
searchWorkItem = '2 - Workitem_Title_3',
Workitem_Title_3 = 'Workitem_Title_3';
await planner.workItemList.openDetailPage(c.workItemTitle2);
workItemTitle2 = 'Workitem_Title_2';
await planner.workItemList.openDetailPage(workItemTitle2);
await planner.waitUntilUrlContains('detail');
await planner.detailPage.titleInput.untilTextIsPresentInValue(c.workItemTitle2);
await planner.detailPage.addLink(linkType, searchWorkItem, Workitem_Title_3);
expect(await planner.detailPage.getLinkedItems()).toContain(Workitem_Title_3);
await planner.detailPage.titleInput.untilTextIsPresentInValue(workItemTitle2);
/* Adding link b/w workItemTitle2 and Workitem_Title_3 */
await planner.detailPage.addLink(linkType, testData.searchWorkItem3, testData.Workitem_Title_3);
expect(await planner.detailPage.getLinkedItems()).toContain(testData.Workitem_Title_3);
});

it('should remove link from workitem', async () => {
let workItemName1 = {'title': 'Remove_link_from_workitem_test'},
linkType = 'blocks',
searchWorkItem = '3 - Workitem_Title_4',
Workitem_Title = 'Workitem_Title_4';
linkType = 'blocks';
await planner.createWorkItem(workItemName1);
await planner.workItemList.openDetailPage(workItemName1.title);
await planner.waitUntilUrlContains('detail');
await planner.detailPage.titleInput.untilTextIsPresentInValue(workItemName1.title);
await planner.detailPage.addLink(linkType, searchWorkItem, Workitem_Title);
expect(await planner.detailPage.getLinkedItems()).toContain(Workitem_Title);
await planner.detailPage.removeLink(Workitem_Title);
await planner.detailPage.addLink(linkType, testData.searchWorkItem4, testData.Workitem_Title_4);
expect(await planner.detailPage.getLinkedItems()).toContain(testData.Workitem_Title_4);
await planner.detailPage.removeLink(testData.Workitem_Title_4);
await planner.detailPage.linkCount.untilTextIsPresent('0');
expect(await planner.detailPage.linkCount.getTextWhenReady()).toBe('0');
});

it('should change the state of workitem', async () => {
await planner.workItemList.openDetailPage(c.workItemTitle2);
let workItemTitle2 = 'Workitem_Title_2';
await planner.workItemList.openDetailPage(workItemTitle2);
await planner.waitUntilUrlContains('detail');
await planner.detailPage.titleInput.untilTextIsPresentInValue(c.workItemTitle2);
await planner.detailPage.changeStateTo('open');
expect(await planner.detailPage.getState()).toBe('open');
await planner.detailPage.titleInput.untilTextIsPresentInValue(workItemTitle2);
await planner.detailPage.changeStateTo(testData.stateOpen);
expect(await planner.detailPage.getState()).toBe(testData.stateOpen);
});

it('Should change the type of work item', async () => {
Expand All @@ -116,7 +121,7 @@ describe('Detail View test: ', () => {
await planner.workItemList.openDetailPage(workitemname.title);
await planner.waitUntilUrlContains('detail');
await planner.detailPage.titleInput.untilTextIsPresentInValue(workitemname.title);
await planner.detailPage.changeTypeTo('Bug');
expect(await planner.detailPage.getType()).toBe('Bug');
await planner.detailPage.changeTypeTo(testData.typeIssue);
expect(await planner.detailPage.getType()).toBe(testData.typeIssue);
});
});
10 changes: 5 additions & 5 deletions src/tests/specs/iteration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import * as support from '../support';

describe('Iteration test', () => {
let planner: PlannerPage;
let c = new support.Constants();
let testData;

beforeAll(async () => {
await support.desktopTestSetup();
planner = new PlannerPage(browser.baseUrl);
await planner.openInBrowser();
await planner.waitUntilUrlContains('typegroup');
testData = await c.browserName[browser.browserName];
});

beforeEach(async () => {
Expand All @@ -24,7 +27,6 @@ describe('Iteration test', () => {

it('should create a new iteration', async () => {
let newIteration = 'new Iteration';
let iteration3 = '/' + process.env.SPACE_NAME;
await planner.sidePanel.createNewIteration();
await planner.iteration.addNewIteration(newIteration, null, true);
let month = await planner.iteration.getMonth();
Expand All @@ -38,10 +40,9 @@ describe('Iteration test', () => {

it('should create a new child iteration', async () => {
let newIteration = 'new Iteration1';
let parentIteration = '/' + process.env.SPACE_NAME + '/Iteration_2';
let iteration = 'Iteration_2';
await planner.sidePanel.createNewIteration();
await planner.iteration.addNewIteration(newIteration, parentIteration);
await planner.iteration.addNewIteration(newIteration, testData.parentIteration);
await planner.iteration.clickCreateIteration();
await planner.sidePanel.clickExpander(iteration);
expect(await planner.sidePanel.getIterationList()).toContain(newIteration);
Expand All @@ -55,7 +56,6 @@ describe('Iteration test', () => {
await planner.sidePanel.createNewIteration();
await planner.iteration.addNewIteration(dropdownIteration1);
await planner.iteration.clickCreateIteration();

await planner.workItemList.workItem(workItemTitle1).openQuickPreview();
await planner.quickPreview.addIteration(dropdownIteration1);
await planner.quickPreview.close();
Expand All @@ -81,7 +81,7 @@ describe('Iteration test', () => {
await planner.iteration.parentIteration.enterText(iterationName);
let val = await planner.iteration.parentDropdownList.getTextWhenReady();
// Ensure val is exactly the value we expect it to be
expect(val).toBe('/' + process.env.SPACE_NAME + '/' + iterationName);
expect(val).toBe(testData.rootIteration + '/' + iterationName);
await planner.iteration.clickCancel();
});
});
41 changes: 24 additions & 17 deletions src/tests/specs/quickPreview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import * as support from '../support';
describe('Quick preview tests: ', () => {
let planner: PlannerPage;
let c = new support.Constants();
let testData;

beforeAll(async () => {
await support.desktopTestSetup();
planner = new PlannerPage(browser.baseUrl);
await planner.openInBrowser();
await planner.waitUntilUrlContains('typegroup');
testData = await c.browserName[browser.browserName];
});

beforeEach(async () => {
Expand All @@ -24,17 +26,22 @@ describe('Quick preview tests: ', () => {
});

it('should open quickpreview and apply label', async () => {
await planner.workItemList.clickWorkItem(c.workItemTitle2);
await planner.quickPreview.addLabel(c.label2);
expect(await planner.quickPreview.getLabels()).toContain(c.label2);
let title = await planner.createUniqueWorkItem(),
label = 'sample_label_1';
await planner.workItemList.clickWorkItem(title);
await planner.quickPreview.addLabel(label);
await planner.detailPage.labelListDiv.untilCount(1);
expect(await planner.quickPreview.getLabels()).toContain(label);
});

it('should open quickpreview and create new label', async () => {
let workitemname = {'title': 'test labels'};
let workitemname = {'title': 'test labels'},
newLabel = 'new label';
await planner.createWorkItem(workitemname);
await planner.workItemList.clickWorkItem(workitemname.title);
await planner.quickPreview.createNewLabel(c.newLabel);
expect(await planner.quickPreview.getLabels()).toContain(c.newLabel);
await planner.quickPreview.createNewLabel(newLabel);
await planner.detailPage.labelListDiv.untilCount(1);
expect(await planner.quickPreview.getLabels()).toContain(newLabel);
});

it('should open quickpreview and create new label using Enter Key', async () => {
Expand All @@ -48,38 +55,38 @@ describe('Quick preview tests: ', () => {

it('should link a workitem', async () => {
let workitemname = {'title': 'link test'},
linkType = 'blocks',
searchWorkItem = '3 - Workitem_Title_4',
workItemTitle17 = 'Workitem_Title_4';
linkType = 'blocks';
await planner.createWorkItem(workitemname);
await planner.workItemList.clickWorkItem(workitemname.title);
await planner.quickPreview.addLink(linkType, searchWorkItem, workItemTitle17);
await planner.quickPreview.linklistItem.untilTextIsPresent(workItemTitle17);
expect(await planner.quickPreview.getLinkedItems()).toContain(workItemTitle17);
await planner.quickPreview.addLink(linkType, testData.searchWorkItem4, testData.Workitem_Title_4);
await planner.quickPreview.linklistItem.untilTextIsPresent(testData.Workitem_Title_4);
expect(await planner.quickPreview.getLinkedItems()).toContain(testData.Workitem_Title_4);
});

it('should open quick preview and edit the title', async () => {
let title = await planner.createUniqueWorkItem();
let title = await planner.createUniqueWorkItem(),
editWorkItemTitle1 = 'Title Text "<0>"';
await planner.workItemList.clickWorkItem(title);
await planner.quickPreview.updateTitle(c.editWorkItemTitle1);
await planner.quickPreview.updateTitle(editWorkItemTitle1);
expect(await planner.quickPreview.titleInput.getAttribute('value')).toBe('Title Text "<0>"');
});

it('description box should not be open for wis', async () => {
let workitemname = {'title': 'quickpreview test'};
let workitemname = {'title': 'quickpreview test'},
workItemTitle2 = 'Workitem_Title_2';
await planner.createWorkItem(workitemname);
await planner.workItemList.clickWorkItem(workitemname.title);
await planner.quickPreview.openDescriptionBox();
expect(await planner.quickPreview.isSaveButtonDisplayed()).toBeTruthy();

// Open another WI(Note: the description box is still in edit mode)
await planner.workItemList.clickWorkItem(c.workItemTitle2);
await planner.workItemList.clickWorkItem(workItemTitle2);
// The description box should not be in edit mode
expect(await planner.quickPreview.isSaveButtonDisplayed()).toBeFalsy();
});

it('should close assignee dropdown when clicked outside', async () => {
await planner.workItemList.clickWorkItem(c.workItemTitle2);
await planner.workItemList.clickWorkItem('Workitem_Title_2');
await planner.quickPreview.assigneeDropdown.clickWhenReady();
expect(await planner.quickPreview.assigneeDropdownMenu.getAttribute('className')).toContain('show');
await planner.quickPreview.titleInput.clickWhenReady();
Expand Down
Loading

0 comments on commit 51bacb6

Please sign in to comment.