d5-testing-library 1.0.3 → 1.0.4

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.
@@ -328,6 +328,33 @@ var SelectBoxEditor = class extends AbstractDXEditorWithInput {
328
328
  }
329
329
  };
330
330
 
331
+ // src/pageObjects/elements/Editors/SwitchEditor.ts
332
+ var SwitchEditor = class extends AbstractFormElement {
333
+ async getValue() {
334
+ const inputEl = await this.getElement();
335
+ const result = await inputEl.getAttribute("aria-label");
336
+ if (result === "ON")
337
+ return 1;
338
+ if (result === "OFF")
339
+ return 0;
340
+ return void 0;
341
+ }
342
+ async setValue(value) {
343
+ if (value !== 0 && value !== 1) {
344
+ value = value ? 1 : 0;
345
+ }
346
+ const inputEl = await this.getElement();
347
+ const currentValue = await this.getValue();
348
+ if (currentValue !== value) {
349
+ await inputEl.click();
350
+ await this.driver.wait(async () => {
351
+ const updatedValue = await this.getValue();
352
+ return updatedValue !== currentValue;
353
+ });
354
+ }
355
+ }
356
+ };
357
+
331
358
  // src/pageObjects/elements/Editors/editorFactory.ts
332
359
  var editorFactory = async (getParentElement, elementBy, driver) => {
333
360
  const elementInstance = new AbstractFormElement(getParentElement, elementBy, driver);
@@ -341,6 +368,8 @@ var editorFactory = async (getParentElement, elementBy, driver) => {
341
368
  return new CheckBox(getParentElement, elementBy, driver);
342
369
  if (classSting.includes("select-control"))
343
370
  return new SelectBoxEditor(getParentElement, elementBy, driver);
371
+ if (classSting.includes("switch-control"))
372
+ return new SwitchEditor(getParentElement, elementBy, driver);
344
373
  throw new Error("Unknown type of editor. Please write ticket to the support");
345
374
  };
346
375
 
@@ -512,6 +541,27 @@ var Row = class extends AbstractElementWithParent {
512
541
  });
513
542
  return result;
514
543
  }
544
+ async clickInlineButton(rowClass, buttonClass) {
545
+ const fixedTable = await this.getParentElement().findElement(
546
+ import_selenium_webdriver10.By.css(".dx-fixed-columns .dx-datagrid-content.dx-datagrid-content-fixed")
547
+ );
548
+ const rowEl = await fixedTable.findElement(import_selenium_webdriver10.By.className(rowClass));
549
+ const button = await rowEl.findElement(import_selenium_webdriver10.By.className(buttonClass));
550
+ if (button) {
551
+ return button.click();
552
+ }
553
+ throw new Error(`Cannot find ${buttonClass} button`);
554
+ }
555
+ async edit() {
556
+ await this.select();
557
+ return this.clickInlineButton("dx-selection", "edit");
558
+ }
559
+ async save() {
560
+ return this.clickInlineButton("dx-edit-row", "save");
561
+ }
562
+ async cancel() {
563
+ return this.clickInlineButton("dx-edit-row", "cancel");
564
+ }
515
565
  };
516
566
 
517
567
  // src/pageObjects/elements/Table/elements/Column.ts
@@ -621,6 +671,11 @@ var TableToolbarButton = class extends AbstractElementWithParent {
621
671
  const button = await this.getElement();
622
672
  return button.click();
623
673
  }
674
+ async isDisabled() {
675
+ const button = await this.getElement();
676
+ const result = await button.getAttribute("aria-disabled");
677
+ return result === "true";
678
+ }
624
679
  };
625
680
 
626
681
  // src/pageObjects/elements/TableToolbar/TableToolbar.ts
