658f6a5b8b
Deploy to route.crispygoat.com / deploy (push) Successful in 4m12s
Field users at /water were blocked because every server action called getSession() (Neon Auth) even though the field path is PIN-authenticated. A missing or expired platform session hung or rejected PIN submissions, so users without a platform login could never reach the water log entry screen. Centralize water-log auth in src/actions/water-log/auth.ts with three helpers — requireFieldSession, requireWaterAdminSession, and requireWaterAdminPermission — and migrate all server actions off the stray getSession() calls. Auth.ts deliberately does NOT import getSession; a static-source unit test enforces that. Changes: - src/actions/water-log/auth.ts (new): dedicated auth layer, no Neon Auth - src/actions/water-log/field.ts: -10 await getSession(), use helpers - src/actions/water-log/admin.ts: -18 await getSession(), use helpers - src/actions/water-log/settings.ts: -4 await getSession(), resilient to missing platform admin - 3x admin pages: update getWaterAdminSession import path - tests/unit/water-log-auth.test.ts (new): 17 tests incl. regression guard that auth.ts never imports getSession - tests/water-log.spec.ts: 3 E2E regression tests (no platform login) - vitest.config.ts: alias for deep @/db/schema/water-log path Rollback = revert this commit. No DB migration; no schema change. Existing rows/cookies unchanged.
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import react from "@vitejs/plugin-react";
|
|
import path from "node:path";
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: [
|
|
{ find: /^@\/(?!db)/, replacement: path.resolve(__dirname, "src") + "/" },
|
|
// Specific sub-paths must come before the general @/db catch-all.
|
|
{ find: "@/db/schema/water-log", replacement: path.resolve(__dirname, "db/schema/water-log.ts") },
|
|
{ find: "@/db/client", replacement: path.resolve(__dirname, "db/client.ts") },
|
|
{ find: "@/db/schema", replacement: path.resolve(__dirname, "db/schema/index.ts") },
|
|
{ find: "@/db", replacement: path.resolve(__dirname, "db") },
|
|
],
|
|
},
|
|
test: {
|
|
environment: "node",
|
|
include: [
|
|
"tests/unit/**/*.test.ts",
|
|
"tests/unit/**/*.test.tsx",
|
|
"src/lib/__tests__/**/*.test.ts",
|
|
"src/lib/__tests__/**/*.test.tsx",
|
|
"src/lib/offline/**/*.test.ts",
|
|
],
|
|
exclude: ["node_modules", ".next", "tests/e2e/**", "tests/login/**", "tests/smoke.spec.ts"],
|
|
// Supabase REST, Auth.js v5, and Next.js `cookies()` / `headers()` are
|
|
// stubbed in each test — keep the timeout generous.
|
|
testTimeout: 15_000,
|
|
},
|
|
});
|