d5-testing-library 1.3.1 → 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.
@@ -1,146 +1,33 @@
1
- // src/config.ts
2
- import * as process from "node:process";
3
- var driversMap = /* @__PURE__ */ new Map();
4
- var createConfigProxy = (config2) => {
5
- return new Proxy(config2, {
6
- get(_target, prop) {
7
- if (prop === "driver") {
8
- return driversMap.get(process.pid);
9
- }
10
- return Reflect.get(...arguments);
11
- },
12
- set(_target, prop, value) {
13
- if (prop === "driver") {
14
- driversMap.set(process.pid, value);
15
- return true;
16
- }
17
- return Reflect.set(...arguments);
18
- }
19
- });
20
- };
21
- var Config = class _Config {
22
- static instance;
23
- appConfig;
24
- static getInstance() {
25
- if (!_Config.instance) {
26
- _Config.instance = new _Config();
27
- }
28
- return _Config.instance;
29
- }
30
- config = (cfg) => {
31
- if (!cfg)
32
- return createConfigProxy(this.appConfig);
33
- this.appConfig = cfg;
34
- };
35
- };
36
- var configInstance = Config.getInstance();
37
- function config(cfg) {
38
- return configInstance.config(cfg);
39
- }
40
-
41
- // src/pageObjects/AbstractElement.ts
42
- import { By } from "selenium-webdriver";
43
-
44
- // src/utils/waitElementIsVisible.ts
45
- import { until } from "selenium-webdriver";
46
-
47
- // src/utils/wait.ts
48
- async function wait(condition, driver, errorMessage, timeout) {
49
- driver = driver ?? config().driver;
50
- await driver.wait(condition, timeout ?? config().timeout, errorMessage);
51
- }
52
-
53
- // src/utils/waitElementIsVisible.ts
54
- async function waitElementIsVisible({
55
- element,
56
- timeout,
57
- errorMessage,
58
- driver
59
- }) {
60
- driver = driver ?? config().driver;
61
- const condition = until.elementIsVisible(element);
62
- await wait(condition.fn, driver, errorMessage ?? condition.description(), timeout ?? config().timeout);
63
- }
64
-
65
- // src/pageObjects/AbstractElement.ts
66
- var AbstractElement = class {
67
- driver;
68
- elementCssSelector;
69
- constructor(driver, elementCssSelector) {
70
- this.driver = driver || config().driver;
71
- this.elementCssSelector = elementCssSelector;
72
- }
73
- getFullCssSelector() {
74
- return this.elementCssSelector;
75
- }
76
- joinRelativeCssSelectors(selectors) {
77
- return selectors.join(" ");
78
- }
79
- async getElement() {
80
- return this.driver.findElement(By.css(this.getFullCssSelector()));
81
- }
82
- async getAttribute(attr) {
83
- const element = await this.getElement();
84
- await waitElementIsVisible({
85
- element,
86
- driver: this.driver,
87
- errorMessage: `Element not found: ${this.getFullCssSelector()}`
88
- });
89
- return await element.getAttribute(attr);
90
- }
91
- async getClasses() {
92
- return await this.getAttribute("class");
93
- }
94
- async getDataTestId() {
95
- return await this.getAttribute("data-testid");
96
- }
97
- };
98
-
99
- // src/pageObjects/pages/AbstractPage.ts
100
- var AbstractPage = class extends AbstractElement {
101
- url;
102
- host;
103
- constructor(driver) {
104
- super(driver);
105
- this.host = config().auth.host;
106
- this.url = this.host + this.prependHash(this.path);
107
- }
108
- prependHash(urlPath) {
109
- if (!urlPath.startsWith("/#")) {
110
- return `/#${urlPath}`;
111
- }
112
- return urlPath;
113
- }
114
- async goToUrl(url) {
115
- await this.driver.get(url);
116
- }
117
- get path() {
118
- return "/#";
119
- }
120
- async locate() {
121
- await this.goToUrl(this.url);
122
- }
123
- async reloadPage() {
124
- await this.driver.navigate().refresh();
125
- }
126
- };
127
-
128
- // src/utils/actions.ts
129
- var click = async (webElement, driver) => {
130
- driver = driver ?? config().driver;
131
- const actions = driver.actions({ async: true });
132
- await actions.move({ origin: webElement }).click().perform();
133
- };
134
-
135
- // src/utils/locators.ts
136
- import { By as By2 } from "selenium-webdriver";
137
- var byTestIdCssSelector = (testId, element = "div") => {
138
- return `${element}[data-testid="${testId}"]`;
139
- };
140
- var byTestId = (testId, element = "div") => {
141
- return By2.css(byTestIdCssSelector(testId, element));
142
- };
143
- var readonlyLocator = "readonly";
1
+ import {
2
+ TreeView
3
+ } from "./chunk-44JIUIEW.mjs";
4
+ import {
5
+ FilterPanel,
6
+ FormFilterField,
7
+ ListForm,
8
+ PanelFilterField
9
+ } from "./chunk-NWWYF43G.mjs";
10
+ import {
11
+ FormEdit
12
+ } from "./chunk-FP26UOTI.mjs";
13
+ import {
14
+ AbstractButton,
15
+ AbstractElement,
16
+ AbstractElementWithParent,
17
+ AbstractPage,
18
+ ControlClass,
19
+ FormField,
20
+ NumberEditor,
21
+ TextEditor,
22
+ byTestId,
23
+ byTestIdCssSelector,
24
+ click,
25
+ config,
26
+ editorFactory,
27
+ readonlyLocator,
28
+ wait,
29
+ waitElementIsVisible
30
+ } from "./chunk-VWNH6HVN.mjs";
144
31
 
145
32
  // src/pageObjects/pages/LoginPage.ts
146
33
  var LOGIN_PATH = "/login";
@@ -207,34 +94,11 @@ async function signIn(driver) {
207
94
  return webDriver;
208
95
  }
209
96
 
210
- // src/pageObjects/AbstractElementWithParent.ts
211
- var AbstractElementWithParent = class extends AbstractElement {
212
- parentCssSelector;
213
- constructor(parentCssSelector, elementCssSelector, driver) {
214
- super(driver, elementCssSelector);
215
- this.parentCssSelector = parentCssSelector;
216
- }
217
- getFullCssSelector() {
218
- if (!this.elementCssSelector) {
219
- return this.parentCssSelector;
220
- }
221
- if (!this.parentCssSelector) {
222
- return this.elementCssSelector;
223
- }
224
- return `${this.parentCssSelector} ${this.elementCssSelector}`;
225
- }
226
- async isReadonly() {
227
- const fieldEl = await this.getElement();
228
- const classSting = await fieldEl.getAttribute("class");
229
- return classSting.includes(readonlyLocator);
230
- }
231
- };
232
-
233
97
  // src/pageObjects/elements/SubsystemsPanel/SubsystemsPanelHeader.ts
234
- import { By as By4 } from "selenium-webdriver";
98
+ import { By as By2 } from "selenium-webdriver";
235
99
  var SubsystemsPanelHeader = class extends AbstractElementWithParent {
236
100
  async title() {
237
- return this.driver.findElement(By4.css(this.getFullCssSelector()));
101
+ return this.driver.findElement(By2.css(this.getFullCssSelector()));
238
102
  }
239
103
  };
240
104
 
@@ -252,1280 +116,13 @@ var SubsystemsPanel = class extends AbstractElement {
252
116
  }
253
117
  };
254
118
 
