From e79bbf2883e59a92d3802f16c2818eb415636e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Sun, 22 Oct 2023 18:21:10 +0200 Subject: [PATCH] Ported source selection API error test --- .../source-selection-api-error.spec.ts | 30 +++++++++++++++++++ .../frontend/source-selection-api-error.cy.ts | 17 ----------- 2 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 __tests__/frontend-playwright/source-selection-api-error.spec.ts delete mode 100644 __tests__/frontend/source-selection-api-error.cy.ts diff --git a/__tests__/frontend-playwright/source-selection-api-error.spec.ts b/__tests__/frontend-playwright/source-selection-api-error.spec.ts new file mode 100644 index 00000000..fb93947a --- /dev/null +++ b/__tests__/frontend-playwright/source-selection-api-error.spec.ts @@ -0,0 +1,30 @@ +import { expect, test } from "@playwright/test"; + +import { setup } from "../test-utils-playwright/stub-endpoints"; + +test("handles raw errors in source folder selection gracefully", async ({ + page, +}) => { + await page.goto("/"); + await setup(page); + + await page.evaluate(() => { + window._endpointStubs.listSharedDrives = [ + { + status: "success", + value: { status: "error", type: "DriveAPIError" }, + }, + ]; + }); + + await expect( + page.getByText("Shared drive mover", { exact: true }), + ).toBeVisible(); + await page.getByText("Continue").click(); + 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/source-selection-api-error.cy.ts b/__tests__/frontend/source-selection-api-error.cy.ts deleted file mode 100644 index b836cfb1..00000000 --- a/__tests__/frontend/source-selection-api-error.cy.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { stubEndpoints } from "../test-utils/stubEndpoints"; - -stubEndpoints({ - listSharedDrives: (successHandler) => { - setTimeout(() => { - successHandler({ status: "error", type: "DriveAPIError" }); - }, 100); - }, -}); - -it("handles raw errors in source folder selection gracefully", () => { - cy.visit("http://localhost:8080"); - cy.contains("Shared drive mover"); - cy.contains("Continue").click(); - cy.contains("An error occurred").should("be.visible"); - cy.contains("An error occurred in Google Drive").should("be.visible"); -});