Files
radicle-explorer/tests/e2e/hotkeys.spec.ts
T
2023-04-11 15:31:08 +02:00

37 lines
1.1 KiB
TypeScript

import { test, expect } from "@tests/support/fixtures.js";
const searchPlaceholder = "Search a RID…";
test("global hotkeys", async ({ page }) => {
await page.goto("/");
await page.locator("body").press(`/`);
await page.keyboard.type("searchquery");
// Keyboard hint shows up in the search bar.
{
await expect(page.getByText("⏎")).toBeVisible();
await expect(page.getByPlaceholder(searchPlaceholder)).toHaveValue(
"searchquery",
);
}
// Other hotkeys don't trigger while input is focussed.
{
await page.keyboard.type("?");
await expect(page.getByPlaceholder(searchPlaceholder)).toHaveValue(
"searchquery?",
);
await expect(page.getByText("Keyboard shortcuts")).not.toBeVisible();
}
// Hitting `Esc` defocuses the input.
{
await page.locator("body").press("Escape");
await expect(page.getByPlaceholder(searchPlaceholder)).toHaveValue(
"searchquery?",
);
await expect(page.getByText("⏎")).toBeVisible();
await expect(page.getByPlaceholder(searchPlaceholder)).not.toBeFocused();
}
});