Skip to content

Commit

Permalink
Merge pull request #205 from motech-development/bugfix/apollo-react-s…
Browse files Browse the repository at this point in the history
…trict

chore(deps): bump @apollo/client from 3.3.13 to 3.4.4
  • Loading branch information
mogusbi authored Aug 5, 2021
2 parents 670c498 + 4193274 commit 1aec516
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 107 deletions.
2 changes: 1 addition & 1 deletion applications/accounts/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test:ci": "react-scripts test --coverage --runInBand"
},
"dependencies": {
"@apollo/client": "^3.3.13",
"@apollo/client": "3.4.4",
"@auth0/auth0-spa-js": "^1.14.0",
"@fortawesome/fontawesome-svg-core": "^1.2.35",
"@fortawesome/free-solid-svg-icons": "^5.15.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,43 @@ describe('DELETE_TRANSACTION', () => {
data: {
getBalance: {
__typename: 'Balance',
balance: 50,
currency: 'GBP',
id: 'company-id',
transactions: [
{
balance: 50,
currency: 'GBP',
date: '2021-08-05T00:00:00.000Z',
items: [
{
amount: 50,
attachment: null,
description: 'Transaction description 1',
id: 'transaction-id-0',
name: 'Transaction 1',
},
],
},
{
balance: 100,
currency: 'GBP',
date: '2021-08-04T00:00:00.000Z',
items: [
{
amount: 50,
attachment: null,
description: 'Transaction description 2',
id: 'transaction-id-1',
name: 'Transaction 2',
},
],
},
],
vat: {
owed: 0,
paid: 0,
},
},
},
query: GET_BALANCE,
Expand Down Expand Up @@ -67,6 +86,10 @@ describe('DELETE_TRANSACTION', () => {
],
},
],
vat: {
owed: 0,
paid: 0,
},
},
getTransactions: {
__typename: 'Transactions',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('Accounts', () => {
__typename: 'Transactions',
id: 'company-id',
items: [],
status: 'pending',
},
},
query: GET_TRANSACTIONS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,12 @@ describe('PendingTransactions', () => {
let mocks: MockedResponse[];

beforeEach(() => {
cache = new InMemoryCache();

cache.writeQuery({
data: {
getBalance: {
__typename: 'Balance',
currency: 'GBP',
id: 'company-id',
transactions: [
{
id: 'transaction-id',
items: [],
},
],
},
getTransactions: {
__typename: 'Transactions',
id: 'company-id',
items: [],
cache = new InMemoryCache({
typePolicies: {
Transactions: {
keyFields: ['id', 'status'],
},
},
query: GET_TRANSACTIONS,
variables: {
id: 'company-id',
status: 'pending',
},
});

history = createMemoryHistory({
Expand Down Expand Up @@ -134,6 +114,8 @@ describe('PendingTransactions', () => {
</MockedProvider>
</TestProvider>,
);

await waitForApollo(0);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ describe('RecordTransaction', () => {
__typename: 'Balance',
currency: 'GBP',
id: 'company-id',
transactions: [],
},
getTransactions: {
__typename: 'Transactions',
id: 'company-id',
items: [],
status: 'pending',
},
},
query: GET_TRANSACTIONS,
Expand All @@ -64,11 +66,13 @@ describe('RecordTransaction', () => {
__typename: 'Balance',
currency: 'GBP',
id: 'company-id',
transactions: [],
},
getTransactions: {
__typename: 'Transactions',
id: 'company-id',
items: [],
status: 'confirmed',
},
},
query: GET_TRANSACTIONS,
Expand Down Expand Up @@ -700,7 +704,9 @@ describe('RecordTransaction', () => {
},
},
result: {
data: {},
data: {
addTransaction: null,
},
},
},
{
Expand All @@ -719,7 +725,9 @@ describe('RecordTransaction', () => {
},
},
result: {
data: {},
data: {
requestUpload: null,
},
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ describe('ViewTransaction', () => {
__typename: 'Balance',
currency: 'GBP',
id: 'company-id',
transactions: [],
},
getTransactions: {
__typename: 'Transactions',
id: 'company-id',
items: [],
status: 'pending',
},
},
query: GET_TRANSACTIONS,
Expand Down Expand Up @@ -591,7 +593,9 @@ describe('ViewTransaction', () => {
await waitForApollo(0);
});

expect(saveAs).toHaveBeenCalledWith('success', 'attachment.pdf');
await waitFor(() =>
expect(saveAs).toHaveBeenCalledWith('success', 'attachment.pdf'),
);
});

it('should display a success toast when attachment is downloaded', async () => {
Expand Down Expand Up @@ -1081,7 +1085,9 @@ describe('ViewTransaction', () => {
},
},
result: {
data: {},
data: {
updateTransaction: null,
},
},
},
{
Expand All @@ -1092,7 +1098,9 @@ describe('ViewTransaction', () => {
},
},
result: {
data: {},
data: {
deleteTransaction: null,
},
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe('UploadAttachment', () => {
},
},
result: {
data: {},
errors: [new GraphQLError('Error!')],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ describe('AddClient', () => {
},
},
result: {
data: {},
data: {
createClient: null,
},
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,8 @@ describe('UpdateDetails', () => {
});

it('should hide the delete confirmation modal', async () => {
const {
findAllByRole,
findByRole,
findByText,
queryByRole,
} = component;
const { findAllByRole, findByRole, findByText, queryByRole } =
component;

await act(async () => {
await findByText('New client');
Expand Down Expand Up @@ -441,7 +437,9 @@ describe('UpdateDetails', () => {
},
},
result: {
data: {},
data: {
deleteClient: null,
},
},
},
{
Expand Down Expand Up @@ -495,7 +493,9 @@ describe('UpdateDetails', () => {
},
},
result: {
data: {},
data: {
updateClient: null,
},
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,24 @@ describe('CreateReport', () => {
});
});

it('should output the page title', () => {
it('should output the page title', async () => {
await act(async () => {
await waitForApollo(0);
});

const [title] = screen.getAllByRole('heading');
const subTitle = screen.getByText('create-report.sub-title');

expect(title).toHaveTextContent('create-report.title');
expect(subTitle).toBeInTheDocument();
await waitFor(() =>
expect(title).toHaveTextContent('create-report.title'),
);
await waitFor(() => expect(subTitle).toBeInTheDocument());
});

it('should redirect you back to the reports page on complete', async () => {
await act(async () => {
await waitForApollo(0);

const status = screen.getByLabelText(
'export-form.status.options.confirmed',
);
Expand All @@ -128,6 +136,8 @@ describe('CreateReport', () => {
const button = screen.getByRole('button');

userEvent.click(button);

await waitForApollo(0);
});

await waitFor(() =>
Expand All @@ -139,6 +149,8 @@ describe('CreateReport', () => {

it('should display a success toast on complete', async () => {
await act(async () => {
await waitForApollo(0);

const status = screen.getByLabelText(
'export-form.status.options.confirmed',
);
Expand All @@ -150,6 +162,8 @@ describe('CreateReport', () => {
const button = screen.getByRole('button');

userEvent.click(button);

await waitForApollo(0);
});

await waitFor(() =>
Expand All @@ -161,6 +175,10 @@ describe('CreateReport', () => {
});

it('should redirect you back to the reports page if you cancel', async () => {
await act(async () => {
await waitForApollo(0);
});

const link = screen.getByRole('link');

userEvent.click(link);
Expand Down Expand Up @@ -260,6 +278,8 @@ describe('CreateReport', () => {

it('should redirect you back to the reports page on complete', async () => {
await act(async () => {
await waitForApollo(0);

const status = screen.getByLabelText(
'export-form.status.options.confirmed',
);
Expand All @@ -271,6 +291,8 @@ describe('CreateReport', () => {
const button = screen.getByRole('button');

userEvent.click(button);

await waitForApollo(0);
});

await waitFor(() =>
Expand All @@ -282,6 +304,8 @@ describe('CreateReport', () => {

it('should display a success toast on complete', async () => {
await act(async () => {
await waitForApollo(0);

const status = screen.getByLabelText(
'export-form.status.options.confirmed',
);
Expand All @@ -293,6 +317,8 @@ describe('CreateReport', () => {
const button = screen.getByRole('button');

userEvent.click(button);

await waitForApollo(0);
});

await waitFor(() =>
Expand Down
Loading

0 comments on commit 1aec516

Please sign in to comment.