import AxeBuilder from '@axe-core/playwright'; import { expect, test } from '@playwright/test'; const enabled = Boolean(process.env.PULSE_E2E_REAL_BASE_URL); test('persisted capacity history produces one qualified explainable forecast', async ({ page }) => { test.skip(!enabled, 'Requires an isolated real Pulse stack.'); expect((await page.request.get('/auth/test-login')).ok()).toBeTruthy(); const response = await page.request.get('/api/v1/forecasts'); expect(response.ok()).toBeTruthy(); const snapshot = await response.json() as { qualifiedCount: number; items: Array<{ entityId: string; dataPoints: number; confidence: string; projectedAt?: string }> }; expect(snapshot.qualifiedCount).toBe(1); expect(snapshot.items[0]).toMatchObject({ dataPoints: 3, confidence: 'medium' }); expect(snapshot.items[0].projectedAt).toBeTruthy(); await page.goto('/capacity'); await expect(page.getByText(/1 gekwalificeerde prognoses/)).toBeVisible(); await expect(page.getByRole('heading', { name: 'Media forecast' })).toBeVisible(); await expect(page.getByText('Mediane dagelijkse groei', { exact: true })).toBeVisible(); await expect(page.getByText('Gemiddelde betrouwbaarheid')).toBeVisible(); await expect(page.getByText('42 dagen', { exact: false })).toBeVisible(); await expect(page.getByText('0 B / 0 B')).toHaveCount(0); expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth + 1)).toBe(true); const axe = await new AxeBuilder({ page }).analyze(); expect(axe.violations.filter((item) => item.impact === 'serious' || item.impact === 'critical')).toEqual([]); });