Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

update e2e tests for settings initialization

Michael Shamoonb2307d911eb1
diff --git a/src-ui/cypress/fixtures/frontend_settings/settings.json b/src-ui/cypress/fixtures/frontend_settings/settings.json
new file mode 100644
index 000000000..9a92ba410
--- /dev/null
+++ b/src-ui/cypress/fixtures/frontend_settings/settings.json
@@ -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"
+ }
+}
diff --git a/src-ui/cypress/integration/document-detail.spec.ts b/src-ui/cypress/integration/document-detail.spec.ts
index 9ff566760..7083ef582 100644
--- a/src-ui/cypress/integration/document-detail.spec.ts
+++ b/src-ui/cypress/integration/document-detail.spec.ts
@@ -2,6 +2,9 @@ describe('document-detail', () => {
beforeEach(() => {
this.modifiedDocuments = []
+ cy.intercept('http://localhost:8000/api/frontend_settings/', {
+ fixture: 'frontend_settings/settings.json',
+ })
cy.fixture('documents/documents.json').then((documentsJson) => {
cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => {
let response = { ...documentsJson }
diff --git a/src-ui/cypress/integration/documents-list.spec.ts b/src-ui/cypress/integration/documents-list.spec.ts
index 5b923ed2f..45d292fc7 100644
--- a/src-ui/cypress/integration/documents-list.spec.ts
+++ b/src-ui/cypress/integration/documents-list.spec.ts
@@ -3,6 +3,9 @@ describe('documents-list', () => {
this.bulkEdits = {}
// mock API methods
+ cy.intercept('http://localhost:8000/api/frontend_settings/', {
+ fixture: 'frontend_settings/settings.json',
+ })
cy.fixture('documents/documents.json').then((documentsJson) => {
// bulk edit
cy.intercept(
diff --git a/src-ui/cypress/integration/manage.spec.ts b/src-ui/cypress/integration/manage.spec.ts
index e28556a24..b098ea6a5 100644
--- a/src-ui/cypress/integration/manage.spec.ts
+++ b/src-ui/cypress/integration/manage.spec.ts
@@ -1,5 +1,8 @@
describe('manage', () => {
beforeEach(() => {
+ cy.intercept('http://localhost:8000/api/frontend_settings/', {
+ fixture: 'frontend_settings/settings.json',
+ })
cy.intercept('http://localhost:8000/api/correspondents/*', {
fixture: 'correspondents/correspondents.json',
})
diff --git a/src-ui/cypress/integration/settings.spec.ts b/src-ui/cypress/integration/settings.spec.ts
index 72f9835f2..8350ae035 100644
--- a/src-ui/cypress/integration/settings.spec.ts
+++ b/src-ui/cypress/integration/settings.spec.ts
@@ -3,45 +3,53 @@ describe('settings', () => {
this.modifiedViews = []
// mock API methods
- cy.fixture('saved_views/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('http://localhost:8000/api/frontend_settings/', {
+ fixture: 'frontend_settings/settings.json',
+ }).then(() => {
+ cy.fixture('saved_views/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
- })
- }
+ 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)
- }).as('savedViews')
- })
+ req.reply(response)
+ }
+ ).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.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/', {
- fixture: 'documents/1/metadata.json',
- })
+ cy.intercept('http://localhost:8000/api/documents/1/metadata/', {
+ fixture: 'documents/1/metadata.json',
+ })
- cy.intercept('http://localhost:8000/api/documents/1/suggestions/', {
- fixture: 'documents/1/suggestions.json',
+ cy.intercept('http://localhost:8000/api/documents/1/suggestions/', {
+ fixture: 'documents/1/suggestions.json',
+ })
})
cy.viewport(1024, 1024)