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

test("Keep both preserves imported theme CSS", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("Theme demo");
  await t3.open("/settings/appearance");
  const theme = { version: 1, name: "Nyx", appearance: "light", colors: { canvas: "#f4f1ff", accent: "#6d5ae6" } };
  await screen.getByRole("button", "Add theme", { exact: true }).tap();
  await screen.getByRole("textbox", "Theme JSON").fill(JSON.stringify(theme));
  await screen.getByRole("button", "Add theme", { exact: true }).tap();
  await screen.getByRole("button", "Add theme", { exact: true }).tap();
  await screen.getByRole("textbox", "Theme JSON").fill(JSON.stringify({ ...theme, css: "[data-settings-page-scroll] { outline: 8px solid #ff2d95; outline-offset: -8px; }" }));
  await screen.getByRole("button", "Add theme", { exact: true }).tap();
  await screen.getByRole("button", "Keep both", { exact: true }).tap();
  await screen.getByRole("button", "Use light mode", { exact: true }).tap();
  await screen.getByRole("button", /^Use Nyx \(1\) theme/).tap();
  await screen.getByText("Nyx (1) added", { exact: true }).waitFor({ state: "hidden" });
  await app.screenshot("nyx-copy-selected");
  await expect.poll(() => browser.evaluate(() => getComputedStyle(document.querySelector("[data-settings-page-scroll]")!).outline)).toBe("rgb(255, 45, 149) solid 8px");
});