@@ -180,6 +180,7 @@ declare abstract class FormEdit extends AbstractForm {
180
180
  declare class TableToolbarButton extends AbstractElementWithParent {
181
181
  constructor(getParentElement: () => WebElementPromise, name: string, driver?: WebDriver);
182
182
  click(): Promise<void>;
183
+ isDisabled(): Promise<boolean>;
183
184
  }
184
185
 
185
186
  declare class Cell extends AbstractElementWithParent {
@@ -207,6 +208,10 @@ declare class Row extends AbstractElementWithParent {
207
208
  isSelected(): Promise<boolean>;
208
209
  getIndex(): number;
209
210
  getCells(): Promise<Cell[]>;
211
+ private clickInlineButton;
212
+ edit(): Promise<void>;
213
+ save(): Promise<void>;
214
+ cancel(): Promise<void>;
210
215
  }
211
216
 
212
217
  declare class Table extends AbstractElementWithParent {
@@ -289,6 +289,33 @@ var SelectBoxEditor = class extends AbstractDXEditorWithInput {
289
289
  }
290
290
  };
291
291
 
292
+ // src/pageObjects/elements/Editors/SwitchEditor.ts
293
+ var SwitchEditor = class extends AbstractFormElement {
294
+ async getValue() {
295
+ const inputEl = await this.getElement();
296
+ const result = await inputEl.getAttribute("aria-label");
297
+ if (result === "ON")
298
+ return 1;
299
+ if (result === "OFF")
300
+ return 0;
301
+ return void 0;
302
+ }
303
+ async setValue(value) {
304
+ if (value !== 0 && value !== 1) {
305
+ value = value ? 1 : 0;
306
+ }
307
+ const inputEl = await this.getElement();
308
+ const currentValue = await this.getValue();
309
+ if (currentValue !== value) {
310
+ await inputEl.click();
311
+ await this.driver.wait(async () => {
312
+ const updatedValue = await this.getValue();
313
+ return updatedValue !== currentValue;
314
+ });
315
+ }
316
+ }
317
+ };
318
+
292
319
  // src/pageObjects/elements/Editors/editorFactory.ts
293
320
  var editorFactory = async (getParentElement, elementBy, driver) => {
294
321
  const elementInstance = new AbstractFormElement(getParentElement, elementBy, driver);
@@ -302,6 +329,8 @@ var editorFactory = async (getParentElement, elementBy, driver) => {
302
329
  return new CheckBox(getParentElement, elementBy, driver);
303
330
  if (classSting.includes("select-control"))
304
331
  return new SelectBoxEditor(getParentElement, elementBy, driver);
332
+ if (classSting.includes("switch-control"))
333
+ return new SwitchEditor(getParentElement, elementBy, driver);
305
334
  throw new Error("Unknown type of editor. Please write ticket to the support");
306
335
  };
307
336
 
@@ -473,6 +502,27 @@ var Row = class extends AbstractElementWithParent {
473
502
  });
474
503
  return result;
475
504
  }
505
+ async clickInlineButton(rowClass, buttonClass) {
506
+ const fixedTable = await this.getParentElement().findElement(
507
+ By9.css(".dx-fixed-columns .dx-datagrid-content.dx-datagrid-content-fixed")
508
+ );
509
+ const rowEl = await fixedTable.findElement(By9.className(rowClass));
510
+ const button = await rowEl.findElement(By9.className(buttonClass));
511
+ if (button) {
512
+ return button.click();
513
+ }
514
+ throw new Error(`Cannot find ${buttonClass} button`);
515
+ }
516
+ async edit() {
517
+ await this.select();
518
+ return this.clickInlineButton("dx-selection", "edit");
519
+ }
520
+ async save() {
521
+ return this.clickInlineButton("dx-edit-row", "save");
522
+ }
523
+ async cancel() {
524
+ return this.clickInlineButton("dx-edit-row", "cancel");
525
+ }
476
526
  };
477
527
 
478
528
  // src/pageObjects/elements/Table/elements/Column.ts
@@ -582,6 +632,11 @@ var TableToolbarButton = class extends AbstractElementWithParent {
582
632
  const button = await this.getElement();
583
633
  return button.click();
584
634
  }
