@uuv/a11y 1.0.0-beta.4 → 1.0.0-beta.40

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +348 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/LICENSE +1 -1
  4. package/bundle/uuv-a11y.bundle.js +2 -2
  5. package/dist/CHANGELOG.md +348 -0
  6. package/dist/CONTRIBUTING.md +1 -1
  7. package/dist/lib/engine/engine.js +28 -16
  8. package/dist/lib/model/index.d.ts +1 -1
  9. package/dist/lib/model/index.js +1 -1
  10. package/dist/lib/model/reference.js +1 -1
  11. package/dist/lib/model/result.d.ts +2 -1
  12. package/dist/lib/model/result.js +1 -1
  13. package/dist/lib/model/rule.d.ts +0 -7
  14. package/dist/lib/model/rule.js +3 -5
  15. package/dist/lib/query/00-query.d.ts +6 -1
  16. package/dist/lib/query/00-query.js +10 -0
  17. package/dist/lib/query/accessible-name.query.d.ts +4 -2
  18. package/dist/lib/query/accessible-name.query.js +9 -3
  19. package/dist/lib/query/by-role.query.d.ts +4 -3
  20. package/dist/lib/query/by-role.query.js +22 -6
  21. package/dist/lib/query/by-sibling.query.d.ts +12 -0
  22. package/dist/lib/query/by-sibling.query.js +100 -0
  23. package/dist/lib/query/by-tag.query.d.ts +2 -2
  24. package/dist/lib/query/by-tag.query.js +2 -1
  25. package/dist/lib/query/compliant-attributes/attribut-specification.d.ts +34 -0
  26. package/dist/lib/query/compliant-attributes/attribut-specification.js +96 -0
  27. package/dist/lib/query/compliant-attributes/attribute-checker.d.ts +47 -0
  28. package/dist/lib/query/compliant-attributes/attribute-checker.js +73 -0
  29. package/dist/lib/query/compliant-attributes/compliant-attributes.query.d.ts +9 -0
  30. package/dist/lib/query/compliant-attributes/compliant-attributes.query.js +24 -0
  31. package/dist/lib/query/doctype.query.d.ts +2 -2
  32. package/dist/lib/query/doctype.query.js +2 -1
  33. package/dist/lib/query/form.query.d.ts +2 -2
  34. package/dist/lib/query/index.d.ts +7 -0
  35. package/dist/lib/query/index.js +7 -0
  36. package/dist/lib/query/operators/and-query.d.ts +8 -0
  37. package/dist/lib/query/operators/and-query.js +25 -0
  38. package/dist/lib/query/operators/operator-query.d.ts +8 -0
  39. package/dist/lib/query/operators/operator-query.js +14 -0
  40. package/dist/lib/query/operators/or-query.d.ts +8 -0
  41. package/dist/lib/query/operators/or-query.js +24 -0
  42. package/dist/lib/reference/rgaa/coverage/coverage-statement.json +56 -17
  43. package/dist/lib/reference/rgaa/rules/1-image.d.ts +0 -1
  44. package/dist/lib/reference/rgaa/rules/1-image.js +51 -77
  45. package/dist/lib/reference/rgaa/rules/11-form.d.ts +0 -1
  46. package/dist/lib/reference/rgaa/rules/11-form.js +0 -1
  47. package/dist/lib/reference/rgaa/rules/2-frame.d.ts +0 -1
  48. package/dist/lib/reference/rgaa/rules/2-frame.js +8 -7
  49. package/dist/lib/reference/rgaa/rules/3-color.d.ts +0 -1
  50. package/dist/lib/reference/rgaa/rules/3-color.js +0 -3
  51. package/dist/lib/reference/rgaa/rules/5-table.d.ts +12 -1
  52. package/dist/lib/reference/rgaa/rules/5-table.js +292 -1
  53. package/dist/lib/reference/rgaa/rules/6-link.d.ts +12 -1
  54. package/dist/lib/reference/rgaa/rules/6-link.js +147 -1
  55. package/dist/lib/reference/rgaa/rules/8-required-element.d.ts +0 -1
  56. package/dist/lib/reference/rgaa/rules/8-required-element.js +57 -9
  57. package/dist/lib/reference/rgaa/selector-helper.d.ts +40 -1
  58. package/dist/lib/reference/rgaa/selector-helper.js +82 -10
  59. package/dist/package.json +11 -7
  60. package/package.json +11 -7
