@uuv/cypress
Version:
A solution to facilitate the writing and execution of E2E tests understandable by any human being using cucumber(BDD) and cypress
151 lines (127 loc) • 5.56 kB
text/typescript
/*******************************
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 complementary 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 du complémentaire nommé {string}`, function(name: string) {
withinRoleAndName("complementary", name);
});
/**
* Vérifie l'existence d'un élément Html ayant le rôle complementary et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) spécifiés
* */
Then(`je dois voir un complémentaire nommé {string}`, function(name: string) {
findWithRoleAndName("complementary", name);
});
/**
* Vérifie l'inexistence d'un élément Html ayant le rôle complementary et le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) spécifiés
* */
Then(
`je ne dois pas voir un complémentaire nommé {string}`,
function(name: string) {
notFoundWithRoleAndName("complementary", 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).
* */
When(`je saisie le(s) mot(s) {string} dans le complémentaire nommé {string}`, function(textToType: string, name: string) {
cy.uuvFindByRole("complementary", { name: name }).uuvFoundedElement().type(textToType);
});
/**
* Saisie de la phrase passée en paramètre dans le champ spécifié (utile par exemple pour remplir un champ de formulaire).
* */
When(`j'entre la valeur {string} dans le complémentaire nommé {string}`, function(textToType: string, name: string) {
cy.uuvFindByRole("complementary", { name: name }).uuvFoundedElement().type(textToType);
});
/**
* Vérifie l'existence d'un élément de formulaire (input) ayant le rôle complementary, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et la valeur spécifiée
* */
Then(
`je dois voir un complémentaire nommé {string} avec la valeur {string}`,
function(name: string, expectedValue: string) {
cy.uuvFindByRole("complementary", { name: name })
.uuvFoundedElement()
.should("exist")
.should("have.value", expectedValue);
}
);
// End of Type Section
// Begin of Content Section
/**
* Vérifie l'existence d'un élément Html ayant le rôle complementary, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et le contenu spécifiés
* */
Then(
`je dois voir un complémentaire nommé {string} et contenant {string}`,
function(name: string, expectedTextContent: string) {
findWithRoleAndNameAndContent("complementary", name, expectedTextContent);
}
);
/**
* Vérifie l'existence d'un élément Html ayant le rôle complementary, 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 un complémentaire nommé {string} et contenant {string} désactivé`,
function(name: string, expectedTextContent: string) {
findWithRoleAndNameAndContentDisabled("complementary", name, expectedTextContent);
}
);
/**
* Vérifie l'existence d'un élément Html ayant le rôle complementary, 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 un complémentaire nommé {string} et contenant {string} activé`,
function(name: string, expectedTextContent: string) {
findWithRoleAndNameAndContentEnabled("complementary", name, expectedTextContent);
}
);
/**
* Vérifie l'existence d'un élément Html ayant le rôle complementary, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et avec l'attribut disabled à false
* */
Then(
`je dois voir un complémentaire nommé {string} désactivé`,
function(name: string) {
findWithRoleAndNameDisabled("complementary", name);
}
);
/**
* Vérifie l'existence d'un élément Html ayant le rôle complementary, le [nom accessible](https://russmaxdesign.github.io/html-elements-names/) et avec l'attribut disabled à true
* */
Then(
`je dois voir un complémentaire nommé {string} activé`,
function(name: string) {
findWithRoleAndNameEnabled("complementary", name);
}
);
// End of Content Section