@uuv/playwright 1.7.2 → 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.
- package/dist/cucumber/step_definitions/playwright/base-check-engine.js +6 -6
- package/dist/cucumber/step_definitions/playwright/core-engine.js +7 -7
- package/dist/cucumber/step_definitions/playwright/generated/_en-generated-cucumber-steps-definition.js +6 -6
- package/dist/cucumber/step_definitions/playwright/generated/_fr-generated-cucumber-steps-definition.js +6 -6
- package/package.json +1 -1
- package/src/cucumber/step_definitions/playwright/generated/_en-generated-cucumber-steps-definition.ts +6 -6
- package/src/cucumber/step_definitions/playwright/generated/_fr-generated-cucumber-steps-definition.ts +6 -6
|
@@ -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();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uuv/playwright",
|
|
3
|
-
"version": "1.7.
|
|
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.",
|
|
@@ -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();
|