@uuv/playwright 1.7.1 → 1.7.3

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.
@@ -35,7 +35,7 @@ const cucumber_1 = require("@cucumber/cucumber");
35
35
  // 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
36
  (0, cucumber_1.When)(`${runner_commons_1.key.when.withinElement.ariaLabel}`, async function (expectedAriaLabel) {
37
37
  const sanitizedExpectedAriaLabel = encodeURIComponent(expectedAriaLabel).replaceAll("%20", " ");
38
- await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(sanitizedExpectedAriaLabel)).toHaveCount(1));
38
+ await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(sanitizedExpectedAriaLabel, { exact: true })).toHaveCount(1));
39
39
  await (0, core_engine_1.addCookieWhenValueIsList)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, { name: core_engine_1.FILTER_TYPE.ARIA_LABEL, value: sanitizedExpectedAriaLabel });
40
40
  });
41
41
  (0, cucumber_1.When)(`${runner_commons_1.key.when.resetContext}`, async function () {
@@ -92,7 +92,7 @@ const cucumber_1 = require("@cucumber/cucumber");
92
92
  });
93
93
  (0, cucumber_1.When)(`${runner_commons_1.key.when.mock.withFixture}`, async function (verb, url, name, fixture) {
94
94
  await (0, core_engine_1.addCookieWhenValueIsList)(this, core_engine_1.COOKIE_NAME.MOCK_URL, { name: name, url: url });
95
- const data = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${fixture}`);
95
+ const data = await runner_commons_1.fs.readFileSync(`uuv/playwright/fixtures/${fixture}`);
96
96
  await this.page.route(url, async (route) => {
97
97
  await route.fulfill({ body: data });
98
98
  });
@@ -188,16 +188,16 @@ const cucumber_1 = require("@cucumber/cucumber");
188
188
  });
189
189
  (0, cucumber_1.Then)(`${runner_commons_1.key.then.element.withAriaLabel}`, async function (expectedAriaLabel) {
190
190
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
191
- await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel)).toHaveCount(1));
191
+ await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel, { exact: true })).toHaveCount(1));
192
192
  });
193
193
  (0, cucumber_1.Then)(`${runner_commons_1.key.then.element.not.withAriaLabel}`, async function (expectedAriaLabel) {
194
194
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
195
- await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel)).toHaveCount(0));
195
+ await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel, { exact: true })).toHaveCount(0));
196
196
  });
197
197
  (0, cucumber_1.Then)(`${runner_commons_1.key.then.element.withAriaLabelAndContent}`, async function (expectedAriaLabel, expectedTextContent) {
198
198
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
199
199
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
200
- const byLabel = await element.getByLabel(expectedAriaLabel);
200
+ const byLabel = await element.getByLabel(expectedAriaLabel, { exact: true });
201
201
  await (0, test_1.expect)(byLabel).toHaveCount(1);
202
202
  await (0, test_1.expect)(byLabel.filter({ hasText: expectedTextContent })).toHaveCount(1);
203
203
  });
@@ -230,7 +230,7 @@ const cucumber_1 = require("@cucumber/cucumber");
230
230
  (0, cucumber_1.Then)(`${runner_commons_1.key.then.list.withNameAndContent}`, async function (expectedListName, expectedElementsOfList) {
231
231
  await (0, core_engine_1.withinRoleAndName)(this, "list", expectedListName);
232
232
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
233
- const listitem = await element.getByRole("listitem").all();
233
+ const listitem = await element.getByRole("listitem", { exact: true }).all();
234
234
  const foundedElement = [];
235
235
  for (const element of listitem) {
236
236
  const textContent = await element.textContent();
@@ -47,16 +47,16 @@ async function getPageOrElement(world) {
47
47
  pointer = pointer.locator(filter.value);
48
48
  break;
49
49
  case FILTER_TYPE.ARIA_LABEL:
50
- pointer = pointer.getByLabel(filter.value);
50
+ pointer = pointer.getByLabel(filter.value, { exact: true });
51
51
  break;
52
52
  case FILTER_TYPE.ROLE:
53
- pointer = pointer.getByRole(filter.value, { includeHidden: true });
53
+ pointer = pointer.getByRole(filter.value, { includeHidden: true, exact: true });
54
54
  break;
55
55
  case FILTER_TYPE.TEST_ID:
56
56
  pointer = pointer.getByTestId(filter.value);
57
57
  break;
58
58
  case FILTER_TYPE.TEXT:
59
- pointer = pointer.getByText(filter.value);
59
+ pointer = pointer.getByText(filter.value, { exact: true });
60
60
  break;
61
61
  case FILTER_TYPE.SELECTOR_PARENT:
62
62
  pointer = pointer.locator(filter.value);
@@ -140,14 +140,14 @@ async function withinRoleAndName(world, role, name) {
140
140
  exports.withinRoleAndName = withinRoleAndName;
141
141
  async function notFoundWithRoleAndName(world, role, name) {
142
142
  role = encodeURIComponent(role);
143
- await getPageOrElement(world).then(async (element) => await (0, test_1.expect)(element.getByRole(role, { name: name, includeHidden: true })).toHaveCount(0));
143
+ await getPageOrElement(world).then(async (element) => await (0, test_1.expect)(element.getByRole(role, { name: name, includeHidden: true, exact: true })).toHaveCount(0));
144
144
  }
145
145
  exports.notFoundWithRoleAndName = notFoundWithRoleAndName;
146
146
  async function findWithRoleAndNameAndContent(world, expectedRole, name, expectedTextContent = undefined) {
147
147
  expectedRole = encodeURIComponent(expectedRole);
148
148
  await getPageOrElement(world).then(async (element) => {
149
149
  // console.log("final:",expectedRole,name)
150
- const byRole = await element.getByRole(expectedRole, { name: name, includeHidden: true });
150
+ const byRole = await element.getByRole(expectedRole, { name: name, includeHidden: true, exact: true });
151
151
  await (0, test_1.expect)(byRole).toHaveCount(1);
152
152
  if (expectedTextContent !== undefined) {
153
153
  await checkTextContentLocator(byRole, expectedTextContent);
@@ -158,7 +158,7 @@ exports.findWithRoleAndNameAndContent = findWithRoleAndNameAndContent;
158
158
  async function findWithRoleAndNameAndContentDisable(world, expectedRole, name, expectedTextContent) {
159
159
  expectedRole = encodeURIComponent(expectedRole);
160
160
  await getPageOrElement(world).then(async (element) => {
161
- const byRole = await element.getByRole(expectedRole, { name: name, includeHidden: true });
161
+ const byRole = await element.getByRole(expectedRole, { name: name, includeHidden: true, exact: true });
162
162
  await (0, test_1.expect)(byRole).toHaveCount(1);
163
163
  await checkTextContentLocator(byRole, expectedTextContent);
164
164
  await (0, test_1.expect)(byRole).toBeDisabled();
@@ -168,7 +168,7 @@ exports.findWithRoleAndNameAndContentDisable = findWithRoleAndNameAndContentDisa
168
168
  async function findWithRoleAndNameAndContentEnable(world, expectedRole, name, expectedTextContent) {
169
169
  expectedRole = encodeURIComponent(expectedRole);
170
170
  await getPageOrElement(world).then(async (element) => {
171
- const byRole = element.getByRole(expectedRole, { name: name, includeHidden: true });
171
+ const byRole = element.getByRole(expectedRole, { name: name, includeHidden: true, exact: true });
172
172
  await (0, test_1.expect)(byRole).toHaveCount(1);
173
173
  await checkTextContentLocator(byRole, expectedTextContent);
174
174
  await (0, test_1.expect)(byRole).toBeEnabled();
@@ -38,7 +38,7 @@ const cucumber_1 = require("@cucumber/cucumber");
38
38
  // 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
39
  (0, cucumber_1.When)(`Within the element with aria-label {string}`, async function (expectedAriaLabel) {
40
40
  const sanitizedExpectedAriaLabel = encodeURIComponent(expectedAriaLabel).replaceAll("%20", " ");
41
- await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(sanitizedExpectedAriaLabel)).toHaveCount(1));
41
+ await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(sanitizedExpectedAriaLabel, { exact: true })).toHaveCount(1));
42
42
  await (0, core_engine_1.addCookieWhenValueIsList)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, { name: core_engine_1.FILTER_TYPE.ARIA_LABEL, value: sanitizedExpectedAriaLabel });
43
43
  });
44
44
  (0, cucumber_1.When)(`I reset context`, async function () {
@@ -95,7 +95,7 @@ const cucumber_1 = require("@cucumber/cucumber");
95
95
  });
96
96
  (0, cucumber_1.When)(`I mock a request {} on url {string} named {string} with fixture {}`, async function (verb, url, name, fixture) {
97
97
  await (0, core_engine_1.addCookieWhenValueIsList)(this, core_engine_1.COOKIE_NAME.MOCK_URL, { name: name, url: url });
98
- const data = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${fixture}`);
98
+ const data = await runner_commons_1.fs.readFileSync(`uuv/playwright/fixtures/${fixture}`);
99
99
  await this.page.route(url, async (route) => {
100
100
  await route.fulfill({ body: data });
101
101
  });
@@ -191,16 +191,16 @@ const cucumber_1 = require("@cucumber/cucumber");
191
191
  });
