Commit 5630dbef authored by Ana Ellis's avatar Ana Ellis

feat: new submission test, dashboard selectors updated

parent 686f3b88
......@@ -107,7 +107,6 @@
"testcafe 'chrome:headless --no-sandbox' 'test/**/*.test.js'",
"test:e2e:ci:firefox": "testcafe firefox:headless 'test/**/*.test.js'",
"test": "npm run test:chrome && npm run test:firefox",
"testana": "testcafe 'chrome --inspect --debug-brk --no-sandbox' 'test/**/*.test.js'",
"clean": "rm -rf node_modules",
"lint": "npm run lint:js && npm run lint:style",
"lint:js": "eslint .",
......
import faker from 'faker'
import config from 'config'
import { addUser } from '@pubsweet/db-manager'
import { startServer, setup, setup2, teardown } from './helpers/setup'
import { login, dashboard, submission } from './pageObjects'
import { prepareEditor } from './helpers/prosemirror-helper'
import { Selector, t } from 'testcafe'
import { startServer, setup, setup2, teardown } from './helpers/setup'
import { login, dashboard, submission } from './pageObjects'
let author
let title = 'this is a test submission'
......@@ -21,10 +20,12 @@ fixture
})
.afterEach(teardown)
test.skip('Manage submissions journey, create new submission', async t => {
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(25000)
.wait(30000)
.expect(
Selector('div[id="metadata.title"] div[contenteditable=true]').exists,
)
......@@ -38,11 +39,11 @@ test.skip('Manage submissions journey, create new submission', async t => {
)
.pressKey('tab')
.click(submission.addAuthor)
.typeText(submission.authorFirstName, 'John')
.typeText(submission.authorLastName, 'Cena')
.typeText(submission.authorEmail, 'example@example.com')
.typeText(submission.authorAffiliation, 'WWE')
.typeText(submission.keywords, 'a, few, keywords')
.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))
......@@ -97,17 +98,23 @@ test.skip('Manage submissions journey, create new submission', async t => {
await t
.typeText(
...(await prepareEditor(submission.fundingAcknowledgement, 'thank you')),
...(await prepareEditor(
submission.fundingAcknowledgement,
faker.lorem.words(3),
)),
)
.pressKey('tab')
.click(dashboard.collabraHome) //or back button
//.wait(1000)
//.expect(dashboard.mySubmissions).exists //these
//.expect(dashboard.unsubmittedManuscripts.length).eql(2) //are
//.expect(dashboard.unsubmittedManuscript(1)).contains('Unsubmitted') //wrong
.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()
})
test('Manage submissions journey, failed new submission', async t => {
test.skip('Manage submissions journey, failed new submission', async t => {
await t
.setFilesToUpload(dashboard.createSubmission, ['./testSubmission2.txt']) //setFilesToUpload error automatically causes test to fail
.expect(await Selector(dashboard.submitError).exists)
......
......@@ -12,14 +12,29 @@ const dashboard = {
'There was an error uploading the file',
),
mySubmissions: Selector('div').withText('My submissions'),
unsubmittedManuscripts: Selector('div')
.withText('My submissions')
.parent()
.child(),
unsubmittedManuscript: n => dashboard.unsubmittedManuscripts.child(n),
doSubmit: () => t.setFilesToUpload('input', ['../testSubmission.docx']),
mySubmissionsTitle: Selector('#root div div div div').child(2),
mySubmissions: Selector('#root div div div div'),
submission: n => dashboard.mySubmissions.child(n),
submissionStatus: n =>
dashboard.mySubmissions
.child(n)
.child('div')
.nth(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'),
}
export default dashboard
export { default as login } from './login'
export { default as dashboard } from './dashboard'
export { default as submission } from './submission'
export { default as submissionInformation } from './submissionInformation'
import { Selector } from 'testcafe'
import ReactSelector from 'testcafe-react-selectors'
const submission = {
title: Selector('div[id="metadata.title"] div[contenteditable=true]'),
abstract: Selector('div[id="metadata.abstract"] div[contenteditable=true]'),
//addAuthor: Selector('div[id="metadata.authors"] button[type=button]'),
addAuthor: Selector('button[type=button]').withText('Add another author'),
authorFirstName: Selector(
'div[id="metadata.authors"] input[name="metadata.authors[0].firstName"]',
......@@ -42,7 +40,7 @@ const submission = {
'div[id="notes.fundingAcknowledgement"] div[contenteditable]',
),
submit: Selector('button[type=button]').withText('Submit your manuscript'),
submit: Selector('form button'),
}
export default submission
import config from 'config'
import { Selector, t } from 'testcafe'
const submissionInformation = {
url: `${config.get('pubsweet-server.baseUrl')}`, // /projects/:project/versions/:version/submit
title: Selector('#metadata.title div[contenteditable]'), //must be >= 20 char
abstract: Selector('#metadata.abstract div[contenteditable]'), //must be >= 100 char
authors: Selector('#metadata.authors div[contenteditable]'),
keywords: Selector('#metadata.keywords div[contenteditable]'),
articleType: Selector('#metadata.articleType div[contenteditable]'), //dropdown, one of: [Original Research Report, Review, Opinion/Commentary, Registered Report]
section: Selector('#metadata.articleSection div[contenteditable]'), //one or more of: [Cognitive Psychology, Social Psychology, Personality Psychology, Developmental Psychology,
//Clinial Psychology, Organizational Behavior, Methodology and Research Practice]
openData: Selector('#declarations.openData')
.find('label')
.child(el => el.value === 'yes'),
previouslySubmitted: Selector('#declarations.previouslySubmitted')
.find('label')
.child(el => el.value === 'yes'),
openPeerReview: Selector('#declarationsOpenPeerReview')
.find('label')
.child(el => el.value === 'yes'),
streamlinedReview: Selector('#declarations.streamlinedReview')
.find('label')
.child(el => el.value === 'yes'),
researchNexus: Selector('#declarations.researchNexus')
.find('label')
.child(el => el.value === 'yes'),
preregistered: Selector('#declarations.preregistered')
.find('label')
.child(el => el.value === 'yes'),
suggestedReviewers: Selector(
'form input[name="suggestions.reviewers.suggested"]',
),
opposedReviewers: Selector(
'form input[name="suggestions.reviewers.opposed"]',
),
suggestedEditors: Selector(
'form input[name="suggestions.editors.suggested"]',
),
opposedEditors: Selector('form input[namme="suggestions.editors.opposed"]'),
fundingBodyAcknowledgment: Selector(
'#notes.fundingAcknowledgement div[contenteditable]',
),
specialInstructions: Selector(
'#notes.specialInstructions div[contenteditable]',
),
uploadSupplements: Selector('#files.supplementary type button'),
submit: Selector('form button'),
home: Selector('nav div span a'), //Collabra link at top
}
export default submissionInformation
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