Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions frontend/src/App.keyboard-a11y.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,31 @@ describe("bounty card keyboard navigation", () => {
expect(await axe(container)).toHaveNoViolations();
});
});

describe("jump-to-search keyboard shortcut", () => {
it("focuses the search input when / is pressed outside a text field", async () => {
const user = userEvent.setup();
await renderBoard();

const searchInput = screen.getByPlaceholderText("Search by repo, title, or label...");
expect(searchInput).not.toHaveFocus();

await user.keyboard("/");

expect(searchInput).toHaveFocus();
});

it("does not trigger the shortcut while typing inside a text input", async () => {
const user = userEvent.setup();
await renderBoard();

const searchInput = screen.getByPlaceholderText("Search by repo, title, or label...");
searchInput.focus();

await user.keyboard("/");

// The "/" should be typed into the input, not re-trigger the shortcut.
expect(searchInput).toHaveValue("/");
expect(searchInput).toHaveFocus();
});
});
Loading