-
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.
3. Appeal Header - Move files and allow for editing info
- Loading branch information
Showing
15 changed files
with
428 additions
and
67 deletions.
There are no files selected for viewing
58 changes: 0 additions & 58 deletions
58
src/components/Tool/Appeal/AppealDetails/AppealHeaderInfo.test.tsx
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
src/components/Tool/Appeal/AppealDetails/AppealHeaderInfo/AppealHeaderInfo.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,86 @@ | ||
import { ThemeProvider } from '@mui/material/styles'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers'; | ||
import { AdapterLuxon } from '@mui/x-date-pickers/AdapterLuxon'; | ||
import { render, waitFor } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { SnackbarProvider } from 'notistack'; | ||
import TestRouter from '__tests__/util/TestRouter'; | ||
import { GqlMockedProvider } from '__tests__/util/graphqlMocking'; | ||
import { AppealsWrapper } from 'pages/accountLists/[accountListId]/tools/appeals/AppealsWrapper'; | ||
import theme from 'src/theme'; | ||
import { appealInfo } from '../../appealMockData'; | ||
import { AppealHeaderInfo, AppealHeaderInfoProps } from './AppealHeaderInfo'; | ||
|
||
const router = { | ||
query: { accountListId: 'aaa' }, | ||
isReady: true, | ||
}; | ||
|
||
const Components = ({ appealInfo, loading }: AppealHeaderInfoProps) => ( | ||
<LocalizationProvider dateAdapter={AdapterLuxon}> | ||
<ThemeProvider theme={theme}> | ||
<SnackbarProvider> | ||
<TestRouter router={router}> | ||
<GqlMockedProvider> | ||
<AppealsWrapper> | ||
<AppealHeaderInfo appealInfo={appealInfo} loading={loading} /> | ||
</AppealsWrapper> | ||
</GqlMockedProvider> | ||
</TestRouter> | ||
</SnackbarProvider> | ||
</ThemeProvider> | ||
</LocalizationProvider> | ||
); | ||
|
||
describe('AppealHeaderInfo', () => { | ||
it('renders skeletons when loading', () => { | ||
const { getByTestId, getByRole } = render( | ||
<Components appealInfo={appealInfo} loading={true} />, | ||
); | ||
|
||
expect(getByRole('heading', { name: 'Name:' })).toBeInTheDocument(); | ||
expect(getByTestId('appeal-name-skeleton')).toBeInTheDocument(); | ||
|
||
expect(getByRole('heading', { name: 'Goal:' })).toBeInTheDocument(); | ||
expect(getByTestId('appeal-goal-skeleton')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders appeal info', async () => { | ||
const { getByText, findByText } = render( | ||
<Components appealInfo={appealInfo} loading={false} />, | ||
); | ||
|
||
expect(await findByText('Test Appeal')).toBeInTheDocument(); | ||
|
||
expect(getByText('$100')).toBeInTheDocument(); | ||
expect(getByText(/\$50 \(50%\)/i)).toBeInTheDocument(); | ||
expect(getByText(/\$100 \(100%\)/i)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should allow user to open the edit appeal info modal', async () => { | ||
const { findByText, findByRole, getByTestId, getByRole, queryByRole } = | ||
render(<Components appealInfo={appealInfo} loading={false} />); | ||
|
||
expect(await findByText('Test Appeal')).toBeInTheDocument(); | ||
|
||
userEvent.click(getByTestId('edit-appeal-name')); | ||
|
||
expect( | ||
await findByRole('heading', { name: 'Edit Appeal' }), | ||
).toBeInTheDocument(); | ||
|
||
userEvent.click(getByTestId('edit-appeal-goal')); | ||
|
||
expect( | ||
await findByRole('heading', { name: 'Edit Appeal' }), | ||
).toBeInTheDocument(); | ||
|
||
userEvent.click(getByRole('button', { name: 'Close' })); | ||
|
||
await waitFor(() => { | ||
expect( | ||
queryByRole('heading', { name: 'Edit Appeal' }), | ||
).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
File renamed without changes.
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
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
12 changes: 12 additions & 0 deletions
12
...ponents/Tool/Appeal/Modals/EditAppealHeaderInfoModal/DynamicEditAppealHeaderInfoModal.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,12 @@ | ||
import dynamic from 'next/dynamic'; | ||
import { DynamicModalPlaceholder } from 'src/components/DynamicPlaceholders/DynamicModalPlaceholder'; | ||
|
||
export const preloadEditAppealHeaderInfoModal = () => | ||
import( | ||
/* webpackChunkName: "EditAppealHeaderInfoModal" */ './EditAppealHeaderInfoModal' | ||
).then(({ EditAppealHeaderInfoModal }) => EditAppealHeaderInfoModal); | ||
|
||
export const DynamicEditAppealHeaderInfoModal = dynamic( | ||
preloadEditAppealHeaderInfoModal, | ||
{ loading: DynamicModalPlaceholder }, | ||
); |
8 changes: 8 additions & 0 deletions
8
src/components/Tool/Appeal/Modals/EditAppealHeaderInfoModal/EditAppeal.graphql
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,8 @@ | ||
mutation UpdateAppeal($input: AppealUpdateMutationInput!) { | ||
updateAppeal(input: $input) { | ||
appeal { | ||
name | ||
amount | ||
} | ||
} | ||
} |
Oops, something went wrong.