Skip to content

Commit 63e7b3c

Browse files
MailineNQRuhier
andauthored
feat: disable help button in visualize mode (#350)
* feat: disable help button in collect mode * chore: remove log * chore: redo test * bump: 2.8.1.rc-help-button * bump: 2.8.1.rc-help-button.0 * bump: 2.8.1-rc-help-button.0 --------- Co-authored-by: Quentin Ruhier <quentin.ruhier@insee.fr>
1 parent 28ec969 commit 63e7b3c

5 files changed

Lines changed: 46 additions & 3 deletions

File tree

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ VITE_MULTIMODE_ENABLED=0
4242
VITE_AUTOSAVE_INTERVAL=
4343

4444
# trust uri domains separated by comma ","
45-
VITE_TRUST_URI_DOMAINS=localhost
45+
VITE_TRUST_URI_DOMAINS=localhost

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Disable assistance button when not in collect mode or when assistance url is not provided.
13+
1014
## [2.8.0](https://github.com/InseeFr/stromae-dsfr/releases/tag/2.8.0) - 2026-05-20
1115

1216
### Changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "stromae-dsfr",
33
"private": true,
4-
"version": "2.8.0",
4+
"version": "2.8.1-rc-help-button.0",
55
"type": "module",
66
"scripts": {
77
"prepare": "husky && vite-envs update-types",

src/components/layout/Header.test.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,43 @@ describe('Header & Footer', () => {
263263
expect(getByText('My Test Label')).toBeInTheDocument()
264264
})
265265
})
266+
267+
it('should disable help button when not in collect mode', async () => {
268+
vi.mocked(useMode).mockReturnValueOnce(MODE_TYPE.VISUALIZE)
269+
270+
const { getAllByText } = renderWithRouter(
271+
<TelemetryContext.Provider
272+
value={{
273+
isTelemetryEnabled: true,
274+
pushEvent: vi.fn(),
275+
setDefaultValues: () => {},
276+
}}
277+
>
278+
<Header />
279+
</TelemetryContext.Provider>,
280+
)
281+
282+
const helpButton = getAllByText('Need help?')[0]
283+
expect(helpButton).toHaveAttribute('disabled')
284+
})
285+
286+
it('should disable help button when assistance url is not provided', async () => {
287+
vi.stubEnv('VITE_PORTAIL_URL', '')
288+
289+
vi.mocked(useMode).mockReturnValueOnce(MODE_TYPE.COLLECT)
290+
const { getAllByText } = renderWithRouter(
291+
<TelemetryContext.Provider
292+
value={{
293+
isTelemetryEnabled: true,
294+
pushEvent: vi.fn(),
295+
setDefaultValues: () => {},
296+
}}
297+
>
298+
<Header />
299+
</TelemetryContext.Provider>,
300+
)
301+
302+
const helpButton = getAllByText('Need help?')[0]
303+
expect(helpButton).toHaveAttribute('disabled')
304+
})
266305
})

src/components/layout/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function Header() {
9696
iconId: 'fr-icon-customer-service-fill',
9797
linkProps: {
9898
href: collectPath ? assistanceHref : '',
99-
disabled: isCollectRoute,
99+
disabled: !isCollectRoute || assistanceHref === '',
100100
onClick:
101101
isCollectRoute && isTelemetryEnabled
102102
? () => {

0 commit comments

Comments
 (0)