-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add back help links to individual articles
- Loading branch information
Showing
8 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/components/Coaching/CoachingDetail/HelpButton.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { render } from '@testing-library/react'; | ||
import { HelpButton } from './HelpButton'; | ||
|
||
describe('help button', () => { | ||
it('renders a link to the help article', () => { | ||
process.env.HELP_URL_COACHING_ACTIVITY = 'https://help.org'; | ||
|
||
const { getByRole } = render( | ||
<HelpButton articleVar="HELP_URL_COACHING_ACTIVITY" />, | ||
); | ||
|
||
expect(getByRole('link', { name: 'Help' })).toHaveAttribute( | ||
'href', | ||
'https://help.org', | ||
); | ||
}); | ||
|
||
it('renders nothing if the help article does not exist', () => { | ||
process.env.HELP_URL_COACHING_ACTIVITY = ''; | ||
|
||
const { queryByRole } = render( | ||
<HelpButton articleVar="HELP_URL_COACHING_ACTIVITY" />, | ||
); | ||
|
||
expect(queryByRole('link', { name: 'Help' })).not.toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import QuestionMark from '@mui/icons-material/QuestionMark'; | ||
import { IconButton } from '@mui/material'; | ||
import { ArticleVar, articles } from 'src/lib/helpjuice'; | ||
|
||
interface HelpButtonProps { | ||
articleVar: ArticleVar; | ||
} | ||
|
||
export const HelpButton: React.FC<HelpButtonProps> = ({ articleVar }) => { | ||
const url = articles[articleVar]; | ||
if (!url) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<IconButton href={url} target="_blank" size="small" aria-label="Help"> | ||
<QuestionMark /> | ||
</IconButton> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export type ArticleVar = keyof typeof articles; | ||
|
||
// We are using getters so that when tests override environment variables, the changes will be picked up | ||
export const articles = { | ||
get HELP_URL_COACHING_ACTIVITY() { | ||
return process.env.HELP_URL_COACHING_ACTIVITY; | ||
}, | ||
get HELP_URL_COACHING_APPOINTMENTS_AND_RESULTS() { | ||
return process.env.HELP_URL_COACHING_APPOINTMENTS_AND_RESULTS; | ||
}, | ||
get HELP_URL_SETUP_FIND_ORGANIZATION() { | ||
return process.env.HELP_URL_SETUP_FIND_ORGANIZATION; | ||
}, | ||
}; |