From d41c7c00ac0d139e8f6929c539b071d79b505ff7 Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Mon, 10 Jun 2024 17:27:12 -0700 Subject: [PATCH] tests(lantern): remove Speedline from Lantern unit test for now (#16060) --- core/computed/metrics/lantern-speed-index.js | 2 +- core/lib/lantern/metric.js | 2 +- core/lib/lantern/metrics/speed-index.js | 4 ++-- core/test/lib/lantern/metrics/speed-index-test.js | 11 ++++++----- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/computed/metrics/lantern-speed-index.js b/core/computed/metrics/lantern-speed-index.js index f2538e9b4298..afd2f1555413 100644 --- a/core/computed/metrics/lantern-speed-index.js +++ b/core/computed/metrics/lantern-speed-index.js @@ -34,7 +34,7 @@ class LanternSpeedIndex extends SpeedIndex { const speedline = await Speedline.request(data.trace, context); const fcpResult = await LanternFirstContentfulPaint.request(data, context); return this.computeMetricWithGraphs(data, context, { - speedline, + observedSpeedIndex: speedline.speedIndex, fcpResult, }); } diff --git a/core/lib/lantern/metric.js b/core/lib/lantern/metric.js index f799c98e2d4b..9be8cd506f56 100644 --- a/core/lib/lantern/metric.js +++ b/core/lib/lantern/metric.js @@ -18,7 +18,7 @@ import {RESOURCE_TYPES} from '../../lib/network-request.js'; * @property {LH.Artifacts.LanternMetric=} fcpResult * @property {LH.Artifacts.LanternMetric=} lcpResult * @property {LH.Artifacts.LanternMetric=} interactiveResult - * @property {{speedIndex: number}=} speedline + * @property {number=} observedSpeedIndex */ class Metric { diff --git a/core/lib/lantern/metrics/speed-index.js b/core/lib/lantern/metrics/speed-index.js index 6bf666a4e7d3..1154f32f9653 100644 --- a/core/lib/lantern/metrics/speed-index.js +++ b/core/lib/lantern/metrics/speed-index.js @@ -76,11 +76,11 @@ class SpeedIndex extends Metric { */ static getEstimateFromSimulation(simulationResult, extras) { if (!extras.fcpResult) throw new Error('missing fcpResult'); - if (!extras.speedline) throw new Error('missing speedline'); + if (extras.observedSpeedIndex === undefined) throw new Error('missing observedSpeedIndex'); const fcpTimeInMs = extras.fcpResult.pessimisticEstimate.timeInMs; const estimate = extras.optimistic - ? extras.speedline.speedIndex + ? extras.observedSpeedIndex : SpeedIndex.computeLayoutBasedSpeedIndex(simulationResult.nodeTimings, fcpTimeInMs); return { timeInMs: estimate, diff --git a/core/test/lib/lantern/metrics/speed-index-test.js b/core/test/lib/lantern/metrics/speed-index-test.js index ea2c98425e79..e48ac6b16f12 100644 --- a/core/test/lib/lantern/metrics/speed-index-test.js +++ b/core/test/lib/lantern/metrics/speed-index-test.js @@ -10,7 +10,6 @@ import {readJson} from '../../../test-utils.js'; import {SpeedIndex} from '../../../../lib/lantern/metrics/speed-index.js'; import {FirstContentfulPaint} from '../../../../lib/lantern/metrics/first-contentful-paint.js'; import {getComputationDataFromFixture} from './metric-test-utils.js'; -import {Speedline} from '../../../../computed/speedline.js'; const trace = readJson('../../../fixtures/artifacts/progressive-app/trace.json', import.meta); @@ -18,11 +17,13 @@ const defaultThrottling = constants.throttling.mobileSlow4G; describe('Metrics: Lantern Speed Index', () => { it('should compute predicted value', async () => { - const context = {computedCache: new Map()}; const data = await getComputationDataFromFixture({trace}); + // TODO: observedSpeedIndex is from the Speedline library, and is used for optimistic + // mode. At the moment callers must pass the result into Lantern. + const observedSpeedIndex = 379.04474997520487; const result = await SpeedIndex.compute(data, { fcpResult: await FirstContentfulPaint.compute(data), - speedline: await Speedline.request(trace, context), + observedSpeedIndex, }); expect({ @@ -40,11 +41,11 @@ Object { it('should compute predicted value for different settings', async () => { const settings = {throttlingMethod: 'simulate', throttling: {...defaultThrottling, rttMs: 300}}; - const context = {computedCache: new Map()}; const data = await getComputationDataFromFixture({trace, settings}); + const observedSpeedIndex = 379.04474997520487; const result = await SpeedIndex.compute(data, { fcpResult: await FirstContentfulPaint.compute(data), - speedline: await Speedline.request(trace, context), + observedSpeedIndex, }); expect({