chore: pass cli config overrides straight to test server (#32818)

This commit is contained in:
Yury Semikhatsky 2024-09-25 19:45:59 -07:00 committed by GitHub
parent 61801aa1ee
commit 597642d269
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 9 additions and 30 deletions

View file

@ -40,13 +40,9 @@ export type TraceViewerRedirectOptions = {
grep?: string;
grepInvert?: string;
project?: string[];
workers?: number | string;
headed?: boolean;
timeout?: number;
reporter?: string[];
webApp?: string;
isServer?: boolean;
updateSnapshots?: 'all' | 'none' | 'missing';
};
export type TraceViewerAppOptions = {
@ -126,14 +122,6 @@ export async function installRootRedirect(server: HttpServer, traceUrls: string[
params.append('grepInvert', options.grepInvert);
for (const project of options.project || [])
params.append('project', project);
if (options.workers)
params.append('workers', String(options.workers));
if (options.timeout)
params.append('timeout', String(options.timeout));
if (options.headed)
params.append('headed', '');
if (options.updateSnapshots)
params.append('updateSnapshots', options.updateSnapshots);
for (const reporter of options.reporter || [])
params.append('reporter', reporter);

View file

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

View file

@ -168,11 +168,7 @@ async function runTests(args: string[], opts: { [key: string]: any }) {
grep: opts.grep as string | undefined,
grepInvert: opts.grepInvert as string | undefined,
project: opts.project || undefined,
headed: opts.headed,
reporter: Array.isArray(opts.reporter) ? opts.reporter : opts.reporter ? [opts.reporter] : undefined,
workers: cliOverrides.workers,
timeout: cliOverrides.timeout,
updateSnapshots: cliOverrides.updateSnapshots,
});
await stopProfiling('runner');
if (status === 'restarted')

View file

@ -300,17 +300,17 @@ export class TestServerDispatcher implements TestServerInterface {
repeatEach: 1,
retries: 0,
preserveOutputDir: true,
timeout: params.timeout,
reporter: params.reporters ? params.reporters.map(r => [r]) : undefined,
use: {
...(this._configCLIOverrides.use || {}),
trace: params.trace === 'on' ? { mode: 'on', sources: false, _live: true } : (params.trace === 'off' ? 'off' : undefined),
video: params.video === 'on' ? 'on' : (params.video === 'off' ? 'off' : undefined),
headless: params.headed ? false : undefined,
_optionContextReuseMode: params.reuseContext ? 'when-possible' : undefined,
_optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : undefined,
},
updateSnapshots: params.updateSnapshots,
workers: params.workers,
...(params.updateSnapshots ? { updateSnapshots: params.updateSnapshots } : {}),
...(params.workers ? { workers: params.workers } : {}),
};
if (params.trace === 'on')
process.env.PW_LIVE_TRACE_STACKS = '1';

View file

@ -56,7 +56,6 @@ const queryParams = {
grepInvert: searchParams.get('grepInvert') || undefined,
projects: searchParams.getAll('project'),
workers: searchParams.get('workers') || undefined,
timeout: searchParams.has('timeout') ? +searchParams.get('timeout')! : undefined,
headed: searchParams.has('headed'),
updateSnapshots: (searchParams.get('updateSnapshots') as 'all' | 'none' | 'missing' | undefined) || undefined,
reporters: searchParams.has('reporter') ? searchParams.getAll('reporter') : undefined,
@ -101,9 +100,9 @@ export const UIModeView: React.FC<{}> = ({
const onRevealSource = React.useCallback(() => setRevealSource(true), [setRevealSource]);
const showTestingOptions = false;
const [singleWorker, setSingleWorker] = React.useState(queryParams.workers === '1');
const [showBrowser, setShowBrowser] = React.useState(queryParams.headed);
const [updateSnapshots, setUpdateSnapshots] = React.useState(queryParams.updateSnapshots === 'all');
const [singleWorker, setSingleWorker] = React.useState(false);
const [showBrowser, setShowBrowser] = React.useState(false);
const [updateSnapshots, setUpdateSnapshots] = React.useState(false);
const [darkMode, setDarkMode] = useDarkModeSetting();
const [showScreenshot, setShowScreenshot] = useSetting('screenshot-instead-of-snapshot', false);
@ -288,12 +287,9 @@ export const UIModeView: React.FC<{}> = ({
grepInvert: queryParams.grepInvert,
testIds: [...testIds],
projects: [...projectFilters].filter(([_, v]) => v).map(([p]) => p),
// When started with `--workers=1`, the setting allows to undo that.
// Otherwise, fallback to the cli `--workers=X` argument.
workers: singleWorker ? '1' : (queryParams.workers === '1' ? undefined : queryParams.workers),
timeout: queryParams.timeout,
headed: showBrowser,
updateSnapshots: updateSnapshots ? 'all' : queryParams.updateSnapshots,
...(singleWorker ? { workers: '1' } : {}),
...(showBrowser ? { headed: true } : {}),
...(updateSnapshots ? { updateSnapshots: 'all' } : {}),
reporters: queryParams.reporters,
trace: 'on',
});