fix: fix links in scenario service
This commit is contained in:
@@ -7,6 +7,7 @@ import { chromium } from "playwright";
|
||||
import { Repository } from "typeorm";
|
||||
import type { ScriptLogger } from "../code-executor/code-executor.service";
|
||||
import { CodeExecutorService } from "../code-executor/code-executor.service";
|
||||
import { ExecContextBuilder } from "../code-executor/exec-context.builder";
|
||||
import { traceStorage } from "../common/trace-context";
|
||||
import { TraceLogger } from "../common/trace-logger";
|
||||
import { EnvironmentData, EnvironmentEntity } from "../environment/environment.entity";
|
||||
@@ -170,7 +171,9 @@ export class ScenarioSchedulerService {
|
||||
}
|
||||
|
||||
const handle = this.runBrowsers.get(runId);
|
||||
if (!handle) return;
|
||||
if (!handle) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sessionName = `run-${runId}`;
|
||||
try {
|
||||
@@ -184,7 +187,8 @@ export class ScenarioSchedulerService {
|
||||
cookies.find((c) => c.name === "token")?.value ??
|
||||
"";
|
||||
|
||||
await this.sessionService.upsert(sessionName, token, cookies, localStorage);
|
||||
const session = await this.sessionService.upsert(sessionName, token, cookies, localStorage);
|
||||
await this.runRepo.update(runId, { sessionId: session.id });
|
||||
this.sessionContextService.register(
|
||||
sessionName,
|
||||
handle.browser,
|
||||
@@ -194,7 +198,7 @@ export class ScenarioSchedulerService {
|
||||
// Remove from runBrowsers so closeBrowserHandle won't close it
|
||||
this.runBrowsers.delete(runId);
|
||||
this.logger.log(
|
||||
`Run #${runId}: browser preserved as session "${sessionName}"`,
|
||||
`Run #${runId}: browser preserved as session "${sessionName}" (${session.id})`,
|
||||
);
|
||||
} catch (err) {
|
||||
this.logger.warn(
|
||||
@@ -223,16 +227,17 @@ export class ScenarioSchedulerService {
|
||||
const creds = this.runCredentials.get(stepRun.runId);
|
||||
const snips = this.runSnippets.get(stepRun.runId);
|
||||
const env = this.runEnvironments.get(stepRun.runId);
|
||||
const { result: execOutput } = await this.codeExecutor.execute({
|
||||
page,
|
||||
browser: context,
|
||||
code: step.execCode,
|
||||
log: this.stepLogger(stepRun.id, stepRun.runId),
|
||||
getStepOutput,
|
||||
credentials: creds,
|
||||
environment: env,
|
||||
snippets: snips,
|
||||
});
|
||||
const execCtx = new ExecContextBuilder()
|
||||
.page(page)
|
||||
.browser(context)
|
||||
.code(step.execCode)
|
||||
.log(this.stepLogger(stepRun.id, stepRun.runId))
|
||||
.getStepOutput(getStepOutput)
|
||||
.credentials(creds)
|
||||
.environment(env)
|
||||
.snippets(snips)
|
||||
.build();
|
||||
const { result: execOutput } = await this.codeExecutor.execute(execCtx);
|
||||
|
||||
await this.passStepRun(stepRun, null, execOutput);
|
||||
} catch (err) {
|
||||
@@ -310,7 +315,8 @@ export class ScenarioSchedulerService {
|
||||
],
|
||||
});
|
||||
if (remaining === 0) {
|
||||
await this.closeBrowserHandle(stepRun.runId);
|
||||
// Don't close the browser here — maybePreserveSession will handle it
|
||||
// (either preserving it if saveSession=true, or closing if false)
|
||||
await this.runRepo.update(stepRun.runId, { status: "pass" });
|
||||
this.logger.log(`Run #${stepRun.runId} → pass (all steps passed)`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user