@uuv/assistant 2.72.0 → 2.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/launcher/conf.json +1 -1
- package/dist/launcher/uuv-assistant.js +30 -19
- package/dist/src/Commons.d.ts +60 -0
- package/dist/src/Commons.js +55 -0
- package/dist/src/helper/css-helper.d.ts +47 -0
- package/dist/src/helper/css-helper.js +83 -0
- package/dist/src/helper/highlight/highlight-helper.d.ts +13 -0
- package/dist/src/helper/highlight/highlight-helper.js +51 -0
- package/dist/src/helper/highlight/inspector-dom.d.ts +7 -0
- package/dist/src/helper/highlight/inspector-dom.js +158 -0
- package/dist/src/helper/highlight/tooltip-helper.d.ts +2 -0
- package/dist/src/helper/highlight/tooltip-helper.js +67 -0
- package/dist/src/helper/index.d.ts +1 -0
- package/dist/src/helper/index.js +17 -0
- package/dist/src/helper/informative-nodes-helper.d.ts +38 -0
- package/dist/src/helper/informative-nodes-helper.js +250 -0
- package/dist/src/helper/keyboard-navigation-helper.d.ts +21 -0
- package/dist/src/helper/keyboard-navigation-helper.js +151 -0
- package/dist/src/helper/layer-helper.d.ts +12 -0
- package/dist/src/helper/layer-helper.js +149 -0
- package/dist/src/helper/result-display-helper.d.ts +2 -0
- package/dist/src/helper/result-display-helper.js +20 -0
- package/dist/src/helper/result-script-helper.d.ts +1 -0
- package/dist/src/helper/result-script-helper.js +30 -0
- package/dist/src/helper/selection-helper.d.ts +26 -0
- package/dist/src/helper/selection-helper.js +92 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +19 -0
- package/dist/src/service/abstract-component-service.d.ts +21 -0
- package/dist/src/service/abstract-component-service.js +107 -0
- package/dist/src/service/dialog-service.d.ts +22 -0
- package/dist/src/service/dialog-service.js +90 -0
- package/dist/src/service/form-completion-service.d.ts +23 -0
- package/dist/src/service/form-completion-service.js +72 -0
- package/dist/src/service/index.d.ts +4 -0
- package/dist/src/service/index.js +20 -0
- package/dist/src/service/table-and-grid-service.d.ts +17 -0
- package/dist/src/service/table-and-grid-service.js +87 -0
- package/dist/src/translator/abstract-translator.d.ts +29 -0
- package/dist/src/translator/abstract-translator.js +137 -0
- package/dist/src/translator/click-translator.d.ts +21 -0
- package/dist/src/translator/click-translator.js +60 -0
- package/dist/src/translator/expect-translator.d.ts +23 -0
- package/dist/src/translator/expect-translator.js +157 -0
- package/dist/src/translator/index.d.ts +8 -0
- package/dist/src/translator/index.js +24 -0
- package/dist/src/translator/keyboard-navigation-translator.d.ts +19 -0
- package/dist/src/translator/keyboard-navigation-translator.js +42 -0
- package/dist/src/translator/model.d.ts +38 -0
- package/dist/src/translator/model.js +31 -0
- package/dist/src/translator/textual-translator.d.ts +15 -0
- package/dist/src/translator/textual-translator.js +64 -0
- package/dist/src/translator/type-translator.d.ts +24 -0
- package/dist/src/translator/type-translator.js +121 -0
- package/dist/src/translator/within-translator.d.ts +19 -0
- package/dist/src/translator/within-translator.js +42 -0
- package/dist/uuv-assistant-resources.bundle.js +104 -99
- package/package.json +22 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Software Name : UUV
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This software is distributed under the MIT License,
|
|
7
|
+
* see the "LICENSE" file for more details
|
|
8
|
+
*
|
|
9
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
10
|
+
* Software description: Make test writing fast, understandable by any human
|
|
11
|
+
* understanding English or French.
|
|
12
|
+
*/
|
|
13
|
+
import { TranslateSentences } from "./model";
|
|
14
|
+
import { EnDictionary } from "@uuv/dictionary";
|
|
15
|
+
export declare abstract class Translator {
|
|
16
|
+
protected dictionary: EnDictionary;
|
|
17
|
+
protected selectedHtmlElem: HTMLElement | SVGElement;
|
|
18
|
+
translate(htmlElem: HTMLElement | SVGElement): Promise<TranslateSentences>;
|
|
19
|
+
abstract getSentenceFromDomSelector(htmlElem: HTMLElement | SVGElement): TranslateSentences;
|
|
20
|
+
abstract getSentenceFromAccessibleRoleAndName(accessibleRole: string, accessibleName: string): TranslateSentences;
|
|
21
|
+
abstract getSentenceFromAccessibleRoleAndNameAndContent(accessibleRole: string, accessibleName: string, content: string): TranslateSentences;
|
|
22
|
+
static getSelector(element: any): string;
|
|
23
|
+
protected initResponse(): TranslateSentences;
|
|
24
|
+
protected computeSentenceFromKeyRoleAndName(computedKey: string, accessibleRole: string, accessibleName: string): string;
|
|
25
|
+
protected computeSentenceFromKeyRoleNameAndContent(computedKey: string, accessibleRole: string, accessibleName: string, content: string): string;
|
|
26
|
+
protected computeSentenceFromKeyAndSelector(computedKey: string, selector: string): string;
|
|
27
|
+
computeSentenceFromKeyAndContent(computedKey: string, content: string): string;
|
|
28
|
+
getSentenceFromKey(key: string): import("@uuv/dictionary").BaseSentence;
|
|
29
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Software Name : UUV
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*
|
|
7
|
+
* This software is distributed under the MIT License,
|
|
8
|
+
* see the "LICENSE" file for more details
|
|
9
|
+
*
|
|
10
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
11
|
+
* Software description: Make test writing fast, understandable by any human
|
|
12
|
+
* understanding English or French.
|
|
13
|
+
*/
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.Translator = void 0;
|
|
25
|
+
const dom_accessibility_api_1 = require("dom-accessibility-api");
|
|
26
|
+
const model_1 = require("./model");
|
|
27
|
+
const dictionary_1 = require("@uuv/dictionary");
|
|
28
|
+
class Translator {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.dictionary = new dictionary_1.EnDictionary();
|
|
31
|
+
}
|
|
32
|
+
translate(htmlElem) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
const accessibleRole = (0, dom_accessibility_api_1.getRole)(htmlElem);
|
|
36
|
+
const accessibleName = (0, dom_accessibility_api_1.computeAccessibleName)(htmlElem);
|
|
37
|
+
this.selectedHtmlElem = htmlElem;
|
|
38
|
+
let response = {
|
|
39
|
+
suggestion: undefined,
|
|
40
|
+
sentences: []
|
|
41
|
+
};
|
|
42
|
+
if (htmlElem.getAttribute("type") !== "hidden") {
|
|
43
|
+
if (accessibleRole && accessibleName) {
|
|
44
|
+
const isInputHtmlOrTextArea = htmlElem instanceof HTMLInputElement || htmlElem instanceof HTMLTextAreaElement;
|
|
45
|
+
const content = isInputHtmlOrTextArea ?
|
|
46
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
47
|
+
htmlElem.value :
|
|
48
|
+
(_a = htmlElem.getAttribute("value")) !== null && _a !== void 0 ? _a : (_c = (_b = htmlElem.firstChild) === null || _b === void 0 ? void 0 : _b.textContent) === null || _c === void 0 ? void 0 : _c.trim();
|
|
49
|
+
if (content) {
|
|
50
|
+
response = this.getSentenceFromAccessibleRoleAndNameAndContent(accessibleRole, accessibleName, content);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
response = this.getSentenceFromAccessibleRoleAndName(accessibleRole, accessibleName);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
response = this.getSentenceFromDomSelector(htmlElem);
|
|
58
|
+
response.suggestion = new model_1.Suggestion();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return response;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
65
|
+
static getSelector(element) {
|
|
66
|
+
const path = [];
|
|
67
|
+
while (element.nodeType === Node.ELEMENT_NODE) {
|
|
68
|
+
let selector = element.nodeName.toLowerCase();
|
|
69
|
+
if (element.id) {
|
|
70
|
+
selector += "#" + element.id;
|
|
71
|
+
path.unshift(selector);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
else if (element.getAttribute("data-testid")) {
|
|
75
|
+
selector += `[data-testid=${element.getAttribute("data-testid")}]`;
|
|
76
|
+
path.unshift(selector);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
let sibling = element.previousSibling;
|
|
81
|
+
let index = 1;
|
|
82
|
+
while (sibling) {
|
|
83
|
+
if (sibling.nodeType === Node.ELEMENT_NODE && sibling.nodeName.toLowerCase() === selector) {
|
|
84
|
+
index++;
|
|
85
|
+
}
|
|
86
|
+
sibling = sibling.previousSibling;
|
|
87
|
+
}
|
|
88
|
+
if (index > 1 || element.nextSibling) {
|
|
89
|
+
selector += ":nth-of-type(" + index + ")";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
path.unshift(selector);
|
|
93
|
+
element = element.parentNode;
|
|
94
|
+
}
|
|
95
|
+
return path.join(" > ");
|
|
96
|
+
}
|
|
97
|
+
initResponse() {
|
|
98
|
+
return {
|
|
99
|
+
suggestion: undefined,
|
|
100
|
+
sentences: []
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
computeSentenceFromKeyRoleAndName(computedKey, accessibleRole, accessibleName) {
|
|
104
|
+
return this.dictionary.getRoleBasedSentencesTemplate()
|
|
105
|
+
.filter(value => value.key === computedKey)
|
|
106
|
+
.map(sentence => {
|
|
107
|
+
return this.dictionary.computeSentence({
|
|
108
|
+
sentence,
|
|
109
|
+
accessibleRole,
|
|
110
|
+
parameters: [accessibleName]
|
|
111
|
+
});
|
|
112
|
+
})[0];
|
|
113
|
+
}
|
|
114
|
+
computeSentenceFromKeyRoleNameAndContent(computedKey, accessibleRole, accessibleName, content) {
|
|
115
|
+
return this.dictionary.getRoleBasedSentencesTemplate()
|
|
116
|
+
.filter(value => value.key === computedKey)
|
|
117
|
+
.map(sentence => {
|
|
118
|
+
return this.dictionary.computeSentence({
|
|
119
|
+
sentence,
|
|
120
|
+
accessibleRole,
|
|
121
|
+
parameters: [accessibleName, content]
|
|
122
|
+
});
|
|
123
|
+
})[0];
|
|
124
|
+
}
|
|
125
|
+
computeSentenceFromKeyAndSelector(computedKey, selector) {
|
|
126
|
+
return this.dictionary.getBaseSentences()
|
|
127
|
+
.filter((el) => el.key === computedKey)
|
|
128
|
+
.map((el) => el.wording.replace("{string}", `"${selector}"`))[0];
|
|
129
|
+
}
|
|
130
|
+
computeSentenceFromKeyAndContent(computedKey, content) {
|
|
131
|
+
return this.computeSentenceFromKeyAndSelector(computedKey, content);
|
|
132
|
+
}
|
|
133
|
+
getSentenceFromKey(key) {
|
|
134
|
+
return this.dictionary.getBaseSentences().filter((el) => el.key === key)[0];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.Translator = Translator;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Software Name : UUV
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This software is distributed under the MIT License,
|
|
7
|
+
* see the "LICENSE" file for more details
|
|
8
|
+
*
|
|
9
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
10
|
+
* Software description: Make test writing fast, understandable by any human
|
|
11
|
+
* understanding English or French.
|
|
12
|
+
*/
|
|
13
|
+
import { Translator } from "./abstract-translator";
|
|
14
|
+
import { TranslateSentences } from "./model";
|
|
15
|
+
export declare class ClickTranslator extends Translator {
|
|
16
|
+
getSentenceFromAccessibleRoleAndName(accessibleRole: string, accessibleName: string): TranslateSentences;
|
|
17
|
+
getSentenceFromAccessibleRoleAndNameAndContent(accessibleRole: string, accessibleName: string, content: string): TranslateSentences;
|
|
18
|
+
getSentenceFromDomSelector(htmlElem: HTMLElement | SVGElement): TranslateSentences;
|
|
19
|
+
private buildSentencesWithRoleAndName;
|
|
20
|
+
private buildWording;
|
|
21
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Software Name : UUV
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*
|
|
7
|
+
* This software is distributed under the MIT License,
|
|
8
|
+
* see the "LICENSE" file for more details
|
|
9
|
+
*
|
|
10
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
11
|
+
* Software description: Make test writing fast, understandable by any human
|
|
12
|
+
* understanding English or French.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ClickTranslator = void 0;
|
|
16
|
+
const abstract_translator_1 = require("./abstract-translator");
|
|
17
|
+
const model_1 = require("./model");
|
|
18
|
+
const stepCase = model_1.StepCaseEnum.WHEN;
|
|
19
|
+
class ClickTranslator extends abstract_translator_1.Translator {
|
|
20
|
+
getSentenceFromAccessibleRoleAndName(accessibleRole, accessibleName) {
|
|
21
|
+
const response = this.initResponse();
|
|
22
|
+
response.sentences = this.buildSentencesWithRoleAndName(accessibleRole, accessibleName);
|
|
23
|
+
return response;
|
|
24
|
+
}
|
|
25
|
+
getSentenceFromAccessibleRoleAndNameAndContent(accessibleRole, accessibleName, content) {
|
|
26
|
+
return this.getSentenceFromAccessibleRoleAndName(accessibleRole, accessibleName);
|
|
27
|
+
}
|
|
28
|
+
getSentenceFromDomSelector(htmlElem) {
|
|
29
|
+
const response = this.initResponse();
|
|
30
|
+
const computedKey = "key.when.withinElement.selector";
|
|
31
|
+
const sentence = this.computeSentenceFromKeyAndSelector(computedKey, abstract_translator_1.Translator.getSelector(htmlElem));
|
|
32
|
+
const clickSentence = this.getSentenceFromKey("key.when.click.withContext");
|
|
33
|
+
response.sentences = [stepCase + sentence, model_1.StepCaseEnum.THEN + clickSentence.wording];
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
buildSentencesWithRoleAndName(accessibleRole, accessibleName) {
|
|
37
|
+
const role = this.dictionary.getDefinedRoles().find(role => role.shouldGenerateClickSentence && role.id === accessibleRole);
|
|
38
|
+
if (role) {
|
|
39
|
+
const wording = this.buildWording("key.when.click", accessibleRole, accessibleName);
|
|
40
|
+
return [stepCase + wording];
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const clickSentence = this.getSentenceFromKey("key.when.click.withRole");
|
|
44
|
+
return [stepCase + clickSentence.wording.replace("{string}", `"${accessibleRole}"`).replace("{string}", `"${accessibleName}"`)];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
48
|
+
buildWording(computedKey, accessibleRole, accessibleName) {
|
|
49
|
+
const clickSentence = [
|
|
50
|
+
...this.dictionary.getRoleBasedSentencesTemplate(),
|
|
51
|
+
...this.dictionary.getBaseSentences()
|
|
52
|
+
].find((el) => (el.key === computedKey));
|
|
53
|
+
return this.dictionary.computeSentence({
|
|
54
|
+
sentence: clickSentence,
|
|
55
|
+
accessibleRole,
|
|
56
|
+
parameters: [accessibleName]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.ClickTranslator = ClickTranslator;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Software Name : UUV
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This software is distributed under the MIT License,
|
|
7
|
+
* see the "LICENSE" file for more details
|
|
8
|
+
*
|
|
9
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
10
|
+
* Software description: Make test writing fast, understandable by any human
|
|
11
|
+
* understanding English or French.
|
|
12
|
+
*/
|
|
13
|
+
import { Translator } from "./abstract-translator";
|
|
14
|
+
import { TranslateSentences } from "./model";
|
|
15
|
+
export declare class ExpectTranslator extends Translator {
|
|
16
|
+
private buildResponse;
|
|
17
|
+
getSentenceFromAccessibleRoleAndName(role: string, name: string): TranslateSentences;
|
|
18
|
+
getSentenceFromAccessibleRoleAndNameAndContent(role: string, name: string, content: string): TranslateSentences;
|
|
19
|
+
getSentenceFromDomSelector(htmlElem: HTMLElement | SVGElement): TranslateSentences;
|
|
20
|
+
computeTableSentenceFromKeyNameAndContent(sentenceKey: string, indefiniteArticle: string, roleName: string, accessibleName: string, headers: HTMLElement, rows: HTMLElement[], cellRoleName: string): string;
|
|
21
|
+
computeDialogSentenceFromKeyNameAndContent(sentenceKey: string, accessibleName: string, row: HTMLElement): Promise<string[]>;
|
|
22
|
+
private formatMarkdownTable;
|
|
23
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Software Name : UUV
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*
|
|
7
|
+
* This software is distributed under the MIT License,
|
|
8
|
+
* see the "LICENSE" file for more details
|
|
9
|
+
*
|
|
10
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
11
|
+
* Software description: Make test writing fast, understandable by any human
|
|
12
|
+
* understanding English or French.
|
|
13
|
+
*/
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
48
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
49
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
51
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
52
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
53
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.ExpectTranslator = void 0;
|
|
58
|
+
const Commons_1 = require("../Commons");
|
|
59
|
+
const abstract_translator_1 = require("./abstract-translator");
|
|
60
|
+
const model_1 = require("./model");
|
|
61
|
+
const TextualTranslator = __importStar(require("./textual-translator"));
|
|
62
|
+
const informative_nodes_helper_1 = require("../helper/informative-nodes-helper");
|
|
63
|
+
const dom_accessibility_api_1 = require("dom-accessibility-api");
|
|
64
|
+
const stepCase = model_1.StepCaseEnum.THEN;
|
|
65
|
+
class ExpectTranslator extends abstract_translator_1.Translator {
|
|
66
|
+
buildResponse(sentences) {
|
|
67
|
+
const response = this.initResponse();
|
|
68
|
+
response.sentences = sentences.map(s => stepCase + s);
|
|
69
|
+
return response;
|
|
70
|
+
}
|
|
71
|
+
getSentenceFromAccessibleRoleAndName(role, name) {
|
|
72
|
+
const key = "key.then.element.withRoleAndName";
|
|
73
|
+
const sentence = this.computeSentenceFromKeyRoleAndName(key, role, name);
|
|
74
|
+
return this.buildResponse([sentence]);
|
|
75
|
+
}
|
|
76
|
+
getSentenceFromAccessibleRoleAndNameAndContent(role, name, content) {
|
|
77
|
+
const isDisabled = this.selectedHtmlElem.classList.contains(Commons_1.UUV_DISABLED_CLASS);
|
|
78
|
+
const key = isDisabled ? "key.then.element.withRoleAndNameAndContentDisabled" : "key.then.element.withRoleAndNameAndContent";
|
|
79
|
+
const sentence = this.computeSentenceFromKeyRoleNameAndContent(key, role, name, content);
|
|
80
|
+
return this.buildResponse([sentence]);
|
|
81
|
+
}
|
|
82
|
+
getSentenceFromDomSelector(htmlElem) {
|
|
83
|
+
const key = "key.then.element.withSelector";
|
|
84
|
+
const sentence = this.computeSentenceFromKeyAndSelector(key, abstract_translator_1.Translator.getSelector(htmlElem));
|
|
85
|
+
return this.buildResponse([sentence]);
|
|
86
|
+
}
|
|
87
|
+
computeTableSentenceFromKeyNameAndContent(sentenceKey, indefiniteArticle, roleName, accessibleName, headers, rows, cellRoleName) {
|
|
88
|
+
var _a;
|
|
89
|
+
if (!sentenceKey) {
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
const baseSentence = this.dictionary.getRoleBasedSentencesTemplate().find((v) => v.key === sentenceKey);
|
|
93
|
+
const sentenceAvailable = `Then ${(_a = baseSentence === null || baseSentence === void 0 ? void 0 : baseSentence.wording) !== null && _a !== void 0 ? _a : ""}`
|
|
94
|
+
.replace("$indefiniteArticle", `${indefiniteArticle}`)
|
|
95
|
+
.replace("$roleName", `${roleName}`)
|
|
96
|
+
.replace("{string}", `"${accessibleName}"`)
|
|
97
|
+
.replace("{string}", "");
|
|
98
|
+
const headerValues = Array.from(headers.querySelectorAll("[role=columnheader], th")).map(c => (0, dom_accessibility_api_1.computeAccessibleName)(c));
|
|
99
|
+
const tableLines = ["| " + headerValues.join(" | ") + " |", "| " + headerValues.map(() => "---").join(" | ") + " |"];
|
|
100
|
+
rows.forEach(row => {
|
|
101
|
+
const values = Array.from(row.querySelectorAll(`[role=${cellRoleName}], td, [role=columnheader], th`)).map(c => {
|
|
102
|
+
if (c.classList.contains("ag-floating-filter")) {
|
|
103
|
+
return Array.from(c.querySelectorAll("[role=button]:not(.ag-hidden [role=button]), button:not(.ag-hidden button)")).reduce((accumulator, button) => accumulator + (accumulator.length > 0 ? " " : "") + (0, dom_accessibility_api_1.computeAccessibleName)(button), "");
|
|
104
|
+
}
|
|
105
|
+
return (0, dom_accessibility_api_1.computeAccessibleName)(c);
|
|
106
|
+
});
|
|
107
|
+
tableLines.push("| " + values.join(" | ") + " |");
|
|
108
|
+
});
|
|
109
|
+
return sentenceAvailable + "\n" + this.formatMarkdownTable(tableLines).join("\n");
|
|
110
|
+
}
|
|
111
|
+
computeDialogSentenceFromKeyNameAndContent(sentenceKey, accessibleName, row) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const sentences = [`Then ${this.computeSentenceFromKeyRoleAndName(sentenceKey, "dialog", accessibleName)}`];
|
|
114
|
+
const getSentencesForNode = (node) => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
if (TextualTranslator.isTextualNode(node)) {
|
|
117
|
+
const res = yield TextualTranslator.computeSentence(node);
|
|
118
|
+
return (_a = res === null || res === void 0 ? void 0 : res.sentences) !== null && _a !== void 0 ? _a : [];
|
|
119
|
+
}
|
|
120
|
+
const res = yield this.translate(node);
|
|
121
|
+
return (_b = res === null || res === void 0 ? void 0 : res.sentences) !== null && _b !== void 0 ? _b : [];
|
|
122
|
+
});
|
|
123
|
+
const handleElement = (element) => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
if (element.children.length === 1) {
|
|
125
|
+
const informativeChildren = yield new informative_nodes_helper_1.InformativeNodesHelper().getAvailableChildren(element);
|
|
126
|
+
for (const child of informativeChildren) {
|
|
127
|
+
sentences.push(...(yield getSentencesForNode(child)));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
sentences.push(...(yield getSentencesForNode(element)));
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
yield Promise.all(Array.from(row.children).map(el => handleElement(el)));
|
|
135
|
+
return sentences;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
formatMarkdownTable(lines) {
|
|
139
|
+
const headerLine = lines.find(line => !/^ *\|? *-+/.test(line));
|
|
140
|
+
const separatorLine = lines.find(line => /^ *\|? *-+/.test(line));
|
|
141
|
+
const dataLines = lines.filter(line => line !== headerLine && line !== separatorLine && line.trim());
|
|
142
|
+
const parse = (line) => line
|
|
143
|
+
.replace(/^\||\|$/g, "")
|
|
144
|
+
.split("|")
|
|
145
|
+
.map(cell => cell.trim());
|
|
146
|
+
const header = parse(headerLine);
|
|
147
|
+
const rows = dataLines.map(parse);
|
|
148
|
+
const colCount = Math.max(header.length, ...rows.map(r => r.length));
|
|
149
|
+
const colWidths = Array(colCount).fill(0);
|
|
150
|
+
[header, ...rows].forEach(r => r.forEach((cell, i) => (colWidths[i] = Math.max(colWidths[i], cell.length))));
|
|
151
|
+
const FORMAT_PREFFIX = " ";
|
|
152
|
+
const formatRow = (row) => FORMAT_PREFFIX + "| " + row.map((cell, i) => cell.padEnd(colWidths[i])).join(" | ") + " |";
|
|
153
|
+
const separator = FORMAT_PREFFIX + "| " + colWidths.map(w => "-".repeat(w)).join(" | ") + " |";
|
|
154
|
+
return [formatRow(header), separator, ...rows.map(formatRow)];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.ExpectTranslator = ExpectTranslator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./model";
|
|
2
|
+
export * from "./abstract-translator";
|
|
3
|
+
export * from "./click-translator";
|
|
4
|
+
export * from "./expect-translator";
|
|
5
|
+
export * from "./keyboard-navigation-translator";
|
|
6
|
+
export * from "./textual-translator";
|
|
7
|
+
export * from "./type-translator";
|
|
8
|
+
export * from "./within-translator";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./model"), exports);
|
|
18
|
+
__exportStar(require("./abstract-translator"), exports);
|
|
19
|
+
__exportStar(require("./click-translator"), exports);
|
|
20
|
+
__exportStar(require("./expect-translator"), exports);
|
|
21
|
+
__exportStar(require("./keyboard-navigation-translator"), exports);
|
|
22
|
+
__exportStar(require("./textual-translator"), exports);
|
|
23
|
+
__exportStar(require("./type-translator"), exports);
|
|
24
|
+
__exportStar(require("./within-translator"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Software Name : UUV
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This software is distributed under the MIT License,
|
|
7
|
+
* see the "LICENSE" file for more details
|
|
8
|
+
*
|
|
9
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
10
|
+
* Software description: Make test writing fast, understandable by any human
|
|
11
|
+
* understanding English or French.
|
|
12
|
+
*/
|
|
13
|
+
import { Translator } from "./abstract-translator";
|
|
14
|
+
import { TranslateSentences } from "./model";
|
|
15
|
+
export declare class KeyboardNavigationTranslator extends Translator {
|
|
16
|
+
getSentenceFromAccessibleRoleAndName(accessibleRole: string, accessibleName: string): TranslateSentences;
|
|
17
|
+
getSentenceFromAccessibleRoleAndNameAndContent(accessibleRole: string, accessibleName: string, content: string): TranslateSentences;
|
|
18
|
+
getSentenceFromDomSelector(htmlElem: HTMLElement | SVGElement): TranslateSentences;
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Software Name : UUV
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*
|
|
7
|
+
* This software is distributed under the MIT License,
|
|
8
|
+
* see the "LICENSE" file for more details
|
|
9
|
+
*
|
|
10
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
11
|
+
* Software description: Make test writing fast, understandable by any human
|
|
12
|
+
* understanding English or French.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.KeyboardNavigationTranslator = void 0;
|
|
16
|
+
const abstract_translator_1 = require("./abstract-translator");
|
|
17
|
+
const model_1 = require("./model");
|
|
18
|
+
const stepCase = model_1.StepCaseEnum.THEN;
|
|
19
|
+
class KeyboardNavigationTranslator extends abstract_translator_1.Translator {
|
|
20
|
+
getSentenceFromAccessibleRoleAndName(accessibleRole, accessibleName) {
|
|
21
|
+
const response = this.initResponse();
|
|
22
|
+
const computedKey = "key.then.element.nextWithRoleAndNameFocused";
|
|
23
|
+
const sentence = this.computeSentenceFromKeyRoleAndName(computedKey, accessibleRole, accessibleName);
|
|
24
|
+
response.sentences = [stepCase + sentence];
|
|
25
|
+
return response;
|
|
26
|
+
}
|
|
27
|
+
getSentenceFromAccessibleRoleAndNameAndContent(accessibleRole, accessibleName, content) {
|
|
28
|
+
return this.getSentenceFromAccessibleRoleAndName(accessibleRole, accessibleName);
|
|
29
|
+
}
|
|
30
|
+
getSentenceFromDomSelector(htmlElem) {
|
|
31
|
+
const response = this.initResponse();
|
|
32
|
+
const computedKey = "key.then.element.withSelectorFocused";
|
|
33
|
+
const sentence = this.computeSentenceFromKeyAndSelector(computedKey, abstract_translator_1.Translator.getSelector(htmlElem));
|
|
34
|
+
const nextFocusedElementSentence = this.dictionary.getBaseSentences().find((el) => el.key === "key.when.keyboard.nextElement");
|
|
35
|
+
response.sentences = [
|
|
36
|
+
stepCase + (nextFocusedElementSentence === null || nextFocusedElementSentence === void 0 ? void 0 : nextFocusedElementSentence.wording),
|
|
37
|
+
model_1.StepCaseEnum.AND + sentence
|
|
38
|
+
];
|
|
39
|
+
return response;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.KeyboardNavigationTranslator = KeyboardNavigationTranslator;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Software Name : UUV
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This software is distributed under the MIT License,
|
|
7
|
+
* see the "LICENSE" file for more details
|
|
8
|
+
*
|
|
9
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
10
|
+
* Software description: Make test writing fast, understandable by any human
|
|
11
|
+
* understanding English or French.
|
|
12
|
+
*/
|
|
13
|
+
export declare class Suggestion {
|
|
14
|
+
accessibleAttribute: string;
|
|
15
|
+
accessibleValue: string;
|
|
16
|
+
code: string;
|
|
17
|
+
sentenceAfterCorrection: string[];
|
|
18
|
+
constructor(accessibleAttribute?: string, accessibleValue?: string, code?: string, sentenceAfterCorrection?: string[]);
|
|
19
|
+
}
|
|
20
|
+
export type BaseSentence = {
|
|
21
|
+
key: string;
|
|
22
|
+
description: string;
|
|
23
|
+
wording: string;
|
|
24
|
+
};
|
|
25
|
+
export type EnrichedSentence = {
|
|
26
|
+
key: string;
|
|
27
|
+
wording: string;
|
|
28
|
+
};
|
|
29
|
+
export declare enum StepCaseEnum {
|
|
30
|
+
WHEN = "When ",
|
|
31
|
+
THEN = "Then ",
|
|
32
|
+
GIVEN = "Given ",
|
|
33
|
+
AND = "And "
|
|
34
|
+
}
|
|
35
|
+
export type TranslateSentences = {
|
|
36
|
+
suggestion: Suggestion | undefined;
|
|
37
|
+
sentences: string[];
|
|
38
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Software Name : UUV
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*
|
|
7
|
+
* This software is distributed under the MIT License,
|
|
8
|
+
* see the "LICENSE" file for more details
|
|
9
|
+
*
|
|
10
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
11
|
+
* Software description: Make test writing fast, understandable by any human
|
|
12
|
+
* understanding English or French.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.StepCaseEnum = exports.Suggestion = void 0;
|
|
16
|
+
class Suggestion {
|
|
17
|
+
constructor(accessibleAttribute = "", accessibleValue = "", code = "", sentenceAfterCorrection = []) {
|
|
18
|
+
this.accessibleAttribute = accessibleAttribute;
|
|
19
|
+
this.accessibleValue = accessibleValue;
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.sentenceAfterCorrection = sentenceAfterCorrection;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Suggestion = Suggestion;
|
|
25
|
+
var StepCaseEnum;
|
|
26
|
+
(function (StepCaseEnum) {
|
|
27
|
+
StepCaseEnum["WHEN"] = "When ";
|
|
28
|
+
StepCaseEnum["THEN"] = "Then ";
|
|
29
|
+
StepCaseEnum["GIVEN"] = "Given ";
|
|
30
|
+
StepCaseEnum["AND"] = "And ";
|
|
31
|
+
})(StepCaseEnum || (exports.StepCaseEnum = StepCaseEnum = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Software Name : UUV
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* This software is distributed under the MIT License,
|
|
7
|
+
* see the "LICENSE" file for more details
|
|
8
|
+
*
|
|
9
|
+
* Authors: NJAKO MOLOM Louis Fredice & SERVICAL Stanley
|
|
10
|
+
* Software description: Make test writing fast, understandable by any human
|
|
11
|
+
* understanding English or French.
|
|
12
|
+
*/
|
|
13
|
+
import { TranslateSentences } from "./model";
|
|
14
|
+
export declare function computeSentence(element: HTMLElement | SVGElement | Element): Promise<TranslateSentences | null>;
|
|
15
|
+
export declare function isTextualNode(element: HTMLElement | SVGElement | Element): boolean;
|