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

test("renders the public library and import workflow without mobile overflow", async ({ page }) => {
  await page.goto("/");
  await expect(page.getByRole("heading", { name: "我的书架" })).toBeVisible();
  await expect(page.getByRole("note")).toContainText("这是公开书架");
  await expect(page.getByRole("navigation", { name: "主要导航" })).toBeVisible();
  const uploadLink = page.getByRole("link", { name: "上传", exact: true });
  await expect(uploadLink).toBeVisible();
  await expect.poll(() => page.evaluate(() => document.documentElement.scrollWidth - window.innerWidth)).toBeLessThanOrEqual(1);

  await uploadLink.click();
  await expect(page.getByRole("heading", { name: "上传电子书" })).toBeVisible();
  await expect(page.getByText("支持 EPUB、文字型 PDF 和扫描版 PDF，最大 200 MB。")).toBeVisible();
  await expect.poll(() => page.evaluate(() => document.documentElement.scrollWidth - window.innerWidth)).toBeLessThanOrEqual(1);
});
