Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(test): move regenerated fixtures to new folders #15031

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/test/audits/mainthread-work-breakdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import PageExecutionTimings from '../../audits/mainthread-work-breakdown.js';
import {readJson} from '../test-utils.js';

const acceptableTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta);
const siteWithRedirectTrace = readJson('../fixtures/traces/site-with-redirect.json', import.meta);
const siteWithRedirectTrace = readJson('../fixtures/artifacts/redirect/trace.json', import.meta);
const loadTraceOld = readJson('../fixtures/traces/load.json', import.meta);
const loadTrace = readJson('../fixtures/traces/animation.json', import.meta);
const loadTrace = readJson('../fixtures/artifacts/animation/trace.json', import.meta);
const errorTrace = readJson('../fixtures/traces/no_fmp_event.json', import.meta);

const options = PageExecutionTimings.defaultOptions;
Expand Down
4 changes: 2 additions & 2 deletions core/test/audits/metrics/interactive-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {readJson} from '../../test-utils.js';

const acceptableTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta);
const acceptableDevToolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta);
const redirectTrace = readJson('../../fixtures/traces/site-with-redirect.json', import.meta);
const redirectDevToolsLog = readJson('../../fixtures/traces/site-with-redirect.devtools.log.json', import.meta);
const redirectTrace = readJson('../../fixtures/artifacts/redirect/trace.json', import.meta);
const redirectDevToolsLog = readJson('../../fixtures/artifacts/redirect/devtoolslog.json', import.meta);

const options = Interactive.defaultOptions;

Expand Down
4 changes: 2 additions & 2 deletions core/test/audits/third-party-facades-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {getURLArtifactFromDevtoolsLog, readJson} from '../test-utils.js';

const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta);
const pwaDevtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta);
const videoEmbedsTrace = readJson('../fixtures/traces/video-embeds-m84.json', import.meta);
const videoEmbedsDevtolsLog = readJson('../fixtures/traces/video-embeds-m84.devtools.log.json', import.meta);
const videoEmbedsTrace = readJson('../fixtures/artifacts/video-embed/trace.json', import.meta);
const videoEmbedsDevtolsLog = readJson('../fixtures/artifacts/video-embed/devtoolslog.json', import.meta);
const noThirdPartyTrace = readJson('../fixtures/traces/no-tracingstarted-m74.json', import.meta);

function intercomProductUrl(id) {
Expand Down
2 changes: 1 addition & 1 deletion core/test/audits/user-timing-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import assert from 'assert/strict';
import UserTimingsAudit from '../../audits/user-timings.js';
import {readJson} from '../test-utils.js';

const trace = readJson('../fixtures/traces/trace-user-timings.json', import.meta);
const trace = readJson('../fixtures/artifacts/user-timing/trace.json', import.meta);

function generateArtifactsWithTrace(trace) {
return {
Expand Down
2 changes: 1 addition & 1 deletion core/test/fixtures/artifacts/animation/regenerate.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function verify(artifacts) {
await updateTestFixture({
name: 'animation',
about: 'Page with an animated elements that are composited and non-composited',
saveTrace: 'animation.json',
saveTrace: true,
saveDevtoolsLog: false,
runUserFlow,
verify,
Expand Down
4 changes: 2 additions & 2 deletions core/test/fixtures/artifacts/redirect/regenerate.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function verify(artifacts) {
await updateTestFixture({
name: 'redirect',
about: 'Page with a multiple navigation-initiated redirects and a JS reload',
saveTrace: 'site-with-redirect.json',
saveDevtoolsLog: 'site-with-redirect.devtools.log.json',
saveTrace: true,
saveDevtoolsLog: true,
runUserFlow,
verify,
});
13 changes: 6 additions & 7 deletions core/test/fixtures/artifacts/update-test-fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ import {saveTrace, saveDevtoolsLog} from '../../../lib/asset-saver.js';
* @property {string} about
* @property {(page: puppeteer.Page, port: number) => Promise<LH.UserFlow>} runUserFlow
* @property {(artifacts: LH.Artifacts) => void} verify
* @property {string|false} saveTrace
* @property {string|false} saveDevtoolsLog
* @property {boolean} saveTrace
* @property {boolean} saveDevtoolsLog
*/

/**
* @param {CollectMeta} collectMeta
*/
export async function updateTestFixture(collectMeta) {
const fixturesDir = `${LH_ROOT}/core/test/fixtures/traces`;

const browser = await puppeteer.launch();
const server = new Server(0);
server.baseDir = `${LH_ROOT}/core/test/fixtures/artifacts/${collectMeta.name}/page`;
const dir = `${LH_ROOT}/core/test/fixtures/artifacts/${collectMeta.name}`;
server.baseDir = `${dir}/page`;
await server.listen(0, 'localhost');
const port = server.getPort();

Expand All @@ -40,10 +39,10 @@ export async function updateTestFixture(collectMeta) {
const {artifacts} = flow.createArtifactsJson().gatherSteps[0];
collectMeta.verify(artifacts);
if (collectMeta.saveTrace) {
await saveTrace(artifacts.Trace, `${fixturesDir}/${collectMeta.saveTrace}`);
await saveTrace(artifacts.Trace, `${dir}/trace.json`);
}
if (collectMeta.saveDevtoolsLog) {
await saveDevtoolsLog(artifacts.DevtoolsLog, `${fixturesDir}/${collectMeta.saveDevtoolsLog}`);
await saveDevtoolsLog(artifacts.DevtoolsLog, `${dir}/devtoolslog.json`);
}
} finally {
await server.close();
Expand Down
2 changes: 1 addition & 1 deletion core/test/fixtures/artifacts/user-timing/regenerate.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function verify(artifacts) {
await updateTestFixture({
name: 'user-timing',
about: 'Page with calls to the performance user timings API',
saveTrace: 'trace-user-timings.json',
saveTrace: true,
saveDevtoolsLog: false,
runUserFlow,
verify,
Expand Down
5 changes: 2 additions & 3 deletions core/test/fixtures/artifacts/video-embed/regenerate.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ function verify(artifacts) {
await updateTestFixture({
name: 'video-embed',
about: 'Page with a YouTube and Vimeo video',
// TODO: drop m84 suffix
saveTrace: 'video-embeds-m84.json',
saveDevtoolsLog: 'video-embeds-m84.devtools.log.json',
saveTrace: true,
saveDevtoolsLog: true,
runUserFlow,
verify,
});
2 changes: 1 addition & 1 deletion core/test/gather/gatherers/trace-elements-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {createTestTrace, rootFrame} from '../../create-test-trace.js';
import {createMockSendCommandFn, createMockOnFn} from '../mock-commands.js';
import {flushAllTimersAndMicrotasks, fnAny, readJson, timers} from '../../test-utils.js';

const animationTrace = readJson('../../fixtures/traces/animation.json', import.meta);
const animationTrace = readJson('../../fixtures/artifacts/animation/trace.json', import.meta);

function makeLayoutShiftTraceEvent(score, impactedNodes, had_recent_input = false) { // eslint-disable-line camelcase
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {NetworkRecords} from '../../../../computed/network-records.js';
import {readJson} from '../../../test-utils.js';

const devtoolsLog = readJson('../../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta);
const devtoolsLogWithRedirect = readJson('../../../fixtures/traces/site-with-redirect.devtools.log.json', import.meta);
const devtoolsLogWithRedirect = readJson('../../../fixtures/artifacts/redirect/devtoolslog.json', import.meta);

describe('DependencyGraph/Simulator/NetworkAnalyzer', () => {
let recordId;
Expand Down