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

test("Enter restores hovered stash selection while another restore button has focus", WEB, async ({ t3, app, browser, screen }) => {
  await t3.project("demo");
  await t3.open("/");
  const composer = screen.getByRole("textbox");
  await composer.tap();
  await browser.keyboard.type("Alpha prompt 7353");
  await browser.keyboard.press("Control+s");
  await browser.keyboard.type("Beta prompt 7353");
  await browser.keyboard.press("Control+s");
  await screen.getByRole("button", "Stashed prompts: 2. Open stash.", { exact: true }).click();
  await screen.getByRole("button", "Close stash", { exact: true }).focus();
  await browser.keyboard.press("Tab");
  await browser.keyboard.press("ArrowDown");
  await screen.getByRole("button", "Restore stashed prompt: Beta prompt 7353", { exact: true }).hover();
  await app.screenshot("highlight-beta-focus-alpha");
  await browser.keyboard.press("Enter");
  await app.screenshot("restored-prompt");
  await expect(composer).toHaveText("Beta prompt 7353");
});
