test(server): align specs with run environment and step schema
- update scenario tests to create runs with required environmentId - adjust browser controller expectations to session auto-create behavior - sync playwright/context mocks with current browser service usage
This commit is contained in:
@@ -15,6 +15,7 @@ import { DataSource } from "typeorm";
|
||||
import { buildTestApp } from "./app.harness";
|
||||
import { ScenarioService } from "../src/scenario/scenario.service";
|
||||
import { ScenarioSchedulerService } from "../src/scenario/scenario-scheduler.service";
|
||||
import { EnvironmentEntity } from "../src/environment/environment.entity";
|
||||
|
||||
describe("ScenarioRunStepEntity.output + helpers.getStepOutput", () => {
|
||||
let app: INestApplication;
|
||||
@@ -52,18 +53,26 @@ describe("ScenarioRunStepEntity.output + helpers.getStepOutput", () => {
|
||||
scenarioId: string,
|
||||
_order: number,
|
||||
execCode: string,
|
||||
sessionName = "output-test-session",
|
||||
): Promise<string> {
|
||||
const step = await scenarioService.createStep(scenarioId, {
|
||||
sessionName,
|
||||
execCode,
|
||||
});
|
||||
return step.id;
|
||||
}
|
||||
|
||||
/** Create a test environment and return its id. */
|
||||
async function createEnvironment(
|
||||
name = `output-env-${Math.random().toString(36).slice(2, 8)}`,
|
||||
): Promise<string> {
|
||||
const repo = dataSource.getRepository(EnvironmentEntity);
|
||||
const env = await repo.save(repo.create({ name, data: {} }));
|
||||
return env.id;
|
||||
}
|
||||
|
||||
/** Trigger a run and process it to completion via the scheduler. */
|
||||
async function runScenario(scenarioId: string): Promise<string> {
|
||||
const run = await scenarioService.createRun(scenarioId);
|
||||
const environmentId = await createEnvironment();
|
||||
const run = await scenarioService.createRun(scenarioId, environmentId);
|
||||
// Drive the scheduler directly — keeps tests synchronous and fast.
|
||||
await scheduler.pickUpPendingRuns();
|
||||
// Wait for the run to reach a terminal state (max 10 s).
|
||||
|
||||
Reference in New Issue
Block a user