diff --git a/test/author.test.js b/test/author.test.js deleted file mode 100644 index 58a32e12caffee5d45d50fcec00292ccee6a2bbb..0000000000000000000000000000000000000000 --- a/test/author.test.js +++ /dev/null @@ -1,142 +0,0 @@ -import config from 'config' -import { Selector } from 'testcafe' -import { createSubmission } from './helpers/submission' -import { startServer, setup, teardown } from './helpers/setup' -import { setupWithTwoUnsubmittedManuscripts } from './fixtures/manuscript-setup/setup-two-unsubmitted' -import { login, dashboard, submission, confirmation } from './pageObjects' - -const goodInkConfig = { - inkEndpoint: 'http://inkdemo-api.coko.foundation/', - email: 'editoria@coko.foundation', - password: 'editoria', - recipes: { - 'editoria-typescript': '2', - }, -} - -let author - -fixture - .only('Author user') - .before(async () => { - config['pubsweet-component-ink-backend'] = goodInkConfig - await startServer() - }) - .afterEach(teardown) - -test.skip - .before(async t => { - const result = await setup() - author = result.userData - await login.doLogin(author.username, author.password) - })('create new submission', async t => { - await t.expect(Selector(dashboard.mySubmissionsTitle).exists).notOk() - - await createSubmission('./fixtures/testSubmission1.docx') - - await t.click(dashboard.collabraHome) - - await t - .expect(Selector(dashboard.submissionStatus(1)).exists) - .ok() - .expect(dashboard.submissionStatus(1).innerText) - .contains('UNSUBMITTED') - .expect(Selector(dashboard.submissionSummaryInfoLink(0)).exists) - .ok() - }) - .after(async t => { - teardown() - }) - -test - .before(async t => { - const result = await setup() - author = result.userData - await login.doLogin(author.username, author.password) - })('Failed new submission', async t => { - await t - .setFilesToUpload(dashboard.createSubmission, ['./testSubmission1.docx']) - .expect(await Selector('div').withText('Internal Server Error').exists) - await t.expect(dashboard.createSubmission).exists - }) - .after(async t => { - config.util.extendDeep( - {}, - JSON.parse(JSON.stringify(config.get('pubsweet-component-ink-backend'))), - JSON.parse(JSON.stringify(config.get('pubsweet-component-ink-backend'))), - ) - teardown() - }) - -test.skip - .before(async t => { - await setupWithTwoUnsubmittedManuscripts() - await login.doLogin('john', 'johnjohn') - })('Author submits manuscript', async t => { - await t - .wait(1000) - .click(dashboard.submissionSummaryInfoLink(1)) - .wait(1000) - .click(submission.submit.withText('SUBMIT YOUR MANUSCRIPT')) - .wait(1000) - .expect(confirmation.returnToSubmission.exists) - - await t.wait(500).click(confirmation.returnToSubmission) - - await t - .wait(500) - .expect( - Selector(submission.submit.withText('SUBMIT YOUR MANUSCRIPT')).exists, - ) - .ok() - - await t.click(submission.submit.withText('SUBMIT YOUR MANUSCRIPT')) - - await t - .wait(1000) - .expect(confirmation.submitManuscript.exists) - .ok() - - await t.wait(1000).click(confirmation.submitManuscript) - - await t - .expect(Selector(dashboard.myManuscriptsTitle).exists) // fails when admin user == false - .ok() - - await t - .expect(Selector(dashboard.manuscript(1)).exists) - .ok() - .expect(Selector(dashboard.manuscriptStatus(1)).exists) - .ok() - .expect(dashboard.manuscriptStatus(1).innerText) - .contains('SUBMITTED') - - .expect(Selector(dashboard.submissionStatus(1, 2)).exists) - .ok() - .expect(dashboard.submissionStatus(1, 2).innerText) - .contains('UNSUBMITTED') - - await t - .expect(Selector(dashboard.submissionStatus(1)).exists) - .ok() - .expect(dashboard.submissionStatus(1).innerText) - .contains('SUBMITTED') - .wait(5000) - - await t - .expect(Selector(dashboard.submissionSummaryInfoLink(2)).exists) - .ok() - .click(dashboard.submissionSummaryInfoLink(2)) - .wait(5000) - .expect(Selector(submission.authorFirstName).exists) - .ok() - - await t - .expect( - Selector(submission.submit.withText('submit your manuscript')).exists, - ) - .notOk() - }) - .after(async t => { - teardown() - }) diff --git a/test/authsome/index.test.js b/test/authsome/index.test.js deleted file mode 100644 index d6056b2ee6ff6e73559e834ab1ab19cb4c5d6afb..0000000000000000000000000000000000000000 --- a/test/authsome/index.test.js +++ /dev/null @@ -1,151 +0,0 @@ -const Authsome = require('authsome') - -const authsomeConfig = require('config').get('authsome') - -const collections = [ - { - id: 'collection1', - fragments: ['fragment1'], - }, - { - id: 'collection2', - fragments: [], - }, -] - -const teams = [ - { - id: 'team1', - role: 'handlingEditor', - object: { - id: 'collection2', - type: 'collection', - }, - }, - { - id: 'team2', - role: 'seniorEditor', - object: { - id: 'collection1', - type: 'collection', - }, - }, - { - id: 'team3', - role: 'managingEditor', - object: { - id: 'collection1', - type: 'collection', - }, - }, - { - id: 'team4', - role: 'reviewer', - object: { - id: 'fragment1', - type: 'fragment', - }, - }, - { - id: 'team5', - role: 'managingEditor', - object: { - id: 'collection2', - type: 'collection', - }, - }, -] - -const users = [ - { - id: 'user1', - username: 'handlingEditor1', - teams: ['team1'], - }, - { - id: 'user2', - username: 'seniorEditor1', - teams: ['team2'], - }, - { - id: 'user3', - username: 'managingEditor1', - teams: ['team3', 'team5'], - }, - { - id: 'user4', - username: 'reviewerEditor1', - teams: ['team4'], - }, - { - id: 'adminId', - username: 'admin', - admin: true, - }, -] - -const authsome = new Authsome( - { ...authsomeConfig, mode: require('../../config/authsome.js') }, - { - models: { - User: { find: id => users.find(user => user.id === id) }, - Team: { find: id => teams.find(team => team.id === id) }, - }, - }, -) - -describe('admin', () => { - it('allows everything to an admin', async () => { - const permission = await authsome.can( - 'adminId', - 'DELETE', - 'thisSensitiveThing', - ) - expect(permission).toBe(true) - }) -}) - -describe('Handling Editor', () => { - it('lists only collections where user is a member of the handling editors team', async () => { - const permission = await authsome.can('user1', 'GET', { - path: '/collections', - }) - - const filteredCollections = await permission.filter(collections) - - expect(filteredCollections).toEqual([collections[1]]) - }) -}) - -describe('Reviewer Editor', () => { - it('lists only collections where user is a member of the reviewer editors team', async () => { - const permission = await authsome.can('user4', 'GET', { - path: '/collections', - }) - - const filteredCollections = await permission.filter(collections) - - expect(filteredCollections).toEqual([collections[0]]) - }) -}) - -describe('Senior Editor', () => { - it('lists only collections where user is a member of the senior editors team', async () => { - const permission = await authsome.can('user2', 'GET', { - path: '/collections', - }) - const filteredCollections = await permission.filter(collections) - expect(filteredCollections).toEqual([collections[0]]) - }) -}) - -describe('Managing Editor', () => { - it('can list all collections', async () => { - const permission = await authsome.can('user3', 'GET', { - path: '/collections', - }) - const filteredCollections = await permission.filter(collections) - - expect(filteredCollections).toEqual(collections) - }) -}) diff --git a/test/fixtures/manuscript-setup/setup-one-submitted.js b/test/fixtures/manuscript-setup/setup-one-submitted.js deleted file mode 100644 index 674afe640cd544f9489341ebb4444b9c43cf8489..0000000000000000000000000000000000000000 --- a/test/fixtures/manuscript-setup/setup-one-submitted.js +++ /dev/null @@ -1,107 +0,0 @@ -const logger = require('@pubsweet/logger') -const { User, Team } = require('pubsweet-server/src/models') -// const { setupDb } = require('@pubsweet/db-manager') -const Manuscript = require('../../../server/manuscript/src/manuscript') -const File = require('../../../server/file/src/file') -const Journal = require('../../../server/journal/src/journal') - -export async function setupWithOneSubmittedManuscript() { - const journalData = { - title: 'xPub Collabra', - meta: {}, - } - - const journal = new Journal(journalData) - await journal.save() - - let user = await User.findByUsername('john') - if (!user) { - user = await new User({ - username: 'john', - email: 'john@example.com', - password: 'johnjohn', - admin: true, - }).save() - } - - const emptyManuscript = { - meta: { - title: 'This is a dummy document for testing purposes', - abstract: - 'This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes', - keywords: 'keywords...', - articleType: 'original-research', - articleSection: ['clinical-psychology'], - declarations: { - openData: 'no', - preregistered: 'no', - researchNexus: 'no', - openPeerReview: 'no', - streamlinedReview: 'no', - previouslySubmitted: 'no', - }, - notes: [ - { - notesType: 'fundingAcknowledgement', - content: '<p>funding acknowledgement...</p>', - }, - { - notesType: 'specialInstructions', - content: 'special instructions...', - }, - ], - source: - '<html xmlns="http://www.w3.org/1999/xhtml">\n<head><title>This is a dummy document for testing purposes</title>\n<meta charset="UTF-8"/></head>\n<body>\n<container id="main">\n<h1>This is a dummy document for testing purposes</h1></container>\n\n</body></html>', - }, - status: 'submitted', - authors: [ - { - email: 'email@example.com', - lastName: 'John', - firstName: 'Cena', - affiliation: 'WWE', - }, - ], - suggestions: { - editors: { - suggested: 'Marge Simpson', - }, - reviewers: { - suggested: 'Daffy Duck', - }, - }, - } - - const manuscript = await new Manuscript(emptyManuscript).save() - - const newFile = Object.assign( - {}, - { - url: '/uploads/ec0a2df13f11ef9feaf4411b3ffd8c47.docx', - filename: 'testSubmission1.docx', - mimeType: - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - }, - { - fileType: 'manuscript', - object: 'Manuscript', - objectId: manuscript.id, - }, - ) - await new File(newFile).save() - - // create Team Author Owner - const team = new Team({ - role: 'author', - name: 'Author', - object: { - objectId: manuscript.id, - objectType: 'Manuscript', - }, - members: [user.id], - }) - - await team.save() - - logger.info('Seeding complete.') -} diff --git a/test/fixtures/manuscript-setup/setup-one-unsubmitted.js b/test/fixtures/manuscript-setup/setup-one-unsubmitted.js deleted file mode 100644 index fb279a61509b723a24fb0853b56030d977f9dd45..0000000000000000000000000000000000000000 --- a/test/fixtures/manuscript-setup/setup-one-unsubmitted.js +++ /dev/null @@ -1,106 +0,0 @@ -const logger = require('@pubsweet/logger') -const { User, Team } = require('pubsweet-server/src/models') -// const { setupDb } = require('@pubsweet/db-manager') -const Manuscript = require('../../../server/manuscript/src/manuscript') -const File = require('../../../server/file/src/file') -const Journal = require('../../../server/journal/src/journal') - -export async function setupWithOneUnsubmittedManuscript() { - const journalData = { - title: 'xPub Collabra', - meta: {}, - } - - const journal = new Journal(journalData) - await journal.save() - - let user = await User.findByUsername('john') - if (!user) { - user = await new User({ - username: 'john', - email: 'john@example.com', - password: 'johnjohn', - admin: true, - }).save() - } - const emptyManuscript = { - meta: { - title: 'This is a dummy document for testing purposes', - abstract: - 'This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes', - keywords: 'keywords...', - articleType: 'original-research', - articleSection: ['clinical-psychology'], - declarations: { - openData: 'no', - preregistered: 'no', - researchNexus: 'no', - openPeerReview: 'no', - streamlinedReview: 'no', - previouslySubmitted: 'no', - }, - notes: [ - { - notesType: 'fundingAcknowledgement', - content: '<p>funding acknowledgement...</p>', - }, - { - notesType: 'specialInstructions', - content: 'special instructions...', - }, - ], - source: - '<html xmlns="http://www.w3.org/1999/xhtml">\n<head><title>This is a dummy document for testing purposes</title>\n<meta charset="UTF-8"/></head>\n<body>\n<container id="main">\n<h1>This is a dummy document for testing purposes</h1></container>\n\n</body></html>', - }, - status: 'new', - authors: [ - { - email: 'email@example.com', - lastName: 'John', - firstName: 'Cena', - affiliation: 'WWE', - }, - ], - suggestions: { - editors: { - suggested: 'Marge Simpson', - }, - reviewers: { - suggested: 'Daffy Duck', - }, - }, - } - - const manuscript = await new Manuscript(emptyManuscript).save() - - const newFile = Object.assign( - {}, - { - url: '/uploads/ec0a2df13f11ef9feaf4411b3ffd8c47.docx', - filename: 'testSubmission1.docx', - mimeType: - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - }, - { - fileType: 'manuscript', - object: 'Manuscript', - objectId: manuscript.id, - }, - ) - await new File(newFile).save() - - // create Team Author Owner - const team = new Team({ - role: 'author', - name: 'Author', - object: { - objectId: manuscript.id, - objectType: 'Manuscript', - }, - members: [user.id], - }) - - await team.save() - - logger.info('Seeding complete.') -} diff --git a/test/fixtures/manuscript-setup/setup-two-submitted-assigned-reviewer.js b/test/fixtures/manuscript-setup/setup-two-submitted-assigned-reviewer.js deleted file mode 100644 index 8dd80262d03e87bff49c781f31fa1ad344d1d9d5..0000000000000000000000000000000000000000 --- a/test/fixtures/manuscript-setup/setup-two-submitted-assigned-reviewer.js +++ /dev/null @@ -1,142 +0,0 @@ -const logger = require('@pubsweet/logger') -const { Collection, Fragment, User } = require('pubsweet-server/src/models') -// const { setupDb } = require('@pubsweet/db-manager') - -export async function setupWithTwoSubmittedManuscriptsReviewerAssigned() { - let user = await User.findByUsername('john') - if (!user) { - user = await new User({ - username: 'john', - email: 'john@example.com', - password: 'johnjohn', - admin: true, - }).save() - } - - const collection1 = new Collection({ - title: 'My Blog', - owners: [user.id], - }) - await collection1.save() - - const collection2 = new Collection({ - title: 'My Blog 2', - owners: [user.id], - }) - await collection2.save() - - const fragment1 = await new Fragment({ - type: 'fragment', - files: { - manuscript: { - url: '/uploads/ec0a2df13f11ef9feaf4411b3ffd8c47.docx', - name: 'testSubmission1.docx', - }, - supplementary: [], - }, - notes: { - specialInstructions: 'special instructions...', - fundingAcknowledgement: '<p>funding acknowledgement...</p>', - }, - owners: [user.id], - source: - '<html xmlns="http://www.w3.org/1999/xhtml">\n<head><title>This is a dummy document for testing purposes</title>\n<meta charset="UTF-8"/></head>\n<body>\n<container id="main">\n<h1>This is a dummy document for testing purposes</h1></container>\n\n</body></html>', - version: 1, - metadata: { - title: 'This is a dummy document for testing purposes', - authors: [ - { - email: 'email@example.com', - lastName: 'John', - firstName: 'Cena', - affiliation: 'WWE', - }, - ], - abstract: - 'This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes', - keywords: ['keywords...'], - articleType: 'original-research', - articleSection: ['clinical-psychology'], - }, - submitted: '2018-05-23T07:17:38.601Z', - suggestions: { - editors: { - suggested: ['Marge Simpson'], - }, - reviewers: { - suggested: ['Daffy Duck'], - }, - }, - declarations: { - openData: 'no', - preregistered: 'no', - researchNexus: 'no', - openPeerReview: 'no', - streamlinedReview: 'no', - previouslySubmitted: 'no', - }, - fragmentType: 'version', - }).save() - - const fragment2 = await new Fragment({ - type: 'fragment', - files: { - manuscript: { - url: '/uploads/3f0a64b9b26b45d08b292f55219d5dc9.docx', - name: 'testSubmission1.docx', - }, - supplementary: [], - }, - notes: { - specialInstructions: 'confidential special instructions...', - fundingAcknowledgement: '<p>funding body acknowledgement...</p>', - }, - owners: [], - source: - '<html xmlns="http://www.w3.org/1999/xhtml">\n<head><title>This is a test document</title>\n<meta charset="UTF-8"/></head>\n<body>\n<container id="main">\n<h1>This is a test document</h1></container>\n\n</body></html>', - version: 1, - metadata: { - title: 'This is a test document', - authors: [ - { - email: 'example@email.com', - lastName: 'Simpson', - firstName: 'Homer', - affiliation: 'Power Plant', - }, - ], - abstract: - 'This is a test document This is a test document This is a test document This is a test document This is a test document This is a test document This is a test document', - keywords: ['keywords...'], - articleType: 'review', - articleSection: ['clinical-psychology', 'methodology'], - }, - submitted: '2018-05-23T07:17:38.601Z', - suggestions: { - editors: { - suggested: ['Lisa Simpso'], - }, - reviewers: { - opposed: ['Marge Simpson'], - suggested: ['Moe Szyslak'], - }, - }, - declarations: { - openData: 'no', - preregistered: 'no', - researchNexus: 'no', - openPeerReview: 'no', - streamlinedReview: 'no', - previouslySubmitted: 'no', - }, - fragmentType: 'version', - }).save() - - collection1.addFragment(fragment1) - collection2.addFragment(fragment2) - - await collection1.save() - await collection2.save() - - logger.info('Seeding complete.') -} diff --git a/test/fixtures/manuscript-setup/setup-two-unsubmitted.js b/test/fixtures/manuscript-setup/setup-two-unsubmitted.js deleted file mode 100644 index b008cd6f71f5fa93c36dba78969ef04953040dde..0000000000000000000000000000000000000000 --- a/test/fixtures/manuscript-setup/setup-two-unsubmitted.js +++ /dev/null @@ -1,183 +0,0 @@ -const logger = require('@pubsweet/logger') -const { User, Team } = require('pubsweet-server/src/models') -const Manuscript = require('../../../server/manuscript/src/manuscript') -const File = require('../../../server/file/src/file') -const Journal = require('../../../server/journal/src/journal') - -export async function setupWithTwoUnsubmittedManuscripts() { - const journalData = { - title: 'xPub Collabra', - meta: {}, - } - - const journal = new Journal(journalData) - await journal.save() - - const user = await new User({ - username: 'john', - email: 'john@example.com', - password: 'johnjohn', - admin: true, - }).save() - - const emptyManuscript1 = { - meta: { - title: 'This is a dummy document for testing purposes', - abstract: - 'This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes This is a dummy document for testing purposes', - keywords: 'keywords...', - articleType: 'original-research', - articleSection: ['clinical-psychology'], - declarations: { - openData: 'no', - preregistered: 'no', - researchNexus: 'no', - openPeerReview: 'no', - streamlinedReview: 'no', - previouslySubmitted: 'no', - }, - notes: [ - { - notesType: 'fundingAcknowledgement', - content: '<p>funding acknowledgement...</p>', - }, - { - notesType: 'specialInstructions', - content: 'special instructions...', - }, - ], - source: - '<html xmlns="http://www.w3.org/1999/xhtml">\n<head><title>This is a dummy document for testing purposes</title>\n<meta charset="UTF-8"/></head>\n<body>\n<container id="main">\n<h1>This is a dummy document for testing purposes</h1></container>\n\n</body></html>', - }, - status: 'new', - authors: [ - { - email: 'email@example.com', - lastName: 'John', - firstName: 'Cena', - affiliation: 'WWE', - }, - ], - suggestions: { - editors: { - suggested: 'Marge Simpson', - }, - reviewers: { - suggested: 'Daffy Duck', - }, - }, - } - - const manuscript1 = await new Manuscript(emptyManuscript1).save() - - const newFile1 = Object.assign( - {}, - { - url: '/uploads/ec0a2df13f11ef9feaf4411b3ffd8c47.docx', - filename: 'testSubmission1.docx', - mimeType: - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - }, - { - fileType: 'manuscript', - object: 'Manuscript', - objectId: manuscript1.id, - }, - ) - await new File(newFile1).save() - - // create Team Author Owner - const team1 = new Team({ - role: 'author', - name: 'Author', - object: { - objectId: manuscript1.id, - objectType: 'Manuscript', - }, - members: [user.id], - }) - - await team1.save() - - const emptyManuscript2 = { - meta: { - title: 'This is a test document', - abstract: - 'This is a test document This is a test document This is a test document This is a test document This is a test document This is a test document This is a test document', - keywords: 'keywords...', - articleType: 'review', - articleSection: ['clinical-psychology', 'methodology'], - declarations: { - openData: 'no', - preregistered: 'no', - researchNexus: 'no', - openPeerReview: 'no', - streamlinedReview: 'no', - previouslySubmitted: 'no', - }, - notes: [ - { - notesType: 'fundingAcknowledgement', - content: '<p>funding acknowledgement...</p>', - }, - { - notesType: 'specialInstructions', - content: 'special instructions...', - }, - ], - source: - '<html xmlns="http://www.w3.org/1999/xhtml">\n<head><title>This is a dummy document for testing purposes</title>\n<meta charset="UTF-8"/></head>\n<body>\n<container id="main">\n<h1>This is a dummy document for testing purposes</h1></container>\n\n</body></html>', - }, - status: 'new', - authors: [ - { - email: 'example@email.com', - lastName: 'Simpson', - firstName: 'Homer', - affiliation: 'Power Plant', - }, - ], - suggestions: { - editors: { - suggested: 'Lisa Simpso', - }, - reviewers: { - opposed: 'Marge Simpson', - suggested: 'Moe Szyslak', - }, - }, - created: new Date(), - } - const manuscript2 = await new Manuscript(emptyManuscript2).save() - - const newFile2 = Object.assign( - {}, - { - url: '/uploads/3f0a64b9b26b45d08b292f55219d5dc9.docx', - filename: 'testSubmission1.docx', - mimeType: - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - }, - { - fileType: 'manuscript', - object: 'Manuscript', - objectId: manuscript2.id, - }, - ) - await new File(newFile2).save() - - // create Team Author Owner - const team2 = new Team({ - role: 'author', - name: 'Author', - object: { - objectId: manuscript2.id, - objectType: 'Manuscript', - }, - members: [user.id], - }) - - await team2.save() - - logger.info('Seeding complete.') -} diff --git a/test/fixtures/submissionWrongFormat.txt b/test/fixtures/submissionWrongFormat.txt deleted file mode 100644 index 67154809f41568a59d6fd09b4e389777bd8e9d93..0000000000000000000000000000000000000000 --- a/test/fixtures/submissionWrongFormat.txt +++ /dev/null @@ -1 +0,0 @@ -bad submission \ No newline at end of file diff --git a/test/fixtures/testSubmission1.docx b/test/fixtures/testSubmission1.docx deleted file mode 100644 index fd8cc4bc3563af209358bb2902a6864eaf9c0c5a..0000000000000000000000000000000000000000 Binary files a/test/fixtures/testSubmission1.docx and /dev/null differ diff --git a/test/fixtures/testSubmission2.docx b/test/fixtures/testSubmission2.docx deleted file mode 100644 index e3b2025d3c65579db5fa07e99a295bc85606315b..0000000000000000000000000000000000000000 Binary files a/test/fixtures/testSubmission2.docx and /dev/null differ diff --git a/test/guest.test.js b/test/guest.test.js deleted file mode 100644 index 4a32c78149ebb3ad1bd1fe0b42534cc32471866d..0000000000000000000000000000000000000000 --- a/test/guest.test.js +++ /dev/null @@ -1,23 +0,0 @@ -import faker from 'faker' -import { login } from './pageObjects' -import { startServer, setup } from './helpers/setup' - -fixture('Guest user') - .before(startServer) - .beforeEach(async () => { - await setup() - }) - -test('Signup journey', async t => { - const user = { - username: faker.internet.domainWord(), - email: faker.internet.exampleEmail(), - password: faker.internet.password(), - } - - // cannot log in - await login - .doLogin(user.username, user.password) - .expect(login.alert.innerText) - .contains('Unauthorized') -}) diff --git a/test/helpers/jest-setup.js b/test/helpers/jest-setup.js deleted file mode 100644 index 062566dce611900705362d5b47541a4e2d8ef734..0000000000000000000000000000000000000000 --- a/test/helpers/jest-setup.js +++ /dev/null @@ -1,3 +0,0 @@ -const path = require('path') - -process.env.NODE_CONFIG_DIR = path.resolve(__dirname, '..', '..', 'config') diff --git a/test/helpers/prosemirror-helper.js b/test/helpers/prosemirror-helper.js deleted file mode 100644 index ee01768e1e3b7c1d7bdae5eacb9b301d496a140e..0000000000000000000000000000000000000000 --- a/test/helpers/prosemirror-helper.js +++ /dev/null @@ -1,13 +0,0 @@ -import { ClientFunction } from 'testcafe' - -export async function prepareEditor(selector, text) { - const hasPlaceholder = await selector.find('.placeholder').exists - const options = {} - if (hasPlaceholder) { - await goToEditMode(selector.child()) - options.replace = true - } - return [selector, text, options] -} - -const goToEditMode = ClientFunction(selector => (selector().innerHTML += '')) diff --git a/test/helpers/setup.js b/test/helpers/setup.js deleted file mode 100644 index d308fb67a74b44c10aa03ec56a6b31259c00ef3a..0000000000000000000000000000000000000000 --- a/test/helpers/setup.js +++ /dev/null @@ -1,43 +0,0 @@ -import faker from 'faker' -import DestinationRequest from 'testcafe-hammerhead/lib/request-pipeline/destination-request' -import start from 'pubsweet/src/startup/start' -import { User } from 'pubsweet-server' -import { createTables } from '@pubsweet/db-manager' - -import Journal from '../../server/journal/src/journal' - -let server - -export async function startServer() { - if (!server) { - // increase timeout to wait for webpack compilation - DestinationRequest.TIMEOUT = 60 * 1000 - server = await start() - } -} - -export async function setup(user) { - await createTables(true) - - const userData = user || { - username: faker.internet.domainWord(), - email: faker.internet.exampleEmail(), - password: faker.internet.password(), - admin: true, - } - - const journalData = { - title: 'SimpleJ', - meta: {}, - } - - const newUser = new User(userData) - await newUser.save() - - const journal = new Journal(journalData) - await journal.save() - - return { userData, journal } -} - -export function teardown() {} diff --git a/test/helpers/submission.js b/test/helpers/submission.js deleted file mode 100644 index 8770cb05924182b775601798f011b8cbe8ba5f91..0000000000000000000000000000000000000000 --- a/test/helpers/submission.js +++ /dev/null @@ -1,73 +0,0 @@ -import faker from 'faker' -import { Selector, t } from 'testcafe' -import { dashboard, submission, confirmation } from '../pageObjects' -import { prepareEditor } from './prosemirror-helper' - -const title = 'this is a test submission' - -export async function createSubmission(testfile) { - await t - .setFilesToUpload(dashboard.createSubmission, [testfile]) - .wait(30000) - .expect( - Selector('div[id="metadata.title"] div[contenteditable=true]').exists, - ) - .ok() - - await t - .click(submission.title) - .wait(500) - .typeText(submission.title, title, { replace: true }) - - await t - .typeText( - ...(await prepareEditor(submission.abstract, faker.lorem.words(20))), - ) - .pressKey('tab') - .click(submission.addAuthor) - .typeText(submission.authorFirstName, faker.internet.domainWord()) - .typeText(submission.authorLastName, faker.internet.domainWord()) - .typeText(submission.authorEmail, faker.internet.exampleEmail()) - .typeText(submission.authorAffiliation, faker.internet.domainWord()) - .typeText(submission.keywords, faker.lorem.words(3)) - .click(submission.articleType) - .click(submission.articleTypeOptions.nth(0)) - .click(submission.articleSectionOptions.nth(2)) - .click(submission.articleSectionOptions.nth(3)) - - .click(submission.openDataOptions.nth(0)) - .click(submission.previouslySubmittedOptions.nth(0)) - .click(submission.openPeerReviewOptions.nth(1)) - .click(submission.streamlinedReviewOptions.nth(0)) - .click(submission.researchNexusOptions.nth(1)) - .click(submission.preregisteredOptions.nth(0)) - - await t - .typeText( - ...(await prepareEditor( - submission.fundingAcknowledgement, - faker.lorem.words(3), - )), - ) - .pressKey('tab tab tab tab tab tab tab tab') - - return t -} - -export async function submitManuscript(testfile) { - await createSubmission(testfile) - - await t - .wait(500) - .pressKey('enter') - .wait(500) - - await t.expect(confirmation.submitManuscript).exists - - await t.wait(1000).click(confirmation.submitManuscript) - - await t - .wait(1000) - .expect(await Selector(dashboard.createSubmission).exists) - .ok() -} diff --git a/test/pageObjects/confirmation.js b/test/pageObjects/confirmation.js deleted file mode 100644 index 080cc6b6dacd5a999a7339c29dffff56b2a5875e..0000000000000000000000000000000000000000 --- a/test/pageObjects/confirmation.js +++ /dev/null @@ -1,10 +0,0 @@ -import { Selector } from 'testcafe' - -const confirmation = { - submitManuscript: Selector('button[type=submit]'), - returnToSubmission: Selector('button').withText( - 'GET BACK TO YOUR SUBMISSION', - ), -} - -export default confirmation diff --git a/test/pageObjects/controlPanel.js b/test/pageObjects/controlPanel.js deleted file mode 100644 index 3ea83c29e2b60daa00399cf295a9e196788ccebc..0000000000000000000000000000000000000000 --- a/test/pageObjects/controlPanel.js +++ /dev/null @@ -1,11 +0,0 @@ -import config from 'config' -import { Selector } from 'testcafe' - -const controlPanel = { - url: `${config.get('pubsweet-server.baseUrl')}`, - collabraHome: Selector('nav a'), - - assignReviewers: Selector('a').withText('Assign Reviewers'), -} - -export default controlPanel diff --git a/test/pageObjects/dashboard.js b/test/pageObjects/dashboard.js deleted file mode 100644 index c3c87608ba0a5607f5e330d303936504897b55b2..0000000000000000000000000000000000000000 --- a/test/pageObjects/dashboard.js +++ /dev/null @@ -1,66 +0,0 @@ -import config from 'config' -import { Selector } from 'testcafe' - -const dashboard = { - url: `${config.get('pubsweet-server.baseUrl')}`, - collabraHome: Selector('nav a'), - logout: Selector('button[type=button]').withText('Logout'), - - createSubmission: Selector('input'), - input: Selector('input[type=file]'), - - mySubmissionsTitle: Selector('#root div div div div div').child(1), - mySubmissions: Selector('#root div div div div div'), - submission: n => dashboard.mySubmissions.child(n), - submissionStatus: (n, k) => - dashboard.mySubmissions - .child(n) - .child('div') - .nth(k || n), - submissionSummaryInfoLink: n => - dashboard.mySubmissions - .child(n) - .find('a') - .withText('Summary Info'), - submissionManuscriptLink: n => - dashboard.mySubmissions - .child(n) - .find('a') - .withText('Manuscript'), - submissionDeleteLink: n => - dashboard.mySubmissions - .child(n) - .find('a') - .withText('Delete'), - - toReviewTitle: Selector('#root div div div div div').child(2), - acceptReview: Selector('a').withText('Accept'), - rejectReview: Selector('a').withText('Reject'), - doReview: Selector('a').withText('Do review'), - completed: Selector('a').withText('Completed'), - - myManuscriptsTitle: Selector('#root div div div div').child(3), - myManuscripts: Selector('#root div div div div'), - manuscript: n => dashboard.myManuscripts.child(n), // specified manuscript - manuscriptStatus: n => - dashboard.myManuscripts - .child(n) - .child('div') - .nth(1), - controlPanel: Selector('a').withText('Control Panel'), - manuscriptLink: Selector('div').withText('this is a test submission'), - invitedReviewsCount: Selector('span span') - .withText('invited') - .sibling(0), - acceptedReviewsCount: Selector('span span') - .withText('accepted') - .sibling(0), - rejectedReviewsCount: Selector('span span') - .withText('rejected') - .sibling(0), - completedReviewsCount: Selector('span span') - .withText('completed') - .sibling(0), -} - -export default dashboard diff --git a/test/pageObjects/index.js b/test/pageObjects/index.js deleted file mode 100644 index 13e7053a4ce35a9f1ac7a85308d4969018191162..0000000000000000000000000000000000000000 --- a/test/pageObjects/index.js +++ /dev/null @@ -1,6 +0,0 @@ -export { default as login } from './login' -export { default as dashboard } from './dashboard' -export { default as submission } from './submission' -export { default as confirmation } from './confirmation' -export { default as reviewers } from './reviewers' -export { default as review } from './review' diff --git a/test/pageObjects/login.js b/test/pageObjects/login.js deleted file mode 100644 index 3b389f56fc9a8bc6bba321a25782cd937d5208dd..0000000000000000000000000000000000000000 --- a/test/pageObjects/login.js +++ /dev/null @@ -1,21 +0,0 @@ -import config from 'config' -import { Selector, t } from 'testcafe' - -const login = { - url: `${config.get('pubsweet-server.baseUrl')}/login?next=/`, - - username: Selector('form input[type=text]'), - password: Selector('form input[type=password]'), - submit: Selector('form button'), - - alert: Selector(() => document.querySelector('form').previousSibling), - - doLogin: (username, password) => - t - .navigateTo(login.url) - .typeText(login.username, username) - .typeText(login.password, password) - .click(login.submit), -} - -export default login diff --git a/test/pageObjects/review.js b/test/pageObjects/review.js deleted file mode 100644 index 072e3be054a9d2a3500e564743534b1234bda2a0..0000000000000000000000000000000000000000 --- a/test/pageObjects/review.js +++ /dev/null @@ -1,28 +0,0 @@ -import config from 'config' -import { Selector } from 'testcafe' - -const review = { - url: `${config.get('pubsweet-server.baseUrl')}`, - collabraHome: Selector('nav a'), - - assignEditors: Selector('div').withText('Assign Editors'), - assignReviewers: Selector('a').withText('Assign Reviewers'), - - comments: Selector('div[name="note.content"] div[contenteditable]'), - confidentialComments: Selector( - 'div[name=confidential.content] div[contenteditable]', - ), - - accept: Selector( - 'input[type=radio name="Recommendation.recommendation" value="accept"]', - ), - revise: Selector( - 'input[type=radio name="Recommendation.recommendation" value="revise"]', - ), - reject: Selector( - 'input[type=radio name="Recommendation.recommendation" value="reject"]', - ), - submit: Selector('button[type=submit]'), -} - -export default review diff --git a/test/pageObjects/reviewers.js b/test/pageObjects/reviewers.js deleted file mode 100644 index 4e51c4ff2ea04650aff5d4c333ac1fd615bc2d85..0000000000000000000000000000000000000000 --- a/test/pageObjects/reviewers.js +++ /dev/null @@ -1,16 +0,0 @@ -import config from 'config' -import { Selector } from 'testcafe' -import { ReactSelector } from 'testcafe-react-selectors' - -const reviewers = { - url: `${config.get('pubsweet-server.baseUrl')}`, - collabraHome: Selector('nav a'), - - reviewerSelect: ReactSelector('CreatableSelect Select'), - reviewer: Selector('#react-select-3--option-1'), - inviteReviewer: Selector('button[type=submit]'), - - backToControlPanel: Selector('a').withText('Back to Control Panel'), -} - -export default reviewers diff --git a/test/pageObjects/submission.js b/test/pageObjects/submission.js deleted file mode 100644 index 8059051cb13ff8846ca1ab6a42d5cb0734e267fb..0000000000000000000000000000000000000000 --- a/test/pageObjects/submission.js +++ /dev/null @@ -1,38 +0,0 @@ -import { Selector } from 'testcafe' - -const submission = { - title: Selector('div[id="metadata.title"] div[contenteditable=true]'), - abstract: Selector('div[id="metadata.abstract"] div[contenteditable=true]'), - addAuthor: Selector('button[type=button]').withText('ADD ANOTHER AUTHOR'), - authorFirstName: Selector('input[name="authors.0.firstName"]'), - authorLastName: Selector('input[name="authors.0.lastName"]'), - authorEmail: Selector('input[name="authors.0.email"]'), - authorAffiliation: Selector('input[name="authors.0.affiliation"]'), - keywords: Selector('div[id="metadata.keywords"] input'), - articleType: Selector('div[id="metadata.articleType"] button'), - articleTypeOptions: Selector( - 'div[id="metadata.articleType"] div[role=option]', - ), - articleSectionOptions: Selector('div[id="metadata.articleSection"] label'), - - openDataOptions: Selector('div[id="declarations.openData"] label'), - previouslySubmittedOptions: Selector( - 'div[id="declarations.previouslySubmitted"] label', - ), - openPeerReviewOptions: Selector( - 'div[id="declarations.openPeerReview"] label', - ), - streamlinedReviewOptions: Selector( - 'div[id="declarations.streamlinedReview"] label', - ), - researchNexusOptions: Selector('div[id="declarations.researchNexus"] label'), - preregisteredOptions: Selector('div[id="declarations.preregistered"] label'), - - fundingAcknowledgement: Selector( - 'div[id="notes.fundingAcknowledgement"] div[contenteditable]', - ), - - submit: Selector('form button'), -} - -export default submission diff --git a/test/reviewer.test.js b/test/reviewer.test.js deleted file mode 100644 index 217cb405a16bfe955a802d83980ae9167e93f71a..0000000000000000000000000000000000000000 --- a/test/reviewer.test.js +++ /dev/null @@ -1,64 +0,0 @@ -import config from 'config' -import { Selector } from 'testcafe' -import { startServer, teardown } from './helpers/setup' -import { setupWithOneSubmittedManuscript } from './fixtures/manuscript-setup/setup-one-submitted' -import { login, dashboard, reviewers, review } from './pageObjects' - -const goodInkConfig = { - inkEndpoint: 'http://inkdemo-api.coko.foundation/', - email: 'editoria@coko.foundation', - password: 'editoria', - recipes: { - 'editoria-typescript': '2', - }, -} - -const user = { username: 'john', password: 'johnjohn' } - -fixture - .only('Assign reviewers') - .before(async () => { - config['pubsweet-component-ink-backend'] = goodInkConfig - await startServer() - }) - .afterEach(teardown) - -test.skip.before(async t => { - await setupWithOneSubmittedManuscript() - await login.doLogin(user.username, user.password) -})('Assign reviewer', async t => { - await t - .expect(dashboard.invitedReviewsCount.innerText) - .eql('0') - .expect(dashboard.manuscriptStatus(2).innerText) - .contains('SUBMITTED') - // .expect(await Selector(dashboard.controlPanel).exists) - // .ok() - - await t.click(dashboard.controlPanel).wait(2000) - - await t.expect(await Selector(review.assignEditors).exists).ok() - await t.expect(await Selector(review.assignReviewers).exists).ok() - - await t - .click(review.assignReviewers) - .expect(Selector(reviewers.reviewerSelect).exists) - .ok() - .click(reviewers.reviewerSelect) - - await t - .expect(await Selector(reviewers.reviewer.withText(user.username)).exists) - .ok() - - await t - .click(reviewers.reviewer.withText(user.username)) - .expect(await Selector(reviewers.inviteReviewer).exists) - .ok() - .click(reviewers.inviteReviewer) - - await t - .click(reviewers.collabraHome) - .wait(1000) - .expect(dashboard.invitedReviewsCount.innerText) - .eql('1') -})