Commit 501a8f39 authored by Ana Ellis's avatar Ana Ellis
Browse files

feat: test now passing

parent 7c517fe6
Pipeline #7673 failed with stages
in 4 minutes
const { Collection, Fragment, User } = require('pubsweet-server/src/models')
const { setupDb } = require('@pubsweet/db-manager')
export async function setupWithOneAcceptedReview() {
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],
reviewers: [
{
id: '028ef3a7-3582-4511-a844-30c3685efb4',
user: user.id,
},
],
})
await collection.save()
const fragment = 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'],
},
reviewers: [
{
id: '028ef3a7-3582-4511-a844-30c3685efb3',
_user: {
id: user.id,
type: 'user',
admin: user.admin,
email: user.email,
teams: user.teams,
username: user.username,
fragments: user.fragments,
collections: user.collections,
},
events: {
invited:
'Sat Jun 23 2018 21:27:22 GMT+1200 (New Zealand Standard Time)',
},
status: 'accepted',
reviewer: '028ef3a7-3582-4511-a844-30c3685efb4',
_reviewer: {
id: '028ef3a7-3582-4511-a844-30c3685efb4',
user: user.id,
},
},
],
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(fragment)
await collection.save()
}
......@@ -8,23 +8,19 @@ const review = {
assignEditors: Selector('div').withText('Assign Editors'),
assignReviewers: Selector('a').withText('Assign Reviewers'),
comments: Selector('div[name="note.content"] div[contenteditable]'),
comments: Selector('div[name="note.content"] div[contenteditable=true]'),
confidentialComments: Selector(
'div[name=confidential.content] div[contenteditable=true]',
'div[name="confidential.content"] div[contenteditable=true]',
),
confidentialCommentsLabel: Selector('div').withText(
'Confidential Comments to Editor (Optional)',
),
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"]',
),
recommendationLabel: Selector('div').withText('Recommendation'),
accept: Selector('span').withText('Accept'),
revise: Selector('span').withText('Revise'),
reject: Selector('span').withText('Reject'),
submit: Selector('button[type=submit]'),
}
......
......@@ -4,6 +4,7 @@ import { Selector } from 'testcafe'
import { startServer, teardown } from './helpers/setup'
import { setupWithOneSubmittedManuscript } from './fixtures/manuscript-setup/setup-one-submitted'
import { setupWithTwoSubmittedManuscriptsReviewerAssigned } from './fixtures/manuscript-setup/setup-two-submitted-assigned-reviewer'
import { setupWithOneAcceptedReview } from './fixtures/manuscript-setup/setup-one-accepted-review'
import { login, dashboard, reviewers, review } from './pageObjects'
const goodInkConfig = {
......@@ -66,7 +67,7 @@ test.skip.before(async t => {
.eql('1')
})
test.before(async t => {
test.skip.before(async t => {
await setupWithTwoSubmittedManuscriptsReviewerAssigned()
await login.doLogin(user.username, user.password)
})('Accept and Reject a review', async t => {
......@@ -110,46 +111,32 @@ test.before(async t => {
.ok()
})
test.skip('Submit a review', async t => {
// assign reviewer to manuscript
await t
.click(review.assignReviewers)
.expect(Selector(reviewers.reviewerSelect).exists)
.ok()
.click(reviewers.reviewerSelect)
test.before(async t => {
await setupWithOneAcceptedReview()
await login.doLogin(user.username, user.password)
})('Submit a review', async t => {
await t
.expect(await Selector(reviewers.reviewer.withText(author.username)).exists)
.expect(Selector(dashboard.doReview(0)).exists)
.ok()
.click(dashboard.doReview(0))
await t
.click(reviewers.reviewer.withText(author.username))
.expect(await Selector(reviewers.inviteReviewer).exists)
.expect(Selector(review.recommendationLabel).exists)
.ok()
.click(reviewers.inviteReviewer)
// end
// author logs out, reviewer logs in
// await t.click(dashboard.logout).expect((login.username).exists).ok()
// await login.doLogin(reviewer.username, reviwer.password)
//from dashboard:
await t
.expect(Selector(dashboard.acceptReview(1)).exists)
.ok()
.click(dashboard.acceptReview(1))
await t
.typeText(review.comments, faker.lorem.words(3))
.pressKey('tab')
.typeText(review.confidentialComments, faker.lorem.words(3))
.pressKey('tab')
.click(review.revise)
.click(review.submit)
.wait(1000) //redirects to dashboard
await t
.expect(Selector(dashboard.completed).exists)
.wait(1000) // redirects to dashboard
.expect(Selector(dashboard.completedReview(0)).exists)
.ok()
.click(dashboard.completed)
.expect('Verify that you are taken to the review form again') // TODO
.expect('Verify that the review form is now readonly') // TODO - check read only and shows the expected comment text submitted previously
.click(dashboard.completedReview(0))
.expect(Selector(review.recommendationLabel).exists)
.ok()
.expect(Selector(review.comments).exists)
.notOk()
.expect(Selector(review.confidentialComments).exists)
.notOk()
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment