Skip to content

Commit

Permalink
Implement SIA-R54 (#834)
Browse files Browse the repository at this point in the history
* Add basic tests for R11 (#770)

* Remove second expectation from R62 (#772)

* Implement pseudo classes equality (#773)

* Add toString() to Nth
* Add equals() and toString() to functional pseudo-classes and elements

* Name computation: skip step 1 when descending (#778)

* Add failing example
* Skip step 1 when descending

* SIA R62: accept different font weight (#779)

* Add failing example
* Accept font weight difference with container as good for SIA-R62

* Extended diagnostic for R14 (#786)

* Add label and name in Diagnostic for R14
* Add tests for R42

* Fix background size (#788)

* Add test cases for `background-size`
* Accept percentages and two values for background-size
* Use Tuple to store dimensions in background-size

* Assume no background on size (#789)

* Bail out of background colour computation when encountering a background-size

* SIA R17: add test (#791)

* Create rule.spec.tsx

* sia-r17 added test

* Apply suggestions from code review

Co-authored-by: Jean-Yves Moyen <[email protected]>

Co-authored-by: Jean-Yves Moyen <[email protected]>

* SIA R4: test added (#793)

* SIA R3: add test (#792)

* Sia r3 testing added

* Apply suggestions from code review

Co-authored-by: Jean-Yves Moyen <[email protected]>

Co-authored-by: Jean-Yves Moyen <[email protected]>

* R6 test added (#795)

* Run prettier

* Add --immutable flag to install instruction, add intructions for running tests

* Simplify double negative

* SIA R5: add test (#794)

* Test r5 added

* Apply suggestions from code review

Co-authored-by: Jean-Yves Moyen <[email protected]>

* variable const target changed to html

Co-authored-by: Jean-Yves Moyen <[email protected]>

* SIA R12: Add Test (#800)

* Pass tests for R12 implemented, starting with failed

* Update rule.spec.tsx

* Test rule 12 finished

* Apply suggestions from code review

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Text sintax improved

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Fix hasRole to pick the role from the accessible node (#805)

* Clean up

* R18 add test (#803)

* Bump actions/create-release from 1 to 1.1.4 (#802)

Bumps [actions/create-release](https://github.com/actions/create-release) from 1 to 1.1.4.
- [Release notes](https://github.com/actions/create-release/releases)
- [Commits](actions/create-release@v1...v1.1.4)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* SIA R18: Added test

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jean-Yves Moyen <[email protected]>

* SIA-R19: Add test (#807)

* Test for R19 Added

* Added test for rule 19

* Apply suggestions from code review

Co-authored-by: Jean-Yves Moyen <[email protected]>

Co-authored-by: Jean-Yves Moyen <[email protected]>

* SIA-R8: Added tests (#806)

* Added test to Rule 8

* Apply suggestions from code review

Co-authored-by: Jean-Yves Moyen <[email protected]>

Co-authored-by: Jean-Yves Moyen <[email protected]>

* R16 extended diagnostic (#804)

* Set role name in extended diagnostic

* Required attributes added in rule and test

* Extended diagnostic added

* Apply suggestions from code review

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Correctly send required attributes to diagnostic

* Structure diagnostic JSON a bit

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Clean up test descriptions a bit

* Use n-ary and to streamline code

* R62 extended diagnostic (#801)

* Expanded Diagnostic added for R62, test updated as well
* Reduce computation in expected values
* Clean up and streamline

* Send shorthands for border

* Avoid sending styles that are equals to initial

* Avoid sending styles that are equals to initial

* Send shorthands for outline

* Send shorthand for text-decoration

* Support text-decoration-thickness (#817)

* Support text-decoration-thickness
* Send text-decoration-thickness in extended diagnostic of R62

* Remove unused imports

* Increase Nodejs heap size (#818)

* SIA R65: accept different border as focus indicator (#819)

* Remove duplicate test on border-style
* Accept difference in border-* as focus indicator
* Add some tests

* Remove 'found' which is not used by frontend

* Fix serialisation of outline

* Heap size problem and investigation. (#822)

* Double heap size

* Support `font-variant` CSS property (#821)

* Support font-variant-ligatures
* Support font-variant-position
* Support font-variant-caps
* Support font-variant-numeric
* Support font-variant-east-asian
* Support font-variant
* Support font-variant longhands in font shorthand
* Add some test for font-variant

* Test for SIA-R20 added

* Rule 54 is added, tests need to be completed

* Update rule.ts

* Update rule.spec.tsx

* Clean up

* Tests improved and finalized

* Update tsconfig.json

* Add --immutable flag to install instruction, add intructions for running tests

* R16 extended diagnostic (#804)

* Set role name in extended diagnostic

* Required attributes added in rule and test

* Extended diagnostic added

* Apply suggestions from code review

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Correctly send required attributes to diagnostic

* Structure diagnostic JSON a bit

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Avoid sending styles that are equals to initial

* Send shorthand for text-decoration

* Support text-decoration-thickness (#817)

* Support text-decoration-thickness
* Send text-decoration-thickness in extended diagnostic of R62

* Rule 54 is added, tests need to be completed

* Update rule.ts

* Update rule.spec.tsx

* Tests improved and finalized

* Clean up

* Clean up

* Clean up

* Remove unused imports

* Update packages/alfa-rules/src/sia-r54/rule.ts

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Update packages/alfa-rules/src/sia-r54/rule.ts

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Update packages/alfa-rules/test/sia-r54/rule.spec.tsx

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Update packages/alfa-rules/test/sia-r54/rule.spec.tsx

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Update packages/alfa-rules/test/sia-r54/rule.spec.tsx

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Update packages/alfa-rules/test/sia-r54/rule.spec.tsx

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Update packages/alfa-rules/test/sia-r54/rule.spec.tsx

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Update packages/alfa-rules/test/sia-r54/rule.spec.tsx

Co-authored-by: Jean-Yves Moyen <[email protected]>

* Update rule.ts

* Comments have been implemented

Co-authored-by: Jean-Yves Moyen <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 7, 2021
1 parent 1d32474 commit 01db7c6
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/alfa-rules/src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export { default as R48 } from "./sia-r48/rule";
export { default as R49 } from "./sia-r49/rule";
export { default as R50 } from "./sia-r50/rule";
export { default as R53 } from "./sia-r53/rule";
export { default as R54 } from "./sia-r54/rule";
export { default as R55 } from "./sia-r55/rule";
export { default as R56 } from "./sia-r56/rule";
export { default as R57 } from "./sia-r57/rule";
Expand Down
54 changes: 54 additions & 0 deletions packages/alfa-rules/src/sia-r54/rule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Rule, Diagnostic } from "@siteimprove/alfa-act";
import { Node } from "@siteimprove/alfa-aria";
import { Element } from "@siteimprove/alfa-dom";
import { Predicate } from "@siteimprove/alfa-predicate";
import { Err, Ok } from "@siteimprove/alfa-result";
import { Page } from "@siteimprove/alfa-web";

import { isIgnored } from "../common/predicate";
import { expectation } from "../common/expectation";

const { and, not } = Predicate;
const { isElement } = Element;

export default Rule.Atomic.of<Page, Element>({
uri: "https://alfa.siteimprove.com/rules/sia-r54",
evaluate({ device, document }) {
return {
applicability() {
return document
.descendants({ flattened: true, nested: true })
.filter(isElement)
.filter(
and(not(isIgnored(device)), (element) =>
Node.from(element, device)
.attribute("aria-live")
.some((attribute) => attribute.value === "assertive")
)
);
},

expectations(target) {
return {
1: expectation(
Node.from(target, device)
.attribute("aria-atomic")
.some((attribute) => attribute.value === "true"),
() => Outcomes.IsAtomic,
() => Outcomes.IsNotAtomic
),
};
},
};
},
});

export namespace Outcomes {
export const IsAtomic = Ok.of(
Diagnostic.of("The assertive region is atomic")
);

export const IsNotAtomic = Err.of(
Diagnostic.of("The assertive region is not atomic")
);
}
72 changes: 72 additions & 0 deletions packages/alfa-rules/test/sia-r54/rule.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { test } from "@siteimprove/alfa-test";

import { h } from "@siteimprove/alfa-dom";

import R54, { Outcomes } from "../../src/sia-r54/rule";

import { evaluate } from "../common/evaluate";
import { passed, failed, inapplicable } from "../common/outcome";

test("evaluate() passes an assertive and atomic element", async (t) => {
const target = (
<div aria-live="assertive" aria-atomic="true">
Some words
</div>
);

const document = h.document([target]);

t.deepEqual(await evaluate(R54, { document }), [
passed(R54, target, {
1: Outcomes.IsAtomic,
}),
]);
});

test("evaluate() fails an element which is assertive but not atomic", async (t) => {
const target = <div aria-live="assertive"> Some words </div>;

const document = h.document([target]);

t.deepEqual(await evaluate(R54, { document }), [
failed(R54, target, {
1: Outcomes.IsNotAtomic,
}),
]);
});

test("evaluate() fails an assertive element with an incorrect aria-atomic attribute", async (t) => {
const target = (
<div aria-live="assertive" aria-atomic="wrong">
Some words
</div>
);

const document = h.document([target]);

t.deepEqual(await evaluate(R54, { document }), [
failed(R54, target, {
1: Outcomes.IsNotAtomic,
}),
]);
});

test("evaluate() is inapplicable to elements that are not in the accessibility tree", async (t) => {
const target = (
<div hidden aria-live="assertive" aria-atomic="true">
Some words
</div>
);

const document = h.document([target]);

t.deepEqual(await evaluate(R54, { document }), [inapplicable(R54)]);
});

test("evaluate() is inapplicable to an element which is not assertive", async (t) => {
const target = <div>Some words</div>;

const document = h.document([target]);

t.deepEqual(await evaluate(R54, { document }), [inapplicable(R54)]);
});
2 changes: 2 additions & 0 deletions packages/alfa-rules/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"src/sia-r5/rule.ts",
"src/sia-r50/rule.ts",
"src/sia-r53/rule.ts",
"src/sia-r54/rule.ts",
"src/sia-r55/rule.ts",
"src/sia-r56/rule.ts",
"src/sia-r57/rule.ts",
Expand Down Expand Up @@ -185,6 +186,7 @@
"test/sia-r45/rule.spec.tsx",
"test/sia-r46/rule.spec.tsx",
"test/sia-r53/rule.spec.tsx",
"test/sia-r54/rule.spec.tsx",
"test/sia-r55/rule.spec.tsx",
"test/sia-r56/rule.spec.tsx",
"test/sia-r57/rule.spec.tsx",
Expand Down

0 comments on commit 01db7c6

Please sign in to comment.