Skip to content

Commit

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

test("works with non-empty destination folder and 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: [] },
},
];
window._endpointStubs.move = [
{
status: "success",
delay: 500,
value: { status: "error", type: "notEmpty" },
},
{
status: "success",
delay: 500,
value: { status: "error", type: "notEmpty" },
},
{
status: "success",
value: { status: "success", response: { errors: [] } },
},
];
});

await expect(
page.getByText("Shared drive mover", { 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 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("Destination not empty", { exact: true }),
).toBeVisible();
await expect(
page.getByRole("button").filter({ hasText: "No" }),
).toBeFocused();
await page.keyboard.press("Enter");
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 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("Destination not empty", { exact: true }),
).toBeVisible();
await page.keyboard.press("Tab");
await expect(
page.getByRole("button").filter({ hasText: "Yes" }),
).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(3);
expect(moveCalls[0]).toStrictEqual(["root", "root", true, true, false]);
expect(moveCalls[1]).toStrictEqual(["root", "root", true, true, false]);
expect(moveCalls[2]).toStrictEqual(["root", "root", true, true, true]);
});

0 comments on commit cb46e7d

Please sign in to comment.