document-detail e2e tests
[ci skip]
This commit is contained in:
		
							parent
							
								
									bd66333147
								
							
						
					
					
						commit
						83d769251d
					
				
							
								
								
									
										1
									
								
								src-ui/cypress/fixtures/documents/1/metadata.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src-ui/cypress/fixtures/documents/1/metadata.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					{"original_checksum":"e959bc7d593245d92685213264e962ba","original_size":963754,"original_mime_type":"application/pdf","media_filename":"2022/lorem-ipsum.pdf","has_archive_version":true,"original_metadata":[],"archive_checksum":"5a1f46a9150bcade978c764b039ce4d0","archive_media_filename":"2022/lorem-ipsum.pdf","archive_size":351160,"archive_metadata":[{"namespace":"http://ns.adobe.com/pdf/1.3/","prefix":"pdf","key":"Producer","value":"pikepdf5.0.1"},{"namespace":"http://ns.adobe.com/xap/1.0/","prefix":"xmp","key":"ModifyDate","value":"2022-03-22T04:53:18+00:00"},{"namespace":"http://ns.adobe.com/xap/1.0/","prefix":"xmp","key":"CreateDate","value":"2022-03-22T18:05:43+00:00"},{"namespace":"http://ns.adobe.com/xap/1.0/","prefix":"xmp","key":"CreatorTool","value":"ocrmypdf13.4.0/TesseractOCR-PDF4.1.1"},{"namespace":"http://ns.adobe.com/xap/1.0/mm/","prefix":"xmpMM","key":"DocumentID","value":"uuid:df27edcf-e34a-11f7-0000-8fa6067a3c04"},{"namespace":"http://purl.org/dc/elements/1.1/","prefix":"dc","key":"format","value":"application/pdf"},{"namespace":"http://purl.org/dc/elements/1.1/","prefix":"dc","key":"title","value":"ScannedDocument"},{"namespace":"http://www.aiim.org/pdfa/ns/id/","prefix":"pdfaid","key":"part","value":"2"},{"namespace":"http://www.aiim.org/pdfa/ns/id/","prefix":"pdfaid","key":"conformance","value":"B"},{"namespace":"http://purl.org/dc/elements/1.1/","prefix":"dc","key":"creator","value":"None"},{"namespace":"http://ns.adobe.com/xap/1.0/","prefix":"xmp","key":"MetadataDate","value":"2022-03-22T21:53:18.882551-07:00"}]}
 | 
				
			||||||
							
								
								
									
										1
									
								
								src-ui/cypress/fixtures/documents/1/suggestions.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src-ui/cypress/fixtures/documents/1/suggestions.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					{"correspondents":[],"tags":[3],"document_types":[1]}
 | 
				
			||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										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')
 | 
					      }).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.viewport(1024, 1024)
 | 
				
			||||||
    cy.visit('/settings')
 | 
					    cy.visit('/settings')
 | 
				
			||||||
    cy.wait('@savedViews')
 | 
					    cy.wait('@savedViews')
 | 
				
			||||||
@ -46,8 +62,8 @@ describe('settings', () => {
 | 
				
			|||||||
    cy.contains('a', 'Dashboard').click()
 | 
					    cy.contains('a', 'Dashboard').click()
 | 
				
			||||||
    cy.contains('You have unsaved changes')
 | 
					    cy.contains('You have unsaved changes')
 | 
				
			||||||
    cy.contains('button', 'Cancel').click()
 | 
					    cy.contains('button', 'Cancel').click()
 | 
				
			||||||
    cy.contains('button', 'Save').click()
 | 
					    cy.contains('button', 'Save').click().wait('@savedViews')
 | 
				
			||||||
    cy.visit('/dashboard')
 | 
					    cy.contains('a', 'Dashboard').click()
 | 
				
			||||||
    cy.contains('You have unsaved changes').should('not.exist')
 | 
					    cy.contains('You have unsaved changes').should('not.exist')
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -61,14 +77,14 @@ describe('settings', () => {
 | 
				
			|||||||
  it('should remove saved view from sidebar when unset', () => {
 | 
					  it('should remove saved view from sidebar when unset', () => {
 | 
				
			||||||
    cy.contains('a', 'Saved views').click()
 | 
					    cy.contains('a', 'Saved views').click()
 | 
				
			||||||
    cy.get('#show_in_sidebar_1').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')
 | 
					    cy.contains('li', 'Inbox').should('not.exist')
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('should remove saved view from dashboard when unset', () => {
 | 
					  it('should remove saved view from dashboard when unset', () => {
 | 
				
			||||||
    cy.contains('a', 'Saved views').click()
 | 
					    cy.contains('a', 'Saved views').click()
 | 
				
			||||||
    cy.get('#show_on_dashboard_1').click()
 | 
					    cy.get('#show_on_dashboard_1').click()
 | 
				
			||||||
    cy.contains('button', 'Save').click()
 | 
					    cy.contains('button', 'Save').click().wait('@savedViews')
 | 
				
			||||||
    cy.visit('/dashboard')
 | 
					    cy.visit('/dashboard')
 | 
				
			||||||
    cy.get('app-saved-view-widget').contains('Inbox').should('not.exist')
 | 
					    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.get('object[data*="/api/documents/1/preview/"]').should('not.exist')
 | 
				
			||||||
    cy.visit('/settings')
 | 
					    cy.visit('/settings')
 | 
				
			||||||
    cy.contains('Use PDF viewer provided by the browser').click()
 | 
					    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.visit('/documents/1')
 | 
				
			||||||
    cy.get('object[data*="/api/documents/1/preview/"]')
 | 
					    cy.get('object[data*="/api/documents/1/preview/"]')
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user