mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	update e2e tests for settings initialization
This commit is contained in:
		
							
								
								
									
										29
									
								
								src-ui/cypress/fixtures/frontend_settings/settings.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src-ui/cypress/fixtures/frontend_settings/settings.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| { | ||||
|     "bulk_edit": { | ||||
|         "apply_on_close": false, | ||||
|         "confirmation_dialogs": true | ||||
|     }, | ||||
|     "dark_mode": { | ||||
|         "enabled": "false", | ||||
|         "thumb_inverted": "true", | ||||
|         "use_system": true | ||||
|     }, | ||||
|     "date_display": { | ||||
|         "date_format": "mediumDate", | ||||
|         "date_locale": "" | ||||
|     }, | ||||
|     "documentListSize": 50, | ||||
|     "document_details": { | ||||
|         "native_pdf_viewer": false | ||||
|     }, | ||||
|     "language": "", | ||||
|     "notifications": { | ||||
|         "consumer_failed": true, | ||||
|         "consumer_new_documents": true, | ||||
|         "consumer_success": true, | ||||
|         "consumer_suppress_on_dashboard": true | ||||
|     }, | ||||
|     "theme": { | ||||
|         "color": "#cd42cf" | ||||
|     } | ||||
| } | ||||
| @@ -2,6 +2,9 @@ describe('document-detail', () => { | ||||
|   beforeEach(() => { | ||||
|     this.modifiedDocuments = [] | ||||
|  | ||||
|     cy.intercept('http://localhost:8000/api/frontend_settings/', { | ||||
|       fixture: 'frontend_settings/settings.json', | ||||
|     }) | ||||
|     cy.fixture('documents/documents.json').then((documentsJson) => { | ||||
|       cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => { | ||||
|         let response = { ...documentsJson } | ||||
|   | ||||
| @@ -3,6 +3,9 @@ describe('documents-list', () => { | ||||
|     this.bulkEdits = {} | ||||
|  | ||||
|     // mock API methods | ||||
|     cy.intercept('http://localhost:8000/api/frontend_settings/', { | ||||
|       fixture: 'frontend_settings/settings.json', | ||||
|     }) | ||||
|     cy.fixture('documents/documents.json').then((documentsJson) => { | ||||
|       // bulk edit | ||||
|       cy.intercept( | ||||
|   | ||||
| @@ -1,5 +1,8 @@ | ||||
| describe('manage', () => { | ||||
|   beforeEach(() => { | ||||
|     cy.intercept('http://localhost:8000/api/frontend_settings/', { | ||||
|       fixture: 'frontend_settings/settings.json', | ||||
|     }) | ||||
|     cy.intercept('http://localhost:8000/api/correspondents/*', { | ||||
|       fixture: 'correspondents/correspondents.json', | ||||
|     }) | ||||
|   | ||||
| @@ -3,45 +3,53 @@ describe('settings', () => { | ||||
|     this.modifiedViews = [] | ||||
|  | ||||
|     // mock API methods | ||||
|     cy.fixture('saved_views/savedviews.json').then((savedViewsJson) => { | ||||
|       // saved views PATCH | ||||
|       cy.intercept( | ||||
|         'PATCH', | ||||
|         'http://localhost:8000/api/saved_views/*', | ||||
|         (req) => { | ||||
|           this.modifiedViews.push(req.body) // store this for later | ||||
|           req.reply({ result: 'OK' }) | ||||
|         } | ||||
|       ) | ||||
|     cy.intercept('http://localhost:8000/api/frontend_settings/', { | ||||
|       fixture: 'frontend_settings/settings.json', | ||||
|     }).then(() => { | ||||
|       cy.fixture('saved_views/savedviews.json').then((savedViewsJson) => { | ||||
|         // saved views PATCH | ||||
|         cy.intercept( | ||||
|           'PATCH', | ||||
|           'http://localhost:8000/api/saved_views/*', | ||||
|           (req) => { | ||||
|             this.modifiedViews.push(req.body) // store this for later | ||||
|             req.reply({ result: 'OK' }) | ||||
|           } | ||||
|         ) | ||||
|  | ||||
|       cy.intercept('GET', 'http://localhost:8000/api/saved_views/*', (req) => { | ||||
|         let response = { ...savedViewsJson } | ||||
|         if (this.modifiedViews.length) { | ||||
|           response.results = response.results.map((v) => { | ||||
|             if (this.modifiedViews.find((mv) => mv.id == v.id)) | ||||
|               v = this.modifiedViews.find((mv) => mv.id == v.id) | ||||
|             return v | ||||
|           }) | ||||
|         } | ||||
|         cy.intercept( | ||||
|           'GET', | ||||
|           'http://localhost:8000/api/saved_views/*', | ||||
|           (req) => { | ||||
|             let response = { ...savedViewsJson } | ||||
|             if (this.modifiedViews.length) { | ||||
|               response.results = response.results.map((v) => { | ||||
|                 if (this.modifiedViews.find((mv) => mv.id == v.id)) | ||||
|                   v = this.modifiedViews.find((mv) => mv.id == v.id) | ||||
|                 return v | ||||
|               }) | ||||
|             } | ||||
|  | ||||
|         req.reply(response) | ||||
|       }).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) | ||||
|             req.reply(response) | ||||
|           } | ||||
|         ).as('savedViews') | ||||
|       }) | ||||
|     }) | ||||
|  | ||||
|     cy.intercept('http://localhost:8000/api/documents/1/metadata/', { | ||||
|       fixture: 'documents/1/metadata.json', | ||||
|     }) | ||||
|       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/suggestions/', { | ||||
|       fixture: 'documents/1/suggestions.json', | ||||
|       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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon