@uuv/playwright 1.8.1 → 1.9.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.
@@ -29,9 +29,15 @@ const cucumber_1 = require("@cucumber/cucumber");
29
29
  await (0, core_engine_1.deleteCookieByName)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
30
30
  await this.page.goto(`${siteUrl}`);
31
31
  });
32
- (0, cucumber_1.When)(`${runner_commons_1.key.when.click}`, async function () {
32
+ (0, cucumber_1.When)(`${runner_commons_1.key.when.click.withContext}`, async function () {
33
33
  await (0, core_engine_1.getPageOrElement)(this).then((element) => element.click({ timeout: runner_commons_1.DEFAULT_TIMEOUT }));
34
34
  });
35
+ (0, cucumber_1.When)(`${runner_commons_1.key.when.click.button}`, async function (name) {
36
+ await click(this, "button", name);
37
+ });
38
+ (0, cucumber_1.When)(`${runner_commons_1.key.when.click.withRole}`, async function (role, name) {
39
+ await click(this, role, name);
40
+ });
35
41
  // TODO : permet de gérer les label accessibles donc pas que les aria : https://playwright.dev/docs/api/class-locator#locator-get-by-label
36
42
  (0, cucumber_1.When)(`${runner_commons_1.key.when.withinElement.ariaLabel}`, async function (expectedAriaLabel) {
37
43
  const sanitizedExpectedAriaLabel = encodeURIComponent(expectedAriaLabel).replaceAll("%20", " ");
@@ -269,3 +275,11 @@ async function pressKey(world, element, key) {
269
275
  await (0, core_engine_1.deleteCookieByName)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
270
276
  await (0, core_engine_1.addCookieWhenValueIsList)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, { name: core_engine_1.FILTER_TYPE.SELECTOR_PARENT, value: "*:focus" });
271
277
  }
278
+ async function click(world, role, name) {
279
+ await (0, core_engine_1.getPageOrElement)(world).then(async (element) => {
280
+ const byRole = await element.getByRole(role, { name: name, includeHidden: true, exact: true });
281
+ await (0, test_1.expect)(byRole).toHaveCount(1);
282
+ await byRole.click({ timeout: runner_commons_1.DEFAULT_TIMEOUT });
283
+ await world.context.clearCookies();
284
+ });
285
+ }
@@ -43,10 +43,10 @@ export declare function addCookieWhenValueIsList(world: World, cookieName: COOKI
43
43
  export declare function getCookie(world: World, cookieName: COOKIE_NAME): Promise<Cookie>;
44
44
  export declare function deleteCookieByValue(world: World, cookieName: COOKIE_NAME, node: any): Promise<void>;
45
45
  export declare function deleteCookieByName(world: World, cookieName: COOKIE_NAME): Promise<void>;
46
- export declare function findWithRoleAndName(world: World, role: string, name: string): Promise<void>;
46
+ export declare function findWithRoleAndName(world: World, role: string, name: string): Promise<any>;
47
47
  export declare function withinRoleAndName(world: World, role: string, name: string): Promise<void>;
48
48
  export declare function notFoundWithRoleAndName(world: World, role: string, name: string): Promise<void>;
49
- export declare function findWithRoleAndNameAndContent(world: World, expectedRole: string, name: string, expectedTextContent?: string | undefined): Promise<void>;
49
+ export declare function findWithRoleAndNameAndContent(world: World, expectedRole: string, name: string, expectedTextContent?: string | undefined): Promise<any>;
50
50
  export declare function findWithRoleAndNameAndContentDisable(world: World, expectedRole: string, name: string, expectedTextContent: string): Promise<void>;
51
51
  export declare function findWithRoleAndNameAndContentEnable(world: World, expectedRole: string, name: string, expectedTextContent: string): Promise<void>;
52
52
  export declare function showAttributesInLocator(element: any): Promise<void>;
@@ -35,6 +35,12 @@ const cucumber_1 = require("@cucumber/cucumber");
35
35
  (0, cucumber_1.When)(`I click`, async function () {
36
36
  await (0, core_engine_1.getPageOrElement)(this).then((element) => element.click({ timeout: runner_commons_1.DEFAULT_TIMEOUT }));
37
37
  });
38
+ (0, cucumber_1.When)(`I click on button named {string}`, async function (name) {
39
+ await click(this, "button", name);
40
+ });
41
+ (0, cucumber_1.When)(`I click on element with role {string} and name {string}`, async function (role, name) {
42
+ await click(this, role, name);
43
+ });
38
44
  // TODO : permet de gérer les label accessibles donc pas que les aria : https://playwright.dev/docs/api/class-locator#locator-get-by-label
39
45
  (0, cucumber_1.When)(`Within the element with aria-label {string}`, async function (expectedAriaLabel) {
40
46
  const sanitizedExpectedAriaLabel = encodeURIComponent(expectedAriaLabel).replaceAll("%20", " ");
@@ -272,3 +278,11 @@ async function pressKey(world, element, key) {
272
278
  await (0, core_engine_1.deleteCookieByName)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
273
279
  await (0, core_engine_1.addCookieWhenValueIsList)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, { name: core_engine_1.FILTER_TYPE.SELECTOR_PARENT, value: "*:focus" });
274
280
  }
281
+ async function click(world, role, name) {
282
+ await (0, core_engine_1.getPageOrElement)(world).then(async (element) => {
283
+ const byRole = await element.getByRole(role, { name: name, includeHidden: true, exact: true });
284
+ await (0, test_1.expect)(byRole).toHaveCount(1);
285
+ await byRole.click({ timeout: runner_commons_1.DEFAULT_TIMEOUT });
286
+ await world.context.clearCookies();
287
+ });
288
+ }
@@ -35,6 +35,12 @@ const cucumber_1 = require("@cucumber/cucumber");
35
35
  (0, cucumber_1.When)(`je clique`, async function () {
36
36
  await (0, core_engine_1.getPageOrElement)(this).then((element) => element.click({ timeout: runner_commons_1.DEFAULT_TIMEOUT }));
37
37
  });
38
+ (0, cucumber_1.When)(`je clique sur le bouton nommé {string}`, async function (name) {
39
+ await click(this, "button", name);
40
+ });
41
+ (0, cucumber_1.When)(`je clique sur l'élément avec le rôle {string} et le nom {string}`, async function (role, name) {
42
+ await click(this, role, name);
43
+ });
38
44
  // TODO : permet de gérer les label accessibles donc pas que les aria : https://playwright.dev/docs/api/class-locator#locator-get-by-label
39
45
  (0, cucumber_1.When)(`je vais à l'intérieur de l'élément ayant pour aria-label {string}`, async function (expectedAriaLabel) {
40
46
  const sanitizedExpectedAriaLabel = encodeURIComponent(expectedAriaLabel).replaceAll("%20", " ");
@@ -272,3 +278,11 @@ async function pressKey(world, element, key) {
272
278
  await (0, core_engine_1.deleteCookieByName)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
273
279
  await (0, core_engine_1.addCookieWhenValueIsList)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, { name: core_engine_1.FILTER_TYPE.SELECTOR_PARENT, value: "*:focus" });
274
280
  }
281
+ async function click(world, role, name) {
282
+ await (0, core_engine_1.getPageOrElement)(world).then(async (element) => {
283
+ const byRole = await element.getByRole(role, { name: name, includeHidden: true, exact: true });
284
+ await (0, test_1.expect)(byRole).toHaveCount(1);
285
+ await byRole.click({ timeout: runner_commons_1.DEFAULT_TIMEOUT });
286
+ await world.context.clearCookies();
287
+ });
288
+ }
@@ -148,7 +148,6 @@ class UuvPlaywrightReporterHelper {
148
148
  }
149
149
  });
150
150
  this.envelopes.push(newTestStepSkippedEnvelope);
151
- this.consoleReportMap.get(featureFile)?.increment("skipped");
152
151
  });
153
152
  }
154
153
  }
