chore: iterate towards recording into trace (4) (#32743)
This commit is contained in:
parent
418d1c0c55
commit
17ed944a84
|
|
@ -560,7 +560,7 @@ async function open(options: Options, url: string | undefined, language: string)
|
||||||
|
|
||||||
async function codegen(options: Options & { target: string, output?: string, testIdAttribute?: string }, url: string | undefined) {
|
async function codegen(options: Options & { target: string, output?: string, testIdAttribute?: string }, url: string | undefined) {
|
||||||
const { target: language, output: outputFile, testIdAttribute: testIdAttributeName } = options;
|
const { target: language, output: outputFile, testIdAttribute: testIdAttributeName } = options;
|
||||||
const tracesDir = path.join(os.tmpdir(), `recorder-trace-${Date.now()}`);
|
const tracesDir = path.join(os.tmpdir(), `playwright-recorder-trace-${Date.now()}`);
|
||||||
const { context, launchOptions, contextOptions } = await launchContext(options, {
|
const { context, launchOptions, contextOptions } = await launchContext(options, {
|
||||||
headless: !!process.env.PWTEST_CLI_HEADLESS,
|
headless: !!process.env.PWTEST_CLI_HEADLESS,
|
||||||
executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH,
|
executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH,
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,6 @@ export class BrowserContextDispatcher extends Dispatcher<BrowserContext, channel
|
||||||
screenshots: true,
|
screenshots: true,
|
||||||
live: true,
|
live: true,
|
||||||
});
|
});
|
||||||
await this._context.tracing.startChunk({ name: 'trace', title: 'trace' });
|
|
||||||
await Recorder.show('trace-events', this._context, RecorderInTraceViewer.factory(this._context), params);
|
await Recorder.show('trace-events', this._context, RecorderInTraceViewer.factory(this._context), params);
|
||||||
} else {
|
} else {
|
||||||
await Recorder.show('actions', this._context, RecorderApp.factory(this._context), params);
|
await Recorder.show('actions', this._context, RecorderApp.factory(this._context), params);
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ export class ContextRecorder extends EventEmitter {
|
||||||
saveStorage: params.saveStorage,
|
saveStorage: params.saveStorage,
|
||||||
};
|
};
|
||||||
|
|
||||||
const collection = new RecorderCollection(codegenMode, context, this._pageAliases, params.mode === 'recording');
|
this._collection = new RecorderCollection(codegenMode, context, this._pageAliases);
|
||||||
collection.on('change', (actions: ActionInContext[]) => {
|
this._collection.on('change', (actions: ActionInContext[]) => {
|
||||||
this._recorderSources = [];
|
this._recorderSources = [];
|
||||||
for (const languageGenerator of this._orderedLanguages) {
|
for (const languageGenerator of this._orderedLanguages) {
|
||||||
const { header, footer, actionTexts, text } = generateCode(actions, languageGenerator, languageGeneratorOptions);
|
const { header, footer, actionTexts, text } = generateCode(actions, languageGenerator, languageGeneratorOptions);
|
||||||
|
|
@ -103,7 +103,7 @@ export class ContextRecorder extends EventEmitter {
|
||||||
this._listeners.push(eventsHelper.addEventListener(process, 'exit', () => {
|
this._listeners.push(eventsHelper.addEventListener(process, 'exit', () => {
|
||||||
this._throttledOutputFile?.flush();
|
this._throttledOutputFile?.flush();
|
||||||
}));
|
}));
|
||||||
this._collection = collection;
|
this.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
setOutput(codegenId: string, outputFile?: string) {
|
setOutput(codegenId: string, outputFile?: string) {
|
||||||
|
|
@ -145,6 +145,10 @@ export class ContextRecorder extends EventEmitter {
|
||||||
|
|
||||||
setEnabled(enabled: boolean) {
|
setEnabled(enabled: boolean) {
|
||||||
this._collection.setEnabled(enabled);
|
this._collection.setEnabled(enabled);
|
||||||
|
if (enabled)
|
||||||
|
this._context.tracing.startChunk({ name: 'trace', title: 'trace' }).catch(() => {});
|
||||||
|
else
|
||||||
|
this._context.tracing.stopChunk({ mode: 'discard' }).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,13 @@ import type { BrowserContext } from '../browserContext';
|
||||||
|
|
||||||
export class RecorderCollection extends EventEmitter {
|
export class RecorderCollection extends EventEmitter {
|
||||||
private _actions: ActionInContext[] = [];
|
private _actions: ActionInContext[] = [];
|
||||||
private _enabled: boolean;
|
private _enabled = false;
|
||||||
private _pageAliases: Map<Page, string>;
|
private _pageAliases: Map<Page, string>;
|
||||||
private _context: BrowserContext;
|
private _context: BrowserContext;
|
||||||
|
|
||||||
constructor(codegenMode: 'actions' | 'trace-events', context: BrowserContext, pageAliases: Map<Page, string>, enabled: boolean) {
|
constructor(codegenMode: 'actions' | 'trace-events', context: BrowserContext, pageAliases: Map<Page, string>) {
|
||||||
super();
|
super();
|
||||||
this._context = context;
|
this._context = context;
|
||||||
this._enabled = enabled;
|
|
||||||
this._pageAliases = pageAliases;
|
this._pageAliases = pageAliases;
|
||||||
|
|
||||||
if (codegenMode === 'trace-events') {
|
if (codegenMode === 'trace-events') {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ async function loadTrace(traceUrl: string, traceFileName: string | null, clientI
|
||||||
}
|
}
|
||||||
set.add(traceUrl);
|
set.add(traceUrl);
|
||||||
|
|
||||||
const isRecorderMode = traceUrl.includes('/recorder-trace-');
|
const isRecorderMode = traceUrl.includes('/playwright-recorder-trace-');
|
||||||
|
|
||||||
const traceModel = new TraceModel();
|
const traceModel = new TraceModel();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
.call-section {
|
.call-section {
|
||||||
padding-left: 6px;
|
padding-left: 6px;
|
||||||
|
padding-top: 2px;
|
||||||
|
margin-top: 2px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
|
|
@ -53,9 +55,8 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
line-height: 18px;
|
line-height: 20px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
max-height: 18px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.call-line:not(:hover) .toolbar-button.copy {
|
.call-line:not(:hover) .toolbar-button.copy {
|
||||||
|
|
@ -64,7 +65,8 @@
|
||||||
|
|
||||||
.call-line .toolbar-button.copy {
|
.call-line .toolbar-button.copy {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
transform: scale(0.8);
|
margin-top: -2px;
|
||||||
|
margin-bottom: -2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.call-value {
|
.call-value {
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ export const TraceView: React.FC<{
|
||||||
showSourcesFirst={true}
|
showSourcesFirst={true}
|
||||||
fallbackLocation={fallbackLocation}
|
fallbackLocation={fallbackLocation}
|
||||||
isLive={true}
|
isLive={true}
|
||||||
|
hideTimeline={true}
|
||||||
/>;
|
/>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ export const Workbench: React.FunctionComponent<{
|
||||||
rootDir?: string,
|
rootDir?: string,
|
||||||
fallbackLocation?: modelUtil.SourceLocation,
|
fallbackLocation?: modelUtil.SourceLocation,
|
||||||
isLive?: boolean,
|
isLive?: boolean,
|
||||||
|
hideTimeline?: boolean,
|
||||||
status?: UITestStatus,
|
status?: UITestStatus,
|
||||||
annotations?: { type: string; description?: string; }[];
|
annotations?: { type: string; description?: string; }[];
|
||||||
inert?: boolean,
|
inert?: boolean,
|
||||||
|
|
@ -57,7 +58,7 @@ export const Workbench: React.FunctionComponent<{
|
||||||
onOpenExternally?: (location: modelUtil.SourceLocation) => void,
|
onOpenExternally?: (location: modelUtil.SourceLocation) => void,
|
||||||
revealSource?: boolean,
|
revealSource?: boolean,
|
||||||
showSettings?: boolean,
|
showSettings?: boolean,
|
||||||
}> = ({ model, showSourcesFirst, rootDir, fallbackLocation, isLive, status, annotations, inert, openPage, onOpenExternally, revealSource, showSettings }) => {
|
}> = ({ model, showSourcesFirst, rootDir, fallbackLocation, isLive, hideTimeline, status, annotations, inert, openPage, onOpenExternally, revealSource, showSettings }) => {
|
||||||
const [selectedCallId, setSelectedCallId] = React.useState<string | undefined>(undefined);
|
const [selectedCallId, setSelectedCallId] = React.useState<string | undefined>(undefined);
|
||||||
const [revealedError, setRevealedError] = React.useState<ErrorDescription | undefined>(undefined);
|
const [revealedError, setRevealedError] = React.useState<ErrorDescription | undefined>(undefined);
|
||||||
|
|
||||||
|
|
@ -317,7 +318,7 @@ export const Workbench: React.FunctionComponent<{
|
||||||
};
|
};
|
||||||
|
|
||||||
return <div className='vbox workbench' {...(inert ? { inert: 'true' } : {})}>
|
return <div className='vbox workbench' {...(inert ? { inert: 'true' } : {})}>
|
||||||
<Timeline
|
{!hideTimeline && <Timeline
|
||||||
model={model}
|
model={model}
|
||||||
consoleEntries={consoleModel.entries}
|
consoleEntries={consoleModel.entries}
|
||||||
boundaries={boundaries}
|
boundaries={boundaries}
|
||||||
|
|
@ -328,7 +329,7 @@ export const Workbench: React.FunctionComponent<{
|
||||||
sdkLanguage={sdkLanguage}
|
sdkLanguage={sdkLanguage}
|
||||||
selectedTime={selectedTime}
|
selectedTime={selectedTime}
|
||||||
setSelectedTime={setSelectedTime}
|
setSelectedTime={setSelectedTime}
|
||||||
/>
|
/>}
|
||||||
<SplitView
|
<SplitView
|
||||||
sidebarSize={250}
|
sidebarSize={250}
|
||||||
orientation={sidebarLocation === 'bottom' ? 'vertical' : 'horizontal'} settingName='propertiesSidebar'
|
orientation={sidebarLocation === 'bottom' ? 'vertical' : 'horizontal'} settingName='propertiesSidebar'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue