finishes 13 and 14
This commit is contained in:
43
cypress/e2e/questionnaire-flow.cy.js
Normal file
43
cypress/e2e/questionnaire-flow.cy.js
Normal file
@@ -0,0 +1,43 @@
|
||||
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') + '/')
|
||||
})
|
||||
})
|
||||
54
cypress/e2e/result-page.cy.js
Normal file
54
cypress/e2e/result-page.cy.js
Normal file
@@ -0,0 +1,54 @@
|
||||
describe('Result Page', () => {
|
||||
beforeEach(() => {
|
||||
cy.resetDatabase()
|
||||
cy.login()
|
||||
})
|
||||
|
||||
function passScreeningAndStartSession() {
|
||||
cy.get('[data-cy="start-screening"]').click()
|
||||
|
||||
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()
|
||||
|
||||
cy.get('[data-cy="category-select"]').within(() => {
|
||||
cy.contains('button', 'Start').first().click()
|
||||
})
|
||||
|
||||
cy.url().should('include', '/sessions/')
|
||||
}
|
||||
|
||||
it('shows session result after completion', () => {
|
||||
passScreeningAndStartSession()
|
||||
|
||||
// Just complete without answering specific questions
|
||||
cy.get('[data-cy="complete-session"]').click()
|
||||
|
||||
cy.url().should('include', '/result')
|
||||
cy.get('[data-cy="session-result"]').should('exist')
|
||||
})
|
||||
|
||||
it('shows the result badge with correct result type', () => {
|
||||
passScreeningAndStartSession()
|
||||
|
||||
cy.get('[data-cy="complete-session"]').click()
|
||||
|
||||
cy.url().should('include', '/result')
|
||||
// Should show one of the result types
|
||||
cy.get('[data-cy="session-result"]').should('exist')
|
||||
cy.get('[data-cy^="result-"]').should('exist')
|
||||
})
|
||||
|
||||
it('can start over from result page', () => {
|
||||
passScreeningAndStartSession()
|
||||
|
||||
cy.get('[data-cy="complete-session"]').click()
|
||||
cy.url().should('include', '/result')
|
||||
|
||||
cy.get('[data-cy="start-new"]').click()
|
||||
cy.url().should('eq', Cypress.config('baseUrl') + '/')
|
||||
})
|
||||
})
|
||||
69
cypress/e2e/scoring-display.cy.js
Normal file
69
cypress/e2e/scoring-display.cy.js
Normal file
@@ -0,0 +1,69 @@
|
||||
describe('Scoring Display', () => {
|
||||
beforeEach(() => {
|
||||
cy.resetDatabase()
|
||||
cy.login()
|
||||
})
|
||||
|
||||
it('shows No Go result when fewer than 5 yes answers', () => {
|
||||
cy.get('[data-cy="start-screening"]').click()
|
||||
|
||||
// Answer 4 yes, 6 no
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="yes"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
for (let i = 5; i <= 10; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="no"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
cy.get('[data-cy="submit-screening"]').click()
|
||||
|
||||
// Should fail
|
||||
cy.get('[data-cy="result-failed"]').should('exist')
|
||||
cy.get('[data-cy="screening-score"]').should('contain', '4')
|
||||
cy.get('[data-cy="category-select"]').should('not.exist')
|
||||
})
|
||||
|
||||
it('passes at boundary with exactly 5 yes answers', () => {
|
||||
cy.get('[data-cy="start-screening"]').click()
|
||||
|
||||
// Answer 5 yes, 5 no
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="yes"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
for (let i = 6; i <= 10; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="no"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
cy.get('[data-cy="submit-screening"]').click()
|
||||
|
||||
// Should pass
|
||||
cy.get('[data-cy="result-passed"]').should('exist')
|
||||
cy.get('[data-cy="screening-score"]').should('contain', '5')
|
||||
cy.get('[data-cy="category-select"]').should('exist')
|
||||
})
|
||||
|
||||
it('displays the score correctly', () => {
|
||||
cy.get('[data-cy="start-screening"]').click()
|
||||
|
||||
// Answer 7 yes, 3 no
|
||||
for (let i = 1; i <= 7; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="yes"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
for (let i = 8; i <= 10; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="no"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
cy.get('[data-cy="submit-screening"]').click()
|
||||
|
||||
cy.get('[data-cy="screening-score"]').should('contain', '7')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user