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

127 lines (126 loc) 8.22 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 cypress_cucumber_preprocessor_1 = require("@badeball/cypress-cucumber-preprocessor"); require("../../../../../../cypress/commands"); const core_engine_1 = require("../../../core-engine"); const __common_1 = require("../../../_.common"); // 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, cypress_cucumber_preprocessor_1.When)(`within a button named {string}`, function (name) { (0, core_engine_1.withinRoleAndName)("button", 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, cypress_cucumber_preprocessor_1.Then)(`I should see a button named {string}`, function (name) { (0, core_engine_1.findWithRoleAndName)("button", 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, cypress_cucumber_preprocessor_1.Then)(`I should not see a button named {string}`, function (name) { (0, core_engine_1.notFoundWithRoleAndName)("button", name); }); // End of General Section // Begin of Click Section /** * Triggers a click on the element with role $roleId and the specified name * */ (0, cypress_cucumber_preprocessor_1.When)(`I click on button named {string}`, function (name) { (0, core_engine_1.click)("button", name); }); // End of Click 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, cypress_cucumber_preprocessor_1.When)(`I type the sentence {string} in the button named {string}`, function (textToType, name) { cy.uuvFindByRole("button", { name: name }).uuvFoundedElement().type(textToType); }); /** * Writes the sentence given as a parameter inside the specified field (useful for example to fill in a form field) * */ (0, cypress_cucumber_preprocessor_1.When)(`I enter the value {string} in the button named {string}`, function (textToType, name) { cy.uuvFindByRole("button", { name: name }).uuvFoundedElement().type(textToType); }); /** * Checks that an Form element(input) 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 specified value * */ (0, cypress_cucumber_preprocessor_1.Then)(`I should see a button named {string} with value {string}`, function (name, expectedValue) { cy.uuvFindByRole("button", { name: name }) .uuvFoundedElement() .should("exist") .should("have.value", expectedValue); }); // 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, cypress_cucumber_preprocessor_1.Then)(`I should see a button named {string} and containing {string}`, function (name, expectedTextContent) { (0, core_engine_1.findWithRoleAndNameAndContent)("button", 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, cypress_cucumber_preprocessor_1.Then)(`I should see a button named {string} and containing {string} disabled`, function (name, expectedTextContent) { (0, core_engine_1.findWithRoleAndNameAndContentDisabled)("button", 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 false * */ (0, cypress_cucumber_preprocessor_1.Then)(`I should see a button named {string} and containing {string} enabled`, function (name, expectedTextContent) { (0, core_engine_1.findWithRoleAndNameAndContentEnabled)("button", 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, cypress_cucumber_preprocessor_1.Then)(`I should see a button named {string} disabled`, function (name) { (0, core_engine_1.findWithRoleAndNameDisabled)("button", 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 with the disabled attribute set to false * */ (0, cypress_cucumber_preprocessor_1.Then)(`I should see a button named {string} enabled`, function (name) { (0, core_engine_1.findWithRoleAndNameEnabled)("button", name); }); // End of Content Section // Begin of Keyboard Section /** * Checks that the Html element 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/) is focused<br/><a target='_blank' href='https://github.com/e2e-test-quest/uuv/blob/main/example/en-keyboard.feature'>Examples</a> * */ (0, cypress_cucumber_preprocessor_1.Then)(`I should see a button named {string} keyboard focused`, function (name) { (0, core_engine_1.findWithRoleAndNameFocused)("button", name); }); /** * Move to the previous html element that can be reached with Tab and checks that the Html element 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/) is focused<br/><a target='_blank' href='https://github.com/e2e-test-quest/uuv/blob/main/example/en-keyboard.feature'>Examples</a> * */ (0, cypress_cucumber_preprocessor_1.Then)(`the previous keyboard element focused should be a button named {string}`, function (name) { (0, __common_1.pressKey)("{reverseTab}"); (0, core_engine_1.findWithRoleAndNameFocused)("button", name); }); /** * Move to the next html element that can be reached with Tab and checks that the Html element 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/) is focused<br/><a target='_blank' href='https://github.com/e2e-test-quest/uuv/blob/main/example/en-keyboard.feature'>Examples</a> * */ (0, cypress_cucumber_preprocessor_1.Then)(`the next keyboard element focused should be a button named {string}`, function (name) { (0, __common_1.pressKey)("{tab}"); (0, core_engine_1.findWithRoleAndNameFocused)("button", name); }); // End of Keyboard Section