
 RUN  v4.1.9 /home/tyler/dev/routecomm

 ✓ src/lib/__tests__/design-tokens.test.ts (35 tests) 9ms
 ❯ tests/unit/reset-admin-password.test.ts (11 tests | 11 failed) 11ms
     × rejects unauthenticated callers 5ms
     × rejects non-platform-admin callers 1ms
     × rejects an empty email 0ms
     × looks up the user in neon_auth.user (not the legacy `users` table) 0ms
     × returns a clear error when no Neon Auth user matches the email 0ms
     × returns a server-generated temp password and flips must_change_password 0ms
     × falls back to the public reset-email endpoint when setUserPassword returns FORBIDDEN 0ms
     × falls back when setUserPassword returns UNAUTHORIZED 0ms
     × falls back when setUserPassword throws 0ms
     × does NOT fall back for USER_NOT_FOUND — it surfaces the error 1ms
     × propagates the public-endpoint error if BOTH paths fail 0ms
 ❯ tests/unit/create-admin-user.test.ts (10 tests | 10 failed) 12ms
     × rejects unauthenticated callers 5ms
     × rejects non-platform-admin callers 1ms
     × uses the privileged admin endpoint when it succeeds 1ms
     × falls back to /sign-up/email when the admin endpoint fails with FORBIDDEN 1ms
     × rejects with a clear error when the email is already in use 0ms
     × surfaces the fallback error if the public sign-up fails 0ms
     × returns an error explaining the orphaned Neon Auth user 0ms
     × still returns success when the welcome email fails 0ms
     × records the email error message when sendWelcomeEmail throws 0ms
     × creates a platform admin without inserting an admin_user_brands link 1ms
 ✓ tests/unit/water-log-reporting.test.ts (31 tests) 21ms
 ❯ tests/unit/send-password-reset-email.test.ts (8 tests | 8 failed) 11ms
     × rejects unauthenticated callers 5ms
     × rejects non-platform-admin callers 1ms
     × rejects an empty email without calling Neon Auth 1ms
     × trims and lowercases the email before calling Neon Auth 1ms
     × returns success when Neon Auth accepts the request 1ms
     × returns a clear error when Neon Auth returns a structured error 0ms
     × falls back to the error code if the message is missing 0ms
     × catches thrown exceptions and surfaces them as a string 0ms
 ✓ tests/unit/email-service.test.ts (5 tests) 23ms
 ✓ src/lib/__tests__/format-date.test.ts (6 tests) 26ms
stderr | tests/unit/sign-in-with-google.test.ts > signInWithGoogleAction > returns a structured error when Neon Auth rejects the request
[auth/google] signIn.social error: {
  code: 'PROVIDER_NOT_CONFIGURED',
  message: 'Google OAuth is not enabled'
}