255
- // src/pageObjects/elements/Forms/AbstractForm.ts
256
- import { By as By5 } from "selenium-webdriver";
257
- var AbstractForm = class extends AbstractPage {
258
- containerCssSelector = "";
259
- containerBy;
260
- popupContainerCssSelector;
261
- constructor(driver) {
262
- super(driver);
263
- const testId = `form-content-wrapper-${this.formName}`;
264
- this.containerBy = byTestId(testId);
265
- this.containerCssSelector = byTestIdCssSelector(testId);
266
- }
267
- async isModal() {
268
- const el = await this.getContainerElement();
269
- const value = await el.getAttribute("data-ismodal");
270
- return value === "true";
271
- }
272
- getContainerElement = () => {
273
- return this.driver.findElement(this.containerBy);
274
- };
275
- get formName() {
276
- return "";
277
- }
278
- /**
279
- * Возвращает true если форма есть в DOM
280
- * @example
281
- * class MyForm extends FormEdit {}
282
- * //...
283
- * const formEdit = new MyForm();
284
- * expect(await formEdit.exists()).toBe(true);
285
- */
286
- async exists() {
287
- try {
288
- let elements = await this.driver.findElements(this.containerBy);
289
- return elements.length > 0;
290
- } catch (error) {
291
- return false;
292
- }
293
- }
294
- /**
295
- * Получение заголовка на формы
296
- * @example
297
- * const listForm = new MyForm();
298
- * //...
299
- * expect(await listForm.getTitleText()).toBe('MyFormTitle');
300
- */
301
- async getTitleText() {
302
- if (await this.isModal()) {
303
- const titleEl2 = await this.driver.findElement(By5.css(`${this.popupContainerCssSelector} .popup-title`));
304
- return titleEl2.getText();
305
- }
306
- let titleEl = await this.driver.findElement(By5.className("main-toolbar-form-title"));
307
- return titleEl.getText();
308
- }
309
- };
310
-
311
- // src/pageObjects/elements/Forms/FormEdit.ts
312
- import { By as By12 } from "selenium-webdriver";
313
-
314
- // src/utils/createDataTestId.ts
315
- function createDataTestId(formName, itemType, itemName) {
316
- return `${formName}-${itemType}-${itemName}`;
317
- }
318
- function createFieldTestId(formName, itemName) {
319
- return createDataTestId(formName, "form_field" /* FORM_FIELD */, itemName);
320
- }
321
- function createGroupTestId(formName, itemName) {
322
- return createDataTestId(formName, "group" /* GROUP */, itemName);
323
- }
324
- function createFilterTestId(formName, itemName, layout) {
325
- return createDataTestId(formName, "filter" /* FILTER */, itemName) + `-${layout}`;
326
- }
327
- function createDocFilterTestId(formName, itemName) {
328
- return createFilterTestId(formName, itemName, "dock-panel-filter" /* DOCK_PANEL */);
329
- }
330
- function createLayoutFilterTestId(formName, itemName) {
331
- return createFilterTestId(formName, itemName, "layout-filter" /* LAYOUT */);
332
- }
333
- function createTableId(formName) {
334
- return `${"table" /* TABLE */}-${formName}`;
335
- }
336
-
337
- // src/pageObjects/elements/Editors/AbstractEditor.ts
338
- import { By as By6, Key } from "selenium-webdriver";
339
-
340
- // src/pageObjects/elements/Editors/ClearStrategy/InputClearStrategy.ts
341
- var InputClearStrategy = class {
342
- async clear(editor) {
343
- const inputEl = await editor.getInputElement();
344
- await inputEl.clear();
345
- }
346
- };
347
-
348
- // src/pageObjects/elements/Editors/AbstractEditor.ts
349
- var AbstractDXEditorWithInput = class extends AbstractElementWithParent {
350
- clearStrategy = new InputClearStrategy();
351
- setClearStrategy(strategy) {
352
- this.clearStrategy = strategy;
353
- }
354
- getInputCssSelector() {
355
- return `${this.getFullCssSelector()} .dx-texteditor-input`;
356
- }
357
- async getInputElement() {
358
- return this.driver.findElement(By6.css(this.getInputCssSelector()));
359
- }
360
- async getInputValue() {
361
- const inputEl = await this.getInputElement();
362
- return inputEl.getAttribute("value");
363
- }
364
- async setInputValue(value) {
365
- const inputEl = await this.getInputElement();
366
- await click(inputEl, this.driver);
367
- await inputEl.sendKeys(value, Key.ENTER);
368
- }
369
- async clear() {
370
- await this.clearStrategy.clear(this);
371
- }
372
- };
373
-
374
- // src/pageObjects/elements/Editors/TextEditor.ts
375
- var TextEditor = class extends AbstractDXEditorWithInput {
376
- constructor(parentCssSelector, elementCssSelector, driver) {
377
- super(parentCssSelector, elementCssSelector, driver);
378
- this.setClearStrategy(new InputClearStrategy());
379
- }
380
- getValue() {
381
- return this.getInputValue();
382
- }
383
- setValue(value) {
384
- return this.setInputValue(value);
385
- }
386
- };
387
-
388
- // src/pageObjects/elements/Editors/NumberEditor.ts
389
- var NumberEditor = class extends AbstractDXEditorWithInput {
390
- constructor(parentCssSelector, elementCssSelector, driver) {
391
- super(parentCssSelector, elementCssSelector, driver);
392
- this.setClearStrategy(new InputClearStrategy());
393
- }
394
- async getValue() {
395
- const value = await super.getInputValue();
396
- return value == "" ? null : Number.parseFloat(value);
397
- }
398
- setValue(value) {
399
- return this.setInputValue(value);
400
- }
401
- };
402
-
403
- // src/pageObjects/AbstractFormElement.ts
404
- var AbstractFormElement = class extends AbstractElementWithParent {
405
- constructor(parentCssSelector, elementCssSelector, driver) {
406
- super(parentCssSelector, elementCssSelector, driver);
407
- }
408
- };
409
-
410
- // src/pageObjects/elements/Editors/CheckBox.ts
411
- var CheckBox = class extends AbstractElementWithParent {
412
- async getValue() {
413
- const result = await this.getAttribute("aria-checked");
414
- if (result === "true")
415
- return 1;
416
- if (result === "false")
417
- return 0;
418
- return null;
419
- }
420
- async setValue(value) {
421
- const inputEl = await this.getElement();
422
- const currentValue = await this.getValue();
423
- if (currentValue !== value) {
424
- await click(inputEl, this.driver);
425
- }
426
- }
427
- };
428
-
429
- // src/pageObjects/elements/Editors/SelectBoxEditor.ts
430
- import { By as By8, Key as Key2 } from "selenium-webdriver";
431
-
432
- // src/utils/xpathHelper.ts
433
- var XPathHelper = class {
434
- static getRoleXpath(role) {
435
- return `//div[@role='${role}']`;
436
- }
437
- static getClassAndValueXpath(cssClass, value) {
438
- return `//div[contains(@class, '${cssClass}') and contains(.,'${value}')]`;
439
- }
440
- };
441
-
442
- // src/pageObjects/elements/Editors/ClearStrategy/ClearButtonStrategy.ts
443
- import { By as By7 } from "selenium-webdriver";
444
- var DX_TEXTEDITOR_EMPTY = "dx-texteditor-empty";
445
- var DX_CLEAR_BUTTON_AREA = "dx-clear-button-area";
446
- var ClearButtonStrategy = class {
447
- editorContainerClass;
448
- _driver;
449
- constructor(editorContainerClass, driver) {
450
- this.editorContainerClass = editorContainerClass;
451
- this._driver = driver;
452
- }
453
- async isEmptyEditorField() {
454
- const editorContainer = await this._driver.findElement(By7.css(this.editorContainerClass));
455
- const classAttribute = await editorContainer.getAttribute("class");
456
- return classAttribute.includes(DX_TEXTEDITOR_EMPTY);
457
- }
458
- async clear() {
459
- if (await this.isEmptyEditorField()) {
460
- throw new Error("This field is already empty");
461
- }
462
- const clearBtnSelector = `${this.editorContainerClass} .${DX_CLEAR_BUTTON_AREA}`;
463
- const clearBtn = await this._driver.findElement(By7.css(clearBtnSelector));
464
- await click(clearBtn, this._driver);
465
- }
466
- };
467
-
468
- // src/pageObjects/elements/Editors/SelectBoxEditor.ts
469
- var SELECT_BOX_OPTION_TEXT_CONTAINER_CLASS = "d5-multi-select-item";
470
- var SELECT_BOX_ELEMENT_ROLE = "option";
471
- var combinedValueXpath = (value) => `${XPathHelper.getRoleXpath(SELECT_BOX_ELEMENT_ROLE)}${XPathHelper.getClassAndValueXpath(
472
- SELECT_BOX_OPTION_TEXT_CONTAINER_CLASS,
473
- value
474
- )}`;
475
- var SelectBoxEditor = class extends AbstractDXEditorWithInput {
476
- constructor(parentCssSelector, elementCssSelector, driver) {
477
- super(parentCssSelector, elementCssSelector, driver);
478
- this.setClearStrategy(new ClearButtonStrategy(this.getFullCssSelector(), this.driver));
479
- }
480
- async setSelectInputValue(value) {
481
- const inputEl = await this.getInputElement();
482
- await click(inputEl, this.driver);
483
- await inputEl.sendKeys(value, Key2.ENTER);
484
- const optElement = await inputEl.findElement(By8.xpath(combinedValueXpath(value)));
485
- await click(optElement, this.driver);
486
- }
487
- async getValue() {
488
- const value = await super.getInputValue();
489
- return value == "" ? null : value;
490
- }
491
- setValue(value) {
492
- return this.setSelectInputValue(value);
493
- }
494
- };
495
-
496
- // src/pageObjects/elements/Editors/SwitchEditor.ts
497
- var SwitchEditor = class extends AbstractElementWithParent {
498
- async getValue() {
499
- const result = await this.getAttribute("aria-label");
500
- if (result === "ON")
501
- return 1;
502
- if (result === "OFF")
503
- return 0;
504
- return null;
505
- }
506
- async setValue(value) {
507
- if (value !== 0 && value !== 1) {
508
- value = value ? 1 : 0;
509
- }
510
- const inputEl = await this.getElement();
511
- const currentValue = await this.getValue();
512
- if (currentValue === value) {
513
- return;
514
- }
515
- await click(inputEl, this.driver);
516
- await wait(async () => {
517
- const updatedValue = await this.getValue();
518
- return updatedValue !== currentValue;
519
- }, this.driver);
520
- }
521
- };
522
-
523
- // src/pageObjects/elements/Editors/TagBox.ts
524
- import { By as By9 } from "selenium-webdriver";
525
- var TAGS_SELECTOR = ".dx-tag .tag-text";
526
- var DX_TAG_CONTAINER = "dx-tag-container";
527
- var DX_TEXTEDITOR_EMPTY2 = "dx-texteditor-empty";
528
- var BTN_OK_SELECTOR = ".dx-tagbox-popup-wrapper .dx-popup-bottom .dx-button.dx-popup-done";
529
- var TAG_BOX_LIST_ITEM_SELECTOR = '.dx-tagbox-popup-wrapper .dx-list-item[aria-selected="true"]';
530
- var TagBox = class extends AbstractDXEditorWithInput {
531
- constructor(parentCssSelector, elementCssSelector, driver) {
532
- super(parentCssSelector, elementCssSelector, driver);
533
- this.setClearStrategy(new ClearButtonStrategy(this.getFullCssSelector(), this.driver));
534
- }
535
- async setTagBoxInputValue(values) {
536
- const lastElement = values[values.length - 1];
537
- const inputEl = await this.getInputElement();
538
- await inputEl.click();
539
- for (const value of values) {
540
- await this.selectOption(inputEl, value, lastElement);
541
- }
542
- await this.confirmSelection();
543
- }
544
- async waitOptionSelection() {
545
- const option = await this.driver.findElement(By9.css(TAG_BOX_LIST_ITEM_SELECTOR));
546
- await wait(() => option.isDisplayed(), this.driver);
547
- }
548
- async selectOption(inputEl, value, lastElement) {
549
- await inputEl.sendKeys(value);
550
- const optElement = await inputEl.findElement(By9.xpath(combinedValueXpath(value)));
551
- await click(optElement, this.driver);
552
- await this.waitOptionSelection();
553
- if (value !== lastElement) {
554
- await inputEl.clear();
555
- }
556
- }
557
- async confirmSelection() {
558
- const btnOk = await this.driver.findElement(By9.css(BTN_OK_SELECTOR));
559
- await click(btnOk, this.driver);
560
- }
561
- async getTagBoxInputValue() {
562
- if (await this.isTagBoxEmpty()) {
563
- return [];
564
- }
565
- const tags = await this.driver.findElements(By9.css(`${this.getFullCssSelector()} .${DX_TAG_CONTAINER} ${TAGS_SELECTOR}`));
566
- const values = [];
567
- for (const tag of tags) {
568
- values.push(await tag.getAttribute("textContent"));
569
- }
570
- return values;
571
- }
572
- async isTagBoxEmpty() {
573
- const classAttribute = await this.getClasses();
574
- return classAttribute.includes(DX_TEXTEDITOR_EMPTY2);
575
- }
576
- async getValue() {
577
- const value = await this.getTagBoxInputValue();
578
- return value.length ? value : null;
579
- }
580
- async setValue(values) {
581
- if (!Array.isArray(values)) {
582
- throw new Error("The provided value is not an array");
583
- }
584
- await this.setTagBoxInputValue(values);
585
- }
586
- async remove(itemText) {
587
- const tagValues = await this.getValue();
588
- const tagExists = tagValues.includes(itemText);
589
- if (!tagExists) {
590
- throw new Error(`The tag with the text: ${itemText} was not found`);
591
- }
592
- const clearBtnTestId = byTestIdCssSelector(`clear-button-${itemText}`);
593
- const clearBtn = await this.driver.findElement(By9.css(`${this.getFullCssSelector()} .${DX_TAG_CONTAINER} ${clearBtnTestId}`));
594
- await click(clearBtn, this.driver);
595
- }
596
- };
597
-
598
- // src/pageObjects/elements/Editors/ButtonGroup.ts
599
- import { By as By10 } from "selenium-webdriver";
600
- var ITEM_CLASS = "dx-buttongroup-item";
601
- var SELECTED_CLASS = "dx-state-selected";
602
- var ButtonGroup = class extends AbstractElementWithParent {
603
- getItems() {
604
- return this.driver.findElements(By10.css(`${this.getFullCssSelector()} .${ITEM_CLASS}`));
605
- }
606
- getDataValue(el) {
607
- return el.getAttribute("data-value");
608
- }
609
- async getValue() {
610
- const selectedEl = await this.driver.findElement(By10.css(`${this.getFullCssSelector()} .${ITEM_CLASS}.${SELECTED_CLASS}`));
611
- return this.getDataValue(selectedEl);
612
- }
613
- async setValue(value) {
614
- const items = await this.getItems();
615
- let buttonEl = void 0;
616
- for (const item of items) {
617
- const text = await this.getDataValue(item);
618
- if (text == value) {
619
- buttonEl = item;
620
- break;
621
- }
622
- }
623
- if (!buttonEl)
624
- throw new Error(`Cannot find item in button group with text: ${value}`);
625
- await click(buttonEl, this.driver);
626
- }
627
- };
628
-
629
- // src/pageObjects/elements/Editors/BooleanSelector.ts
630
- var BooleanSelector = class extends ButtonGroup {
631
- // @ts-ignore
632
- async getValue() {
633
- const value = await super.getValue();
634
- return value === "null" ? null : value === "1" ? 1 : 0;
635
- }
636
- // @ts-ignore
637
- async setValue(value) {
638
- const val = value == null ? "null" : value ? "1" : "0";
639
- await super.setValue(val);
640
- }
641
- };
642
-
643
- // src/pageObjects/elements/Editors/DateEditor.ts
644
- import { By as By11, Key as Key3 } from "selenium-webdriver";
645
- var DateEditor = class extends AbstractDXEditorWithInput {
646
- constructor(parentCssSelector, elementCssSelector, driver) {
647
- super(parentCssSelector, elementCssSelector, driver);
648
- this.setClearStrategy(new InputClearStrategy());
649
- }
650
- async getDateElement() {
651
- return this.driver.findElement(By11.css(this.getFullCssSelector() + " .dx-dropdowneditor-input-wrapper input[type=hidden]"));
652
- }
653
- async setDateValue(value) {
654
- const dateEl = await this.getInputElement();
655
- const stringDate = value.toJSON().split("T")[0];
656
- const dateArr = stringDate.split("-");
657
- const [year, month, day] = dateArr;
658
- const keys = day + month + year;
659
- await click(dateEl, this.driver);
660
- const actions = this.driver.actions({ async: true });
661
- await actions.move({ origin: dateEl }).sendKeys(Key3.HOME).perform();
662
- await actions.move({ origin: dateEl }).sendKeys(keys, Key3.ENTER).perform();
663
- }
664
- async getDateValue() {
665
- const inputEl = await this.getDateElement();
666
- return inputEl.getAttribute("value");
667
- }
668
- async getValue() {
669
- const value = await this.getDateValue();
670
- return value == "" ? null : new Date(value);
671
- }
672
- setValue(value) {
673
- if (typeof value === "object") {
674
- return this.setDateValue(value);
675
- }
676
- throw new Error(`Value is incorrect. It should be Object`);
677
- }
678
- };
679
-
680
- // src/pageObjects/elements/Editors/editorFactory.ts
681
- var editorFactory = async (parentCssSelector, elementCssSelector, driver) => {
682
- const elementInstance = new AbstractFormElement(parentCssSelector, elementCssSelector, driver);
683
- const classSting = await elementInstance.getClasses();
684
- if (classSting.includes("text-control"))
685
- return new TextEditor(parentCssSelector, elementCssSelector, driver);
686
- if (classSting.includes("number-control"))
687
- return new NumberEditor(parentCssSelector, elementCssSelector, driver);
688
- if (classSting.includes("check-box"))
689
- return new CheckBox(parentCssSelector, elementCssSelector, driver);
690
- if (classSting.includes("multi-select-control"))
691
- return new TagBox(parentCssSelector, elementCssSelector, driver);
692
- if (classSting.includes("select-control"))
693
- return new SelectBoxEditor(parentCssSelector, elementCssSelector, driver);
694
- if (classSting.includes("switch-control"))
695
- return new SwitchEditor(parentCssSelector, elementCssSelector, driver);
696
- if (classSting.includes("date-control"))
697
- return new DateEditor(parentCssSelector, elementCssSelector, driver);
698
- if (classSting.includes("buttons-group"))
699
- return new BooleanSelector(parentCssSelector, elementCssSelector, driver);
700
- if (classSting.includes("button-group-field"))
701
- return new ButtonGroup(parentCssSelector, elementCssSelector, driver);
702
- throw new Error("Unknown type of editor. Please write ticket to the support");
703
- };
704
-
705
- // src/pageObjects/elements/AbstractEditor.ts
706
- var AbstractEditor = class extends AbstractElementWithParent {
707
- editor;
708
- constructor(parentCssSelector, elementCssSelector, driver) {
709
- super(parentCssSelector, elementCssSelector, driver);
710
- }
711
- async initEditor() {
712
- if (!this.editor) {
713
- this.editor = await editorFactory(this.parentCssSelector, this.elementCssSelector, this.driver);
714
- }
715
- }
716
- /**
717
- * Возвращает значение в поле
718
- * @example
719
- * expect(await formEdit.field('NumberFld').getValue()).toBe(10);
720
- * expect(await formEdit.field('TextFld').getValue()).toBe('TestValue');
721
- */
722
- async getValue() {
723
- await this.initEditor();
724
- return this.editor.getValue();
725
- }
726
- /**
727
- * Устанавливает значение в поле
728
- * @example
729
- * await formEdit.field('NumberFld').setValue(123);
730
- * await formEdit.field('TextFld').setValue('TestValue');
731
- */
732
- async setValue(value) {
733
- await this.initEditor();
734
- return this.editor.setValue(value);
735
- }
736
- /**
737
- * Очищает значение в поле
738
- * @example
739
- * await formEdit.field('NumberFld').clear();
740
- */
741
- async clear() {
742
- await this.initEditor();
743
- if (!this.editor.clear) {
744
- throw new Error("The clear method is not available for this field type.");
745
- }
746
- return this.editor.clear();
747
- }
748
- /**
749
- * Удаляет тег по переданному тексту
750
- * @example
751
- * await formEdit.field('TagBox').remove('test');
752
- */
753
- async remove(itemText) {
754
- await this.initEditor();
755
- if (!this.editor.remove) {
756
- throw new Error("This method is only available for the TagBox field.");
757
- }
758
- return this.editor.remove(itemText);
759
- }
760
- /**
761
- * Возвращает значение true|false в зависимости readOnly поле или нет
762
- * @example
763
- * expect(await formEdit.field('NumberFld').isReadonly()).toBe(true);
764
- * expect(await formEdit.field('TextFld').isReadonly()).toBe(false);
765
- */
766
- async isReadonly() {
767
- await this.initEditor();
768
- return this.editor.isReadonly();
769
- }
770
- };
771
-
772
- // src/pageObjects/elements/FormField.ts
773
- var FormField = class extends AbstractEditor {
774
- constructor(parentCssSelector, formName, name, driver) {
775
- super(parentCssSelector, byTestIdCssSelector(createFieldTestId(formName, name)), driver);
776
- }
777
- };
778
-
779
- // src/pageObjects/elements/Groups/AbstractGroup.ts
780
- var AbstractGroup = class extends AbstractElementWithParent {
781
- async isDisplayed() {
782
- const groupElement = await this.getElement();
783
- return await groupElement.isDisplayed();
784
- }
785
- };
786
-
787
- // src/pageObjects/elements/Groups/Panel.ts
788
- var Panel = class extends AbstractGroup {
789
- };
790
-
791
- // src/pageObjects/elements/Groups/groupFactory.ts
792
- var groupFactory = async (parentCssSelector, elementCssSelector, driver) => {
793
- const elementInstance = new AbstractFormElement(parentCssSelector, elementCssSelector, driver);
794
- const classSting = await elementInstance.getClasses();
795
- if (classSting.includes("panel-group"))
796
- return new Panel(parentCssSelector, elementCssSelector, driver);
797
- throw new Error("Unknown type of group. Please write ticket to the support");
798
- };
799
-
800
- // src/pageObjects/elements/FormGroup.ts
801
- var FormGroup = class extends AbstractElementWithParent {
802
- editor;
803
- constructor(parentCssSelector, formName, name, driver) {
804
- super(parentCssSelector, byTestIdCssSelector(createGroupTestId(formName, name)), driver);
805
- }
806
- async initEditor() {
807
- if (!this.editor) {
808
- this.editor = await groupFactory(this.parentCssSelector, this.elementCssSelector, this.driver);
809
- }
810
- }
811
- /**
812
- * Возвращает булевое значение доступна ли группа
813
- * @example
814
- * expect(await tableList.group('MainSuperPanel').isDisplayed();
815
- */
816
- async isDisplayed() {
817
- try {
818
- await this.initEditor();
819
- return this.editor.isDisplayed();
820
- } catch {
821
- return false;
822
- }
823
- }
824
- };
825
-
826
- // src/pageObjects/elements/Forms/FormEdit.ts
827
- var FormEdit = class extends AbstractForm {
828
- saveButtonBy = By12.id("button-save");
829
- closeButtonBy = By12.id("button-cancel");
830
- constructor(driver) {
831
- super(driver);
832
- this.popupContainerCssSelector = `.popup .form-edit-${this.formName}`;
833
- }
834
- /**
835
- * Находит поле формы редактирования по имени
836
- * @example
837
- * const formEdit = new MyForm();
838
- * //...
839
- * expect(await formEdit.field('Name').getValue()).toBe('test value');
840
- */
841
- field(name) {
842
- return new FormField(this.containerCssSelector, this.formName, name, this.driver);
843
- }
844
- /**
845
- * Проверяет не отключена ли кнопка Сохранить
846
- * @example
847
- * const formEdit = new MyForm();
848
- * //...
849
- * await formEdit.isSaveButtonDisabled();
850
- */
851
- async isSaveButtonDisabled() {
852
- const saveButton = await this.driver.findElement(this.saveButtonBy);
853
- const result = await saveButton.getAttribute("aria-disabled");
854
- return result === "true";
855
- }
856
- /**
857
- * Находит группу формы редактирования по имени
858
- * @example
859
- * const formEdit = new MyForm();
860
- * //...
861
- * expect(await formEdit.group('Name');
862
- */
863
- group(name) {
864
- return new FormGroup(this.containerCssSelector, this.formName, name, this.driver);
865
- }
866
- /**
867
- * Нажатие на кнопку Сохранить
868
- * @example
869
- * const formEdit = new MyForm();
870
- * //...
871
- * await formEdit.saveButtonClick();
872
- */
873
- async saveButtonClick() {
874
- const saveButton = await this.driver.findElement(this.saveButtonBy);
875
- await wait(async () => !await this.isSaveButtonDisabled(), this.driver, "Button is disabled");
876
- await click(saveButton, this.driver);
877
- }
878
- /**
879
- * Нажатие на кнопку Закрить
880
- * @example
881
- * const formEdit = new MyForm();
882
- * //...
883
- * await formEdit.closeButtonClick();
884
- */
885
- async closeButtonClick() {
886
- const closeButton = await this.driver.findElement(this.closeButtonBy);
887
- await click(closeButton, this.driver);
888
- }
889
- };
890
-
891
- // src/pageObjects/elements/Table/Table.ts
892
- import { By as By17 } from "selenium-webdriver";
893
-
894
- // src/pageObjects/elements/Table/elements/Row.ts
895
- import { By as By15 } from "selenium-webdriver";
896
-
897
- // src/pageObjects/elements/Table/elements/Cell.ts
898
- import { By as By14 } from "selenium-webdriver";
899
-
900
- // src/pageObjects/elements/Table/utils.ts
901
- import { By as By13 } from "selenium-webdriver";
902
- function getCssRowByIndexSelector(index) {
903
- return `tr[aria-rowindex="${transformInputIndex(index)}"]`;
904
- }
905
- var getColumnByIndexCssSelector = (columnIndex) => `td[aria-colindex="${transformInputIndex(columnIndex)}"]`;
906
- var getColumnByCaptionCssSelector = (caption) => `td[role="columnheader"][aria-label="Column ${caption}"]`;
907
- var getColumnByNameCssSelector = (name) => `td[role="columnheader"][data-fieldname="${name}"]`;
908
- function getCssCellByIndexSelector(index) {
909
- return `td[role="gridcell"][aria-colindex="${transformInputIndex(index)}"]`;
910
- }
911
- var transformInputIndex = (index) => index + 1;
912
- var transformOutputIndex = (index) => +index - 1;
913
-
914
- // src/pageObjects/elements/Table/elements/Cell.ts
915
- var Cell = class extends AbstractElementWithParent {
916
- _index;
917
- getCellIndex;
918
- constructor(parentCssSelector, getCellIndex, index, driver) {
919
- super(parentCssSelector, getCssCellByIndexSelector(index), driver);
920
- this.getCellIndex = getCellIndex;
921
- this._index = index;
922
- }
923
- set index(index) {
924
- this._index = index;
925
- this.elementCssSelector = getCssCellByIndexSelector(index);
926
- }
927
- async getBooleanValue(cellEl) {
928
- const booleanEl = await cellEl.findElement(By14.className("boolean-widget"));
929
- return await booleanEl.getAttribute("aria-checked") === "true" ? 1 : 0;
930
- }
931
- async getElement() {
932
- if (this._index == null) {
933
- this.index = await this.getCellIndex();
934
- }
935
- return super.getElement();
936
- }
937
- async getValue() {
938
- const cellEl = await this.getElement();
939
- const cellElClass = await cellEl.getAttribute("class");
940
- if (cellElClass.includes("boolean-column")) {
941
- return this.getBooleanValue(cellEl);
942
- }
943
- return cellEl.getText();
944
- }
945
- getIndex() {
946
- return this._index;
947
- }
948
- };
949
-
950
- // src/pageObjects/elements/Table/elements/Row.ts
951
- var DX_SELECTION_CLASS = "dx-selection";
952
- var DX_ROW_EDIT_CLASS = "dx-edit-row";
953
- var DX_DATA_ROW_CLASS = "dx-data-row";
954
- var Row = class extends AbstractElementWithParent {
955
- index;
956
- getColumnBy;
957
- constructor(parentCssSelector, index, driver, getColumnBy) {
958
- super(parentCssSelector, getCssRowByIndexSelector(index), driver);
959
- this.index = index;
960
- this.getColumnBy = getColumnBy;
961
- }
962
- _getCell({ index, name, title }) {
963
- return new Cell(this.getFullCssSelector(), () => {
964
- return this.getColumnBy({ title, name }).getIndex();
965
- }, index, this.driver);
966
- }
967
- getCellByIndex(index) {
968
- return this._getCell({ index });
969
- }
970
- getCell(name) {
971
- return this._getCell({ name });
972
- }
973
- getCellByTitle(title) {
974
- return this._getCell({ title });
975
- }
976
- async select() {
977
- const rowEl = await this.getElement();
978
- await click(rowEl, this.driver);
979
- await wait(async () => {
980
- const classes = await this.getClasses();
981
- return classes.includes(DX_SELECTION_CLASS);
982
- }, this.driver, "Cannot select row");
983
- }
984
- async isSelected() {
985
- const result = await this.getAttribute("aria-selected");
986
- return result === "true";
987
- }
988
- getIndex() {
989
- return this.index;
990
- }
991
- async getCells() {
992
- const cells = await this.driver.findElements(By15.css(`${this.getFullCssSelector()} td[role="gridcell"]`));
993
- const result = [];
994
- cells.forEach((_, index) => {
995
- const newCell = this.getCellByIndex(index);
996
- result.push(newCell);
997
- });
998
- return result;
999
- }
1000
- async clickInlineButton(buttonClass) {
1001
- const FIXED_TABLE_CSS_SELECTOR = ".dx-fixed-columns .dx-datagrid-content.dx-datagrid-content-fixed";
1002
- const buttonCssSelector = `.${DX_DATA_ROW_CLASS}[aria-rowindex="${transformInputIndex(this.index)}"] .${buttonClass}`;
1003
- const button = await this.driver.findElement(By15.css(`${this.parentCssSelector} ${FIXED_TABLE_CSS_SELECTOR} ${buttonCssSelector}`));
1004
- return click(button, this.driver);
1005
- }
1006
- async checkEditingMode(isEditing, msg) {
1007
- await wait(async () => {
1008
- return (await this.getClasses()).includes(DX_ROW_EDIT_CLASS) === isEditing;
1009
- }, this.driver, msg);
1010
- }
1011
- async edit() {
1012
- await this.clickInlineButton("edit");
1013
- await this.checkEditingMode(true, "Row did not switch to edit mode");
1014
- }
1015
- async save() {
1016
- await this.clickInlineButton("save");
1017
- await this.checkEditingMode(false, "Row did not saved");
1018
- }
1019
- async cancel() {
1020
- await this.clickInlineButton("cancel");
1021
- await this.checkEditingMode(false, "Row did not switch to normal mode");
1022
- }
1023
- };
1024
-
1025
- // src/pageObjects/elements/Table/elements/Column.ts
1026
- import { By as By16 } from "selenium-webdriver";
1027
- var getHeaderCssSelector = () => {
1028
- return ".dx-datagrid-headers .dx-datagrid-content:not(.dx-datagrid-content-fixed)";
1029
- };
1030
- var Column = class extends AbstractElementWithParent {
1031
- _index;
1032
- _caption;
1033
- _name;
1034
- constructor({ parentCssSelector, name, caption, index, driver }) {
1035
- super(parentCssSelector, "", driver);
1036
- this._name = name;
1037
- this.index = index;
1038
- this._caption = caption;
1039
- }
1040
- set index(index) {
1041
- this._index = index;
1042
- this.elementCssSelector = getColumnByIndexCssSelector(index);
1043
- }
1044
- get index() {
1045
- return this._index;
1046
- }
1047
- async getElement() {
1048
- await this.getIndex();
1049
- return super.getElement();
1050
- }
1051
- async getColumnHeaderIndexBy(cssSelector) {
1052
- const column = await this.driver.findElement(By16.css(`${this.parentCssSelector} ${getHeaderCssSelector()} ${cssSelector}`));
1053
- return transformOutputIndex(await column.getAttribute("aria-colindex"));
1054
- }
1055
- async getIndexByCaption() {
1056
- return this.getColumnHeaderIndexBy(getColumnByCaptionCssSelector(this._caption));
1057
- }
1058
- async getIndexByName() {
1059
- return this.getColumnHeaderIndexBy(getColumnByNameCssSelector(this._name));
1060
- }
1061
- async caption() {
1062
- const el = await this.getElement();
1063
- return el.getText();
1064
- }
1065
- async getIndex() {
1066
- if (this.index != null) {
1067
- return this.index;
1068
- }
1069
- if (this._caption != null) {
1070
- this.index = await this.getIndexByCaption();
1071
- return this.index;
1072
- }
1073
- if (this._name != null) {
1074
- this.index = await this.getIndexByName();
1075
- return this.index;
1076
- }
1077
- throw new Error("Cant get the index in the column");
1078
- }
1079
- };
1080
-
1081
- // src/pageObjects/elements/Table/Table.ts
1082
- var Table = class extends AbstractElementWithParent {
1083
- formName;
1084
- constructor(parentCssSelector, formName, driver) {
1085
- super(parentCssSelector, `#${createTableId(formName)}`, driver);
1086
- this.formName = formName;
1087
- }
1088
- getColumnBy = (args) => {
1089
- if (args.title) {
1090
- return this.getColumnByTitle(args.title);
1091
- }
1092
- return this.getColumnByName(args.name);
1093
- };
1094
- getRowByIndex(index) {
1095
- return new Row(this.getFullCssSelector(), index, this.driver, this.getColumnBy);
1096
- }
1097
- getColumnByIndex(index) {
1098
- return new Column({
1099
- parentCssSelector: this.getFullCssSelector(),
1100
- driver: this.driver,
1101
- index
1102
- });
1103
- }
1104
- getColumnByTitle = (title) => {
1105
- return new Column({
1106
- parentCssSelector: this.getFullCssSelector(),
1107
- caption: title,
1108
- driver: this.driver
1109
- });
1110
- };
1111
- getColumnByName = (name) => {
1112
- return new Column({
1113
- parentCssSelector: this.getFullCssSelector(),
1114
- name,
1115
- driver: this.driver
1116
- });
1117
- };
1118
- selectRowByIndex(index) {
1119
- return this.getRowByIndex(index).select();
1120
- }
1121
- async getRows() {
1122
- const rows = await this.driver.findElements(By17.css(`${this.getFullCssSelector()} .dx-row.dx-data-row`));
1123
- const result = [];
1124
- rows.forEach((_, index) => {
1125
- const newRow = new Row(this.getFullCssSelector(), index, this.driver, this.getColumnBy);
1126
- result.push(newRow);
1127
- });
1128
- return result;
1129
- }
1130
- async getColumns() {
1131
- const columns = await this.driver.findElements(By17.css(`${this.getFullCssSelector()} ${getHeaderCssSelector()} td[role="columnheader"]`));
1132
- const result = [];
1133
- columns.forEach((_, index) => {
1134
- const newCol = new Column({
1135
- parentCssSelector: this.getFullCssSelector(),
1136
- index,
1137
- driver: this.driver
1138
- });
1139
- result.push(newCol);
1140
- });
1141
- return result;
1142
- }
1143
- element() {
1144
- return this.getElement();
1145
- }
1146
- /**
1147
- * Находит поле когда форма находится в состоянии редактирования
1148
- * @example
1149
- * const form = new MyForm();
1150
- * //...
1151
- * expect(await form.field('Name').getValue()).toBe('test value');
1152
- */
1153
- field(name) {
1154
- return new FormField(this.getFullCssSelector(), this.formName, name, this.driver);
1155
- }
1156
- };
1157
-
1158
- // src/pageObjects/elements/TableToolbar/AbstractButton.ts
1159
- var AbstractButton = class extends AbstractElementWithParent {
1160
- constructor(parentCssSelector, elementCssSelector, driver) {
1161
- super(parentCssSelector, elementCssSelector, driver);
1162
- }
1163
- async click() {
1164
- const button = await this.getElement();
1165
- await wait(async () => {
1166
- return await button.isDisplayed() && !await this.isDisabled();
1167
- }, this.driver, this.buttonNotDisplayedError());
1168
- await click(button, this.driver);
1169
- }
1170
- async isDisabled() {
1171
- const button = await this.getElement();
1172
- return await button.getCssValue("pointer-events") === "none";
1173
- }
1174
- };
1175
-
1176
- // src/pageObjects/elements/TableToolbar/ToolbarGroupButton.ts
1177
- var ToolbarGroupButton = class extends AbstractButton {
1178
- name;
1179
- constructor(parentCssSelector, name, driver) {
1180
- super(parentCssSelector, ``, driver);
1181
- this.name = name;
1182
- }
1183
- buttonNotDisplayedError() {
1184
- return `Button ${this.name} cannot be clicked. It is not displayed or it is disabled`;
1185
- }
1186
- };
1187
-
1188
- // src/pageObjects/elements/TableToolbar/ToolbarButton.ts
1189
- var TOOLBAR_BUTTON_CLASS = "toolbar-button";
1190
- var ToolbarButton = class extends AbstractButton {
1191
- name;
1192
- constructor(parentCssSelector, name, driver) {
1193
- super(parentCssSelector, `#${TOOLBAR_BUTTON_CLASS}-${name}`, driver);
1194
- this.name = name;
1195
- }
1196
- buttonNotDisplayedError() {
1197
- return `Button ${this.name} cannot be clicked. It is not displayed or it is disabled`;
1198
- }
1199
- };
1200
-
1201
- // src/pageObjects/elements/TableToolbar/ToolbarMenu.ts
1202
- import { By as By18 } from "selenium-webdriver";
1203
-
1204
- // src/utils/typesUtil.ts
1205
- var types = {
1206
- "[object Array]": "array",
1207
- "[object Date]": "date",
1208
- "[object Object]": "object",
1209
- "[object String]": "string",
1210
- "[object Null]": "null"
1211
- };
1212
- var type = function(object) {
1213
- const typeOfObject = Object.prototype.toString.call(object);
1214
- return typeof object === "object" ? types[typeOfObject] || "object" : typeof object;
1215
- };
1216
- var isArray = function(value) {
1217
- return type(value) === "array";
1218
- };
1219
- var isString = function(object) {
1220
- return typeof object === "string";
1221
- };
1222
-
1223
- // src/pageObjects/elements/TableToolbar/ToolbarMenu.ts
1224
- var SPINDOWN_CLASS = ".dx-icon-spindown";
1225
- var buttonGroupItemSelector = (formName, name) => byTestIdCssSelector(`ftb-${formName}-${name}`);
1226
- var getFullCssSelector = (formName, name) => `${buttonGroupItemSelector(formName, name)} ${SPINDOWN_CLASS}`;
1227
- var buttonByTextXpath = (text) => `.//span[contains(@class, "dx-menu-item-text") and contains(text(), "${text}")]`;
1228
- var ToolbarMenu = class extends AbstractElementWithParent {
1229
- _formName;
1230
- constructor(parentCssSelector, formName, name, driver) {
1231
- super(parentCssSelector, getFullCssSelector(formName, name), driver);
1232
- this._formName = formName;
1233
- }
1234
- async toggle() {
1235
- const dropdown = await this.getElement();
1236
- await dropdown.click();
1237
- }
1238
- getCssSelectorToButton(name) {
1239
- return byTestId(`ftb-${this._formName}-${name}`);
1240
- }
1241
- buttonNotDisplayedError(name) {
1242
- return `Toolbar menu button ${name} cannot be clicked. It is not displayed or it is disabled`;
1243
- }
1244
- async goToButton(name, selector) {
1245
- const toolbarMenuItem = this.driver.findElement(selector);
1246
- await wait(async () => {
1247
- return await toolbarMenuItem.isDisplayed();
1248
- }, this.driver, this.buttonNotDisplayedError(name));
1249
- await click(toolbarMenuItem, this.driver);
1250
- }
1251
- async clickButton(name) {
1252
- await this.toggle();
1253
- if (isString(name)) {
1254
- const selector = this.getCssSelectorToButton(name);
1255
- await this.goToButton(name, selector);
1256
- }
1257
- if (isArray(name)) {
1258
- for (let n of name) {
1259
- const selector = this.getCssSelectorToButton(n);
1260
- await this.goToButton(n, selector);
1261
- }
1262
- }
1263
- }
1264
- async clickButtonByTitle(title) {
1265
- await this.toggle();
1266
- if (isString(title)) {
1267
- const selector = By18.xpath(buttonByTextXpath(title));
1268
- await this.goToButton(title, selector);
1269
- }
1270
- if (isArray(title)) {
1271
- for (let t of title) {
1272
- const selector = By18.xpath(buttonByTextXpath(t));
1273
- await this.goToButton(t, selector);
1274
- }
1275
- }
1276
- }
1277
- };
1278
-
1279
- // src/pageObjects/elements/TableToolbar/ToolbarItem.ts
1280
- var GROUP_BUTTON_CLASS = "toolbar-group-button";
1281
- var toolbarItemSelector = (form, name) => byTestIdCssSelector(`ftb-${form}-${name}`);
1282
- var ToolbarItem = class extends AbstractElementWithParent {
1283
- _button;
1284
- _formName;
1285
- _itemName;
1286
- constructor(parentCssSelector, formName, itemName, driver) {
1287
- super(parentCssSelector, toolbarItemSelector(formName, itemName), driver);
1288
- this._itemName = itemName;
1289
- this._formName = formName;
1290
- }
1291
- async init() {
1292
- if (this._button)
1293
- return this._button;
1294
- const classNames = await this.getClasses();
1295
- if (classNames.includes(GROUP_BUTTON_CLASS)) {
1296
- this._button = new ToolbarGroupButton(this.getFullCssSelector(), this._itemName, this.driver);
1297
- return;
1298
- }
1299
- this._button = new ToolbarButton(this.parentCssSelector, this._itemName, this.driver);
1300
- }
1301
- async click() {
1302
- await this.init();
1303
- await this._button.click();
1304
- }
1305
- async isDisabled() {
1306
- await this.init();
1307
- return await this._button.isDisabled();
1308
- }
1309
- get menu() {
1310
- return new ToolbarMenu(this.parentCssSelector, this._formName, this._itemName, this.driver);
1311
- }
1312
- };
1313
-
1314
- // src/pageObjects/elements/TableToolbar/FormToolbar.ts
1315
- var TABLE_TOOLBAR_CLASS = "d5-table-toolbar";
1316
- var FormToolbar = class extends AbstractElementWithParent {
1317
- formName;
1318
- constructor(parentCssSelector, formName, driver) {
1319
- super(parentCssSelector, `#${TABLE_TOOLBAR_CLASS}-${formName}`, driver);
1320
- this.formName = formName;
1321
- }
1322
- button(name) {
1323
- return new ToolbarItem(this.getFullCssSelector(), this.formName, name, this.driver);
1324
- }
1325
- };
1326
-
1327
- // src/pageObjects/elements/Filters/FormFilterField.ts
1328
- var FormFilterField = class extends AbstractEditor {
1329
- constructor(parentCssSelector, formName, name, driver) {
1330
- super(parentCssSelector, byTestIdCssSelector(createLayoutFilterTestId(formName, name)), driver);
1331
- }
1332
- /**
1333
- * Возвращает значение в поле
1334
- * @example
1335
- * expect(await form.formFilter('NumberFld').getValue()).toBe(10);
1336
- * expect(await form.formFilter('TextFld').getValue()).toBe('TestValue');
1337
- */
1338
- async getValue() {
1339
- return super.getValue();
1340
- }
1341
- /**
1342
- * Устанавливает значение в поле
1343
- * @example
1344
- * await form.formFilter('NumberFld').setValue(123);
1345
- * await form.formFilter('TextFld').setValue('TestValue');
1346
- */
1347
- async setValue(value) {
1348
- return super.setValue(value);
1349
- }
1350
- /**
1351
- * Очищает значение в поле
1352
- * @example
1353
- * await form.formFilter('NumberFld').clear();
1354
- */
1355
- async clear() {
1356
- return super.clear();
1357
- }
1358
- /**
1359
- * Удаляет тег по переданному тексту
1360
- * @example
1361
- * await form.formFilter('TagBox').remove('test');
1362
- */
1363
- async remove(itemText) {
1364
- return super.remove(itemText);
1365
- }
1366
- };
1367
-
1368
- // src/pageObjects/elements/Filters/FilterPanel.ts
1369
- import { By as By19 } from "selenium-webdriver";
1370
-
1371
- // src/pageObjects/elements/Filters/PanelFilterField.ts
1372
- var PanelFilterField = class extends AbstractEditor {
1373
- constructor(parentCssSelector, formName, name, driver) {
1374
- super(parentCssSelector, byTestIdCssSelector(createDocFilterTestId(formName, name)), driver);
1375
- }
1376
- /**
1377
- * Возвращает значение в поле
1378
- * @example
1379
- * expect(await form.filterPanel.filterField('NumberFld').getValue()).toBe(10);
1380
- * expect(await form.filterPanel.filterField('TextFld').getValue()).toBe('TestValue');
1381
- */
1382
- async getValue() {
1383
- return super.getValue();
1384
- }
1385
- /**
1386
- * Устанавливает значение в поле
1387
- * @example
1388
- * await form.filterPanel.filterField('NumberFld').setValue(123);
1389
- * await form.filterPanel.filterField('TextFld').setValue('TestValue');
1390
- */
1391
- async setValue(value) {
1392
- return super.setValue(value);
1393
- }
1394
- /**
1395
- * Очищает значение в поле
1396
- * @example
1397
- * await form.filterPanel.filterField('NumberFld').clear();
1398
- */
1399
- async clear() {
1400
- return super.clear();
1401
- }
1402
- /**
1403
- * Удаляет тег по переданному тексту
1404
- * @example
1405
- * await form.filterPanel.filterField('TagBox').remove('test');
1406
- */
1407
- async remove(itemText) {
1408
- return super.remove(itemText);
1409
- }
1410
- };
1411
-
1412
- // src/pageObjects/elements/Filters/FilterPanel.ts
1413
- var drawerSelector = (formName) => `.secondary-drawer-side-panel.form-${formName}`;
1414
- var FILTER_PANEL_SELECTOR = ".filter-panel";
1415
- var CLOSE_SELECTOR = ".button-close";
1416
- var FilterPanel = class extends AbstractElement {
1417
- _formName;
1418
- get filterPanelSelector() {
1419
- return `${this.elementCssSelector} ${FILTER_PANEL_SELECTOR}`;
1420
- }
1421
- async filterPanelButtons() {
1422
- const selector = `${this.elementCssSelector} ${FILTER_PANEL_SELECTOR} .filter-panel__buttons-panel .dx-button-text`;
1423
- const el = await this.getElement();
1424
- return el.findElements(By19.css(selector));
1425
- }
1426
- constructor(formName, driver) {
1427
- super(driver, drawerSelector(formName));
1428
- this._formName = formName;
1429
- }
1430
- /**
1431
- * Возвращает фильтр на панели фильтрации
1432
- * @returns {PanelFilterField}
1433
- * @example
1434
- * await form.filterPanel.filterField('NumberFld');
1435
- */
1436
- filterField(name) {
1437
- return new PanelFilterField(this.filterPanelSelector, this._formName, name, this.driver);
1438
- }
1439
- async apply() {
1440
- const btn = await this.findButtonByTitle("\u0417\u0430\u0441\u0442\u043E\u0441\u0443\u0432\u0430\u0442\u0438");
1441
- await click(btn, this.driver);
1442
- }
1443
- async findButtonByTitle(title) {
1444
- const buttons = await this.filterPanelButtons();
1445
- for (const btn of buttons) {
1446
- if (await btn.getText() === title) {
1447
- return btn;
1448
- }
1449
- }
1450
- }
1451
- async clearAll() {
1452
- const btn = await this.findButtonByTitle("\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u0438");
1453
- await click(btn, this.driver);
1454
- await this.driver.sleep(300);
1455
- }
1456
- async close() {
1457
- const btn = await this.driver.findElement(By19.css(`${this.elementCssSelector} ${CLOSE_SELECTOR}`));
1458
- await click(btn, this.driver);
1459
- }
1460
- };
1461
-
1462
- // src/pageObjects/elements/Forms/ListForm.ts
1463
- var ListForm = class extends AbstractForm {
1464
- constructor(driver) {
1465
- super(driver);
1466
- this.popupContainerCssSelector = `.popup .form-inline-${this.formName}`;
1467
- }
1468
- /**
1469
- * Находит таблицу
1470
- * @example
1471
- * const listForm = new MyForm();
1472
- * //...
1473
- * expect(listForm.table());
1474
- */
1475
- table() {
1476
- return new Table(this.containerCssSelector, this.formName, this.driver);
1477
- }
1478
- /**
1479
- * Находит группу на лист форме по имени
1480
- * @example
1481
- * const formEdit = new MyForm();
1482
- * //...
1483
- * expect(await formEdit.group('Name');
1484
- */
1485
- group(name) {
1486
- return new FormGroup(this.containerCssSelector, this.formName, name, this.driver);
1487
- }
1488
- /**
1489
- * Находит таблицу
1490
- * @example
1491
- * const listForm = new MyForm();
1492
- * //...
1493
- * expect(listForm.toolbarButton());
1494
- */
1495
- toolbarButton(name) {
1496
- const toolbar = new FormToolbar(this.containerCssSelector, this.formName, this.driver);
1497
- return toolbar.button(name);
1498
- }
1499
- /**
1500
- * Фильтр который расположен на форме
1501
- * @example
1502
- * const listForm = new MyForm();
1503
- * //...
1504
- * expect(listForm.formFilter());
1505
- */
1506
- formFilter(name) {
1507
- return new FormFilterField(this.containerCssSelector, this.formName, name, this.driver);
1508
- }
1509
- /**
1510
- * Модель панели фильтрации
1511
- * @returns {FilterPanel}
1512
- * @example
1513
- * const listForm = new MyForm();
1514
- * //...
1515
- * expect(listForm.filterPanel());
1516
- */
1517
- get filterPanel() {
1518
- return new FilterPanel(this.formName, this.driver);
1519
- }
1520
- };
1521
-
1522
119
  // src/pageObjects/elements/Dialog.ts
