From 3aead99c4ddd20a68efc2bca7b2f4dafa417628c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Sun, 22 Oct 2023 00:45:12 +0200 Subject: [PATCH] Ported move API error test --- .../move-api-error.spec.ts | 47 +++++++++++++++++++ __tests__/frontend/move-api-error.cy.ts | 30 ------------ 2 files changed, 47 insertions(+), 30 deletions(-) create mode 100644 __tests__/frontend-playwright/move-api-error.spec.ts delete mode 100644 __tests__/frontend/move-api-error.cy.ts diff --git a/__tests__/frontend-playwright/move-api-error.spec.ts b/__tests__/frontend-playwright/move-api-error.spec.ts new file mode 100644 index 00000000..561512cb --- /dev/null +++ b/__tests__/frontend-playwright/move-api-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: "DriveAPIError" }, + }; + }); +}); + +test("works with an API 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("Confirmation", { exact: true })).toBeVisible(); + await expect( + page.getByText("An error occurred", { exact: true }), + ).toBeVisible(); + await expect( + page.getByText("An error occurred in Google Drive"), + ).toBeVisible(); +}); diff --git a/__tests__/frontend/move-api-error.cy.ts b/__tests__/frontend/move-api-error.cy.ts deleted file mode 100644 index aa46f2ba..00000000 --- a/__tests__/frontend/move-api-error.cy.ts +++ /dev/null @@ -1,30 +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: "DriveAPIError" }); - }, 100); - }, -}); - -it("works with an API 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("Confirmation"); - cy.contains("An error occurred").should("be.visible"); - cy.contains("An error occurred in Google Drive").should("be.visible"); -});