diff --git a/__tests__/frontend-playwright/move-repeat-after-timeout.spec.ts b/__tests__/frontend-playwright/move-repeat-after-timeout.spec.ts new file mode 100644 index 00000000..2b1a11c2 --- /dev/null +++ b/__tests__/frontend-playwright/move-repeat-after-timeout.spec.ts @@ -0,0 +1,60 @@ +import { expect, test } from "@playwright/test"; + +import { calls, setup } from "../test-utils-playwright/stub-endpoints"; + +test.beforeEach(async ({ page }) => { + await page.goto("/"); + await setup(page); + + await page.evaluate(() => { + const e = new Error(); + e.name = "ScriptError"; + window._endpointStubs.listSharedDrives = [ + { + status: "success", + value: { status: "success", response: [] }, + }, + { + status: "success", + value: { status: "success", response: [] }, + }, + ]; + window._endpointStubs.move = [ + { + status: "failure", + value: e, + }, + { + status: "failure", + value: e, + }, + { + status: "success", + value: { status: "success", response: { errors: [] } }, + }, + ]; + }); +}); + +test("works with an unhandled move error", async ({ page }) => { + await expect( + page.getByText("Shared drive mover", { exact: true }), + ).toBeVisible(); + await page.getByText("Continue").click(); + await page.getByText("My Drive").click(); + await page.getByText("Continue").click(); + await page.getByText("My Drive").click(); + await page.getByText("Continue").click(); + await expect( + page.getByText( + 'contents of the folder "My Drive" into the folder "My Drive"', + ), + ).toBeVisible(); + await page.getByText("Move", { exact: true }).click(); + await expect(page.getByText("Done!", { exact: true })).toBeVisible(); + await expect(page.getByText("Successfully moved")).toBeVisible(); + expect(calls.move).toHaveLength(3); + expect(calls.move[0]).toStrictEqual(["root", "root", true, true, false]); + expect(calls.move[1]).toStrictEqual(["root", "root", true, true, false]); + expect(calls.move[1]).toStrictEqual(["root", "root", true, true, false]); +}); diff --git a/__tests__/frontend/move-repeat-after-timeout.cy.ts b/__tests__/frontend/move-repeat-after-timeout.cy.ts deleted file mode 100644 index 288cc115..00000000 --- a/__tests__/frontend/move-repeat-after-timeout.cy.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { stubEndpoints } from "../test-utils/stubEndpoints"; - -let attempt = 0; - -const stubs = stubEndpoints({ - listFolders: (successHandler) => { - successHandler({ status: "success", response: [] }); - }, - listSharedDrives: (successHandler) => { - successHandler({ status: "success", response: [] }); - }, - move: (successHandler, failureHandler) => { - setTimeout(() => { - if (attempt < 2) { - const e = new Error(); - e.name = "ScriptError"; - failureHandler(e); - } else { - successHandler({ status: "success", response: { errors: [] } }); - } - attempt += 1; - }, 100); - }, -}); - -it("works with an unhandled move error", () => { - cy.visit("http://localhost:8080"); - cy.contains("Shared drive mover"); - cy.contains("Continue").click(); - cy.contains("My Drive").click(); - cy.contains("Continue").click(); - cy.contains("My Drive").click(); - cy.contains("Continue").click(); - cy.contains('contents of the folder "My Drive" into the folder "My Drive"'); - cy.contains("Move").click(); - cy.contains("Done!"); - cy.contains("Successfully moved").then(() => { - expect(stubs.move).to.have.been.calledOnceWith( - "root", - "root", - true, - true, - false, - ); - }); -});