/// <reference lib="dom" />
import { expect } from "e2e";
import { test, WEB } from "./t3.ts";

test("A keybinding recorder captures the dictation shortcut", WEB, async ({ t3, app, browser, screen }) => {
  const project = await t3.project("shortcut-demo");
  const thread = await t3.thread({ project, title: "Record a shortcut", messages: ["Start"] });
  await browser.setViewport({ width: 1440, height: 1000 });
  await t3.open(thread);
  await screen.getByRole("button", "Start voice input", { exact: true }).waitFor();
  await screen.getByRole("button", "Add project script", { exact: true }).tap();
  const recorder = browser.locator("#script-keybinding");
  await recorder.press("Control+Shift+K");
  await app.screenshot("control-shortcut-recorded");
  await recorder.press("Control+Shift+D");
  await app.screenshot("dictation-shortcut-result");
  const value = await browser.evaluate(() => document.querySelector<HTMLInputElement>("#script-keybinding")?.value ?? null);
  expect(value, "The recorder captures dictation instead of opening Voice settings").toBe("mod+shift+d");
});
