d5-testing-library 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FormEdit-MZJH5R5H.mjs +7 -0
- package/dist/ListForm-HDVXB6CG.mjs +7 -0
- package/dist/TreeView-DE5RBMDD.mjs +8 -0
- package/dist/chunk-44JIUIEW.mjs +17 -0
- package/dist/chunk-FP26UOTI.mjs +66 -0
- package/dist/chunk-NWWYF43G.mjs +656 -0
- package/dist/chunk-VWNH6HVN.mjs +1106 -0
- package/dist/cjs/d5-testing-library.cjs +2258 -1607
- package/dist/d5-testing-library.d.ts +62 -48
- package/dist/d5-testing-library.legacy-esm.js +37 -1697
- package/dist/d5-testing-library.mjs +37 -1697
- package/package.json +1 -1
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbstractButton,
|
|
3
|
+
AbstractEditor,
|
|
4
|
+
AbstractElement,
|
|
5
|
+
AbstractElementWithParent,
|
|
6
|
+
Form,
|
|
7
|
+
FormField,
|
|
8
|
+
byTestId,
|
|
9
|
+
byTestIdCssSelector,
|
|
10
|
+
click,
|
|
11
|
+
createDocFilterTestId,
|
|
12
|
+
createLayoutFilterTestId,
|
|
13
|
+
createTableId,
|
|
14
|
+
fixElementStaleError,
|
|
15
|
+
wait,
|
|
16
|
+
waitElementIsClickable
|
|
17
|
+
} from "./chunk-VWNH6HVN.mjs";
|
|
18
|
+
|
|
19
|
+
// src/pageObjects/elements/Table/Table.ts
|
|
20
|
+
import { By as By5 } from "selenium-webdriver";
|
|
21
|
+
|
|
22
|
+
// src/pageObjects/elements/Table/elements/Row.ts
|
|
23
|
+
import { By as By3 } from "selenium-webdriver";
|
|
24
|
+
|
|
25
|
+
// src/pageObjects/elements/Table/elements/Cell.ts
|
|
26
|
+
import { By as By2 } from "selenium-webdriver";
|
|
27
|
+
|
|
28
|
+
// src/pageObjects/elements/Table/utils.ts
|
|
29
|
+
import { By } from "selenium-webdriver";
|
|
30
|
+
function getCssRowByIndexSelector(index) {
|
|
31
|
+
return `tr[aria-rowindex="${transformInputIndex(index)}"]`;
|
|
32
|
+
}
|
|
33
|
+
var getColumnByIndexCssSelector = (columnIndex) => `td[aria-colindex="${transformInputIndex(columnIndex)}"]`;
|
|
34
|
+
var getColumnByCaptionCssSelector = (caption) => `td[role="columnheader"][aria-label="Column ${caption}"]`;
|
|
35
|
+
var getColumnByNameCssSelector = (name) => `td[role="columnheader"][data-fieldname="${name}"]`;
|
|
36
|
+
function getCssCellByIndexSelector(index) {
|
|
37
|
+
return `td[role="gridcell"][aria-colindex="${transformInputIndex(index)}"]`;
|
|
38
|
+
}
|
|
39
|
+
var transformInputIndex = (index) => index + 1;
|
|
40
|
+
var transformOutputIndex = (index) => +index - 1;
|
|
41
|
+
|
|
42
|
+
// src/pageObjects/elements/Table/elements/Cell.ts
|
|
43
|
+
var Cell = class extends AbstractElementWithParent {
|
|
44
|
+
_index;
|
|
45
|
+
getCellIndex;
|
|
46
|
+
constructor(parentCssSelector, getCellIndex, index, driver) {
|
|
47
|
+
super(parentCssSelector, getCssCellByIndexSelector(index), driver);
|
|
48
|
+
this.getCellIndex = getCellIndex;
|
|
49
|
+
this._index = index;
|
|
50
|
+
}
|
|
51
|
+
set index(index) {
|
|
52
|
+
this._index = index;
|
|
53
|
+
this.elementCssSelector = getCssCellByIndexSelector(index);
|
|
54
|
+
}
|
|
55
|
+
async getBooleanValue(cellEl) {
|
|
56
|
+
const booleanEl = await cellEl.findElement(By2.className("boolean-widget"));
|
|
57
|
+
return await booleanEl.getAttribute("aria-checked") === "true" ? 1 : 0;
|
|
58
|
+
}
|
|
59
|
+
async getTagsValue(cellEl) {
|
|
60
|
+
const tagsCssSelector = ".multiselect-container .multiselect-cell";
|
|
61
|
+
const tags = await cellEl.findElements(By2.css(tagsCssSelector));
|
|
62
|
+
const values = [];
|
|
63
|
+
for (const tag of tags) {
|
|
64
|
+
values.push(await tag.getAttribute("textContent"));
|
|
65
|
+
}
|
|
66
|
+
return values;
|
|
67
|
+
}
|
|
68
|
+
async getElement() {
|
|
69
|
+
if (this._index == null) {
|
|
70
|
+
this.index = await this.getCellIndex();
|
|
71
|
+
}
|
|
72
|
+
return super.getElement();
|
|
73
|
+
}
|
|
74
|
+
async getValue() {
|
|
75
|
+
const cellEl = await this.getElement();
|
|
76
|
+
const cellElClass = await cellEl.getAttribute("class");
|
|
77
|
+
if (cellElClass.includes("boolean-column" /* Boolean */))
|
|
78
|
+
return this.getBooleanValue(cellEl);
|
|
79
|
+
if (cellElClass.includes("tags-column" /* Tags */))
|
|
80
|
+
return this.getTagsValue(cellEl);
|
|
81
|
+
return cellEl.getText();
|
|
82
|
+
}
|
|
83
|
+
getIndex() {
|
|
84
|
+
return this._index;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/pageObjects/elements/Table/elements/Row.ts
|
|
89
|
+
var DX_SELECTION_CLASS = "dx-selection";
|
|
90
|
+
var DX_ROW_EDIT_CLASS = "dx-edit-row";
|
|
91
|
+
var DX_DATA_ROW_CLASS = "dx-data-row";
|
|
92
|
+
var Row = class extends AbstractElementWithParent {
|
|
93
|
+
index;
|
|
94
|
+
getColumnBy;
|
|
95
|
+
constructor(parentCssSelector, index, driver, getColumnBy) {
|
|
96
|
+
super(parentCssSelector, getCssRowByIndexSelector(index), driver);
|
|
97
|
+
this.index = index;
|
|
98
|
+
this.getColumnBy = getColumnBy;
|
|
99
|
+
}
|
|
100
|
+
_getCell({ index, name, title }) {
|
|
101
|
+
return new Cell(
|
|
102
|
+
this.getFullCssSelector(),
|
|
103
|
+
() => {
|
|
104
|
+
return this.getColumnBy({ title, name }).getIndex();
|
|
105
|
+
},
|
|
106
|
+
index,
|
|
107
|
+
this.driver
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
getCellByIndex(index) {
|
|
111
|
+
return this._getCell({ index });
|
|
112
|
+
}
|
|
113
|
+
getCell(name) {
|
|
114
|
+
return this._getCell({ name });
|
|
115
|
+
}
|
|
116
|
+
getCellByTitle(title) {
|
|
117
|
+
return this._getCell({ title });
|
|
118
|
+
}
|
|
119
|
+
async select() {
|
|
120
|
+
const rowEl = await this.getElement();
|
|
121
|
+
await click(rowEl, this.driver);
|
|
122
|
+
await wait(
|
|
123
|
+
async () => {
|
|
124
|
+
const classes = await this.getClasses();
|
|
125
|
+
return classes.includes(DX_SELECTION_CLASS);
|
|
126
|
+
},
|
|
127
|
+
this.driver,
|
|
128
|
+
"Cannot select row"
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
async isSelected() {
|
|
132
|
+
const result = await this.getAttribute("aria-selected");
|
|
133
|
+
return result === "true";
|
|
134
|
+
}
|
|
135
|
+
getIndex() {
|
|
136
|
+
return this.index;
|
|
137
|
+
}
|
|
138
|
+
async getCells() {
|
|
139
|
+
const cells = await this.driver.findElements(By3.css(`${this.getFullCssSelector()} td[role="gridcell"]`));
|
|
140
|
+
const result = [];
|
|
141
|
+
cells.forEach((_, index) => {
|
|
142
|
+
const newCell = this.getCellByIndex(index);
|
|
143
|
+
result.push(newCell);
|
|
144
|
+
});
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
async clickInlineButton(buttonClass) {
|
|
148
|
+
const FIXED_TABLE_CSS_SELECTOR = ".dx-fixed-columns .dx-datagrid-content.dx-datagrid-content-fixed";
|
|
149
|
+
const buttonCssSelector = `.${DX_DATA_ROW_CLASS}[aria-rowindex="${transformInputIndex(
|
|
150
|
+
this.index
|
|
151
|
+
)}"] .${buttonClass}`;
|
|
152
|
+
const button = await this.driver.findElement(
|
|
153
|
+
By3.css(`${this.parentCssSelector} ${FIXED_TABLE_CSS_SELECTOR} ${buttonCssSelector}`)
|
|
154
|
+
);
|
|
155
|
+
return click(button, this.driver);
|
|
156
|
+
}
|
|
157
|
+
async checkEditingMode(isEditing, msg) {
|
|
158
|
+
await wait(
|
|
159
|
+
async () => {
|
|
160
|
+
return (await this.getClasses()).includes(DX_ROW_EDIT_CLASS) === isEditing;
|
|
161
|
+
},
|
|
162
|
+
this.driver,
|
|
163
|
+
msg
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
async edit() {
|
|
167
|
+
await this.clickInlineButton("edit");
|
|
168
|
+
await this.checkEditingMode(true, "Row did not switch to edit mode");
|
|
169
|
+
}
|
|
170
|
+
async save() {
|
|
171
|
+
await this.clickInlineButton("save");
|
|
172
|
+
await this.checkEditingMode(false, "Row did not saved");
|
|
173
|
+
}
|
|
174
|
+
async cancel() {
|
|
175
|
+
await this.clickInlineButton("cancel");
|
|
176
|
+
await this.checkEditingMode(false, "Row did not switch to normal mode");
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// src/pageObjects/elements/Table/elements/Column.ts
|
|
181
|
+
import { By as By4 } from "selenium-webdriver";
|
|
182
|
+
var Column = class extends AbstractElementWithParent {
|
|
183
|
+
_index;
|
|
184
|
+
_caption;
|
|
185
|
+
_name;
|
|
186
|
+
headerCssSelector;
|
|
187
|
+
constructor({ parentCssSelector, headerCssSelector, name, caption, index, driver }) {
|
|
188
|
+
super(parentCssSelector, "", driver);
|
|
189
|
+
this._name = name;
|
|
190
|
+
this.index = index;
|
|
191
|
+
this._caption = caption;
|
|
192
|
+
this.headerCssSelector = headerCssSelector;
|
|
193
|
+
}
|
|
194
|
+
set index(index) {
|
|
195
|
+
this._index = index;
|
|
196
|
+
this.elementCssSelector = getColumnByIndexCssSelector(index);
|
|
197
|
+
}
|
|
198
|
+
get index() {
|
|
199
|
+
return this._index;
|
|
200
|
+
}
|
|
201
|
+
async getElement() {
|
|
202
|
+
await this.getIndex();
|
|
203
|
+
return super.getElement();
|
|
204
|
+
}
|
|
205
|
+
async getColumnHeaderIndexBy(cssSelector) {
|
|
206
|
+
const column = await fixElementStaleError(By4.css(`${this.parentCssSelector} ${this.headerCssSelector} ${cssSelector}`), this.driver);
|
|
207
|
+
return transformOutputIndex(await column.getAttribute("aria-colindex"));
|
|
208
|
+
}
|
|
209
|
+
async getIndexByCaption() {
|
|
210
|
+
return this.getColumnHeaderIndexBy(getColumnByCaptionCssSelector(this._caption));
|
|
211
|
+
}
|
|
212
|
+
async getIndexByName() {
|
|
213
|
+
return this.getColumnHeaderIndexBy(getColumnByNameCssSelector(this._name));
|
|
214
|
+
}
|
|
215
|
+
async caption() {
|
|
216
|
+
const el = await this.getElement();
|
|
217
|
+
return el.getText();
|
|
218
|
+
}
|
|
219
|
+
async getIndex() {
|
|
220
|
+
if (this.index != null) {
|
|
221
|
+
return this.index;
|
|
222
|
+
}
|
|
223
|
+
if (this._caption != null) {
|
|
224
|
+
this.index = await this.getIndexByCaption();
|
|
225
|
+
return this.index;
|
|
226
|
+
}
|
|
227
|
+
if (this._name != null) {
|
|
228
|
+
this.index = await this.getIndexByName();
|
|
229
|
+
return this.index;
|
|
230
|
+
}
|
|
231
|
+
throw new Error("Cant get the index in the column");
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// src/pageObjects/elements/Table/Table.ts
|
|
236
|
+
var Table = class extends AbstractElementWithParent {
|
|
237
|
+
formName;
|
|
238
|
+
headerCssSelector;
|
|
239
|
+
constructor(parentCssSelector, headerCssSelector, formName, driver) {
|
|
240
|
+
super(parentCssSelector, `#${createTableId(formName)}`, driver);
|
|
241
|
+
this.formName = formName;
|
|
242
|
+
this.headerCssSelector = headerCssSelector;
|
|
243
|
+
}
|
|
244
|
+
getColumnBy = (args) => {
|
|
245
|
+
if (args.title) {
|
|
246
|
+
return this.getColumnByTitle(args.title);
|
|
247
|
+
}
|
|
248
|
+
return this.getColumnByName(args.name);
|
|
249
|
+
};
|
|
250
|
+
getRowByIndex(index) {
|
|
251
|
+
return new Row(this.getFullCssSelector(), index, this.driver, this.getColumnBy);
|
|
252
|
+
}
|
|
253
|
+
getColumnByIndex(index) {
|
|
254
|
+
return new Column({
|
|
255
|
+
parentCssSelector: this.getFullCssSelector(),
|
|
256
|
+
driver: this.driver,
|
|
257
|
+
index
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
getColumnByTitle = (title) => {
|
|
261
|
+
return new Column({
|
|
262
|
+
parentCssSelector: this.getFullCssSelector(),
|
|
263
|
+
headerCssSelector: this.headerCssSelector,
|
|
264
|
+
caption: title,
|
|
265
|
+
driver: this.driver
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
getColumnByName = (name) => {
|
|
269
|
+
return new Column({
|
|
270
|
+
parentCssSelector: this.getFullCssSelector(),
|
|
271
|
+
headerCssSelector: this.headerCssSelector,
|
|
272
|
+
name,
|
|
273
|
+
driver: this.driver
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
selectRowByIndex(index) {
|
|
277
|
+
return this.getRowByIndex(index).select();
|
|
278
|
+
}
|
|
279
|
+
async getRows() {
|
|
280
|
+
const rows = await this.driver.findElements(By5.css(`${this.getFullCssSelector()} .dx-row.dx-data-row`));
|
|
281
|
+
const result = [];
|
|
282
|
+
rows.forEach((_, index) => {
|
|
283
|
+
const newRow = new Row(this.getFullCssSelector(), index, this.driver, this.getColumnBy);
|
|
284
|
+
result.push(newRow);
|
|
285
|
+
});
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
async getColumns() {
|
|
289
|
+
const columns = await this.driver.findElements(
|
|
290
|
+
By5.css(`${this.getFullCssSelector()} ${this.headerCssSelector} td[role="columnheader"]`)
|
|
291
|
+
);
|
|
292
|
+
const result = [];
|
|
293
|
+
columns.forEach((_, index) => {
|
|
294
|
+
const newCol = new Column({
|
|
295
|
+
parentCssSelector: this.getFullCssSelector(),
|
|
296
|
+
index,
|
|
297
|
+
driver: this.driver
|
|
298
|
+
});
|
|
299
|
+
result.push(newCol);
|
|
300
|
+
});
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
element() {
|
|
304
|
+
return this.getElement();
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Находит поле когда форма находится в состоянии редактирования
|
|
308
|
+
* @example
|
|
309
|
+
* const form = new MyForm();
|
|
310
|
+
* //...
|
|
311
|
+
* expect(await form.field('Name').getValue()).toBe('test value');
|
|
312
|
+
*/
|
|
313
|
+
field(name) {
|
|
314
|
+
return new FormField(this.getFullCssSelector(), this.formName, name, this.driver);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
// src/pageObjects/elements/TableToolbar/ToolbarGroupButton.ts
|
|
319
|
+
var ToolbarGroupButton = class extends AbstractButton {
|
|
320
|
+
name;
|
|
321
|
+
constructor(parentCssSelector, name, driver) {
|
|
322
|
+
super(parentCssSelector, ``, driver);
|
|
323
|
+
this.name = name;
|
|
324
|
+
}
|
|
325
|
+
buttonNotDisplayedError() {
|
|
326
|
+
return `Button ${this.name} cannot be clicked. It is not displayed or it is disabled`;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// src/pageObjects/elements/TableToolbar/ToolbarButton.ts
|
|
331
|
+
var TOOLBAR_BUTTON_CLASS = "toolbar-button";
|
|
332
|
+
var ToolbarButton = class extends AbstractButton {
|
|
333
|
+
name;
|
|
334
|
+
constructor(parentCssSelector, name, driver) {
|
|
335
|
+
super(parentCssSelector, `#${TOOLBAR_BUTTON_CLASS}-${name}`, driver);
|
|
336
|
+
this.name = name;
|
|
337
|
+
}
|
|
338
|
+
buttonNotDisplayedError() {
|
|
339
|
+
return `Button ${this.name} cannot be clicked. It is not displayed or it is disabled`;
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
// src/pageObjects/elements/TableToolbar/ToolbarMenu.ts
|
|
344
|
+
import { By as By6 } from "selenium-webdriver";
|
|
345
|
+
|
|
346
|
+
// src/utils/typesUtil.ts
|
|
347
|
+
var types = {
|
|
348
|
+
"[object Array]": "array",
|
|
349
|
+
"[object Date]": "date",
|
|
350
|
+
"[object Object]": "object",
|
|
351
|
+
"[object String]": "string",
|
|
352
|
+
"[object Null]": "null"
|
|
353
|
+
};
|
|
354
|
+
var type = function(object) {
|
|
355
|
+
const typeOfObject = Object.prototype.toString.call(object);
|
|
356
|
+
return typeof object === "object" ? types[typeOfObject] || "object" : typeof object;
|
|
357
|
+
};
|
|
358
|
+
var isArray = function(value) {
|
|
359
|
+
return type(value) === "array";
|
|
360
|
+
};
|
|
361
|
+
var isString = function(object) {
|
|
362
|
+
return typeof object === "string";
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
// src/pageObjects/elements/TableToolbar/ToolbarMenu.ts
|
|
366
|
+
var SPINDOWN_CLASS = ".dx-icon-spindown";
|
|
367
|
+
var buttonGroupItemSelector = (formName, name) => byTestIdCssSelector(`ftb-${formName}-${name}`);
|
|
368
|
+
var getFullCssSelector = (formName, name) => `${buttonGroupItemSelector(formName, name)} ${SPINDOWN_CLASS}`;
|
|
369
|
+
var buttonByTextXpath = (text) => `.//span[contains(@class, "dx-menu-item-text") and contains(text(), "${text}")]`;
|
|
370
|
+
var ToolbarMenu = class extends AbstractElementWithParent {
|
|
371
|
+
_formName;
|
|
372
|
+
constructor(parentCssSelector, formName, name, driver) {
|
|
373
|
+
super(parentCssSelector, getFullCssSelector(formName, name), driver);
|
|
374
|
+
this._formName = formName;
|
|
375
|
+
}
|
|
376
|
+
async openDropdownMenu() {
|
|
377
|
+
const dropdown = await this.getElement();
|
|
378
|
+
await click(dropdown, this.driver);
|
|
379
|
+
}
|
|
380
|
+
getCssSelectorToButton(name) {
|
|
381
|
+
return byTestId(`ftb-${this._formName}-${name}`);
|
|
382
|
+
}
|
|
383
|
+
buttonNotDisplayedError(name) {
|
|
384
|
+
return `Toolbar menu button ${name} cannot be clicked. It is not displayed or it is disabled`;
|
|
385
|
+
}
|
|
386
|
+
async goToButton(name, by) {
|
|
387
|
+
const toolbarMenuItem = await fixElementStaleError(by, this.driver);
|
|
388
|
+
await waitElementIsClickable({
|
|
389
|
+
element: toolbarMenuItem,
|
|
390
|
+
errorMessage: this.buttonNotDisplayedError(name),
|
|
391
|
+
driver: this.driver
|
|
392
|
+
});
|
|
393
|
+
await click(toolbarMenuItem, this.driver);
|
|
394
|
+
}
|
|
395
|
+
async clickButton(name) {
|
|
396
|
+
await this.openDropdownMenu();
|
|
397
|
+
if (!isString(name) && !isArray(name))
|
|
398
|
+
throw new Error(`"name" must be a string or array of string`);
|
|
399
|
+
let lName = isString(name) ? [name] : name;
|
|
400
|
+
for (let n of lName) {
|
|
401
|
+
await this.goToButton(n, this.getCssSelectorToButton(n));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
async clickButtonByTitle(title) {
|
|
405
|
+
await this.openDropdownMenu();
|
|
406
|
+
if (!isString(title) && !isArray(title))
|
|
407
|
+
throw new Error(`"title" must be a string or array of string`);
|
|
408
|
+
let lTitle = isString(title) ? [title] : title;
|
|
409
|
+
for (let t of lTitle) {
|
|
410
|
+
await this.goToButton(t, By6.xpath(buttonByTextXpath(t)));
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
// src/pageObjects/elements/TableToolbar/ToolbarItem.ts
|
|
416
|
+
var GROUP_BUTTON_CLASS = "toolbar-group-button";
|
|
417
|
+
var toolbarItemSelector = (form, name) => byTestIdCssSelector(`ftb-${form}-${name}`);
|
|
418
|
+
var ToolbarItem = class extends AbstractElementWithParent {
|
|
419
|
+
_button;
|
|
420
|
+
_formName;
|
|
421
|
+
_itemName;
|
|
422
|
+
constructor(parentCssSelector, formName, itemName, driver) {
|
|
423
|
+
super(parentCssSelector, toolbarItemSelector(formName, itemName), driver);
|
|
424
|
+
this._itemName = itemName;
|
|
425
|
+
this._formName = formName;
|
|
426
|
+
}
|
|
427
|
+
async init() {
|
|
428
|
+
if (this._button)
|
|
429
|
+
return this._button;
|
|
430
|
+
const classNames = await this.getClasses();
|
|
431
|
+
if (classNames.includes(GROUP_BUTTON_CLASS)) {
|
|
432
|
+
this._button = new ToolbarGroupButton(this.getFullCssSelector(), this._itemName, this.driver);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
this._button = new ToolbarButton(this.parentCssSelector, this._itemName, this.driver);
|
|
436
|
+
}
|
|
437
|
+
async click() {
|
|
438
|
+
await this.init();
|
|
439
|
+
await this._button.click();
|
|
440
|
+
}
|
|
441
|
+
async isDisabled() {
|
|
442
|
+
await this.init();
|
|
443
|
+
return await this._button.isDisabled();
|
|
444
|
+
}
|
|
445
|
+
get menu() {
|
|
446
|
+
return new ToolbarMenu(this.parentCssSelector, this._formName, this._itemName, this.driver);
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
// src/pageObjects/elements/TableToolbar/FormToolbar.ts
|
|
451
|
+
var TABLE_TOOLBAR_CLASS = "d5-table-toolbar";
|
|
452
|
+
var FormToolbar = class extends AbstractElementWithParent {
|
|
453
|
+
formName;
|
|
454
|
+
constructor(parentCssSelector, formName, driver) {
|
|
455
|
+
super(parentCssSelector, `#${TABLE_TOOLBAR_CLASS}-${formName}`, driver);
|
|
456
|
+
this.formName = formName;
|
|
457
|
+
}
|
|
458
|
+
button(name) {
|
|
459
|
+
return new ToolbarItem(this.getFullCssSelector(), this.formName, name, this.driver);
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
// src/pageObjects/elements/Filters/FormFilterField.ts
|
|
464
|
+
var FormFilterField = class extends AbstractEditor {
|
|
465
|
+
constructor(parentCssSelector, formName, name, driver) {
|
|
466
|
+
super(parentCssSelector, byTestIdCssSelector(createLayoutFilterTestId(formName, name)), driver);
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Возвращает значение в поле
|
|
470
|
+
* @example
|
|
471
|
+
* expect(await form.formFilter('NumberFld').getValue()).toBe(10);
|
|
472
|
+
* expect(await form.formFilter('TextFld').getValue()).toBe('TestValue');
|
|
473
|
+
*/
|
|
474
|
+
async getValue() {
|
|
475
|
+
return super.getValue();
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Устанавливает значение в поле
|
|
479
|
+
* @example
|
|
480
|
+
* await form.formFilter('NumberFld').setValue(123);
|
|
481
|
+
* await form.formFilter('TextFld').setValue('TestValue');
|
|
482
|
+
*/
|
|
483
|
+
async setValue(value) {
|
|
484
|
+
return super.setValue(value);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Очищает значение в поле
|
|
488
|
+
* @example
|
|
489
|
+
* await form.formFilter('NumberFld').clear();
|
|
490
|
+
*/
|
|
491
|
+
async clear() {
|
|
492
|
+
return super.clear();
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Удаляет тег по переданному тексту
|
|
496
|
+
* @example
|
|
497
|
+
* await form.formFilter('TagBox').remove('test');
|
|
498
|
+
*/
|
|
499
|
+
async remove(itemText) {
|
|
500
|
+
return super.remove(itemText);
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
// src/pageObjects/elements/Filters/FilterPanel.ts
|
|
505
|
+
import { By as By7 } from "selenium-webdriver";
|
|
506
|
+
|
|
507
|
+
// src/pageObjects/elements/Filters/PanelFilterField.ts
|
|
508
|
+
var PanelFilterField = class extends AbstractEditor {
|
|
509
|
+
constructor(parentCssSelector, formName, name, driver) {
|
|
510
|
+
super(parentCssSelector, byTestIdCssSelector(createDocFilterTestId(formName, name)), driver);
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Возвращает значение в поле
|
|
514
|
+
* @example
|
|
515
|
+
* expect(await form.filterPanel.filterField('NumberFld').getValue()).toBe(10);
|
|
516
|
+
* expect(await form.filterPanel.filterField('TextFld').getValue()).toBe('TestValue');
|
|
517
|
+
*/
|
|
518
|
+
async getValue() {
|
|
519
|
+
return super.getValue();
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Устанавливает значение в поле
|
|
523
|
+
* @example
|
|
524
|
+
* await form.filterPanel.filterField('NumberFld').setValue(123);
|
|
525
|
+
* await form.filterPanel.filterField('TextFld').setValue('TestValue');
|
|
526
|
+
*/
|
|
527
|
+
async setValue(value) {
|
|
528
|
+
return super.setValue(value);
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Очищает значение в поле
|
|
532
|
+
* @example
|
|
533
|
+
* await form.filterPanel.filterField('NumberFld').clear();
|
|
534
|
+
*/
|
|
535
|
+
async clear() {
|
|
536
|
+
return super.clear();
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Удаляет тег по переданному тексту
|
|
540
|
+
* @example
|
|
541
|
+
* await form.filterPanel.filterField('TagBox').remove('test');
|
|
542
|
+
*/
|
|
543
|
+
async remove(itemText) {
|
|
544
|
+
return super.remove(itemText);
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
// src/pageObjects/elements/Filters/FilterPanel.ts
|
|
549
|
+
var drawerSelector = (formName) => `.secondary-drawer-side-panel.form-${formName}`;
|
|
550
|
+
var FILTER_PANEL_SELECTOR = ".filter-panel";
|
|
551
|
+
var CLOSE_SELECTOR = ".button-close";
|
|
552
|
+
var FilterPanel = class extends AbstractElement {
|
|
553
|
+
_formName;
|
|
554
|
+
get filterPanelSelector() {
|
|
555
|
+
return `${this.elementCssSelector} ${FILTER_PANEL_SELECTOR}`;
|
|
556
|
+
}
|
|
557
|
+
async filterPanelButtons() {
|
|
558
|
+
const selector = `${this.elementCssSelector} ${FILTER_PANEL_SELECTOR} .filter-panel__buttons-panel .dx-button-text`;
|
|
559
|
+
const el = await this.getElement();
|
|
560
|
+
return el.findElements(By7.css(selector));
|
|
561
|
+
}
|
|
562
|
+
constructor(formName, driver) {
|
|
563
|
+
super(driver, drawerSelector(formName));
|
|
564
|
+
this._formName = formName;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Возвращает фильтр на панели фильтрации
|
|
568
|
+
* @returns {PanelFilterField}
|
|
569
|
+
* @example
|
|
570
|
+
* await form.filterPanel.filterField('NumberFld');
|
|
571
|
+
*/
|
|
572
|
+
filterField(name) {
|
|
573
|
+
return new PanelFilterField(this.filterPanelSelector, this._formName, name, this.driver);
|
|
574
|
+
}
|
|
575
|
+
async apply() {
|
|
576
|
+
const btn = await this.findButtonByTitle("\u0417\u0430\u0441\u0442\u043E\u0441\u0443\u0432\u0430\u0442\u0438");
|
|
577
|
+
await click(btn, this.driver);
|
|
578
|
+
}
|
|
579
|
+
async findButtonByTitle(title) {
|
|
580
|
+
const buttons = await this.filterPanelButtons();
|
|
581
|
+
for (const btn of buttons) {
|
|
582
|
+
if (await btn.getText() === title) {
|
|
583
|
+
return btn;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
async clearAll() {
|
|
588
|
+
const btn = await this.findButtonByTitle("\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u0438");
|
|
589
|
+
await click(btn, this.driver);
|
|
590
|
+
await this.driver.sleep(300);
|
|
591
|
+
}
|
|
592
|
+
async close() {
|
|
593
|
+
const btn = await this.driver.findElement(By7.css(`${this.elementCssSelector} ${CLOSE_SELECTOR}`));
|
|
594
|
+
await click(btn, this.driver);
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
// src/pageObjects/elements/Forms/ListForm.ts
|
|
599
|
+
var DATAGRID_HEADER_CSS_SELECTOR = ".dx-datagrid-headers .dx-datagrid-content:not(.dx-datagrid-content-fixed)";
|
|
600
|
+
var ListForm = class extends Form {
|
|
601
|
+
headerCssSelector;
|
|
602
|
+
constructor(driver) {
|
|
603
|
+
super(driver);
|
|
604
|
+
this.popupContainerCssSelector = `.popup .form-inline-${this.formName}`;
|
|
605
|
+
this.headerCssSelector = DATAGRID_HEADER_CSS_SELECTOR;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Находит таблицу
|
|
609
|
+
* @example
|
|
610
|
+
* const listForm = new MyForm();
|
|
611
|
+
* //...
|
|
612
|
+
* expect(listForm.table());
|
|
613
|
+
*/
|
|
614
|
+
table() {
|
|
615
|
+
return new Table(this.containerCssSelector, this.headerCssSelector, this.formName, this.driver);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Находит таблицу
|
|
619
|
+
* @example
|
|
620
|
+
* const listForm = new MyForm();
|
|
621
|
+
* //...
|
|
622
|
+
* expect(listForm.toolbarButton());
|
|
623
|
+
*/
|
|
624
|
+
toolbarButton(name) {
|
|
625
|
+
const toolbar = new FormToolbar(this.containerCssSelector, this.formName, this.driver);
|
|
626
|
+
return toolbar.button(name);
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Фильтр который расположен на форме
|
|
630
|
+
* @example
|
|
631
|
+
* const listForm = new MyForm();
|
|
632
|
+
* //...
|
|
633
|
+
* expect(listForm.formFilter());
|
|
634
|
+
*/
|
|
635
|
+
formFilter(name) {
|
|
636
|
+
return new FormFilterField(this.containerCssSelector, this.formName, name, this.driver);
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Модель панели фильтрации
|
|
640
|
+
* @returns {FilterPanel}
|
|
641
|
+
* @example
|
|
642
|
+
* const listForm = new MyForm();
|
|
643
|
+
* //...
|
|
644
|
+
* expect(listForm.filterPanel());
|
|
645
|
+
*/
|
|
646
|
+
get filterPanel() {
|
|
647
|
+
return new FilterPanel(this.formName, this.driver);
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
export {
|
|
652
|
+
FormFilterField,
|
|
653
|
+
PanelFilterField,
|
|
654
|
+
FilterPanel,
|
|
655
|
+
ListForm
|
|
656
|
+
};
|