From f8e4be9b36a16969ac53bd9ce12ce8064be10196 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 4 Jan 2026 17:43:59 +0900 Subject: refactor(client): migrate state management from React Context to Jotai MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace AuthProvider and SyncProvider with Jotai atoms for more granular state management and better performance. This migration: - Creates atoms for auth, sync, decks, cards, noteTypes, and study state - Uses atomFamily for parameterized state (e.g., cards by deckId) - Introduces StoreInitializer component for subscription initialization - Updates all components and pages to use useAtomValue/useSetAtom - Updates all tests to use Jotai Provider with createStore pattern 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/client/pages/LoginPage.test.tsx | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/client/pages/LoginPage.test.tsx') diff --git a/src/client/pages/LoginPage.test.tsx b/src/client/pages/LoginPage.test.tsx index a3efa8d..6ed4011 100644 --- a/src/client/pages/LoginPage.test.tsx +++ b/src/client/pages/LoginPage.test.tsx @@ -3,11 +3,11 @@ */ import { cleanup, render, screen, waitFor } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; +import { createStore, Provider } from "jotai"; 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 { AuthProvider } from "../stores"; +import { authLoadingAtom } from "../atoms"; import { LoginPage } from "./LoginPage"; vi.mock("../api/client", () => ({ @@ -30,14 +30,18 @@ vi.mock("../api/client", () => ({ }, })); +import { apiClient } from "../api/client"; + function renderWithProviders(path = "/login") { const { hook } = memoryLocation({ path }); + const store = createStore(); + store.set(authLoadingAtom, false); return render( - - + + - - , + + , ); } @@ -156,12 +160,15 @@ describe("LoginPage", () => { return [result[0], navigateSpy]; }; + const store = createStore(); + store.set(authLoadingAtom, false); + render( - - + + - - , + + , ); await waitFor(() => { -- cgit v1.2.3-70-g09d2