- snapshot scenario and snippet content into version tables on every
content change; live tables keep holding the latest version
- record the scenario version on each run and copy its steps into the
run steps, so runs execute and show the version they were created with
- keep run step history when a step is deleted (FK set null)
- pin a snippet version with runSnippet('alias@N')
- add version picker to the run modal and version info across the UI
- add version list/get endpoints and MCP tools
- include version in exports and require it on import, restoring the
exact version by id + version
71 lines
1.9 KiB
TypeScript
71 lines
1.9 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
OneToMany,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from "typeorm";
|
|
import type { TraceMode } from "../config/app.config";
|
|
import { EnvironmentEntity } from "../environment/environment.entity";
|
|
import { SessionEntity } from "../session/session.entity";
|
|
import { ScenarioRunStepEntity } from "./scenario-run-step.entity";
|
|
import { ScenarioEntity } from "./scenario.entity";
|
|
|
|
export type RunStatus = "pending" | "in_progress" | "pass" | "fail";
|
|
|
|
@Entity("scenario_runs")
|
|
export class ScenarioRunEntity {
|
|
@PrimaryGeneratedColumn("uuid")
|
|
id: string;
|
|
|
|
@Column("text")
|
|
scenarioId: string;
|
|
|
|
@Column("text", { nullable: true, default: null })
|
|
environmentId: string | null;
|
|
|
|
@ManyToOne(() => ScenarioEntity, { onDelete: "CASCADE" })
|
|
@JoinColumn({ name: "scenarioId" })
|
|
scenario: ScenarioEntity;
|
|
|
|
@ManyToOne(() => EnvironmentEntity, { onDelete: "SET NULL", nullable: true })
|
|
@JoinColumn({ name: "environmentId" })
|
|
environment: EnvironmentEntity;
|
|
|
|
@Column("text", { nullable: true, default: null })
|
|
sessionId: string | null;
|
|
|
|
@ManyToOne(() => SessionEntity, { onDelete: "SET NULL", nullable: true })
|
|
@JoinColumn({ name: "sessionId" })
|
|
session: SessionEntity | null;
|
|
|
|
/** Scenario version this run executes; null for runs created before versioning. */
|
|
@Column({ type: "int", nullable: true, default: null })
|
|
scenarioVersion: number | null;
|
|
|
|
@Column({ type: "text", default: "pending" })
|
|
status: RunStatus;
|
|
|
|
@Column({ type: "boolean", default: false })
|
|
saveSession: boolean;
|
|
|
|
// Playwright trace mode for this run; null falls back to PLAYWRIGHT_TRACE_MODE
|
|
@Column("text", { nullable: true, default: null })
|
|
traceMode: TraceMode | null;
|
|
|
|
@OneToMany(() => ScenarioRunStepEntity, (rs) => rs.run, {
|
|
cascade: true,
|
|
eager: false,
|
|
})
|
|
stepRuns: ScenarioRunStepEntity[];
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn()
|
|
updatedAt: Date;
|
|
}
|