Skip to content

Commit

Permalink
Added keyboard navigation test for navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Feb 9, 2024
1 parent cb46e7d commit 8165d3f
Showing 1 changed file with 157 additions and 1 deletion.
158 changes: 157 additions & 1 deletion __tests__/frontend/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, test } from "playwright-test-coverage";

import { setup } from "../test-utils/stub-endpoints";

test("works with basic configuration", async ({ page }) => {
test("works with mouse navigation", async ({ page }) => {
await page.goto("/");
const getCalls = await setup(page);

Expand Down Expand Up @@ -90,3 +90,159 @@ test("works with basic configuration", async ({ page }) => {
expect(moveCalls).toHaveLength(1);
expect(moveCalls[0]).toStrictEqual(["root", "root", true, true, false]);
});

test("works with keyboard navigation", async ({ page }) => {
await page.goto("/");
const getCalls = await setup(page);

await page.evaluate(() => {
window._endpointStubs.listSharedDrives = [
{
status: "success",
value: { status: "success", response: [] },
},
{
status: "success",
value: { status: "success", response: [] },
},
{
status: "success",
value: { status: "success", response: [] },
},
{
status: "success",
value: { status: "success", response: [] },
},
{
status: "success",
value: { status: "success", response: [] },
},
{
status: "success",
value: { status: "success", response: [] },
},
];
window._endpointStubs.move = [
{
status: "success",
value: { status: "success", response: { errors: [] } },
},
];
});

await expect(
page.getByText("Shared drive mover", { exact: true }),
).toBeVisible();
await expect(page.getByText("Introduction", { exact: true })).toBeVisible();
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Continue" }),
).toBeFocused();
await page.keyboard.press("Enter");
await expect(
page.getByText("Source folder selection", { exact: true }),
).toBeVisible();
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("option").filter({ hasText: "My Drive" }),
).toBeFocused();
await page.keyboard.press("Enter");
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Continue" }),
).toBeFocused();
await page.keyboard.press("Enter");
await expect(
page.getByText("Destination folder selection", { exact: true }),
).toBeVisible();
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("option").filter({ hasText: "My Drive" }),
).toBeFocused();
await page.keyboard.press("Enter");
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Continue" }),
).toBeFocused();
await page.keyboard.press("Enter");
await expect(page.getByText("Confirmation", { exact: true })).toBeVisible();
await expect(
page.getByText(
'contents of the folder "My Drive" into the folder "My Drive"',
),
).toBeVisible();
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Back" }),
).toBeFocused();
await page.keyboard.press("Enter");
await expect(
page.getByText("Destination folder selection", { exact: true }),
).toBeVisible();
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Back" }),
).toBeFocused();
await page.keyboard.press("Enter");
await expect(
page.getByText("Source folder selection", { exact: true }),
).toBeVisible();
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Back" }),
).toBeFocused();
await page.keyboard.press("Enter");
await expect(page.getByText("Introduction", { exact: true })).toBeVisible();
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Continue" }),
).toBeFocused();
await page.keyboard.press("Enter");
await expect(
page.getByText("Source folder selection", { exact: true }),
).toBeVisible();
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Continue" }),
).toBeFocused();
await page.keyboard.press("Enter");
await expect(
page.getByText("Destination folder selection", { exact: true }),
).toBeVisible();
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Continue" }),
).toBeFocused();
await page.keyboard.press("Enter");
await expect(page.getByText("Confirmation", { exact: true })).toBeVisible();
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Move" }),
).toBeFocused();
await page.keyboard.press("Enter");
await expect(page.getByText("Done!", { exact: true })).toBeVisible();
await expect(page.getByText("Successfully moved")).toBeVisible();

const moveCalls = getCalls("move");
expect(moveCalls).toHaveLength(1);
expect(moveCalls[0]).toStrictEqual(["root", "root", true, true, false]);
});

0 comments on commit 8165d3f

Please sign in to comment.