Skip to content
Snippets Groups Projects
Commit 52f8b945 authored by Jen Spencer's avatar Jen Spencer
Browse files

Merge branch 'test-happy-path' into 'master'

test: add e2e test for submission happy path

See merge request !32
parents c0dcfe3f 59388d03
No related branches found
No related tags found
1 merge request!32test: add e2e test for submission happy path
Pipeline #6450 passed with stages
in 2 minutes and 10 seconds
import React from 'react' import React from 'react'
import { Link } from 'react-router-dom' import ButtonLink from '../ui/atoms/ButtonLink'
const Dashboard = () => ( const Dashboard = () => (
<div> <div>
<h1>Dashboard Dummy Page</h1> <h1>Dashboard Dummy Page</h1>
<Link to="/submit">Submit a manuscript</Link> <ButtonLink data-test-id="submit" primary to="/submit">
<div> Submit a manuscript
<Link to="/manuscript">View manuscript</Link> </ButtonLink>
</div>
</div> </div>
) )
......
...@@ -68,7 +68,7 @@ class AuthorDetails extends React.Component { ...@@ -68,7 +68,7 @@ class AuthorDetails extends React.Component {
<Flex> <Flex>
<Box width={1}> <Box width={1}>
<Button primary type="submit"> <Button data-test-id="next" primary type="submit">
Next Next
</Button> </Button>
</Box> </Box>
......
...@@ -26,7 +26,7 @@ const FileUploads = () => ( ...@@ -26,7 +26,7 @@ const FileUploads = () => (
</Box> </Box>
</Flex> </Flex>
<ButtonLink primary to="/submit/metadata"> <ButtonLink data-test-id="next" primary to="/submit/metadata">
Next Next
</ButtonLink> </ButtonLink>
<ButtonLink to="/submit">Back</ButtonLink> <ButtonLink to="/submit">Back</ButtonLink>
......
...@@ -9,7 +9,7 @@ export default () => ( ...@@ -9,7 +9,7 @@ export default () => (
<H1>Help us get your work seen by the right people</H1> <H1>Help us get your work seen by the right people</H1>
<ButtonLink primary to="/submit/suggestions"> <ButtonLink data-test-id="next" primary to="/submit/suggestions">
Next Next
</ButtonLink> </ButtonLink>
<ButtonLink to="/submit/upload">Back</ButtonLink> <ButtonLink to="/submit/upload">Back</ButtonLink>
......
...@@ -35,12 +35,7 @@ const MoreButton = ({ ...@@ -35,12 +35,7 @@ const MoreButton = ({
const MAX_EXCLUDED_EDITORS = 2 const MAX_EXCLUDED_EDITORS = 2
const ReviewerSuggestions = ({ const ReviewerSuggestions = ({ handleSubmit, values, setFieldValue }) => (
handleSubmit,
values,
setValues,
setFieldValue,
}) => (
<form noValidate onSubmit={handleSubmit}> <form noValidate onSubmit={handleSubmit}>
<ProgressBar currentStep={3} /> <ProgressBar currentStep={3} />
...@@ -132,8 +127,8 @@ const ReviewerSuggestions = ({ ...@@ -132,8 +127,8 @@ const ReviewerSuggestions = ({
<Declaration /> <Declaration />
<Button primary type="submit"> <Button data-test-id="next" primary type="submit">
Next Submit
</Button> </Button>
<ButtonLink to="/submit/metadata">Back</ButtonLink> <ButtonLink to="/submit/metadata">Back</ButtonLink>
</form> </form>
......
import replay from 'replay'
import { Selector } from 'testcafe'
import { addUser } from '@pubsweet/db-manager'
import { startServer, setup, teardown } from './helpers/setup'
import { dashboard } from './pageObjects'
replay.fixtures = `${__dirname}/http-mocks`
const admin = {
username: 'tester',
email: 'tester@example.com',
password: 'password',
orcid: '0000-0001',
admin: true,
}
fixture('Smoke test')
.before(startServer)
.beforeEach(async () => {
await setup()
await addUser(admin)
})
.afterEach(teardown)
test('Submission journey', async t => {
await t.navigateTo(dashboard.url)
// check that React root element exists
await t.expect(Selector('#root').exists).ok()
})
import replay from 'replay'
import { Selector, ClientFunction } from 'testcafe'
import { addUser } from '@pubsweet/db-manager'
import authentication from 'pubsweet-server/src/authentication'
import { startServer, setup, teardown } from './helpers/setup'
import { dashboard } from './pageObjects'
replay.fixtures = `${__dirname}/http-mocks`
const admin = {
username: 'tester',
email: 'tester@example.com',
password: 'password',
orcid: '0000-0001',
admin: true,
}
let token
fixture('Submission')
.before(startServer)
.beforeEach(async () => {
await setup()
const user = await addUser(admin)
token = authentication.token.create(user)
})
.afterEach(teardown)
const localStorageSet = ClientFunction((key, val) =>
localStorage.setItem(key, val),
)
test('Happy path', async t => {
// fake login by navigating to site and injecting token into local storage
await t.navigateTo(dashboard.url)
await localStorageSet('token', token)
await t.navigateTo(dashboard.url).click('[data-test-id=submit]')
// author details
await t
.typeText('[name=firstName]', 'Anne')
.typeText('[name=lastName]', 'Author')
.typeText('[name=email]', 'anne.author@life.ac.uk')
.typeText('[name=institute]', 'University of Life')
.click('[data-test-id=next')
// file uploads
await t.click('[data-test-id=next]')
// metadata
await t.click('[data-test-id=next]')
// reviewer suggestions
await t
.typeText('[name="suggestedSeniorEditors.0"]', 'Sen Yor')
.typeText('[name="suggestedSeniorEditors.1"]', 'Eddie Tar')
.typeText('[name="suggestedReviewingEditors.0"]', 'Rev. Ewing')
.typeText('[name="suggestedReviewingEditors.1"]', 'Ed Eater')
.typeText('[name="suggestedReviewers.0.name"]', 'Si Entist')
.typeText('[name="suggestedReviewers.0.email"]', 'si.entist@example.com')
.typeText('[name="suggestedReviewers.1.name"]', 'Reece Archer')
.typeText('[name="suggestedReviewers.1.email"]', 'reece@example.net')
.typeText('[name="suggestedReviewers.2.name"]', 'Dave')
.typeText('[name="suggestedReviewers.2.email"]', 'dave@example.org')
.click(Selector('[name=declaration]').parent())
.click('[data-test-id=next]')
})
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