192
192
  (0, cucumber_1.Then)(`I should see an element with aria-label {string}`, async function (expectedAriaLabel) {
193
193
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
194
- await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel)).toHaveCount(1));
194
+ await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel, { exact: true })).toHaveCount(1));
195
195
  });
196
196
  (0, cucumber_1.Then)(`I should not see an element with aria-label {string}`, async function (expectedAriaLabel) {
197
197
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
198
- await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel)).toHaveCount(0));
198
+ await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel, { exact: true })).toHaveCount(0));
199
199
  });
200
200
  (0, cucumber_1.Then)(`I should see an element with aria-label {string} and content {string}`, async function (expectedAriaLabel, expectedTextContent) {
201
201
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
202
202
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
203
- const byLabel = await element.getByLabel(expectedAriaLabel);
203
+ const byLabel = await element.getByLabel(expectedAriaLabel, { exact: true });
204
204
  await (0, test_1.expect)(byLabel).toHaveCount(1);
205
205
  await (0, test_1.expect)(byLabel.filter({ hasText: expectedTextContent })).toHaveCount(1);
206
206
  });
@@ -233,7 +233,7 @@ const cucumber_1 = require("@cucumber/cucumber");
233
233
  (0, cucumber_1.Then)(`I should see elements of the list with name {string}`, async function (expectedListName, expectedElementsOfList) {
234
234
  await (0, core_engine_1.withinRoleAndName)(this, "list", expectedListName);
235
235
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
236
- const listitem = await element.getByRole("listitem").all();
236
+ const listitem = await element.getByRole("listitem", { exact: true }).all();
237
237
  const foundedElement = [];
238
238
  for (const element of listitem) {
239
239
  const textContent = await element.textContent();
@@ -38,7 +38,7 @@ const cucumber_1 = require("@cucumber/cucumber");
38
38
  // 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
39
  (0, cucumber_1.When)(`je vais à l'intérieur de l'élément ayant pour aria-label {string}`, async function (expectedAriaLabel) {
40
40
  const sanitizedExpectedAriaLabel = encodeURIComponent(expectedAriaLabel).replaceAll("%20", " ");
41
- await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(sanitizedExpectedAriaLabel)).toHaveCount(1));
41
+ await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(sanitizedExpectedAriaLabel, { exact: true })).toHaveCount(1));
42
42
  await (0, core_engine_1.addCookieWhenValueIsList)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, { name: core_engine_1.FILTER_TYPE.ARIA_LABEL, value: sanitizedExpectedAriaLabel });
