diff --git a/app/components/dashboard/Dashboard.js b/app/components/dashboard/Dashboard.js index bb3a55a90541dd1ddcb7033c5b972afce0d6464e..a0dd8d7e9343d0c5017731752915e081ccfeaee8 100644 --- a/app/components/dashboard/Dashboard.js +++ b/app/components/dashboard/Dashboard.js @@ -1,13 +1,12 @@ import React from 'react' -import { Link } from 'react-router-dom' +import ButtonLink from '../ui/atoms/ButtonLink' const Dashboard = () => ( <div> <h1>Dashboard Dummy Page</h1> - <Link to="/submit">Submit a manuscript</Link> - <div> - <Link to="/manuscript">View manuscript</Link> - </div> + <ButtonLink data-test-id="submit" primary to="/submit"> + Submit a manuscript + </ButtonLink> </div> ) diff --git a/app/components/submission/AuthorDetails/AuthorDetails.js b/app/components/submission/AuthorDetails/AuthorDetails.js index 7fb868126bb5b2d9ab31840e95a30c9eb4f898a9..7802d6178af21b550ea2dd7f1121626e89700dc9 100644 --- a/app/components/submission/AuthorDetails/AuthorDetails.js +++ b/app/components/submission/AuthorDetails/AuthorDetails.js @@ -68,7 +68,7 @@ class AuthorDetails extends React.Component { <Flex> <Box width={1}> - <Button primary type="submit"> + <Button data-test-id="next" primary type="submit"> Next </Button> </Box> diff --git a/app/components/submission/FileUploads/FileUploads.js b/app/components/submission/FileUploads/FileUploads.js index d678ee223f0a635574d081cb622d3f76917793fd..6d1efd8742e357082dfdf8575efc832280e94185 100644 --- a/app/components/submission/FileUploads/FileUploads.js +++ b/app/components/submission/FileUploads/FileUploads.js @@ -26,7 +26,7 @@ const FileUploads = () => ( </Box> </Flex> - <ButtonLink primary to="/submit/metadata"> + <ButtonLink data-test-id="next" primary to="/submit/metadata"> Next </ButtonLink> <ButtonLink to="/submit">Back</ButtonLink> diff --git a/app/components/submission/ManuscriptMetadata/ManuscriptMetadataPage.js b/app/components/submission/ManuscriptMetadata/ManuscriptMetadataPage.js index 233c78db107c95a70c37665b0c3d4db20020f723..075ed87d1371924a3885b4e02322371db15fcbba 100644 --- a/app/components/submission/ManuscriptMetadata/ManuscriptMetadataPage.js +++ b/app/components/submission/ManuscriptMetadata/ManuscriptMetadataPage.js @@ -9,7 +9,7 @@ export default () => ( <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 </ButtonLink> <ButtonLink to="/submit/upload">Back</ButtonLink> diff --git a/app/components/submission/ReviewerSuggestions/ReviewerSuggestions.js b/app/components/submission/ReviewerSuggestions/ReviewerSuggestions.js index 6685a3eb5f9f0988882effca8b0de9dae1675ec2..306a526609278f5c5a40c8bc1332d4a8c92568d1 100644 --- a/app/components/submission/ReviewerSuggestions/ReviewerSuggestions.js +++ b/app/components/submission/ReviewerSuggestions/ReviewerSuggestions.js @@ -35,12 +35,7 @@ const MoreButton = ({ const MAX_EXCLUDED_EDITORS = 2 -const ReviewerSuggestions = ({ - handleSubmit, - values, - setValues, - setFieldValue, -}) => ( +const ReviewerSuggestions = ({ handleSubmit, values, setFieldValue }) => ( <form noValidate onSubmit={handleSubmit}> <ProgressBar currentStep={3} /> @@ -132,8 +127,8 @@ const ReviewerSuggestions = ({ <Declaration /> - <Button primary type="submit"> - Next + <Button data-test-id="next" primary type="submit"> + Submit </Button> <ButtonLink to="/submit/metadata">Back</ButtonLink> </form> diff --git a/test/smoke.e2e.js b/test/smoke.e2e.js deleted file mode 100644 index f1c85c3e4bb62a456b73c146516f76035067bd9f..0000000000000000000000000000000000000000 --- a/test/smoke.e2e.js +++ /dev/null @@ -1,30 +0,0 @@ -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() -}) diff --git a/test/submission.e2e.js b/test/submission.e2e.js new file mode 100644 index 0000000000000000000000000000000000000000..a564e61330735238b15ac0a5c2f1eae41dbcd2aa --- /dev/null +++ b/test/submission.e2e.js @@ -0,0 +1,67 @@ +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]') +})