diff --git a/__tests__/frontend/basic.spec.ts b/__tests__/frontend/basic.spec.ts index 2885438d..7397c5da 100644 --- a/__tests__/frontend/basic.spec.ts +++ b/__tests__/frontend/basic.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works with basic configuration", async ({ page }) => { await page.goto("/"); diff --git a/__tests__/frontend/configuration.spec.ts b/__tests__/frontend/configuration.spec.ts index b66d25b3..bedac650 100644 --- a/__tests__/frontend/configuration.spec.ts +++ b/__tests__/frontend/configuration.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works with copy configuration", async ({ page }) => { await page.goto("/"); diff --git a/__tests__/frontend/destination-selection-api-error.spec.ts b/__tests__/frontend/destination-selection-api-error.spec.ts index 54f5c2f1..c5d445d0 100644 --- a/__tests__/frontend/destination-selection-api-error.spec.ts +++ b/__tests__/frontend/destination-selection-api-error.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("handles raw errors in source folder selection gracefully", async ({ page, diff --git a/__tests__/frontend/destination-selection-unhandled-error.spec.ts b/__tests__/frontend/destination-selection-unhandled-error.spec.ts index 8d44466b..74479cab 100644 --- a/__tests__/frontend/destination-selection-unhandled-error.spec.ts +++ b/__tests__/frontend/destination-selection-unhandled-error.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("handles raw errors in source folder selection gracefully", async ({ page, diff --git a/__tests__/frontend/destination-selection-unknown-error.spec.ts b/__tests__/frontend/destination-selection-unknown-error.spec.ts index 157ffdfe..dfe76929 100644 --- a/__tests__/frontend/destination-selection-unknown-error.spec.ts +++ b/__tests__/frontend/destination-selection-unknown-error.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("handles raw errors in source folder selection gracefully", async ({ page, diff --git a/__tests__/frontend/move-api-error.spec.ts b/__tests__/frontend/move-api-error.spec.ts index 012c6d67..59bab003 100644 --- a/__tests__/frontend/move-api-error.spec.ts +++ b/__tests__/frontend/move-api-error.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works with an API error", async ({ page }) => { await page.goto("/"); diff --git a/__tests__/frontend/move-folders-equal-error.spec.ts b/__tests__/frontend/move-folders-equal-error.spec.ts index 9b473475..9c1c50cc 100644 --- a/__tests__/frontend/move-folders-equal-error.spec.ts +++ b/__tests__/frontend/move-folders-equal-error.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works with source and destination folders being equal", async ({ page, diff --git a/__tests__/frontend/move-repeat-after-timeout.spec.ts b/__tests__/frontend/move-repeat-after-timeout.spec.ts index 67856a9b..e2f314f7 100644 --- a/__tests__/frontend/move-repeat-after-timeout.spec.ts +++ b/__tests__/frontend/move-repeat-after-timeout.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works with an unhandled move error", async ({ page }) => { await page.goto("/"); diff --git a/__tests__/frontend/move-unhandled-error.spec.ts b/__tests__/frontend/move-unhandled-error.spec.ts index b32b4491..1427a8f5 100644 --- a/__tests__/frontend/move-unhandled-error.spec.ts +++ b/__tests__/frontend/move-unhandled-error.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works with an unhandled move error", async ({ page }) => { await page.goto("/"); diff --git a/__tests__/frontend/move-unknown-error.spec.ts b/__tests__/frontend/move-unknown-error.spec.ts index 9bf1dce3..8e759b07 100644 --- a/__tests__/frontend/move-unknown-error.spec.ts +++ b/__tests__/frontend/move-unknown-error.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works with an unknown move error", async ({ page }) => { await page.goto("/"); diff --git a/__tests__/frontend/navigation.spec.ts b/__tests__/frontend/navigation.spec.ts index 2a931705..714da46f 100644 --- a/__tests__/frontend/navigation.spec.ts +++ b/__tests__/frontend/navigation.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works with basic configuration", async ({ page }) => { await page.goto("/"); diff --git a/__tests__/frontend/non-empty.spec.ts b/__tests__/frontend/non-empty.spec.ts index 809fac93..c6a76db1 100644 --- a/__tests__/frontend/non-empty.spec.ts +++ b/__tests__/frontend/non-empty.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works with non-empty destination folder", async ({ page }) => { await page.goto("/"); diff --git a/__tests__/frontend/source-destination-selection.spec.ts b/__tests__/frontend/source-destination-selection.spec.ts index 87e628ce..8f3235e7 100644 --- a/__tests__/frontend/source-destination-selection.spec.ts +++ b/__tests__/frontend/source-destination-selection.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works with folder selection", async ({ page }) => { await page.goto("/"); diff --git a/__tests__/frontend/source-selection-api-error.spec.ts b/__tests__/frontend/source-selection-api-error.spec.ts index fb93947a..4dcd3137 100644 --- a/__tests__/frontend/source-selection-api-error.spec.ts +++ b/__tests__/frontend/source-selection-api-error.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("handles raw errors in source folder selection gracefully", async ({ page, diff --git a/__tests__/frontend/source-selection-unhandled-error.spec.ts b/__tests__/frontend/source-selection-unhandled-error.spec.ts index 3d80a3c5..23140c9b 100644 --- a/__tests__/frontend/source-selection-unhandled-error.spec.ts +++ b/__tests__/frontend/source-selection-unhandled-error.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("handles raw errors in source folder selection gracefully", async ({ page, diff --git a/__tests__/frontend/source-selection-unknown-error.spec.ts b/__tests__/frontend/source-selection-unknown-error.spec.ts index 2ab5ea4a..1479b1af 100644 --- a/__tests__/frontend/source-selection-unknown-error.spec.ts +++ b/__tests__/frontend/source-selection-unknown-error.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("handles raw errors in source folder selection gracefully", async ({ page, diff --git a/__tests__/frontend/success-with-errors.spec.ts b/__tests__/frontend/success-with-errors.spec.ts index 5b8f0e52..99e4446c 100644 --- a/__tests__/frontend/success-with-errors.spec.ts +++ b/__tests__/frontend/success-with-errors.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -import { setup } from "../test-utils-playwright/stub-endpoints"; +import { setup } from "../test-utils/stub-endpoints"; test("works and displays moving errors", async ({ page }) => { await page.goto("/"); diff --git a/__tests__/test-utils-playwright/stub-endpoints.ts b/__tests__/test-utils/stub-endpoints.ts similarity index 100% rename from __tests__/test-utils-playwright/stub-endpoints.ts rename to __tests__/test-utils/stub-endpoints.ts diff --git a/__tests__/test-utils/stubEndpoints.ts b/__tests__/test-utils/stubEndpoints.ts deleted file mode 100644 index 6e3db08d..00000000 --- a/__tests__/test-utils/stubEndpoints.ts +++ /dev/null @@ -1,73 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type SuccessHandlerType = (value?: any, object?: any) => void; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type FailureHandlerType = (error: Error, object?: any) => void; - -export function stubEndpoints( - endpoints: Record< - string, - ( - successHandler: SuccessHandlerType, - failureHandler: FailureHandlerType, - parameters: Array, - ) => void - >, -): Record { - const stubbedEndpoints: Record = {}; - function endpointFn( - successHandler: SuccessHandlerType, - failureHandler: FailureHandlerType, - ): Record { - for (const key in endpoints) { - stubbedEndpoints[key] = cy.stub().callsFake((...args) => { - endpoints[key](successHandler, failureHandler, args); - }); - } - return stubbedEndpoints; - } - Cypress.on("window:before:load", (win) => { - win.google = { - script: { - history: { - push: cy.stub(), - replace: cy.stub(), - setChangeHandler: cy.stub(), - }, - host: { - close: cy.stub(), - setHeight: cy.stub(), - setWidth: cy.stub(), - origin: "", - editor: { - focus: cy.stub(), - }, - }, - run: { - withFailureHandler: cy - .stub() - .callsFake((failureHandler: FailureHandlerType) => ({ - withSuccessHandler: cy - .stub() - .callsFake((successHandler: SuccessHandlerType) => - endpointFn(successHandler, failureHandler), - ), - })), - withSuccessHandler: cy - .stub() - .callsFake((successHandler: SuccessHandlerType) => ({ - withFailureHandler: cy - .stub() - .callsFake((failureHandler: FailureHandlerType) => - endpointFn(successHandler, failureHandler), - ), - })), - withUserObject: cy.stub(), - }, - url: { - getLocation: cy.stub(), - }, - }, - }; - }); - return stubbedEndpoints; -}