@@ -477,11 +476,27 @@ class UuvPlaywrightReporterHelper {
477
476
  console.info(` ${this.getResultIcon(testCase)} ${this.getTestCaseTitle(testCase, result)}`);
478
477
  }
479
478
  getResultIcon(testCase) {
480
- return !testCase.ok() ? chalk_1.default.redBright("\u166D") : chalk_1.default.green("\u2713");
479
+ if (testCase.expectedStatus === "skipped") {
480
+ return chalk_1.default.yellowBright("\u2192");
481
+ }
482
+ else if (testCase.ok()) {
483
+ return chalk_1.default.green("\u2713");
484
+ }
485
+ else {
486
+ return chalk_1.default.redBright("\u166D");
487
+ }
481
488
  }
482
489
  getTestCaseTitle(testCase, result) {
483
490
  const message = `${testCase.title} (${result.duration}ms)`;
484
- return !testCase.ok() ? chalk_1.default.redBright(message) : chalk_1.default.gray(message);
491
+ if (testCase.expectedStatus === "skipped") {
492
+ return chalk_1.default.yellowBright(message);
493
+ }
494
+ else if (testCase.ok()) {
495
+ return chalk_1.default.gray(message);
496
+ }
497
+ else {
498
+ return chalk_1.default.redBright(message);
499
+ }
485
500
  }
