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

test("PageUp and PageDown retain their internal capitals in the command palette", WEB, async ({ t3, app, screen, browser }) => {
  const project = await t3.project("Shortcut demo");
  const thread = await t3.thread({ project, title: "Shortcut labels", messages: ["Hello"] });
  await t3.open("/settings/keybindings");
  await screen.getByRole("button", "Edit shortcut for Theme: Select:", { exact: false }).tap();
  await browser.keyboard.press("Control+Shift+PageUp");
  await screen.getByRole("button", "Save", { exact: true }).tap();
  await screen.getByRole("button", "Edit shortcut for Appearance: Cycle:", { exact: false }).tap();
  await browser.keyboard.press("Control+Shift+PageDown");
  await screen.getByRole("button", "Save", { exact: true }).tap();
  await t3.open(thread);
  await screen.getByText("first fixture turn complete", { exact: false }).tap();
  await browser.keyboard.press("Control+k");
  await screen.getByRole("dialog", "Command palette").getByRole("combobox").fill("Change");
  await screen.getByText("Searching messages…", { exact: true }).waitFor({ state: "hidden" });
  await app.screenshot("page-key-labels");
  await expect(screen.getByRole("option", "Change theme", { exact: false })).toContainText("Ctrl+Shift+PageUp");
  await expect(screen.getByRole("option", "Change appearance", { exact: false })).toContainText("Ctrl+Shift+PageDown");
});
