From a2569837aa07ef48f27884fc2869b5be47087a4e Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 6 Dec 2025 18:36:10 +0900 Subject: feat(client): implement Register page with form validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add functional registration form with: - Username and password fields with confirm password - Client-side validation (password match, minimum length) - Error display for API failures - Redirect to home when already authenticated - Loading state during submission 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/client/App.test.tsx | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/client/App.test.tsx') diff --git a/src/client/App.test.tsx b/src/client/App.test.tsx index cd448bf..4a7af14 100644 --- a/src/client/App.test.tsx +++ b/src/client/App.test.tsx @@ -2,22 +2,53 @@ * @vitest-environment jsdom */ import { cleanup, render, screen } from "@testing-library/react"; -import { afterEach, describe, expect, it } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { Router } from "wouter"; import { memoryLocation } from "wouter/memory-location"; +import { apiClient } from "./api/client"; import { App } from "./App"; +import { AuthProvider } from "./stores"; + +vi.mock("./api/client", () => ({ + apiClient: { + login: vi.fn(), + register: vi.fn(), + logout: vi.fn(), + isAuthenticated: vi.fn(), + getTokens: vi.fn(), + }, + ApiClientError: class ApiClientError extends Error { + constructor( + message: string, + public status: number, + public code?: string, + ) { + super(message); + this.name = "ApiClientError"; + } + }, +})); function renderWithRouter(path: string) { const { hook } = memoryLocation({ path, static: true }); return render( - + + + , ); } +beforeEach(() => { + vi.clearAllMocks(); + vi.mocked(apiClient.getTokens).mockReturnValue(null); + vi.mocked(apiClient.isAuthenticated).mockReturnValue(false); +}); + afterEach(() => { cleanup(); + vi.restoreAllMocks(); }); describe("App routing", () => { -- cgit v1.2.3-70-g09d2