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 Task Phase 1/4 - Initialization #948

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
# Use production API for codegen to make sure production is compatible with the code to be merged
API_URL: 'https://api.mpdx.org/graphql'
API_URL: 'https://api.stage.mpdx.org/graphql'
SITE_URL: 'http://next-stage.mpdx.org'

jobs:
Expand Down
32 changes: 29 additions & 3 deletions __tests__/util/TestWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
import React, { ReactElement, ReactNode } from 'react';
import { InMemoryCache } from '@apollo/client';
import { MockedProvider, MockedResponse } from '@apollo/client/testing';
import { ApolloLink, InMemoryCache } from '@apollo/client';
import { onError } from '@apollo/client/link/error';
import {
MockLink,
MockedProvider,
MockedResponse,
} from '@apollo/client/testing';
import { AdapterLuxon } from '@mui/x-date-pickers/AdapterLuxon';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { SnackbarProvider } from 'notistack';
import TestRouter from './TestRouter';

export type OnErrorFunction = (error: string) => void;

interface Props {
mocks?: MockedResponse[];
children: ReactNode;
cache?: InMemoryCache;
onErrorFunction?: OnErrorFunction;
}

const TestWrapper = ({
mocks = [],
children,
cache = new InMemoryCache({ addTypename: false }),
onErrorFunction,
}: Props): ReactElement => {
const mockLink = new MockLink(mocks);
const errorLoggingLink = onError(({ networkError }) => {
if (networkError) {
// eslint-disable-next-line no-console
console.warn(`[Network error]: ${networkError}`);
if (onErrorFunction) {
onErrorFunction(JSON.stringify(networkError.message));
}
}
});
const link = ApolloLink.from([errorLoggingLink, mockLink]);

return (
<TestRouter>
<LocalizationProvider dateAdapter={AdapterLuxon}>
<SnackbarProvider>
<MockedProvider mocks={mocks} cache={cache} addTypename={false}>
<MockedProvider
mocks={mocks}
cache={cache}
addTypename={false}
link={link}
>
{children}
</MockedProvider>
</SnackbarProvider>
Expand Down
26 changes: 22 additions & 4 deletions src/components/Constants/LoadConstants.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ query LoadConstants {
activities {
id
value
name
}
languages {
id
Expand Down Expand Up @@ -58,9 +59,26 @@ query LoadConstants {
key
value
}
# userNotificationTitles {
# id
# value
# }
phases {
id
name
results {
resultOptions {
dbResult {
task
result
}
name
suggestedContactStatus
suggestedNextActions
}
tags {
value
id
}
}
contactStatuses
tasks
}
}
}
Loading
Loading