diff --git a/cypress/fixtures/test-docx.docx b/cypress/fixtures/test-docx.docx new file mode 100644 index 0000000000000000000000000000000000000000..6f3f7405cb9f05c6da4240e8ef32ad7343300643 Binary files /dev/null and b/cypress/fixtures/test-docx.docx differ diff --git a/cypress/fixtures/test-pdf.pdf b/cypress/fixtures/test-pdf.pdf new file mode 100644 index 0000000000000000000000000000000000000000..b63b75f63afb063f9cf3c01c7cb11ac14d653557 Binary files /dev/null and b/cypress/fixtures/test-pdf.pdf differ diff --git a/cypress/integration/upload_spec.js b/cypress/integration/upload_spec.js new file mode 100644 index 0000000000000000000000000000000000000000..5e86228c9c592e1e1fecd7db54ce015a124c1516 --- /dev/null +++ b/cypress/integration/upload_spec.js @@ -0,0 +1,22 @@ +describe('PDF submission test', () => { + it('can upload and submit a PDF', () => { + cy.visit('/dashboard') + + const username = 'admin' + const password = 'password' + + cy.get('input[name="username"]').type(username) + cy.get('input[name="password"]').type(password) + cy.get('button[type="submit"]').click() + + cy.fixture('test-pdf.pdf', 'base64').then(fileContent => { + cy.get('[data-testid="dropzone"]').upload( + { fileContent, fileName: 'test-pdf.pdf', mimeType: 'application/pdf' }, + { subjectType: 'drag-n-drop' }, + ) + }) + + cy.get('body').contains('Submission information') + cy.get('[data-testid="meta.title"]').contains('test pdf') + }) +}) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index ca4d256f3eb15dfabad1f5760c9b2d0ceb4c24b9..fc10dd90c315d16d2eea13e6b9399a1a46878528 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -1,3 +1,5 @@ +import 'cypress-file-upload' + // *********************************************** // This example commands.js shows you how to // create various custom commands and overwrite diff --git a/package.json b/package.json index 44fa17a3a87fc54f76dcb30cdea59142bd2ca4c8..25f8ea61baceb15ae059bde8e80cbff550b6b769 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "copy-webpack-plugin": "^4.0.1", "css-loader": "^0.28.4", "cypress": "^3.7.0", + "cypress-file-upload": "^3.5.0", "eslint": "^4.12.0", "eslint-config-pubsweet": "^0.0.6", "eslint-plugin-import": "^2.8.0",