@@ -1,8 +1,9 @@
1
- import { Query } from "./00-query";
1
+ import { Query, QueryResult } from "./00-query";
2
2
  export declare class ByRoleQuery implements Query {
3
3
  readonly role: string;
4
4
  readonly attributes: string[];
5
- constructor(role: string, attributes?: string[]);
6
- execute(): HTMLElement[];
5
+ readonly excludedTags: string[];
6
+ constructor(role: string, attributes?: string[], excludedTags?: string[]);
7
+ execute(): QueryResult[];
7
8
  getSelector(): string;
8
9
  }
@@ -1,27 +1,43 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.ByRoleQuery = void 0;
7
+ const _00_query_1 = require("./00-query");
4
8
  const dom_1 = require("@testing-library/dom");
9
+ const lodash_1 = __importDefault(require("lodash"));
5
10
  class ByRoleQuery {
6
11
  role;
7
12
  attributes;
8
- constructor(role, attributes = []) {
13
+ excludedTags;
14
+ constructor(role, attributes = [], excludedTags = []) {
9
15
  this.role = role;
10
16
  this.attributes = attributes;
17
+ this.excludedTags = excludedTags;
11
18
  }
12
19
  execute() {
13
20
  return (0, dom_1.queryAllByRole)(window.document.documentElement, this.role)
14
21
  ?.filter((element) => {
15
- if (this.attributes.length == 0) {
22
+ if (lodash_1.default.isEmpty(this.attributes) && lodash_1.default.isEmpty(this.excludedTags)) {
16
23
  return true;
17
24
  }
18
- return this.attributes.filter(value => {
25
+ const foundExcludedTags = this.excludedTags.filter(value => {
26
+ return element.tagName.toLowerCase() === value;
27
+ });
28
+ const foundAttributes = this.attributes.filter(value => {
19
29
  return element.getAttribute(value);
20
- }).length > 0;
21
- });
30
+ });
31
+ const hasFoundExcludedTags = !lodash_1.default.isEmpty(this.excludedTags) && !lodash_1.default.isEmpty(foundExcludedTags);
32
+ const hasFoundAttributes = !lodash_1.default.isEmpty(this.attributes) && !lodash_1.default.isEmpty(foundAttributes);
33
+ return (!hasFoundExcludedTags &&
34
+ hasFoundAttributes) ||
35
+ lodash_1.default.isEmpty(this.excludedTags) && hasFoundAttributes ||
36
+ lodash_1.default.isEmpty(this.attributes) && !hasFoundExcludedTags;
37
+ }).map((element) => new _00_query_1.QueryResult(element));
22
38
  }
23
39
  getSelector() {
24
- return `ByRole(${this.role}, ${this.attributes})`;
40
+ return `ByRole(${this.role}, ${this.excludedTags}, ${this.attributes})`;
25
41
  }
26
42
  }
27
43
  exports.ByRoleQuery = ByRoleQuery;
