-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWorkflowCases.page.ts
More file actions
351 lines (314 loc) · 12.5 KB
/
WorkflowCases.page.ts
File metadata and controls
351 lines (314 loc) · 12.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
import Page from '../Page';
import {selectDateOnDatePicker} from '../../Helpers/helper-functions';
import { $ } from '@wdio/globals';
export class WorkflowCasesPage extends Page {
constructor() {
super();
}
public async rowNum(): Promise<number> {
await browser.pause(500);
return (await $$('#tableBody > tr')).length;
}
public async idTableHeader(): Promise<WebdriverIO.Element> {
const ele = await $('thead > tr > th.mat-column-id');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async dateOfIncidentHeader(): Promise<WebdriverIO.Element> {
const ele = await $('thead > tr > th.mat-column-dateOfIncident');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async incidentTypeHeader(): Promise<WebdriverIO.Element> {
const ele = await $('thead > tr > th.mat-column-incidentType');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async incidentPlaceHeader(): Promise<WebdriverIO.Element> {
const ele = await $('thead > tr > th.mat-column-incidentPlace');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async photosExistsHeader(): Promise<WebdriverIO.Element> {
const ele = await $('#photosExistsHeader');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async descriptionHeader(): Promise<WebdriverIO.Element> {
const ele = await $('thead > tr > th.mat-column-description');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async deadlineHeader(): Promise<WebdriverIO.Element> {
const ele = await $('#deadlineHeader');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async actionPlanHeader(): Promise<WebdriverIO.Element> {
const ele = await $('thead > tr > th.mat-column-actionPlan');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async searchInput(): Promise<WebdriverIO.Element> {
const ele = await $('#searchInput');
await ele.waitForDisplayed({ timeout: 40000 });
// ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async saveEditBtn(): Promise<WebdriverIO.Element> {
const ele = await $('#saveEditBtn');
await ele.waitForDisplayed({ timeout: 40000 });
// ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async cancelEditBtn(): Promise<WebdriverIO.Element> {
const ele = await $('#cancelEditBtn');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async toBeSolvedByEdit(): Promise<WebdriverIO.Element> {
const ele = await $('#toBeSolvedByEdit');
await ele.waitForDisplayed({ timeout: 40000 });
// ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async statusEdit(): Promise<WebdriverIO.Element> {
const ele = await $('#statusEdit');
// ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async workflowCaseDeleteDeleteBtn(): Promise<WebdriverIO.Element> {
const ele = await $('#workflowCaseDeleteDeleteBtn');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async workflowCaseDeleteCancelBtn(): Promise<WebdriverIO.Element> {
const ele = await $('#workflowCaseDeleteCancelBtn');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async workflowPnCases(): Promise<WebdriverIO.Element> {
const ele = await $('#workflow-pn-cases');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async workflowPn(): Promise<WebdriverIO.Element> {
const ele = await $('#workflow-pn');
await ele.waitForDisplayed({ timeout: 40000 });
await ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async deadlineFormInput(): Promise<WebdriverIO.Element> {
const ele = await $('#deadline');
await ele.waitForDisplayed({ timeout: 40000 });
// ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async dateOfIncidentFormInput(): Promise<WebdriverIO.Element> {
const ele = await $('#dateOfIncident');
await ele.waitForDisplayed({ timeout: 40000 });
// ele.waitForClickable({ timeout: 40000 });
return ele;
}
public async descriptionEdit(): Promise<WebdriverIO.Element> {
const ele = await $('#descriptionEdit');
await ele.waitForDisplayed({ timeout: 40000 });
// ele.waitForClickable({ timeout: 40000 });
// ele = $('#descriptionEdit .pell-content');
return ele;
}
public async actionPlanEdit(): Promise<WebdriverIO.Element> {
const ele = await $('#actionPlanEdit');
await ele.waitForDisplayed({ timeout: 40000 });
// ele.waitForClickable({ timeout: 40000 });
// ele = $('#actionPlanEdit .pell-content');
return ele;
}
public async goToWorkflowCasesPage() {
await (await this.workflowPn()).click();
await (await this.workflowPnCases()).click();
await (await $('#spinner-animation')).waitForDisplayed({ timeout: 90000, reverse: true });
await (await this.searchInput()).waitForClickable({ timeout: 90000 });
}
public async getFirstWorkflowCase(): Promise<WorkflowCaseRowObject> {
return this.getWorkflowCaseByNumber(1);
}
public async getWorkflowCaseByNumber(number: number): Promise<WorkflowCaseRowObject> {
const obj = new WorkflowCaseRowObject();
return await obj.getRow(number);
}
}
const workflowCasesPage = new WorkflowCasesPage();
export default workflowCasesPage;
export class WorkflowCaseRowObject {
constructor() {
}
public id: number;
public dateOfIncident: string;
// public updateAt: Date;
public incidentType: string;
public incidentPlace: string;
// public photo: boolean;
public description: string;
public deadline: string;
public actionPlan: string;
public toBeSolvedBy: string;
public status: string;
public menuBtn: WebdriverIO.Element;
public updateBtn: WebdriverIO.Element;
public deleteBtn: WebdriverIO.Element;
public static async closeEdit(clickCancel = false) {
if (!clickCancel) {
await (await workflowCasesPage.saveEditBtn()).click();
await (await $('#spinner-animation')).waitForDisplayed({
timeout: 90000,
reverse: true,
});
} else {
await (await workflowCasesPage.cancelEditBtn()).click();
}
await browser.pause(500);
await (await workflowCasesPage.searchInput()).waitForDisplayed();
await browser.pause(500);
}
public static async closeDelete(clickCancel = false) {
if (!clickCancel) {
await (await workflowCasesPage.workflowCaseDeleteDeleteBtn()).click();
await (await $('#spinner-animation')).waitForDisplayed({
timeout: 90000,
reverse: true,
});
} else {
await (await workflowCasesPage.workflowCaseDeleteCancelBtn()).click();
}
await browser.pause(500);
await (await workflowCasesPage.searchInput()).waitForDisplayed();
await browser.pause(500);
}
async getRow(rowNum: number): Promise<WorkflowCaseRowObject> {
const row = (await $$('table tr.mat-mdc-row'))[rowNum - 1];
rowNum = rowNum - 1;
if (row) {
this.id = +await (await $$('tbody > tr > td.mat-column-id'))[rowNum].getText();
let date = await (await $$('tbody > tr > td.mat-column-dateOfIncident'))[rowNum].getText();
this.dateOfIncident = date; // parse(date, 'dd.MM.yyyy HH:mm:ss', new Date());
// date = row.$('#workflowCaseUpdatedAt').getText();
// this.updateAt = parse(date, 'dd.MM.yyyy HH:mm:ss', new Date());
this.incidentType = await (await $$('tbody > tr > td.mat-column-incidentType'))[rowNum].getText();
this.incidentPlace = await (await $$('tbody > tr > td.mat-column-incidentPlace'))[rowNum].getText();
// this.photo = row.$('#workflowCasePhotosExists').getText() === 'true';
this.description = await (await $$('tbody > tr > td.mat-column-description'))[rowNum].getText();
//date =
this.deadline = await (await $$('tbody > tr > td.mat-column-deadline'))[rowNum].getText(); // parse(date, 'dd.MM.yyyy HH:mm:ss', new Date());
this.actionPlan = await (await $$('tbody > tr > td.mat-column-actionPlan'))[rowNum].getText();
this.toBeSolvedBy = await (await $$('tbody > tr > td.mat-column-solvedBy'))[rowNum].getText();
this.status = await (await $$('tbody > tr > td.mat-column-status'))[rowNum].getText();
this.menuBtn = await $(`#actionMenu-${rowNum}`);
this.updateBtn = await $(`#editWorkflowCaseBtn-${rowNum}`);
this.deleteBtn = await $(`#deleteBtn-${rowNum}`);
}
return this;
}
public async openDelete() {
await this.menuBtn.waitForClickable({ timeout: 20000 });
await this.menuBtn.click();
await browser.pause(500);
await this.deleteBtn.waitForClickable({ timeout: 20000 });
await this.deleteBtn.click();
await (await workflowCasesPage.workflowCaseDeleteCancelBtn()).waitForDisplayed({
timeout: 20000,
});
}
public async openEdit(updateModel: WorkflowCaseForEdit) {
await this.menuBtn.waitForClickable({ timeout: 20000 });
await this.menuBtn.click();
await browser.pause(500);
await this.updateBtn.waitForClickable({ timeout: 20000 });
await this.updateBtn.click();
await (await workflowCasesPage.cancelEditBtn()).waitForDisplayed({
timeout: 20000,
});
if (updateModel) {
const ngOption = await $('.ng-option-label');
if (updateModel.status) {
await (await workflowCasesPage.statusEdit()).$('input').setValue(updateModel.status);
// spinnerAnimation.waitForDisplayed({ timeout: 90000, reverse: true });
// ngOption.waitForDisplayed({ timeout: 20000 });
await browser.pause(1000);
const ele = await (
await $('ng-dropdown-panel')
).$(`.ng-option=${updateModel.status}`);
//const ele = await $(`//*[@id="statusEdit"]//*[text()="${updateModel.status}"]`);
await ele.waitForDisplayed({timeout: 20000});
await ele.click();
// workflowCasesPage.statusEdit
// .$('.ng-dropdown-panel')
// .$(`.ng-option-label`)
// .click();
}
// if (updateModel.toBeSolvedBy) {
// workflowCasesPage.toBeSolvedByEdit
// .$('input')
// .setValue(updateModel.toBeSolvedBy);
// spinnerAnimation.waitForDisplayed({ timeout: 90000, reverse: true });
// ngOption.waitForDisplayed({ timeout: 20000 });
// workflowCasesPage.toBeSolvedByEdit
// .$('.ng-dropdown-panel')
// .$(`.ng-option=${updateModel.toBeSolvedBy}`)
// .click();
// }
if (updateModel.deadline) {
await (await workflowCasesPage.deadlineFormInput()).click();
await selectDateOnDatePicker(updateModel.deadline.year, updateModel.deadline.month, updateModel.deadline.day);
}
if (updateModel.dateOfIncident) {
await (await workflowCasesPage.dateOfIncidentFormInput()).click();
await selectDateOnDatePicker(updateModel.dateOfIncident.year, updateModel.dateOfIncident.month, updateModel.dateOfIncident.day);
}
if (updateModel.description) {
await (await workflowCasesPage.descriptionEdit()).setValue(updateModel.description);
}
if (updateModel.actionPlan) {
await (await workflowCasesPage.actionPlanEdit()).setValue(updateModel.actionPlan);
}
}
}
async update(updateModel: WorkflowCaseForEdit, clickCancel = false) {
await this.openEdit(updateModel);
await WorkflowCaseRowObject.closeEdit(clickCancel);
}
async delete(clickCancel = false) {
await this.openDelete();
await WorkflowCaseRowObject.closeDelete(clickCancel);
}
}
export class WorkflowCaseForEdit {
public dateOfIncident: {
year: number;
month: number;
day: number;
};
// public incidentPlace: string;
public description: string;
public deadline: {
year: number;
month: number;
day: number;
};
public actionPlan: string;
// public toBeSolvedBy: string;
public status: string;
}