From eecf52511ecc217e54b3844db219d1acf5f2308b Mon Sep 17 00:00:00 2001 From: Brendan Kenny Date: Mon, 17 Jul 2017 11:59:45 -0700 Subject: [PATCH] track number of completed requests in total-byte-weight extendedInfo (#2697) --- lighthouse-core/audits/byte-efficiency/total-byte-weight.js | 2 ++ .../test/audits/byte-efficiency/total-byte-weight-test.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lighthouse-core/audits/byte-efficiency/total-byte-weight.js b/lighthouse-core/audits/byte-efficiency/total-byte-weight.js index ea56c205216e..fe60a89ad11a 100644 --- a/lighthouse-core/audits/byte-efficiency/total-byte-weight.js +++ b/lighthouse-core/audits/byte-efficiency/total-byte-weight.js @@ -64,6 +64,7 @@ class TotalByteWeight extends ByteEfficiencyAudit { totalBytes += result.totalBytes; results.push(result); }); + const totalCompletedRequests = results.length; results = results.sort((itemA, itemB) => itemB.totalBytes - itemA.totalBytes).slice(0, 10); @@ -91,6 +92,7 @@ class TotalByteWeight extends ByteEfficiencyAudit { extendedInfo: { value: { results, + totalCompletedRequests } }, details: tableDetails diff --git a/lighthouse-core/test/audits/byte-efficiency/total-byte-weight-test.js b/lighthouse-core/test/audits/byte-efficiency/total-byte-weight-test.js index 6b7cb2a1d3f2..f94aa0c187c7 100644 --- a/lighthouse-core/test/audits/byte-efficiency/total-byte-weight-test.js +++ b/lighthouse-core/test/audits/byte-efficiency/total-byte-weight-test.js @@ -45,6 +45,7 @@ describe('Total byte weight audit', () => { assert.strictEqual(result.score, 100); const results = result.details.items; assert.strictEqual(results.length, 3); + assert.strictEqual(result.extendedInfo.value.totalCompletedRequests, 3); assert.strictEqual(results[0][1].text, `70${NBSP}KB`, 'results are sorted'); }); }); @@ -69,6 +70,7 @@ describe('Total byte weight audit', () => { assert.strictEqual(result.rawValue, 4180 * 1024); const results = result.details.items; assert.strictEqual(results.length, 10, 'results are clipped at top 10'); + assert.strictEqual(result.extendedInfo.value.totalCompletedRequests, 11); }); });