26 lines
1.4 KiB
TypeScript
26 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { AppLifecycleManager } from "@/runtime/app-management/app-lifecycle-manager";
|
|
|
|
const now = "2026-08-04T00:00:00.000Z";
|
|
|
|
describe("AppLifecycleManager", () => {
|
|
it("preserves the prior foreground instance and restores a bounded workspace snapshot", () => {
|
|
const lifecycle = new AppLifecycleManager();
|
|
lifecycle.start({ instance_id: "interaction:audio-001", app_scope: "chat", conversation_id: "conversation" }, now);
|
|
lifecycle.foreground("interaction:audio-001", now);
|
|
lifecycle.start({ instance_id: "draw-and-guess:game-001", app_scope: "draw-and-guess", conversation_id: "conversation", parent_instance_id: "interaction:audio-001" }, now);
|
|
lifecycle.foreground("draw-and-guess:game-001", now);
|
|
|
|
expect(lifecycle.instances.get("interaction:audio-001")).toMatchObject({ state: "background" });
|
|
expect(lifecycle.instances.get("draw-and-guess:game-001")).toMatchObject({ state: "foreground" });
|
|
expect(lifecycle.focus.history()).toEqual(["interaction:audio-001", "draw-and-guess:game-001"]);
|
|
|
|
lifecycle.close("draw-and-guess:game-001", now);
|
|
lifecycle.foreground("interaction:audio-001", now);
|
|
const restored = new AppLifecycleManager();
|
|
restored.restore(lifecycle.snapshot());
|
|
expect(restored.focus.foreground()).toBe("interaction:audio-001");
|
|
expect(restored.instances.get("draw-and-guess:game-001")).toMatchObject({ state: "stopped" });
|
|
});
|
|
});
|