@@ -0,0 +1,12 @@
1
+ import { Query, QueryResult } from "./00-query";
2
+ export declare class BySiblingQuery implements Query {
3
+ readonly subQuery: Query;
4
+ readonly shouldBeFound: boolean;
5
+ readonly siblingTags: string[];
6
+ constructor(subQuery: Query, shouldBeFound: boolean, siblingTags: string[]);
7
+ execute(): QueryResult[];
8
+ private computeResult;
9
+ private foundSiblingElement;
10
+ getSelector(): string;
11
+ private addGhostInputNode;
12
+ }
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BySiblingQuery = void 0;
7
+ const _00_query_1 = require("./00-query");
8
+ const lodash_1 = __importDefault(require("lodash"));
9
+ const emulate_tab_1 = require("emulate-tab");
10
+ const DATA_TESTID = "data-testid";
11
+ const BODY = "BODY";
12
+ class BySiblingQuery {
13
+ subQuery;
14
+ shouldBeFound;
15
+ siblingTags;
16
+ constructor(subQuery, shouldBeFound, siblingTags) {
17
+ this.subQuery = subQuery;
18
+ this.shouldBeFound = shouldBeFound;
19
+ this.siblingTags = siblingTags;
20
+ }
21
+ execute() {
22
+ const result = [];
23
+ this.subQuery.execute().forEach((currentElement) => {
24
+ const element = currentElement.domNode;
25
+ element.focus();
26
+ if (document.activeElement?.tagName === BODY) {
27
+ const ghost = this.addGhostInputNode(element);
28
+ ghost.focus();
29
+ this.computeResult(element, result, ghost);
30
+ ghost.remove();
31
+ }
32
+ else {
33
+ this.computeResult(element, result);
34
+ }
35
+ });
36
+ return result;
37
+ }
38
+ computeResult(element, result, ghost = undefined) {
39
+ const elementFocused = ghost ?? element;
40
+ const siblingElements = [];
41
+ emulate_tab_1.emulateTab.findSelectableElements().forEach((value, index, collection) => {
42
+ if (value.getAttribute(DATA_TESTID) === elementFocused.getAttribute(DATA_TESTID)) {
43
+ const previousExist = index - 1 >= 0;
44
+ const nextExist = index + 1 <= collection.length - 1;
45
+ if (this.shouldBeFound) {
46
+ if (previousExist && this.foundSiblingElement(collection[index - 1])) {
47
+ siblingElements.push(collection[index - 1]);
48
+ }
49
+ if (nextExist && this.foundSiblingElement(collection[index + 1])) {
50
+ siblingElements.push(collection[index + 1]);
51
+ }
52
+ if (!lodash_1.default.isEmpty(siblingElements)) {
53
+ result.push(new _00_query_1.QueryResult(element, siblingElements));
54
+ }
55
+ }
56
+ else {
57
+ if ((previousExist &&
58
+ !this.foundSiblingElement(collection[index - 1]) &&
59
+ nextExist &&
60
+ !this.foundSiblingElement(collection[index + 1]))) {
61
+ siblingElements.push(collection[index - 1]);
62
+ siblingElements.push(collection[index + 1]);
63
+ }
64
+ if ((previousExist &&
65
+ !this.foundSiblingElement(collection[index - 1]) &&
66
+ !nextExist)) {
67
+ siblingElements.push(collection[index - 1]);
68
+ result.push(new _00_query_1.QueryResult(element, siblingElements));
69
+ }
70
+ if ((!previousExist &&
71
+ nextExist &&
72
+ !this.foundSiblingElement(collection[index + 1]))) {
73
+ siblingElements.push(collection[index + 1]);
74
+ }
75
+ if (!lodash_1.default.isEmpty(siblingElements)) {
76
+ result.push(new _00_query_1.QueryResult(element, siblingElements));
77
+ }
78
+ }
79
+ }
80
+ });
81
+ }
82
+ foundSiblingElement(element) {
83
+ return this.siblingTags.includes(element.tagName.toLowerCase());
84
+ }
85
+ getSelector() {
86
+ return `${this.subQuery.getSelector()}`;
87
+ }
88
+ addGhostInputNode(element) {
89
+ const input = document.createElement("input");
90
+ input.setAttribute(DATA_TESTID, "to-delete-" + String(Math.floor(Math.random() * Date.now())));
91
+ if (element.parentNode) {
92
+ element.parentNode.insertBefore(input, element.nextSibling);
93
+ }
94
+ else {
95
+ element.insertBefore(input, element.nextSibling);
96
+ }
97
+ return input;
98
+ }
99
+ }
100
+ exports.BySiblingQuery = BySiblingQuery;
@@ -1,7 +1,7 @@
1
- import { Query } from "./00-query";
1
+ import { Query, QueryResult } from "./00-query";
2
2
  export declare class ByTagQuery implements Query {
3
3
  readonly selectors: string[];
4
4
  constructor(selectors: string[]);
5
- execute(): HTMLElement[];
5
+ execute(): QueryResult[];
6
6
  getSelector(): string;
7
7
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ByTagQuery = void 0;
4
+ const _00_query_1 = require("./00-query");
4
5
  // eslint-disable-next-line @typescript-eslint/no-var-requires
5
6
  const $ = require("jquery/dist/jquery.min");
6
7
  class ByTagQuery {
@@ -9,7 +10,7 @@ class ByTagQuery {
9
10
  this.selectors = selectors;
10
11
  }
11
12
  execute() {
12
- return $(this.selectors.join(",")).toArray();
13
+ return $(this.selectors.join(",")).toArray().map((element) => new _00_query_1.QueryResult(element));
13
14
  }
14
15
  getSelector() {
15
16
  return `${this.selectors}`;
@@ -0,0 +1,34 @@
1
+ export interface IAttributeSpecification {
2
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
3
+ }
4
+ export declare class EmptyAttributeSpecification implements IAttributeSpecification {
5
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
6
+ }
7
+ export declare class NotEmptyAttributeSpecification implements IAttributeSpecification {
8
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
9
+ }
10
+ export declare class EmptyElementWithIdSpecification implements IAttributeSpecification {
11
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
12
+ }
13
+ export declare class NotUniqueIdAttributeSpecification implements IAttributeSpecification {
14
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
15
+ }
16
+ export declare class NotEqualsAttributeSpecification implements IAttributeSpecification {
17
+ private expectedValueList;
18
+ constructor(expectedValueList: string[]);
19
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
20
+ }
21
+ export declare class EqualsAttributeSpecification implements IAttributeSpecification {
22
+ private expectedValueList;
23
+ constructor(expectedValueList: string[]);
24
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
25
+ }
26
+ export declare class AccessibleNameNotContainsVisibleTextSpecification implements IAttributeSpecification {
27
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
28
+ }
29
+ export declare class EmptyInnerTextSpecification implements IAttributeSpecification {
30
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
31
+ }
32
+ export declare class NotEmptyInnerTextSpecification implements IAttributeSpecification {
33
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
34
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NotEmptyInnerTextSpecification = exports.EmptyInnerTextSpecification = exports.AccessibleNameNotContainsVisibleTextSpecification = exports.EqualsAttributeSpecification = exports.NotEqualsAttributeSpecification = exports.NotUniqueIdAttributeSpecification = exports.EmptyElementWithIdSpecification = exports.NotEmptyAttributeSpecification = exports.EmptyAttributeSpecification = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
9
+ const $ = require("jquery/dist/jquery.min");
10
+ const dom_accessibility_api_1 = require("dom-accessibility-api");
11
+ class EmptyAttributeSpecification {
12
+ isSatisfiedBy(element, attributeName) {
13
+ const attributeValue = element.getAttribute(attributeName);
14
+ return lodash_1.default.isEmpty(attributeValue);
15
+ }
16
+ }
17
+ exports.EmptyAttributeSpecification = EmptyAttributeSpecification;
18
+ class NotEmptyAttributeSpecification {
19
+ isSatisfiedBy(element, attributeName) {
20
+ const attributeValue = element.getAttribute(attributeName);
21
+ return !lodash_1.default.isEmpty(attributeValue);
22
+ }
23
+ }
24
+ exports.NotEmptyAttributeSpecification = NotEmptyAttributeSpecification;
25
+ class EmptyElementWithIdSpecification {
26
+ isSatisfiedBy(element, attributeName) {
27
+ const attributeValue = element.getAttribute(attributeName);
28
+ if (attributeValue === null || lodash_1.default.isEmpty(attributeValue)) {
29
+ return true;
30
+ }
31
+ const bindingNodeId = $(`#${attributeValue.replaceAll(".", "\\.")}`).text();
32
+ return lodash_1.default.isEmpty(bindingNodeId);
33
+ }
34
+ }
35
+ exports.EmptyElementWithIdSpecification = EmptyElementWithIdSpecification;
36
+ class NotUniqueIdAttributeSpecification {
37
+ isSatisfiedBy(element, attributeName) {
38
+ if (lodash_1.default.isNull(element.id) || lodash_1.default.isEmpty(element.id)) {
39
+ return true;
40
+ }
41
+ return $(`[id=${element.id}]`).length > 1;
42
+ }
43
+ }
44
+ exports.NotUniqueIdAttributeSpecification = NotUniqueIdAttributeSpecification;
45
+ class NotEqualsAttributeSpecification {
46
+ expectedValueList;
47
+ constructor(expectedValueList) {
48
+ this.expectedValueList = expectedValueList;
49
+ }
50
+ isSatisfiedBy(element, attributeName) {
51
+ const attributeValue = element.getAttribute(attributeName);
52
+ if (attributeValue === null) {
53
+ return true;
54
+ }
55
+ return !this.expectedValueList.includes(attributeValue);
56
+ }
57
+ }
58
+ exports.NotEqualsAttributeSpecification = NotEqualsAttributeSpecification;
59
+ class EqualsAttributeSpecification {
60
+ expectedValueList;
61
+ constructor(expectedValueList) {
62
+ this.expectedValueList = expectedValueList;
63
+ }
64
+ isSatisfiedBy(element, attributeName) {
65
+ const attributeValue = element.getAttribute(attributeName);
66
+ if (attributeValue === null) {
67
+ return false;
68
+ }
69
+ return this.expectedValueList.includes(attributeValue);
70
+ }
71
+ }
72
+ exports.EqualsAttributeSpecification = EqualsAttributeSpecification;
73
+ class AccessibleNameNotContainsVisibleTextSpecification {
74
+ isSatisfiedBy(element, attributeName) {
75
+ const visibleText = element.textContent;
76
+ if (visibleText === null || lodash_1.default.isEmpty(visibleText)) {
77
+ return false;
78
+ }
79
+ const accessibleName = (0, dom_accessibility_api_1.computeAccessibleName)(element);
80
+ console.debug("visibleText", visibleText, "accessibleName", accessibleName);
81
+ return accessibleName?.toLowerCase().indexOf(visibleText.toLowerCase()) === -1;
82
+ }
83
+ }
84
+ exports.AccessibleNameNotContainsVisibleTextSpecification = AccessibleNameNotContainsVisibleTextSpecification;
85
+ class EmptyInnerTextSpecification {
86
+ isSatisfiedBy(element, attributeName) {
87
+ return lodash_1.default.isEmpty(element.textContent);
88
+ }
89
+ }
90
+ exports.EmptyInnerTextSpecification = EmptyInnerTextSpecification;
91
+ class NotEmptyInnerTextSpecification {
92
+ isSatisfiedBy(element, attributeName) {
93
+ return !lodash_1.default.isEmpty(element.textContent);
94
+ }
95
+ }
96
+ exports.NotEmptyInnerTextSpecification = NotEmptyInnerTextSpecification;
@@ -0,0 +1,47 @@
1
+ import { IAttributeSpecification } from "./attribut-specification";
2
+ export declare class CompliantSpecification {
3
+ readonly attribute: string;
4
+ specification: IAttributeSpecification;
5
+ constructor(attribute: string, specification: IAttributeSpecification);
6
+ }
7
+ export declare class AttributeChecker {
8
+ /**
9
+ * Check if the value of the attributeName is empty
10
+ * @param attributeName : HTMLElement attributeName
11
+ */
12
+ static emptyAttribute(attributeName: string): CompliantSpecification;
13
+ /**
14
+ * Check if the value of the attributeName is not empty
15
+ * @param attributeName : HTMLElement attributeName
16
+ */
17
+ static notEmptyAttribute(attributeName: string): CompliantSpecification;
18
+ /**
19
+ * Check that the text of the HTMLElement whose id matches the value of the attribute named attributeName another HTMLElement is empty
20
+ * @param attributeName : HTMLElement attribute name
21
+ */
22
+ static emptyHtmlNodeTargetedByTheAttribute(attributeName: string): CompliantSpecification;
23
+ /**
24
+ * Check that id attribute is not unique in current page
25
+ */
26
+ static notUniqueId(): CompliantSpecification;
27
+ /**
28
+ * Check that html element does not have the expected value
29
+ */
30
+ static notEquals(attributeName: string, expectedValueList: string[]): CompliantSpecification;
31
+ /**
32
+ * Check that html element have the expected value
33
+ */
34
+ static equals(attributeName: string, expectedValueList: string[]): CompliantSpecification;
35
+ /**
36
+ * Check that html element accessible name contains visible text ignoring case
37
+ */
38
+ static accessibleNameNotContainsVisibleText(): CompliantSpecification;
39
+ /**
40
+ * Check that html element have empty text
41
+ */
42
+ static emptyText(): CompliantSpecification;
43
+ /**
44
+ * Check that html element have not empty text
45
+ */
46
+ static notEmptyText(): CompliantSpecification;
47
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AttributeChecker = exports.CompliantSpecification = void 0;
4
+ const attribut_specification_1 = require("./attribut-specification");
5
+ class CompliantSpecification {
6
+ attribute;
7
+ specification;
8
+ constructor(attribute, specification) {
9
+ this.attribute = attribute;
10
+ this.specification = specification;
11
+ }
12
+ }
13
+ exports.CompliantSpecification = CompliantSpecification;
14
+ class AttributeChecker {
15
+ /**
16
+ * Check if the value of the attributeName is empty
17
+ * @param attributeName : HTMLElement attributeName
18
+ */
19
+ static emptyAttribute(attributeName) {
20
+ return new CompliantSpecification(attributeName, new attribut_specification_1.EmptyAttributeSpecification());
21
+ }
22
+ /**
23
+ * Check if the value of the attributeName is not empty
24
+ * @param attributeName : HTMLElement attributeName
25
+ */
26
+ static notEmptyAttribute(attributeName) {
27
+ return new CompliantSpecification(attributeName, new attribut_specification_1.NotEmptyAttributeSpecification());
28
+ }
29
+ /**
30
+ * Check that the text of the HTMLElement whose id matches the value of the attribute named attributeName another HTMLElement is empty
31
+ * @param attributeName : HTMLElement attribute name
32
+ */
33
+ static emptyHtmlNodeTargetedByTheAttribute(attributeName) {
34
+ return new CompliantSpecification(attributeName, new attribut_specification_1.EmptyElementWithIdSpecification());
35
+ }
36
+ /**
37
+ * Check that id attribute is not unique in current page
38
+ */
39
+ static notUniqueId() {
40
+ return new CompliantSpecification("id", new attribut_specification_1.NotUniqueIdAttributeSpecification());
41
+ }
42
+ /**
43
+ * Check that html element does not have the expected value
44
+ */
45
+ static notEquals(attributeName, expectedValueList) {
46
+ return new CompliantSpecification(attributeName, new attribut_specification_1.NotEqualsAttributeSpecification(expectedValueList));
47
+ }
48
+ /**
49
+ * Check that html element have the expected value
50
+ */
51
+ static equals(attributeName, expectedValueList) {
52
+ return new CompliantSpecification(attributeName, new attribut_specification_1.EqualsAttributeSpecification(expectedValueList));
53
+ }
54
+ /**
55
+ * Check that html element accessible name contains visible text ignoring case
56
+ */
57
+ static accessibleNameNotContainsVisibleText() {
58
+ return new CompliantSpecification("accessibleName", new attribut_specification_1.AccessibleNameNotContainsVisibleTextSpecification());
59
+ }
60
+ /**
61
+ * Check that html element have empty text
62
+ */
63
+ static emptyText() {
64
+ return new CompliantSpecification("text", new attribut_specification_1.EmptyInnerTextSpecification());
65
+ }
66
+ /**
67
+ * Check that html element have not empty text
68
+ */
69
+ static notEmptyText() {
70
+ return new CompliantSpecification("text", new attribut_specification_1.NotEmptyInnerTextSpecification());
71
+ }
72
+ }
73
+ exports.AttributeChecker = AttributeChecker;
@@ -0,0 +1,9 @@
1
+ import { Query, QueryResult } from "../00-query";
2
+ import { CompliantSpecification } from "./attribute-checker";
3
+ export declare class CompliantAttributesQuery implements Query {
4
+ readonly subQuery: Query;
5
+ readonly attributeSpecifications: CompliantSpecification[];
6
+ constructor(subQuery: Query, attributeSpecifications: CompliantSpecification[]);
7
+ execute(): QueryResult[];
8
+ getSelector(): string;
9
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CompliantAttributesQuery = void 0;
4
+ class CompliantAttributesQuery {
5
+ subQuery;
6
+ attributeSpecifications;
7
+ constructor(subQuery, attributeSpecifications) {
8
+ this.subQuery = subQuery;
9
+ this.attributeSpecifications = attributeSpecifications;
10
+ }
11
+ execute() {
12
+ return this.subQuery.execute().filter((element) => {
13
+ let result = true;
14
+ this.attributeSpecifications.forEach(attributeSpecification => {
15
+ result = result && attributeSpecification.specification.isSatisfiedBy(element.domNode, attributeSpecification.attribute);
16
+ });
17
+ return result;
18
+ });
19
+ }
20
+ getSelector() {
21
+ return `CompliantAttributes: ${this.subQuery.getSelector()}`;
22
+ }
23
+ }
24
+ exports.CompliantAttributesQuery = CompliantAttributesQuery;
@@ -1,5 +1,5 @@
1
- import { Query } from "./00-query";
1
+ import { Query, QueryResult } from "./00-query";
2
2
  export declare class DoctypeQuery implements Query {
3
- execute(): HTMLElement[];
3
+ execute(): QueryResult[];
4
4
  getSelector(): string;
5
5
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DoctypeQuery = void 0;
4
+ const _00_query_1 = require("./00-query");
4
5
  class DoctypeQuery {
5
6
  execute() {
6
7
  if (document?.doctype?.name !== "html") {
7
- return [document.documentElement];
8
+ return [new _00_query_1.QueryResult(document.documentElement)];
8
9
  }
9
10
  return [];
10
11
  }
@@ -1,8 +1,8 @@
1
- import { Query } from "./00-query";
1
+ import { Query, QueryResult } from "./00-query";
2
2
  export declare class FormQuery implements Query {
3
3
  LABEL_ATTRIBUTE: string;
4
4
  FORMFIELD_SELECTORS: string[];
5
5
  FORMFIELD_LABEL_ATTRIBUTES: string[];
6
- execute(): HTMLElement[];
6
+ execute(): QueryResult[];
7
7
  getSelector(): string;
8
8
  }
@@ -3,4 +3,11 @@ export * from "./by-tag.query";
3
3
  export * from "./doctype.query";
4
4
  export * from "./form.query";
5
5
  export * from "./by-role.query";
6
+ export * from "./by-sibling.query";
7
+ export * from "./operators/operator-query";
8
+ export * from "./operators/or-query";
9
+ export * from "./operators/and-query";
6
10
  export * from "./accessible-name.query";
11
+ export * from "./compliant-attributes/compliant-attributes.query";
12
+ export * from "./compliant-attributes/attribute-checker";
13
+ export * from "./compliant-attributes/attribut-specification";
@@ -19,4 +19,11 @@ __exportStar(require("./by-tag.query"), exports);
19
19
  __exportStar(require("./doctype.query"), exports);
20
20
  __exportStar(require("./form.query"), exports);
21
21
  __exportStar(require("./by-role.query"), exports);
22
+ __exportStar(require("./by-sibling.query"), exports);
23
+ __exportStar(require("./operators/operator-query"), exports);
24
+ __exportStar(require("./operators/or-query"), exports);
25
+ __exportStar(require("./operators/and-query"), exports);
22
26
  __exportStar(require("./accessible-name.query"), exports);
27
+ __exportStar(require("./compliant-attributes/compliant-attributes.query"), exports);
28
+ __exportStar(require("./compliant-attributes/attribute-checker"), exports);
29
+ __exportStar(require("./compliant-attributes/attribut-specification"), exports);
@@ -0,0 +1,8 @@
1
+ import { IOperatorQuery } from "./operator-query";
2
+ import { Query, QueryResult } from "../00-query";
3
+ export declare class AndQuery implements IOperatorQuery, Query {
4
+ readonly queries: Query[];
5
+ constructor(queries: Query[]);
6
+ execute(): QueryResult[];
7
+ getSelector(): string;
8
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AndQuery = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const DOM_NODE_ATTRIBUTE = "domNode";
9
+ class AndQuery {
10
+ queries;
11
+ constructor(queries) {
12
+ this.queries = queries;
13
+ }
14
+ execute() {
15
+ const queryResults = this.queries.map(query => query.execute());
16
+ return queryResults.reduce((left, right) => {
17
+ return lodash_1.default.intersectionBy(left, right, DOM_NODE_ATTRIBUTE);
18
+ });
19
+ }
20
+ getSelector() {
21
+ const result = this.queries.map(query => query.execute());
22
+ return `${lodash_1.default.intersection(...result).map(query => query.domNode).join(",")}`;
23
+ }
24
+ }
25
+ exports.AndQuery = AndQuery;
@@ -0,0 +1,8 @@
1
+ import { Query } from "../00-query";
2
+ export interface IOperatorQuery {
3
+ queries: Query[];
4
+ }
5
+ export declare class OperatorQuery {
6
+ static Or: (...queries: Query[]) => Query;
7
+ static And: (...queries: Query[]) => Query;
8
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OperatorQuery = void 0;
4
+ const or_query_1 = require("./or-query");
5
+ const and_query_1 = require("./and-query");
6
+ class OperatorQuery {
7
+ static Or = (...queries) => {
8
+ return new or_query_1.OrQuery(queries);
9
+ };
10
+ static And = (...queries) => {
11
+ return new and_query_1.AndQuery(queries);
12
+ };
13
+ }
14
+ exports.OperatorQuery = OperatorQuery;
@@ -0,0 +1,8 @@
1
+ import { IOperatorQuery } from "./operator-query";
2
+ import { Query, QueryResult } from "../00-query";
3
+ export declare class OrQuery implements IOperatorQuery, Query {
4
+ readonly queries: Query[];
5
+ constructor(queries: Query[]);
6
+ execute(): QueryResult[];
7
+ getSelector(): string;
8
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OrQuery = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const DOM_NODE_ATTRIBUTE = "domNode";
9
+ class OrQuery {
10
+ queries;
11
+ constructor(queries) {
12
+ this.queries = queries;
13
+ }
14
+ execute() {
15
+ const queryResults = this.queries.map(query => query.execute());
16
+ return queryResults.reduce((left, right) => {
17
+ return lodash_1.default.unionBy(left, right, DOM_NODE_ATTRIBUTE);
18
+ });
19
+ }
20
+ getSelector() {
21
+ return `${this.queries.map(query => query.getSelector()).join(",")}`;
22
+ }
23
+ }
24
+ exports.OrQuery = OrQuery;