…lines 1–34 unchanged (34 lines)
35});
36
37describe("SplashRoute", () => {
38 it("shows Splash while boot is not initialized", async () => {
39 useGlobalStore.setState(s => {
40 s.app.boot = "cold";
41 s.settings.onboardingComplete = false;
42 s.session.isActive = false;
43 });
44
45 const r = renderWithRouter("/");
46 await act(async () => {});
47
48 expect(screen.getByTestId("splash")).toBeInTheDocument();
49 expect(screen.getByTestId("loc")).toHaveTextContent("/");
50
51 r.unmount();
52 });
53
54 it("redirects to onboarding when not onboarded", async () => {
55 useGlobalStore.setState(s => {
56 s.app.boot = "booted";
57 s.settings.onboardingComplete = false;
58 });
59
60 const r = renderWithRouter("/");
61 await act(async () => {});
62
63 expect(screen.getByTestId("onboarding")).toBeInTheDocument();
64 expect(screen.getByTestId("loc")).toHaveTextContent("/onboarding");
65
66 r.unmount();
67 });
68
69 it("redirects to login when onboarded but session is not active", async () => {
70 useGlobalStore.setState(s => {
71 s.app.boot = "booted";
72 s.settings.onboardingComplete = true;
73 });
74
75 const r = renderWithRouter("/");
76 await act(async () => {});
77
78 expect(screen.getByTestId("login")).toBeInTheDocument();
79 expect(screen.getByTestId("loc")).toHaveTextContent("/login");
80
81 r.unmount();
82 });
83
84 it("shows splash when active but app not initialized", async () => {
85 useGlobalStore.setState(s => {
86 s.app.boot = "booting";
87 s.settings.onboardingComplete = true;
88 s.session.isActive = true;
89 // missing providers
90 });
91
92 const r = renderWithRouter("/");
93 await act(async () => {});
…lines 94–98 unchanged (5 lines)
99 });
100
101 it("redirects to browser when active and app initialized", async () => {
102 useGlobalStore.setState(s => {
103 s.app.boot = "booted";
104 // prevent onboarding
105 s.settings.onboardingComplete = true;
106 // prevent login
107 s.session.isActive = true;
108 s.preferences.country = "CA";
109 });
110
111 const r = renderWithRouter("/");
…lines 112–115 unchanged (4 lines)
116 r.unmount();
117 });
118
119 it("reacts when app initialization flips", async () => {
120 useGlobalStore.setState(s => {
121 s.app.boot = "cold";
122 s.settings.onboardingComplete = true;
123 });
124
125 const r = renderWithRouter("/");
126 await act(async () => {});
127
128 expect(screen.getByTestId("splash")).toBeInTheDocument();
…lines 129–144 unchanged (16 lines)