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

test("modified Enter preserves the stashed prompt", WEB, async ({ t3, app, screen, browser }) => {
  await t3.project("Prompt stash demo");
  await t3.open();
  const composer = screen.getByRole("textbox");
  await composer.fill("Keep this prompt");
  await composer.press("ControlOrMeta+s");
  await composer.fill("Unsent draft");
  const stash = screen.getByRole("button", /Stashed prompts: 1/);
  await stash.tap();
  await browser.keyboard.press("Shift+Enter");
  await app.screenshot("shift-enter-with-stash-open");
  await expect(stash).toBeVisible();
  await expect(composer).not.toContainText("Keep this prompt");
  await stash.tap();
  await browser.keyboard.press("Alt+Enter");
  await app.screenshot("alt-enter-with-stash-open");
  await expect(stash).toBeVisible();
  await expect(composer).not.toContainText("Keep this prompt");
  await stash.tap();
  await browser.keyboard.press("Enter");
  await app.screenshot("plain-enter-restores-stash");
  await expect(composer).toContainText("Keep this prompt");
  await expect(stash).not.toBeVisible();
});
