import { test, expect, type Page } from '@playwright/test'; import { mockDagnotitieChat, mockZoekenChat, mockOverdrachtChat, mockOnbekendChat } from '../fixtures/ai-mocks'; // De pagina heeft twee textareas (desktop + mobiel layout). .first() pakt de zichtbare desktop-versie. const input = (page: Page) => page.getByPlaceholder('Typ of spreek wat je wilt doen...').first(); test.describe('Cortex - Demo flows', () => { test.beforeEach(async ({ page }) => { await page.goto('/epd/cortex'); await expect(input(page)).toBeVisible({ timeout: 10_000 }); }); test('dagnotitie flow: bericht → AI response → artifact verschijnt', async ({ page }) => { await mockDagnotitieChat(page, 'Jan de Vries'); await input(page).fill('notitie jan de vries voelt zich goed vandaag'); await input(page).press('Enter'); await expect(page.locator('text=notitie jan de vries voelt zich goed vandaag').first()).toBeVisible({ timeout: 5_000 }); await expect(page.locator('text=Genoteerd.').first()).toBeVisible({ timeout: 10_000 }); }); test('dagnotitie flow: input is leeg na verzenden', async ({ page }) => { await mockDagnotitieChat(page); await input(page).fill('notitie jan medicatie gegeven'); await input(page).press('Enter'); await expect(input(page)).toHaveValue('', { timeout: 3_000 }); }); test('zoeken flow: bericht → zoek-artifact verschijnt', async ({ page }) => { await mockZoekenChat(page, 'Marie'); await input(page).fill('zoek marie'); await input(page).press('Enter'); await expect(page.locator('text=zoek marie').first()).toBeVisible({ timeout: 5_000 }); await expect(page.locator('text=Even kijken.').first()).toBeVisible({ timeout: 10_000 }); }); test('overdracht flow: bericht → overdracht-artifact', async ({ page }) => { await mockOverdrachtChat(page); await input(page).fill('overdracht'); await input(page).press('Enter'); await expect(page.locator('text=overdracht').first()).toBeVisible({ timeout: 5_000 }); await expect(page.locator('text=Overdracht klaar.').first()).toBeVisible({ timeout: 10_000 }); }); test('onbekende intent: AI vraagt om verduidelijking', async ({ page }) => { await mockOnbekendChat(page); await input(page).fill('xyz'); await input(page).press('Enter'); await expect(page.locator('text=snap niet helemaal wat je bedoelt').first()).toBeVisible({ timeout: 10_000 }); }); test('meerdere berichten: chat history groeit', async ({ page }) => { await mockDagnotitieChat(page); await input(page).fill('notitie jan medicatie gegeven'); await input(page).press('Enter'); await expect(page.locator('text=Genoteerd.').first()).toBeVisible({ timeout: 10_000 }); await mockDagnotitieChat(page, 'Marie'); await input(page).fill('notitie marie slaapt slecht'); await input(page).press('Enter'); await expect(page.locator('text=notitie jan medicatie gegeven').first()).toBeVisible(); await expect(page.locator('text=notitie marie slaapt slecht').first()).toBeVisible(); }); });