45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { SolveWorkspace } from "../../src/components/SolveWorkspace";
|
|
import type { ExactSolveResult } from "../../src/solver";
|
|
|
|
const limited: ExactSolveResult = {
|
|
solutions: [],
|
|
count: 0,
|
|
truncated: true,
|
|
limitReason: "timeout",
|
|
nodes: 100,
|
|
elapsedMs: 10_000,
|
|
};
|
|
|
|
describe("solve result reporting", () => {
|
|
it("does not report zero solutions at a safety limit as unsatisfiable", () => {
|
|
const props = {
|
|
size: 9,
|
|
busy: false,
|
|
onLogical: vi.fn(),
|
|
onExact: vi.fn(),
|
|
onApplyValues: vi.fn(),
|
|
onFocusCells: vi.fn(),
|
|
};
|
|
const { rerender } = render(<SolveWorkspace {...props} exact={limited} />);
|
|
|
|
expect(
|
|
screen.getByText(/solvability is not established/u),
|
|
).toBeInTheDocument();
|
|
expect(
|
|
screen.queryByText("No completion satisfies every supported rule."),
|
|
).not.toBeInTheDocument();
|
|
|
|
rerender(
|
|
<SolveWorkspace
|
|
{...props}
|
|
exact={{ ...limited, truncated: false, limitReason: undefined }}
|
|
/>,
|
|
);
|
|
expect(
|
|
screen.getByText("No completion satisfies every supported rule."),
|
|
).toBeInTheDocument();
|
|
});
|
|
});
|