1523
- import { By as By20 } from "selenium-webdriver";
120
+ import { By as By3 } from "selenium-webdriver";
1524
121
  var DIALOG_CLASS = ".d5-dialog";
1525
122
  var DIALOG_TITLE_CLASS = ".dialog__title";
1526
123
  var DIALOG_TEXT_CLASS = ".dialog__text";
1527
124
  var DIALOG_BUTTONS_PANEL_CLASS = ".dialog__buttons-panel";
1528
- var buttonByTextXpath2 = (text) => `.//span[contains(@class, "dx-button-text") and contains(text(), "${text}")]`;
125
+ var buttonByTextXpath = (text) => `.//span[contains(@class, "dx-button-text") and contains(text(), "${text}")]`;
1529
126
  var DialogButton = class extends AbstractButton {
1530
127
  text;
1531
128
  constructor(parentCssSelector, text, driver) {
@@ -1534,7 +131,7 @@ var DialogButton = class extends AbstractButton {
1534
131
  }
1535
132
  async getElement() {
1536
133
  const panel = await super.getElement();
1537
- return panel.findElement(By20.xpath(buttonByTextXpath2(this.text)));
134
+ return panel.findElement(By3.xpath(buttonByTextXpath(this.text)));
1538
135
  }
1539
136
  buttonNotDisplayedError() {
1540
137
  return `Dialog button ${this.text} cannot be clicked. It is not displayed or it is disabled`;
@@ -1554,11 +151,11 @@ var Dialog = class extends AbstractElement {
1554
151
  return this.joinRelativeCssSelectors([DIALOG_CLASS, DIALOG_BUTTONS_PANEL_CLASS]);
1555
152
  }
1556
153
  async title() {
1557
- const el = await this.driver.findElement(By20.css(this.titleSelector));
154
+ const el = await this.driver.findElement(By3.css(this.titleSelector));
1558
155
  return await el.getText();
1559
156
  }
1560
157
  async text() {
1561
- const el = await this.driver.findElement(By20.css(this.textSelector));
158
+ const el = await this.driver.findElement(By3.css(this.textSelector));
1562
159
  return await el.getText();
1563
160
  }
1564
161
  button(text) {
@@ -1567,6 +164,7 @@ var Dialog = class extends AbstractElement {
1567
164
  };
1568
165
  export {
1569
166
  AbstractPage,
167
+ ControlClass,
1570
168
  Dialog,
1571
169
  FilterPanel,
1572
170
  FormEdit,
@@ -1578,6 +176,7 @@ export {
1578
176
  PanelFilterField,
1579
177
  SubsystemsPanel,
1580
178
  TextEditor,
179
+ TreeView,
1581
180
  byTestId,
1582
181
  byTestIdCssSelector,
1583
182
  click,