import { expect } from "e2e";
import { test, WEB } from "./t3.ts";

test("Sidebar cards keep their bottom line at larger interface font sizes", WEB, async ({ t3, app, screen, browser }) => {
  const project = await t3.project("Sidebar demo");
  const thread = await t3.thread({ project, title: "Review sidebar layout", model: "default", messages: ["go"] });
  await t3.open(thread);
  await screen.getByRole("button", /^Review sidebar layout,/).waitFor();
  const height = () => browser.evaluate(() => {
    const card = document.querySelector<HTMLElement>('[style*="--sidebar-card-height"]');
    return card?.getBoundingClientRect().height ?? 0;
  });
  await t3.open("/settings/appearance");
  await screen.getByRole("combobox", "Interface font size").tap();
  await screen.getByRole("option", "20 px", { exact: true }).tap();
  await t3.open(thread);
  await screen.getByRole("button", /^Review sidebar layout,/).waitFor();
  await app.screenshot("interface-font-20");
  const largeHeight = await height();
  await t3.open("/settings/appearance");
  await screen.getByRole("combobox", "Interface font size").tap();
  await screen.getByRole("option", "16 px", { exact: true }).tap();
  await t3.open(thread);
  await screen.getByRole("button", /^Review sidebar layout,/).waitFor();
  await app.screenshot("interface-font-16");
  const defaultHeight = await height();
  expect(defaultHeight).toBe(78);
  expect(largeHeight).toBeGreaterThanOrEqual(97);
});
