diff --git a/src-ui/cypress/fixtures/settings/savedviews.json b/src-ui/cypress/fixtures/settings/savedviews.json new file mode 100644 index 000000000..003bd900a --- /dev/null +++ b/src-ui/cypress/fixtures/settings/savedviews.json @@ -0,0 +1 @@ +{"count":3,"next":null,"previous":null,"results":[{"id":1,"name":"Inbox","show_on_dashboard":true,"show_in_sidebar":true,"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"}]}]} diff --git a/src-ui/cypress/fixtures/settings/savedviews_saved.json b/src-ui/cypress/fixtures/settings/savedviews_saved.json new file mode 100644 index 000000000..486f0dd1d --- /dev/null +++ b/src-ui/cypress/fixtures/settings/savedviews_saved.json @@ -0,0 +1 @@ +{"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"}]}]} diff --git a/src-ui/cypress/integration/settings.spec.ts b/src-ui/cypress/integration/settings.spec.ts new file mode 100644 index 000000000..d61d70b19 --- /dev/null +++ b/src-ui/cypress/integration/settings.spec.ts @@ -0,0 +1,55 @@ +describe('settings', () => { + beforeEach(() => { + cy.intercept('http://localhost:8000/api/saved_views/*', { + fixture: 'settings/savedviews.json', + }) + cy.viewport(1024, 1024) + cy.visit('/settings') + }) + + it('should activate / deactivate save button when settings change and are saved', () => { + cy.contains('button', 'Save').should('be.disabled') + cy.contains('Use system settings').click() + cy.contains('button', 'Save').should('not.be.disabled') + cy.contains('button', 'Save').click() + cy.contains('button', 'Save').should('be.disabled') + }) + + it('should warn on unsaved changes', () => { + cy.contains('Use system settings').click() + cy.contains('a', 'Dashboard').click() + cy.contains('You have unsaved changes') + cy.contains('button', 'Cancel').click() + cy.contains('button', 'Save').click() + cy.visit('/dashboard') + cy.contains('You have unsaved changes').should('not.exist') + }) + + it('should apply appearance changes when set', () => { + cy.contains('Use system settings').click() + cy.get('body').should('not.have.class', 'color-scheme-system') + cy.contains('Enable dark mode').click() + cy.get('body').should('have.class', 'color-scheme-dark') + }) + + 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') + }) +})