mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-08-03 09:32:17 +00:00
Per Playwright's own docs, routeFromHAR's notFound: 'fallback' sends unmatched requests straight to the network -- it does not chain to other, earlier-registered page.route() handlers via route.fallback() the way I'd assumed. Since Playwright checks routes in reverse-registration order, a handler registered in beforeEach (i.e. before the test body's routeFromHAR call) is checked AFTER routeFromHAR, whose catch-all pattern intercepts everything first and sends any miss straight to the (nonexistent, in e2e) network -- my stub never got a chance to run. Confirmed by a second CI failure with the same "Failed to fetch" symptom even after the CORS-header fix. Moved the mockFilterSelectionData(page) call to immediately after each test's own routeFromHAR(...) call instead, so it's registered later and checked first for that specific URL, with routeFromHAR's broader pattern still handling everything else as before. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
70 lines
2.7 KiB
TypeScript
70 lines
2.7 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
import path from 'node:path'
|
|
import { mockFilterSelectionData } from '../mock-filter-selection-data'
|
|
|
|
const REQUESTS_HAR1 = path.join(__dirname, 'requests/api-dashboard1.har')
|
|
const REQUESTS_HAR2 = path.join(__dirname, 'requests/api-dashboard2.har')
|
|
const REQUESTS_HAR3 = path.join(__dirname, 'requests/api-dashboard3.har')
|
|
const REQUESTS_HAR4 = path.join(__dirname, 'requests/api-dashboard4.har')
|
|
|
|
test('dashboard inbox link', async ({ page }) => {
|
|
await page.routeFromHAR(REQUESTS_HAR1, { notFound: 'fallback' })
|
|
await mockFilterSelectionData(page)
|
|
await page.goto('/dashboard')
|
|
await page.getByRole('link', { name: 'Documents in inbox' }).click()
|
|
await expect(page).toHaveURL(/tags__id__in=9/)
|
|
await expect(page.locator('pngx-document-list')).toHaveText(/8 documents/)
|
|
})
|
|
|
|
test('dashboard total documents link', async ({ page }) => {
|
|
await page.routeFromHAR(REQUESTS_HAR2, { notFound: 'fallback' })
|
|
await mockFilterSelectionData(page)
|
|
await page.goto('/dashboard')
|
|
await page.getByRole('link').filter({ hasText: 'Total documents' }).click()
|
|
await expect(page).toHaveURL(/documents/)
|
|
await expect(page.locator('pngx-document-list')).toHaveText(/61 documents/)
|
|
await page.getByRole('button', { name: 'Reset filters' })
|
|
})
|
|
|
|
test('dashboard saved view show all', async ({ page }) => {
|
|
await page.routeFromHAR(REQUESTS_HAR3, { notFound: 'fallback' })
|
|
await mockFilterSelectionData(page)
|
|
await page.goto('/dashboard')
|
|
await page
|
|
.locator('pngx-widget-frame')
|
|
.filter({ hasText: 'Inbox' })
|
|
.getByRole('link', { name: 'Show all' })
|
|
.first()
|
|
.click()
|
|
await expect(page).toHaveURL(/view\/7/)
|
|
await expect(page.locator('pngx-document-list')).toHaveText(/8 documents/)
|
|
})
|
|
|
|
test('dashboard saved view document links', async ({ page }) => {
|
|
await page.routeFromHAR(REQUESTS_HAR4, { notFound: 'fallback' })
|
|
await mockFilterSelectionData(page)
|
|
await page.goto('/dashboard')
|
|
await page
|
|
.locator('pngx-widget-frame')
|
|
.filter({ hasText: 'Inbox' })
|
|
.locator('table')
|
|
.getByRole('link', { name: /test/ })
|
|
.first()
|
|
.click({ position: { x: 0, y: 0 } })
|
|
await expect(page).toHaveURL(/documents\/310\/details/)
|
|
})
|
|
|
|
test('test slim sidebar', async ({ page }) => {
|
|
await page.routeFromHAR(REQUESTS_HAR1, { notFound: 'fallback' })
|
|
await mockFilterSelectionData(page)
|
|
await page.goto('/dashboard')
|
|
await page.locator('.sidebar-slim-toggler').click()
|
|
await expect(
|
|
page.getByRole('link', { name: 'Dashboard' }).getByText('Dashboard')
|
|
).toBeHidden()
|
|
await page.locator('.sidebar-slim-toggler').click()
|
|
await expect(
|
|
page.getByRole('link', { name: 'Dashboard' }).getByText('Dashboard')
|
|
).toBeVisible()
|
|
})
|