From ef40cc0f3b1b3013046820b84e8482f1c6a29533 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sun, 7 Dec 2025 17:44:14 +0900
Subject: feat(client): add deck list page with empty state and list view
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Implement HomePage to display user's decks fetched from the API.
Includes loading state, error handling with retry, and empty state
messaging. Also adds comprehensive tests for the deck list page.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---
 src/client/App.test.tsx | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

(limited to 'src/client/App.test.tsx')

diff --git a/src/client/App.test.tsx b/src/client/App.test.tsx
index 516cbeb..bdc281a 100644
--- a/src/client/App.test.tsx
+++ b/src/client/App.test.tsx
@@ -15,6 +15,14 @@ vi.mock("./api/client", () => ({
 		logout: vi.fn(),
 		isAuthenticated: vi.fn(),
 		getTokens: vi.fn(),
+		getAuthHeader: vi.fn(),
+		rpc: {
+			api: {
+				decks: {
+					$get: vi.fn(),
+				},
+			},
+		},
 	},
 	ApiClientError: class ApiClientError extends Error {
 		constructor(
@@ -28,6 +36,12 @@ vi.mock("./api/client", () => ({
 	},
 }));
 
+// Helper to create mock responses compatible with Hono's ClientResponse
+// biome-ignore lint/suspicious/noExplicitAny: Test helper needs flexible typing
+function mockResponse(data: { ok: boolean; status?: number; json: () => Promise<any> }) {
+	return data as unknown as Awaited<ReturnType<typeof apiClient.rpc.api.decks.$get>>;
+}
+
 function renderWithRouter(path: string) {
 	const { hook } = memoryLocation({ path, static: true });
 	return render(
@@ -58,12 +72,21 @@ describe("App routing", () => {
 				refreshToken: "refresh-token",
 			});
 			vi.mocked(apiClient.isAuthenticated).mockReturnValue(true);
+			vi.mocked(apiClient.getAuthHeader).mockReturnValue({
+				Authorization: "Bearer access-token",
+			});
+			vi.mocked(apiClient.rpc.api.decks.$get).mockResolvedValue(
+				mockResponse({
+					ok: true,
+					json: async () => ({ decks: [] }),
+				}),
+			);
 		});
 
 		it("renders home page at /", () => {
 			renderWithRouter("/");
 			expect(screen.getByRole("heading", { name: "Kioku" })).toBeDefined();
-			expect(screen.getByText("Spaced repetition learning app")).toBeDefined();
+			expect(screen.getByRole("heading", { name: "Your Decks" })).toBeDefined();
 		});
 	});
 
-- 
cgit v1.2.3-70-g09d2

