Skip to content

Commit

Permalink
feat: Upgrade to axe-core 4.7.2 (#1769)
Browse files Browse the repository at this point in the history
#### Details

This PR updates to axe-core 4.7.2 and ai-scan 2.3.1. The tests have all
been updated, including increasing the timeout of an e2e test that is
slightly slower due to additional redirect overheads that exist in this
scenario.

##### Motivation

Feature work

##### Context

<!-- Are there any parts that you've intentionally left out-of-scope for
a later PR to handle? -->

<!-- Were there any alternative approaches you considered? What
tradeoffs did you consider? -->

#### Pull request checklist
<!-- If a checklist item is not applicable to this change, write "n/a"
in the checkbox -->
- [n/a] Addresses an existing issue
- [x] Added relevant unit test for your changes. (`yarn test`)
- [x] Verified code coverage for the changes made. Check coverage report
at: `<rootDir>/test-results/unit/coverage`
- [x] Ran precheckin (`yarn precheckin`)
  • Loading branch information
DaveTryon authored Aug 11, 2023
1 parent 3b89bbc commit 14e9561
Show file tree
Hide file tree
Showing 6 changed files with 1,309 additions and 1,021 deletions.
42 changes: 30 additions & 12 deletions packages/ado-extension/e2e/ado-extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Sample task tests', () => {
inputs = {};
});

