44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { beforeAll, describe, expect, it, vi } from "vitest";
|
|
import { Workbench } from "../../src/components/Workbench";
|
|
|
|
beforeAll(() => {
|
|
Object.defineProperty(HTMLMediaElement.prototype, "canPlayType", {
|
|
configurable: true,
|
|
value: vi.fn(() => "maybe"),
|
|
});
|
|
});
|
|
|
|
describe("Device Workbench", () => {
|
|
it("shows passive evidence and a redacted report", async () => {
|
|
const user = userEvent.setup();
|
|
render(<Workbench />);
|
|
expect(
|
|
screen.getByRole("heading", {
|
|
name: "Inspect capabilities, not identity.",
|
|
}),
|
|
).toBeVisible();
|
|
expect(screen.getByLabelText("Redacted JSON report")).not.toHaveTextContent(
|
|
"userAgent",
|
|
);
|
|
await user.type(screen.getByLabelText("Filter capabilities"), "codec");
|
|
expect(screen.getByRole("heading", { name: "Codecs" })).toBeVisible();
|
|
expect(
|
|
screen.queryByRole("heading", { name: "Display" }),
|
|
).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("runs only the explicitly selected probe", async () => {
|
|
const user = userEvent.setup();
|
|
render(<Workbench />);
|
|
await user.click(
|
|
screen.getByRole("button", { name: "Read permission states" }),
|
|
);
|
|
expect(await screen.findByRole("status")).toHaveTextContent(
|
|
/Permissions API is unavailable|Permission states read/u,
|
|
);
|
|
expect(screen.getByText("1 run")).toBeVisible();
|
|
});
|
|
});
|