mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
document-detail e2e tests
[ci skip]
This commit is contained in:
64
src-ui/cypress/integration/document-detail.spec.ts
Normal file
64
src-ui/cypress/integration/document-detail.spec.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
describe('document-detail', () => {
|
||||
beforeEach(() => {
|
||||
this.modifiedDocuments = []
|
||||
|
||||
cy.fixture('documents/documents.json').then((documentsJson) => {
|
||||
cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => {
|
||||
let response = { ...documentsJson }
|
||||
response = response.results.find((d) => d.id == 1)
|
||||
req.reply(response)
|
||||
})
|
||||
})
|
||||
|
||||
cy.intercept('PUT', 'http://localhost:8000/api/documents/1/', (req) => {
|
||||
this.modifiedDocuments.push(req.body) // store this for later
|
||||
req.reply({ result: 'OK' })
|
||||
}).as('saveDoc')
|
||||
|
||||
cy.intercept('http://localhost:8000/api/documents/1/metadata/', {
|
||||
fixture: 'documents/1/metadata.json',
|
||||
})
|
||||
|
||||
cy.intercept('http://localhost:8000/api/documents/1/suggestions/', {
|
||||
fixture: 'documents/1/suggestions.json',
|
||||
})
|
||||
|
||||
cy.intercept('http://localhost:8000/api/saved_views/*', {
|
||||
fixture: 'saved_views/savedviews.json',
|
||||
})
|
||||
|
||||
cy.intercept('http://localhost:8000/api/tags/*', {
|
||||
fixture: 'tags/tags.json',
|
||||
})
|
||||
|
||||
cy.intercept('http://localhost:8000/api/correspondents/*', {
|
||||
fixture: 'correspondents/correspondents.json',
|
||||
})
|
||||
|
||||
cy.intercept('http://localhost:8000/api/document_types/*', {
|
||||
fixture: 'document_types/doctypes.json',
|
||||
})
|
||||
|
||||
cy.viewport(1024, 1024)
|
||||
cy.visit('/documents/1/')
|
||||
})
|
||||
|
||||
it('should activate / deactivate save button when changes are saved', () => {
|
||||
cy.contains('button', 'Save').should('be.disabled')
|
||||
cy.get('app-input-text[formcontrolname="title"]')
|
||||
.type(' additional')
|
||||
.wait(1500) // this delay is for frontend debounce
|
||||
cy.contains('button', 'Save').should('not.be.disabled')
|
||||
})
|
||||
|
||||
it('should warn on unsaved changes', () => {
|
||||
cy.get('app-input-text[formcontrolname="title"]')
|
||||
.type(' additional')
|
||||
.wait(1500) // this delay is for frontend debounce
|
||||
cy.get('button[title="Close"]').click()
|
||||
cy.contains('You have unsaved changes')
|
||||
cy.contains('button', 'Cancel').click().wait(150)
|
||||
cy.contains('button', 'Save').click().wait('@saveDoc').wait(2000) // navigates away after saving
|
||||
cy.contains('You have unsaved changes').should('not.exist')
|
||||
})
|
||||
})
|
@@ -28,6 +28,22 @@ describe('settings', () => {
|
||||
}).as('savedViews')
|
||||
})
|
||||
|
||||
cy.fixture('documents/documents.json').then((documentsJson) => {
|
||||
cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => {
|
||||
let response = { ...documentsJson }
|
||||
response = response.results.find((d) => d.id == 1)
|
||||
req.reply(response)
|
||||
})
|
||||
})
|
||||
|
||||
cy.intercept('http://localhost:8000/api/documents/1/metadata/', {
|
||||
fixture: 'documents/1/metadata.json',
|
||||
})
|
||||
|
||||
cy.intercept('http://localhost:8000/api/documents/1/suggestions/', {
|
||||
fixture: 'documents/1/suggestions.json',
|
||||
})
|
||||
|
||||
cy.viewport(1024, 1024)
|
||||
cy.visit('/settings')
|
||||
cy.wait('@savedViews')
|
||||
@@ -46,8 +62,8 @@ describe('settings', () => {
|
||||
cy.contains('a', 'Dashboard').click()
|
||||
cy.contains('You have unsaved changes')
|
||||
cy.contains('button', 'Cancel').click()
|
||||
cy.contains('button', 'Save').click()
|
||||
cy.visit('/dashboard')
|
||||
cy.contains('button', 'Save').click().wait('@savedViews')
|
||||
cy.contains('a', 'Dashboard').click()
|
||||
cy.contains('You have unsaved changes').should('not.exist')
|
||||
})
|
||||
|
||||
@@ -61,14 +77,14 @@ describe('settings', () => {
|
||||
it('should remove saved view from sidebar when unset', () => {
|
||||
cy.contains('a', 'Saved views').click()
|
||||
cy.get('#show_in_sidebar_1').click()
|
||||
cy.contains('button', 'Save').click()
|
||||
cy.contains('button', 'Save').click().wait('@savedViews')
|
||||
cy.contains('li', 'Inbox').should('not.exist')
|
||||
})
|
||||
|
||||
it('should remove saved view from dashboard when unset', () => {
|
||||
cy.contains('a', 'Saved views').click()
|
||||
cy.get('#show_on_dashboard_1').click()
|
||||
cy.contains('button', 'Save').click()
|
||||
cy.contains('button', 'Save').click().wait('@savedViews')
|
||||
cy.visit('/dashboard')
|
||||
cy.get('app-saved-view-widget').contains('Inbox').should('not.exist')
|
||||
})
|
||||
@@ -78,7 +94,7 @@ describe('settings', () => {
|
||||
cy.get('object[data*="/api/documents/1/preview/"]').should('not.exist')
|
||||
cy.visit('/settings')
|
||||
cy.contains('Use PDF viewer provided by the browser').click()
|
||||
cy.contains('button', 'Save').click()
|
||||
cy.contains('button', 'Save').click().wait('@savedViews').wait(1000)
|
||||
cy.visit('/documents/1')
|
||||
cy.get('object[data*="/api/documents/1/preview/"]')
|
||||
})
|
||||
|
Reference in New Issue
Block a user