-
Notifications
You must be signed in to change notification settings - Fork 1
MPDX-9327, MPDX-9670 - Fix MHA "Update Current MHA" button visibility and taken/approved amounts displays #1824
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
Merged
Changes from all commits
Commits
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
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 |
|---|---|---|
|
|
@@ -23,21 +23,20 @@ interface TestComponentProps { | |
| push?: jest.Mock; | ||
| query?: { accountListId?: string }; | ||
| }; | ||
| hasOpenRequest?: boolean; | ||
| } | ||
|
|
||
| const TestComponent: React.FC<TestComponentProps> = ({ | ||
| contextValue, | ||
| router = {}, | ||
| hasOpenRequest = false, | ||
| }) => { | ||
| const approvedMHARequest = { | ||
| ...mockMHARequest, | ||
| updatedAt: '2022-12-01', | ||
| requestAttributes: { | ||
| ...mockMHARequest.requestAttributes, | ||
| hrApprovedAt: '2023-01-15', | ||
| approvedOverallAmount: 1500, | ||
| staffSpecific: 1000, | ||
| spouseSpecific: 500, | ||
| }, | ||
| }; | ||
|
|
||
|
|
@@ -52,7 +51,10 @@ const TestComponent: React.FC<TestComponentProps> = ({ | |
| <MinisterHousingAllowanceContext.Provider | ||
| value={contextValue as ContextType} | ||
| > | ||
| <CurrentBoardApproved request={approvedMHARequest} /> | ||
| <CurrentBoardApproved | ||
| request={approvedMHARequest} | ||
| hasOpenRequest={hasOpenRequest} | ||
| /> | ||
| </MinisterHousingAllowanceContext.Provider> | ||
| </GqlMockedProvider> | ||
| </TestRouter> | ||
|
|
@@ -68,6 +70,10 @@ describe('CurrentBoardApproved Component', () => { | |
| isMarried: true, | ||
| preferredName: 'John', | ||
| spousePreferredName: 'Jane', | ||
| userApprovedOverallAmount: 1500, | ||
| spouseApprovedOverallAmount: 1500, | ||
| userTakenAmount: 1000, | ||
| spouseTakenAmount: 500, | ||
| userHcmData: { | ||
| staffInfo: { | ||
| personNumber: '000123456', | ||
|
|
@@ -110,6 +116,8 @@ describe('CurrentBoardApproved Component', () => { | |
| isMarried: false, | ||
| preferredName: 'John', | ||
| spousePreferredName: '', | ||
| userApprovedOverallAmount: 1500, | ||
| userTakenAmount: 1000, | ||
| userHcmData: { | ||
| staffInfo: { | ||
| personNumber: '000123456', | ||
|
|
@@ -139,6 +147,55 @@ describe('CurrentBoardApproved Component', () => { | |
| expect(queryByText('Jane')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('shows distinct per-person approved and claimed amounts from HCM', () => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
[Suggestion] Add a test pinning the null-amount behavior, since this is a money display. A fixture already exists (HCM amounts can be `null`). Example:
it('renders $0.00 when HCM approved/claimed amounts are null', () => {
// contextValue with userApprovedOverallAmount: null, userTakenAmount: null
// assert the intended rendering (currently $0.00; or a dash if the Medium finding is adopted)
});This locks whatever the chosen empty-state behavior is. |
||
| const { getByText } = render( | ||
| <TestComponent | ||
| contextValue={{ | ||
| isMarried: true, | ||
| preferredName: 'John', | ||
| spousePreferredName: 'Jane', | ||
| userApprovedOverallAmount: 2000, | ||
| spouseApprovedOverallAmount: 800, | ||
| userTakenAmount: 1200, | ||
| spouseTakenAmount: 300, | ||
| userHcmData: { | ||
| staffInfo: { personNumber: '000123456' }, | ||
| } as unknown as HcmData, | ||
| spouseHcmData: { | ||
| staffInfo: { personNumber: '100123456' }, | ||
| } as unknown as HcmData, | ||
| }} | ||
| />, | ||
| ); | ||
|
|
||
| // MHA Approved by Board (per person) | ||
| expect(getByText('$2,000.00')).toBeInTheDocument(); | ||
| expect(getByText('$800.00')).toBeInTheDocument(); | ||
| // MHA Claimed in Salary (per person) | ||
| expect(getByText('$1,200.00')).toBeInTheDocument(); | ||
| expect(getByText('$300.00')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders $0.00 when HCM approved/claimed amounts are null', () => { | ||
| const { getAllByText } = render( | ||
| <TestComponent | ||
| contextValue={{ | ||
| isMarried: false, | ||
| preferredName: 'John', | ||
| spousePreferredName: '', | ||
| userApprovedOverallAmount: null, | ||
| userTakenAmount: null, | ||
| userHcmData: { | ||
| staffInfo: { personNumber: '000123456' }, | ||
| } as unknown as HcmData, | ||
| spouseHcmData: null, | ||
| }} | ||
| />, | ||
| ); | ||
|
|
||
| expect(getAllByText('$0.00')).toHaveLength(2); | ||
| }); | ||
|
|
||
| it('should navigate to edit page with new requestId after duplicate mutation', async () => { | ||
| const { getByText } = render( | ||
| <ThemeProvider theme={theme}> | ||
|
|
@@ -172,7 +229,10 @@ describe('CurrentBoardApproved Component', () => { | |
| } as ContextType | ||
| } | ||
| > | ||
| <CurrentBoardApproved request={mockMHARequest} /> | ||
| <CurrentBoardApproved | ||
| request={mockMHARequest} | ||
| hasOpenRequest={false} | ||
| /> | ||
| </MinisterHousingAllowanceContext.Provider> | ||
| </GqlMockedProvider> | ||
| </TestRouter> | ||
|
|
@@ -199,4 +259,26 @@ describe('CurrentBoardApproved Component', () => { | |
| ); | ||
| }); | ||
| }); | ||
|
|
||
| it('should hide Update Current MHA button when there is an open request', () => { | ||
| const { queryByText, getByText } = render( | ||
| <TestComponent | ||
| contextValue={{ | ||
| isMarried: false, | ||
| preferredName: 'John', | ||
| spousePreferredName: '', | ||
| userHcmData: { | ||
| staffInfo: { | ||
| personNumber: '000123456', | ||
| }, | ||
| } as unknown as HcmData, | ||
| spouseHcmData: null, | ||
| }} | ||
| hasOpenRequest | ||
| />, | ||
| ); | ||
|
|
||
| expect(getByText('View Current MHA')).toBeInTheDocument(); | ||
| expect(queryByText('Update Current MHA')).not.toBeInTheDocument(); | ||
| }); | ||
| }); | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.