Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions frontend/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,31 @@ describe('StayLong Continuous Home Path', () => {
expect(screen.getByRole('radio', { name: 'I’m not sure who to involve yet' })).toBeVisible()
})

it('keeps a consent field aligned with the accepted supporter-choice UI', async () => {
const user = userEvent.setup()
const consentQuestion = {
key: 'information_sharing_consent',
question: 'Do you give consent for us to share these details with your nominated support contacts or assessors?',
reason: 'Consent is required before sending household information to external supporters or care teams.',
}
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({
ok: true,
json: async () => workflow('intake', { questions: [...questions.slice(0, 2), consentQuestion] }),
}))
render(<App />)

fireEvent.change(screen.getByRole('textbox', { name: 'Describe what is becoming difficult' }), { target: { value: concern } })
await user.click(screen.getByRole('button', { name: 'Start my plan' }))
await screen.findByRole('heading', { name: 'A few details will help prepare your plan' })

expect(screen.getByRole('group', { name: 'Would you like to involve anyone now?' })).toBeVisible()
expect(screen.getByRole('radio', { name: 'Not right now' })).toBeVisible()
expect(screen.getByRole('radio', { name: 'I’d like to involve someone' })).toBeVisible()
expect(screen.getByRole('radio', { name: 'I’m not sure who to involve yet' })).toBeVisible()
expect(screen.getByText('StayLong only shares information when invited.')).toBeVisible()
expect(screen.queryByRole('textbox', { name: /consent/i })).not.toBeInTheDocument()
})

it('explains that the plan is being prepared while the start request is pending', async () => {
const user = userEvent.setup()
let resolveRequest: ((value: unknown) => void) | undefined
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ const assessmentStatusOptions = [
'No, not yet',
'I’m not sure',
]
const supporterQuestion = 'Would you like to involve anyone now?'
const supporterReason = 'StayLong only shares information when invited.'
const supporterOptions = ['Not right now', 'I’d like to involve someone', 'I’m not sure who to involve yet']
const quickAnswerOptions: Record<string, string[]> = {
housing_tenure: ['I own my home', 'I rent my home', 'I’m not sure about the home yet'],
support_contacts: ['Not right now', 'I’d like to involve someone', 'I’m not sure who to involve yet'],
support_contacts: supporterOptions,
information_sharing_consent: supporterOptions,
}

const timelineLabels: Record<string, string> = {
Expand Down Expand Up @@ -154,7 +158,8 @@ function IntakeQuestion({ question, value, onChange }: { question: Fact; value:
}
const options = quickAnswerOptions[question.key]
if (options) {
return <fieldset className="input-group choice-group"><legend>{question.question}</legend><div className="choice-options">{options.map((option) => <label className="choice-option" key={option}><input checked={value === option} name={question.key} onChange={() => onChange(option)} required type="radio" value={option} /><span>{option}</span></label>)}</div><p className="field-help">{question.reason}</p></fieldset>
const isSupporterQuestion = question.key === 'support_contacts' || question.key === 'information_sharing_consent'
return <fieldset className="input-group choice-group"><legend>{isSupporterQuestion ? supporterQuestion : question.question}</legend><div className="choice-options">{options.map((option) => <label className="choice-option" key={option}><input checked={value === option} name={question.key} onChange={() => onChange(option)} required type="radio" value={option} /><span>{option}</span></label>)}</div><p className="field-help">{isSupporterQuestion ? supporterReason : question.reason}</p></fieldset>
}
return <div className="input-group"><label htmlFor={question.key}>{question.question}</label><input id={question.key} onChange={(event) => onChange(event.target.value)} required value={value} /><p className="field-help">{question.reason}</p></div>
}
Expand Down
Loading