mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-31 10:37:12 -04:00 
			
		
		
		
	Add frontend testing of multi-object filtering
This commit is contained in:
		
							parent
							
								
									00e17f4d69
								
							
						
					
					
						commit
						adb956467b
					
				| @ -48,6 +48,26 @@ describe('documents-list', () => { | |||||||
|             (d.tags as Array<number>).includes(tag_id) |             (d.tags as Array<number>).includes(tag_id) | ||||||
|           ) |           ) | ||||||
|           response.count = response.results.length |           response.count = response.results.length | ||||||
|  |         } else if (req.query.hasOwnProperty('correspondent__id__in')) { | ||||||
|  |           // filtering e.g. http://localhost:8000/api/documents/?page=1&page_size=50&ordering=-created&correspondent__id__in=9,14
 | ||||||
|  |           const correspondent_ids = req.query['correspondent__id__in'] | ||||||
|  |             .toString() | ||||||
|  |             .split(',') | ||||||
|  |             .map((c) => +c) | ||||||
|  |           response.results = (documentsJson.results as Array<any>).filter((d) => | ||||||
|  |             correspondent_ids.includes(d.correspondent) | ||||||
|  |           ) | ||||||
|  |           response.count = response.results.length | ||||||
|  |         } else if (req.query.hasOwnProperty('correspondent__id__none')) { | ||||||
|  |           // filtering e.g. http://localhost:8000/api/documents/?page=1&page_size=50&ordering=-created&correspondent__id__none=9,14
 | ||||||
|  |           const correspondent_ids = req.query['correspondent__id__none'] | ||||||
|  |             .toString() | ||||||
|  |             .split(',') | ||||||
|  |             .map((c) => +c) | ||||||
|  |           response.results = (documentsJson.results as Array<any>).filter( | ||||||
|  |             (d) => !correspondent_ids.includes(d.correspondent) | ||||||
|  |           ) | ||||||
|  |           response.count = response.results.length | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         req.reply(response) |         req.reply(response) | ||||||
| @ -112,6 +132,27 @@ describe('documents-list', () => { | |||||||
|     cy.contains('One document') |     cy.contains('One document') | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|  |   it('should filter including multiple correspondents', () => { | ||||||
|  |     cy.get('app-filter-editor app-filterable-dropdown[title="Correspondent"]') | ||||||
|  |       .click() | ||||||
|  |       .within(() => { | ||||||
|  |         cy.contains('button', 'ABC Test Correspondent').click() | ||||||
|  |         cy.contains('button', 'Corresp 11').click() | ||||||
|  |       }) | ||||||
|  |     cy.contains('3 documents') | ||||||
|  |   }) | ||||||
|  | 
 | ||||||
|  |   it('should filter excluding multiple correspondents', () => { | ||||||
|  |     cy.get('app-filter-editor app-filterable-dropdown[title="Correspondent"]') | ||||||
|  |       .click() | ||||||
|  |       .within(() => { | ||||||
|  |         cy.contains('button', 'ABC Test Correspondent').click() | ||||||
|  |         cy.contains('button', 'Corresp 11').click() | ||||||
|  |         cy.contains('label', 'Exclude').click() | ||||||
|  |       }) | ||||||
|  |     cy.contains('One document') | ||||||
|  |   }) | ||||||
|  | 
 | ||||||
|   it('should apply tags', () => { |   it('should apply tags', () => { | ||||||
|     cy.get('app-document-card-small:first-of-type').click() |     cy.get('app-document-card-small:first-of-type').click() | ||||||
|     cy.get('app-bulk-editor app-filterable-dropdown[title="Tags"]').within( |     cy.get('app-bulk-editor app-filterable-dropdown[title="Tags"]').within( | ||||||
|  | |||||||
| @ -232,6 +232,11 @@ describe('documents query params', () => { | |||||||
| 
 | 
 | ||||||
|   it('should show a list of documents filtered by document type', () => { |   it('should show a list of documents filtered by document type', () => { | ||||||
|     cy.visit('/documents?sort=created&reverse=true&document_type__id=1') |     cy.visit('/documents?sort=created&reverse=true&document_type__id=1') | ||||||
|  |     cy.contains('2 documents') | ||||||
|  |   }) | ||||||
|  | 
 | ||||||
|  |   it('should show a list of documents filtered by multiple correspondents', () => { | ||||||
|  |     cy.visit('/documents?sort=created&reverse=true&document_type__id__in=1,2') | ||||||
|     cy.contains('3 documents') |     cy.contains('3 documents') | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
| @ -245,9 +250,14 @@ describe('documents query params', () => { | |||||||
|     cy.contains('2 documents') |     cy.contains('2 documents') | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|  |   it('should show a list of documents filtered by multiple correspondents', () => { | ||||||
|  |     cy.visit('/documents?sort=created&reverse=true&correspondent__id__in=9,14') | ||||||
|  |     cy.contains('3 documents') | ||||||
|  |   }) | ||||||
|  | 
 | ||||||
|   it('should show a list of documents filtered by no correspondent', () => { |   it('should show a list of documents filtered by no correspondent', () => { | ||||||
|     cy.visit('/documents?sort=created&reverse=true&correspondent__isnull=1') |     cy.visit('/documents?sort=created&reverse=true&correspondent__isnull=1') | ||||||
|     cy.contains('2 documents') |     cy.contains('One document') | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|   it('should show a list of documents filtered by storage path', () => { |   it('should show a list of documents filtered by storage path', () => { | ||||||
|  | |||||||
| @ -1 +1,257 @@ | |||||||
| {"count":27,"next":"http://localhost:8000/api/correspondents/?page=2","previous":null,"results":[{"id":9,"slug":"abc-test-correspondent","name":"ABC Test Correspondent","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":13,"slug":"corresp-10","name":"Corresp 10","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":14,"slug":"corresp-11","name":"Corresp 11","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":15,"slug":"corresp-12","name":"Corresp 12","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":16,"slug":"corresp-13","name":"Corresp 13","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":18,"slug":"corresp-15","name":"Corresp 15","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":19,"slug":"corresp-16","name":"Corresp 16","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":20,"slug":"corresp-17","name":"Corresp 17","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":21,"slug":"corresp-18","name":"Corresp 18","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":22,"slug":"corresp-19","name":"Corresp 19","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":23,"slug":"corresp-20","name":"Corresp 20","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":24,"slug":"corresp-21","name":"Corresp 21","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":25,"slug":"corresp-22","name":"Corresp 22","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":26,"slug":"corresp-23","name":"Corresp 23","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":5,"slug":"corresp-3","name":"Corresp 3","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":6,"slug":"corresp-4","name":"Corresp 4","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":7,"slug":"corresp-5","name":"Corresp 5","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":8,"slug":"corresp-6","name":"Corresp 6","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":10,"slug":"corresp-7","name":"Corresp 7","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":11,"slug":"corresp-8","name":"Corresp 8","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":12,"slug":"corresp-9","name":"Corresp 9","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":17,"slug":"correspondent-14","name":"Correspondent 14","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0,"last_correspondence":null},{"id":2,"slug":"correspondent-2","name":"Correspondent 2","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":7,"last_correspondence":"2021-01-20T23:37:58.204614Z"},{"id":27,"slug":"michael-shamoon","name":"Michael Shamoon","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":1,"last_correspondence":"2022-03-16T03:48:50.089624Z"},{"id":4,"slug":"newest-correspondent","name":"Newest Correspondent","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":1,"last_correspondence":"2021-02-07T08:00:00Z"}]} | { | ||||||
|  |     "count": 27, | ||||||
|  |     "next": "http://localhost:8000/api/correspondents/?page=2", | ||||||
|  |     "previous": null, | ||||||
|  |     "results": [ | ||||||
|  |         { | ||||||
|  |             "id": 9, | ||||||
|  |             "slug": "abc-test-correspondent", | ||||||
|  |             "name": "ABC Test Correspondent", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 13, | ||||||
|  |             "slug": "corresp-10", | ||||||
|  |             "name": "Corresp 10", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 14, | ||||||
|  |             "slug": "corresp-11", | ||||||
|  |             "name": "Corresp 11", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 15, | ||||||
|  |             "slug": "corresp-12", | ||||||
|  |             "name": "Corresp 12", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 16, | ||||||
|  |             "slug": "corresp-13", | ||||||
|  |             "name": "Corresp 13", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 18, | ||||||
|  |             "slug": "corresp-15", | ||||||
|  |             "name": "Corresp 15", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 19, | ||||||
|  |             "slug": "corresp-16", | ||||||
|  |             "name": "Corresp 16", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 20, | ||||||
|  |             "slug": "corresp-17", | ||||||
|  |             "name": "Corresp 17", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 21, | ||||||
|  |             "slug": "corresp-18", | ||||||
|  |             "name": "Corresp 18", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 22, | ||||||
|  |             "slug": "corresp-19", | ||||||
|  |             "name": "Corresp 19", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 23, | ||||||
|  |             "slug": "corresp-20", | ||||||
|  |             "name": "Corresp 20", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 24, | ||||||
|  |             "slug": "corresp-21", | ||||||
|  |             "name": "Corresp 21", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 25, | ||||||
|  |             "slug": "corresp-22", | ||||||
|  |             "name": "Corresp 22", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 26, | ||||||
|  |             "slug": "corresp-23", | ||||||
|  |             "name": "Corresp 23", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 5, | ||||||
|  |             "slug": "corresp-3", | ||||||
|  |             "name": "Corresp 3", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 6, | ||||||
|  |             "slug": "corresp-4", | ||||||
|  |             "name": "Corresp 4", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 7, | ||||||
|  |             "slug": "corresp-5", | ||||||
|  |             "name": "Corresp 5", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 8, | ||||||
|  |             "slug": "corresp-6", | ||||||
|  |             "name": "Corresp 6", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 10, | ||||||
|  |             "slug": "corresp-7", | ||||||
|  |             "name": "Corresp 7", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 11, | ||||||
|  |             "slug": "corresp-8", | ||||||
|  |             "name": "Corresp 8", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 12, | ||||||
|  |             "slug": "corresp-9", | ||||||
|  |             "name": "Corresp 9", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 17, | ||||||
|  |             "slug": "correspondent-14", | ||||||
|  |             "name": "Correspondent 14", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 0, | ||||||
|  |             "last_correspondence": null | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 2, | ||||||
|  |             "slug": "correspondent-2", | ||||||
|  |             "name": "Correspondent 2", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 7, | ||||||
|  |             "last_correspondence": "2021-01-20T23:37:58.204614Z" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 27, | ||||||
|  |             "slug": "correspondent-slug", | ||||||
|  |             "name": "Correspondent Slug", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 1, | ||||||
|  |             "last_correspondence": "2022-03-16T03:48:50.089624Z" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 4, | ||||||
|  |             "slug": "newest-correspondent", | ||||||
|  |             "name": "Newest Correspondent", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 1, | ||||||
|  |             "last_correspondence": "2021-02-07T08:00:00Z" | ||||||
|  |         } | ||||||
|  |     ] | ||||||
|  | } | ||||||
|  | |||||||
| @ -1 +1,25 @@ | |||||||
| {"count":1,"next":null,"previous":null,"results":[{"id":1,"slug":"test","name":"Test Doc Type","match":"","matching_algorithm":1,"is_insensitive":true,"document_count":0}]} | { | ||||||
|  |     "count": 2, | ||||||
|  |     "next": null, | ||||||
|  |     "previous": null, | ||||||
|  |     "results": [ | ||||||
|  |         { | ||||||
|  |             "id": 1, | ||||||
|  |             "slug": "test", | ||||||
|  |             "name": "Test Doc Type", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 1 | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             "id": 2, | ||||||
|  |             "slug": "test2", | ||||||
|  |             "name": "Test Doc Type 2", | ||||||
|  |             "match": "", | ||||||
|  |             "matching_algorithm": 1, | ||||||
|  |             "is_insensitive": true, | ||||||
|  |             "document_count": 1 | ||||||
|  |         } | ||||||
|  |     ] | ||||||
|  | } | ||||||
|  | |||||||
| @ -43,7 +43,7 @@ | |||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             "id": 3, |             "id": 3, | ||||||
|             "correspondent": null, |             "correspondent": 14, | ||||||
|             "document_type": 1, |             "document_type": 1, | ||||||
|             "storage_path": null, |             "storage_path": null, | ||||||
|             "title": "dolor", |             "title": "dolor", | ||||||
| @ -64,7 +64,7 @@ | |||||||
|         { |         { | ||||||
|             "id": 4, |             "id": 4, | ||||||
|             "correspondent": 9, |             "correspondent": 9, | ||||||
|             "document_type": 1, |             "document_type": 2, | ||||||
|             "storage_path": null, |             "storage_path": null, | ||||||
|             "title": "sit amet", |             "title": "sit amet", | ||||||
|             "content": "Test document PDF", |             "content": "Test document PDF", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user