109e74db41
Web UI rework. Shared-components slice (drift prevention): - Migrate SectionCard, SelectionRailCard, TabbedCard, MetricCard, DiskSpaceCard, HoverEditButton, DialogFooter, ConfirmDialog, LibraryOverview, NowPlaying, SessionActivityPanel off @mui - HoverEditButton: MUI IconButton + EditOutlined -> Button + lucide Pencil - Status mapping uses the success Badge variant (chart-2) for healthy - Exported APIs preserved so consuming pages still compile (no page edits) - 11 behavioral Vitest component tests added Gate: build + lint + test green.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
import { render, screen } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { ConfirmDialog } from "../ConfirmDialog";
|
|
|
|
describe("ConfirmDialog", () => {
|
|
it("renders the title and message and wires confirm/cancel", async () => {
|
|
const onCancel = vi.fn();
|
|
const onConfirm = vi.fn();
|
|
render(
|
|
<ConfirmDialog
|
|
open
|
|
title="Delete machine?"
|
|
message="This cannot be undone."
|
|
confirmLabel="Delete"
|
|
onCancel={onCancel}
|
|
onConfirm={onConfirm}
|
|
/>,
|
|
);
|
|
expect(screen.getByText("Delete machine?")).toBeInTheDocument();
|
|
expect(screen.getByText("This cannot be undone.")).toBeInTheDocument();
|
|
await userEvent.click(screen.getByRole("button", { name: "Delete" }));
|
|
expect(onConfirm).toHaveBeenCalledTimes(1);
|
|
await userEvent.click(screen.getByRole("button", { name: "Cancel" }));
|
|
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("renders nothing when closed", () => {
|
|
render(
|
|
<ConfirmDialog
|
|
open={false}
|
|
title="Hidden"
|
|
message="nope"
|
|
onCancel={() => {}}
|
|
onConfirm={() => {}}
|
|
/>,
|
|
);
|
|
expect(screen.queryByText("Hidden")).not.toBeInTheDocument();
|
|
});
|
|
});
|