Skip to content
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-8220 Donation Designation #1067

Merged
merged 5 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/DonationTable/DonationTable.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fragment DonationTableRow on Donation {
designationAccount {
id
name
accountNumber
}
paymentMethod
}
Expand Down
15 changes: 15 additions & 0 deletions src/components/DonationTable/DonationTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ const TestComponent: React.FC<TestComponentProps> = ({
displayName: 'Donor 1',
},
paymentMethod: 'Check',
designationAccount: {
name: 'Tony Starks Account',
accountNumber: '111111',
},
},
{
id: 'donation-2',
Expand All @@ -92,6 +96,10 @@ const TestComponent: React.FC<TestComponentProps> = ({
displayName: 'Donor 2',
},
paymentMethod: 'Credit Card',
designationAccount: {
name: '',
accountNumber: '080808',
},
},
],
pageInfo: {
Expand Down Expand Up @@ -282,4 +290,11 @@ describe('DonationTable', () => {
}),
);
});

it('shows designation number if there is no designation name', async () => {
const { findByText } = render(<TestComponent />);

expect(await findByText('Tony Starks Account')).toBeInTheDocument();
expect(await findByText('080808')).toBeInTheDocument();
});
});
4 changes: 3 additions & 1 deletion src/components/DonationTable/DonationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ export const createDonationRow = (
currency: data.amount.convertedCurrency,
foreignAmount: data.amount.amount,
foreignCurrency: data.amount.currency,
designationAccount: data.designationAccount.name,
designationAccount: data.designationAccount.name
? data.designationAccount.name
: data.designationAccount.accountNumber,
caleballdrin marked this conversation as resolved.
Show resolved Hide resolved
paymentMethod: data.paymentMethod ?? null,
appealName: data.appeal?.name ?? null,
rawDonation: data,
Expand Down
1 change: 1 addition & 0 deletions src/components/EditDonationModal/EditDonationModal.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ query GetDesignationAccounts($accountListId: ID!) {
id
name
active
designationNumber
caleballdrin marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
52 changes: 52 additions & 0 deletions src/components/EditDonationModal/EditDonationModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ const mocks = {
},
},
},
GetDesignationAccounts: {
designationAccounts: [
{
designationAccounts: [
{
id: '12345',
name: '',
designationNumber: '808080',
},
{
id: '123',
name: 'Tony Starks Account',
designationNumber: '11111',
},
],
},
],
},
};

const donation = gqlMock<EditDonationModalDonationFragment>(
Expand All @@ -62,6 +80,10 @@ const donationWithAppeal = gqlMock<EditDonationModalDonationFragment>(
appealAmount: {
amount: 50,
},
designationAccount: {
id: '12345',
name: '',
},
},
},
);
Expand Down Expand Up @@ -104,6 +126,36 @@ describe('EditDonationModal', () => {
expect(getByRole('textbox', { name: 'Amount' })).toHaveValue('100');
});

it('renders designation accounts', async () => {
const mutationSpy = jest.fn();
const { getByRole, getByText, findByText } = render(
<SnackbarProvider>
<LocalizationProvider dateAdapter={AdapterLuxon}>
<ThemeProvider theme={theme}>
<TestRouter router={router}>
<GqlMockedProvider<{ UpdateDonation: UpdateDonationMutation }>
mocks={mocks}
onCall={mutationSpy}
>
<EditDonationModal
donation={donationWithAppeal}
open={true}
handleClose={handleClose}
/>
</GqlMockedProvider>
</TestRouter>
</ThemeProvider>
</LocalizationProvider>
</SnackbarProvider>,
);

expect(getByText('Edit Donation')).toBeInTheDocument();

expect(await findByText('808080')).toBeInTheDocument();
userEvent.click(getByRole('combobox', { name: 'Designation Account' }));
expect(await findByText('Tony Starks Account')).toBeInTheDocument();
});

it('renders with appeal', async () => {
const mutationSpy = jest.fn();
const { getByRole, getByText } = render(
Expand Down
4 changes: 3 additions & 1 deletion src/components/EditDonationModal/EditDonationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ export const EditDonationModal: React.FC<EditDonationModalProps> = ({
)
.map((account) => (
<MenuItem key={account.id} value={account.id}>
{account.name}
{account.name
? account.name
: account.designationNumber}
caleballdrin marked this conversation as resolved.
Show resolved Hide resolved
</MenuItem>
))}
</Select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ describe('MultiPageMenu', () => {
designationAccounts: [
{
designationAccounts: [
{ id: 'account-1', name: 'Account 1' },
{ id: 'account-2', name: 'Account 2' },
{ id: 'account-3', name: 'Account 3' },
{ id: 'account-1', name: 'Account 1', designationNumber: '' },
{ id: 'account-2', name: 'Account 2', designationNumber: '' },
{ id: 'account-3', name: 'Account 3', designationNumber: '' },
{ id: 'account-4', name: '', designationNumber: '4444' },
],
},
],
Expand Down Expand Up @@ -111,6 +112,7 @@ describe('MultiPageMenu', () => {
expect(getAllByRole('option').map((option) => option.textContent)).toEqual([
'Account 2',
'Account 3',
'4444',
]);
userEvent.click(getByRole('option', { name: 'Account 2' }));
expect(setDesignationAccounts).toHaveBeenLastCalledWith([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@
data?.designationAccounts
.flatMap((group) => group.designationAccounts)
.map((account) => ({
name: account.name,
name: account.name
? account.name
: account.designationNumber
? account.designationNumber
: '',

Check warning on line 128 in src/components/Shared/MultiPageLayout/MultiPageMenu/MultiPageMenu.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Shared/MultiPageLayout/MultiPageMenu/MultiPageMenu.tsx#L128

Added line #L128 was not covered by tests
caleballdrin marked this conversation as resolved.
Show resolved Hide resolved
value: account.id,
placeholder: null,
})) ?? [];
Expand Down
Loading