Files
radicle-explorer/tests/e2e/hotkeys.spec.ts
T
2023-02-13 11:28:42 +01:00

37 lines
1.1 KiB
TypeScript

import { test, expect } from "@tests/support/fixtures.js";
const searchPlaceholder = "Search a name…";
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();
}
});