-
Notifications
You must be signed in to change notification settings - Fork 1
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
MPDX - (#8032, #8033, #7533, #8034, #8035, #8036, #8037) - FixCommitmentInfo #974
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3da36e2
Updates Fix Commitment Info to use Formik; Adds dropdown for pledge c…
wjames111 587f8b0
Adds modal for hide contact; Fix lost work with currencies dropdown.
wjames111 46de743
Added update contact function for all update types.
wjames111 69c0c95
Adds tab query string for contact details tab.
wjames111 305ce81
Updates field in fixCommitmentInfo Contact to use StyledInput.
wjames111 a080332
Add infinite loading to fixCommitmentInfo.
wjames111 9d374b6
Small edits to the FixCommitmentInfo tool; added tests and mocks.
wjames111 bb48c79
PR review edits for FixCommitmentInfo
wjames111 54ecccc
Merge branch 'main' into mpdx-fix-commitment-info
wjames111 fbabcd8
Fix error from rebase.
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
95 changes: 95 additions & 0 deletions
95
pages/accountLists/[accountListId]/tools/fix/commitmentInfo/[[...contactId]].page.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,95 @@ | ||
import { useRouter } from 'next/router'; | ||
import { ThemeProvider } from '@mui/material/styles'; | ||
import { render, waitFor } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { ErgonoMockShape } from 'graphql-ergonomock'; | ||
import { getSession } from 'next-auth/react'; | ||
import { SnackbarProvider } from 'notistack'; | ||
import { I18nextProvider } from 'react-i18next'; | ||
import { VirtuosoMockContext } from 'react-virtuoso'; | ||
import TestRouter from '__tests__/util/TestRouter'; | ||
import { GqlMockedProvider } from '__tests__/util/graphqlMocking'; | ||
import { mockInvalidStatusesResponse } from 'src/components/Tool/FixCommitmentInfo/FixCommitmentInfoMocks'; | ||
import { InvalidStatusesQuery } from 'src/components/Tool/FixCommitmentInfo/GetInvalidStatuses.generated'; | ||
import i18n from 'src/lib/i18n'; | ||
import theme from 'src/theme'; | ||
import FixCommitmentInfoPage from './[[...contactId]].page'; | ||
|
||
jest.mock('next/router', () => ({ | ||
useRouter: jest.fn(), | ||
})); | ||
|
||
const pushFn = jest.fn(); | ||
const accountListId = 'account-list-1'; | ||
const session = { | ||
expires: '2021-10-28T14:48:20.897Z', | ||
user: { | ||
email: 'Chair Library Bed', | ||
image: null, | ||
name: 'Dung Tapestry', | ||
token: 'superLongJwtString', | ||
}, | ||
}; | ||
const Components = ({ | ||
mockNodes = mockInvalidStatusesResponse, | ||
}: { | ||
mockNodes?: ErgonoMockShape[]; | ||
}) => ( | ||
<ThemeProvider theme={theme}> | ||
<TestRouter> | ||
<GqlMockedProvider<{ | ||
InvalidStatuses: InvalidStatusesQuery; | ||
}> | ||
mocks={{ | ||
InvalidStatuses: { | ||
contacts: { | ||
nodes: mockNodes, | ||
}, | ||
}, | ||
}} | ||
> | ||
<I18nextProvider i18n={i18n}> | ||
<SnackbarProvider> | ||
<VirtuosoMockContext.Provider | ||
value={{ viewportHeight: 1000, itemHeight: 100 }} | ||
> | ||
<FixCommitmentInfoPage /> | ||
</VirtuosoMockContext.Provider> | ||
</SnackbarProvider> | ||
</I18nextProvider> | ||
</GqlMockedProvider> | ||
</TestRouter> | ||
</ThemeProvider> | ||
); | ||
|
||
describe('FixCommitmentInfoPage', () => { | ||
beforeEach(() => { | ||
(getSession as jest.Mock).mockResolvedValue(session); | ||
(useRouter as jest.Mock).mockReturnValue({ | ||
query: { | ||
accountListId, | ||
}, | ||
isReady: true, | ||
push: pushFn, | ||
}); | ||
}); | ||
|
||
it('should open up contact details', async () => { | ||
const { getByText, queryByText } = render(<Components />); | ||
await waitFor(() => expect(queryByText('Tester 1')).toBeInTheDocument()); | ||
|
||
const contactName = getByText('Tester 1'); | ||
|
||
expect(contactName).toBeInTheDocument(); | ||
userEvent.click(contactName); | ||
|
||
await waitFor(() => { | ||
expect(pushFn).toHaveBeenCalledWith({ | ||
pathname: | ||
'/accountLists/account-list-1/tools/fix/commitmentInfo/tester-1', | ||
|
||
query: { tab: 'Donations' }, | ||
}); | ||
}); | ||
}); | ||
}); |
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
13 changes: 10 additions & 3 deletions
13
pages/accountLists/[accountListId]/tools/useToolsHelper.ts
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
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.
I think we already have this functionailty on line 61 - 63. Sorry, I didn't catch that before. It uses
query?.tab
instead but is the same thing.