From 6e11d4980789a9adb5281244866ea41c2e153e6e Mon Sep 17 00:00:00 2001 From: ekremney Date: Wed, 28 Aug 2024 12:07:09 +0200 Subject: [PATCH] fix: audit context includes interval info --- src/cwv/handler.js | 3 +++ test/audits/cwv.test.js | 3 +++ test/fixtures/rum-data.js | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cwv/handler.js b/src/cwv/handler.js index 0b485ba2..78d255b3 100644 --- a/src/cwv/handler.js +++ b/src/cwv/handler.js @@ -29,6 +29,9 @@ export async function CWVRunner(auditUrl, context, site) { const cwvData = await rumAPIClient.query('cwv', options); const auditResult = { cwv: cwvData.filter((data) => data.pageviews >= DAILY_THRESHOLD * INTERVAL), + auditContext: { + interval: INTERVAL, + }, }; return { diff --git a/test/audits/cwv.test.js b/test/audits/cwv.test.js index 9beca15e..28080c1c 100644 --- a/test/audits/cwv.test.js +++ b/test/audits/cwv.test.js @@ -63,6 +63,9 @@ describe('Index Tests', () => { expect(result).to.deep.equal({ auditResult: { cwv: rumData.filter((data) => data.pageviews >= 7000), + auditContext: { + interval: 7, + }, }, fullAuditRef: auditUrl, }); diff --git a/test/fixtures/rum-data.js b/test/fixtures/rum-data.js index de4712fe..65c18db5 100644 --- a/test/fixtures/rum-data.js +++ b/test/fixtures/rum-data.js @@ -21,7 +21,7 @@ export const rumData = [ inpCount: 3, ttfb: 520.4500000476837, ttfbCount: 18, - pageviews: 2620, + pageviews: 9620, }, { url: 'https://www.aem.live/developer/block-collection', @@ -33,7 +33,7 @@ export const rumData = [ inpCount: 2, ttfb: 122.90000003576279, ttfbCount: 4, - pageviews: 2000, + pageviews: 8000, }, { url: 'https://www.aem.live/docs/', @@ -45,7 +45,7 @@ export const rumData = [ inpCount: 8, ttfb: 96.97500000149012, ttfbCount: 16, - pageviews: 1910, + pageviews: 7910, }, { url: 'https://www.aem.live/tools/rum/explorer.html', @@ -57,7 +57,7 @@ export const rumData = [ inpCount: 5, ttfb: 312.69999980926514, ttfbCount: 9, - pageviews: 1600, + pageviews: 7600, }, { url: 'https://www.aem.live/developer/tutorial',