Commit f0b79f12 authored by Yannis Barlas's avatar Yannis Barlas

test(submission form): insert manuscript programmatically

parent b2a8b32b
......@@ -3,10 +3,11 @@
describe('Author creates new submission', () => {
beforeEach(() => {
cy.login('author')
cy.visit('/dashboard')
})
it('should create a new submission', () => {
cy.visit('/dashboard')
cy.get('[data-test-id="dashboard-section"]').should('have.length', 2)
cy.getById('dashboard-section-item-author').should('have.length', 0)
......@@ -21,7 +22,11 @@ describe('Author creates new submission', () => {
})
it('should make initial submission', () => {
cy.getById('new-submission-button').click()
cy.createEmptyManuscript().then(res => {
cy.getCurrentUser().then(res2 => {
cy.visit(`/article/${res.body.data.createManuscript}`)
})
})
cy.get('[data-test-id="authorinput-author.name"] input')
.type('John Brown')
......@@ -109,7 +114,6 @@ describe('Author creates new submission', () => {
'Quisque bibendum, lectus et facilisis luctus.',
)
// cy.getById('submit-button').click()
cy.contains('button', 'Submit').click()
cy.get('.ReactModal__Content').should('be.visible')
......
......@@ -22,6 +22,7 @@ module.exports = (on, config) => {
await Team.query()
.delete()
.whereNot({ global: true })
.orWhere({ global: null })
await TeamMember.query().delete()
await Manuscript.query().delete()
......
......@@ -80,3 +80,49 @@ Cypress.Commands.add(
})
},
)
Cypress.Commands.add('createEmptyManuscript', () => {
const createManuscriptMutation = `
mutation{
createManuscript
}
`
makeRequest({
query: createManuscriptMutation,
})
})
Cypress.Commands.add('getCurrentUser', () => {
const currentUserQuery = `
query CurrentUser {
currentUser {
admin
id
teams {
id
}
username
}
}
`
makeRequest({
query: currentUserQuery,
})
})
const makeRequest = body => {
const token = window.localStorage.getItem('token')
cy.request({
method: 'POST',
url: '/graphql',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
authorization: `Bearer ${token}`,
},
body,
})
}
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