mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Mock some API methods in settings spec
This commit is contained in:
		| @@ -1 +0,0 @@ | |||||||
| {"count":3,"next":null,"previous":null,"results":[{"id":1,"name":"Inbox","show_on_dashboard":false,"show_in_sidebar":false,"sort_field":"created","sort_reverse":true,"filter_rules":[{"rule_type":6,"value":"18"}]},{"id":2,"name":"Recently Added","show_on_dashboard":true,"show_in_sidebar":false,"sort_field":"created","sort_reverse":true,"filter_rules":[]},{"id":11,"name":"Taxes","show_on_dashboard":false,"show_in_sidebar":true,"sort_field":"created","sort_reverse":true,"filter_rules":[{"rule_type":6,"value":"39"}]}]} |  | ||||||
| @@ -1,8 +1,33 @@ | |||||||
| describe('settings', () => { | describe('settings', () => { | ||||||
|   beforeEach(() => { |   beforeEach(() => { | ||||||
|     cy.intercept('http://localhost:8000/api/saved_views/*', { |     this.modifiedViews = [] | ||||||
|       fixture: 'settings/savedviews.json', |  | ||||||
|  |     // mock API methods | ||||||
|  |     cy.fixture('settings/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 | ||||||
|           }) |           }) | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         req.reply(response) | ||||||
|  |       }) | ||||||
|  |     }) | ||||||
|  |  | ||||||
|     cy.viewport(1024, 1024) |     cy.viewport(1024, 1024) | ||||||
|     cy.visit('/settings') |     cy.visit('/settings') | ||||||
|   }) |   }) | ||||||
| @@ -35,9 +60,6 @@ describe('settings', () => { | |||||||
|   it('should remove saved view from sidebar when unset', () => { |   it('should remove saved view from sidebar when unset', () => { | ||||||
|     cy.contains('a', 'Saved views').click() |     cy.contains('a', 'Saved views').click() | ||||||
|     cy.get('#show_in_sidebar_1').click() |     cy.get('#show_in_sidebar_1').click() | ||||||
|     cy.intercept('http://localhost:8000/api/saved_views/*', { |  | ||||||
|       fixture: 'settings/savedviews_saved.json', |  | ||||||
|     }) |  | ||||||
|     cy.contains('button', 'Save').click() |     cy.contains('button', 'Save').click() | ||||||
|     cy.contains('li', 'Inbox').should('not.exist') |     cy.contains('li', 'Inbox').should('not.exist') | ||||||
|   }) |   }) | ||||||
| @@ -45,9 +67,6 @@ describe('settings', () => { | |||||||
|   it('should remove saved view from dashboard when unset', () => { |   it('should remove saved view from dashboard when unset', () => { | ||||||
|     cy.contains('a', 'Saved views').click() |     cy.contains('a', 'Saved views').click() | ||||||
|     cy.get('#show_on_dashboard_1').click() |     cy.get('#show_on_dashboard_1').click() | ||||||
|     cy.intercept('http://localhost:8000/api/saved_views/*', { |  | ||||||
|       fixture: 'settings/savedviews_saved.json', |  | ||||||
|     }) |  | ||||||
|     cy.contains('button', 'Save').click() |     cy.contains('button', 'Save').click() | ||||||
|     cy.visit('/dashboard') |     cy.visit('/dashboard') | ||||||
|     cy.get('app-saved-view-widget').contains('Inbox').should('not.exist') |     cy.get('app-saved-view-widget').contains('Inbox').should('not.exist') | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon