Skip to content

Commit

Permalink
Fix Cypress tests again
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxwellBo committed Jan 10, 2021
1 parent e660388 commit ff848c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
14 changes: 11 additions & 3 deletions cypress/integration/onboard.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { purge, enterUsernameAndPassword } from './utils'
import { purge, enterUsername, enterPassword } from './utils'

const CHAIRPERSON = 'Test chairperson'
const TOPIC = 'Test topic'
Expand All @@ -18,13 +18,21 @@ describe('Run through creating a new committee', function () {
})

it('attempts to create an account that is already in use, and then logs in', function () {
cy.get('button').contains('Login').then(() => {
enterUsernameAndPassword()
cy.get('button').contains('Log in').then(() => {
cy.contains('Create account').click()

enterUsername()
enterPassword()

cy.contains('Create account').click()

cy.contains('in use by another account')

cy.get('button').contains('Login').click()

enterPassword()

cy.get('button').contains('Log in').click()
})
})

Expand Down
20 changes: 7 additions & 13 deletions cypress/integration/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,24 @@ export function purge() {
cy.clearLocalStorage()
}

export function enterUsernameAndPassword() {
export function enterUsername() {
cy.get('input[autocomplete=email]')
.type('[email protected]')
.should('have.value', '[email protected]')
}

export function enterPassword() {
cy.get('input[autocomplete=current-password]')
.type('fakepassword')
.should('have.value', 'fakepassword')
}

export function enterUsernameAndPasswordAndHitsEnter() {
cy.get('input[autocomplete=email]')
.type('[email protected]')
.should('have.value', '[email protected]')

cy.get('input[autocomplete=current-password]')
.type('fakepassword{enter}')
.should('have.value', 'fakepassword')
}

export function invokeModalAndLogin() {
cy.get('button').contains('Log in').click()
enterUsernameAndPassword()
cy.get('.modal').find('button').contains('Login').click()
cy.get('button').contains('Login').click()
enterUsername()
enterPassword()
cy.get('.modal').find('button').contains('Log in').click()
cy.get('body').type('{esc}')
cy.wait(2000)
}

0 comments on commit ff848c7

Please sign in to comment.