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

55 lines
1.5 KiB
JavaScript

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') + '/')
})
})