Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,31 @@ describe("App", () => {
expect(localStorage.getItem("t19.favorites")).toBe(JSON.stringify([]));
});

it("supports the complete library user flow without unnecessary requests", async () => {
const user = userEvent.setup();
withProviders(<App />);

await screen.findByRole("heading", { name: "A Wizard of Earthsea" });

await user.selectOptions(screen.getByRole("combobox", { name: "Subject" }), "mystery");
await waitFor(() => expect(getSearchRequestCount()).toBe(2));

await user.selectOptions(screen.getByRole("combobox", { name: "Sort by" }), "newest");
expect(
await screen.findByRole("heading", { name: "The Left Hand of Darkness" }),
).toBeInTheDocument();

await user.selectOptions(screen.getByRole("combobox", { name: "Jump to book" }), "1");
expect(
await screen.findByRole("heading", { name: "A Wizard of Earthsea" }),
).toBeInTheDocument();

await user.click(screen.getByRole("button", { name: "Add A Wizard of Earthsea to favorites" }));

expect(localStorage.getItem("t19.favorites")).toBe(JSON.stringify(["/works/OL2"]));
expect(getSearchRequestCount()).toBe(2);
});

it("matches the snapshot", async () => {
const { container } = withProviders(<App />);
await screen.findByRole("heading", { level: 2, name: "A Wizard of Earthsea" });
Expand Down