43
43
  });
44
44
  (0, cucumber_1.When)(`je reinitialise le contexte`, async function () {
@@ -95,7 +95,7 @@ const cucumber_1 = require("@cucumber/cucumber");
95
95
  });
96
96
  (0, cucumber_1.When)(`je simule une requête {} sur l'url {string} nommée {string} avec le fichier suivant {}`, async function (verb, url, name, fixture) {
97
97
  await (0, core_engine_1.addCookieWhenValueIsList)(this, core_engine_1.COOKIE_NAME.MOCK_URL, { name: name, url: url });
98
- const data = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${fixture}`);
98
+ const data = await runner_commons_1.fs.readFileSync(`uuv/playwright/fixtures/${fixture}`);
99
99
  await this.page.route(url, async (route) => {
100
100
  await route.fulfill({ body: data });
101
101
  });
@@ -191,16 +191,16 @@ const cucumber_1 = require("@cucumber/cucumber");
191
191
  });
192
192
  (0, cucumber_1.Then)(`je dois voir un élément ayant pour aria-label {string}`, async function (expectedAriaLabel) {
193
193
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
194
- await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel)).toHaveCount(1));
194
+ await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel, { exact: true })).toHaveCount(1));
195
195
  });
196
196
  (0, cucumber_1.Then)(`je ne dois pas voir un élément ayant pour aria-label {string}`, async function (expectedAriaLabel) {
197
197
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
198
- await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel)).toHaveCount(0));
198
+ await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByLabel(expectedAriaLabel, { exact: true })).toHaveCount(0));
199
199
  });
200
200
  (0, cucumber_1.Then)(`je dois voir un élément ayant pour aria-label {string} et pour contenu {string}`, async function (expectedAriaLabel, expectedTextContent) {
201
201
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
202
202
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
203
- const byLabel = await element.getByLabel(expectedAriaLabel);
203
+ const byLabel = await element.getByLabel(expectedAriaLabel, { exact: true });
204
204
  await (0, test_1.expect)(byLabel).toHaveCount(1);
205
205
  await (0, test_1.expect)(byLabel.filter({ hasText: expectedTextContent })).toHaveCount(1);
206
206
  });
@@ -233,7 +233,7 @@ const cucumber_1 = require("@cucumber/cucumber");
233
233
  (0, cucumber_1.Then)(`je dois voir des elements de la liste ayant pour nom {string}`, async function (expectedListName, expectedElementsOfList) {
234
234
  await (0, core_engine_1.withinRoleAndName)(this, "list", expectedListName);
235
235
  await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
236
- const listitem = await element.getByRole("listitem").all();
236
+ const listitem = await element.getByRole("listitem", { exact: true }).all();
237
237
  const foundedElement = [];
238
238
  for (const element of listitem) {
239
239
  const textContent = await element.textContent();
@@ -0,0 +1,6 @@
1
+ import { Formatter } from "cucumber-json-report-formatter";
2
+ export declare class UuvCustomFormatter extends Formatter {
3
+ constructor();
4
+ parseCucumberJson(sourceFile: any, outputFile: any): Promise<void>;
5
+ private buildAndAddScenario;
6
+ }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UuvCustomFormatter = void 0;
4
+ const cucumber_json_report_formatter_1 = require("cucumber-json-report-formatter");
5
+ // FIXME remove this class when the PR https://github.com/vrymar/cucumber-json-report-formatter/pull/20 will be merged
6
+ class UuvCustomFormatter extends cucumber_json_report_formatter_1.Formatter {
7
+ constructor() {
8
+ super();
9
+ }
10
+ async parseCucumberJson(sourceFile, outputFile) {
11
+ console.info(`Start formatting file '${sourceFile}' into '${outputFile}'`);
12
+ const report = await this.helper.readFileIntoJson(sourceFile);
13
+ const gherkinDocumentJson = this.helper.getJsonFromArray(report, "gherkinDocument");
14
+ const cucumberReport = [];
15
+ gherkinDocumentJson.forEach(gherkinJson => {
16
+ let gherkinDocument;
17
+ try {
18
+ gherkinDocument = JSON.parse(gherkinJson).gherkinDocument;
19
+ }
20
+ catch (err) {
21
+ console.error("Error parsing JSON string.", err);
22
+ }
23
+ const feature = gherkinDocument.feature;
24
+ const featureChildren = feature.children;
25
+ const scenariosJson = [];
26
+ const background = {};
27
+ featureChildren.forEach(featureChild => {
28
+ if (featureChild.rule) {
29
+ featureChild.rule.steps = [];
30
+ featureChild.rule.children.forEach(ruleChildren => {
31
+ this.buildAndAddScenario(ruleChildren, report, background, feature, scenariosJson, featureChild.rule);
32
+ });
33
+ }
34
+ else {
35
+ this.buildAndAddScenario(featureChild, report, background, feature, scenariosJson, undefined);
36
+ }
37
+ });
38
+ const rootJson = {
39
+ comments: this.getComments(gherkinDocument.comments),
40
+ description: gherkinDocument.feature.description,
41
+ elements: scenariosJson,
42
+ id: feature.name,
43
+ keyword: feature.keyword,
44
+ line: feature.location.line,
45
+ name: feature.name,
46
+ uri: gherkinDocument.uri,
47
+ tags: this.getTags(gherkinDocument.feature.tags)
48
+ };
49
+ cucumberReport.push(rootJson);
50
+ });
51
+ await this.validateReportSchema(report);
52
+ const reportString = JSON.stringify(cucumberReport);
53
+ console.info(`Finished formatting file '${sourceFile}'`);
54
+ this.helper.writeFile(outputFile, reportString);
55
+ }
56
+ buildAndAddScenario(child, report, background, feature, scenariosJson, rule) {
57
+ let steps = [];
58
+ let stepJson = {};
59
+ // Background
60
+ if (child.scenario === undefined) {
61
+ child.background.steps.forEach(step => {
62
+ stepJson = this.createStepJson(step, report, 0);
63
+ steps.push(stepJson);
64
+ });
65
+ background = this.createScenarioJson(feature, child.background, steps, "background");
66
+ // eslint-disable-next-line brace-style
67
+ }
68
+ // Normal Scenario
69
+ else if (!child.scenario.keyword.includes("Outline")) {
70
+ child.scenario.steps.forEach(step => {
71
+ stepJson = this.createStepJson(step, report, 0);
72
+ steps.push(stepJson);
73
+ });
74
+ const scenario = this.createScenarioJson(feature, child.scenario, steps, "scenario");
75
+ if (rule) {
76
+ scenario.id = `${feature.name};${rule.name};${scenario.name}`;
77
+ }
78
+ if (Object.keys(background).length !== 0 && background !== undefined) {
79
+ scenariosJson.push(background);
80
+ }
81
+ scenariosJson.push(scenario);
82
+ } /* Scenario Outline */
83
+ else if (child.scenario.examples[0].tableBody !== undefined) {
84
+ const numberOfExecutions = child.scenario.examples[0].tableBody.length;
85
+ const numberOfStepsEachExecution = child.scenario.steps.length;
86
+ let scenarioIndex = 0;
87
+ while (scenarioIndex < numberOfExecutions) {
88
+ let currentStep = 0;
89
+ steps = [];
90
+ while (currentStep < numberOfStepsEachExecution) {
91
+ stepJson = this.createStepJson(child.scenario.steps[currentStep], report, scenarioIndex);
92
+ currentStep++;
93
+ steps.push(stepJson);
94
+ }
95
+ const scenario = this.createScenarioJson(feature, child.scenario, steps, "scenario", scenarioIndex);
96
+ if (rule) {
97
+ scenario.id = `${feature.name};${rule.name};${scenario.name}`;
98
+ }
99
+ if (Object.keys(background).length !== 0 && background !== undefined) {
100
+ scenariosJson.push(background);
101
+ }
102
+ scenariosJson.push(scenario);
103
+ scenarioIndex++;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ exports.UuvCustomFormatter = UuvCustomFormatter;
@@ -10,10 +10,10 @@ const messages_1 = require("@cucumber/messages");
10
10
  const fs_1 = __importDefault(require("fs"));
11
11
  const runner_playwright_1 = require("../lib/runner-playwright");
12
12
  const multiple_cucumber_html_reporter_1 = __importDefault(require("multiple-cucumber-html-reporter"));
13
- const cucumber_json_report_formatter_1 = require("cucumber-json-report-formatter");
14
13
  const nanoid_1 = require("nanoid");
15
14
  const chalk_1 = __importDefault(require("chalk"));
16
15
  const chalk_table_1 = __importDefault(require("chalk-table"));
16
+ const uuv_custom_formatter_1 = require("./uuv-custom-formatter");
17
17
  const NANOS_IN_SECOND = 1000000000;
18
18
  const NANOS_IN_MILLISSECOND = 1000000;
19
19
  var GeneratedReportType;
@@ -364,7 +364,7 @@ class UuvPlaywrightReporterHelper {
364
364
  return [...new Set(suite.allTests().map(testCase => testCase.location?.file))];
365
365
  }
366
366
  async formatCucumberMessageFile(inputMessageFile, outputFormattedFileJson) {
367
- const formatter = new cucumber_json_report_formatter_1.Formatter();
367
+ const formatter = new uuv_custom_formatter_1.UuvCustomFormatter();
368
368
  await formatter.parseCucumberJson(inputMessageFile, outputFormattedFileJson);
369
369
  }
370
370
  generateHtmlReportFromJson(reportDirHtml, reportDirJson) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uuv/playwright",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
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.1",
49
+ "@uuv/runner-commons": "1.6.2",
50
50
  "axe-core": "4.7.2",
51
51
  "axe-playwright": "1.2.3",
52
52
  "chalk": "4.1.2",
@@ -66,7 +66,7 @@ When(`I click`, async function(this: World) {
66
66
  // 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
67
  When(`Within the element with aria-label {string}`, async function(this: World, expectedAriaLabel: string) {
68
68
  const sanitizedExpectedAriaLabel = encodeURIComponent(expectedAriaLabel).replaceAll("%20", " ");
69
- await getPageOrElement(this).then((element) => expect(element.getByLabel(sanitizedExpectedAriaLabel)).toHaveCount(1));
69
+ await getPageOrElement(this).then((element) => expect(element.getByLabel(sanitizedExpectedAriaLabel, { exact: true })).toHaveCount(1));
70
70
  await addCookieWhenValueIsList(this, COOKIE_NAME.SELECTED_ELEMENT, { name: FILTER_TYPE.ARIA_LABEL, value: sanitizedExpectedAriaLabel });
71
71
  });
72
72
  When(`I reset context`, async function(this: World) {
@@ -143,7 +143,7 @@ When(
143
143
  `I mock a request {} on url {string} named {string} with fixture {}`,
144
144
  async function(this: World, verb: string, url: string, name: string, fixture: any) {
145
145
  await addCookieWhenValueIsList(this, COOKIE_NAME.MOCK_URL, { name: name, url: url });
146
- const data = await fs.readFileSync(`playwright/fixtures/${fixture}`);
146
+ const data = await fs.readFileSync(`uuv/playwright/fixtures/${fixture}`);
147
147
  await this.page.route(url, async route => {
148
148
  await route.fulfill({ body: data });
149
149
  });
@@ -287,18 +287,18 @@ Then(
287
287
 
288
288
  Then(`I should see an element with aria-label {string}`, async function(this: World, expectedAriaLabel: string) {
289
289
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
290
- await getPageOrElement(this).then((element) => expect(element.getByLabel(expectedAriaLabel)).toHaveCount(1));
290
+ await getPageOrElement(this).then((element) => expect(element.getByLabel(expectedAriaLabel, { exact: true })).toHaveCount(1));
291
291
  });
292
292
 
293
293
  Then(`I should not see an element with aria-label {string}`, async function(this: World, expectedAriaLabel: string) {
294
294
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
295
- await getPageOrElement(this).then((element) => expect(element.getByLabel(expectedAriaLabel)).toHaveCount(0));
295
+ await getPageOrElement(this).then((element) => expect(element.getByLabel(expectedAriaLabel, { exact: true })).toHaveCount(0));
296
296
  });
297
297
 
298
298
  Then(`I should see an element with aria-label {string} and content {string}`, async function(this: World, expectedAriaLabel: string, expectedTextContent: string) {
299
299
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
300
300
  await getPageOrElement(this).then(async (element) => {
301
- const byLabel = await element.getByLabel(expectedAriaLabel);
301
+ const byLabel = await element.getByLabel(expectedAriaLabel, { exact: true });
302
302
  await expect(byLabel).toHaveCount(1);
303
303
  await expect(byLabel.filter({ hasText: expectedTextContent })).toHaveCount(1);
304
304
  });
@@ -339,7 +339,7 @@ Then(
339
339
  async function(this: World, expectedListName: string, expectedElementsOfList: DataTable) {
340
340
  await withinRoleAndName(this, "list", expectedListName);
341
341
  await getPageOrElement(this).then(async (element) => {
342
- const listitem = await element.getByRole("listitem").all();
342
+ const listitem = await element.getByRole("listitem", { exact: true }).all();
343
343
  const foundedElement: any[] = [];
344
344
  for (const element of listitem) {
345
345
  const textContent = await element.textContent();
@@ -66,7 +66,7 @@ When(`je clique`, async function(this: World) {
66
66
  // 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
67
  When(`je vais à l'intérieur de l'élément ayant pour aria-label {string}`, async function(this: World, expectedAriaLabel: string) {
68
68
  const sanitizedExpectedAriaLabel = encodeURIComponent(expectedAriaLabel).replaceAll("%20", " ");
69
- await getPageOrElement(this).then((element) => expect(element.getByLabel(sanitizedExpectedAriaLabel)).toHaveCount(1));
69
+ await getPageOrElement(this).then((element) => expect(element.getByLabel(sanitizedExpectedAriaLabel, { exact: true })).toHaveCount(1));
70
70
  await addCookieWhenValueIsList(this, COOKIE_NAME.SELECTED_ELEMENT, { name: FILTER_TYPE.ARIA_LABEL, value: sanitizedExpectedAriaLabel });
71
71
  });
72
72
  When(`je reinitialise le contexte`, async function(this: World) {
@@ -143,7 +143,7 @@ When(
143
143
  `je simule une requête {} sur l'url {string} nommée {string} avec le fichier suivant {}`,
144
144
  async function(this: World, verb: string, url: string, name: string, fixture: any) {
145
145
  await addCookieWhenValueIsList(this, COOKIE_NAME.MOCK_URL, { name: name, url: url });
146
- const data = await fs.readFileSync(`playwright/fixtures/${fixture}`);
146
+ const data = await fs.readFileSync(`uuv/playwright/fixtures/${fixture}`);
147
147
  await this.page.route(url, async route => {
148
148
  await route.fulfill({ body: data });
149
149
  });
@@ -287,18 +287,18 @@ Then(
287
287
 
288
288
  Then(`je dois voir un élément ayant pour aria-label {string}`, async function(this: World, expectedAriaLabel: string) {
289
289
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
290
- await getPageOrElement(this).then((element) => expect(element.getByLabel(expectedAriaLabel)).toHaveCount(1));
290
+ await getPageOrElement(this).then((element) => expect(element.getByLabel(expectedAriaLabel, { exact: true })).toHaveCount(1));
291
291
  });
292
292
 
293
293
  Then(`je ne dois pas voir un élément ayant pour aria-label {string}`, async function(this: World, expectedAriaLabel: string) {
294
294
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
295
- await getPageOrElement(this).then((element) => expect(element.getByLabel(expectedAriaLabel)).toHaveCount(0));
295
+ await getPageOrElement(this).then((element) => expect(element.getByLabel(expectedAriaLabel, { exact: true })).toHaveCount(0));
296
296
  });
297
297
 
298
298
  Then(`je dois voir un élément ayant pour aria-label {string} et pour contenu {string}`, async function(this: World, expectedAriaLabel: string, expectedTextContent: string) {
299
299
  expectedAriaLabel = encodeURIComponent(expectedAriaLabel);
300
300
  await getPageOrElement(this).then(async (element) => {
301
- const byLabel = await element.getByLabel(expectedAriaLabel);
301
+ const byLabel = await element.getByLabel(expectedAriaLabel, { exact: true });
302
302
  await expect(byLabel).toHaveCount(1);
303
303
  await expect(byLabel.filter({ hasText: expectedTextContent })).toHaveCount(1);
304
304
  });
@@ -339,7 +339,7 @@ Then(
339
339
  async function(this: World, expectedListName: string, expectedElementsOfList: DataTable) {
340
340
  await withinRoleAndName(this, "list", expectedListName);
341
341
  await getPageOrElement(this).then(async (element) => {
342
- const listitem = await element.getByRole("listitem").all();
342
+ const listitem = await element.getByRole("listitem", { exact: true }).all();
343
343
  const foundedElement: any[] = [];
344
344
  for (const element of listitem) {
345
345
  const textContent = await element.textContent();