it('returns expected scan summary and footer', () => {
it('returns expected scan summary and footer (ignoring user agent)', () => {
inputs = {
url: 'https://www.washington.edu/accesscomputing/AU/before.html',
};
Expand All @@ -22,13 +22,16 @@ describe('Sample task tests', () => {
Rules: 5 with failures, 14 passed, 36 not applicable
-------------------
This scan used axe-core 4.6.3 (https://github.com/dequelabs/axe-core/releases/tag/v4.6.3) and Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 with a display resolution of 1920x1080.
##[debug][Telemetry] tracking a 'ScanCompleted' event"
This scan used axe-core 4.7.2"
`);

expect(
testSubject.stdOutContainedRegex(new RegExp('This scan used axe-core 4.* with a display resolution of 1920x1080.$')),
).toBeTruthy();
expect(testSubject.stdOutContained("##[debug][Telemetry] tracking a 'ScanCompleted' event"));

function filterStdOut(stdout: string) {
const logs = stdout.match(/-------------------(.|\n)*##\[debug\]\[Telemetry\] tracking a 'ScanCompleted' event/);
const logs = stdout.match(/-------------------(.|\n)*This scan used axe-core 4\.7\.2/);
return logs ? logs[0] : '';
}
});
Expand Down Expand Up @@ -86,8 +89,16 @@ describe('Sample task tests', () => {

expect(testSubject.warningIssues.length).toEqual(0);
expect(testSubject.errorIssues.length).toEqual(1);
expect(testSubject.stdOutContained('Processing page https://www.washington.edu/accesscomputing/AU/after.html')).toBeTruthy();
expect(testSubject.stdOutContained('Processing page https://www.washington.edu/accesscomputing/AU/before.html')).toBeTruthy();
expect(
testSubject.stdOutContainedRegex(
new RegExp('Processing loaded page.*{"url":"https://www.washington.edu/accesscomputing/AU/before.html"}'),
),
).toBeTruthy();
expect(
testSubject.stdOutContainedRegex(
new RegExp('Processing loaded page.*{"url":"https://www.washington.edu/accesscomputing/AU/after.html"}'),
),
).toBeTruthy();
expect(testSubject.stdOutContained('URLs: 1 with failures, 1 passed, 0 not scannable')).toBeTruthy();
});

Expand All @@ -96,16 +107,19 @@ describe('Sample task tests', () => {
staticSiteDir: path.join(__dirname, '..', '..', '..', 'dev', 'website-root'),
staticSitePort: '39983',
inputUrls: 'http://localhost:39983/unlinked/index.html',
scanTimeout: '120000', // Needed becuase of additional redirects in this scenario
};
const testSubject = runTestWithInputs(inputs);

expect(testSubject.warningIssues.length).toEqual(0);
expect(testSubject.errorIssues.length).toEqual(1);
expect(testSubject.stdOutContained('Processing page http://localhost:39983/unlinked/')).toBeTruthy();
expect(
testSubject.stdOutContainedRegex(new RegExp('Processing loaded page.*{"url":"http://localhost:39983/unlinked/index.html"}')),
).toBeTruthy();
expect(testSubject.stdOutContained('Rules: 4 with failures, 13 passed, 39 not applicable')).toBeTruthy();
});

it('scans folders that are passed in as inputUrls (without trailing slash)', () => {
it('scans folders that are passed in as inputUrls (without a trailing slash)', () => {
inputs = {
staticSiteDir: path.join(__dirname, '..', '..', '..', 'dev', 'website-root'),
staticSitePort: '39983',
Expand All @@ -115,11 +129,13 @@ describe('Sample task tests', () => {

expect(testSubject.warningIssues.length).toEqual(0);
expect(testSubject.errorIssues.length).toEqual(1);
expect(testSubject.stdOutContained('Processing page http://localhost:39983/unlinked/')).toBeTruthy();
expect(
testSubject.stdOutContainedRegex(new RegExp('Processing loaded page.*{"url":"http://localhost:39983/unlinked/"}')),
).toBeTruthy();
expect(testSubject.stdOutContained('Rules: 4 with failures, 13 passed, 39 not applicable')).toBeTruthy();
});

it('scans folders that are passed in as inputUrls (with trailing slash)', () => {
it('scans folders that are passed in as inputUrls (with a trailing slash)', () => {
inputs = {
staticSiteDir: path.join(__dirname, '..', '..', '..', 'dev', 'website-root'),
staticSitePort: '39983',
Expand All @@ -129,7 +145,9 @@ describe('Sample task tests', () => {

expect(testSubject.warningIssues.length).toEqual(0);
expect(testSubject.errorIssues.length).toEqual(1);
expect(testSubject.stdOutContained('Processing page http://localhost:39983/unlinked/')).toBeTruthy();
expect(
testSubject.stdOutContainedRegex(new RegExp('Processing loaded page.*{"url":"http://localhost:39983/unlinked/"}')),
).toBeTruthy();
expect(testSubject.stdOutContained('Rules: 4 with failures, 13 passed, 39 not applicable')).toBeTruthy();
});

Expand Down
16 changes: 16 additions & 0 deletions packages/ado-extension/e2e/mock-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ export class MockTestRunner {
return this.stderr.indexOf(message) > 0;
}

public stdOutContainedRegex(regex: RegExp): boolean {
const lines: string[] = this.splitToLines(this.stdout.toString());

for (const line of lines) {
if (regex.test(line)) {
return true;
}
}

return false;
}

splitToLines(text: string): string[] {
return text.replace(/\r\n/g, '\n').split('\n');
}

public run(): void {
this.cmdlines = {};
this.invokedToolCount = 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"@types/react": "^16.14",
"@types/react-dom": "^16.9",
"accessibility-insights-report": "4.7.0",
"accessibility-insights-scan": "1.7.0",
"axe-core": "4.6.3",
"accessibility-insights-scan": "2.3.1",
"axe-core": "4.7.2",
"express": "^4.18.2",
"filenamify-url": "^3.0.0",
"get-port": "^7.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Failed instances
* 1 × blink: Ensures <blink> elements are not used
* 1 × button-name: Ensures buttons have discernible text
* 1 × bypass: Ensures each page has at least one mechanism for a user to bypass navigation and jump straight to the content
* 1 × color-contrast-enhanced: Ensures the contrast between foreground and background colors meets WCAG 2 AAA contrast ratio thresholds
* 1 × color-contrast: Ensures the contrast between foreground and background colors meets WCAG 2 AA contrast ratio thresholds
* 1 × color-contrast-enhanced: Ensures the contrast between foreground and background colors meets WCAG 2 AAA enhanced contrast ratio thresholds
* 1 × color-contrast: Ensures the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
* 1 × css-orientation-lock: Ensures content is not locked to any specific display orientation, and the content is operable in all display orientations
* 1 × definition-list: Ensures <dl> elements are structured correctly
* 1 × dlitem: Ensures <dt> and <dd> elements are contained by a <dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
* **1 × blink**: Ensures \<blink> elements are not used
* **1 × button-name**: Ensures buttons have discernible text
* **1 × bypass**: Ensures each page has at least one mechanism for a user to bypass navigation and jump straight to the content
* **1 × color-contrast-enhanced**: Ensures the contrast between foreground and background colors meets WCAG 2 AAA contrast ratio thresholds
* **1 × color-contrast**: Ensures the contrast between foreground and background colors meets WCAG 2 AA contrast ratio thresholds
* **1 × color-contrast-enhanced**: Ensures the contrast between foreground and background colors meets WCAG 2 AAA enhanced contrast ratio thresholds
* **1 × color-contrast**: Ensures the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
* **1 × css-orientation-lock**: Ensures content is not locked to any specific display orientation, and the content is operable in all display orientations
* **1 × definition-list**: Ensures \<dl> elements are structured correctly
* **1 × dlitem**: Ensures \<dt> and \<dd> elements are contained by a \<dl>
Expand Down
Loading

0 comments on commit 14e9561

Please sign in to comment.