paperless-ngx/src-ui/e2e/document-detail/document-detail.spec.ts
shamoon e8905c1c5e pngx-pdf-viewer based on ng2-pdf-viewer with pdfjs 3.11
Squashed commit of the following:

commit 32bec8dfedbc7cbd0e2f290e1fd9ceaaa7a94366
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Nov 30 12:38:19 2023 -0800

    Correctly include pdf worker js

commit 48aedbb2b9983a45ee319bc8fa1518d430c4a81b
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Nov 30 08:30:53 2023 -0800

    Update angular.json

commit 23db5031632290e42e15a4eb46e2f0c72a6dadd9
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Thu Nov 30 00:43:08 2023 -0800

    Update pdf-viewer.component.ts

commit b01a18526e7df893d7ab09e491470f4bd2c3abeb
Author: shamoon <4887959+shamoon@users.noreply.github.com>
Date:   Wed Nov 29 22:50:33 2023 -0800

    pngx-pdf-viewer based on ng2-pdf-viewer with pdfjs 3.11

    Implement zoom
2023-11-30 14:25:14 -08:00

105 lines
3.7 KiB
TypeScript

import { test, expect } from '@playwright/test'
const REQUESTS_HAR = 'e2e/document-detail/requests/api-document-detail.har'
const REQUESTS_HAR2 = 'e2e/document-detail/requests/api-document-detail2.har'
test('should activate / deactivate save button when changes are saved', async ({
page,
}) => {
await page.routeFromHAR(REQUESTS_HAR, { notFound: 'fallback' })
await page.goto('/documents/175/')
await page.waitForSelector('pngx-document-detail pngx-input-text:first-child')
await expect(page.getByTitle('Storage path', { exact: true })).toHaveText(
/\w+/
)
await expect(
page.getByRole('button', { name: 'Save', exact: true })
).toBeDisabled()
await page.getByTitle('Storage path').getByTitle('Clear all').click()
await expect(
page.getByRole('button', { name: 'Save', exact: true })
).toBeEnabled()
})
test('should warn on unsaved changes', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR, { notFound: 'fallback' })
await page.goto('/documents/175/')
await expect(page.getByTitle('Correspondent', { exact: true })).toHaveText(
/\w+/
)
await expect(
page.getByRole('button', { name: 'Save', exact: true })
).toBeDisabled()
await page
.getByTitle('Storage path', { exact: true })
.getByTitle('Clear all')
.click()
await expect(
page.getByRole('button', { name: 'Save', exact: true })
).toBeEnabled()
await page.getByRole('button', { name: 'Close', exact: true }).click()
await expect(page.getByRole('dialog')).toHaveText(/unsaved changes/)
await page.getByRole('button', { name: 'Cancel' }).click()
await page.getByRole('link', { name: 'Close all' }).click()
await expect(page.getByRole('dialog')).toHaveText(/unsaved changes/)
})
test('should support tab direct navigation', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR, { notFound: 'fallback' })
await page.goto('/documents/175/details')
await expect(page.getByRole('tab', { name: 'Details' })).toHaveAttribute(
'aria-selected',
'true'
)
await page.goto('/documents/175/content')
await expect(page.getByRole('tab', { name: 'Content' })).toHaveAttribute(
'aria-selected',
'true'
)
await page.goto('/documents/175/metadata')
await expect(page.getByRole('tab', { name: 'Metadata' })).toHaveAttribute(
'aria-selected',
'true'
)
await page.goto('/documents/175/notes')
await expect(page.getByRole('tab', { name: 'Notes' })).toHaveAttribute(
'aria-selected',
'true'
)
await page.goto('/documents/175/permissions')
await expect(page.getByRole('tab', { name: 'Permissions' })).toHaveAttribute(
'aria-selected',
'true'
)
})
test('should show a mobile preview', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR, { notFound: 'fallback' })
await page.goto('/documents/175/')
await page.setViewportSize({ width: 400, height: 1000 })
await expect(page.getByRole('tab', { name: 'Preview' })).toBeVisible()
await page.getByRole('tab', { name: 'Preview' }).click()
await page.waitForSelector('pngx-pdf-viewer')
})
test('should show a list of notes', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR, { notFound: 'fallback' })
await page.goto('/documents/175/notes')
await expect(page.locator('pngx-document-notes')).toBeVisible()
await expect(
await page.getByRole('button', {
name: /delete note/i,
includeHidden: true,
})
).toHaveCount(4)
})
test('should support quick filters', async ({ page }) => {
await page.routeFromHAR(REQUESTS_HAR2, { notFound: 'fallback' })
await page.goto('/documents/175/details')
await page
.getByRole('button', { name: 'Filter documents with these Tags' })
.click()
await expect(page).toHaveURL(/tags__id__all=4&sort=created&reverse=1&page=1/)
})