From bfba95b1ed3482a22b3221fdc1772aec3227479b Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Sat, 5 Sep 2026 07:52:42 +0200 Subject: [PATCH] Verify compact Today flow and explicit history access --- src/App.test.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/App.test.tsx b/src/App.test.tsx index f61b88b..ae151b2 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -191,6 +191,10 @@ describe("homepage", () => { f.setTime("2026-09-04T12:00:00Z"); await f.json(`/habits/${habit.id}`, "PATCH", { method: "count", target: 10, unit: "pages" }); await render("/"); + expect(container.querySelector(".ds-calendar")).toBeNull(); + expect(buttonNamed("View history for Reading").getAttribute("aria-expanded")).toBe("false"); + await act(async () => buttonNamed("View history for Reading").click()); + expect(buttonNamed("Hide history for Reading").getAttribute("aria-expanded")).toBe("true"); await act(async () => container.querySelector('[aria-label^="2026-09-03:"]')!.click()); expect(buttonNamed("Edit selected check-in").closest(".ds-date-inspector")?.textContent).toContain("September 3, 2026"); await act(async () => buttonNamed("Edit selected check-in").click()); @@ -207,7 +211,7 @@ describe("homepage", () => { expect(container.querySelector("h1")?.textContent).toBe("Small steps.Lasting rhythm."); expect(fetchMock.mock.calls.map(call => call[0])).toEqual(["/api/me"]); await act(async () => buttonNamed("Increase glasses of water").click()); - expect(container.querySelector(".ds-counter output")?.textContent).toBe("4 / 8"); + expect(container.querySelector('[aria-label="Total glasses of water"]')?.value).toBe("4"); expect(fetchMock).toHaveBeenCalledTimes(1); }); @@ -274,7 +278,11 @@ describe("homepage", () => { expect(container.querySelector(".ds-welcome-progress")?.textContent).toContain("0 / 3"); await act(async () => buttonNamed("Increase Water").click()); expect(container.querySelector(".ds-welcome-progress")?.textContent).toContain("1 / 3"); + expect(container.querySelector(`#history-${water.id} .ds-date-inspector`)).toBeNull(); + await act(async () => buttonNamed("View history for Water").click()); expect(container.querySelector(`#history-${water.id} .ds-date-inspector`)?.textContent).toContain("8 of 8 glasses"); + expect(container.textContent).not.toContain("Sunday walk"); + await act(async () => buttonNamed("All habits · 4").click()); const checkbox = (name: string) => [...container.querySelectorAll('input[type="checkbox"]')].find(input => (input.getAttribute("aria-label") || input.closest("label")?.textContent) === name)!; expect(checkbox("Sunday walk done").disabled).toBe(true); await act(async () => checkbox("Reading done").click()); @@ -359,6 +367,8 @@ describe("homepage", () => { const f = connectAccount(); const habit = await f.json("/habits", "POST", { name: "Sunday", method: "tasks", schedule: { type: "weekdays", days: [0] }, tasks: [{ name: "Walk" }] }, 201); await render("/"); + expect(container.querySelector(".ds-habit-chart")).toBeNull(); + await act(async () => buttonNamed("All habits · 1").click()); expect(container.textContent).toContain("Not scheduled today"); expect(container.querySelector('.ds-editable-task input[type="checkbox"]')?.disabled).toBe(true); await act(async () => buttonNamed("Edit task Walk").click()); @@ -410,6 +420,7 @@ describe("homepage", () => { if (schedule.type === "weekly") await selectValue(form.querySelectorAll("select")[1]!, String(schedule.weekday)); await act(async () => form.dispatchEvent(new dom.Event("submit", { bubbles: true, cancelable: true }) as unknown as Event)); expect((await f.json(`/habits/${habit.id}/tasks/${id}`)).schedule).toEqual(schedule); + if (schedule.type === "interval") expect(buttonNamed("All habits · 1").getAttribute("aria-pressed")).toBe("true"); expect(container.querySelector("form")).toBeNull(); await act(async () => buttonNamed("Edit task Walk").click()); const reopened = container.querySelector('form[aria-label="Edit task Walk"]')!; @@ -489,10 +500,10 @@ describe("homepage", () => { fetchMock.mockResolvedValueOnce(Response.json({ error: "Save unavailable" }, { status: 500 })); await act(async () => buttonNamed("Increase Water").click()); expect(container.querySelector('[role="alert"]')?.textContent).toContain("Save unavailable"); - expect(container.querySelector(".ds-counter output")?.textContent).toBe("0 / 8"); + expect(container.querySelector('[aria-label="Total Water"]')?.value).toBe("0"); expect(buttonNamed("Increase Water").disabled).toBe(false); await act(async () => buttonNamed("Increase Water").click()); - expect(container.querySelector(".ds-counter output")?.textContent).toBe("1 / 8"); + expect(container.querySelector('[aria-label="Total Water"]')?.value).toBe("1"); expect((await f.json("/today")).habits[0].value).toBe(1); }); }); @@ -660,7 +671,7 @@ describe("design system tabs", () => { await act(async () => panel().querySelector('[aria-label="Increase example count"]')!.click()); await clickTab("calendar-states"); await clickTab("components"); - expect(panel().querySelector("output")?.textContent).toBe("4 / 8"); + expect(panel().querySelector('[aria-label="Total example count"]')?.value).toBe("4"); const viewHabit = Array.from(panel().querySelectorAll("button")).find(button => button.textContent?.startsWith("View habit"))!; await act(async () => viewHabit.click()); expect(panel().id).toBe("ds-panel-calendar-states");