// `session.me` returns the caller's resolved identity — the proof the auth loop // threads the Subject through to handlers, and the value the frontend's SSR gate // reads to decide redirect-to-login vs render. `makeTestContext({ subject })` // sets `ctx.request.subject` to exactly what the AuthMiddleware would resolve at // runtime, so the executor is fully runnable with no cookie, no session store, // no running server. Run with `voltro test` (vitest). import { describe, it, expect } from 'vitest' import { makeTestContext } from '@voltro/testing' import '../database/schema' // registers actors / tenants import me from '../actions/me.action.server' describe('session.me', () => { it('reflects a signed-in user Subject', async () => { const ctx = makeTestContext({ subject: { type: 'user', id: 'user_1', tenantId: 'acme' }, }) const identity = await me({}, ctx) expect(identity.type).toBe('user') expect(identity.id).toBe('user_1') expect(identity.tenantId).toBe('acme') }) it('returns an anonymous identity with null id/tenant when no session is present', async () => { const ctx = makeTestContext() const identity = await me({}, ctx) expect(identity.type).toBe('anonymous') expect(identity.id).toBeNull() expect(identity.tenantId).toBeNull() }) })