@uuv/playwright 1.6.1 → 1.7.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/_.common.d.ts +13 -13
- package/dist/cucumber/step_definitions/playwright/_.common.js +13 -117
- package/dist/cucumber/step_definitions/playwright/base-check-engine.d.ts +13 -13
- package/dist/cucumber/step_definitions/playwright/base-check-engine.js +96 -15
- package/dist/cucumber/step_definitions/playwright/core-engine.d.ts +2 -1
- package/dist/cucumber/step_definitions/playwright/core-engine.js +4 -0
- package/dist/cucumber/step_definitions/playwright/generated/_en-generated-cucumber-steps-definition.js +95 -14
- package/dist/cucumber/step_definitions/playwright/generated/_fr-generated-cucumber-steps-definition.js +95 -14
- package/package.json +2 -2
- package/src/cucumber/step_definitions/playwright/generated/_en-generated-cucumber-steps-definition.ts +279 -180
- package/src/cucumber/step_definitions/playwright/generated/_fr-generated-cucumber-steps-definition.ts +279 -180
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Software Name : UUV
|
|
3
|
-
*
|
|
4
|
-
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
5
|
-
* SPDX-License-Identifier: MIT
|
|
6
|
-
*
|
|
7
|
-
* This software is distributed under the MIT License,
|
|
8
|
-
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
9
|
-
* or see the "LICENSE" file for more details.
|
|
10
|
-
*
|
|
11
|
-
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
12
|
-
* Software description: Make test writing fast, understandable by any human
|
|
13
|
-
* understanding English or French.
|
|
14
|
-
*/
|
|
2
|
+
* Software Name : UUV
|
|
3
|
+
*
|
|
4
|
+
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*
|
|
7
|
+
* This software is distributed under the MIT License,
|
|
8
|
+
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
9
|
+
* or see the "LICENSE" file for more details.
|
|
10
|
+
*
|
|
11
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
12
|
+
* Software description: Make test writing fast, understandable by any human
|
|
13
|
+
* understanding English or French.
|
|
14
|
+
*/
|
|
@@ -1,119 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Software Name : UUV
|
|
4
|
-
*
|
|
5
|
-
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
6
|
-
* SPDX-License-Identifier: MIT
|
|
7
|
-
*
|
|
8
|
-
* This software is distributed under the MIT License,
|
|
9
|
-
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
10
|
-
* or see the "LICENSE" file for more details.
|
|
11
|
-
*
|
|
12
|
-
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
13
|
-
* Software description: Make test writing fast, understandable by any human
|
|
14
|
-
* understanding English or French.
|
|
15
|
-
*/
|
|
16
|
-
// import { ByRoleOptions } from "@testing-library/cypress";
|
|
17
|
-
// import {Context} from "./_context";
|
|
18
|
-
// import Chainable = Cypress.Chainable;
|
|
19
|
-
// export const uuvGetContext = (): Chainable<Context> => {
|
|
20
|
-
// return cy.get<Context>('@context');
|
|
21
|
-
// }
|
|
22
|
-
//
|
|
23
|
-
// export function uuvCheckContextFocusedElement(): Cypress.Chainable<Context> {
|
|
24
|
-
// return cy.get<Context>('@context')
|
|
25
|
-
// .then(context => {
|
|
26
|
-
// console.log('focusedElement: ', context);
|
|
27
|
-
// if (!context.focusedElement) {
|
|
28
|
-
// throw new Error("No element currently selected");
|
|
29
|
-
// }
|
|
30
|
-
// return context;
|
|
31
|
-
// });
|
|
32
|
-
// }
|
|
33
|
-
//
|
|
34
|
-
// export function uuvPatchContext(partOfContext: any): Cypress.Chainable<Context>{
|
|
35
|
-
// return cy.get<Context>('@context').then(context => {
|
|
36
|
-
// cy.wrap({
|
|
37
|
-
// ...context,
|
|
38
|
-
// ...partOfContext
|
|
39
|
-
// }).as('context');
|
|
40
|
-
// });
|
|
41
|
-
// }
|
|
42
|
-
//
|
|
43
|
-
// function addContextOptions(context: Context, roleOptions: any): any {
|
|
44
|
-
// let retour = {
|
|
45
|
-
// timeout: context.timeout
|
|
46
|
-
// };
|
|
47
|
-
//
|
|
48
|
-
// return Object.assign(roleOptions, retour);
|
|
49
|
-
// }
|
|
50
|
-
//
|
|
51
|
-
// function abstractFindBy(callBackFunction: Function, inputToSearch: any, inputOptions: any) : Cypress.Chainable<JQuery<HTMLElement>> {
|
|
52
|
-
// return cy.uuvGetContext().then(context => {
|
|
53
|
-
// console.log('context');
|
|
54
|
-
// console.log(context);
|
|
55
|
-
// const parentElement = context.focusedElement;
|
|
56
|
-
// const options = addContextOptions(context, inputOptions);
|
|
57
|
-
//
|
|
58
|
-
// if (parentElement) {
|
|
59
|
-
// console.log('parentElement: ', parentElement);
|
|
60
|
-
// return parentElement.should('exist').within(() => {
|
|
61
|
-
// callBackFunction(inputToSearch, options).as('foundedChildElement');
|
|
62
|
-
// });
|
|
63
|
-
// }
|
|
64
|
-
//
|
|
65
|
-
// cy.wrap(null).as("foundedChildElement");
|
|
66
|
-
// return callBackFunction(inputToSearch, options);
|
|
67
|
-
// })
|
|
68
|
-
// }
|
|
69
|
-
//
|
|
70
|
-
// export function uuvFindAllByRole(role: string, roleOptions: ByRoleOptions) : Cypress.Chainable<JQuery<HTMLElement>> {
|
|
71
|
-
// return abstractFindBy(
|
|
72
|
-
// cy.findAllByRole,
|
|
73
|
-
// role,
|
|
74
|
-
// roleOptions
|
|
75
|
-
// );
|
|
76
|
-
// }
|
|
77
|
-
//
|
|
78
|
-
// export function uuvFindByRole(role: string, roleOptions: ByRoleOptions) : Cypress.Chainable<JQuery<HTMLElement>> {
|
|
79
|
-
// return abstractFindBy(
|
|
80
|
-
// cy.findByRole,
|
|
81
|
-
// role,
|
|
82
|
-
// roleOptions
|
|
83
|
-
// );
|
|
84
|
-
// }
|
|
85
|
-
//
|
|
86
|
-
// export function uuvFindByLabelText(labelTextToSearch: string, roleOptions: ByRoleOptions) : Cypress.Chainable<JQuery<HTMLElement>> {
|
|
87
|
-
// return abstractFindBy(
|
|
88
|
-
// cy.findByLabelText,
|
|
89
|
-
// labelTextToSearch,
|
|
90
|
-
// roleOptions
|
|
91
|
-
// );
|
|
92
|
-
// }
|
|
93
|
-
//
|
|
94
|
-
// export function uuvFindByText(textToSearch: string, roleOptions: ByRoleOptions) : Cypress.Chainable<JQuery<HTMLElement>> {
|
|
95
|
-
// return abstractFindBy(
|
|
96
|
-
// cy.findByText,
|
|
97
|
-
// (content: any, element: any) => {
|
|
98
|
-
// const hasText = (elem: any) => elem.textContent === textToSearch
|
|
99
|
-
// const elementHasText = hasText(element)
|
|
100
|
-
// const childrenDontHaveText = Array.from(element?.children || []).every(child => !hasText(child))
|
|
101
|
-
// return elementHasText && childrenDontHaveText
|
|
102
|
-
// },
|
|
103
|
-
// roleOptions
|
|
104
|
-
// );
|
|
105
|
-
// }
|
|
106
|
-
// export function uuvFindByTestId(testId: string) : Cypress.Chainable<JQuery<HTMLElement>> {
|
|
107
|
-
// return abstractFindBy(
|
|
108
|
-
// cy.findByTestId,
|
|
109
|
-
// testId,
|
|
110
|
-
// {}
|
|
111
|
-
// );
|
|
112
|
-
// }
|
|
113
|
-
//
|
|
114
|
-
// export function uuvFoundedElement(subject) : Cypress.Chainable<JQuery<HTMLElement>> {
|
|
115
|
-
// return cy.get('@foundedChildElement')
|
|
116
|
-
// .then((response: any) => {
|
|
117
|
-
// return response !== 'empty' && response !== null ? response.foundedChildElement : subject;
|
|
118
|
-
// });
|
|
119
|
-
// }
|
|
3
|
+
* Software Name : UUV
|
|
4
|
+
*
|
|
5
|
+
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
6
|
+
* SPDX-License-Identifier: MIT
|
|
7
|
+
*
|
|
8
|
+
* This software is distributed under the MIT License,
|
|
9
|
+
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
10
|
+
* or see the "LICENSE" file for more details.
|
|
11
|
+
*
|
|
12
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
13
|
+
* Software description: Make test writing fast, understandable by any human
|
|
14
|
+
* understanding English or French.
|
|
15
|
+
*/
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Software Name : UUV
|
|
3
|
-
*
|
|
4
|
-
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
5
|
-
* SPDX-License-Identifier: MIT
|
|
6
|
-
*
|
|
7
|
-
* This software is distributed under the MIT License,
|
|
8
|
-
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
9
|
-
* or see the "LICENSE" file for more details.
|
|
10
|
-
*
|
|
11
|
-
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
12
|
-
* Software description: Make test writing fast, understandable by any human
|
|
13
|
-
* understanding English or French.
|
|
14
|
-
*/
|
|
2
|
+
* Software Name : UUV
|
|
3
|
+
*
|
|
4
|
+
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*
|
|
7
|
+
* This software is distributed under the MIT License,
|
|
8
|
+
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
9
|
+
* or see the "LICENSE" file for more details.
|
|
10
|
+
*
|
|
11
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
12
|
+
* Software description: Make test writing fast, understandable by any human
|
|
13
|
+
* understanding English or French.
|
|
14
|
+
*/
|
|
15
15
|
export {};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Software Name : UUV
|
|
4
|
-
*
|
|
5
|
-
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
6
|
-
* SPDX-License-Identifier: MIT
|
|
7
|
-
*
|
|
8
|
-
* This software is distributed under the MIT License,
|
|
9
|
-
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
10
|
-
* or see the "LICENSE" file for more details.
|
|
11
|
-
*
|
|
12
|
-
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
13
|
-
* Software description: Make test writing fast, understandable by any human
|
|
14
|
-
* understanding English or French.
|
|
15
|
-
*/
|
|
3
|
+
* Software Name : UUV
|
|
4
|
+
*
|
|
5
|
+
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
6
|
+
* SPDX-License-Identifier: MIT
|
|
7
|
+
*
|
|
8
|
+
* This software is distributed under the MIT License,
|
|
9
|
+
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
10
|
+
* or see the "LICENSE" file for more details.
|
|
11
|
+
*
|
|
12
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
13
|
+
* Software description: Make test writing fast, understandable by any human
|
|
14
|
+
* understanding English or French.
|
|
15
|
+
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
const runner_commons_1 = require("@uuv/runner-commons");
|
|
18
18
|
const axe_playwright_1 = require("axe-playwright");
|
|
@@ -48,10 +48,24 @@ const cucumber_1 = require("@cucumber/cucumber");
|
|
|
48
48
|
(0, cucumber_1.When)(`${runner_commons_1.key.when.type}`, async function (textToType) {
|
|
49
49
|
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
|
|
50
50
|
await element.focus({ timeout: 10000 });
|
|
51
|
-
await element.
|
|
51
|
+
await element.type(textToType);
|
|
52
52
|
// console.debug(await showAttributesInLocator(element));
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
|
+
(0, cucumber_1.When)(`${runner_commons_1.key.when.keyboard.multiplePress}`, async function (nbTimes, key) {
|
|
56
|
+
for (let i = 1; i <= nbTimes; i++) {
|
|
57
|
+
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
|
|
58
|
+
await element.focus({ timeout: 10000 });
|
|
59
|
+
await pressKey(this, element, key);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
(0, cucumber_1.When)(`${runner_commons_1.key.when.keyboard.press}`, async function (key) {
|
|
64
|
+
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
|
|
65
|
+
await element.focus({ timeout: 10000 });
|
|
66
|
+
await pressKey(this, element, key);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
55
69
|
(0, cucumber_1.When)(`${runner_commons_1.key.when.timeout}`, async function (newTimeout) {
|
|
56
70
|
await this.testInfo.setTimeout(newTimeout);
|
|
57
71
|
});
|
|
@@ -116,10 +130,50 @@ const cucumber_1 = require("@cucumber/cucumber");
|
|
|
116
130
|
testId = encodeURIComponent(testId);
|
|
117
131
|
await (0, core_engine_1.getPageOrElement)(this).then((element) => (0, test_1.expect)(element.getByTestId(testId, { exact: true })).toHaveCount(0));
|
|
118
132
|
});
|
|
119
|
-
(0, cucumber_1.Then)(`${runner_commons_1.key.then.a11y.check}`, async function () {
|
|
133
|
+
(0, cucumber_1.Then)(`${runner_commons_1.key.then.a11y.check.default}`, async function () {
|
|
120
134
|
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
121
135
|
await (0, axe_playwright_1.checkA11y)(this.page);
|
|
122
136
|
});
|
|
137
|
+
(0, cucumber_1.Then)(`${runner_commons_1.key.then.a11y.check.withFixtureOption}`, async function (option) {
|
|
138
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
139
|
+
const optionFile = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${option}`);
|
|
140
|
+
const optionJson = JSON.parse(optionFile.toString());
|
|
141
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
142
|
+
axeOptions: optionJson
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
(0, cucumber_1.Then)(`${runner_commons_1.key.then.a11y.check.withFixtureContextAndFixtureOption}`, async function (context, option) {
|
|
146
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
147
|
+
const contextFile = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${context}`);
|
|
148
|
+
const optionFile = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${option}`);
|
|
149
|
+
const optionJson = JSON.parse(optionFile.toString());
|
|
150
|
+
await (0, axe_playwright_1.checkA11y)(this.page, JSON.parse(contextFile.toString()), {
|
|
151
|
+
axeOptions: optionJson
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
(0, cucumber_1.Then)(`${runner_commons_1.key.then.a11y.check.onlyCritical}`, async function () {
|
|
155
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
156
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
157
|
+
includedImpacts: ["critical"]
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
(0, cucumber_1.Then)(`${runner_commons_1.key.then.a11y.check.withImpacts}`, async function (impacts) {
|
|
161
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
162
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
163
|
+
includedImpacts: [impacts]
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
(0, cucumber_1.Then)(`${runner_commons_1.key.then.a11y.check.withTags}`, async function (tags) {
|
|
167
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
168
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
169
|
+
axeOptions: {
|
|
170
|
+
runOnly: {
|
|
171
|
+
type: "tag",
|
|
172
|
+
values: [tags]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
});
|
|
123
177
|
(0, cucumber_1.Then)(`${runner_commons_1.key.then.element.not.withRoleAndName}`, async function (role, name) {
|
|
124
178
|
await (0, core_engine_1.notFoundWithRoleAndName)(this, role, name);
|
|
125
179
|
});
|
|
@@ -188,3 +242,30 @@ const cucumber_1 = require("@cucumber/cucumber");
|
|
|
188
242
|
await (0, test_1.expect)(foundedElement).toEqual(expectedElementsOfList.raw());
|
|
189
243
|
});
|
|
190
244
|
});
|
|
245
|
+
async function pressKey(world, element, key) {
|
|
246
|
+
switch (key) {
|
|
247
|
+
case runner_commons_1.KEY_PRESS.TAB:
|
|
248
|
+
await element.press("Tab");
|
|
249
|
+
break;
|
|
250
|
+
case runner_commons_1.KEY_PRESS.REVERSE_TAB:
|
|
251
|
+
await element.press("ShiftLeft+Tab");
|
|
252
|
+
break;
|
|
253
|
+
case runner_commons_1.KEY_PRESS.UP:
|
|
254
|
+
await element.press("ArrowUp");
|
|
255
|
+
break;
|
|
256
|
+
case runner_commons_1.KEY_PRESS.DOWN:
|
|
257
|
+
await element.press("ArrowDown");
|
|
258
|
+
break;
|
|
259
|
+
case runner_commons_1.KEY_PRESS.LEFT:
|
|
260
|
+
await element.press("ArrowLeft");
|
|
261
|
+
break;
|
|
262
|
+
case runner_commons_1.KEY_PRESS.RIGHT:
|
|
263
|
+
await element.press("ArrowRight");
|
|
264
|
+
break;
|
|
265
|
+
default:
|
|
266
|
+
console.error("the command" + key + " is unrecognized.");
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
await (0, core_engine_1.deleteCookieByName)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
|
|
270
|
+
await (0, core_engine_1.addCookieWhenValueIsList)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, { name: core_engine_1.FILTER_TYPE.SELECTOR_PARENT, value: "*:focus" });
|
|
271
|
+
}
|
|
@@ -32,6 +32,7 @@ var FILTER_TYPE;
|
|
|
32
32
|
FILTER_TYPE["TEXT"] = "byText";
|
|
33
33
|
FILTER_TYPE["ARIA_LABEL"] = "byAriaLabel";
|
|
34
34
|
FILTER_TYPE["TEST_ID"] = "byTestId";
|
|
35
|
+
FILTER_TYPE["SELECTOR_PARENT"] = "bySelectorParent";
|
|
35
36
|
})(FILTER_TYPE = exports.FILTER_TYPE || (exports.FILTER_TYPE = {}));
|
|
36
37
|
async function getPageOrElement(world) {
|
|
37
38
|
let pointer = world.page;
|
|
@@ -57,6 +58,9 @@ async function getPageOrElement(world) {
|
|
|
57
58
|
case FILTER_TYPE.TEXT:
|
|
58
59
|
pointer = pointer.getByText(filter.value);
|
|
59
60
|
break;
|
|
61
|
+
case FILTER_TYPE.SELECTOR_PARENT:
|
|
62
|
+
pointer = pointer.locator(filter.value);
|
|
63
|
+
break;
|
|
60
64
|
default:
|
|
61
65
|
break;
|
|
62
66
|
}
|
|
@@ -4,19 +4,19 @@ NE PAS MODIFIER, FICHIER GENERE
|
|
|
4
4
|
*******************************/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
/**
|
|
7
|
-
* Software Name : UUV
|
|
8
|
-
*
|
|
9
|
-
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
10
|
-
* SPDX-License-Identifier: MIT
|
|
11
|
-
*
|
|
12
|
-
* This software is distributed under the MIT License,
|
|
13
|
-
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
14
|
-
* or see the "LICENSE" file for more details.
|
|
15
|
-
*
|
|
16
|
-
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
17
|
-
* Software description: Make test writing fast, understandable by any human
|
|
18
|
-
* understanding English or French.
|
|
19
|
-
*/
|
|
7
|
+
* Software Name : UUV
|
|
8
|
+
*
|
|
9
|
+
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
10
|
+
* SPDX-License-Identifier: MIT
|
|
11
|
+
*
|
|
12
|
+
* This software is distributed under the MIT License,
|
|
13
|
+
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
14
|
+
* or see the "LICENSE" file for more details.
|
|
15
|
+
*
|
|
16
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
17
|
+
* Software description: Make test writing fast, understandable by any human
|
|
18
|
+
* understanding English or French.
|
|
19
|
+
*/
|
|
20
20
|
const runner_commons_1 = require("@uuv/runner-commons");
|
|
21
21
|
const axe_playwright_1 = require("axe-playwright");
|
|
22
22
|
const test_1 = require("@playwright/test");
|
|
@@ -51,10 +51,24 @@ const cucumber_1 = require("@cucumber/cucumber");
|
|
|
51
51
|
(0, cucumber_1.When)(`I type the sentence {string}`, async function (textToType) {
|
|
52
52
|
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
|
|
53
53
|
await element.focus({ timeout: 10000 });
|
|
54
|
-
await element.
|
|
54
|
+
await element.type(textToType);
|
|
55
55
|
// console.debug(await showAttributesInLocator(element));
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
|
+
(0, cucumber_1.When)(`I press {int} times on {string}`, async function (nbTimes, key) {
|
|
59
|
+
for (let i = 1; i <= nbTimes; i++) {
|
|
60
|
+
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
|
|
61
|
+
await element.focus({ timeout: 10000 });
|
|
62
|
+
await pressKey(this, element, key);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
(0, cucumber_1.When)(`I press {string}`, async function (key) {
|
|
67
|
+
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
|
|
68
|
+
await element.focus({ timeout: 10000 });
|
|
69
|
+
await pressKey(this, element, key);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
58
72
|
(0, cucumber_1.When)(`I set timeout with value {int}`, async function (newTimeout) {
|
|
59
73
|
await this.testInfo.setTimeout(newTimeout);
|
|
60
74
|
});
|
|
@@ -123,6 +137,46 @@ const cucumber_1 = require("@cucumber/cucumber");
|
|
|
123
137
|
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
124
138
|
await (0, axe_playwright_1.checkA11y)(this.page);
|
|
125
139
|
});
|
|
140
|
+
(0, cucumber_1.Then)(`I should not have any accessibility issue with option json fixture {}`, async function (option) {
|
|
141
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
142
|
+
const optionFile = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${option}`);
|
|
143
|
+
const optionJson = JSON.parse(optionFile.toString());
|
|
144
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
145
|
+
axeOptions: optionJson
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
(0, cucumber_1.Then)(`I should not have any accessibility issue with context json fixture {} and option json fixture {}`, async function (context, option) {
|
|
149
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
150
|
+
const contextFile = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${context}`);
|
|
151
|
+
const optionFile = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${option}`);
|
|
152
|
+
const optionJson = JSON.parse(optionFile.toString());
|
|
153
|
+
await (0, axe_playwright_1.checkA11y)(this.page, JSON.parse(contextFile.toString()), {
|
|
154
|
+
axeOptions: optionJson
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
(0, cucumber_1.Then)(`I should not have any critical accessibility issue`, async function () {
|
|
158
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
159
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
160
|
+
includedImpacts: ["critical"]
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
(0, cucumber_1.Then)(`I should not have any accessibility issue with {} impact(s)`, async function (impacts) {
|
|
164
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
165
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
166
|
+
includedImpacts: [impacts]
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
(0, cucumber_1.Then)(`I should not have any accessibility issue with accessibility standard(s) {}`, async function (tags) {
|
|
170
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
171
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
172
|
+
axeOptions: {
|
|
173
|
+
runOnly: {
|
|
174
|
+
type: "tag",
|
|
175
|
+
values: [tags]
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
126
180
|
(0, cucumber_1.Then)(`I should not see an element with role {string} and name {string}`, async function (role, name) {
|
|
127
181
|
await (0, core_engine_1.notFoundWithRoleAndName)(this, role, name);
|
|
128
182
|
});
|
|
@@ -191,3 +245,30 @@ const cucumber_1 = require("@cucumber/cucumber");
|
|
|
191
245
|
await (0, test_1.expect)(foundedElement).toEqual(expectedElementsOfList.raw());
|
|
192
246
|
});
|
|
193
247
|
});
|
|
248
|
+
async function pressKey(world, element, key) {
|
|
249
|
+
switch (key) {
|
|
250
|
+
case runner_commons_1.KEY_PRESS.TAB:
|
|
251
|
+
await element.press("Tab");
|
|
252
|
+
break;
|
|
253
|
+
case runner_commons_1.KEY_PRESS.REVERSE_TAB:
|
|
254
|
+
await element.press("ShiftLeft+Tab");
|
|
255
|
+
break;
|
|
256
|
+
case runner_commons_1.KEY_PRESS.UP:
|
|
257
|
+
await element.press("ArrowUp");
|
|
258
|
+
break;
|
|
259
|
+
case runner_commons_1.KEY_PRESS.DOWN:
|
|
260
|
+
await element.press("ArrowDown");
|
|
261
|
+
break;
|
|
262
|
+
case runner_commons_1.KEY_PRESS.LEFT:
|
|
263
|
+
await element.press("ArrowLeft");
|
|
264
|
+
break;
|
|
265
|
+
case runner_commons_1.KEY_PRESS.RIGHT:
|
|
266
|
+
await element.press("ArrowRight");
|
|
267
|
+
break;
|
|
268
|
+
default:
|
|
269
|
+
console.error("the command" + key + " is unrecognized.");
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
await (0, core_engine_1.deleteCookieByName)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
|
|
273
|
+
await (0, core_engine_1.addCookieWhenValueIsList)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, { name: core_engine_1.FILTER_TYPE.SELECTOR_PARENT, value: "*:focus" });
|
|
274
|
+
}
|
|
@@ -4,19 +4,19 @@ NE PAS MODIFIER, FICHIER GENERE
|
|
|
4
4
|
*******************************/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
/**
|
|
7
|
-
* Software Name : UUV
|
|
8
|
-
*
|
|
9
|
-
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
10
|
-
* SPDX-License-Identifier: MIT
|
|
11
|
-
*
|
|
12
|
-
* This software is distributed under the MIT License,
|
|
13
|
-
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
14
|
-
* or see the "LICENSE" file for more details.
|
|
15
|
-
*
|
|
16
|
-
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
17
|
-
* Software description: Make test writing fast, understandable by any human
|
|
18
|
-
* understanding English or French.
|
|
19
|
-
*/
|
|
7
|
+
* Software Name : UUV
|
|
8
|
+
*
|
|
9
|
+
* SPDX-FileCopyrightText: Copyright (c) 2022-2023 Orange
|
|
10
|
+
* SPDX-License-Identifier: MIT
|
|
11
|
+
*
|
|
12
|
+
* This software is distributed under the MIT License,
|
|
13
|
+
* the text of which is available at https://spdx.org/licenses/MIT.html
|
|
14
|
+
* or see the "LICENSE" file for more details.
|
|
15
|
+
*
|
|
16
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
17
|
+
* Software description: Make test writing fast, understandable by any human
|
|
18
|
+
* understanding English or French.
|
|
19
|
+
*/
|
|
20
20
|
const runner_commons_1 = require("@uuv/runner-commons");
|
|
21
21
|
const axe_playwright_1 = require("axe-playwright");
|
|
22
22
|
const test_1 = require("@playwright/test");
|
|
@@ -51,10 +51,24 @@ const cucumber_1 = require("@cucumber/cucumber");
|
|
|
51
51
|
(0, cucumber_1.When)(`je saisie le(s) mot(s) {string}`, async function (textToType) {
|
|
52
52
|
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
|
|
53
53
|
await element.focus({ timeout: 10000 });
|
|
54
|
-
await element.
|
|
54
|
+
await element.type(textToType);
|
|
55
55
|
// console.debug(await showAttributesInLocator(element));
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
|
+
(0, cucumber_1.When)(`j'appuie {int} fois sur {string}`, async function (nbTimes, key) {
|
|
59
|
+
for (let i = 1; i <= nbTimes; i++) {
|
|
60
|
+
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
|
|
61
|
+
await element.focus({ timeout: 10000 });
|
|
62
|
+
await pressKey(this, element, key);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
(0, cucumber_1.When)(`j'appuie sur {string}`, async function (key) {
|
|
67
|
+
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
|
|
68
|
+
await element.focus({ timeout: 10000 });
|
|
69
|
+
await pressKey(this, element, key);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
58
72
|
(0, cucumber_1.When)(`je positionne le timeout à {int} secondes`, async function (newTimeout) {
|
|
59
73
|
await this.testInfo.setTimeout(newTimeout);
|
|
60
74
|
});
|
|
@@ -123,6 +137,46 @@ const cucumber_1 = require("@cucumber/cucumber");
|
|
|
123
137
|
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
124
138
|
await (0, axe_playwright_1.checkA11y)(this.page);
|
|
125
139
|
});
|
|
140
|
+
(0, cucumber_1.Then)(`je ne dois pas avoir de problèmes d'accessibilité avec le fichier json suivant d'option {}`, async function (option) {
|
|
141
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
142
|
+
const optionFile = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${option}`);
|
|
143
|
+
const optionJson = JSON.parse(optionFile.toString());
|
|
144
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
145
|
+
axeOptions: optionJson
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
(0, cucumber_1.Then)(`je ne dois pas avoir de problèmes d'accessibilité sur le fichier json suivant de contexte {} et avec le fichier json suivant d'option {}`, async function (context, option) {
|
|
149
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
150
|
+
const contextFile = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${context}`);
|
|
151
|
+
const optionFile = await runner_commons_1.fs.readFileSync(`playwright/fixtures/${option}`);
|
|
152
|
+
const optionJson = JSON.parse(optionFile.toString());
|
|
153
|
+
await (0, axe_playwright_1.checkA11y)(this.page, JSON.parse(contextFile.toString()), {
|
|
154
|
+
axeOptions: optionJson
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
(0, cucumber_1.Then)(`je ne dois pas avoir de problèmes d'accessibilité de niveau critique`, async function () {
|
|
158
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
159
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
160
|
+
includedImpacts: ["critical"]
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
(0, cucumber_1.Then)(`je ne dois pas avoir de problèmes d'accessibilité avec l(es) impact(s) {}`, async function (impacts) {
|
|
164
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
165
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
166
|
+
includedImpacts: [impacts]
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
(0, cucumber_1.Then)(`je ne dois pas avoir de problèmes d'accessibilité avec le(s) standard(s) {}`, async function (tags) {
|
|
170
|
+
await (0, axe_playwright_1.injectAxe)(this.page);
|
|
171
|
+
await (0, axe_playwright_1.checkA11y)(this.page, undefined, {
|
|
172
|
+
axeOptions: {
|
|
173
|
+
runOnly: {
|
|
174
|
+
type: "tag",
|
|
175
|
+
values: [tags]
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
126
180
|
(0, cucumber_1.Then)(`je ne dois pas voir un élément avec le rôle {string} et le nom {string}`, async function (role, name) {
|
|
127
181
|
await (0, core_engine_1.notFoundWithRoleAndName)(this, role, name);
|
|
128
182
|
});
|
|
@@ -191,3 +245,30 @@ const cucumber_1 = require("@cucumber/cucumber");
|
|
|
191
245
|
await (0, test_1.expect)(foundedElement).toEqual(expectedElementsOfList.raw());
|
|
192
246
|
});
|
|
193
247
|
});
|
|
248
|
+
async function pressKey(world, element, key) {
|
|
249
|
+
switch (key) {
|
|
250
|
+
case runner_commons_1.KEY_PRESS.TAB:
|
|
251
|
+
await element.press("Tab");
|
|
252
|
+
break;
|
|
253
|
+
case runner_commons_1.KEY_PRESS.REVERSE_TAB:
|
|
254
|
+
await element.press("ShiftLeft+Tab");
|
|
255
|
+
break;
|
|
256
|
+
case runner_commons_1.KEY_PRESS.UP:
|
|
257
|
+
await element.press("ArrowUp");
|
|
258
|
+
break;
|
|
259
|
+
case runner_commons_1.KEY_PRESS.DOWN:
|
|
260
|
+
await element.press("ArrowDown");
|
|
261
|
+
break;
|
|
262
|
+
case runner_commons_1.KEY_PRESS.LEFT:
|
|
263
|
+
await element.press("ArrowLeft");
|
|
264
|
+
break;
|
|
265
|
+
case runner_commons_1.KEY_PRESS.RIGHT:
|
|
266
|
+
await element.press("ArrowRight");
|
|
267
|
+
break;
|
|
268
|
+
default:
|
|
269
|
+
console.error("the command" + key + " is unrecognized.");
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
await (0, core_engine_1.deleteCookieByName)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
|
|
273
|
+
await (0, core_engine_1.addCookieWhenValueIsList)(world, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT, { name: core_engine_1.FILTER_TYPE.SELECTOR_PARENT, value: "*:focus" });
|
|
274
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uuv/playwright",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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.
|
|
49
|
+
"@uuv/runner-commons": "1.6.0",
|
|
50
50
|
"axe-core": "4.7.2",
|
|
51
51
|
"axe-playwright": "1.2.3",
|
|
52
52
|
"chalk": "4.1.2",
|