Skip to content

Commit

Permalink
Add e2e test of swapping choices
Browse files Browse the repository at this point in the history
  • Loading branch information
leung018 committed May 6, 2024
1 parent 873bf56 commit 0b005c4
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cypress/e2e/spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,38 @@ describe('End to end tests', () => {
cy.contains('Answer 1')
cy.contains('Answer 2')
})

it('should swap the choices of question set after submit', () => {
cy.visit('/')
cy.contains('Add New Question Set').click()

// Adding question set

cy.contains('Question Set Name').type('Test Question Set')
cy.contains('Question 1').type('Test Question 1')

// choice 1
cy.findByLabelText('answer of question 1 choice 1').type('Answer 1')
cy.findByLabelText('question 1 choice 1 is correct answer').click()

// choice 2
cy.findByLabelText('answer of question 1 choice 2').type('Answer 2')

cy.contains('Save').click()

cy.visit('/')
cy.contains('Take Quiz').click()
cy.contains('Submit').click()

cy.visit('/')
cy.contains('Take Quiz').click()

cy.findByText('Answer 1').then(($el1) => {
cy.findByText('Answer 2').then(($el2) => {
expect($el2[0].compareDocumentPosition($el1[0])).to.eq(
Node.DOCUMENT_POSITION_FOLLOWING,
)
})
})
})
})

0 comments on commit 0b005c4

Please sign in to comment.