@uuv/playwright 3.38.0 → 3.40.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.
@@ -456,6 +456,56 @@ function getConfigDir() {
456
456
  await (0, test_1.expect)(foundedElement).toEqual(expectedElementsOfList.raw());
457
457
  });
458
458
  });
459
+ /**
460
+ * Checks that there is a grid with the specified [name](https://russmaxdesign.github.io/html-elements-names/) containing list items.<br/> <u>Example</u>\n```gherkin\nWhen I visit path "https://e2e-test-quest.github.io/simple-webapp/grid.html"\nThen I should see a grid named "HTML Grid Example" and containing\n| Make | Model | Price |\n| ------------ | ------- | ------ |\n| Toyota | Celica | 35000 |\n| Ford | Mondeo | 32000 |\n| Porsche | Boxster | 72000 |\n| BMW | M50 | 60000 |\n| Aston Martin | DBX | 190000 |\n```
461
+ * */
462
+ (0, world_1.Then)(`I should see a grid named {string} and containing`, async function (expectedListName, pExpectedElementsOfList) {
463
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
464
+ await (0, core_engine_1.findWithRoleAndName)(this, "grid", expectedListName);
465
+ await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
466
+ await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
467
+ });
468
+ });
469
+ /**
470
+ * Checks that there is a treegrid with the specified [name](https://russmaxdesign.github.io/html-elements-names/) containing list items.<br/> <u>Example</u>\n```gherkin\nWhen I visit path "https://e2e-test-quest.github.io/simple-webapp/treegrid.html"\nThen I should see a treegrid named "HTML Treegrid Example" and containing\n| Make | Model | Price |\n| ------------ | ------- | ------ |\n| Toyota | Celica | 35000 |\n| Ford | Mondeo | 32000 |\n| Porsche | Boxster | 72000 |\n| BMW | M50 | 60000 |\n| Aston Martin | DBX | 190000 |\n```
471
+ * */
472
+ (0, world_1.Then)(`I should see a treegrid named {string} and containing`, async function (expectedListName, pExpectedElementsOfList) {
473
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
474
+ await (0, core_engine_1.findWithRoleAndName)(this, "treegrid", expectedListName);
475
+ await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
476
+ await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
477
+ });
478
+ });
479
+ /**
480
+ * Checks that there is a table with the specified [name](https://russmaxdesign.github.io/html-elements-names/) containing list items.<br/> <u>Example</u>\n```gherkin\nWhen I visit path "https://e2e-test-quest.github.io/simple-webapp/table.html"\nThen I should see a table named "test-list" and containing\n| Company | Contact | Country |\n| ----------------------------- | ---------------- | ------- |\n| Alfreds Futterkiste | Maria Anders | Germany |\n| Centro comercial Moctezuma | Francisco Chang | Mexico |\n| Ernst Handel | Roland Mendel | Austria |\n| Island Trading | Helen Bennett | UK |\n| Laughing Bacchus Winecellars | Yoshi Tannamuri | Canada |\n| Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |\n```
481
+ * */
482
+ (0, world_1.Then)(`I should see a table named {string} and containing`, async function (expectedListName, pExpectedElementsOfList) {
483
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
484
+ await (0, core_engine_1.findWithRoleAndName)(this, "table", expectedListName);
485
+ await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
486
+ await expectTableToHaveContent(element, expectedElementsOfList, "cell");
487
+ });
488
+ });
489
+ function removeHeaderSeparatorLine(pExpectedElementsOfList) {
490
+ const expectedElementsOfList = pExpectedElementsOfList.raw();
491
+ if (expectedElementsOfList.length > 1) {
492
+ expectedElementsOfList.splice(1, 1);
493
+ }
494
+ return expectedElementsOfList;
495
+ }
496
+ async function expectTableToHaveContent(element, expectedElementsOfList, pCellAccessibleRole) {
497
+ const rows = await element.getByRole("row", { exact: true }).all();
498
+ return await Promise.all(rows.map(async (row, rowNumber) => {
499
+ const cellAccessibleRole = rowNumber === 0 ? "columnheader" : pCellAccessibleRole;
500
+ const cellsElement = await row.getByRole(cellAccessibleRole, { exact: true }).all();
501
+ let cellNumber = 0;
502
+ return await Promise.all(cellsElement.map((cell) => {
503
+ const expectedValue = expectedElementsOfList[rowNumber][cellNumber];
504
+ (0, test_1.expect)(cell, { message: `${cellAccessibleRole} at index [${rowNumber}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
505
+ cellNumber++;
506
+ }));
507
+ }));
508
+ }
459
509
  async function pressKey(world, key) {
460
510
  switch (key) {
461
511
  case runner_commons_1.KEY_PRESS.TAB:
@@ -456,6 +456,56 @@ function getConfigDir() {
456
456
  await (0, test_1.expect)(foundedElement).toEqual(expectedElementsOfList.raw());
457
457
  });
458
458
  });
459
+ /**
460
+ * Vérifie qu'il existe une grille (grid) avec le nom et les éléments spécifiés.<br/> <u>Exemple</u>\n```gherkin\nQuand je visite l'Url "https://e2e-test-quest.github.io/simple-webapp/grid.html"\nAlors je dois voir une liste nommée "HTML Grid Example" et contenant\n| Make | Model | Price |\n| ------------ | ------- | ------ |\n| Toyota | Celica | 35000 |\n| Ford | Mondeo | 32000 |\n| Porsche | Boxster | 72000 |\n| BMW | M50 | 60000 |\n| Aston Martin | DBX | 190000 |\n```
461
+ * */
462
+ (0, world_1.Then)(`je dois voir une grille nommée {string} et contenant`, async function (expectedListName, pExpectedElementsOfList) {
463
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
464
+ await (0, core_engine_1.findWithRoleAndName)(this, "grid", expectedListName);
465
+ await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
466
+ await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
467
+ });
468
+ });
469
+ /**
470
+ * Vérifie qu'il existe une grille arborescente (treegrid) avec le nom et les éléments spécifiés.<br/> <u>Exemple</u>\n```gherkin\nQuand je visite l'Url "https://e2e-test-quest.github.io/simple-webapp/treegrid.html"\nAlors je dois voir une liste nommée "HTML Treegrid Example" et contenant\n| Make | Model | Price |\n| ------------ | ------- | ------ |\n| Toyota | Celica | 35000 |\n| Ford | Mondeo | 32000 |\n| Porsche | Boxster | 72000 |\n| BMW | M50 | 60000 |\n| Aston Martin | DBX | 190000 |\n```
471
+ * */
472
+ (0, world_1.Then)(`je dois voir une grille arborescente nommée {string} et contenant`, async function (expectedListName, pExpectedElementsOfList) {
473
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
474
+ await (0, core_engine_1.findWithRoleAndName)(this, "treegrid", expectedListName);
475
+ await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
476
+ await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
477
+ });
478
+ });
479
+ /**
480
+ * Vérifie qu'il existe un tableau (table) avec le nom et les éléments spécifiés.<br/> <u>Exemple</u>\n```gherkin\nQuand je visite l'Url "https://e2e-test-quest.github.io/simple-webapp/table.html"\nAlors je dois voir un tableau nommée "HTML Table Example" et contenant\n| Company | Contact | Country |\n| ----------------------------- | ---------------- | ------- |\n| Alfreds Futterkiste | Maria Anders | Germany |\n| Centro comercial Moctezuma | Francisco Chang | Mexico |\n| Ernst Handel | Roland Mendel | Austria |\n| Island Trading | Helen Bennett | UK |\n| Laughing Bacchus Winecellars | Yoshi Tannamuri | Canada |\n| Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |\n```
481
+ * */
482
+ (0, world_1.Then)(`je dois voir un tableau nommé {string} et contenant`, async function (expectedListName, pExpectedElementsOfList) {
483
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
484
+ await (0, core_engine_1.findWithRoleAndName)(this, "table", expectedListName);
485
+ await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
486
+ await expectTableToHaveContent(element, expectedElementsOfList, "cell");
487
+ });
488
+ });
489
+ function removeHeaderSeparatorLine(pExpectedElementsOfList) {
490
+ const expectedElementsOfList = pExpectedElementsOfList.raw();
491
+ if (expectedElementsOfList.length > 1) {
492
+ expectedElementsOfList.splice(1, 1);
493
+ }
494
+ return expectedElementsOfList;
495
+ }
496
+ async function expectTableToHaveContent(element, expectedElementsOfList, pCellAccessibleRole) {
497
+ const rows = await element.getByRole("row", { exact: true }).all();
498
+ return await Promise.all(rows.map(async (row, rowNumber) => {
499
+ const cellAccessibleRole = rowNumber === 0 ? "columnheader" : pCellAccessibleRole;
500
+ const cellsElement = await row.getByRole(cellAccessibleRole, { exact: true }).all();
501
+ let cellNumber = 0;
502
+ return await Promise.all(cellsElement.map((cell) => {
503
+ const expectedValue = expectedElementsOfList[rowNumber][cellNumber];
504
+ (0, test_1.expect)(cell, { message: `${cellAccessibleRole} at index [${rowNumber}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
505
+ cellNumber++;
506
+ }));
507
+ }));
508
+ }
459
509
  async function pressKey(world, key) {
460
510
  switch (key) {
461
511
  case runner_commons_1.KEY_PRESS.TAB:
@@ -22,19 +22,19 @@ const test_1 = require("@playwright/test");
22
22
  /**
23
23
  * Sélectionne l'élément ayant le rôle table et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) sont spécifiés <br />⚠ pensez à déselectionner l'élement avec <b>[je reinitialise le contexte](#je-reinitialise-le-contexte)</b> si vous n'agissez plus dessus
24
24
  * */
25
- (0, world_1.When)(`je vais à l'intérieur de la tableau nommée {string}`, async function (name) {
25
+ (0, world_1.When)(`je vais à l'intérieur du tableau nommé {string}`, async function (name) {
26
26
  return await (0, core_engine_1.withinRoleAndName)(this, "table", name);
27
27
  });
28
28
  /**
29
29
  * Vérifie l'existence d'un élément Html ayant le rôle table et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) spécifiés
30
30
  * */
31
- (0, world_1.Then)(`je dois voir une tableau nommée {string}`, async function (name) {
31
+ (0, world_1.Then)(`je dois voir un tableau nommé {string}`, async function (name) {
32
32
  await (0, core_engine_1.findWithRoleAndName)(this, "table", name);
33
33
  });
34
34
  /**
35
35
  * Vérifie l'inexistence d'un élément Html ayant le rôle table et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) spécifiés
36
36
  * */
37
- (0, world_1.Then)(`je ne dois pas voir une tableau nommée {string}`, async function (name) {
37
+ (0, world_1.Then)(`je ne dois pas voir un tableau nommé {string}`, async function (name) {
38
38
  await (0, core_engine_1.notFoundWithRoleAndName)(this, "table", name);
39
39
  });
40
40
  // End of General Section
@@ -42,7 +42,7 @@ const test_1 = require("@playwright/test");
42
42
  /**
43
43
  * Saisie de la phrase passée en paramètre dans le champ spécifié (utile par exemple pour remplir un champ de formulaire).
44
44
  * */
45
- (0, world_1.When)(`je saisie le(s) mot(s) {string} dans le tableau nommée {string}`, async function (textToType, name) {
45
+ (0, world_1.When)(`je saisie le(s) mot(s) {string} dans le tableau nommé {string}`, async function (textToType, name) {
46
46
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
47
47
  const byRole = await element.getByRole("table", { name: name, exact: true });
48
48
  await (0, test_1.expect)(byRole).toHaveCount(1, { timeout: await (0, core_engine_1.getTimeout)(this) });
@@ -53,7 +53,7 @@ const test_1 = require("@playwright/test");
53
53
  /**
54
54
  * Saisie de la phrase passée en paramètre dans le champ spécifié (utile par exemple pour remplir un champ de formulaire).
55
55
  * */
56
- (0, world_1.When)(`j'entre la valeur {string} dans le tableau nommée {string}`, async function (textToType, name) {
56
+ (0, world_1.When)(`j'entre la valeur {string} dans le tableau nommé {string}`, async function (textToType, name) {
57
57
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
58
58
  const byRole = await element.getByRole("table", { name: name, includeHidden: true, exact: true });
59
59
  await (0, test_1.expect)(byRole).toHaveCount(1);
@@ -66,19 +66,19 @@ const test_1 = require("@playwright/test");
66
66
  /**
67
67
  * Vérifie l'existence d'un élément Html ayant le rôle table, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et le contenu spécifiés
68
68
  * */
69
- (0, world_1.Then)(`je dois voir une tableau nommée {string} et contenant {string}`, async function (name, expectedTextContent) {
69
+ (0, world_1.Then)(`je dois voir un tableau nommé {string} et contenant {string}`, async function (name, expectedTextContent) {
70
70
  await (0, core_engine_1.findWithRoleAndNameAndContent)(this, "table", name, expectedTextContent);
71
71
  });
72
72
  /**
73
73
  * Vérifie l'existence d'un élément Html ayant le rôle table, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/), le contenu spécifiés et avec l'attribut disabled à false
74
74
  * */
75
- (0, world_1.Then)(`je dois voir une tableau nommée {string} et contenant {string} inactif`, async function (name, expectedTextContent) {
75
+ (0, world_1.Then)(`je dois voir un tableau nommé {string} et contenant {string} inactif`, async function (name, expectedTextContent) {
76
76
  await (0, core_engine_1.findWithRoleAndNameAndContentDisable)(this, "table", name, expectedTextContent);
77
77
  });
78
78
  /**
79
79
  * Vérifie l'existence d'un élément Html ayant le rôle table, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/), le contenu spécifiés et avec l'attribut disabled à true
80
80
  * */
81
- (0, world_1.Then)(`je dois voir une tableau nommée {string} et contenant {string} actif`, async function (name, expectedTextContent) {
81
+ (0, world_1.Then)(`je dois voir un tableau nommé {string} et contenant {string} actif`, async function (name, expectedTextContent) {
82
82
  await (0, core_engine_1.findWithRoleAndNameAndContentEnable)(this, "table", name, expectedTextContent);
83
83
  });
84
84
  // End of Content Section
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uuv/playwright",
3
- "version": "3.38.0",
3
+ "version": "3.40.0",
4
4
  "type": "commonjs",
5
5
  "author": "Louis Fredice NJAKO MOLOM (https://github.com/luifr10) & Stanley SERVICAL (https://github.com/stanlee974)",
6
6
  "description": "A solution to facilitate the writing and execution of E2E tests understandable by any human being using cucumber(BDD) and playwright",
@@ -47,7 +47,7 @@
47
47
  "@cucumber/tag-expressions": "6.2.0",
48
48
  "@playwright/test": "1.52.0",
49
49
  "@uuv/a11y": "1.0.0-beta.71",
50
- "@uuv/runner-commons": "2.51.0",
50
+ "@uuv/runner-commons": "2.53.0",
51
51
  "axe-core": "4.10.3",
52
52
  "axe-playwright": "2.1.0",
53
53
  "chalk-table": "1.0.2",
@@ -34,14 +34,14 @@ import {
34
34
  findWithRoleAndNameFocused,
35
35
  getCookie,
36
36
  getPageOrElement,
37
+ getTimeout,
37
38
  MockCookie,
38
39
  notFoundWithRoleAndName,
39
40
  SelectedElementCookie,
40
41
  TimeoutCookie,
41
- withinRoleAndName,
42
- getTimeout
42
+ withinRoleAndName
43
43
  } from "../core-engine";
44
- import { World, Given, Then, When } from "../../../preprocessor/run/world";
44
+ import { Given, Then, When, World } from "../../../preprocessor/run/world";
45
45
  import { ContextObject, RunOptions } from "axe-core";
46
46
  import path from "path";
47
47
 
@@ -586,6 +586,70 @@ Then(
586
586
  }
587
587
  );
588
588
 
589
+ /**
590
+ * Checks that there is a grid with the specified [name](https://russmaxdesign.github.io/html-elements-names/) containing list items.<br/> <u>Example</u>\n```gherkin\nWhen I visit path "https://e2e-test-quest.github.io/simple-webapp/grid.html"\nThen I should see a grid named "HTML Grid Example" and containing\n| Make | Model | Price |\n| ------------ | ------- | ------ |\n| Toyota | Celica | 35000 |\n| Ford | Mondeo | 32000 |\n| Porsche | Boxster | 72000 |\n| BMW | M50 | 60000 |\n| Aston Martin | DBX | 190000 |\n```
591
+ * */
592
+ Then(
593
+ `I should see a grid named {string} and containing`,
594
+ async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
595
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
596
+ await findWithRoleAndName(this, "grid", expectedListName);
597
+ await getPageOrElement(this).then(async (element) => {
598
+ await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
599
+ });
600
+ }
601
+ );
602
+
603
+ /**
604
+ * Checks that there is a treegrid with the specified [name](https://russmaxdesign.github.io/html-elements-names/) containing list items.<br/> <u>Example</u>\n```gherkin\nWhen I visit path "https://e2e-test-quest.github.io/simple-webapp/treegrid.html"\nThen I should see a treegrid named "HTML Treegrid Example" and containing\n| Make | Model | Price |\n| ------------ | ------- | ------ |\n| Toyota | Celica | 35000 |\n| Ford | Mondeo | 32000 |\n| Porsche | Boxster | 72000 |\n| BMW | M50 | 60000 |\n| Aston Martin | DBX | 190000 |\n```
605
+ * */
606
+ Then(
607
+ `I should see a treegrid named {string} and containing`,
608
+ async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
609
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
610
+ await findWithRoleAndName(this, "treegrid", expectedListName);
611
+ await getPageOrElement(this).then(async (element) => {
612
+ await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
613
+ });
614
+ }
615
+ );
616
+
617
+ /**
618
+ * Checks that there is a table with the specified [name](https://russmaxdesign.github.io/html-elements-names/) containing list items.<br/> <u>Example</u>\n```gherkin\nWhen I visit path "https://e2e-test-quest.github.io/simple-webapp/table.html"\nThen I should see a table named "test-list" and containing\n| Company | Contact | Country |\n| ----------------------------- | ---------------- | ------- |\n| Alfreds Futterkiste | Maria Anders | Germany |\n| Centro comercial Moctezuma | Francisco Chang | Mexico |\n| Ernst Handel | Roland Mendel | Austria |\n| Island Trading | Helen Bennett | UK |\n| Laughing Bacchus Winecellars | Yoshi Tannamuri | Canada |\n| Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |\n```
619
+ * */
620
+ Then(
621
+ `I should see a table named {string} and containing`,
622
+ async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
623
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
624
+ await findWithRoleAndName(this, "table", expectedListName);
625
+ await getPageOrElement(this).then(async (element) => {
626
+ await expectTableToHaveContent(element, expectedElementsOfList, "cell");
627
+ });
628
+ }
629
+ );
630
+
631
+ function removeHeaderSeparatorLine(pExpectedElementsOfList: DataTable) {
632
+ const expectedElementsOfList = pExpectedElementsOfList.raw();
633
+ if (expectedElementsOfList.length > 1) {
634
+ expectedElementsOfList.splice(1, 1);
635
+ }
636
+ return expectedElementsOfList;
637
+ }
638
+
639
+ async function expectTableToHaveContent(element: Locator, expectedElementsOfList: string[][], pCellAccessibleRole: string) {
640
+ const rows = await element.getByRole("row", { exact: true }).all();
641
+ return await Promise.all(rows.map(async (row: Locator, rowNumber: number) => {
642
+ const cellAccessibleRole = rowNumber === 0 ? "columnheader" : pCellAccessibleRole;
643
+ const cellsElement = await row.getByRole(cellAccessibleRole as any, { exact: true }).all();
644
+ let cellNumber = 0;
645
+ return await Promise.all(cellsElement.map((cell: Locator) => {
646
+ const expectedValue = expectedElementsOfList[rowNumber][cellNumber];
647
+ expect(cell, { message: `${cellAccessibleRole} at index [${rowNumber}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
648
+ cellNumber++;
649
+ }));
650
+ }));
651
+ }
652
+
589
653
  async function pressKey(world: World, key: string) {
590
654
  switch (key) {
591
655
  case KEY_PRESS.TAB:
@@ -34,14 +34,14 @@ import {
34
34
  findWithRoleAndNameFocused,
35
35
  getCookie,
36
36
  getPageOrElement,
37
+ getTimeout,
37
38
  MockCookie,
38
39
  notFoundWithRoleAndName,
39
40
  SelectedElementCookie,
40
41
  TimeoutCookie,
41
- withinRoleAndName,
42
- getTimeout
42
+ withinRoleAndName
43
43
  } from "../core-engine";
44
- import { World, Given, Then, When } from "../../../preprocessor/run/world";
44
+ import { Given, Then, When, World } from "../../../preprocessor/run/world";
45
45
  import { ContextObject, RunOptions } from "axe-core";
46
46
  import path from "path";
47
47
 
@@ -586,6 +586,70 @@ Then(
586
586
  }
587
587
  );
588
588
 
589
+ /**
590
+ * Vérifie qu'il existe une grille (grid) avec le nom et les éléments spécifiés.<br/> <u>Exemple</u>\n```gherkin\nQuand je visite l'Url "https://e2e-test-quest.github.io/simple-webapp/grid.html"\nAlors je dois voir une liste nommée "HTML Grid Example" et contenant\n| Make | Model | Price |\n| ------------ | ------- | ------ |\n| Toyota | Celica | 35000 |\n| Ford | Mondeo | 32000 |\n| Porsche | Boxster | 72000 |\n| BMW | M50 | 60000 |\n| Aston Martin | DBX | 190000 |\n```
591
+ * */
592
+ Then(
593
+ `je dois voir une grille nommée {string} et contenant`,
594
+ async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
595
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
596
+ await findWithRoleAndName(this, "grid", expectedListName);
597
+ await getPageOrElement(this).then(async (element) => {
598
+ await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
599
+ });
600
+ }
601
+ );
602
+
603
+ /**
604
+ * Vérifie qu'il existe une grille arborescente (treegrid) avec le nom et les éléments spécifiés.<br/> <u>Exemple</u>\n```gherkin\nQuand je visite l'Url "https://e2e-test-quest.github.io/simple-webapp/treegrid.html"\nAlors je dois voir une liste nommée "HTML Treegrid Example" et contenant\n| Make | Model | Price |\n| ------------ | ------- | ------ |\n| Toyota | Celica | 35000 |\n| Ford | Mondeo | 32000 |\n| Porsche | Boxster | 72000 |\n| BMW | M50 | 60000 |\n| Aston Martin | DBX | 190000 |\n```
605
+ * */
606
+ Then(
607
+ `je dois voir une grille arborescente nommée {string} et contenant`,
608
+ async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
609
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
610
+ await findWithRoleAndName(this, "treegrid", expectedListName);
611
+ await getPageOrElement(this).then(async (element) => {
612
+ await expectTableToHaveContent(element, expectedElementsOfList, "gridcell");
613
+ });
614
+ }
615
+ );
616
+
617
+ /**
618
+ * Vérifie qu'il existe un tableau (table) avec le nom et les éléments spécifiés.<br/> <u>Exemple</u>\n```gherkin\nQuand je visite l'Url "https://e2e-test-quest.github.io/simple-webapp/table.html"\nAlors je dois voir un tableau nommée "HTML Table Example" et contenant\n| Company | Contact | Country |\n| ----------------------------- | ---------------- | ------- |\n| Alfreds Futterkiste | Maria Anders | Germany |\n| Centro comercial Moctezuma | Francisco Chang | Mexico |\n| Ernst Handel | Roland Mendel | Austria |\n| Island Trading | Helen Bennett | UK |\n| Laughing Bacchus Winecellars | Yoshi Tannamuri | Canada |\n| Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |\n```
619
+ * */
620
+ Then(
621
+ `je dois voir un tableau nommé {string} et contenant`,
622
+ async function(expectedListName: string, pExpectedElementsOfList: DataTable) {
623
+ const expectedElementsOfList = removeHeaderSeparatorLine(pExpectedElementsOfList);
624
+ await findWithRoleAndName(this, "table", expectedListName);
625
+ await getPageOrElement(this).then(async (element) => {
626
+ await expectTableToHaveContent(element, expectedElementsOfList, "cell");
627
+ });
628
+ }
629
+ );
630
+
631
+ function removeHeaderSeparatorLine(pExpectedElementsOfList: DataTable) {
632
+ const expectedElementsOfList = pExpectedElementsOfList.raw();
633
+ if (expectedElementsOfList.length > 1) {
634
+ expectedElementsOfList.splice(1, 1);
635
+ }
636
+ return expectedElementsOfList;
637
+ }
638
+
639
+ async function expectTableToHaveContent(element: Locator, expectedElementsOfList: string[][], pCellAccessibleRole: string) {
640
+ const rows = await element.getByRole("row", { exact: true }).all();
641
+ return await Promise.all(rows.map(async (row: Locator, rowNumber: number) => {
642
+ const cellAccessibleRole = rowNumber === 0 ? "columnheader" : pCellAccessibleRole;
643
+ const cellsElement = await row.getByRole(cellAccessibleRole as any, { exact: true }).all();
644
+ let cellNumber = 0;
645
+ return await Promise.all(cellsElement.map((cell: Locator) => {
646
+ const expectedValue = expectedElementsOfList[rowNumber][cellNumber];
647
+ expect(cell, { message: `${cellAccessibleRole} at index [${rowNumber}, ${cellNumber}] should be ${expectedValue}` }).toHaveAccessibleName(expectedValue);
648
+ cellNumber++;
649
+ }));
650
+ }));
651
+ }
652
+
589
653
  async function pressKey(world: World, key: string) {
590
654
  switch (key) {
591
655
  case KEY_PRESS.TAB:
@@ -40,14 +40,14 @@ import { expect } from "@playwright/test";
40
40
  /**
41
41
  * Sélectionne l'élément ayant le rôle table et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) sont spécifiés <br />⚠ pensez à déselectionner l'élement avec <b>[je reinitialise le contexte](#je-reinitialise-le-contexte)</b> si vous n'agissez plus dessus
42
42
  * */
43
- When(`je vais à l'intérieur de la tableau nommée {string}`, async function(name: string) {
43
+ When(`je vais à l'intérieur du tableau nommé {string}`, async function(name: string) {
44
44
  return await withinRoleAndName(this, "table", name);
45
45
  });
46
46
 
47
47
  /**
48
48
  * Vérifie l'existence d'un élément Html ayant le rôle table et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) spécifiés
49
49
  * */
50
- Then(`je dois voir une tableau nommée {string}`, async function(name: string) {
50
+ Then(`je dois voir un tableau nommé {string}`, async function(name: string) {
51
51
  await findWithRoleAndName(this, "table", name);
52
52
  });
53
53
 
@@ -55,7 +55,7 @@ Then(`je dois voir une tableau nommée {string}`, async function(name: string) {
55
55
  * Vérifie l'inexistence d'un élément Html ayant le rôle table et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) spécifiés
56
56
  * */
57
57
  Then(
58
- `je ne dois pas voir une tableau nommée {string}`,
58
+ `je ne dois pas voir un tableau nommé {string}`,
59
59
  async function(name: string) {
60
60
  await notFoundWithRoleAndName(this, "table", name);
61
61
  }
@@ -68,7 +68,7 @@ Then(
68
68
  /**
69
69
  * Saisie de la phrase passée en paramètre dans le champ spécifié (utile par exemple pour remplir un champ de formulaire).
70
70
  * */
71
- When(`je saisie le(s) mot(s) {string} dans le tableau nommée {string}`, async function(textToType: string, name: string) {
71
+ When(`je saisie le(s) mot(s) {string} dans le tableau nommé {string}`, async function(textToType: string, name: string) {
72
72
  await getPageOrElement(this).then(async (element) => {
73
73
  const byRole = await element.getByRole("table", { name: name, exact: true });
74
74
  await expect(byRole).toHaveCount(1, { timeout: await getTimeout(this) });
@@ -80,7 +80,7 @@ When(`je saisie le(s) mot(s) {string} dans le tableau nommée {string}`, async f
80
80
  /**
81
81
  * Saisie de la phrase passée en paramètre dans le champ spécifié (utile par exemple pour remplir un champ de formulaire).
82
82
  * */
83
- When(`j'entre la valeur {string} dans le tableau nommée {string}`, async function(textToType: string, name: string) {
83
+ When(`j'entre la valeur {string} dans le tableau nommé {string}`, async function(textToType: string, name: string) {
84
84
  await getPageOrElement(this).then(async (element) => {
85
85
  const byRole = await element.getByRole("table", { name: name, includeHidden: true, exact: true });
86
86
  await expect(byRole).toHaveCount(1);
@@ -96,7 +96,7 @@ When(`j'entre la valeur {string} dans le tableau nommée {string}`, async functi
96
96
  * Vérifie l'existence d'un élément Html ayant le rôle table, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et le contenu spécifiés
97
97
  * */
98
98
  Then(
99
- `je dois voir une tableau nommée {string} et contenant {string}`,
99
+ `je dois voir un tableau nommé {string} et contenant {string}`,
100
100
  async function(name: string, expectedTextContent: string) {
101
101
  await findWithRoleAndNameAndContent(this, "table", name, expectedTextContent);
102
102
  }
@@ -106,7 +106,7 @@ Then(
106
106
  * Vérifie l'existence d'un élément Html ayant le rôle table, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/), le contenu spécifiés et avec l'attribut disabled à false
107
107
  * */
108
108
  Then(
109
- `je dois voir une tableau nommée {string} et contenant {string} inactif`,
109
+ `je dois voir un tableau nommé {string} et contenant {string} inactif`,
110
110
  async function(name: string, expectedTextContent: string) {
111
111
  await findWithRoleAndNameAndContentDisable(this, "table", name, expectedTextContent);
112
112
  }
@@ -116,7 +116,7 @@ Then(
116
116
  * Vérifie l'existence d'un élément Html ayant le rôle table, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/), le contenu spécifiés et avec l'attribut disabled à true
117
117
  * */
118
118
  Then(
119
- `je dois voir une tableau nommée {string} et contenant {string} actif`,
119
+ `je dois voir un tableau nommé {string} et contenant {string} actif`,
120
120
  async function(name: string, expectedTextContent: string) {
121
121
  await findWithRoleAndNameAndContentEnable(this, "table", name, expectedTextContent);
122
122
  }