Skip to content

Commit

Permalink
refactor: removes the group
Browse files Browse the repository at this point in the history
The change colour links don't get associated to
the group as they aren't form elements. So just
added visually hidden text to the checkbox with
the prognosis name.
  • Loading branch information
GentlemanHal committed Jul 6, 2024
1 parent 68d6b63 commit 236d9b7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 30 deletions.
12 changes: 9 additions & 3 deletions journey/settings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ describe('Settings', () => {
cy.locate('duration').should('not.exist')
cy.findByRole('button', { name: /dismiss/i }).click()

cy.findAllByLabelText('Show on the Monitor page').each((prognosis) => {
cy.wrap(prognosis).check()
})
cy.findByLabelText('Show sick prognosis on the Monitor page').check()
cy.findByLabelText(
'Show sick building prognosis on the Monitor page',
).check()
cy.findByLabelText(
'Show healthy building prognosis on the Monitor page',
).check()
cy.findByLabelText('Show unknown prognosis on the Monitor page').check()
cy.findByLabelText('Show healthy prognosis on the Monitor page').check()

cy.findByLabelText('Amount of project to show').select('Large')
cy.findByLabelText('Sort projects by').select('prognosis')
Expand Down
2 changes: 1 addition & 1 deletion resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.17.0
7.17.1
38 changes: 20 additions & 18 deletions src/client/settings/display/DisplayPrognosisSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { Card } from '../../common/card/Card'
import { CardHeading } from '../../common/card/CardHeading'
import { Checkbox } from '../../common/forms/Checkbox'
import { ChangeColoursLink } from '../colours/ChangeColoursLink'
import { Group } from '../../common/forms/Group'
import { IconPrognosis } from '../../common/icons/prognosis/IconPrognosis'
import styles from './display-prognosis-selection.scss'
import { VisuallyHidden } from '../../common/VisuallyHidden'

function groupTitle(prognosis: Prognosis): string {
return `${capitalize(prognosisDisplay(prognosis))} prognosis`
Expand Down Expand Up @@ -60,23 +60,25 @@ export function DisplayPrognosisSelection(): ReactElement {
}}
key={prognosis}
>
<Group title={groupTitle(prognosis)}>
<Checkbox
className={styles.checkbox}
checked={showing.includes(prognosis)}
onToggle={(show) =>
dispatch(setShowPrognosis({ prognosis, show }))
}
>
Show on the Monitor page
</Checkbox>
<ChangeColoursLink
path={prognosis}
additionalContext={`for ${prognosisDisplay(
prognosis,
)} prognosis`}
/>
</Group>
<Checkbox
className={styles.checkbox}
checked={showing.includes(prognosis)}
onToggle={(show) =>
dispatch(setShowPrognosis({ prognosis, show }))
}
>
Show{' '}
<VisuallyHidden>
{prognosisDisplay(prognosis)} prognosis
</VisuallyHidden>{' '}
on the Monitor page
</Checkbox>
<ChangeColoursLink
path={prognosis}
additionalContext={`for ${prognosisDisplay(
prognosis,
)} prognosis`}
/>
</Card>
)
})}
Expand Down
17 changes: 9 additions & 8 deletions src/client/settings/display/DisplaySettingsPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getShowPrognosis,
getShowPrognosisName,
} from './DisplaySettingsReducer'
import { screen, within } from '@testing-library/react'
import { screen } from '@testing-library/react'
import { DisplaySettingsPage } from './DisplaySettingsPage'
import { Prognosis } from '../../domain/Project'

Expand Down Expand Up @@ -66,11 +66,11 @@ it('should set the show prognosis name setting', async () => {
describe('showing on the monitor page', () => {
it.each`
prognosis | name
${Prognosis.healthy} | ${'Healthy prognosis'}
${Prognosis.healthyBuilding} | ${'Healthy building prognosis'}
${Prognosis.sick} | ${'Sick prognosis'}
${Prognosis.sickBuilding} | ${'Sick building prognosis'}
${Prognosis.unknown} | ${'Unknown prognosis'}
${Prognosis.healthy} | ${'healthy prognosis'}
${Prognosis.healthyBuilding} | ${'healthy building prognosis'}
${Prognosis.sick} | ${'sick prognosis'}
${Prognosis.sickBuilding} | ${'sick building prognosis'}
${Prognosis.unknown} | ${'unknown prognosis'}
`(
'$prognosis',
async ({ prognosis, name }: { prognosis: Prognosis; name: string }) => {
Expand All @@ -81,8 +81,9 @@ describe('showing on the monitor page', () => {
}

const { store, user } = render(<DisplaySettingsPage />, { state })
const group = screen.getByRole('group', { name })
await user.click(within(group).getByLabelText('Show on the Monitor page'))
await user.click(
screen.getByLabelText(`Show ${name} on the Monitor page`),
)

expect(getShowPrognosis(store.getState())).toContain(prognosis)
},
Expand Down

0 comments on commit 236d9b7

Please sign in to comment.