import { expect, test } from '@playwright/test' // Note: These tests run as team_admin user (from auth.setup.ts). // The seeded user is `teamadmin@resolutionflow.example.com` with role team_admin. // Some admin features may require super_admin — tests gracefully handle access denial. test.describe('admin panel smoke tests', () => { test('can access the admin dashboard', async ({ page }) => { await page.goto('/admin') // If user has admin access, dashboard should load // If not (team_admin vs super_admin), may redirect const hasAccess = await page.getByText(/Admin|Dashboard|Users|Overview/i).isVisible().catch(() => false) if (hasAccess) { await expect(page.getByText(/Admin|Dashboard/i)).toBeVisible() } else { // Redirected away — team_admin may not have super_admin access await expect(page).not.toHaveURL(/\/admin/) } }) test('can view user management page if super_admin', async ({ page }) => { await page.goto('/admin/users') const hasAccess = await page.getByText(/User Management|Users/i).isVisible().catch(() => false) if (hasAccess) { await expect(page.getByText(/User Management|Users/i)).toBeVisible() // Should show a list of users await expect(page.locator('table, [class*="card"]').first()).toBeVisible({ timeout: 5000 }) } }) test('can view platform settings page', async ({ page }) => { await page.goto('/admin/settings') const hasAccess = await page.getByText(/Settings|Platform/i).isVisible().catch(() => false) if (hasAccess) { await expect(page.getByText(/Settings|Platform/i)).toBeVisible() } }) })