import { expect, test } from '@playwright/test';
import { captureEvidence } from './helpers/evidence';

const baseUrl = (process.env.E2E_BASE_URL ?? 'https://www.taxbaik.com').replace(/\/$/, '');

test.describe('public smoke', () => {
  test('@smoke loads the home page and key public pages with SEO basics', async ({ page }) => {
    await page.goto(baseUrl);
    await expect(page).toHaveTitle(/백원숙 세무회계/);
    await expect(page).not.toHaveTitle(/관리자/);
    await expect(page.getByRole('heading', { name: /세금과 자산|백원숙 세무회계/ })).toBeVisible();
    // 상담 신청 버튼: 첫 번째 "상담 신청하기" 버튼만 선택 (strict mode 위반 방지)
    await expect(page.getByRole('link', { name: '상담 신청하기' })).toBeVisible();
    await expect(page.locator('meta[name="description"]')).toHaveAttribute('content', /사업자 기장|부동산|종합소득세/);
    await expect(page.getByRole('heading', { name: /상담 과정/ })).toBeVisible();

    await page.goto(`${baseUrl}/blog`);
    await expect(page).toHaveTitle(/블로그/);
    await expect(page.getByRole('heading', { name: /세무 블로그/ })).toBeVisible();

    await page.goto(`${baseUrl}/contact`);
    await expect(page).toHaveTitle(/상담 신청/);
    await expect(page.getByRole('heading', { name: /상담 신청/ })).toBeVisible();
    await expect(page.getByRole('link', { name: /뒤로가기/ })).toBeVisible();
    await expect(page.getByRole('button', { name: /상담신청/ })).toBeVisible();

    await captureEvidence(page, test.info(), 'public-smoke');
  });
});
