From 1e5c0f63253b689b7e38079dfe64a94e578360fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Sun, 22 Oct 2023 18:24:31 +0200 Subject: [PATCH] Ported source selection unhandled error test --- .../source-selection-unhandled-error.spec.ts | 28 +++++++++++++++++++ .../source-selection-unhandled-error.cy.ts | 17 ----------- 2 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 __tests__/frontend-playwright/source-selection-unhandled-error.spec.ts delete mode 100644 __tests__/frontend/source-selection-unhandled-error.cy.ts diff --git a/__tests__/frontend-playwright/source-selection-unhandled-error.spec.ts b/__tests__/frontend-playwright/source-selection-unhandled-error.spec.ts new file mode 100644 index 00000000..3d80a3c5 --- /dev/null +++ b/__tests__/frontend-playwright/source-selection-unhandled-error.spec.ts @@ -0,0 +1,28 @@ +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: "failure", + value: new Error("ERROR MESSAGE"), + }, + ]; + }); + + 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("ERROR MESSAGE")).toBeVisible(); +}); diff --git a/__tests__/frontend/source-selection-unhandled-error.cy.ts b/__tests__/frontend/source-selection-unhandled-error.cy.ts deleted file mode 100644 index 435ac463..00000000 --- a/__tests__/frontend/source-selection-unhandled-error.cy.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { stubEndpoints } from "../test-utils/stubEndpoints"; - -stubEndpoints({ - listSharedDrives: (_, failureHandler) => { - setTimeout(() => { - failureHandler(new Error("ERROR MESSAGE")); - }, 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("ERROR MESSAGE"); -});