import { test, expect, type Page } from '@playwright/test';

// 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 Command Center - UI', () => {
  test.beforeEach(async ({ page }) => {
    await page.goto('/epd/cortex');
    await expect(input(page)).toBeVisible({ timeout: 10_000 });
  });

  test('laadt de command center interface', async ({ page }) => {
    await expect(input(page)).toBeVisible();
    await expect(page.locator('text=Welkom bij Cortex Assistent').first()).toBeVisible();
  });

  test('chat input accepteert tekst', async ({ page }) => {
    await input(page).fill('test invoer');
    await expect(input(page)).toHaveValue('test invoer');
  });

  test('keyboard shortcut ⌘K focust de input', async ({ page }) => {
    await page.click('body');
    await page.keyboard.press('Meta+k');
    await expect(input(page)).toBeFocused();
  });

  test('escape wist de input', async ({ page }) => {
    await input(page).fill('iets typen');
    await input(page).press('Escape');
    await expect(input(page)).toHaveValue('');
  });

  test('toont voorbeeldcommandos in de empty state', async ({ page }) => {
    await expect(page.locator('text=Dagnotitie maken').first()).toBeVisible();
    await expect(page.locator('text=Patiënt zoeken').first()).toBeVisible();
    await expect(page.locator('text=Overdracht maken').first()).toBeVisible();
  });
});
