UNPKG

@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.12 kB
"use strict"; /******************************* 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 /** * Sélectionne l'élément ayant le rôle command et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) sont spécifiés <br />⚠ pensez à déselectionner l'élement avec <b>[je reinitialise le contexte](#je-reinitialise-le-contexte)</b> si vous n'agissez plus dessus * */ (0, world_1.When)(`je vais à l'intérieur de la commande nommée {string}`, async function (name) { return await (0, core_engine_1.withinRoleAndName)(this, "command", name); }); /** * Vérifie l'existence d'un élément Html ayant le rôle command et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) spécifiés * */ (0, world_1.Then)(`je dois voir une commande nommée {string}`, async function (name) { await (0, core_engine_1.findWithRoleAndName)(this, "command", name); }); /** * Vérifie l'inexistence d'un élément Html ayant le rôle command et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) spécifiés * */ (0, world_1.Then)(`je ne dois pas voir une commande nommée {string}`, async function (name) { await (0, core_engine_1.notFoundWithRoleAndName)(this, "command", name); }); // End of General Section // Begin of Type Section /** * Saisie de la phrase passée en paramètre dans le champ spécifié (utile par exemple pour remplir un champ de formulaire). * */ (0, world_1.When)(`je saisie le(s) mot(s) {string} dans la commande nommée {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); }); }); /** * Saisie de la phrase passée en paramètre dans le champ spécifié (utile par exemple pour remplir un champ de formulaire). * */ (0, world_1.When)(`j'entre la valeur {string} dans la commande nommée {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)(`je dois voir une commande nommée {string} avec la valeur {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 /** * Vérifie l'existence d'un élément Html ayant le rôle command, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et le contenu spécifiés * */ (0, world_1.Then)(`je dois voir une commande nommée {string} et contenant {string}`, async function (name, expectedTextContent) { await (0, core_engine_1.findWithRoleAndNameAndContent)(this, "command", name, expectedTextContent); }); /** * Vérifie l'existence d'un élément Html ayant le rôle command, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/), le contenu spécifiés et avec l'attribut disabled à false * */ (0, world_1.Then)(`je dois voir une commande nommée {string} et contenant {string} désactivé`, async function (name, expectedTextContent) { await (0, core_engine_1.findWithRoleAndNameAndContentDisabled)(this, "command", name, expectedTextContent); }); /** * Vérifie l'existence d'un élément Html ayant le rôle command, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et avec l'attribut disabled à false * */ (0, world_1.Then)(`je dois voir une commande nommée {string} désactivé`, async function (name) { await (0, core_engine_1.findWithRoleAndNameDisabled)(this, "command", name); }); /** * Vérifie l'existence d'un élément Html ayant le rôle command, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/), le contenu spécifiés et avec l'attribut disabled à true * */ (0, world_1.Then)(`je dois voir une commande nommée {string} et contenant {string} activé`, async function (name, expectedTextContent) { await (0, core_engine_1.findWithRoleAndNameAndContentEnabled)(this, "command", name, expectedTextContent); }); /** * Vérifie l'existence d'un élément Html ayant le rôle command, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et avec l'attribut disabled à true * */ (0, world_1.Then)(`je dois voir une commande nommée {string} activé`, async function (name) { await (0, core_engine_1.findWithRoleAndNameEnabled)(this, "command", name); }); // End of Content Section