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:
@@ -8,8 +8,8 @@ import { Repository } from "typeorm";
|
||||
/**
|
||||
* Browser controller integration tests.
|
||||
*
|
||||
* POST /open and POST /exec need a running Playwright browser. We test
|
||||
* validation rejections (no browser launched) and session-not-found paths,
|
||||
* POST /open and POST /exec need a running Playwright browser. We test
|
||||
* validation rejections and auto-create behavior for unknown named sessions,
|
||||
* which are safe to run in a headless CI environment.
|
||||
*/
|
||||
describe("BrowserController", () => {
|
||||
@@ -54,11 +54,16 @@ describe("BrowserController", () => {
|
||||
.expect(400);
|
||||
});
|
||||
|
||||
it("returns 404 when session does not exist", async () => {
|
||||
await request(app.getHttpServer())
|
||||
it("auto-creates missing named session and succeeds", async () => {
|
||||
const res = await request(app.getHttpServer())
|
||||
.post("/open")
|
||||
.send({ sessionName: "no-such-session", url: "https://example.com" })
|
||||
.expect(404);
|
||||
.expect(201);
|
||||
expect(res.body).toMatchObject({
|
||||
url: expect.any(String),
|
||||
title: expect.any(String),
|
||||
content: expect.any(String),
|
||||
});
|
||||
});
|
||||
|
||||
it("succeeds without a session (sessionless open)", async () => {
|
||||
@@ -115,11 +120,12 @@ describe("BrowserController", () => {
|
||||
.expect(400);
|
||||
});
|
||||
|
||||
it("returns 404 when session does not exist", async () => {
|
||||
await request(app.getHttpServer())
|
||||
it("auto-creates missing named session and succeeds", async () => {
|
||||
const res = await request(app.getHttpServer())
|
||||
.post("/exec")
|
||||
.send({ sessionName: "no-such-session", code: "return 1;" })
|
||||
.expect(404);
|
||||
.expect(201);
|
||||
expect(res.body).toEqual({ result: 1 });
|
||||
});
|
||||
|
||||
it("succeeds without a session (sessionless exec)", async () => {
|
||||
|
||||
Reference in New Issue
Block a user