import { test, expect } from "@playwright/test";
import { mockApi, 登录 } from "../测试夹具";

test.describe("账本：列表与新建", () => {
  test("01-显示个人账本和共享账本，并标出当前账本", async ({ page }) => {
    await mockApi(page);
    await 登录(page);
    await page.getByRole("link", { name: /账本/ }).click();
    await expect(page.getByRole("region", { name: "全部账本" })).toContainText("个人账本");
    await expect(page.getByRole("region", { name: "全部账本" })).toContainText("家庭账本");
  });

  test("02-新增账本后进入新账本并保留默认币种", async ({ page }) => {
    await mockApi(page);
    await 登录(page);
    await page.getByRole("link", { name: /账本/ }).click();
    await page.getByRole("button", { name: "新增账本" }).click();
    await page.getByLabel("账本名称").fill("旅行计划");
    await page.getByRole("button", { name: "创建账本" }).click();
    await expect(page).toHaveURL(/\/$/);
    await expect(page.getByText("旅行计划")).toBeVisible();
  });
});