486
501
  logTeamCity(line) {
487
502
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uuv/playwright",
3
- "version": "1.8.1",
3
+ "version": "1.9.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 run E2E tests written in cucumber(BDD) with playwright.",
@@ -46,7 +46,7 @@
46
46
  "dependencies": {
47
47
  "@cucumber/cucumber": "9.3.0",
48
48
  "@playwright/test": "1.33.0",
49
- "@uuv/runner-commons": "1.6.4",
49
+ "@uuv/runner-commons": "1.7.0",
50
50
  "axe-core": "4.7.2",
51
51
  "axe-playwright": "1.2.3",
52
52
  "chalk": "4.1.2",
@@ -89,7 +89,7 @@
89
89
  },
90
90
  "devDependencies": {
91
91
  "@types/minimist": "1.2.2",
92
- "@types/node": "16.18.39",
92
+ "@types/node": "16.18.50",
93
93
  "cross-env": "7.0.3",
94
94
  "eslint-plugin-cucumber": "2.0.0",
95
95
  "eslint-plugin-jest": "27.2.3",
@@ -24,7 +24,7 @@ import { devices, expect } from "@playwright/test";
24
24
  import { Page } from "playwright";
25
25
  import { DataTable } from "@cucumber/cucumber";
26
26
  import {
27
- addCookieWhenValueIsList,
27
+ addCookieWhenValueIsList, checkTextContentLocator,
28
28
  COOKIE_NAME, deleteCookieByName,
29
29
  deleteCookieByValue,
30
30
  FILTER_TYPE,
@@ -63,6 +63,15 @@ When(`I click`, async function(this: World) {
63
63
  await getPageOrElement(this).then((element: Locator) => element.click({ timeout: DEFAULT_TIMEOUT }));
64
64
  });
65
65
 
66
+
67
+ When(`I click on button named {string}`, async function(this: World, name: string) {
68
+ await click(this, "button", name);
69
+ });
70
+
71
+ When(`I click on element with role {string} and name {string}`, async function(this: World, role: string, name: string) {
72
+ await click(this, role, name);
73
+ });
74
+
66
75
  // TODO : permet de gérer les label accessibles donc pas que les aria : https://playwright.dev/docs/api/class-locator#locator-get-by-label
67
76
  When(`Within the element with aria-label {string}`, async function(this: World, expectedAriaLabel: string) {
68
77
  const sanitizedExpectedAriaLabel = encodeURIComponent(expectedAriaLabel).replaceAll("%20", " ");
@@ -381,4 +390,13 @@ async function pressKey(world: World, element: Locator, key: string) {
381
390
  await addCookieWhenValueIsList(world, COOKIE_NAME.SELECTED_ELEMENT, { name: FILTER_TYPE.SELECTOR_PARENT, value: "*:focus" });
382
391
  }
383
392
 
393
+ async function click(world: World, role: any, name: string) {
394
+ await getPageOrElement(world).then(async (element) => {
395
+ const byRole = await element.getByRole(role, { name: name, includeHidden: true, exact: true });
396
+ await expect(byRole).toHaveCount(1);
397
+ await byRole.click({ timeout: DEFAULT_TIMEOUT });
398
+ await world.context.clearCookies();
399
+ });
400
+ }
401
+
384
402
 
@@ -24,7 +24,7 @@ import { devices, expect } from "@playwright/test";
24
24
  import { Page } from "playwright";
25
25
  import { DataTable } from "@cucumber/cucumber";
26
26
  import {
27
- addCookieWhenValueIsList,
27
+ addCookieWhenValueIsList, checkTextContentLocator,
28
28
  COOKIE_NAME, deleteCookieByName,
29
29
  deleteCookieByValue,
30
30
  FILTER_TYPE,
@@ -63,6 +63,15 @@ When(`je clique`, async function(this: World) {
63
63
  await getPageOrElement(this).then((element: Locator) => element.click({ timeout: DEFAULT_TIMEOUT }));
64
64
  });
65
65
 
66
+
67
+ When(`je clique sur le bouton nommé {string}`, async function(this: World, name: string) {
68
+ await click(this, "button", name);
69
+ });
70
+
71
+ When(`je clique sur l'élément avec le rôle {string} et le nom {string}`, async function(this: World, role: string, name: string) {
72
+ await click(this, role, name);
73
+ });
74
+
66
75
  // TODO : permet de gérer les label accessibles donc pas que les aria : https://playwright.dev/docs/api/class-locator#locator-get-by-label
67
76
  When(`je vais à l'intérieur de l'élément ayant pour aria-label {string}`, async function(this: World, expectedAriaLabel: string) {
68
77
  const sanitizedExpectedAriaLabel = encodeURIComponent(expectedAriaLabel).replaceAll("%20", " ");
@@ -381,4 +390,13 @@ async function pressKey(world: World, element: Locator, key: string) {
381
390
  await addCookieWhenValueIsList(world, COOKIE_NAME.SELECTED_ELEMENT, { name: FILTER_TYPE.SELECTOR_PARENT, value: "*:focus" });
382
391
  }
383
392
 
393
+ async function click(world: World, role: any, name: string) {
394
+ await getPageOrElement(world).then(async (element) => {
395
+ const byRole = await element.getByRole(role, { name: name, includeHidden: true, exact: true });
396
+ await expect(byRole).toHaveCount(1);
397
+ await byRole.click({ timeout: DEFAULT_TIMEOUT });
398
+ await world.context.clearCookies();
399
+ });
400
+ }
401
+
384
402