import { test as setup, expect } from '@playwright/test' import { CREDENTIALS_HINT, STAFF_NAME, STAFF_PASSWORD, hasStaffCredentials, login } from './helpers/admin-app' const AUTH_STATE_PATH = 'tests/.auth/staff.json' /** * Logs into the admin panel once and persists the session (JWT lives in * localStorage) so every spec runs already authenticated. */ setup('authenticate staff user', async ({ page }) => { if (!hasStaffCredentials()) { setup.skip(true, CREDENTIALS_HINT) } await login(page, STAFF_NAME, STAFF_PASSWORD) // Sidebar entry (exact) — the dashboard body also has "Products …" tiles. await expect(page.getByRole('button', { name: 'Products', exact: true })).toBeVisible() await page.context().storageState({ path: AUTH_STATE_PATH }) })