Skip to content

Commit 236d9b7

Browse files
committedJul 6, 2024··
refactor: removes the group
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.
1 parent 68d6b63 commit 236d9b7

File tree

4 files changed

+39
-30
lines changed

4 files changed

+39
-30
lines changed
 

‎journey/settings.cy.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,15 @@ describe('Settings', () => {
3535
cy.locate('duration').should('not.exist')
3636
cy.findByRole('button', { name: /dismiss/i }).click()
3737

38-
cy.findAllByLabelText('Show on the Monitor page').each((prognosis) => {
39-
cy.wrap(prognosis).check()
40-
})
38+
cy.findByLabelText('Show sick prognosis on the Monitor page').check()
39+
cy.findByLabelText(
40+
'Show sick building prognosis on the Monitor page',
41+
).check()
42+
cy.findByLabelText(
43+
'Show healthy building prognosis on the Monitor page',
44+
).check()
45+
cy.findByLabelText('Show unknown prognosis on the Monitor page').check()
46+
cy.findByLabelText('Show healthy prognosis on the Monitor page').check()
4147

4248
cy.findByLabelText('Amount of project to show').select('Large')
4349
cy.findByLabelText('Sort projects by').select('prognosis')

‎resources/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.17.0
1+
7.17.1

‎src/client/settings/display/DisplayPrognosisSelection.tsx

+20-18
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { Card } from '../../common/card/Card'
1111
import { CardHeading } from '../../common/card/CardHeading'
1212
import { Checkbox } from '../../common/forms/Checkbox'
1313
import { ChangeColoursLink } from '../colours/ChangeColoursLink'
14-
import { Group } from '../../common/forms/Group'
1514
import { IconPrognosis } from '../../common/icons/prognosis/IconPrognosis'
1615
import styles from './display-prognosis-selection.scss'
16+
import { VisuallyHidden } from '../../common/VisuallyHidden'
1717

1818
function groupTitle(prognosis: Prognosis): string {
1919
return `${capitalize(prognosisDisplay(prognosis))} prognosis`
@@ -60,23 +60,25 @@ export function DisplayPrognosisSelection(): ReactElement {
6060
}}
6161
key={prognosis}
6262
>
63-
<Group title={groupTitle(prognosis)}>
64-
<Checkbox
65-
className={styles.checkbox}
66-
checked={showing.includes(prognosis)}
67-
onToggle={(show) =>
68-
dispatch(setShowPrognosis({ prognosis, show }))
69-
}
70-
>
71-
Show on the Monitor page
72-
</Checkbox>
73-
<ChangeColoursLink
74-
path={prognosis}
75-
additionalContext={`for ${prognosisDisplay(
76-
prognosis,
77-
)} prognosis`}
78-
/>
79-
</Group>
63+
<Checkbox
64+
className={styles.checkbox}
65+
checked={showing.includes(prognosis)}
66+
onToggle={(show) =>
67+
dispatch(setShowPrognosis({ prognosis, show }))
68+
}
69+
>
70+
Show{' '}
71+
<VisuallyHidden>
72+
{prognosisDisplay(prognosis)} prognosis
73+
</VisuallyHidden>{' '}
74+
on the Monitor page
75+
</Checkbox>
76+
<ChangeColoursLink
77+
path={prognosis}
78+
additionalContext={`for ${prognosisDisplay(
79+
prognosis,
80+
)} prognosis`}
81+
/>
8082
</Card>
8183
)
8284
})}

‎src/client/settings/display/DisplaySettingsPage.test.tsx

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
getShowPrognosis,
88
getShowPrognosisName,
99
} from './DisplaySettingsReducer'
10-
import { screen, within } from '@testing-library/react'
10+
import { screen } from '@testing-library/react'
1111
import { DisplaySettingsPage } from './DisplaySettingsPage'
1212
import { Prognosis } from '../../domain/Project'
1313

@@ -66,11 +66,11 @@ it('should set the show prognosis name setting', async () => {
6666
describe('showing on the monitor page', () => {
6767
it.each`
6868
prognosis | name
69-
${Prognosis.healthy} | ${'Healthy prognosis'}
70-
${Prognosis.healthyBuilding} | ${'Healthy building prognosis'}
71-
${Prognosis.sick} | ${'Sick prognosis'}
72-
${Prognosis.sickBuilding} | ${'Sick building prognosis'}
73-
${Prognosis.unknown} | ${'Unknown prognosis'}
69+
${Prognosis.healthy} | ${'healthy prognosis'}
70+
${Prognosis.healthyBuilding} | ${'healthy building prognosis'}
71+
${Prognosis.sick} | ${'sick prognosis'}
72+
${Prognosis.sickBuilding} | ${'sick building prognosis'}
73+
${Prognosis.unknown} | ${'unknown prognosis'}
7474
`(
7575
'$prognosis',
7676
async ({ prognosis, name }: { prognosis: Prognosis; name: string }) => {
@@ -81,8 +81,9 @@ describe('showing on the monitor page', () => {
8181
}
8282

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

8788
expect(getShowPrognosis(store.getState())).toContain(prognosis)
8889
},

0 commit comments

Comments
 (0)
Please sign in to comment.