Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce automated tests #1105

Merged
merged 25 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6031e06
Add jest
howard-e Aug 5, 2024
4b5958a
Add mock content
howard-e Aug 5, 2024
ccd63ed
Update how create-all-tests.js is handled
howard-e Aug 5, 2024
68c4e66
Prepare process-test-directory scripts to be testable
howard-e Aug 6, 2024
2e31336
sample test run
howard-e Aug 6, 2024
fad789c
Add sample snapshot
howard-e Aug 6, 2024
e992888
Update tests
howard-e Aug 6, 2024
c6f2f84
Update snapshot
howard-e Aug 6, 2024
cd5cd85
Update snapshot
howard-e Aug 6, 2024
3c31e91
Support snapshots for the review pages
howard-e Aug 15, 2024
a1a7889
Simplify generate-and-commit-files.yml
howard-e Aug 15, 2024
383332d
Add test.yml workflow
howard-e Aug 15, 2024
6e6e5b4
Use dynamic import for test-reviewer
howard-e Aug 15, 2024
abdb938
Merge branch 'master' into add-tests
howard-e Aug 15, 2024
fc2bfdf
Start moving functions from creaetReviewPages
howard-e Aug 20, 2024
392961b
Simplify patterns' page generation
howard-e Aug 20, 2024
960edb7
Move generating functions
howard-e Aug 20, 2024
0c7afc9
Flatten for loop when processing review pages
howard-e Aug 20, 2024
8689fcc
Extract referencesData collection function
howard-e Aug 20, 2024
6acad5a
Extract references and scripts data collecting functions
howard-e Aug 20, 2024
5ba3c27
Extract collectedTestsData to separate function
howard-e Aug 20, 2024
e6796cb
Extracted collectedTests functionality
howard-e Aug 20, 2024
b333622
Include console colors where applicable
howard-e Aug 20, 2024
c66455f
Fix display issue when showing exceptions through fromJSONCommandsCon…
howard-e Aug 21, 2024
64d84b0
Introduce horizontal-slider mock as it has real-world assertionExcept…
howard-e Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ tests/**/reference/**/*
build/tests/**/*
# keys are manually parsed in process-test-directory.js and depend on format
tests/resources/keys.mjs

# Automated tests related resources
__test__/__mocks__/tests/**/reference/**/*
30 changes: 7 additions & 23 deletions .github/workflows/generate-and-commit-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ on:

jobs:
generate-and-commit-files:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]

steps:
- uses: actions/checkout@v3
Expand All @@ -26,27 +31,6 @@ jobs:
run: npm run build

- uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ github.actor != 'dependabot[bot]' }}
if: ${{ matrix.os == 'ubuntu-latest' && github.actor != 'dependabot[bot]' }}
with:
commit_message: Generate .html source files with scripts automatically

generate-files-windows:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
with:
ref: refs/pull/${{ github.event.pull_request.number }}/head
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Generate test and review files
run: npm run build
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run tests

