@uuv/playwright 1.7.2 → 1.8.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.
- 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/dist/lib/runner-playwright.d.ts +1 -1
- package/dist/lib/runner-playwright.js +15 -4
- package/dist/lib/uuv-cli.js +7 -3
- package/dist/reporter/uuv-playwright-reporter-helper.d.ts +10 -0
- package/dist/reporter/uuv-playwright-reporter-helper.js +60 -2
- package/dist/reporter/uuv-playwright-reporter.js +3 -1
- package/package.json +2 -2
- 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();
|
|
@@ -17,4 +17,4 @@ export interface UUVPlaywrightCucumberMapItem {
|
|
|
17
17
|
generatedFile: string;
|
|
18
18
|
}
|
|
19
19
|
export declare const UUVPlaywrightCucumberMapFile = ".uuv-playwright-cucumber-map.json";
|
|
20
|
-
export declare function run(mode: "open" | "e2e", tempDir?: string, configDir?: string, generateHtmlReport?: boolean): Promise<void>;
|
|
20
|
+
export declare function run(mode: "open" | "e2e", tempDir?: string, configDir?: string, generateHtmlReport?: boolean, env?: any, targetTestFile?: string): Promise<void>;
|
|
@@ -88,7 +88,7 @@ function translateFeatures(tempDir, configDir) {
|
|
|
88
88
|
console.log(chalk_1.default.gray(`[WRITE] ${generatedFile} written successfully`));
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
function runPlaywright(mode, configDir, generateHtmlReport = false) {
|
|
91
|
+
function runPlaywright(mode, configDir, generateHtmlReport = false, env, targetTestFile) {
|
|
92
92
|
const configFile = `${configDir}/playwright.config.ts`;
|
|
93
93
|
const reportType = generateHtmlReport ? uuv_playwright_reporter_helper_1.GeneratedReportType.HTML : uuv_playwright_reporter_helper_1.GeneratedReportType.CONSOLE;
|
|
94
94
|
try {
|
|
@@ -98,7 +98,10 @@ function runPlaywright(mode, configDir, generateHtmlReport = false) {
|
|
|
98
98
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
99
99
|
// @ts-ignore
|
|
100
100
|
process.env.CONFIG_DIR = configDir;
|
|
101
|
-
|
|
101
|
+
if (env) {
|
|
102
|
+
Object.keys(env).forEach(key => process.env[key] = env[key]);
|
|
103
|
+
}
|
|
104
|
+
const command = `npx playwright test --project=chromium -c ${configFile} ${mode === "open" ? "--ui" : ""} ${getTargetTestFileForPlawright(targetTestFile)}`;
|
|
102
105
|
console.log(chalk_1.default.gray(`Running ${command}`));
|
|
103
106
|
(0, child_process_1.execSync)(command, { stdio: "inherit" });
|
|
104
107
|
}
|
|
@@ -106,14 +109,22 @@ function runPlaywright(mode, configDir, generateHtmlReport = false) {
|
|
|
106
109
|
process.exit(-1);
|
|
107
110
|
}
|
|
108
111
|
}
|
|
112
|
+
function getTargetTestFileForPlawright(targetTestFile) {
|
|
113
|
+
if (!targetTestFile) {
|
|
114
|
+
return "";
|
|
115
|
+
}
|
|
116
|
+
return targetTestFile
|
|
117
|
+
.replaceAll("uuv/e2e/", ".uuv-features-gen/uuv/e2e/")
|
|
118
|
+
.replaceAll(".feature", ".feature.spec.js");
|
|
119
|
+
}
|
|
109
120
|
async function executePreprocessor(tempDir, configDir) {
|
|
110
121
|
console.log("running preprocessor...");
|
|
111
122
|
await bddGen(tempDir);
|
|
112
123
|
translateFeatures(tempDir, configDir);
|
|
113
124
|
console.log("preprocessor executed");
|
|
114
125
|
}
|
|
115
|
-
async function run(mode, tempDir = "uuv/.features-gen/e2e", configDir = "uuv", generateHtmlReport = false) {
|
|
126
|
+
async function run(mode, tempDir = "uuv/.features-gen/e2e", configDir = "uuv", generateHtmlReport = false, env, targetTestFile) {
|
|
116
127
|
await executePreprocessor(tempDir, configDir);
|
|
117
|
-
runPlaywright(mode, configDir, generateHtmlReport);
|
|
128
|
+
runPlaywright(mode, configDir, generateHtmlReport, env, targetTestFile);
|
|
118
129
|
}
|
|
119
130
|
exports.run = run;
|
package/dist/lib/uuv-cli.js
CHANGED
|
@@ -46,10 +46,14 @@ async function main() {
|
|
|
46
46
|
function extractArgs(argv) {
|
|
47
47
|
const browser = argv.browser ? argv.browser : "chrome";
|
|
48
48
|
const env = argv.env ? JSON.parse(argv.env.replace(/'/g, "\"")) : {};
|
|
49
|
+
const targetTestFile = argv.targetTestFile ? argv.targetTestFile : null;
|
|
49
50
|
console.debug("Variables: ");
|
|
50
51
|
console.debug(` -> browser: ${browser}`);
|
|
51
52
|
console.debug(` -> env: ${JSON.stringify(env)}`);
|
|
52
|
-
|
|
53
|
+
if (targetTestFile) {
|
|
54
|
+
console.debug(` -> targetTestFile: ${targetTestFile}`);
|
|
55
|
+
}
|
|
56
|
+
return { browser, env, targetTestFile };
|
|
53
57
|
}
|
|
54
58
|
function openPlaywright(argv) {
|
|
55
59
|
// TODO Implementer les paramètres env en json
|
|
@@ -57,14 +61,14 @@ async function main() {
|
|
|
57
61
|
return (0, runner_playwright_1.run)("open", FEATURE_GEN_DIR, PROJECT_DIR);
|
|
58
62
|
}
|
|
59
63
|
function runE2ETests(argv) {
|
|
60
|
-
const { browser, env } = extractArgs(argv);
|
|
64
|
+
const { browser, env, targetTestFile } = extractArgs(argv);
|
|
61
65
|
// TODO Manage HTML Report
|
|
62
66
|
// Creating needed dirs
|
|
63
67
|
// if (!fs.existsSync(JSON_REPORT_DIR)) {
|
|
64
68
|
// fs.mkdirSync(JSON_REPORT_DIR, { recursive: true });
|
|
65
69
|
// }
|
|
66
70
|
// Running Tests
|
|
67
|
-
return (0, runner_playwright_1.run)("e2e", FEATURE_GEN_DIR, PROJECT_DIR, argv.generateHtmlReport)
|
|
71
|
+
return (0, runner_playwright_1.run)("e2e", FEATURE_GEN_DIR, PROJECT_DIR, argv.generateHtmlReport, env, targetTestFile)
|
|
68
72
|
.then(async (result) => {
|
|
69
73
|
console.log(`Status ${chalk_1.default.green("success")}`);
|
|
70
74
|
})
|
|
@@ -10,6 +10,7 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
10
10
|
testDir: string;
|
|
11
11
|
private queries;
|
|
12
12
|
envelopes: Envelope[];
|
|
13
|
+
private featureFileAndTestCaseStatusMap;
|
|
13
14
|
private testCasesAndTestCasesStartedIdMap;
|
|
14
15
|
private testCasesAndPickleIdMap;
|
|
15
16
|
private testCasesTestStepStartedIdMap;
|
|
@@ -36,6 +37,8 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
36
37
|
}): void;
|
|
37
38
|
private getTestStepKey;
|
|
38
39
|
createTestCaseFinishedEnvelope(test: TestCase, result: TestResult, featureFile: string, endTimestamp: any): void;
|
|
40
|
+
private logTeamcityTestEnd;
|
|
41
|
+
private logTeamcitySuiteFinishedIfNeeded;
|
|
39
42
|
private addResultErrors;
|
|
40
43
|
private createTestCaseErrorAttachmentsEnvelope;
|
|
41
44
|
private initConsoleReportIfNotExists;
|
|
@@ -55,6 +58,7 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
55
58
|
private loadUUVPlaywrightCucumberMap;
|
|
56
59
|
private initializeCucumberReportNdJson;
|
|
57
60
|
private populateTestCasesAndPickleIdMap;
|
|
61
|
+
private updateTestcaseStatus;
|
|
58
62
|
private generateTestStep;
|
|
59
63
|
private createStepDefinitionEnvelope;
|
|
60
64
|
private getFeatureFiles;
|
|
@@ -67,5 +71,11 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
67
71
|
logTestEnd(testCase: TestCase, result: TestResult): void;
|
|
68
72
|
private getResultIcon;
|
|
69
73
|
private getTestCaseTitle;
|
|
74
|
+
logTeamCity(line: any): void;
|
|
75
|
+
private teamcityFlowId;
|
|
76
|
+
private teamcityFlowIdAndParentFlowId;
|
|
77
|
+
private teamcityAddName;
|
|
78
|
+
private teamcityAddDuration;
|
|
79
|
+
private teamcityAddCustomField;
|
|
70
80
|
}
|
|
71
81
|
export default UuvPlaywrightReporterHelper;
|
|
@@ -42,6 +42,7 @@ class UuvPlaywrightReporterHelper {
|
|
|
42
42
|
testDir;
|
|
43
43
|
queries = new Map();
|
|
44
44
|
envelopes = [];
|
|
45
|
+
featureFileAndTestCaseStatusMap = new Map();
|
|
45
46
|
testCasesAndTestCasesStartedIdMap = new Map();
|
|
46
47
|
testCasesAndPickleIdMap = new Map();
|
|
47
48
|
testCasesTestStepStartedIdMap = new Map();
|
|
@@ -87,6 +88,7 @@ class UuvPlaywrightReporterHelper {
|
|
|
87
88
|
this.testCasesAndTestCasesStartedIdMap.set(test.id, testCaseStartedId);
|
|
88
89
|
this.initConsoleReportIfNotExists(featureFile);
|
|
89
90
|
}
|
|
91
|
+
this.logTeamCity(`##teamcity[testStarted ${this.teamcityAddName(test.title)} ${this.teamcityFlowIdAndParentFlowId(test.title, featureFile)} ${this.teamcityAddCustomField("locationHint", "test://" + featureFile)} ]`);
|
|
90
92
|
}
|
|
91
93
|
createTestStepStartedEnvelope(test, step, featureFile, startTimestamp) {
|
|
92
94
|
const currentQuery = this.queries.get(featureFile);
|
|
@@ -180,6 +182,8 @@ class UuvPlaywrightReporterHelper {
|
|
|
180
182
|
return `${location.file.replaceAll("\\", "_")}-${location.line}-${location.column}`;
|
|
181
183
|
}
|
|
182
184
|
createTestCaseFinishedEnvelope(test, result, featureFile, endTimestamp) {
|
|
185
|
+
this.logTeamcityTestEnd(result, test, featureFile);
|
|
186
|
+
this.updateTestcaseStatus(featureFile, test.id, "done");
|
|
183
187
|
const currentQuery = this.queries.get(featureFile);
|
|
184
188
|
if (currentQuery) {
|
|
185
189
|
if (result.status === "skipped" || result.status === "failed") {
|
|
@@ -199,6 +203,28 @@ class UuvPlaywrightReporterHelper {
|
|
|
199
203
|
this.addResultErrors(result, test, featureFile);
|
|
200
204
|
this.createTestCaseErrorAttachmentsEnvelope(testCaseStartedId, result);
|
|
201
205
|
}
|
|
206
|
+
this.logTeamcitySuiteFinishedIfNeeded(featureFile);
|
|
207
|
+
}
|
|
208
|
+
logTeamcityTestEnd(result, test, featureFile) {
|
|
209
|
+
switch (result.status) {
|
|
210
|
+
case "passed":
|
|
211
|
+
this.logTeamCity(`##teamcity[testFinished ${this.teamcityAddName(test.title)} ${this.teamcityFlowIdAndParentFlowId(test.title, featureFile)} ${this.teamcityAddDuration(result)} ]`);
|
|
212
|
+
break;
|
|
213
|
+
case "failed":
|
|
214
|
+
this.logTeamCity(`##teamcity[testFailed ${this.teamcityAddName(test.title)} ${this.teamcityFlowIdAndParentFlowId(test.title, featureFile)} type='comparisonFailure' message='Test failed' ]`);
|
|
215
|
+
this.logTeamCity(`##teamcity[testFinished ${this.teamcityAddName(test.title)} ${this.teamcityFlowIdAndParentFlowId(test.title, featureFile)} ${this.teamcityAddDuration(result)} ]`);
|
|
216
|
+
break;
|
|
217
|
+
default:
|
|
218
|
+
this.logTeamCity(`##teamcity[testIgnored ${this.teamcityAddName(test.title)} ${this.teamcityFlowIdAndParentFlowId(test.title, featureFile)} ]`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
logTeamcitySuiteFinishedIfNeeded(featureFile) {
|
|
222
|
+
const featureTestCaseStatus = this.featureFileAndTestCaseStatusMap.get(featureFile);
|
|
223
|
+
if (featureTestCaseStatus) {
|
|
224
|
+
if (Object.entries(featureTestCaseStatus).find(([, value]) => value === "todo") === undefined) {
|
|
225
|
+
this.logTeamCity(`##teamcity[testSuiteFinished ${this.teamcityAddName(featureFile)} ${this.teamcityFlowId(featureFile)} ]`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
202
228
|
}
|
|
203
229
|
addResultErrors(result, test, featureFile) {
|
|
204
230
|
result.errors.forEach(error => {
|
|
@@ -231,6 +257,7 @@ class UuvPlaywrightReporterHelper {
|
|
|
231
257
|
}
|
|
232
258
|
initConsoleReportIfNotExists(featureFile) {
|
|
233
259
|
if (!this.consoleReportMap.get(featureFile)) {
|
|
260
|
+
this.logTeamCity(`##teamcity[testSuiteStarted ${this.teamcityAddName(featureFile)} ${this.teamcityFlowId(featureFile)} ${this.teamcityAddCustomField("locationHint", "suite://" + featureFile)} ]`);
|
|
234
261
|
this.consoleReportMap.set(featureFile, new ReportOfFeature());
|
|
235
262
|
}
|
|
236
263
|
}
|
|
@@ -316,18 +343,27 @@ class UuvPlaywrightReporterHelper {
|
|
|
316
343
|
currentEnvelopes.forEach(envelope => currentQuery.update(envelope));
|
|
317
344
|
this.queries.set(originalFile, currentQuery);
|
|
318
345
|
this.envelopes = this.envelopes.concat(currentEnvelopes);
|
|
319
|
-
this.
|
|
346
|
+
this.featureFileAndTestCaseStatusMap.set(originalFile, []);
|
|
347
|
+
this.populateTestCasesAndPickleIdMap(currentQuery, suite, featureFile, originalFile);
|
|
320
348
|
}
|
|
321
349
|
});
|
|
322
350
|
}
|
|
323
|
-
populateTestCasesAndPickleIdMap(currentQuery, suite, featureFile) {
|
|
351
|
+
populateTestCasesAndPickleIdMap(currentQuery, suite, featureFile, originalFile) {
|
|
324
352
|
const pickles = currentQuery.getPickles();
|
|
325
353
|
const featureFileTestSuite = suite.allTests()
|
|
326
354
|
.filter(testCase => testCase.location.file === featureFile);
|
|
327
355
|
featureFileTestSuite.forEach((testCase, index) => {
|
|
328
356
|
this.testCasesAndPickleIdMap.set(testCase.id, pickles[index].id);
|
|
357
|
+
this.updateTestcaseStatus(originalFile, testCase.id, "todo");
|
|
329
358
|
});
|
|
330
359
|
}
|
|
360
|
+
updateTestcaseStatus(originalFile, testCaseId, newStatus) {
|
|
361
|
+
const featureTestCaseStatus = this.featureFileAndTestCaseStatusMap.get(originalFile);
|
|
362
|
+
if (featureTestCaseStatus) {
|
|
363
|
+
featureTestCaseStatus[`${testCaseId}`] = newStatus;
|
|
364
|
+
this.featureFileAndTestCaseStatusMap.set(originalFile, featureTestCaseStatus);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
331
367
|
generateTestStep(currentQuery, test) {
|
|
332
368
|
const pickleId = this.testCasesAndPickleIdMap.get(test.id);
|
|
333
369
|
return currentQuery.getPickles()
|
|
@@ -447,5 +483,27 @@ class UuvPlaywrightReporterHelper {
|
|
|
447
483
|
const message = `${testCase.title} (${result.duration}ms)`;
|
|
448
484
|
return !testCase.ok() ? chalk_1.default.redBright(message) : chalk_1.default.gray(message);
|
|
449
485
|
}
|
|
486
|
+
logTeamCity(line) {
|
|
487
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
488
|
+
// @ts-ignore
|
|
489
|
+
if (process.env.enableTeamcityLogging) {
|
|
490
|
+
console.log(line);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
teamcityFlowId(name) {
|
|
494
|
+
return "flowId='" + name.replaceAll("'", "|'") + "'";
|
|
495
|
+
}
|
|
496
|
+
teamcityFlowIdAndParentFlowId(name, parentName) {
|
|
497
|
+
return "flowId='" + name.replaceAll("'", "|'") + "' parent='" + parentName.replaceAll("'", "|'") + "'";
|
|
498
|
+
}
|
|
499
|
+
teamcityAddName(name) {
|
|
500
|
+
return "name='" + name.replaceAll("'", "|'") + "'";
|
|
501
|
+
}
|
|
502
|
+
teamcityAddDuration(result) {
|
|
503
|
+
return "duration='" + result.duration + "'";
|
|
504
|
+
}
|
|
505
|
+
teamcityAddCustomField(fieldName, value) {
|
|
506
|
+
return `${fieldName}='${value}'`;
|
|
507
|
+
}
|
|
450
508
|
}
|
|
451
509
|
exports.default = UuvPlaywrightReporterHelper;
|
|
@@ -11,6 +11,7 @@ class UuvPlawrightReporter {
|
|
|
11
11
|
const startTimestamp = this.helper.getTimestamp();
|
|
12
12
|
// console.log(`Starting the run with ${suite.allTests().length} tests`);
|
|
13
13
|
this.helper.createTestRunStartedEnvelope(config, suite, startTimestamp);
|
|
14
|
+
this.helper.logTeamCity("##teamcity[progressStart 'Running UUV Tests']");
|
|
14
15
|
console.info(chalk_1.default.yellow(`Starting the run with ${suite.allTests().length} tests`));
|
|
15
16
|
}
|
|
16
17
|
onError(error) {
|
|
@@ -46,8 +47,8 @@ class UuvPlawrightReporter {
|
|
|
46
47
|
// console.log(`Finished test ${test.title}: ${result.status}`);
|
|
47
48
|
const featureFile = this.helper.getOriginalFeatureFile(test.location.file);
|
|
48
49
|
if (featureFile) {
|
|
49
|
-
this.helper.createTestCaseFinishedEnvelope(test, result, featureFile, endTimestamp);
|
|
50
50
|
this.helper.logTestEnd(test, result);
|
|
51
|
+
this.helper.createTestCaseFinishedEnvelope(test, result, featureFile, endTimestamp);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
async onEnd(result) {
|
|
@@ -64,6 +65,7 @@ class UuvPlawrightReporter {
|
|
|
64
65
|
else {
|
|
65
66
|
console.error(chalk_1.default.red(`Tests executed with status: ${result.status}`));
|
|
66
67
|
}
|
|
68
|
+
this.helper.logTeamCity("##teamcity[progressFinish 'Running UUV Tests']");
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
exports.default = UuvPlawrightReporter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uuv/playwright",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.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.
|
|
49
|
+
"@uuv/runner-commons": "1.6.3",
|
|
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();
|