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

test('demo registration flow reaches mock appointment success', async ({ page }) => {
  await page.goto('/');

  const input = page.getByPlaceholder('继续输入症状、科室、医生或时间...');
  await input.click();
  await input.fill('我头疼三天，还有点恶心，想挂号');
  const sendBtn = page.getByRole('button', { name: '发送' });
  await expect(sendBtn).toBeEnabled();
  await sendBtn.click();

  await expect(page.getByText('推荐科室')).toBeVisible();
  await page.getByRole('button', { name: '选择神经内科' }).click();

  await expect(page.getByText('选择医生')).toBeVisible();
  await page.getByRole('button', { name: /选择李明/ }).click();

  await expect(page.getByText('选择时间')).toBeVisible();
  await page.getByRole('button', { name: /09:30/ }).click();

  await expect(page.getByText('确认挂号信息')).toBeVisible();
  await page.getByRole('button', { name: '确认挂号' }).click();

  await expect(page.getByText('联调演示 / Mock 支付')).toBeVisible();
  await page.getByRole('button', { name: '模拟支付完成' }).click();

  await expect(page.getByText('挂号成功')).toBeVisible();
  await expect(page.getByText('A023')).toBeVisible();
  await expect(page.getByText('联调演示', { exact: true })).toBeVisible();
});