on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: refs/pull/${{ github.event.pull_request.number }}/head
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run npm test
run: npm test
3 changes: 3 additions & 0 deletions __test__/__mocks__/tests/alert/data/assertions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
assertionId,priority,assertionStatement,assertionPhrase,refIds
roleAlert,3,Role 'alert' is conveyed,convey role 'alert',
textHello,1,Text 'Hello' is conveyed,convey text 'Hello',
5 changes: 5 additions & 0 deletions __test__/__mocks__/tests/alert/data/jaws-commands.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
testId,command,settings,assertionExceptions,presentationNumber
triggerAlert,space,virtualCursor,,1.0
triggerAlert,enter,virtualCursor,,1.1
triggerAlert,space,pcCursor,,2.0
triggerAlert,enter,pcCursor,,2.1
2 changes: 2 additions & 0 deletions __test__/__mocks__/tests/alert/data/js/setFocusOnButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// sets focus on the 'Trigger Alert' button
testPageDocument.querySelector('#alert-trigger').focus();
5 changes: 5 additions & 0 deletions __test__/__mocks__/tests/alert/data/nvda-commands.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
testId,command,settings,assertionExceptions,presentationNumber
triggerAlert,space,browseMode,,1.0
triggerAlert,enter,browseMode,,1.1
triggerAlert,space,focusMode,,2.0
triggerAlert,enter,focusMode,,2.1
10 changes: 10 additions & 0 deletions __test__/__mocks__/tests/alert/data/references.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
refId,type,value,linkText
author,metadata,Isabel Del Castillo,
authorEmail,metadata,[email protected],
title,metadata,Alert Example,
reference,metadata,reference/2022-4-8_144013/alert.html,Test Case Page for Alert Example
designPattern,metadata,https://www.w3.org/WAI/ARIA/apg/patterns/alert/,APG Pattern: Alert
example,metadata,https://www.w3.org/WAI/ARIA/apg/patterns/alert/examples/alert/,APG Example: Alert
alert,aria,alert,alert
aria-live,aria,aria-live,aria-live
aria-atomic,aria,aria-atomic,aria-atomic
2 changes: 2 additions & 0 deletions __test__/__mocks__/tests/alert/data/scripts.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setupScript,setupScriptDescription
setFocusOnButton,sets focus on the 'Trigger Alert' button
2 changes: 2 additions & 0 deletions __test__/__mocks__/tests/alert/data/tests.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
testId,title,presentationNumber,setupScript,instructions,assertions
triggerAlert,Trigger an alert,3,setFocusOnButton,"Starting at the 'Trigger Alert' button, activate the button to trigger the alert.",roleAlert textHello
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testId,command,settings,assertionExceptions,presentationNumber
triggerAlert,ctrl+opt+space,,,3.0
triggerAlert,space,,,3.1
triggerAlert,enter,,,3.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Alert Example</title>

<!-- js and css for this example. -->
<link href="css/alert.css" rel="stylesheet">
<script src="js/alert.js" type="text/javascript"></script>
</head>
<body>
<main>
<h1>Alert Example</h1>
<p>
The below example demonstrates the <a href="https://w3c.github.io/#alert">design pattern for alert</a>.
Activating the <q>Trigger Alert</q> button causes a message to be inserted into the example alert element.
</p>
<section>
<div class="example-header">
<h2 id="ex_label">Example</h2>
</div>
<div role="separator" id="ex_start_sep" aria-labelledby="ex_start_sep ex_label" aria-label="Start of"></div>
<div id="ex1">
<button type="button" id="alert-trigger">Trigger Alert</button>

<div id="example" role="alert"></div>

<!-- The following script element contains the content that will be inserted into the alert element. -->
<script type="text/template" id="alert-template">
<p>Hello</p>
</script>
</div>
<div role="separator" id="ex_end_sep" aria-labelledby="ex_end_sep ex_label" aria-label="End of"></div>
</section>
</main>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Alert Example</title>

<!-- js and css for this example. -->
<link href="css/alert.css" rel="stylesheet">
<script src="js/alert.js" type="text/javascript"></script>

<!-- Generated by process-test-directory.js -->
<script>
(function() {
function setupScript(testPageDocument) {
// setFocusOnButton
// sets focus on the 'Trigger Alert' button
testPageDocument.querySelector('#alert-trigger').focus();

};
document.addEventListener('click', function(event) {
if (event.target.classList.contains('button-run-test-setup')) {
event.target.disabled = true;
setupScript(document);
}
});
})();
</script>
<!-- End of generated output --></head>
<body>
<main>
<h1>Alert Example</h1>
<p>
The below example demonstrates the <a href="https://w3c.github.io/#alert">design pattern for alert</a>.
Activating the <q>Trigger Alert</q> button causes a message to be inserted into the example alert element.
</p>
<section>
<div class="example-header">
<h2 id="ex_label">Example</h2>
</div>
<div role="separator" id="ex_start_sep" aria-labelledby="ex_start_sep ex_label" aria-label="Start of"></div>
<div id="ex1">
<button type="button" id="alert-trigger">Trigger Alert</button>

<div id="example" role="alert"></div>

<!-- The following script element contains the content that will be inserted into the alert element. -->
<script type="text/template" id="alert-template">
<p>Hello</p>
</script>
</div>
<div role="separator" id="ex_end_sep" aria-labelledby="ex_end_sep ex_label" aria-label="End of"></div>
</section>

