Lines 241-281javascript
241 " const app = await makeHandler();",
242 " const res = await testRequest(app.handle, '/dashboard');",
243 " if (res.status >= 500) {",
244 " t.skip('app deps not ready (run `npm run db:generate` + `npm run db:migrate`)');",
247 " // The dashboard middleware calls auth(); with no session cookie it 302s to",
248 " // /login. This needs no DB row, only a cookie read, so it is always real",
249 " // once the modules import.",
250 " assert.equal(res.status, 302, 'unauthenticated dashboard is gated');",
251 " assert.equal(res.headers.get('location'), '/login');",
254 "test('signup -> login -> dashboard renders for the authenticated user', async (t) => {",
255 " const app = await makeHandler();",
256 " // Probe readiness: a 5xx on the dashboard means deps/DB are not set up.",
257 " const probe = await testRequest(app.handle, '/dashboard');",
258 " if (probe.status >= 500) { t.skip('app deps not ready; run `npm run db:generate` + `npm run db:migrate`'); return; }",
260 " const email = `harness+${Date.now()}@example.com`;",
261 " const password = 'password123';",
263 " // Real signup through the page server action (the no-JS form write-path).",
264 " let canSignup = true;",
266 " const signupRes = await testRequest(app.handle, '/signup', {",
268 " headers: { 'content-type': 'application/x-www-form-urlencoded' },",
269 " body: new URLSearchParams({ name: 'Harness', email, password }).toString(),",
271 " // Success auto-logs-in and 302s to /dashboard (carrying the session",
272 " // cookie); a 422 means validation failed. Either way the action ran.",
273 " assert.ok([302, 422].includes(signupRes.status), 'signup action ran');",
274 " if (signupRes.status === 302) assert.equal(signupRes.headers.get('location'), '/dashboard', 'signup lands on the dashboard');",
275 " if (signupRes.status !== 302) canSignup = false;",
277 " // No migrated DB table -> the action throws. Skip the DB-backed assertions.",
278 " canSignup = false;",
280 " if (!canSignup) { t.skip('no migrated DB; run `npm run db:migrate` to enable the full flow'); return; }",