@uuv/playwright
Version:
A solution to facilitate the writing and execution of E2E tests understandable by any human being using cucumber(BDD) and playwright
108 lines (107 loc) • 6.63 kB
JavaScript
;
/*******************************
NE PAS MODIFIER, FICHIER GENERE
*******************************/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Software Name : UUV
*
* SPDX-License-Identifier: MIT
*
* This software is distributed under the MIT License,
* see the "LICENSE" file for more details
*
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
* Software description: Make test writing fast, understandable by any human
* understanding English or French.
*/
const core_engine_1 = require("../../../core-engine");
const world_1 = require("../../../../../preprocessor/run/world");
const test_1 = require("@playwright/test");
// Begin of General Section
/**
* Selects the element whose [accessible role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types) and accessible [name](https://russmaxdesign.github.io/html-elements-names/) are specified <br />⚠ remember to deselect the element with <b>[I reset context](#i-reset-context)</b> if you're no longer acting on it
* */
(0, world_1.When)(`within a command named {string}`, async function (name) {
return await (0, core_engine_1.withinRoleAndName)(this, "command", name);
});
/**
* Checks that an Html element exists with the specified [accessible role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types) and [name](https://russmaxdesign.github.io/html-elements-names/)
* */
(0, world_1.Then)(`I should see a command named {string}`, async function (name) {
await (0, core_engine_1.findWithRoleAndName)(this, "command", name);
});
/**
* Checks that an Html element does not exists with the specified [accessible role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types) and [name](https://russmaxdesign.github.io/html-elements-names/)
* */
(0, world_1.Then)(`I should not see a command named {string}`, async function (name) {
await (0, core_engine_1.notFoundWithRoleAndName)(this, "command", name);
});
// End of General Section
// Begin of Type Section
/**
* Writes the sentence given as a parameter inside the specified field (useful for example to fill in a form field)
* */
(0, world_1.When)(`I type the sentence {string} in the command named {string}`, async function (textToType, name) {
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
const byRole = await element.getByRole("command", { name: name, exact: true });
await (0, test_1.expect)(byRole).toHaveCount(1, { timeout: await (0, core_engine_1.getTimeout)(this) });
await byRole.type(textToType);
await (0, core_engine_1.deleteCookieByName)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
});
});
/**
* Writes the sentence given as a parameter inside the specified field (useful for example to fill in a form field)
* */
(0, world_1.When)(`I enter the value {string} in the command named {string}`, async function (textToType, name) {
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
const byRole = await element.getByRole("command", { name: name, exact: true });
await (0, test_1.expect)(byRole).toHaveCount(1);
await byRole.type(textToType);
await (0, core_engine_1.deleteCookieByName)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
});
});
/**
* key.then.element.withRoleAndNameAndValue
* */
(0, world_1.When)(`I should see a command named {string} with value {string}`, async function (name, expectedValue) {
await (0, core_engine_1.getPageOrElement)(this).then(async (element) => {
const byRole = await element.getByRole("command", { name: name, exact: true });
await (0, test_1.expect)(byRole).toHaveCount(1, { timeout: await (0, core_engine_1.getTimeout)(this) });
await (0, test_1.expect)(byRole).toHaveValue(expectedValue, { timeout: await (0, core_engine_1.getTimeout)(this) });
await (0, core_engine_1.deleteCookieByName)(this, core_engine_1.COOKIE_NAME.SELECTED_ELEMENT);
});
});
// End of Type Section
// Begin of Content Section
/**
* Checks that an Html element exists with the specified [accessible role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types), [name](https://russmaxdesign.github.io/html-elements-names/) and content
* */
(0, world_1.Then)(`I should see a command named {string} and containing {string}`, async function (name, expectedTextContent) {
await (0, core_engine_1.findWithRoleAndNameAndContent)(this, "command", name, expectedTextContent);
});
/**
* Checks that an Html element exists with the specified [accessible role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types), [name](https://russmaxdesign.github.io/html-elements-names/) and content, and with the disabled attribute set to true
* */
(0, world_1.Then)(`I should see a command named {string} and containing {string} disabled`, async function (name, expectedTextContent) {
await (0, core_engine_1.findWithRoleAndNameAndContentDisabled)(this, "command", name, expectedTextContent);
});
/**
* Checks that an Html element exists with the specified [accessible role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types), [name](https://russmaxdesign.github.io/html-elements-names/), and with the disabled attribute set to true
* */
(0, world_1.Then)(`I should see a command named {string} disabled`, async function (name) {
await (0, core_engine_1.findWithRoleAndNameDisabled)(this, "command", name);
});
/**
* Checks that an Html element exists with the specified [accessible role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types), [name](https://russmaxdesign.github.io/html-elements-names/) and content, and with the disabled attribute set to false
* */
(0, world_1.Then)(`I should see a command named {string} and containing {string} enabled`, async function (name, expectedTextContent) {
await (0, core_engine_1.findWithRoleAndNameAndContentEnabled)(this, "command", name, expectedTextContent);
});
/**
* Checks that an Html element exists with the specified [accessible role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types), [name](https://russmaxdesign.github.io/html-elements-names/), and with the disabled attribute set to false
* */
(0, world_1.Then)(`I should see a command named {string} enabled`, async function (name) {
await (0, core_engine_1.findWithRoleAndNameEnabled)(this, "command", name);
});
// End of Content Section