<!-- Generated by process-test-directory.js -->
<div style="position: relative; left: 0; right: 0; height: 2rem;">
<button class="button-run-test-setup" autofocus style="height: 100%; width: 100%;">Run Test Setup</button>
</div>
<!-- End of generated output --></main>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[role="alert"] {
padding: 10px;
border: 2px solid hsl(206deg 74% 54%);
border-radius: 4px;
background: hsl(206deg 74% 90%);
}

[role="alert"]:empty {
display: none;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* This content is licensed according to the W3C Software License at
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
*
*/

'use strict';

window.addEventListener('load', function () {
var button = document.getElementById('alert-trigger');

button.addEventListener('click', addAlert);
});

/*
* @function addAlert
*
* @desc Adds an alert to the page
*
* @param {object} event - Standard W3C event object
*
*/

function addAlert() {
var example = document.getElementById('example');
var template = document.getElementById('alert-template').innerHTML;

example.innerHTML = template;
}
43 changes: 43 additions & 0 deletions __test__/__mocks__/tests/banner/data/commands.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
testId,task,mode,at,commandA,commandB,commandC,commandD,commandE
1,Navigate forwards into a banner landmark,READING,JAWS,R,DOWN,TAB,U,
1,Navigate forwards into a banner landmark,READING,NVDA,D,DOWN,TAB,U,K
2,Navigate forwards into a banner landmark,INTERACTION,JAWS,TAB,,,,
2,Navigate forwards into a banner landmark,INTERACTION,NVDA,TAB,,,,
3,Navigate forwards into a banner landmark,INTERACTION,VOICEOVER_MACOS,"CTRL_OPT_RIGHT,CTRL_OPT_RIGHT",CTRL_OPT_CMD_L,,,
4,Navigate backwards into a banner landmark,READING,JAWS,UP,SHIFT_TAB,SHIFT_U,,
4,Navigate backwards into a banner landmark,READING,NVDA,UP,SHIFT_TAB,SHIFT_U,SHIFT_K,
5,Navigate backwards into a banner landmark,INTERACTION,JAWS,SHIFT_TAB,,,,
5,Navigate backwards into a banner landmark,INTERACTION,NVDA,SHIFT_TAB,,,,
6,Navigate backwards into a banner landmark,INTERACTION,VOICEOVER_MACOS,"CTRL_OPT_LEFT,CTRL_OPT_LEFT",SHIFT_CTRL_OPT_CMD_L,,,
7,Navigate forwards out of a banner landmark,READING,JAWS,DOWN,U,,,
7,Navigate forwards out of a banner landmark,READING,NVDA,DOWN,U,K,,
8,Navigate forwards out of a banner landmark,INTERACTION,JAWS,TAB,,,,
8,Navigate forwards out of a banner landmark,INTERACTION,NVDA,TAB,,,,
9,Navigate forwards out of a banner landmark,INTERACTION,VOICEOVER_MACOS,"CTRL_OPT_RIGHT,CTRL_OPT_RIGHT",CTRL_OPT_CMD_L,,,
10,Navigate backwards out of a banner landmark,READING,JAWS,UP,SHIFT_U,,,
10,Navigate backwards out of a banner landmark,READING,NVDA,UP,SHIFT_K,SHIFT_U,,
11,Navigate backwards out of a banner landmark,INTERACTION,JAWS,SHIFT_TAB,,,,
11,Navigate backwards out of a banner landmark,INTERACTION,NVDA,SHIFT_TAB,,,,
12,Navigate backwards out of a banner landmark,INTERACTION,VOICEOVER_MACOS,"CTRL_OPT_LEFT,CTRL_OPT_LEFT",SHIFT_CTRL_OPT_CMD_L,,,
13,Navigate forwards to a button inside a banner landmark,READING,JAWS,B,DOWN,TAB,,
13,Navigate forwards to a button inside a banner landmark,READING,NVDA,B,DOWN,TAB,,
14,Navigate forwards to a button inside a banner landmark,INTERACTION,JAWS,TAB,,,,
14,Navigate forwards to a button inside a banner landmark,INTERACTION,NVDA,TAB,,,,
15,Navigate forwards to a button inside a banner landmark,INTERACTION,VOICEOVER_MACOS,"CTRL_OPT_RIGHT,CTRL_OPT_RIGHT",CTRL_OPT_CMD_J,TAB,,
16,Navigate backwards to a button inside a banner landmark,READING,JAWS,UP,SHIFT_B,SHIFT_TAB,,
16,Navigate backwards to a button inside a banner landmark,READING,NVDA,UP,SHIFT_B,SHIFT_TAB,,
17,Navigate backwards to a button inside a banner landmark,INTERACTION,JAWS,SHIFT_TAB,,,,
17,Navigate backwards to a button inside a banner landmark,INTERACTION,NVDA,SHIFT_TAB,,,,
18,Navigate backwards to a button inside a banner landmark,INTERACTION,VOICEOVER_MACOS,"CTRL_OPT_LEFT,CTRL_OPT_LEFT",SHIFT_CTRL_OPT_CMD_J,SHIFT_TAB,,
19,Navigate forwards to an image inside a banner landmark,READING,JAWS,G,,,,
19,Navigate forwards to an image inside a banner landmark,READING,NVDA,G,,,,
20,Navigate forwards to an image inside a banner landmark,INTERACTION,VOICEOVER_MACOS,CTRL_OPT_CMD_G,,,,
21,Navigate backwards to an image inside a banner landmark,READING,JAWS,SHIFT_G,,,,
21,Navigate backwards to an image inside a banner landmark,READING,NVDA,SHIFT_G,,,,
22,Navigate backwards to an image inside a banner landmark,INTERACTION,VOICEOVER_MACOS,SHIFT_CTRL_OPT_CMD_G,,,,
23,Navigate forwards to a heading inside a banner landmark,READING,JAWS,H,ONE,,,
23,Navigate forwards to a heading inside a banner landmark,READING,NVDA,H,ONE,,,
24,Navigate forwards to a heading inside a banner landmark,INTERACTION,VOICEOVER_MACOS,CTRL_OPT_CMD_H,,,,
25,Navigate backwards to a heading inside a banner landmark,READING,JAWS,SHIFT_H,SHIFT_ONE,,,
25,Navigate backwards to a heading inside a banner landmark,READING,NVDA,SHIFT_H,SHIFT_ONE,,,
26,Navigate backwards to a heading inside a banner landmark,INTERACTION,VOICEOVER_MACOS,SHIFT_CTRL_OPT_CMD_H,,,,
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// sets focus on a link after the banner landmark
testPageDocument.getElementById('afterlink').focus();
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// sets focus on a link after the banner landmark, and hides the last link inside the landmark region
testPageDocument.getElementById('bottom').setAttribute('hidden', '');
testPageDocument.getElementById('afterlink').focus();
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// sets focus on a link before the banner landmark
testPageDocument.getElementById('beforelink').focus();
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// sets focus on a link before the banner landmark, and hides the first link inside the landmark region
testPageDocument.getElementById('top').setAttribute('hidden', '');
testPageDocument.getElementById('beforelink').focus();
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// sets focus on the 'Bottom' link
testPageDocument.getElementById('bottom').focus();
2 changes: 2 additions & 0 deletions __test__/__mocks__/tests/banner/data/js/setFocusOnTopLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// sets focus on the 'Top' link
testPageDocument.getElementById('top').focus();
11 changes: 11 additions & 0 deletions __test__/__mocks__/tests/banner/data/references.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
refId,value
author,Isabel Del Castillo
title,Banner Landmark
authorEmail,[email protected]
reference,reference/2021-10-24_135455/banner.html
designPattern,https://w3c.github.io/aria-practices/#aria_lh_banner
example,https://w3c.github.io/aria-practices/examples/landmarks/banner.html
banner,https://w3c.github.io/aria/#banner
aria-haspopup,https://w3c.github.io/aria/#aria-haspopup
aria-describedby,https://w3c.github.io/aria/#aria-describedby
aria-expanded,https://w3c.github.io/aria/#aria-expanded
Loading
Loading