import { test, expect } from "@playwright/test";
import { HealthScorePage } from "../pages/health-score.page";

test.describe("获客路径烟雾测试", () => {
  test("未登录用户访问健康分页面，输入品牌名后看到报告", async ({ page }) => {
    const healthScorePage = new HealthScorePage(page);

    await healthScorePage.goto();

    await expect(healthScorePage.brandInput).toBeVisible();
    await expect(healthScorePage.checkButton).toBeVisible();

    await healthScorePage.checkBrand("华为");

    await expect(page.locator("text=核心维度评分")).toBeVisible({ timeout: 30000 });

    await expect(page.locator("text=/\\d+/")).toBeVisible();

    await expect(page.getByRole("button", { name: /注册/ })).toBeVisible();
  });

  test("健康分页面支持URL参数预填品牌名", async ({ page }) => {
    await page.goto("/health-score?brand=小米");
    await page.waitForLoadState("domcontentloaded");

    const brandInput = page.locator('input[placeholder*="品牌"]');
    await expect(brandInput).toHaveValue("小米");
  });
});
