From db5ea3816a2b937ccb1503513a0e39c719a2e055 Mon Sep 17 00:00:00 2001 From: Rachel Stiansen Date: Tue, 15 Sep 2026 11:07:41 +0200 Subject: [PATCH] test: cover complete library user flow (#32) --- src/App.test.tsx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/App.test.tsx b/src/App.test.tsx index f536b16..de5f00a 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -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(); + + 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(); await screen.findByRole("heading", { level: 2, name: "A Wizard of Earthsea" });