]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
use global fixtures in e2e tests 1083/head
authorMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Thu, 2 Jun 2022 22:00:41 +0000 (15:00 -0700)
committerMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Thu, 2 Jun 2022 22:00:41 +0000 (15:00 -0700)
src-ui/cypress/e2e/documents/document-detail.cy.ts
src-ui/cypress/e2e/documents/documents-list.cy.ts
src-ui/cypress/e2e/documents/query-params.cy.ts
src-ui/cypress/e2e/manage/manage.cy.ts
src-ui/cypress/e2e/settings/settings.cy.ts
src-ui/cypress/support/e2e.ts

index 8faf2412c71fc0d5cdb683c1aec0fcbcaf0b2b4e..cc269655a9385aa49ebcb778bcc09bdc64a0b4d2 100644 (file)
@@ -1,10 +1,9 @@
 describe('document-detail', () => {
   beforeEach(() => {
+    // also uses global fixtures from cypress/support/e2e.ts
+
     this.modifiedDocuments = []
 
-    cy.intercept('http://localhost:8000/api/ui_settings/', {
-      fixture: 'ui_settings/settings.json',
-    })
     cy.fixture('documents/documents.json').then((documentsJson) => {
       cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => {
         let response = { ...documentsJson }
@@ -18,30 +17,6 @@ describe('document-detail', () => {
       req.reply({ result: 'OK' })
     }).as('saveDoc')
 
-    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/saved_views/*', {
-      fixture: 'saved_views/savedviews.json',
-    })
-
-    cy.intercept('http://localhost:8000/api/tags/*', {
-      fixture: 'tags/tags.json',
-    })
-
-    cy.intercept('http://localhost:8000/api/correspondents/*', {
-      fixture: 'correspondents/correspondents.json',
-    })
-
-    cy.intercept('http://localhost:8000/api/document_types/*', {
-      fixture: 'document_types/doctypes.json',
-    })
-
     cy.viewport(1024, 1024)
     cy.visit('/documents/1/')
   })
index 6429dbc6568da944129ef523102e3f3eb29dd433..2dffe4e2430a0a383a1956af35629bfc4750d5b7 100644 (file)
@@ -1,11 +1,9 @@
 describe('documents-list', () => {
   beforeEach(() => {
+    // also uses global fixtures from cypress/support/e2e.ts
+
     this.bulkEdits = {}
 
-    // mock API methods
-    cy.intercept('http://localhost:8000/api/ui_settings/', {
-      fixture: 'ui_settings/settings.json',
-    })
     cy.fixture('documents/documents.json').then((documentsJson) => {
       // bulk edit
       cy.intercept(
@@ -56,22 +54,6 @@ describe('documents-list', () => {
       })
     })
 
-    cy.intercept('http://localhost:8000/api/documents/1/thumb/', {
-      fixture: 'documents/lorem-ipsum.png',
-    })
-
-    cy.intercept('http://localhost:8000/api/tags/*', {
-      fixture: 'tags/tags.json',
-    })
-
-    cy.intercept('http://localhost:8000/api/correspondents/*', {
-      fixture: 'correspondents/correspondents.json',
-    })
-
-    cy.intercept('http://localhost:8000/api/document_types/*', {
-      fixture: 'document_types/doctypes.json',
-    })
-
     cy.viewport(1280, 1024)
     cy.visit('/documents')
   })
index b9f6bd30c3450813fa0be6badcf38a9439a52b2e..a31e43c8a3d136fa0ce06b73161e424236888b49 100644 (file)
@@ -2,27 +2,8 @@ import { PaperlessDocument } from 'src/app/data/paperless-document'
 
 describe('documents query params', () => {
   beforeEach(() => {
-    cy.intercept('http://localhost:8000/api/ui_settings/', {
-      fixture: 'ui_settings/settings.json',
-    })
-    cy.intercept('http://localhost:8000/api/remote_version/', {
-      fixture: 'remote_version/remote_version.json',
-    })
-    cy.intercept('http://localhost:8000/api/correspondents/*', {
-      fixture: 'correspondents/correspondents.json',
-    })
-    cy.intercept('http://localhost:8000/api/document_types/*', {
-      fixture: 'document_types/doctypes.json',
-    })
-    cy.intercept('http://localhost:8000/api/saved_views/*', {
-      fixture: 'saved_views/savedviews.json',
-    })
-    cy.intercept('http://localhost:8000/api/storage_paths/*', {
-      fixture: 'storage_paths/storage_paths.json',
-    })
-    cy.intercept('http://localhost:8000/api/tags/*', {
-      fixture: 'tags/tags.json',
-    })
+    // also uses global fixtures from cypress/support/e2e.ts
+
     cy.fixture('documents/documents.json').then((documentsJson) => {
       // mock api filtering
       cy.intercept('GET', 'http://localhost:8000/api/documents/*', (req) => {
index ef7e12723abc149b084ba14c10534fe2e23004af..9e29ac1116149fabba34a50d895f4cb71ee4f330 100644 (file)
@@ -1,15 +1,5 @@
 describe('manage', () => {
-  beforeEach(() => {
-    cy.intercept('http://localhost:8000/api/ui_settings/', {
-      fixture: 'ui_settings/settings.json',
-    })
-    cy.intercept('http://localhost:8000/api/correspondents/*', {
-      fixture: 'correspondents/correspondents.json',
-    })
-    cy.intercept('http://localhost:8000/api/tags/*', {
-      fixture: 'tags/tags.json',
-    })
-  })
+  // also uses global fixtures from cypress/support/e2e.ts
 
   it('should show a list of correspondents with bottom pagination as well', () => {
     cy.visit('/correspondents')
index 16e706b6309c5145e2f9031687b8224c59fcd09c..7433d16f416b06a79a6abcbfb59367b6b2127010 100644 (file)
@@ -1,5 +1,7 @@
 describe('settings', () => {
   beforeEach(() => {
+    // also uses global fixtures from cypress/support/e2e.ts
+
     this.modifiedViews = []
 
     // mock API methods
@@ -42,14 +44,6 @@ describe('settings', () => {
           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/suggestions/', {
-        fixture: 'documents/1/suggestions.json',
-      })
     })
 
     cy.viewport(1024, 1024)
index ac293b6165aaeaf4c6102f09a5f48cb2a092f2ed..4004aa8a0c4250d34e8b8e64ed14d82939bae8e9 100644 (file)
@@ -1,17 +1,43 @@
-// ***********************************************************
-// This example support/index.js is processed and
-// loaded automatically before your test files.
-//
-// This is a great place to put global configuration and
-// behavior that modifies Cypress.
-//
-// You can change the location of this file or turn off
-// automatically serving support files with the
-// 'supportFile' configuration option.
-//
-// You can read more here:
-// https://on.cypress.io/configuration
-// ***********************************************************
-
-// When a command from ./commands is ready to use, import with `import './commands'` syntax
-// import './commands';
+// mock API methods
+
+beforeEach(() => {
+  cy.intercept('http://localhost:8000/api/ui_settings/', {
+    fixture: 'ui_settings/settings.json',
+  })
+
+  cy.intercept('http://localhost:8000/api/remote_version/', {
+    fixture: 'remote_version/remote_version.json',
+  })
+
+  cy.intercept('http://localhost:8000/api/saved_views/*', {
+    fixture: 'saved_views/savedviews.json',
+  })
+
+  cy.intercept('http://localhost:8000/api/tags/*', {
+    fixture: 'tags/tags.json',
+  })
+
+  cy.intercept('http://localhost:8000/api/correspondents/*', {
+    fixture: 'correspondents/correspondents.json',
+  })
+
+  cy.intercept('http://localhost:8000/api/document_types/*', {
+    fixture: 'document_types/doctypes.json',
+  })
+
+  cy.intercept('http://localhost:8000/api/storage_paths/*', {
+    fixture: 'storage_paths/storage_paths.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/thumb/', {
+    fixture: 'documents/lorem-ipsum.png',
+  })
+})