import { test, expect } from '@playwright/test'; import { RoleAuthHelper } from '../../helpers/helpers'; test.describe('Hospital Admin Role', () => { test.describe.configure({ mode: 'parallel' }); test('login succeeds and goes to dashboard (no hospital select)', async ({ page }) => { const auth = new RoleAuthHelper(page); await auth.login('hospital_admin'); expect(page.url()).not.toContain('login'); expect(page.url()).not.toContain('select-hospital'); }); test('cannot access config dashboard (PX Admin only)', async ({ page }) => { const auth = new RoleAuthHelper(page); await auth.login('hospital_admin'); await page.goto('/config/'); await page.waitForLoadState('domcontentloaded'); const blocked = page.url().includes('command-center') || page.url().includes('analytics') || page.url().toContain('login'); expect(blocked).toBeTruthy(); }); test('can access complaints list', async ({ page }) => { const auth = new RoleAuthHelper(page); await auth.login('hospital_admin'); const response = await page.goto('/complaints/'); expect(response?.status()).toBeLessThan(400); expect(page.url()).not.toContain('login'); }); test('can access surveys page', async ({ page }) => { const auth = new RoleAuthHelper(page); await auth.login('hospital_admin'); const response = await page.goto('/surveys/templates/'); expect(response?.status()).toBeLessThan(400); expect(page.url()).not.toContain('login'); }); test('can access observations page', async ({ page }) => { const auth = new RoleAuthHelper(page); await auth.login('hospital_admin'); const response = await page.goto('/observations/'); expect(response?.status()).toBeLessThan(400); expect(page.url()).not.toContain('login'); }); test('can access organizations page', async ({ page }) => { const auth = new RoleAuthHelper(page); await auth.login('hospital_admin'); await page.goto('/organizations/'); await page.waitForLoadState('domcontentloaded'); expect(page.url()).not.toContain('login'); }); test('cannot access config SLA page', async ({ page }) => { const auth = new RoleAuthHelper(page); await auth.login('hospital_admin'); const response = await page.goto('/config/sla/'); const blocked = page.url().includes('command-center') || page.url().includes('analytics') || page.url().toContain('login'); expect(blocked).toBeTruthy(); }); test('can access dashboard command center', async ({ page }) => { const auth = new RoleAuthHelper(page); await auth.login('hospital_admin'); const response = await page.goto('/'); expect(response?.status()).toBeLessThan(400); expect(page.url()).not.toContain('login'); }); });