From e7af25ac2cc223da7905a73617919ca52951dcd4 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Wed, 30 Aug 2023 12:11:36 +0200 Subject: [PATCH] Display axe version on summary page (#3950) --- lib/plugins/axe/index.js | 6 ++++-- lib/plugins/axe/pug/index.pug | 8 +++----- lib/plugins/browsertime/index.js | 19 +++++++++++-------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/plugins/axe/index.js b/lib/plugins/axe/index.js index f35031c901..35d3d4047b 100644 --- a/lib/plugins/axe/index.js +++ b/lib/plugins/axe/index.js @@ -2,6 +2,8 @@ import { resolve } from 'node:path'; import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import intel from 'intel'; +import axe from 'axe-core'; +const { version: axeVersion } = axe; import { SitespeedioPlugin } from '@sitespeed.io/plugin'; const log = intel.getLogger('sitespeedio.plugin.axe'); const __dirname = fileURLToPath(new URL('.', import.meta.url)); @@ -15,7 +17,7 @@ export default class AxePlugin extends SitespeedioPlugin { this.options = options; this.make = context.messageMaker('axe').make; this.pug = readFileSync(resolve(__dirname, 'pug', 'index.pug'), 'utf8'); - log.info('Axe plugin activated'); + log.info(`Axe version %s plugin activated`, axeVersion); } processMessage(message, queue) { @@ -35,7 +37,7 @@ export default class AxePlugin extends SitespeedioPlugin { case 'sitespeedio.setup': { // Tell other plugins that axe will run - queue.postMessage(make('axe.setup')); + queue.postMessage(make('axe.setup', { version: axeVersion })); // Add the HTML pugs queue.postMessage( diff --git a/lib/plugins/axe/pug/index.pug b/lib/plugins/axe/pug/index.pug index 8c5abfd9de..a544c3dacd 100644 --- a/lib/plugins/axe/pug/index.pug +++ b/lib/plugins/axe/pug/index.pug @@ -1,13 +1,11 @@ - const axe = pageInfo.data.axe.run ? pageInfo.data.axe.run : pageInfo.data.axe.pageSummary - a h2 Axe -p Axe is an accessibility testing engine for websites and other HTML-based user interfaces. Read more about - a(href='https://github.com/dequelabs/axe-core') axe-core - | . #{axe.testEngine ? 'Tested using ' + axe.testEngine.name + ' ' + axe.testEngine.version + '.' : ''} - +p Axe is an accessibility testing engine for websites and other HTML-based user interfaces. Tested using #{axe.testEngine.name} version #{axe.testEngine.version}. Read more about + a(href='https://github.com/dequelabs/axe-core') axe-core + | . if pageInfo.data.axe.run h3 Violations diff --git a/lib/plugins/browsertime/index.js b/lib/plugins/browsertime/index.js index 1e6323baf2..bd6791ded8 100644 --- a/lib/plugins/browsertime/index.js +++ b/lib/plugins/browsertime/index.js @@ -123,6 +123,11 @@ export default class BrowsertimePlugin extends SitespeedioPlugin { _merge(options, message.data); break; } + + case 'axe.setup': { + this.axeVersion = message.data.version; + break; + } // Andother plugin got JavaScript that they want to run in Browsertime case 'browsertime.scripts': { if (message.data.category && message.data.scripts) { @@ -540,14 +545,12 @@ export default class BrowsertimePlugin extends SitespeedioPlugin { // Post the result on the queue so other plugins can use it if (this.useAxe) { - super.sendMessage( - 'axe.pageSummary', - axeAggregatorPerURL.summarizeStats(), - { - url, - group - } - ); + let stats = axeAggregatorPerURL.summarizeStats(); + stats.testEngine = { version: this.axeVersion, name: 'axe-core' }; + super.sendMessage('axe.pageSummary', stats, { + url, + group + }); } // Check for errors. Browsertime errors is an array of all iterations