Files
go-no-go/cypress/e2e/questionnaire-flow.cy.js
2026-02-03 20:18:08 +01:00

44 lines
1.4 KiB
JavaScript

describe('Questionnaire Flow', () => {
beforeEach(() => {
cy.resetDatabase()
cy.login()
})
it('completes the full questionnaire flow from landing to result', () => {
// 1. Landing page — click Continue
cy.get('[data-cy="start-screening"]').click()
// 2. Screening — answer all 10 questions with Yes
for (let i = 1; i <= 10; i++) {
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
cy.get('[data-cy="yes"]').check({ force: true })
})
}
cy.get('[data-cy="submit-screening"]').click()
// 3. Screening result — should pass with 10/10
cy.get('[data-cy="result-passed"]').should('exist')
cy.get('[data-cy="screening-score"]').should('contain', '10')
// 4. Select first category (Audit)
cy.get('[data-cy="category-select"]').within(() => {
cy.contains('button', 'Start').first().click()
})
// 5. Session/Show — should see questionnaire
cy.url().should('include', '/sessions/')
cy.contains('Questionnaire').should('be.visible')
// 6. Complete session
cy.get('[data-cy="complete-session"]').click()
// 7. Session result page
cy.url().should('include', '/result')
cy.get('[data-cy="session-result"]').should('exist')
// 8. Click Again to go back
cy.get('[data-cy="start-new"]').click()
cy.url().should('eq', Cypress.config('baseUrl') + '/')
})
})