Skip to content

Commit e38a48c

Browse files
Add view Milestone tests
1 parent 5c6ba8a commit e38a48c

File tree

10 files changed

+242
-29
lines changed

10 files changed

+242
-29
lines changed

e2e/elements/datepicker.element.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export class DatePicker extends BaseElement {
3737
return this.dayButton(day).click();
3838
}
3939

40+
isEditable(): Promise<boolean> {
41+
return this.linkInput.isPresent();
42+
}
43+
4044
private async selectMonth(month: string): Promise<void> {
4145
for (let i = 0; i < this.monthNames.length; i++) {
4246
const currentMonth = await this.getCurrentMonth();

e2e/elements/multiselect.element.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { by, Locator, ElementFinder } from 'protractor';
1+
import { by, Locator, ElementFinder, protractor } from 'protractor';
22
import { BaseElement } from './base.element';
33
import { WithSearch } from './interfaces/elementWithSearch';
44

@@ -28,11 +28,17 @@ export class Multiselect extends BaseElement implements WithSearch {
2828

2929
public async select(value: string) {
3030
await this.enterValue(value);
31-
return this.selectOption(value);
31+
await this.selectOption(value);
32+
if (await this.isOpened()) {
33+
return this.search.sendKeys(protractor.Key.ESCAPE);
34+
}
3235
}
3336

34-
public remove(name: string) {
35-
return this.removeMsBox(name).click();
37+
public async remove(name: string) {
38+
await this.removeMsBox(name).click();
39+
if (await this.isOpened()) {
40+
return this.search.sendKeys(protractor.Key.ESCAPE);
41+
}
3642
}
3743

3844
public async isEditable() {
@@ -52,6 +58,10 @@ export class Multiselect extends BaseElement implements WithSearch {
5258
return (await this.disabledElement.getText()).split(', ');
5359
}
5460

61+
private isOpened() {
62+
return this.search.isPresent();
63+
}
64+
5565
private findOption(value: string) {
5666
return this.element.element(by.css(`.selector-suggestions li[title="${value}"]`));
5767
}

e2e/elements/ui-switch.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@ export class UiSwitch extends BaseElement {
2828
return this.element.click();
2929
}
3030
}
31+
32+
async isEnabled() {
33+
const elementClass = await this.element.element(by.tagName('span')).getAttribute('class');
34+
return !elementClass.includes('disabled');
35+
}
3136
}

e2e/pages/milestone/list.po/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class MilestoneList extends BasePage {
4646
}
4747

4848
openMilestone(name: string) {
49-
return elements.milestonesTable.clickRow(name, columns.name);
49+
return elements.milestonesTable.clickCell(columns.name, name, columns.name);
5050
}
5151

5252
addMilestoneSuite(suiteName: string, name: string) {

e2e/pages/milestone/view.po/constants.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { SmartTable } from '../../../elements/smartTable.element';
33
import { UiSwitch } from '../../../elements/ui-switch';
44
import { ResultPieChart } from '../../../elements/charts/resultPie.element';
55
import { ResolutionPieChart } from '../../../elements/charts/resolution.Pie.element';
6+
import { Multiselect } from '../../../elements/multiselect.element';
7+
import { DatePicker } from '../../../elements/datepicker.element';
68

79
export const baseUrl = (projectId: number, milestoneId: number) => `/project/${projectId}/milestone/${milestoneId}`;
810

@@ -11,7 +13,13 @@ export const elements = {
1113
milestonesTable: new SmartTable(by.id('suite-results')),
1214
distinctTest: new UiSwitch(by.css('#stack-suites ui-switch')),
1315
resultsChart: new ResultPieChart(by.id('finalResultsChart')),
14-
resolutionsChart: new ResolutionPieChart(by.id('resultResolutionsChart'))
16+
resolutionsChart: new ResolutionPieChart(by.id('resultResolutionsChart')),
17+
suites: new Multiselect(by.id('suites')),
18+
notExecutedSuites: element(by.id('not-executed-suites')),
19+
dueDate: new DatePicker(by.id('milestone-due-date')),
20+
warning: element(by.css('#milestone-view fa-icon.warning-icon')),
21+
warningTitle: element(by.css('#milestone-view fa-icon.warning-icon title')),
22+
activeSwitch: new UiSwitch(by.css('#active-switch ui-switch'))
1523
};
1624

1725
export const names = {

e2e/pages/milestone/view.po/index.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { elements, names, columns } from './constants';
22
import { BasePage } from '../../base.po';
3+
import { promise, element } from 'protractor';
34

45
class MilestoneView extends BasePage {
56
constructor() {
@@ -43,6 +44,50 @@ class MilestoneView extends BasePage {
4344
const isFiltered = await elements.milestonesTable.isContainOnlyRowsWith(column, value);
4445
return isSelected && isFiltered;
4546
}
47+
48+
addSuite(name: string): Promise<void> {
49+
return elements.suites.select(name);
50+
}
51+
52+
getNotExecutedSuites(): promise.Promise<string> {
53+
return elements.notExecutedSuites.getText();
54+
}
55+
56+
isNotExecutedSuitesExist(): promise.Promise<boolean> {
57+
return elements.notExecutedSuites.isPresent();
58+
}
59+
60+
removeSuite(name: string): Promise<void> {
61+
return elements.suites.remove(name);
62+
}
63+
64+
setDueDate(date: Date): Promise<void> {
65+
return elements.dueDate.select(date);
66+
}
67+
68+
isWarningPresent(): promise.Promise<boolean> {
69+
return elements.warning.isPresent();
70+
}
71+
72+
getWarningTitle(): promise.Promise<string> {
73+
return elements.warningTitle.getText();
74+
}
75+
76+
setActive(state: boolean): Promise<void> {
77+
return elements.activeSwitch.setState(state);
78+
}
79+
80+
isSuitesEditable(): Promise<boolean> {
81+
return elements.suites.isEditable();
82+
}
83+
84+
isDueDateEditable(): Promise<boolean> {
85+
return elements.dueDate.isEditable();
86+
}
87+
88+
isActiveSwitcherEditable(): Promise<boolean> {
89+
return elements.activeSwitch.isEnabled();
90+
}
4691
}
4792

4893
export const milestoneView = new MilestoneView();

e2e/specs/milestone/milestoneList.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { logIn } from '../../pages/login.po';
22
import { projectList } from '../../pages/project/list.po';
33
import { milestoneList } from '../../pages/milestone/list.po';
4-
54
import { ProjectHelper } from '../../helpers/project.helper';
5+
import { TestSuite } from '../../../src/app/shared/models/testSuite';
66
import usersTestData from '../../data/users.json';
7-
87
import using from 'jasmine-data-provider';
9-
import { TestSuite } from '../../../src/app/shared/models/testSuite';
108

119
const editorExamples = {
1210
localManager: usersTestData.localManager,
@@ -28,7 +26,6 @@ describe('Milestone List:', () => {
2826

2927
beforeAll(async () => {
3028
await projectHelper.init({
31-
admin: usersTestData.admin,
3229
localAdmin: usersTestData.localAdmin,
3330
localManager: usersTestData.localManager,
3431
localEngineer: usersTestData.localEngineer,

0 commit comments

Comments
 (0)