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:
2026-04-17 15:13:28 +03:00
parent 8c6158e8e3
commit 4e494ce4fd
5 changed files with 101 additions and 2 deletions
+29
View File
@@ -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 ─────────────────────────────────────────────────────