mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Add tests for mail rules / accounts, partial tags, mobile preview
This commit is contained in:
		| @@ -44,7 +44,7 @@ describe('document-detail', () => { | ||||
|     }) | ||||
|  | ||||
|     cy.viewport(1024, 1024) | ||||
|     cy.visit('/documents/1/') | ||||
|     cy.visit('/documents/1/').wait('@ui-settings') | ||||
|   }) | ||||
|  | ||||
|   it('should activate / deactivate save button when changes are saved', () => { | ||||
| @@ -66,8 +66,21 @@ describe('document-detail', () => { | ||||
|     cy.contains('You have unsaved changes').should('not.exist') | ||||
|   }) | ||||
|  | ||||
|   it('should show a mobile preview', () => { | ||||
|     cy.viewport(440, 1000) | ||||
|     cy.get('a') | ||||
|       .contains('Preview') | ||||
|       .scrollIntoView({ offset: { top: 150, left: 0 } }) | ||||
|       .click() | ||||
|     cy.get('pdf-viewer').should('be.visible') | ||||
|   }) | ||||
|  | ||||
|   it('should show a list of comments', () => { | ||||
|     cy.wait(1000).get('a').contains('Comments').click().wait(1000) | ||||
|     cy.wait(1000) | ||||
|       .get('a') | ||||
|       .contains('Comments') | ||||
|       .click({ force: true }) | ||||
|       .wait(1000) | ||||
|     cy.get('app-document-comments').find('.card').its('length').should('eq', 3) | ||||
|   }) | ||||
|  | ||||
|   | ||||
| @@ -52,6 +52,10 @@ describe('documents-list', () => { | ||||
|  | ||||
|         req.reply(response) | ||||
|       }) | ||||
|  | ||||
|       cy.intercept('http://localhost:8000/api/documents/selection_data/', { | ||||
|         fixture: 'documents/selection_data.json', | ||||
|       }).as('selection-data') | ||||
|     }) | ||||
|  | ||||
|     cy.viewport(1280, 1024) | ||||
| @@ -76,6 +80,28 @@ describe('documents-list', () => { | ||||
|     cy.get('app-document-card-large') | ||||
|   }) | ||||
|  | ||||
|   it('should show partial tag selection', () => { | ||||
|     cy.get('app-document-card-small:nth-child(1)').click() | ||||
|     cy.get('app-document-card-small:nth-child(4)').click() | ||||
|     cy.get('app-bulk-editor button') | ||||
|       .contains('Tags') | ||||
|       .click() | ||||
|       .wait('@selection-data') | ||||
|     cy.get('svg.bi-dash').should('be.visible') | ||||
|     cy.get('svg.bi-check').should('be.visible') | ||||
|   }) | ||||
|  | ||||
|   it('should allow bulk removal', () => { | ||||
|     cy.get('app-document-card-small:nth-child(1)').click() | ||||
|     cy.get('app-document-card-small:nth-child(4)').click() | ||||
|     cy.get('app-bulk-editor').within(() => { | ||||
|       cy.get('button').contains('Tags').click().wait('@selection-data') | ||||
|       cy.get('button').contains('Another Sample Tag').click() | ||||
|       cy.get('button').contains('Apply').click() | ||||
|     }) | ||||
|     cy.contains('operation will remove the tag') | ||||
|   }) | ||||
|  | ||||
|   it('should filter tags', () => { | ||||
|     cy.get('app-filter-editor app-filterable-dropdown[title="Tags"]').within( | ||||
|       () => { | ||||
|   | ||||
| @@ -35,16 +35,58 @@ describe('settings', () => { | ||||
|             req.reply(response) | ||||
|           } | ||||
|         ).as('savedViews') | ||||
|       }) | ||||
|  | ||||
|         cy.intercept('http://localhost:8000/api/mail_accounts/*', { | ||||
|           fixture: 'mail_accounts/mail_accounts.json', | ||||
|         }) | ||||
|         cy.intercept('http://localhost:8000/api/mail_rules/*', { | ||||
|           fixture: 'mail_rules/mail_rules.json', | ||||
|         }).as('mailRules') | ||||
|         cy.intercept('http://localhost:8000/api/tasks/', { | ||||
|           fixture: 'tasks/tasks.json', | ||||
|         }) | ||||
|       this.newMailAccounts = [] | ||||
|  | ||||
|       cy.intercept( | ||||
|         'POST', | ||||
|         'http://localhost:8000/api/mail_accounts/', | ||||
|         (req) => { | ||||
|           const newRule = req.body | ||||
|           newRule.id = 3 | ||||
|           this.newMailAccounts.push(newRule) // store this for later | ||||
|           req.reply({ result: 'OK' }) | ||||
|         } | ||||
|       ).as('saveAccount') | ||||
|  | ||||
|       cy.fixture('mail_accounts/mail_accounts.json').then( | ||||
|         (mailAccountsJson) => { | ||||
|           cy.intercept( | ||||
|             'GET', | ||||
|             'http://localhost:8000/api/mail_accounts/*', | ||||
|             (req) => { | ||||
|               console.log(req, this.newMailAccounts) | ||||
|  | ||||
|               let response = { ...mailAccountsJson } | ||||
|               if (this.newMailAccounts.length) { | ||||
|                 response.results = response.results.concat(this.newMailAccounts) | ||||
|               } | ||||
|  | ||||
|               req.reply(response) | ||||
|             } | ||||
|           ).as('getAccounts') | ||||
|         } | ||||
|       ) | ||||
|  | ||||
|       this.newMailRules = [] | ||||
|  | ||||
|       cy.intercept('POST', 'http://localhost:8000/api/mail_rules/', (req) => { | ||||
|         const newRule = req.body | ||||
|         newRule.id = 2 | ||||
|         this.newMailRules.push(newRule) // store this for later | ||||
|         req.reply({ result: 'OK' }) | ||||
|       }).as('saveRule') | ||||
|  | ||||
|       cy.fixture('mail_rules/mail_rules.json').then((mailRulesJson) => { | ||||
|         cy.intercept('GET', 'http://localhost:8000/api/mail_rules/*', (req) => { | ||||
|           let response = { ...mailRulesJson } | ||||
|           if (this.newMailRules.length) { | ||||
|             response.results = response.results.concat(this.newMailRules) | ||||
|           } | ||||
|  | ||||
|           req.reply(response) | ||||
|         }).as('getRules') | ||||
|       }) | ||||
|  | ||||
|       cy.fixture('documents/documents.json').then((documentsJson) => { | ||||
| @@ -99,4 +141,42 @@ describe('settings', () => { | ||||
|     cy.visit('/dashboard') | ||||
|     cy.get('app-saved-view-widget').contains('Inbox').should('not.exist') | ||||
|   }) | ||||
|  | ||||
|   it('should show a list of mail accounts & rules & support creation', () => { | ||||
|     cy.contains('a', 'Mail').click() | ||||
|     cy.get('app-settings .tab-content ul li').its('length').should('eq', 5) // 2 headers, 2 accounts, 1 rule | ||||
|     cy.contains('button', 'Add Account').click() | ||||
|     cy.contains('Create new mail account') | ||||
|     cy.get('app-input-text[formcontrolname="name"]').type( | ||||
|       'Example Mail Account' | ||||
|     ) | ||||
|     cy.get('app-input-text[formcontrolname="imap_server"]').type( | ||||
|       'mail.example.com' | ||||
|     ) | ||||
|     cy.get('app-input-text[formcontrolname="imap_port"]').type('993') | ||||
|     cy.get('app-input-text[formcontrolname="username"]').type('username') | ||||
|     cy.get('app-input-password[formcontrolname="password"]').type('pass') | ||||
|     cy.contains('app-mail-account-edit-dialog button', 'Save') | ||||
|       .click() | ||||
|       .wait('@saveAccount') | ||||
|       .wait('@getAccounts') | ||||
|     cy.contains('Saved account') | ||||
|  | ||||
|     cy.wait(1000) | ||||
|     cy.contains('button', 'Add Rule').click() | ||||
|     cy.contains('Create new mail rule') | ||||
|     cy.get('app-input-text[formcontrolname="name"]').type('Example Rule') | ||||
|     cy.get('app-input-select[formcontrolname="account"]').type('Example{enter}') | ||||
|     cy.get('app-input-number[formcontrolname="maximum_age"]').type('30') | ||||
|     cy.get('app-input-text[formcontrolname="filter_subject"]').type( | ||||
|       '[paperless]' | ||||
|     ) | ||||
|     cy.contains('app-mail-rule-edit-dialog button', 'Save') | ||||
|       .click() | ||||
|       .wait('@saveRule') | ||||
|       .wait('@getRules') | ||||
|     cy.contains('Saved rule').wait(1000) | ||||
|  | ||||
|     cy.get('app-settings .tab-content ul li').its('length').should('eq', 7) | ||||
|   }) | ||||
| }) | ||||
|   | ||||
							
								
								
									
										293
									
								
								src-ui/cypress/fixtures/documents/selection_data.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										293
									
								
								src-ui/cypress/fixtures/documents/selection_data.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,293 @@ | ||||
| { | ||||
|     "selected_correspondents": [ | ||||
|         { | ||||
|             "id": 62, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 75, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 55, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 56, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 73, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 58, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 44, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 42, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 74, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 54, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 29, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 71, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 68, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 82, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 34, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 41, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 51, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 46, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 40, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 43, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 80, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 70, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 52, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 67, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 53, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 32, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 63, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 35, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 45, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 38, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 79, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 48, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 72, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 78, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 39, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 57, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 61, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 81, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 77, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 69, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 36, | ||||
|             "document_count": 3 | ||||
|         }, | ||||
|         { | ||||
|             "id": 31, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 30, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 50, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 49, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 60, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 47, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 66, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 37, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 28, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 59, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 33, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 76, | ||||
|             "document_count": 0 | ||||
|         } | ||||
|     ], | ||||
|     "selected_tags": [ | ||||
|         { | ||||
|             "id": 4, | ||||
|             "document_count": 2 | ||||
|         }, | ||||
|         { | ||||
|             "id": 7, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 5, | ||||
|             "document_count": 1 | ||||
|         }, | ||||
|         { | ||||
|             "id": 6, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 3, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 2, | ||||
|             "document_count": 1 | ||||
|         }, | ||||
|         { | ||||
|             "id": 1, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 8, | ||||
|             "document_count": 0 | ||||
|         } | ||||
|     ], | ||||
|     "selected_document_types": [ | ||||
|         { | ||||
|             "id": 4, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 10, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 2, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 11, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 9, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 7, | ||||
|             "document_count": 2 | ||||
|         }, | ||||
|         { | ||||
|             "id": 3, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 1, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 5, | ||||
|             "document_count": 0 | ||||
|         }, | ||||
|         { | ||||
|             "id": 8, | ||||
|             "document_count": 1 | ||||
|         } | ||||
|     ], | ||||
|     "selected_storage_paths": [] | ||||
| } | ||||
| @@ -23,7 +23,8 @@ | ||||
|             "assign_correspondent": 2, | ||||
|             "assign_document_type": null, | ||||
|             "order": 0, | ||||
|             "attachment_type": 2 | ||||
|             "attachment_type": 2, | ||||
|             "consumption_scope": 1 | ||||
|         } | ||||
|     ] | ||||
| } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| beforeEach(() => { | ||||
|   cy.intercept('http://localhost:8000/api/ui_settings/', { | ||||
|     fixture: 'ui_settings/settings.json', | ||||
|   }) | ||||
|   }).as('ui-settings') | ||||
|  | ||||
|   cy.intercept('http://localhost:8000/api/remote_version/', { | ||||
|     fixture: 'remote_version/remote_version.json', | ||||
| @@ -29,6 +29,10 @@ beforeEach(() => { | ||||
|     fixture: 'storage_paths/storage_paths.json', | ||||
|   }) | ||||
|  | ||||
|   cy.intercept('http://localhost:8000/api/tasks/', { | ||||
|     fixture: 'tasks/tasks.json', | ||||
|   }) | ||||
|  | ||||
|   cy.intercept('http://localhost:8000/api/documents/1/metadata/', { | ||||
|     fixture: 'documents/1/metadata.json', | ||||
|   }) | ||||
|   | ||||
| @@ -180,9 +180,9 @@ | ||||
|  | ||||
|             <div [ngbNavOutlet]="nav" class="mt-2"></div> | ||||
|  | ||||
|             <button type="button" class="btn btn-outline-secondary" (click)="discard()" i18n [disabled]="networkActive || (isDirty$ | async) === false">Discard</button>  | ||||
|             <button type="button" class="btn btn-outline-primary" (click)="saveEditNext()" *ngIf="hasNext()" i18n [disabled]="networkActive || (isDirty$ | async) === false || error">Save & next</button>  | ||||
|             <button type="submit" class="btn btn-primary" i18n [disabled]="networkActive || (isDirty$ | async) === false || error">Save</button>  | ||||
|             <button type="button" class="btn btn-outline-secondary" (click)="discard()" i18n [disabled]="networkActive || (isDirty$ | async) !== true">Discard</button>  | ||||
|             <button type="button" class="btn btn-outline-primary" (click)="saveEditNext()" *ngIf="hasNext()" i18n [disabled]="networkActive || (isDirty$ | async) !== true || error">Save & next</button>  | ||||
|             <button type="submit" class="btn btn-primary" i18n [disabled]="networkActive || (isDirty$ | async) !== true || error">Save</button>  | ||||
|         </form> | ||||
|     </div> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon