Skip to content

Commit

Permalink
aria-required-children
Browse files Browse the repository at this point in the history
  • Loading branch information
koddsson committed Jun 21, 2024
1 parent 6098e02 commit 5fdfd73
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
4 changes: 1 addition & 3 deletions src/rules/aria-required-children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,14 @@ export const references = {
};

export function ariaRequiredChildren(el: Element): AccessibilityError[] {
const root = document.createElement("div");
root.append(el);
const errors = [];

// Loop over all the different rules.
for (const [role, requiredChildren] of Object.entries(
roleToRequiredChildRoleMapping,
)) {
// Find all the elements with a role that we are interested in.
for (const parent of querySelectorAll(`[role=${role}]`, root)) {
for (const parent of querySelectorAll(`[role=${role}]`, el)) {
let isValid = false;

// Look for children of the parents with the correct roles.
Expand Down
4 changes: 4 additions & 0 deletions tests/act/act.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const rulesToIgnore = [
"ucwvc8",
"ye5d6e",
"bf051a",
"ff89c9",
];

const ignoredExamples = [
Expand All @@ -125,6 +126,9 @@ const ignoredExamples = [
"https://act-rules.github.io/testcases/qt1vmo/0ef4f516db9ed70cb25f39c99637272808b8e60f.html",
];

// TODO: Instead of dynamic tests which behave weird in Web Test Runner, we
// should generate the tests from the HTML testcases. It would be great if it's
// easy to regenerate so we don't accidentally change the tests.
describe("ACT Rules", function () {
for (const rule of applicableRules) {
const {
Expand Down
4 changes: 2 additions & 2 deletions tests/aria-required-children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ describe("aria-required-attr", async function () {
});
expect(results).to.eql([
{
text: "ARIA attributes must conform to valid names",
url: "https://dequeuniversity.com/rules/axe/4.4/aria-valid-attr",
text: "TODO",
url: "TODO",
},
]);
});
Expand Down
27 changes: 14 additions & 13 deletions web-test-runner.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// eslint-disable-next-line foo
import { env } from "node:process";

import { summaryReporter } from "@web/test-runner";
import { esbuildPlugin } from "@web/dev-server-esbuild";
import { playwrightLauncher } from "@web/test-runner-playwright";
import { junitReporter } from "@web/test-runner-junit-reporter";
Expand All @@ -15,23 +14,12 @@ if (env.CI) {
);
}

const reporters = [
summaryReporter(),
env.CI
? junitReporter({
outputPath: "./test-results.xml",
reportLogs: true,
})
: null,
];

export default {
const config = {
nodeResolve: true,
coverage: true,
files: ["tests/**/*.ts", "tests/**/*.js"],
plugins: [esbuildPlugin({ ts: true, target: "esnext" })],
browsers,
reporters,
filterBrowserLogs(log) {
if (
typeof log.args[0] === "string" &&
Expand All @@ -44,3 +32,16 @@ export default {
return true;
},
};

if (env.CI) {
config.reporters = [
env.CI
? junitReporter({
outputPath: "./test-results.xml",
reportLogs: true,
})
: null,
];
}

export default config;

0 comments on commit 5fdfd73

Please sign in to comment.