功能修改
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import operationControlsSource from "./OperationControls.tsx?raw";
|
||||
import { ConfirmDialog, ManagementDialog } from "./OperationControls";
|
||||
|
||||
describe("shared operation dialogs", () => {
|
||||
it("renders labelled, busy-aware confirmation semantics", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<ConfirmDialog
|
||||
open
|
||||
title="确认停用"
|
||||
description="会保留审计记录"
|
||||
confirmLabel="停用"
|
||||
busy
|
||||
onConfirm={() => undefined}
|
||||
onCancel={() => undefined}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(html).toContain('role="dialog"');
|
||||
expect(html).toContain('aria-labelledby=');
|
||||
expect(html).toContain('aria-describedby=');
|
||||
expect(html).toContain('aria-busy="true"');
|
||||
expect(operationControlsSource).toContain('event.key === "Escape"');
|
||||
expect(operationControlsSource).toContain("previousFocus?.focus()");
|
||||
});
|
||||
|
||||
it("keeps management forms in a dialog surface", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<ManagementDialog open title="编辑资源" onClose={() => undefined}>
|
||||
<p>内容</p>
|
||||
</ManagementDialog>
|
||||
);
|
||||
|
||||
expect(html).toContain('role="dialog"');
|
||||
expect(html).toContain("编辑资源");
|
||||
expect(html).toContain('aria-modal="true"');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user