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(() => { |   beforeEach(() => { | ||||||
|     this.modifiedDocuments = [] |     this.modifiedDocuments = [] | ||||||
|  |  | ||||||
|  |     cy.intercept('http://localhost:8000/api/frontend_settings/', { | ||||||
|  |       fixture: 'frontend_settings/settings.json', | ||||||
|  |     }) | ||||||
|     cy.fixture('documents/documents.json').then((documentsJson) => { |     cy.fixture('documents/documents.json').then((documentsJson) => { | ||||||
|       cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => { |       cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => { | ||||||
|         let response = { ...documentsJson } |         let response = { ...documentsJson } | ||||||
|   | |||||||
| @@ -3,6 +3,9 @@ describe('documents-list', () => { | |||||||
|     this.bulkEdits = {} |     this.bulkEdits = {} | ||||||
|  |  | ||||||
|     // mock API methods |     // mock API methods | ||||||
|  |     cy.intercept('http://localhost:8000/api/frontend_settings/', { | ||||||
|  |       fixture: 'frontend_settings/settings.json', | ||||||
|  |     }) | ||||||
|     cy.fixture('documents/documents.json').then((documentsJson) => { |     cy.fixture('documents/documents.json').then((documentsJson) => { | ||||||
|       // bulk edit |       // bulk edit | ||||||
|       cy.intercept( |       cy.intercept( | ||||||
|   | |||||||
| @@ -1,5 +1,8 @@ | |||||||
| describe('manage', () => { | describe('manage', () => { | ||||||
|   beforeEach(() => { |   beforeEach(() => { | ||||||
|  |     cy.intercept('http://localhost:8000/api/frontend_settings/', { | ||||||
|  |       fixture: 'frontend_settings/settings.json', | ||||||
|  |     }) | ||||||
|     cy.intercept('http://localhost:8000/api/correspondents/*', { |     cy.intercept('http://localhost:8000/api/correspondents/*', { | ||||||
|       fixture: 'correspondents/correspondents.json', |       fixture: 'correspondents/correspondents.json', | ||||||
|     }) |     }) | ||||||
|   | |||||||
| @@ -3,45 +3,53 @@ describe('settings', () => { | |||||||
|     this.modifiedViews = [] |     this.modifiedViews = [] | ||||||
|  |  | ||||||
|     // mock API methods |     // mock API methods | ||||||
|     cy.fixture('saved_views/savedviews.json').then((savedViewsJson) => { |     cy.intercept('http://localhost:8000/api/frontend_settings/', { | ||||||
|       // saved views PATCH |       fixture: 'frontend_settings/settings.json', | ||||||
|       cy.intercept( |     }).then(() => { | ||||||
|         'PATCH', |       cy.fixture('saved_views/savedviews.json').then((savedViewsJson) => { | ||||||
|         'http://localhost:8000/api/saved_views/*', |         // saved views PATCH | ||||||
|         (req) => { |         cy.intercept( | ||||||
|           this.modifiedViews.push(req.body) // store this for later |           'PATCH', | ||||||
|           req.reply({ result: 'OK' }) |           '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) => { |         cy.intercept( | ||||||
|         let response = { ...savedViewsJson } |           'GET', | ||||||
|         if (this.modifiedViews.length) { |           'http://localhost:8000/api/saved_views/*', | ||||||
|           response.results = response.results.map((v) => { |           (req) => { | ||||||
|             if (this.modifiedViews.find((mv) => mv.id == v.id)) |             let response = { ...savedViewsJson } | ||||||
|               v = this.modifiedViews.find((mv) => mv.id == v.id) |             if (this.modifiedViews.length) { | ||||||
|             return v |               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) |             req.reply(response) | ||||||
|       }).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/', { |       cy.fixture('documents/documents.json').then((documentsJson) => { | ||||||
|       fixture: 'documents/1/metadata.json', |         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/', { |       cy.intercept('http://localhost:8000/api/documents/1/metadata/', { | ||||||
|       fixture: 'documents/1/suggestions.json', |         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) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon