feat(workbench): expand SCADA monitoring and investigation presentation

This commit is contained in:
2026-11-07 19:50:14 +08:00
parent 0801e161ec
commit ba71e2d529
133 changed files with 6754 additions and 1438 deletions
@@ -0,0 +1,28 @@
import { cleanup, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, expect, it, vi } from "vitest";
import { dismissMapNotice, showMapNotice } from "@/features/map/core";
import { NoticeDevTools } from "./notice-dev-tools";
vi.mock("@/features/map/core", () => ({ showMapNotice: vi.fn(), dismissMapNotice: vi.fn() }));
afterEach(() => { cleanup(); vi.clearAllMocks(); });
it("previews every tone, completes loading in place and clears only its own notices", async () => {
render(<NoticeDevTools />);
const user = userEvent.setup();
for (const label of ["信息", "成功", "警告", "错误", "加载"]) {
await user.click(screen.getByRole("button", { name: `测试${label}通知` }));
}
expect(vi.mocked(showMapNotice).mock.calls.map(([options]) => options.tone)).toEqual(["info", "success", "warning", "error", "loading"]);
await user.click(screen.getByRole("button", { name: "模拟加载完成" }));
expect(showMapNotice).toHaveBeenLastCalledWith(expect.objectContaining({ id: "dev-notice:loading", tone: "success" }));
await user.click(screen.getByRole("button", { name: "测试报告通知" }));
const report = vi.mocked(showMapNotice).mock.lastCall![0];
expect(report.actionLabel).toBe("查看报告");
await user.click(screen.getByRole("button", { name: "连续 6 条通知" }));
expect(vi.mocked(showMapNotice).mock.calls.slice(-6).map(([options]) => options.id)).toEqual(
Array.from({ length: 6 }, (_, index) => `dev-notice:batch-${index}`)
);
await user.click(screen.getByRole("button", { name: "清除测试通知" }));
expect(vi.mocked(dismissMapNotice).mock.calls.every(([id]) => typeof id === "string" && id.startsWith("dev-notice:"))).toBe(true);
});