feat(scenarios): show last run status and timestamp on scenarios list
- extend findAll to join latest run per scenario via correlated subquery - return lastRunStatus and lastRunAt fields in GET /scenarios response - add Last Run column with badge and timestamp to ScenariosPage - add integration tests for null and populated lastRunStatus
This commit is contained in:
@@ -171,6 +171,35 @@ describe("ScenarioController", () => {
|
||||
.get("/scenarios?orderDir=SIDEWAYS")
|
||||
.expect(400);
|
||||
});
|
||||
|
||||
it("returns lastRunStatus and lastRunAt as null when scenario has no runs", async () => {
|
||||
await createScenario("no-runs-sc");
|
||||
const res = await request(app.getHttpServer())
|
||||
.get("/scenarios?orderBy=name&orderDir=ASC")
|
||||
.expect(200);
|
||||
const item = res.body.data.find(
|
||||
(s: { name: string }) => s.name === "no-runs-sc",
|
||||
);
|
||||
expect(item).toBeDefined();
|
||||
expect(item.lastRunStatus).toBeNull();
|
||||
expect(item.lastRunAt).toBeNull();
|
||||
});
|
||||
|
||||
it("returns lastRunStatus and lastRunAt reflecting the most recent run", async () => {
|
||||
const sc = await createScenario("last-run-status-sc");
|
||||
await createRun(sc.id);
|
||||
const res = await request(app.getHttpServer())
|
||||
.get("/scenarios?orderBy=name&orderDir=ASC")
|
||||
.expect(200);
|
||||
const item = res.body.data.find(
|
||||
(s: { name: string }) => s.name === "last-run-status-sc",
|
||||
);
|
||||
expect(item).toBeDefined();
|
||||
expect(["pending", "in_progress", "pass", "fail"]).toContain(
|
||||
item.lastRunStatus,
|
||||
);
|
||||
expect(typeof item.lastRunAt).toBe("string");
|
||||
});
|
||||
});
|
||||
|
||||
// ── GET /scenarios/:id ─────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user