+++ /dev/null
-{"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"}]}]}
describe('settings', () => {
beforeEach(() => {
- cy.intercept('http://localhost:8000/api/saved_views/*', {
- fixture: 'settings/savedviews.json',
+ this.modifiedViews = []
+
+ // 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.visit('/settings')
})
it('should remove saved view from sidebar when unset', () => {
cy.contains('a', 'Saved views').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('li', 'Inbox').should('not.exist')
})
it('should remove saved view from dashboard when unset', () => {
cy.contains('a', 'Saved views').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.visit('/dashboard')
cy.get('app-saved-view-widget').contains('Inbox').should('not.exist')