/*******************************
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,
    findWithRoleAndNameAndContentDisable,
    findWithRoleAndNameAndContentEnable,
    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);
});

// 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} inactif`,
    function(name: string, expectedTextContent: string) {
        findWithRoleAndNameAndContentDisable("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} actif`,
    function(name: string, expectedTextContent: string) {
        findWithRoleAndNameAndContentEnable("complementary", name, expectedTextContent);
    }
);

// End of Content Section




