-
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.
MPDX - (#8032, #8033, #7533, #8034, #8035, #8036, #8037) - FixCommitm…
…entInfo (#974) * Updates Fix Commitment Info Tool
- Loading branch information
Showing
12 changed files
with
1,183 additions
and
458 deletions.
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.