stderr | tests/unit/sign-in-with-google.test.ts > signInWithGoogleAction > returns a structured error on unexpected exceptions
[auth/google] Unexpected error: Error: network down
    at /home/tyler/dev/routecomm/tests/unit/sign-in-with-google.test.ts:95:34
    at file:///home/tyler/dev/routecomm/node_modules/.pnpm/@vitest+runner@4.1.9/node_modules/@vitest/runner/dist/chunk-artifact.js:302:11
    at file:///home/tyler/dev/routecomm/node_modules/.pnpm/@vitest+runner@4.1.9/node_modules/@vitest/runner/dist/chunk-artifact.js:1903:26
    at file:///home/tyler/dev/routecomm/node_modules/.pnpm/@vitest+runner@4.1.9/node_modules/@vitest/runner/dist/chunk-artifact.js:2326:20
    at new Promise (<anonymous>)
    at runWithCancel (file:///home/tyler/dev/routecomm/node_modules/.pnpm/@vitest+runner@4.1.9/node_modules/@vitest/runner/dist/chunk-artifact.js:2323:10)
    at file:///home/tyler/dev/routecomm/node_modules/.pnpm/@vitest+runner@4.1.9/node_modules/@vitest/runner/dist/chunk-artifact.js:2305:20
    at new Promise (<anonymous>)
    at runWithTimeout (file:///home/tyler/dev/routecomm/node_modules/.pnpm/@vitest+runner@4.1.9/node_modules/@vitest/runner/dist/chunk-artifact.js:2272:10)
    at file:///home/tyler/dev/routecomm/node_modules/.pnpm/@vitest+runner@4.1.9/node_modules/@vitest/runner/dist/chunk-artifact.js:2955:64

stdout | tests/unit/auth-actions.test.ts > signOutAction > calls signOut and redirects to login
[auth/sign-out] Signing out

 ✓ tests/unit/sign-in-with-google.test.ts (6 tests) 8ms
 ✓ tests/unit/auth-actions.test.ts (1 test) 3ms
 ✓ src/lib/offline/queue.test.ts (8 tests) 18ms
 ✓ src/lib/offline/sync.test.ts (13 tests) 15ms
stderr | tests/unit/getAdminUser.test.ts > getAdminUser() > returns null when the user exists but has no admin_user_brands row
[admin-permissions] Database query failed: TypeError: membershipRows.map is not a function
    at /home/tyler/dev/routecomm/src/lib/admin-permissions.ts:99:34
    at processTicksAndRejections (node:internal/process/task_queues:104:5)

 ✓ tests/unit/getAdminUser.test.ts (11 tests) 8ms
 ✓ tests/unit/water-log-pin.test.ts (21 tests) 365ms
 ✓ tests/unit/passwords.test.ts (9 tests) 485ms

⎯⎯⎯⎯⎯⎯ Failed Tests 29 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  tests/unit/create-admin-user.test.ts > createAdminUser — authorization > rejects unauthenticated callers
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.createAdminUser src/actions/admin/users.ts:244:7
    242| ): Promise<CreateAdminUserResult> {
    243|
    244| await getSession();  // 1. Authorization: only platform admins can min…
       |       ^
    245|   const caller = await getAdminUser();
    246|   if (!caller) {
 ❯ tests/unit/create-admin-user.test.ts:135:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/29]⎯

 FAIL  tests/unit/create-admin-user.test.ts > createAdminUser — authorization > rejects non-platform-admin callers
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.createAdminUser src/actions/admin/users.ts:244:7
    242| ): Promise<CreateAdminUserResult> {
    243|
    244| await getSession();  // 1. Authorization: only platform admins can min…
       |       ^
    245|   const caller = await getAdminUser();
    246|   if (!caller) {
 ❯ tests/unit/create-admin-user.test.ts:144:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/29]⎯

 FAIL  tests/unit/create-admin-user.test.ts > createAdminUser — happy path via auth.admin.createUser > uses the privileged admin endpoint when it succeeds
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.createAdminUser src/actions/admin/users.ts:244:7
    242| ): Promise<CreateAdminUserResult> {
    243|
    244| await getSession();  // 1. Authorization: only platform admins can min…
       |       ^
    245|   const caller = await getAdminUser();
    246|   if (!caller) {
 ❯ tests/unit/create-admin-user.test.ts:194:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/29]⎯

 FAIL  tests/unit/create-admin-user.test.ts > createAdminUser — fallback to public sign-up > falls back to /sign-up/email when the admin endpoint fails with FORBIDDEN
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.createAdminUser src/actions/admin/users.ts:244:7
    242| ): Promise<CreateAdminUserResult> {
    243|
    244| await getSession();  // 1. Authorization: only platform admins can min…
       |       ^
    245|   const caller = await getAdminUser();
    246|   if (!caller) {
 ❯ tests/unit/create-admin-user.test.ts:253:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[4/29]⎯

 FAIL  tests/unit/create-admin-user.test.ts > createAdminUser — fallback to public sign-up > rejects with a clear error when the email is already in use
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.createAdminUser src/actions/admin/users.ts:244:7
    242| ): Promise<CreateAdminUserResult> {
    243|
    244| await getSession();  // 1. Authorization: only platform admins can min…
       |       ^
    245|   const caller = await getAdminUser();
    246|   if (!caller) {
 ❯ tests/unit/create-admin-user.test.ts:276:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[5/29]⎯

 FAIL  tests/unit/create-admin-user.test.ts > createAdminUser — fallback to public sign-up > surfaces the fallback error if the public sign-up fails
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.createAdminUser src/actions/admin/users.ts:244:7
    242| ): Promise<CreateAdminUserResult> {
    243|
    244| await getSession();  // 1. Authorization: only platform admins can min…
       |       ^
    245|   const caller = await getAdminUser();
    246|   if (!caller) {
 ❯ tests/unit/create-admin-user.test.ts:295:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[6/29]⎯

 FAIL  tests/unit/create-admin-user.test.ts > createAdminUser — DB failure after auth success > returns an error explaining the orphaned Neon Auth user
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.createAdminUser src/actions/admin/users.ts:244:7
    242| ): Promise<CreateAdminUserResult> {
    243|
    244| await getSession();  // 1. Authorization: only platform admins can min…
       |       ^
    245|   const caller = await getAdminUser();
    246|   if (!caller) {
 ❯ tests/unit/create-admin-user.test.ts:310:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[7/29]⎯

 FAIL  tests/unit/create-admin-user.test.ts > createAdminUser — email is best-effort > still returns success when the welcome email fails
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.createAdminUser src/actions/admin/users.ts:244:7
    242| ): Promise<CreateAdminUserResult> {
    243|
    244| await getSession();  // 1. Authorization: only platform admins can min…
       |       ^
    245|   const caller = await getAdminUser();
    246|   if (!caller) {
 ❯ tests/unit/create-admin-user.test.ts:355:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[8/29]⎯

 FAIL  tests/unit/create-admin-user.test.ts > createAdminUser — email is best-effort > records the email error message when sendWelcomeEmail throws
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.createAdminUser src/actions/admin/users.ts:244:7
    242| ): Promise<CreateAdminUserResult> {
    243|
    244| await getSession();  // 1. Authorization: only platform admins can min…
       |       ^
    245|   const caller = await getAdminUser();
    246|   if (!caller) {
 ❯ tests/unit/create-admin-user.test.ts:400:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[9/29]⎯

 FAIL  tests/unit/create-admin-user.test.ts > createAdminUser — no brand > creates a platform admin without inserting an admin_user_brands link
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.createAdminUser src/actions/admin/users.ts:244:7
    242| ): Promise<CreateAdminUserResult> {
    243|
    244| await getSession();  // 1. Authorization: only platform admins can min…
       |       ^
    245|   const caller = await getAdminUser();
    246|   if (!caller) {
 ❯ tests/unit/create-admin-user.test.ts:443:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[10/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — authorization > rejects unauthenticated callers
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:106:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[11/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — authorization > rejects non-platform-admin callers
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:116:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[12/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — input handling > rejects an empty email
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:127:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[13/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — input handling > looks up the user in neon_auth.user (not the legacy `users` table)
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:134:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[14/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — input handling > returns a clear error when no Neon Auth user matches the email
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:149:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[15/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — happy path via setUserPassword > returns a server-generated temp password and flips must_change_password
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:159:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[16/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — FORBIDDEN fallback to requestPasswordReset > falls back to the public reset-email endpoint when setUserPassword returns FORBIDDEN
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:188:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[17/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — FORBIDDEN fallback to requestPasswordReset > falls back when setUserPassword returns UNAUTHORIZED
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:207:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[18/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — FORBIDDEN fallback to requestPasswordReset > falls back when setUserPassword throws
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:215:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[19/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — FORBIDDEN fallback to requestPasswordReset > does NOT fall back for USER_NOT_FOUND — it surfaces the error
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:226:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[20/29]⎯

 FAIL  tests/unit/reset-admin-password.test.ts > resetAdminPassword — FORBIDDEN fallback to requestPasswordReset > propagates the public-endpoint error if BOTH paths fail
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.resetAdminPassword src/actions/admin/reset-admin.ts:40:7
     38| ): Promise<ResetAdminPasswordResult> {
     39|
     40| await getSession();  // 1. Authz check.
       |       ^
     41|   const me = await getAdminUser();
     42|   if (!me) {
 ❯ tests/unit/reset-admin-password.test.ts:242:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[21/29]⎯

 FAIL  tests/unit/send-password-reset-email.test.ts > sendPasswordResetEmail — authorization > rejects unauthenticated callers
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.sendPasswordResetEmail src/actions/admin/users.ts:592:7
    590| ): Promise<{ success: boolean; error: string | null }> {
    591|
    592| await getSession();  try {
       |       ^
    593|     // Authz: must be signed in as a platform_admin.
    594|     const me = await getAdminUser();
 ❯ tests/unit/send-password-reset-email.test.ts:83:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[22/29]⎯

 FAIL  tests/unit/send-password-reset-email.test.ts > sendPasswordResetEmail — authorization > rejects non-platform-admin callers
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.sendPasswordResetEmail src/actions/admin/users.ts:592:7
    590| ): Promise<{ success: boolean; error: string | null }> {
    591|
    592| await getSession();  try {
       |       ^
    593|     // Authz: must be signed in as a platform_admin.
    594|     const me = await getAdminUser();
 ❯ tests/unit/send-password-reset-email.test.ts:91:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[23/29]⎯

 FAIL  tests/unit/send-password-reset-email.test.ts > sendPasswordResetEmail — input handling > rejects an empty email without calling Neon Auth
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.sendPasswordResetEmail src/actions/admin/users.ts:592:7
    590| ): Promise<{ success: boolean; error: string | null }> {
    591|
    592| await getSession();  try {
       |       ^
    593|     // Authz: must be signed in as a platform_admin.
    594|     const me = await getAdminUser();
 ❯ tests/unit/send-password-reset-email.test.ts:100:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[24/29]⎯

 FAIL  tests/unit/send-password-reset-email.test.ts > sendPasswordResetEmail — input handling > trims and lowercases the email before calling Neon Auth
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.sendPasswordResetEmail src/actions/admin/users.ts:592:7
    590| ): Promise<{ success: boolean; error: string | null }> {
    591|
    592| await getSession();  try {
       |       ^
    593|     // Authz: must be signed in as a platform_admin.
    594|     const me = await getAdminUser();
 ❯ tests/unit/send-password-reset-email.test.ts:107:11

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[25/29]⎯

 FAIL  tests/unit/send-password-reset-email.test.ts > sendPasswordResetEmail — happy path > returns success when Neon Auth accepts the request
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.sendPasswordResetEmail src/actions/admin/users.ts:592:7
    590| ): Promise<{ success: boolean; error: string | null }> {
    591|
    592| await getSession();  try {
       |       ^
    593|     // Authz: must be signed in as a platform_admin.
    594|     const me = await getAdminUser();
 ❯ tests/unit/send-password-reset-email.test.ts:118:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[26/29]⎯

 FAIL  tests/unit/send-password-reset-email.test.ts > sendPasswordResetEmail — error propagation > returns a clear error when Neon Auth returns a structured error
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.sendPasswordResetEmail src/actions/admin/users.ts:592:7
    590| ): Promise<{ success: boolean; error: string | null }> {
    591|
    592| await getSession();  try {
       |       ^
    593|     // Authz: must be signed in as a platform_admin.
    594|     const me = await getAdminUser();
 ❯ tests/unit/send-password-reset-email.test.ts:130:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[27/29]⎯

 FAIL  tests/unit/send-password-reset-email.test.ts > sendPasswordResetEmail — error propagation > falls back to the error code if the message is missing
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.sendPasswordResetEmail src/actions/admin/users.ts:592:7
    590| ): Promise<{ success: boolean; error: string | null }> {
    591|
    592| await getSession();  try {
       |       ^
    593|     // Authz: must be signed in as a platform_admin.
    594|     const me = await getAdminUser();
 ❯ tests/unit/send-password-reset-email.test.ts:140:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[28/29]⎯

 FAIL  tests/unit/send-password-reset-email.test.ts > sendPasswordResetEmail — error propagation > catches thrown exceptions and surfaces them as a string
Error: [vitest] No "getSession" export is defined on the "@/lib/auth" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("@/lib/auth"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ Module.sendPasswordResetEmail src/actions/admin/users.ts:592:7
    590| ): Promise<{ success: boolean; error: string | null }> {
    591|
    592| await getSession();  try {
       |       ^
    593|     // Authz: must be signed in as a platform_admin.
    594|     const me = await getAdminUser();
 ❯ tests/unit/send-password-reset-email.test.ts:147:21

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[29/29]⎯


 Test Files  3 failed | 11 passed (14)
      Tests  29 failed | 146 passed (175)
   Start at  17:16:50
   Duration  755ms (transform 659ms, setup 0ms, import 1.45s, tests 1.01s, environment 495ms)

