-
Notifications
You must be signed in to change notification settings - Fork 1
[MPDX-9692] - Load selected NSO cohort #2016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
196ed7a
MPDX-9692 Add timeFormat for hour-and-minute display
wjames111 f4e080f
MPDX-9692 Prompt for training costs when a cohort has none
wjames111 833cc40
MPDX-9692 Announce when the cohort goals were last run and sent
wjames111 1b628ba
MPDX-9692 Use the Cru vermilion token so the training-cost prompt cle…
wjames111 69efca1
MPDX-9692 Cover the training-cost prompt loading and cleared states
wjames111 972c9b1
MPDX-9692 Stop the no-costs cohort fixture claiming its goals were sent
wjames111 99d8196
MPDX-9692 Report only the last run-and-send batch and label its timezone
wjames111 a2ca4ab
MPDX-9692 Combine the two training-cost links into one
wjames111 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
66 changes: 66 additions & 0 deletions
66
src/components/HrTools/MpdGoalAdmin/GoalsSentBanner/GoalsSentBanner.test.tsx
This file contains hidden or 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,66 @@ | ||
| import React from 'react'; | ||
| import { ThemeProvider } from '@mui/material/styles'; | ||
| import { render, waitFor } from '@testing-library/react'; | ||
| import { GqlMockedProvider } from '__tests__/util/graphqlMocking'; | ||
| import theme from 'src/theme'; | ||
| import { MpdGoalAdminProvider } from '../MpdGoalAdminContext'; | ||
| import { | ||
| NewStaffCohortAttendeesQuery, | ||
| NewStaffCohortsQuery, | ||
| } from '../NewStaffCohorts.generated'; | ||
| import { attendeesMock, cohortsMock } from '../mpdGoalAdminMocks'; | ||
| import { GoalsSentBanner } from './GoalsSentBanner'; | ||
|
|
||
| const onCall = jest.fn(); | ||
|
|
||
| /** The same cohort, but never run and sent. */ | ||
| const neverSentMock: NewStaffCohortsQuery = { | ||
| newStaffCohorts: { | ||
| ...cohortsMock.newStaffCohorts, | ||
| nodes: [{ ...cohortsMock.newStaffCohorts.nodes[0], goalsSentAt: null }], | ||
| }, | ||
| }; | ||
|
|
||
| interface TestComponentProps { | ||
| neverSent?: boolean; | ||
| } | ||
|
|
||
| const TestComponent: React.FC<TestComponentProps> = ({ neverSent = false }) => ( | ||
| <ThemeProvider theme={theme}> | ||
| <GqlMockedProvider<{ | ||
| NewStaffCohorts: NewStaffCohortsQuery; | ||
| NewStaffCohortAttendees: NewStaffCohortAttendeesQuery; | ||
| }> | ||
| mocks={{ | ||
| NewStaffCohorts: neverSent ? neverSentMock : cohortsMock, | ||
| NewStaffCohortAttendees: attendeesMock(), | ||
| }} | ||
| onCall={onCall} | ||
| > | ||
| <MpdGoalAdminProvider> | ||
| <GoalsSentBanner /> | ||
| </MpdGoalAdminProvider> | ||
| </GqlMockedProvider> | ||
| </ThemeProvider> | ||
| ); | ||
|
|
||
| describe('GoalsSentBanner', () => { | ||
| it('reports when the cohort goals were last run and sent', async () => { | ||
| const { findByRole } = render(<TestComponent />); | ||
|
|
||
| expect(await findByRole('status')).toHaveTextContent( | ||
| 'Goals were last run and sent on 8/10/2026 at 3:40 PM UTC.', | ||
| ); | ||
| }); | ||
|
|
||
| it('renders nothing until the cohort has been sent at least once', async () => { | ||
| const { queryByRole } = render(<TestComponent neverSent />); | ||
|
|
||
| // The banner renders nothing here, so settle on the cohort query instead; | ||
| // asserting immediately would pass on the pre-load render either way. | ||
| await waitFor(() => | ||
| expect(onCall).toHaveGraphqlOperation('NewStaffCohortAttendees'), | ||
| ); | ||
| expect(queryByRole('status')).not.toBeInTheDocument(); | ||
| }); | ||
| }); |
30 changes: 30 additions & 0 deletions
30
src/components/HrTools/MpdGoalAdmin/GoalsSentBanner/GoalsSentBanner.tsx
This file contains hidden or 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,30 @@ | ||
| import React from 'react'; | ||
| import { Alert } from '@mui/material'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import { useLocale } from 'src/hooks/useLocale'; | ||
| import { dateFormatShort, timeFormat } from 'src/lib/intlFormat'; | ||
| import { useMpdGoalAdmin } from '../MpdGoalAdminContext'; | ||
|
|
||
| /** | ||
| * Confirms the cohort's most recent Run & Send batch. Absent until the first | ||
| * send, so its absence is itself meaningful — don't render a placeholder. | ||
| */ | ||
| export const GoalsSentBanner: React.FC = () => { | ||
| const { t } = useTranslation(); | ||
| const locale = useLocale(); | ||
| const { selectedCohort } = useMpdGoalAdmin(); | ||
| const goalsSentAt = selectedCohort?.goalsSentAt; | ||
|
|
||
| if (!goalsSentAt) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <Alert severity="success" role="status" sx={{ mb: 2 }}> | ||
| {t('Goals were last run and sent on {{date}} at {{time}}.', { | ||
| date: dateFormatShort(goalsSentAt, locale), | ||
| time: timeFormat(goalsSentAt, locale), | ||
| })} | ||
| </Alert> | ||
| ); | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.