mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Simple e2e test for Tasks component
This commit is contained in:
		
							
								
								
									
										1
									
								
								src-ui/cypress/fixtures/tasks/tasks.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src-ui/cypress/fixtures/tasks/tasks.json
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										70
									
								
								src-ui/cypress/integration/tasks.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								src-ui/cypress/integration/tasks.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | ||||
| describe('tasks', () => { | ||||
|   beforeEach(() => { | ||||
|     this.dismissedTasks = new Set<number>() | ||||
|  | ||||
|     cy.intercept('http://localhost:8000/api/ui_settings/', { | ||||
|       fixture: 'ui_settings/settings.json', | ||||
|     }) | ||||
|     cy.intercept('http://localhost:8000/api/correspondents/*', { | ||||
|       fixture: 'correspondents/correspondents.json', | ||||
|     }) | ||||
|     cy.intercept('http://localhost:8000/api/tags/*', { | ||||
|       fixture: 'tags/tags.json', | ||||
|     }) | ||||
|  | ||||
|     cy.fixture('tasks/tasks.json').then((tasksViewsJson) => { | ||||
|       // acknowledge tasks POST | ||||
|       cy.intercept( | ||||
|         'POST', | ||||
|         'http://localhost:8000/api/acknowledge_tasks/', | ||||
|         (req) => { | ||||
|           req.body['tasks'].forEach((t) => this.dismissedTasks.add(t)) // store this for later | ||||
|           req.reply({ result: 'OK' }) | ||||
|         } | ||||
|       ) | ||||
|  | ||||
|       cy.intercept('GET', 'http://localhost:8000/api/tasks/', (req) => { | ||||
|         let response = [...tasksViewsJson] | ||||
|         if (this.dismissedTasks.size) { | ||||
|           response = response.filter((t) => { | ||||
|             return !this.dismissedTasks.has(t.id) | ||||
|           }) | ||||
|         } | ||||
|  | ||||
|         req.reply(response) | ||||
|       }).as('tasks') | ||||
|     }) | ||||
|  | ||||
|     cy.visit('/tasks') | ||||
|     cy.wait('@tasks') | ||||
|   }) | ||||
|  | ||||
|   it('should show a list of dismissable tasks in tabs', () => { | ||||
|     cy.get('tbody').find('tr:visible').its('length').should('eq', 5) | ||||
|     cy.wait(500) // stabilizes the test, for some reason... | ||||
|     cy.get('tbody') | ||||
|       .find('button:visible') | ||||
|       .contains('Dismiss') | ||||
|       .first() | ||||
|       .click() | ||||
|       .wait('@tasks') | ||||
|       .wait(2000) | ||||
|       .then(() => { | ||||
|         cy.get('tbody').find('tr:visible').its('length').should('eq', 4) | ||||
|       }) | ||||
|   }) | ||||
|  | ||||
|   it('should allow toggling all tasks in list and warn on dismiss', () => { | ||||
|     cy.get('thead').find('input[type="checkbox"]').first().click() | ||||
|     cy.get('body').find('button').contains('Dismiss selected').first().click() | ||||
|     cy.contains('Confirm') | ||||
|     cy.get('.modal') | ||||
|       .contains('button', 'Dismiss') | ||||
|       .click() | ||||
|       .wait('@tasks') | ||||
|       .wait(2000) | ||||
|       .then(() => { | ||||
|         cy.get('tbody').find('tr:visible').should('not.exist') | ||||
|       }) | ||||
|   }) | ||||
| }) | ||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon