feat(FN-2186): merge fusion/fn-2186

This commit is contained in:
gsxdsm
2026-04-22 13:46:53 -07:00
parent ea1be41a4f
commit 794da6a030
4 changed files with 477 additions and 0 deletions

View File

@@ -255,6 +255,32 @@ describe("devserver-manager", () => {
expect(restarted.config.id).toBe(config.id);
});
it("startServer throws error when process emits error event", async () => {
const config = makeConfig();
const onStatus = vi.fn();
manager.on("status", onStatus);
await manager.startServer(config);
// Simulate process error (e.g., command not found)
children[0].emit("error", new Error("spawn ENOENT"));
const session = manager.getSession(config.id);
expect(session?.status).toBe("failed");
expect(onStatus).toHaveBeenLastCalledWith(config.id, "failed");
});
it("startServer throws error when same server is already running", async () => {
const config = makeConfig();
await manager.startServer(config);
children[0].stdout.emit("data", "ready");
// Try to start the same server again
await expect(manager.startServer(config)).rejects.toThrow(
/already (?:running|starting)/,
);
});
it("setPreviewUrl updates session and emits preview event", async () => {
const config = makeConfig();
const onPreview = vi.fn();