Skip to content

Commit

Permalink
Add shortcut tests
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Jul 22, 2024
1 parent b16446e commit 0841378
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions playwright/components/Dropdown/Dropdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,25 @@ test.describe("Dropdown", () => {
await page.getByRole("combobox").click();
await expect(page).toHaveScreenshot({ fullPage: true });
});

test("should to use keyboard shortcut", async ({ page }) => {
await page.goto(`iframe.html?viewMode=story&id=dropdown--default`, {
waitUntil: "networkidle",
});

await page.getByRole("combobox").focus();
await page.keyboard.press("ArrowDown");

await expect(page).toHaveScreenshot({ fullPage: true });

await page.keyboard.press("End");
await expect(page.getByRole("option", { name: "Option 2" })).toBeFocused();

await page.keyboard.press("Home");
await expect(page.getByRole("option", { name: "Option 1" })).toBeFocused();

await page.keyboard.press("Enter");
await expect(page.getByRole("combobox")).toHaveText("Option 1");
await expect(page).toHaveScreenshot({ fullPage: true });
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0841378

Please sign in to comment.