- scenario_run_logs gains a context column (step:N, snippet:alias, assertion:pass/fail, run), tracked through a call stack in CodeExecutorService so nested runSnippet calls tag their own and inner log lines - automatic step started/passed/failed entries and the Playwright trace upload notice are tagged accordingly - run log export (CSV/Markdown) and the logs search match context as well as message - add a LogOutput UI component: a terminal-style log viewer with level color coding, elapsed-time-since-start timestamps and a context tag, replacing the generic Table on the run detail page - show the full log list instead of paginating it, capped to a scrollable block - fix migrations.spec.ts's revert test, which only undid the last migration instead of all of them
78 lines
1.9 KiB
TypeScript
78 lines
1.9 KiB
TypeScript
import type { BrowserContext, Page } from "playwright";
|
|
import type { EnvironmentData } from "../environment/environment.entity";
|
|
import type { FileStorageService } from "../file/file-storage.service";
|
|
import type { ExecContext, ScriptLogger } from "./code-executor.service";
|
|
|
|
export class ExecContextBuilder {
|
|
private readonly ctx: Partial<ExecContext> = {};
|
|
|
|
page(page: Page): this {
|
|
this.ctx.page = page;
|
|
return this;
|
|
}
|
|
|
|
browser(browser: BrowserContext): this {
|
|
this.ctx.browser = browser;
|
|
return this;
|
|
}
|
|
|
|
code(code: string): this {
|
|
this.ctx.code = code;
|
|
return this;
|
|
}
|
|
|
|
log(log: ScriptLogger): this {
|
|
this.ctx.log = log;
|
|
return this;
|
|
}
|
|
|
|
logContext(logContext: string): this {
|
|
this.ctx.logContext = logContext;
|
|
return this;
|
|
}
|
|
|
|
getStepOutput(fn: (order: number) => Promise<unknown>): this {
|
|
this.ctx.getStepOutput = fn;
|
|
return this;
|
|
}
|
|
|
|
credentials(credentials: Record<string, unknown>): this {
|
|
this.ctx.credentials = credentials;
|
|
return this;
|
|
}
|
|
|
|
environment(environment: EnvironmentData | null): this {
|
|
this.ctx.environment = environment;
|
|
return this;
|
|
}
|
|
|
|
snippets(snippets: Record<string, string> | null): this {
|
|
this.ctx.snippets = snippets;
|
|
return this;
|
|
}
|
|
|
|
scenarioId(scenarioId: string): this {
|
|
this.ctx.scenarioId = scenarioId;
|
|
return this;
|
|
}
|
|
|
|
runId(runId: string): this {
|
|
this.ctx.runId = runId;
|
|
return this;
|
|
}
|
|
|
|
fileService(fileService: FileStorageService): this {
|
|
this.ctx.fileService = fileService;
|
|
return this;
|
|
}
|
|
|
|
build(): ExecContext {
|
|
if (!this.ctx.page) throw new Error("ExecContextBuilder: page is required");
|
|
if (!this.ctx.browser)
|
|
throw new Error("ExecContextBuilder: browser is required");
|
|
if (this.ctx.code === undefined)
|
|
throw new Error("ExecContextBuilder: code is required");
|
|
return this.ctx as ExecContext;
|
|
}
|
|
}
|