635
+ async isDisabled() {
636
+ const button = await this.getElement();
637
+ const result = await button.getAttribute("aria-disabled");
638
+ return result === "true";
639
+ }
585
640
  };
586
641
 
587
642
  // src/pageObjects/elements/TableToolbar/TableToolbar.ts
@@ -289,6 +289,33 @@ var SelectBoxEditor = class extends AbstractDXEditorWithInput {
289
289
  }
290
290
  };
291
291
 
292
+ // src/pageObjects/elements/Editors/SwitchEditor.ts
293
+ var SwitchEditor = class extends AbstractFormElement {
294
+ async getValue() {
295
+ const inputEl = await this.getElement();
296
+ const result = await inputEl.getAttribute("aria-label");
297
+ if (result === "ON")
298
+ return 1;
299
+ if (result === "OFF")
300
+ return 0;
301
+ return void 0;
302
+ }
303
+ async setValue(value) {
304
+ if (value !== 0 && value !== 1) {
305
+ value = value ? 1 : 0;
306
+ }
307
+ const inputEl = await this.getElement();
308
+ const currentValue = await this.getValue();
309
+ if (currentValue !== value) {
310
+ await inputEl.click();
311
+ await this.driver.wait(async () => {
312
+ const updatedValue = await this.getValue();
313
+ return updatedValue !== currentValue;
314
+ });
315
+ }
316
+ }
317
+ };
318
+
292
319
  // src/pageObjects/elements/Editors/editorFactory.ts
293
320
  var editorFactory = async (getParentElement, elementBy, driver) => {
294
321
  const elementInstance = new AbstractFormElement(getParentElement, elementBy, driver);
@@ -302,6 +329,8 @@ var editorFactory = async (getParentElement, elementBy, driver) => {
302
329
  return new CheckBox(getParentElement, elementBy, driver);
303
330
  if (classSting.includes("select-control"))
304
331
  return new SelectBoxEditor(getParentElement, elementBy, driver);
332
+ if (classSting.includes("switch-control"))
333
+ return new SwitchEditor(getParentElement, elementBy, driver);
305
334
  throw new Error("Unknown type of editor. Please write ticket to the support");
306
335
  };
307
336
 
@@ -473,6 +502,27 @@ var Row = class extends AbstractElementWithParent {
473
502
  });
474
503
  return result;
475
504
  }
505
+ async clickInlineButton(rowClass, buttonClass) {
506
+ const fixedTable = await this.getParentElement().findElement(
507
+ By9.css(".dx-fixed-columns .dx-datagrid-content.dx-datagrid-content-fixed")
508
+ );
509
+ const rowEl = await fixedTable.findElement(By9.className(rowClass));
510
+ const button = await rowEl.findElement(By9.className(buttonClass));
511
+ if (button) {
512
+ return button.click();
513
+ }
514
+ throw new Error(`Cannot find ${buttonClass} button`);
515
+ }
516
+ async edit() {
517
+ await this.select();
518
+ return this.clickInlineButton("dx-selection", "edit");
519
+ }
520
+ async save() {
521
+ return this.clickInlineButton("dx-edit-row", "save");
522
+ }
523
+ async cancel() {
524
+ return this.clickInlineButton("dx-edit-row", "cancel");
525
+ }
476
526
  };
477
527
 
478
528
  // src/pageObjects/elements/Table/elements/Column.ts
@@ -582,6 +632,11 @@ var TableToolbarButton = class extends AbstractElementWithParent {
582
632
  const button = await this.getElement();
583
633
  return button.click();
584
634
  }
635
+ async isDisabled() {
636
+ const button = await this.getElement();
637
+ const result = await button.getAttribute("aria-disabled");
638
+ return result === "true";
639
+ }
585
640
  };
586
641
 
587
642
  // src/pageObjects/elements/TableToolbar/TableToolbar.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "d5-testing-library",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "e2e testing D5 projects",
5
5
  "main": "dist/cjs/d5-testing-library.cjs",
6
6
  "module": "dist/d5-testing-library.legacy-esm.js",