From 2eb2d99a913f4b1dcb8a2d55393e5e96794cb17b Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 9 Nov 2022 03:43:57 -0800 Subject: [PATCH] Update frontend fixtures & tests for compatibility --- src-ui/cypress/e2e/settings/settings.cy.ts | 16 +++++-- .../fixtures/mail_accounts/mail_accounts.json | 27 +++++++++++ .../fixtures/mail_rules/mail_rules.json | 29 ++++++++++++ .../fixtures/saved_views/savedviews.json | 45 ++++++++++++++++++- 4 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 src-ui/cypress/fixtures/mail_accounts/mail_accounts.json create mode 100644 src-ui/cypress/fixtures/mail_rules/mail_rules.json diff --git a/src-ui/cypress/e2e/settings/settings.cy.ts b/src-ui/cypress/e2e/settings/settings.cy.ts index 0480e39ce..7752fdf61 100644 --- a/src-ui/cypress/e2e/settings/settings.cy.ts +++ b/src-ui/cypress/e2e/settings/settings.cy.ts @@ -35,6 +35,16 @@ describe('settings', () => { req.reply(response) } ).as('savedViews') + + cy.intercept('http://localhost:8000/api/mail_accounts/*', { + fixture: 'mail_accounts/mail_accounts.json', + }) + cy.intercept('http://localhost:8000/api/mail_rules/*', { + fixture: 'mail_rules/mail_rules.json', + }).as('mailRules') + cy.intercept('http://localhost:8000/api/tasks/', { + fixture: 'tasks/tasks.json', + }) }) cy.fixture('documents/documents.json').then((documentsJson) => { @@ -48,7 +58,7 @@ describe('settings', () => { cy.viewport(1024, 1600) cy.visit('/settings') - cy.wait('@savedViews') + cy.wait('@mailRules') }) it('should activate / deactivate save button when settings change and are saved', () => { @@ -64,7 +74,7 @@ describe('settings', () => { cy.contains('a', 'Dashboard').click() cy.contains('You have unsaved changes') cy.contains('button', 'Cancel').click() - cy.contains('button', 'Save').click().wait('@savedViews') + cy.contains('button', 'Save').click().wait('@savedViews').wait(2000) cy.contains('a', 'Dashboard').click() cy.contains('You have unsaved changes').should('not.exist') }) @@ -77,7 +87,7 @@ describe('settings', () => { }) it('should remove saved view from sidebar when unset', () => { - cy.contains('a', 'Saved views').click() + cy.contains('a', 'Saved views').click().wait(2000) cy.get('#show_in_sidebar_1').click() cy.contains('button', 'Save').click().wait('@savedViews') cy.contains('li', 'Inbox').should('not.exist') diff --git a/src-ui/cypress/fixtures/mail_accounts/mail_accounts.json b/src-ui/cypress/fixtures/mail_accounts/mail_accounts.json new file mode 100644 index 000000000..19c45b15a --- /dev/null +++ b/src-ui/cypress/fixtures/mail_accounts/mail_accounts.json @@ -0,0 +1,27 @@ +{ + "count": 2, + "next": null, + "previous": null, + "results": [ + { + "id": 1, + "name": "IMAP Server", + "imap_server": "imap.example.com", + "imap_port": 993, + "imap_security": 2, + "username": "inbox@example.com", + "password": "pass", + "character_set": "UTF-8" + }, + { + "id": 2, + "name": "Gmail", + "imap_server": "imap.gmail.com", + "imap_port": 993, + "imap_security": 2, + "username": "user@gmail.com", + "password": "pass", + "character_set": "UTF-8" + } + ] +} diff --git a/src-ui/cypress/fixtures/mail_rules/mail_rules.json b/src-ui/cypress/fixtures/mail_rules/mail_rules.json new file mode 100644 index 000000000..a2c59c5c6 --- /dev/null +++ b/src-ui/cypress/fixtures/mail_rules/mail_rules.json @@ -0,0 +1,29 @@ +{ + "count": 1, + "next": null, + "previous": null, + "results": [ + { + "id": 1, + "name": "Gmail", + "account": 2, + "folder": "INBOX", + "filter_from": null, + "filter_subject": "[paperless]", + "filter_body": null, + "filter_attachment_filename": null, + "maximum_age": 30, + "action": 3, + "action_parameter": null, + "assign_title_from": 1, + "assign_tags": [ + 9 + ], + "assign_correspondent_from": 1, + "assign_correspondent": 2, + "assign_document_type": null, + "order": 0, + "attachment_type": 2 + } + ] +} diff --git a/src-ui/cypress/fixtures/saved_views/savedviews.json b/src-ui/cypress/fixtures/saved_views/savedviews.json index 003bd900a..64afcf3dc 100644 --- a/src-ui/cypress/fixtures/saved_views/savedviews.json +++ b/src-ui/cypress/fixtures/saved_views/savedviews.json @@ -1 +1,44 @@ -{"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"}]}]} +{ + "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" + } + ] + } + ] +}