This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
74 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { test, expect, Page } from "@playwright/test" | ||
|
||
import { | ||
LanguageDirection, | ||
pathWithDir, | ||
setCookies, | ||
t, | ||
} from "~~/test/playwright/utils/navigation" | ||
|
||
import { keycodes } from "~/constants/key-codes" | ||
|
||
const isFilterButtonFocused = async (page: Page) => { | ||
return page.evaluate(() => document.activeElement?.id === "filter-button") | ||
} | ||
|
||
const walkToFilterButton = async (page: Page) => { | ||
while (!(await isFilterButtonFocused(page))) { | ||
await page.keyboard.press(keycodes.Tab) | ||
} | ||
} | ||
|
||
const firstFilterCheckbox = (page: Page, dir: LanguageDirection) => { | ||
return page | ||
.getByRole("region", { name: t("filters.filter-by", dir) }) | ||
.getByRole("checkbox") | ||
.first() | ||
} | ||
|
||
test.describe.configure({ mode: "parallel" }) | ||
|
||
for (const dir of ["ltr", "rtl"]) { | ||
test.describe(`search header keyboard accessibility test in ${dir}`, () => { | ||
test.beforeEach(async ({ page }) => { | ||
await setCookies(page.context(), { uiBreakpoint: "lg" }) | ||
/** | ||
* To simplify finding the last focusable element in the filters sidebar, | ||
* we use the image search page. After the removal of the "searchBy" filter, | ||
* the last element on the all media search page is the "license explanation" | ||
* button, not a checkbox. | ||
*/ | ||
await page.goto(pathWithDir("/search/image?q=birds", dir)) | ||
}) | ||
|
||
test("should move focus to the sidebar after header", async ({ page }) => { | ||
await walkToFilterButton(page) | ||
|
||
// Check that the filters sidebar is open | ||
expect( | ||
await page.locator("#filter-button").getAttribute("aria-expanded") | ||
).toBe("true") | ||
|
||
await page.keyboard.press(keycodes.Tab) | ||
|
||
await expect( | ||
firstFilterCheckbox(page, dir as LanguageDirection) | ||
).toBeFocused() | ||
}) | ||
|
||
test("should move focus to main after filters sidebar", async ({ | ||
page, | ||
}) => { | ||
await page.getByRole("checkbox").last().focus() | ||
|
||
await page.keyboard.press(keycodes.Tab) | ||
|
||
const href = await page.evaluate( | ||
() => (document.activeElement as HTMLAnchorElement | null)?.href | ||
) | ||
expect(href).toBeDefined() | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
test/storybook/visual-regression/v-filter-button-old.spec.ts
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-5.05 KB
.../v-filter-button-old.spec.ts-snapshots/filter-button-old-2-filters-md-linux.png
Binary file not shown.
Binary file removed
BIN
-3.83 KB
...ton-old.spec.ts-snapshots/filter-button-old-2-filters-not-scrolled-xs-linux.png
Binary file not shown.
Binary file removed
BIN
-5.07 KB
...r-button-old.spec.ts-snapshots/filter-button-old-2-filters-pressed-md-linux.png
Binary file not shown.
Binary file removed
BIN
-2.9 KB
...-button-old.spec.ts-snapshots/filter-button-old-2-filters-scrolled-xs-linux.png
Binary file not shown.
Binary file removed
BIN
-4.89 KB
...on/v-filter-button-old.spec.ts-snapshots/filter-button-old-at-rest-md-linux.png
Binary file not shown.
Binary file removed
BIN
-2.5 KB
...on-old.spec.ts-snapshots/filter-button-old-no-filters-not-scrolled-xs-linux.png
Binary file not shown.
Binary file removed
BIN
-2.5 KB
...button-old.spec.ts-snapshots/filter-button-old-no-filters-scrolled-xs-linux.png
Binary file not shown.
Binary file removed
BIN
-4.87 KB
...on/v-filter-button-old.spec.ts-snapshots/filter-button-old-pressed-md-linux.png
Binary file not shown.