diff --git a/lib/core/reporters/helpers/process-aggregate.js b/lib/core/reporters/helpers/process-aggregate.js index c6a608d95f..1eddfbb687 100644 --- a/lib/core/reporters/helpers/process-aggregate.js +++ b/lib/core/reporters/helpers/process-aggregate.js @@ -16,13 +16,13 @@ function normalizeRelatedNodes(node, options) { res.element = relatedNode?.element ?? null; } if (options.selectors !== false || relatedNode?.fromFrame) { - res.target = relatedNode?.selector ?? ':root'; + res.target = relatedNode?.selector ?? [':root']; } if (options.ancestry) { - res.ancestry = relatedNode?.ancestry ?? ':root'; + res.ancestry = relatedNode?.ancestry ?? [':root']; } if (options.xpath) { - res.xpath = relatedNode?.xpath ?? '/'; + res.xpath = relatedNode?.xpath ?? ['/']; } return res; }); diff --git a/test/core/reporters/helpers/process-aggregate.js b/test/core/reporters/helpers/process-aggregate.js index 3b6f13b52d..5cdbbc9ee9 100644 --- a/test/core/reporters/helpers/process-aggregate.js +++ b/test/core/reporters/helpers/process-aggregate.js @@ -1,6 +1,7 @@ describe('helpers.processAggregate', function () { 'use strict'; var results, options; + const helpers = axe._thisWillBeDeletedDoNotUse.helpers; beforeEach(function () { results = [ @@ -11,10 +12,10 @@ describe('helpers.processAggregate', function () { result: 'passed', node: { element: document.createElement('div'), - selector: 'header > .thing', + selector: ['header > .thing'], source: '
Thing
', - xpath: '/header/div[@class="thing"]', - ancestry: 'html > body > header > div' + xpath: ['/header/div[@class="thing"]'], + ancestry: ['html > body > header > div'] }, any: [ { @@ -22,10 +23,10 @@ describe('helpers.processAggregate', function () { relatedNodes: [ { element: document.createElement('div'), - selector: 'footer > .thing', + selector: ['footer > .thing'], source: '
Thing
', - xpath: '/footer/div[@class="thing"]', - ancestry: 'html > body > footer > div' + xpath: ['/footer/div[@class="thing"]'], + ancestry: ['html > body > footer > div'] } ] } @@ -37,10 +38,10 @@ describe('helpers.processAggregate', function () { result: 'passed', node: { element: document.createElement('div'), - selector: 'main > .thing', + selector: ['main > .thing'], source: '
Thing
', - xpath: '/main/div[@class="thing"]', - ancestry: 'html > body > main > div' + xpath: ['/main/div[@class="thing"]'], + ancestry: ['html > body > main > div'] }, any: [ { @@ -48,10 +49,10 @@ describe('helpers.processAggregate', function () { relatedNodes: [ { element: document.createElement('div'), - selector: 'footer > .thing', + selector: ['footer > .thing'], source: '
Thing
', - xpath: '/footer/div[@class="thing"]', - ancestry: 'html > body > footer > div' + xpath: ['/footer/div[@class="thing"]'], + ancestry: ['html > body > footer > div'] } ] } @@ -70,10 +71,10 @@ describe('helpers.processAggregate', function () { { result: 'failed', node: { - selector: '#dopel', - source: '', + selector: ['#dopel'], + source: [''], xpath: '/main/input[@id="dopel"]', - ancestry: 'html > body > main > input:nth-child(1)', + ancestry: ['html > body > main > input:nth-child(1)'], fromFrame: true }, any: [ @@ -83,9 +84,9 @@ describe('helpers.processAggregate', function () { { element: document.createElement('input'), selector: '#dopel', - source: '', - xpath: '/main/input[@id="dopel"]', - ancestry: 'html > body > main > input:nth-child(2)', + source: [''], + xpath: ['/main/input[@id="dopel"]'], + ancestry: ['html > body > main > input:nth-child(2)'], fromFrame: true } ] @@ -97,10 +98,10 @@ describe('helpers.processAggregate', function () { { result: 'failed', node: { - selector: '#dopell', + selector: ['#dopell'], source: '', - xpath: '/header/input[@id="dopell"]', - ancestry: 'html > body > main > input:nth-child(1)', + xpath: ['/header/input[@id="dopell"]'], + ancestry: ['html > body > main > input:nth-child(1)'], fromFrame: true }, any: [ @@ -109,10 +110,10 @@ describe('helpers.processAggregate', function () { relatedNodes: [ { element: document.createElement('input'), - selector: '#dopell', + selector: ['#dopell'], source: '', - xpath: '/header/input[@id="dopell"]', - ancestry: 'html > body > main > input:nth-child(2)', + xpath: ['/header/input[@id="dopell"]'], + ancestry: ['html > body > main > input:nth-child(2)'], fromFrame: true } ] @@ -168,9 +169,9 @@ describe('helpers.processAggregate', function () { const { relatedNodes } = resultObject.violations[0].nodes[0].any[0]; assert.deepEqual(relatedNodes[0], { html: 'Undefined', - target: ':root', - ancestry: ':root', - xpath: '/', + target: [':root'], + ancestry: [':root'], + xpath: ['/'], element: null }); });