'use strict'; // Every main page loads for a signed-in admin with no page errors, console // errors or failed requests (checked by the fixture). const { test, expect } = require('./fixtures'); const PAGES = [ ['/', 'dashboard'], ['/ticket/100000001', 'markdown ticket'], ['/ticket/100000002', 'alert ticket'], ['/ticket/100000003', 'plain-text ticket'], ['/ticket/create', 'create ticket'], ['/admin/templates', 'templates admin'], ['/admin/workflow', 'workflow admin'], ['/admin/audit-log', 'audit log'], ['/admin/api-keys', 'API keys'], ]; for (const [path, name] of PAGES) { test(`${name} (${path}) loads cleanly`, async ({ page }) => { const res = await page.goto(path); expect(res.status()).toBe(200); await page.waitForLoadState('networkidle'); await expect(page.locator('body')).not.toContainText('Fatal error'); await expect(page.locator('body')).not.toContainText('Warning:'); }); } test('the dashboard lists the seeded tickets', async ({ page }) => { await page.goto('/'); await expect(page.getByRole('heading', { level: 1 })).toContainText('TICKETS'); for (const id of ['100000001', '100000002', '100000003']) { await expect(page.locator(`a[href*="/ticket/${id}"]`).first()).toBeVisible(); } }); test('requests without the SSO headers are not let in', async ({ baseURL }) => { // Plain fetch: Playwright's own request contexts pick up the fixture's SSO // headers. const res = await fetch(new URL('/', baseURL), { redirect: 'manual' }); expect(res.status, 'anonymous request to the dashboard').toBe(401); });