Commit b74142e8 authored by Giannis Kopanas's avatar Giannis Kopanas

Merge branch 'assign-reviewers-e2e-test' into 'master'

Assign reviewers e2e test

See merge request !189
parents 52dc769b 8909c425
Pipeline #8381 passed with stages
in 4 minutes and 16 seconds
// import faker from 'faker'
import config from 'config'
import { Selector } from 'testcafe'
// import { prepareEditor } from './helpers/prosemirror-helper'
import { createSubmission } from './helpers/submission'
import { startServer, setup, teardown } from './helpers/setup'
import { login, dashboard } from './pageObjects'
const config = require('config')
import { setupWithTwoUnsubmittedManuscripts } from './fixtures/manuscript-setup/setup-two-unsubmitted'
import { login, dashboard, submission, confirmation } from './pageObjects'
const goodInkConfig = {
inkEndpoint: 'http://inkdemo-api.coko.foundation/',
......@@ -16,7 +15,6 @@ const goodInkConfig = {
}
let author
// const title = 'this is a test submission'
fixture
.only('Author user')
......@@ -24,77 +22,38 @@ fixture
config['pubsweet-component-ink-backend'] = goodInkConfig
await startServer()
})
.beforeEach(async () => {
const result = await setup()
.afterEach(teardown)
test.skip
.before(async t => {
const result = await setup()
author = result.userData
await login.doLogin(author.username, author.password)
})
.afterEach(teardown)
})('create new submission', async t => {
await t.expect(Selector(dashboard.mySubmissionsTitle).exists).notOk()
// test('Manage submissions journey, create new submission', async t => {
// await t.expect(Selector(dashboard.mySubmissionsTitle).exists).notOk()
// await t
// .setFilesToUpload(dashboard.createSubmission, ['./testSubmission1.docx'])
// .wait(40000)
// .expect(
// Selector('div[id="metadata.title"] div[contenteditable=true]').exists,
// )
// .ok()
// await t.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),
// )),
// )
// .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 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 => {
startServer()
const result = await setup()
author = result.userData
await login.doLogin(author.username, author.password)
})('Manage submissions journey, failed new submission', async t => {
})('Failed new submission', async t => {
await t
.setFilesToUpload(dashboard.createSubmission, ['./testSubmission1.docx'])
.expect(await Selector('div').withText('Internal Server Error').exists)
......@@ -107,3 +66,71 @@ test
JSON.parse(JSON.stringify(config.get('pubsweet-component-ink-backend'))),
)
})
test.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
.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)).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.authorFirstName).exists)
.ok()
await t
.expect(
Selector(submission.submit.withText('submit your manuscript')).exists,
)
.notOk()
})
const logger = require('@pubsweet/logger')
const { Collection, Fragment, User } = require('pubsweet-server/src/models')
const { setupDb } = require('@pubsweet/db-manager')
export async function setupWithOneSubmittedManuscript() {
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],
status: 'submitted',
})
await collection.save()
const fragment1 = await new Fragment({
type: 'fragment',
collections: [collection.id],
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()
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 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 fragment = {
type: 'fragment',
files: {
manuscript: {
url: '/uploads/ec0a2df13f11ef9feaf4411b3ffd8c47.docx',
name: 'testSubmission1.docx',
},
supplementary: [],
},
notes: {
specialInstructions: 'special instructions...',
fundingAcknowledgement: '<p>funding acknowledgement...</p>',
},
owners: ['f34e6a7f-d078-4bcc-a45d-15b20ca06acf'],
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>',
created: '2018-06-09T11:37:17.717Z',