UNPKG

@uuv/cypress

Version:

A solution to facilitate the writing and execution of E2E tests understandable by any human being using cucumber(BDD) and cypress

165 lines (140 loc) 6.52 kB
/******************************* NE PAS MODIFIER, FICHIER GENERE *******************************/ /** * 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. */ import { Then, When, } from "@badeball/cypress-cucumber-preprocessor"; import "../../../../../../cypress/commands"; import { click, findWithRoleAndName, findWithRoleAndNameAndAttribute, findWithRoleAndNameAndContent, findWithRoleAndNameAndContentDisabled, findWithRoleAndNameAndContentEnabled, findWithRoleAndNameDisabled, findWithRoleAndNameEnabled, findWithRoleAndNameFocused, notFoundWithRoleAndName, withinRoleAndName } from "../../../core-engine"; import { pressKey } from "../../../_.common"; // Begin of General Section /** * Sélectionne l'élément ayant le rôle combobox 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 * */ When(`je vais à l'intérieur de la liste déroulante nommée {string}`, function(name: string) { withinRoleAndName("combobox", name); }); /** * Vérifie l'existence d'un élément Html ayant le rôle combobox et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) spécifiés * */ Then(`je dois voir une liste déroulante nommée {string}`, function(name: string) { findWithRoleAndName("combobox", name); }); /** * Vérifie l'inexistence d'un élément Html ayant le rôle combobox et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) spécifiés * */ Then( `je ne dois pas voir une liste déroulante nommée {string}`, function(name: string) { notFoundWithRoleAndName("combobox", name); } ); // End of General Section // Begin of Click Section /** * Déclenche un click sur l'élément Html ayant le rôle $roleId, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) * */ When(`je clique sur la liste déroulante nommé {string}`, function(name: string) { click("combobox", name); }); // End of Click Section // Begin of Content Section /** * Vérifie l'existence d'un élément Html ayant le rôle combobox, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et le contenu spécifiés * */ Then( `je dois voir une liste déroulante nommée {string} et contenant {string}`, function(name: string, expectedTextContent: string) { findWithRoleAndNameAndContent("combobox", name, expectedTextContent); } ); /** * Vérifie l'existence d'un élément Html ayant le rôle combobox, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/), le contenu spécifiés et avec l'attribut disabled à false * */ Then( `je dois voir une liste déroulante nommée {string} et contenant {string} désactivé`, function(name: string, expectedTextContent: string) { findWithRoleAndNameAndContentDisabled("combobox", name, expectedTextContent); } ); /** * Vérifie l'existence d'un élément Html ayant le rôle combobox, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/), le contenu spécifiés et avec l'attribut disabled à true * */ Then( `je dois voir une liste déroulante nommée {string} et contenant {string} activé`, function(name: string, expectedTextContent: string) { findWithRoleAndNameAndContentEnabled("combobox", name, expectedTextContent); } ); /** * Vérifie l'existence d'un élément Html ayant le rôle combobox, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et avec l'attribut disabled à false * */ Then( `je dois voir une liste déroulante nommée {string} désactivé`, function(name: string) { findWithRoleAndNameDisabled("combobox", name); } ); /** * Vérifie l'existence d'un élément Html ayant le rôle combobox, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et avec l'attribut disabled à true * */ Then( `je dois voir une liste déroulante nommée {string} activé`, function(name: string) { findWithRoleAndNameEnabled("combobox", name); } ); // End of Content Section // Begin of Keyboard Section /** * Vérifie que l'élément Html avec le [rôle accessible](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types) et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) a le focus clavier<br/><a target='_blank' href='https://github.com/e2e-test-quest/uuv/blob/main/example/fr-keyboard.feature'>Exemples</a> * */ Then( `je dois voir une liste déroulante nommée {string} avoir le focus clavier`, function(name: string) { findWithRoleAndNameFocused("combobox", name); } ); /** * Se déplace au précédent élément HTML atteignable avec la tabulation et vérifie que l'élément Html avec le [rôle accessible](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types) et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) a le focus clavier<br/><a target='_blank' href='https://github.com/e2e-test-quest/uuv/blob/main/example/fr-keyboard.feature'>Exemples</a> * */ Then( `le précédent élément avec le focus clavier doit être une liste déroulante nommée {string}`, function(name: string) { pressKey("{reverseTab}"); findWithRoleAndNameFocused("combobox", name); } ); /** * Se déplace au prochain élément HTML atteignable avec la tabulation et vérifie que l'élément Html avec le [rôle accessible](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#aria_role_types) et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) a le focus clavier<br/><a target='_blank' href='https://github.com/e2e-test-quest/uuv/blob/main/example/fr-keyboard.feature'>Exemples</a> * */ Then( `le prochain élément avec le focus clavier doit être une liste déroulante nommée {string}`, function(name: string) { pressKey("{tab}"); findWithRoleAndNameFocused("combobox", name); } ); // End of Keyboard Section