feat: expand sudoku analysis and interoperability
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user