UNPKG

@uuv/assistant

Version:

UUV Helper used to improve the life of testers and developers by generating cucumber phrases from the GUI.

43 lines (42 loc) 2 kB
"use strict"; /** * 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.KeyboardNavigationTranslator = void 0; const abstract_translator_1 = require("./abstract-translator"); const model_1 = require("./model"); const stepCase = model_1.StepCaseEnum.THEN; class KeyboardNavigationTranslator extends abstract_translator_1.Translator { getSentenceFromAccessibleRoleAndName(accessibleRole, accessibleName) { const response = this.initResponse(); const computedKey = "key.then.element.nextWithRoleAndNameFocused"; const sentence = this.computeSentenceFromKeyRoleAndName(computedKey, accessibleRole, accessibleName); response.sentences = [stepCase + sentence]; return response; } getSentenceFromAccessibleRoleAndNameAndContent(accessibleRole, accessibleName, content) { return this.getSentenceFromAccessibleRoleAndName(accessibleRole, accessibleName); } getSentenceFromDomSelector(domSelector, htmlElem) { const response = this.initResponse(); const computedKey = "key.then.element.withSelectorFocused"; const sentence = this.computeSentenceFromKeyAndSelector(computedKey, domSelector); const nextFocusedElementSentence = this.dictionary.getBaseSentences().find((el) => el.key === "key.when.keyboard.nextElement"); response.sentences = [ stepCase + (nextFocusedElementSentence === null || nextFocusedElementSentence === void 0 ? void 0 : nextFocusedElementSentence.wording), model_1.StepCaseEnum.AND + sentence ]; return response; } } exports.KeyboardNavigationTranslator = KeyboardNavigationTranslator;