Files
fixture-tools/tests/components/app.test.tsx
T
2026-09-01 13:03:32 +02:00

38 lines
1.5 KiB
TypeScript

import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, it } from "vitest";
import { Workbench } from "../../src/components/Workbench";
describe("Fixture workbench", () => {
it("generates records and exposes intentional invalid cases", async () => {
const user = userEvent.setup();
render(<Workbench />);
expect(
screen.getByRole("heading", { name: "Fixture Tools" }),
).toBeInTheDocument();
const invalid = screen.getByLabelText("Intentional invalids (%)");
await user.clear(invalid);
await user.type(invalid, "100");
await user.click(screen.getByRole("button", { name: "Generate fixtures" }));
await user.click(screen.getByRole("button", { name: /Invalid cases/u }));
expect(
screen.getAllByText(/required|unique|foreignKey/u).length,
).toBeGreaterThan(0);
});
it("retains the active model after malformed input", async () => {
const user = userEvent.setup();
render(<Workbench />);
await user.selectOptions(
screen.getByLabelText("Source kind"),
"json-schema",
);
const source = screen.getByLabelText("Fixture model source");
await user.clear(source);
await user.type(source, "{{");
await user.click(screen.getByRole("button", { name: "Import model" }));
expect(screen.getByRole("alert")).toHaveTextContent(/retained/u);
expect(screen.getByLabelText("Data table")).toHaveValue("users");
});
});