Skip to content

Commit

Permalink
Added keyboard navigation test for configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Feb 8, 2024
1 parent 9fdfdc1 commit 97bc9bc
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions __tests__/frontend/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,83 @@ test("works with merge configuration", async ({ page }) => {
expect(moveCalls).toHaveLength(1);
expect(moveCalls[0]).toStrictEqual(["root", "root", true, false, false]);
});

test("works with keyboard configuration", 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: [] },
},
];
window._endpointStubs.move = [
{
status: "success",
value: { status: "success", response: { errors: [] } },
},
];
});

await expect(
page.getByText("Shared drive mover", { exact: true }),
).toBeVisible();
await page.keyboard.press("Tab");
await expect(page.getByLabel("Copy comments")).toBeFocused();
await page.keyboard.press("Space");
await page.keyboard.press("Tab");
await expect(page.getByLabel("Merge folders")).toBeFocused();
await page.keyboard.press("Space");
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Continue" }),
).toBeFocused();
await page.keyboard.press("Enter");
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 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(
'contents of the folder "My Drive" into the folder "My Drive"',
),
).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", false, false, false]);
});

0 comments on commit 97bc9bc

Please sign in to comment.