diff --git a/src-ui/e2e/admin/settings.spec.ts b/src-ui/e2e/admin/settings.spec.ts index edff75b28..3d67fd340 100644 --- a/src-ui/e2e/admin/settings.spec.ts +++ b/src-ui/e2e/admin/settings.spec.ts @@ -1,5 +1,10 @@ import { expect, test } from '@playwright/test' import path from 'node:path' +import { mockFilterSelectionData } from '../mock-filter-selection-data' + +test.beforeEach(async ({ page }) => { + await mockFilterSelectionData(page) +}) const REQUESTS_HAR = path.join(__dirname, 'requests/api-settings.har') diff --git a/src-ui/e2e/dashboard/dashboard.spec.ts b/src-ui/e2e/dashboard/dashboard.spec.ts index 801f431f3..d4c367a12 100644 --- a/src-ui/e2e/dashboard/dashboard.spec.ts +++ b/src-ui/e2e/dashboard/dashboard.spec.ts @@ -1,5 +1,10 @@ import { expect, test } from '@playwright/test' import path from 'node:path' +import { mockFilterSelectionData } from '../mock-filter-selection-data' + +test.beforeEach(async ({ page }) => { + await mockFilterSelectionData(page) +}) const REQUESTS_HAR1 = path.join(__dirname, 'requests/api-dashboard1.har') const REQUESTS_HAR2 = path.join(__dirname, 'requests/api-dashboard2.har') diff --git a/src-ui/e2e/document-detail/document-detail.spec.ts b/src-ui/e2e/document-detail/document-detail.spec.ts index ba10745ec..ed709e569 100644 --- a/src-ui/e2e/document-detail/document-detail.spec.ts +++ b/src-ui/e2e/document-detail/document-detail.spec.ts @@ -1,5 +1,10 @@ import { expect, test } from '@playwright/test' import path from 'node:path' +import { mockFilterSelectionData } from '../mock-filter-selection-data' + +test.beforeEach(async ({ page }) => { + await mockFilterSelectionData(page) +}) const REQUESTS_HAR = path.join(__dirname, 'requests/api-document-detail.har') const REQUESTS_HAR2 = path.join(__dirname, 'requests/api-document-detail2.har') diff --git a/src-ui/e2e/document-list/document-list.spec.ts b/src-ui/e2e/document-list/document-list.spec.ts index 0cea8effa..7abb06aae 100644 --- a/src-ui/e2e/document-list/document-list.spec.ts +++ b/src-ui/e2e/document-list/document-list.spec.ts @@ -1,5 +1,10 @@ import { expect, test } from '@playwright/test' import path from 'node:path' +import { mockFilterSelectionData } from '../mock-filter-selection-data' + +test.beforeEach(async ({ page }) => { + await mockFilterSelectionData(page) +}) const REQUESTS_HAR1 = path.join(__dirname, 'requests/api-document-list1.har') const REQUESTS_HAR2 = path.join(__dirname, 'requests/api-document-list2.har') diff --git a/src-ui/e2e/mock-filter-selection-data.ts b/src-ui/e2e/mock-filter-selection-data.ts new file mode 100644 index 000000000..744aaffd5 --- /dev/null +++ b/src-ui/e2e/mock-filter-selection-data.ts @@ -0,0 +1,27 @@ +import { Page } from '@playwright/test' + +const EMPTY_SELECTION_DATA = { + selected_correspondents: [], + selected_tags: [], + selected_document_types: [], + selected_storage_paths: [], + selected_custom_fields: [], +} + +/** + * The document list now fires a GET to filter_selection_data on every + * non-search reload(), independent of and concurrent with the main list + * request. It's not present in any of the recorded HAR fixtures, so with + * `notFound: 'fallback'` it would otherwise fall through to the real + * network (nothing listens there in e2e, since only the frontend dev + * server is started) and fail every test that reloads the list. + * + * Playwright checks routes in reverse-registration order, so this must be + * registered before a test's own page.routeFromHAR() call for the HAR + * route's `notFound: 'fallback'` to defer back to this one. + */ +export async function mockFilterSelectionData(page: Page) { + await page.route('**/api/documents/filter_selection_data/**', (route) => + route.fulfill({ json: EMPTY_SELECTION_DATA }) + ) +} diff --git a/src-ui/e2e/permissions/global-permissions.spec.ts b/src-ui/e2e/permissions/global-permissions.spec.ts index 7021b6d9b..005ddc7e8 100644 --- a/src-ui/e2e/permissions/global-permissions.spec.ts +++ b/src-ui/e2e/permissions/global-permissions.spec.ts @@ -1,5 +1,10 @@ import { expect, test } from '@playwright/test' import path from 'node:path' +import { mockFilterSelectionData } from '../mock-filter-selection-data' + +test.beforeEach(async ({ page }) => { + await mockFilterSelectionData(page) +}) const REQUESTS_HAR = path.join(__dirname, 'requests/api-global-permissions.har')