From 6aca0ceb69a5b1172908a2ed081a563110688e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Sun, 22 Oct 2023 00:26:16 +0200 Subject: [PATCH] Ported configuration test --- __tests__/frontend-playwright/basic.spec.ts | 4 +- .../frontend-playwright/configuration.spec.ts | 67 +++++++++++++++++++ __tests__/frontend/configuration.cy.ts | 61 ----------------- 3 files changed, 69 insertions(+), 63 deletions(-) create mode 100644 __tests__/frontend-playwright/configuration.spec.ts delete mode 100644 __tests__/frontend/configuration.cy.ts diff --git a/__tests__/frontend-playwright/basic.spec.ts b/__tests__/frontend-playwright/basic.spec.ts index ba6aae6d..e1dc1fe1 100644 --- a/__tests__/frontend-playwright/basic.spec.ts +++ b/__tests__/frontend-playwright/basic.spec.ts @@ -5,9 +5,7 @@ import { calls, setup } from "../test-utils-playwright/stub-endpoints"; test.beforeEach(async ({ page }) => { await page.goto("/"); await setup(page); -}); -test("works with basic configuration", async ({ page }) => { await page.evaluate(() => { window._endpointStubs.listFolders = { status: "success", @@ -22,7 +20,9 @@ test("works with basic configuration", async ({ page }) => { value: { status: "success", response: { errors: [] } }, }; }); +}); +test("works with basic configuration", async ({ page }) => { await expect( page.getByText("Shared drive mover", { exact: true }), ).toBeVisible(); diff --git a/__tests__/frontend-playwright/configuration.spec.ts b/__tests__/frontend-playwright/configuration.spec.ts new file mode 100644 index 00000000..e5bb1c8c --- /dev/null +++ b/__tests__/frontend-playwright/configuration.spec.ts @@ -0,0 +1,67 @@ +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(() => { + 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: "success", response: { errors: [] } }, + }; + }); +}); + +test("works with copy configuration", async ({ page }) => { + await expect( + page.getByText("Shared drive mover", { exact: true }), + ).toBeVisible(); + await page.getByText("Copy comments").click(); + 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(1); + expect(calls.move[0]).toStrictEqual(["root", "root", false, true, false]); +}); + +test("works with merge configuration", async ({ page }) => { + await expect( + page.getByText("Shared drive mover", { exact: true }), + ).toBeVisible(); + await page.getByText("Merge folders").click(); + 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(1); + expect(calls.move[0]).toStrictEqual(["root", "root", true, false, false]); +}); diff --git a/__tests__/frontend/configuration.cy.ts b/__tests__/frontend/configuration.cy.ts deleted file mode 100644 index eb4b5e36..00000000 --- a/__tests__/frontend/configuration.cy.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { stubEndpoints } from "../test-utils/stubEndpoints"; - -const stubs = stubEndpoints({ - listFolders: (successHandler) => { - successHandler({ status: "success", response: [] }); - }, - listSharedDrives: (successHandler) => { - successHandler({ status: "success", response: [] }); - }, - move: (successHandler) => { - setTimeout(() => { - successHandler({ status: "success", response: { errors: [] } }); - }, 100); - }, -}); - -it("works with copy configuration", () => { - cy.visit("http://localhost:8080"); - cy.contains("Shared drive mover"); - cy.contains("Copy comments").click(); - 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", - false, - true, - false, - ); - }); -}); - -it("works with merge configuration", () => { - cy.visit("http://localhost:8080"); - cy.contains("Shared drive mover"); - cy.contains("Copy comments").click(); - 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", - false, - true, - false, - ); - }); -});