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

test("PR find shortcut respects the Save PR view dialog", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("shortcut-demo");
  await t3.open("/pull-requests?involvement=all&state=open");
  await screen.getByRole("button", "Saved pull request views", { exact: true }).click();
  await screen.getByRole("menuitem", "Save current view…", { exact: true }).click();
  await screen.getByRole("textbox", "View name", { exact: true }).click();
  await browser.keyboard.press("Control+f");
  await browser.keyboard.type("hello");
  await app.screenshot("dialog-after-find-and-typing");
  await expect(screen.getByRole("textbox", "View name", { exact: true })).toHaveValue("hello");
  await screen.getByRole("button", "Cancel", { exact: true }).click();
  await screen.getByRole("dialog").waitFor({ state: "hidden" });
  await browser.keyboard.press("Control+f");
  await browser.keyboard.type("outside");
  await app.screenshot("outside-dialog-find-control");
  await expect(screen.getByRole("searchbox", "Search pull requests", { exact: true })).toHaveValue("outside");
});
