fix(ui mode): allow --updateSnapshots (#31584)

Fixes #31408.
This commit is contained in:
Dmitry Gozman 2024-07-08 01:08:57 -07:00 committed by GitHub
parent bc27ca225e
commit 48db1b1663
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 0 deletions

View File

@ -47,6 +47,7 @@ export type TraceViewerRedirectOptions = {
webApp?: string;
isServer?: boolean;
outputDir?: string;
updateSnapshots?: 'all' | 'none' | 'missing';
};
export type TraceViewerAppOptions = {
@ -132,6 +133,8 @@ export async function installRootRedirect(server: HttpServer, traceUrls: string[
params.append('headed', '');
if (options.outputDir)
params.append('outputDir', options.outputDir);
if (options.updateSnapshots)
params.append('updateSnapshots', options.updateSnapshots);
for (const reporter of options.reporter || [])
params.append('reporter', reporter);

View File

@ -93,6 +93,7 @@ export interface TestServerInterface {
workers?: number | string;
timeout?: number,
outputDir?: string;
updateSnapshots?: 'all' | 'none' | 'missing';
reporters?: string[],
trace?: 'on' | 'off';
video?: 'on' | 'off';

View File

@ -171,6 +171,7 @@ async function runTests(args: string[], opts: { [key: string]: any }) {
workers: cliOverrides.workers,
timeout: cliOverrides.timeout,
outputDir: cliOverrides.outputDir,
updateSnapshots: cliOverrides.updateSnapshots,
});
await stopProfiling('runner');
if (status === 'restarted')

View File

@ -314,6 +314,7 @@ class TestServerDispatcher implements TestServerInterface {
_optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : undefined,
},
outputDir: params.outputDir,
updateSnapshots: params.updateSnapshots,
workers: params.workers,
};
if (params.trace === 'on')

View File

@ -61,8 +61,11 @@ const queryParams = {
timeout: searchParams.has('timeout') ? +searchParams.get('timeout')! : undefined,
headed: searchParams.has('headed'),
outputDir: searchParams.get('outputDir') || undefined,
updateSnapshots: (searchParams.get('updateSnapshots') as 'all' | 'none' | 'missing' | undefined) || undefined,
reporters: searchParams.has('reporter') ? searchParams.getAll('reporter') : undefined,
};
if (queryParams.updateSnapshots && !['all', 'none', 'missing'].includes(queryParams.updateSnapshots))
queryParams.updateSnapshots = undefined;
const isMac = navigator.platform === 'MacIntel';
@ -285,6 +288,7 @@ export const UIModeView: React.FC<{}> = ({
timeout: queryParams.timeout,
headed: queryParams.headed,
outputDir: queryParams.outputDir,
updateSnapshots: queryParams.updateSnapshots,
reporters: queryParams.reporters,
trace: 'on',
});