Skip to content

Commit

Permalink
Add test, and graphql fields for the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
caleballdrin committed Oct 9, 2024
1 parent a902b63 commit 53d91dd
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ export const AddAddressModal: React.FC<EditContactAddressModalProps> = ({
...dataFromCache.contact.addresses,
nodes: [
...dataFromCache.contact.addresses.nodes,
{
...createdAddressData?.createAddress?.address,
sourceDonorAccount: { accountNumber: null },
startDate: '',
},
{ ...createdAddressData?.createAddress?.address },
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ mutation CreateContactAddress(
state
street
createdAt
startDate
sourceDonorAccount {
id
accountNumber
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const data: ContactMailingFragment = {
state: null,
street: '100 Lake Hart Dr',
createdAt: new Date(2023, 0, 1).toISOString(),
startDate: null,
},
{
id: 'address-2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fragment ContactMailing on Contact {
region
source
sourceDonorAccount {
id
accountNumber
}
state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mutation UpdateContactAddress(
input: { accountListId: $accountListId, attributes: $attributes }
) {
address {
id
city
country
historic
Expand All @@ -26,6 +27,8 @@ mutation UpdateContactAddress(
region
state
street
createdAt
startDate
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,33 @@ describe('FixMailingAddresses', () => {
expect(getByText(/12\/10\/2022/i)).toBeInTheDocument();
});

it('should show createdAt date when startDate is null', async () => {
const { queryByTestId, getByText } = render(
<Components
mocks={{
InvalidAddresses: {
contacts: {
nodes: [
{
id: contactId,
name: 'Baggins, Frodo',
status: null,
addresses: {
nodes: [mpdxSourcedAddress],
},
},
],
},
},
}}
/>,
);
await waitFor(() =>
expect(queryByTestId('loading')).not.toBeInTheDocument(),
);
expect(getByText(/6\/12\/2024/i)).toBeInTheDocument();
});

describe('Editing an address', () => {
it('should edit Address via EditContactAddressModal', async () => {
const cache = new InMemoryCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,7 @@ const FixMailingAddresses: React.FC<Props> = ({
addresses: {
nodes: [
...contact.addresses.nodes,
{
...createdAddressData.createAddress.address,
startDate: '',
},
createdAddressData.createAddress.address,
],
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const mpdxSourcedAddress = {
source: 'MPDX',
location: 'Home',
createdAt: '2024-06-12T13:07:40-04:00',
startDate: null,
historic: false,
};

Expand Down

0 comments on commit 53d91dd

Please sign in to comment.