Commit 5824930e authored by Ana Ellis's avatar Ana Ellis
Browse files

feat: setup submissions in db for e2e tests

parent d00c897d
......@@ -2,8 +2,8 @@ import config from 'config'
import { Selector } from 'testcafe'
import { createSubmission } from './helpers/submission'
import { startServer, setup, teardown, setupManuscript } from './helpers/setup'
import { setupWithTwoUnsubmittedManuscripts } from './fixtures/manuscript-setup/setup-two-unsubmitted'
import { login, dashboard, submission, confirmation } from './pageObjects'
import { collection2, fragment2 } from './fixtures/unsubmittedManuscript'
const goodInkConfig = {
inkEndpoint: 'http://inkdemo-api.coko.foundation/',
......@@ -24,25 +24,29 @@ fixture
})
.afterEach(teardown)
test.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()
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 createSubmission('./fixtures/testSubmission1.docx')
await t.click(dashboard.collabraHome)
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()
})
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 => {
......@@ -61,73 +65,74 @@ test
JSON.parse(JSON.stringify(config.get('pubsweet-component-ink-backend'))),
JSON.parse(JSON.stringify(config.get('pubsweet-component-ink-backend'))),
)
teardown()
})
test.before(async t => {
const result = await setup()
await setupManuscript(collection2, fragment2)
await setupManuscript(collection2, fragment2)
test
.before(async t => {
const result = 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)
author = result.userData
await t.wait(500).click(confirmation.returnToSubmission)
await login.doLogin(author.username, author.password)
})('Author submits manuscript', async t => {
await t
.click(dashboard.submissionSummaryInfoLink(1))
.wait(1000)
.click(submission.submit.withText('SUBMIT YOUR MANUSCRIPT'))
.wait(1000)
.expect(confirmation.returnToSubmission.exists)
await t
.expect(
Selector(submission.submit.withText('SUBMIT YOUR MANUSCRIPT')).exists,
)
.ok()
await t.wait(500).click(confirmation.returnToSubmission)
await t.click(submission.submit.withText('SUBMIT YOUR MANUSCRIPT'))
await t
.expect(
Selector(submission.submit.withText('SUBMIT YOUR MANUSCRIPT')).exists,
)
.ok()
await t.click(submission.submit.withText('SUBMIT YOUR MANUSCRIPT'))
await t
.wait(1000)
.click(submission.submit)
.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)).exists)
.ok()
.expect(dashboard.submissionStatus(1).innerText)
.contains('UNSUBMITTED')
await t
.expect(Selector(dashboard.submissionStatus(2)).exists)
.ok()
.expect(dashboard.submissionStatus(2).innerText)
.contains('SUBMITTED')
.wait(5000)
await t
.expect(Selector(dashboard.submissionSummaryInfoLink(0)).exists)
.ok()
.click(dashboard.submissionSummaryInfoLink(0))
.wait(5000)
.expect(
Selector(submission.submit.withText('SUBMIT YOUR MANUSCRIPT')).exists,
)
.notOk()
})
await t
.wait(1000)
.click(submission.submit)
.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)).exists)
.ok()
.expect(dashboard.submissionStatus(1).innerText)
.contains('UNSUBMITTED')
await t
.expect(Selector(dashboard.submissionStatus(2)).exists)
.ok()
.expect(dashboard.submissionStatus(2).innerText)
.contains('SUBMITTED')
.wait(5000)
await t
.expect(Selector(dashboard.submissionSummaryInfoLink(2)).exists)
.ok()
.click(dashboard.submissionSummaryInfoLink(2))
.wait(5000)
.expect(
Selector(submission.submit.withText('SUBMIT YOUR MANUSCRIPT')).exists,
)
.notOk()
})
.after(async t => {
teardown()
})
const logger = require('@pubsweet/logger')
const { Collection, Fragment, User } = require('pubsweet-server/src/models')
const { setupDb } = require('@pubsweet/db-manager')
export async function setupWithOneUnsubmittedManuscript() {
await setupDb({
username: 'admin',
password: 'password',
email: 'admin@example.com',
admin: true,
clobber: true,
})
const user = await new User({
username: 'john',
email: 'john@example.com',
password: 'johnjohn',
admin: true,
}).save()
const collection = new Collection({
title: 'My Blog',
owners: [user.id],
})
await collection.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'],
},
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()
collection.addFragment(fragment1)
await collection.save()
logger.info('Seeding complete.')
}
const logger = require('@pubsweet/logger')
const { Collection, Fragment, User } = require('pubsweet-server/src/models')
const { setupDb } = require('@pubsweet/db-manager')
export async function setupWithTwoSubmittedManuscriptsReviewerAssigned() {
await setupDb({
username: 'admin',
password: 'password',
email: 'admin@example.com',
admin: true,
clobber: true,
})
const 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.')
}
const logger = require('@pubsweet/logger')
const { Collection, Fragment, User } = require('pubsweet-server/src/models')
const { setupDb } = require('@pubsweet/db-manager')
export async function setupWithTwoUnsubmittedManuscripts() {
await setupDb({
username: 'admin',
password: 'password',
email: 'admin@example.com',
admin: true,
clobber: true,
})
const 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'],
},
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'],
},
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.')
}
export const fragment1 = {
type: 'fragment',
files: {
manuscript: {
url: '/uploads/ec0a2df13f11ef9feaf4411b3ffd8c47.docx',
name: 'testSubmission1.docx',
},
supplementary: [],
},
notes: {
specialInstructions: 'special instructions...',
fundingAcknowledgement: '<p>funding acknowledgement...</p>',
},
owners: [],
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,