diff --git a/__tests__/frontend-playwright/move-folders-equal-error.spec.ts b/__tests__/frontend-playwright/move-folders-equal-error.spec.ts new file mode 100644 index 00000000..aed327f6 --- /dev/null +++ b/__tests__/frontend-playwright/move-folders-equal-error.spec.ts @@ -0,0 +1,47 @@ +import { expect, test } from "@playwright/test"; + +import { setup } from "../test-utils-playwright/stub-endpoints"; + +test.beforeEach(async ({ page }) => { + await page.goto("/"); + await setup(page); + + await page.evaluate(() => { + window._endpointStubs.listFolders = { + status: "success", + value: { status: "success", response: [] }, + }; + window._endpointStubs.listSharedDrives = { + status: "success", + value: { status: "success", response: [] }, + }; + window._endpointStubs.move = { + status: "success", + value: { status: "error", type: "sourceEqualsDestination" }, + }; + }); +}); + +test("works with source and destination folders being equal", 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("Confirmation")).toBeVisible(); + await expect(page.getByText("An error occurred")).toBeVisible(); + await expect( + page.getByText("The source and destination folders must be different"), + ).toBeVisible(); +}); diff --git a/__tests__/frontend/move-folders-equal-error.cy.ts b/__tests__/frontend/move-folders-equal-error.cy.ts deleted file mode 100644 index 4585d1a1..00000000 --- a/__tests__/frontend/move-folders-equal-error.cy.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { stubEndpoints } from "../test-utils/stubEndpoints"; - -stubEndpoints({ - listFolders: (successHandler) => { - successHandler({ status: "success", response: [] }); - }, - listSharedDrives: (successHandler) => { - successHandler({ status: "success", response: [] }); - }, - move: (successHandler) => { - setTimeout(() => { - successHandler({ status: "error", type: "sourceEqualsDestination" }); - }, 100); - }, -}); - -it("works with source and destination folders being equal", () => { - 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("Confirmation"); - cy.contains("An error occurred").should("be.visible"); - cy.contains("The source and destination folders must be different").should( - "be.visible", - ); -});