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
+37
View File
@@ -0,0 +1,37 @@
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, expect, it } from "vitest";
import { FloatingWindow } from "./floating-window";
afterEach(cleanup);
const content = () => <p>图表内容</p>;
it("opens display requests without stealing focus and respects dismissal until the next request", () => {
const { rerender } = render(<><button autoFocus>回放控制</button><FloatingWindow title="压力分析" openRequestKey="first">{content}</FloatingWindow></>);
expect(screen.getByRole("dialog", { name: "压力分析" })).toBeVisible();
expect(screen.getByRole("button", { name: "回放控制" })).toHaveFocus();
fireEvent.click(screen.getByRole("button", { name: "关闭窗口" }));
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
rerender(<><button>回放控制</button><FloatingWindow title="压力分析" openRequestKey="first">{content}</FloatingWindow></>);
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
rerender(<><button>回放控制</button><FloatingWindow title="压力分析" openRequestKey="second">{content}</FloatingWindow></>);
expect(screen.getByRole("dialog", { name: "压力分析" })).toBeVisible();
expect(screen.getByRole("button", { name: "回放控制" })).toHaveFocus();
fireEvent.click(screen.getByRole("button", { name: "关闭窗口" }));
rerender(<><button>回放控制</button><FloatingWindow title="压力分析" openRequestKey="first">{content}</FloatingWindow></>);
expect(screen.getByRole("dialog", { name: "压力分析" })).toBeVisible();
});
it("retains manual opening, Escape dismissal and focus return", () => {
render(<FloatingWindow title="压力分析">{content}</FloatingWindow>);
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
const trigger = screen.getByRole("button", { name: "放大查看 压力分析" });
fireEvent.click(trigger);
const heading = screen.getByLabelText("窗口标题栏,可用方向键移动,Shift 加方向键调整大小");
expect(heading).toHaveFocus();
fireEvent.keyDown(heading, { key: "Escape" });
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
expect(trigger).toHaveFocus();
fireEvent.click(trigger);
expect(screen.getByRole("dialog", { name: "压力分析" })).toBeVisible();
});