test: migrate workbench fixtures to persistent event streams

Static fulfilled SSE bodies closed immediately and made ordinary UI cases reconnect. Serve persistent fixture streams, retain outage and cursor recovery coverage, and update legacy approval and investigation assertions for current disclosures and SVG diagrams.

Validation: 12 related browser scenarios, 877 unit tests, type checking, scoped ESLint, and diff checks. Unrelated SCADA replay changes remain outside this commit.
This commit is contained in:
2026-11-02 18:56:57 +08:00
parent 0ec74b15b2
commit 78481903d7
7 changed files with 125 additions and 53 deletions
@@ -1,6 +1,7 @@
import { expect, test } from "@playwright/test";
import { mockAgentApi } from "./support/mock-agent-api";
import { mockWorkbenchContext } from "./support/mock-workbench-context";
import { mockWorkbenchEventStream } from "./support/mock-workbench-event-stream";
type SyncProbe = {
available: boolean;
@@ -14,6 +15,27 @@ declare global {
interface Window { syncProbe: SyncProbe }
}
test("healthy UI fixtures keep one event connection open across the warning window and page reload", async ({ page }) => {
await mockWorkbenchContext(page);
await mockAgentApi(page);
const stream = await mockWorkbenchEventStream(page);
const now = new Date("2026-10-12T02:00:00Z");
await page.clock.install({ time: now });
await page.clock.pauseAt(now);
await page.goto("/", { waitUntil: "domcontentloaded" });
await expect.poll(() => stream.cursors.length).toBe(1);
await page.clock.runFor(31_000);
expect(stream.cursors).toEqual(["0"]);
await expect(page.getByText("业务同步正在重连", { exact: true })).toHaveCount(0);
await page.reload({ waitUntil: "domcontentloaded" });
await expect.poll(() => stream.cursors.length).toBe(2);
await page.clock.runFor(16_000);
expect(stream.cursors).toEqual(["0", "0"]);
await expect(page.getByText("业务同步正在重连", { exact: true })).toHaveCount(0);
});
test("scheduled renewals stay silent while a sustained outage warns and recovers", async ({ page }) => {
await mockWorkbenchContext(page);
await mockAgentApi(page);