/** * Server-admin login helper (Fase 13.5.2). * * Ana is pre-seeded into `public.server_admins` by `supabase/seed.sql`. This * helper is a thin sugar over `loginAs(page, USERS.ana)` that ALSO waits for * `$isServerAdmin` to flip true (which only happens once the root layout's * `refreshServerAdminFlag()` resolves). Tests that rely on the sidebar admin * entry being rendered need this; tests that hit /admin/* directly do not * (the layout's effect handles the wait). * * We don't expose a non-Ana admin promotion path here — the integration suite * already covers `grant_server_admin` end-to-end. If a test needs a different * admin it should call grant_server_admin from a privileged-client setup step * and rely on the next token refresh; we have no such test today. */ import type { Page } from '@playwright/test'; import { USERS } from './users.js'; import { loginAs } from './login.js'; export async function loginAsAdmin(page: Page): Promise { await loginAs(page, USERS.ana); // `refreshServerAdminFlag()` is fire-and-forget inside the auth callback // and the sidebar tile keys off the resulting store. Wait until the // rendered tile (or its data-testid) actually appears so any subsequent // click is deterministic. await page.waitForSelector('[data-testid="sidebar-admin-link"]', { timeout: 10_000 }); }