Skip to content

Commit

Permalink
add api request/reponse logging to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
jgunnCO committed Apr 12, 2024
1 parent 36acd66 commit 0ced5b9
Show file tree
Hide file tree
Showing 36 changed files with 86 additions and 66 deletions.
2 changes: 1 addition & 1 deletion packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@contentful/rich-text-from-markdown": "15.16.6",
"@contentful/rich-text-react-renderer": "^15.12.1",
"@tinymce/tinymce-react": "4.3.2",
"axios": "^0.27.2",
"axios": "1.6.8",
"body-parser": "1.20.2",
"cookie-parser": "^1.4.6",
"cypress-recurse": "^1.18.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { ApplicationFormSummary } from '../../../../types/ApplicationForm';
import { getSessionIdFromCookies } from '../../../../utils/session';

jest.mock('axios');
jest.mock('../../../../utils/axios');
jest.mock('../../../../utils/session');
const mockGetSessionIdFromCookies = jest.mocked(getSessionIdFromCookies);
jest.mock('next/config', () => () => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import axios from 'axios';
import { merge } from 'lodash';
import { GetServerSidePropsContext } from 'next';
import { getGrantScheme } from '../../../../../services/SchemeService';
import { axios } from '../../../../../utils/axios';
import { updateSectionStatus } from '../../../../../services/SectionService';
import { parseBody } from '../../../../../utils/parseBody';
import EligibilityStatement, {
getServerSideProps,
} from './eligibility-statement.page';

jest.mock('axios');
jest.mock('../../../../../utils/axios');
jest.mock('../../../../../utils/parseBody');
jest.mock('../../../../../services/SectionService');
jest.mock('../../../../../services/SchemeService');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import axios from 'axios';
import { axios } from '../../../../utils/axios';
import DueDiligence, { getServerSideProps } from './due-diligence.page';
import { merge } from 'lodash';
import NextGetServerSidePropsResponse from '../../../../types/NextGetServerSidePropsResponse';
Expand Down Expand Up @@ -28,7 +28,7 @@ jest.mock('next/config', () => () => {
},
};
});
jest.mock('axios');
jest.mock('../../../../utils/axios');
jest.mock('../../../../utils/parseBody');
jest.mock('../../../../services/SectionService');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { GetServerSidePropsContext } from 'next';
import { getApplicationFormSummary } from '../../../../../services/ApplicationService';
import { getServerSideProps } from './index.getServerSideProps';
import NextGetServerSidePropsResponse from '../../../../../types/NextGetServerSidePropsResponse';
import axios from 'axios';
import {
addFieldsToSession,
getSummaryFromSession,
getValueFromSession,
} from '../../../../../services/SessionService';
import { axios } from '../../../../../utils/axios';
import { parseBody } from '../../../../../utils/parseBody';
import { ValidationError } from 'gap-web-ui';
import { getQuestion } from '../../../../../services/QuestionService';
import ResponseTypeEnum from '../../../../../enums/ResponseType';
import * as QuestionService from '../../../../../services/QuestionService';

jest.mock('axios');
jest.mock('../../../../../utils/axios');
jest.mock('../../../../../utils/parseBody');
jest.mock('../../../../../services/SessionService');
jest.mock('../../../../../services/ApplicationService');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { render, screen } from '@testing-library/react';
import { GetServerSidePropsContext } from 'next';
import NextGetServerSidePropsResponse from '../../../types/NextGetServerSidePropsResponse';
import { merge } from 'lodash';
import axios from 'axios';
import { parseBody } from '../../../utils/parseBody';
import { getApplicationFormSummary } from '../../../services/ApplicationService';
import { postSection } from '../../../services/SectionService';
import { ValidationError } from 'gap-web-ui';
import SectionNameContent, { getServerSideProps } from './section-name.page';

jest.mock('axios');
jest.mock('../../../utils/axios');
jest.mock('../../../utils/parseBody');
jest.mock('../../../services/ApplicationService');
jest.mock('../../../services/SectionService');
Expand Down
5 changes: 2 additions & 3 deletions packages/admin/src/services/AdvertPageService.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { LastUpdatedBy } from './../pages/scheme/components/BuildAdvertContentHelper';
import axios from 'axios';
import getConfig from 'next/config';
import AdvertStatusEnum from '../enums/AdvertStatus';
import { InferServiceMethodResponse } from '../testUtils/unitTestHelpers';
Expand All @@ -18,8 +16,9 @@ import {
} from './AdvertPageService';
import { PatchAdvertSectionPageResponseBody } from './AdvertPageService.d';
import { decrypt } from '../utils/encryption';
import { axios } from '../utils/axios';

jest.mock('axios');
jest.mock('../utils/axios');

jest.mock('../utils/encryption');

Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/services/AdvertPageService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import axios from 'axios';
import getConfig from 'next/config';
import { GetSectionOverviewPageContentResponse } from '../types/GetSectionOverviewPageContentResponse';
import { GrantAdvertSummaryPageResponse } from '../types/GetSummaryPageContentResponse';
Expand All @@ -11,6 +10,7 @@ import {
PreviewPageContent,
} from './AdvertPageService.d';
import { decrypt } from '../utils/encryption';
import { axios } from '../utils/axios';

const { serverRuntimeConfig } = getConfig();
const BACKEND_HOST = serverRuntimeConfig.backendHost;
Expand Down
5 changes: 3 additions & 2 deletions packages/admin/src/services/ApplicationService.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { AxiosError } from 'axios';
import { AxiosError } from 'axios';
import getConfig from 'next/config';
import ApplicationQueryObject from '../types/ApplicationQueryObject';
import FindApplicationFormStatsResponse from '../types/FindApplicationFormStatsResponse';
Expand All @@ -15,6 +15,7 @@ import {
updateApplicationFormStatus,
} from './ApplicationService';
import { decrypt } from '../utils/encryption';
import { axios } from '../utils/axios';

jest.mock('next/config', () => () => {
return {
Expand All @@ -27,7 +28,7 @@ jest.mock('next/config', () => () => {
},
};
});
jest.mock('axios');
jest.mock('../utils/axios');

jest.mock('../utils/encryption', () => ({
decrypt: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/services/ApplicationService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import axios from 'axios';
import getConfig from 'next/config';
import {
ApplicationFormSection,
Expand All @@ -9,6 +8,7 @@ import FindApplicationFormStatsResponse from '../types/FindApplicationFormStatsR
import { decrypt } from '../utils/encryption';
import { axiosSessionConfig } from '../utils/session';
import { mapSingleSection } from '../utils/applicationSummaryHelper';
import { axios } from '../utils/axios';

const { serverRuntimeConfig } = getConfig();
const BACKEND_HOST = serverRuntimeConfig.backendHost;
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/services/AuthService.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import { authenticateUser, logoutUser } from './AuthService';
import getConfig from 'next/config';
import { axios } from '../utils/axios';

jest.mock('next/config', () => () => {
return {
Expand All @@ -14,7 +14,7 @@ jest.mock('next/config', () => () => {
};
});

jest.mock('axios');
jest.mock('../utils/axios');

const mockedAxios = axios as jest.Mocked<typeof axios>;

Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/services/AuthService.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from 'axios';
import cookie from 'cookie';
import cookieParser from 'cookie-parser';
import getConfig from 'next/config';
import { axiosSessionConfig } from '../utils/session';
import { axios } from '../utils/axios';

const { serverRuntimeConfig } = getConfig();
const BACKEND_HOST = serverRuntimeConfig.backendHost;
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/services/ExportService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { axiosSessionConfig } from '../utils/session';
import { axios } from '../utils/axios';
import Pagination from '../types/Pagination';

const BASE_SUBMISSIONS_URL = process.env.BACKEND_HOST + '/grant-export';
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/services/MandatoryQuestionsService.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import axios from 'axios';
import {
downloadMandatoryQuestionsDueDiligenceData,
hasCompletedMandatoryQuestions,
} from './MandatoryQuestionsService';
import { axios } from '../utils/axios';

jest.mock('axios');
jest.mock('../utils/axios');

describe('MandatoryQuestionsService', () => {
const mockedAxios = axios as jest.Mocked<typeof axios>;
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/services/MandatoryQuestionsService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from 'axios';
import { axios } from '../utils/axios';
import { axiosSessionConfig } from '../utils/session';

const BASE_MANDATORY_QUESTIONS_URL =
Expand Down
7 changes: 4 additions & 3 deletions packages/admin/src/services/QuestionService.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from 'axios';
import getConfig from 'next/config';
import { axios } from '../utils/axios';
import ResponseTypeEnum from '../enums/ResponseType';
import {
deleteQuestion,
getQuestion,
patchQuestion,
postQuestion,
} from './QuestionService';
import getConfig from 'next/config';

jest.mock('next/config', () => () => {
return {
Expand All @@ -20,7 +20,8 @@ jest.mock('next/config', () => () => {
};
});

jest.mock('axios');
jest.mock('../utils/axios');

const mockedAxios = axios as jest.Mocked<typeof axios>;

const { serverRuntimeConfig } = getConfig();
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/services/QuestionService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import getConfig from 'next/config';
import ResponseType from '../enums/ResponseType';
import { ApplicationFormQuestion } from '../types/ApplicationForm';
import getConfig from 'next/config';
import { axios } from '../utils/axios';
import { axiosSessionConfig } from '../utils/session';

const { serverRuntimeConfig } = getConfig();
Expand Down
5 changes: 3 additions & 2 deletions packages/admin/src/services/SatisfactionSurveyService.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import axios from 'axios';
import getConfig from 'next/config';
import { postSurveyResponse } from './SatisfactionSurveyService';
import { axios } from '../utils/axios';

jest.mock('../utils/axios');

jest.mock('axios');
const mockedAxios = axios as jest.Mocked<typeof axios>;
const { serverRuntimeConfig } = getConfig();
const BACKEND_HOST = serverRuntimeConfig.backendHost;
Expand Down
7 changes: 1 addition & 6 deletions packages/admin/src/services/SatisfactionSurveyService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import axios from 'axios';
import getConfig from 'next/config';

const { serverRuntimeConfig } = getConfig();
const BACKEND_HOST = serverRuntimeConfig.backendHost;
const BASE_FEEDBACK_URL = BACKEND_HOST + '/feedback';
import { axios } from '../utils/axios';

const postSurveyResponse = async (
satisfaction: string,
Expand Down
3 changes: 1 addition & 2 deletions packages/admin/src/services/SchemeEditorService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import axios from 'axios';
import getConfig from 'next/config';
import { axiosSessionConfig, getFullConfig } from '../utils/session';

import { axios } from '../utils/axios';
import { decrypt } from '../utils/encryption';
import EditableSchemes from '../types/EditableSchemes';
import Scheme from '../types/Scheme';
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/services/SchemeService.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import getConfig from 'next/config';
import ApplicationQueryObject from '../types/ApplicationQueryObject';
import Pagination from '../types/Pagination';
import { axios } from '../utils/axios';
import { axiosSessionConfig } from '../utils/session';
import { findMatchingApplicationForms } from './ApplicationService';
import {
Expand All @@ -26,7 +26,7 @@ jest.mock('next/config', () => () => {
};
});

jest.mock('axios');
jest.mock('../utils/axios');
jest.mock('../services/ApplicationService');

describe('SchemeService', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/services/SchemeService.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from 'axios';
import getConfig from 'next/config';
import ApplicationQueryObject from '../types/ApplicationQueryObject';
import Pagination from '../types/Pagination';
import Scheme from '../types/Scheme';
import { axios } from '../utils/axios';
import { axiosSessionConfig } from '../utils/session';
import { findMatchingApplicationForms } from './ApplicationService';
import { decryptLastUpdatedBy } from './SchemeEditorService';
Expand Down
7 changes: 4 additions & 3 deletions packages/admin/src/services/SectionService.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import axios from 'axios';
import getConfig from 'next/config';
import { axios } from '../utils/axios';
import {
deleteSection,
postSection,
updateSectionStatus,
updateSectionTitle,
} from './SectionService';
import getConfig from 'next/config';

jest.mock('axios');
jest.mock('../utils/axios');

const mockedAxios = axios as jest.Mocked<typeof axios>;
const { serverRuntimeConfig } = getConfig();
const BACKEND_HOST = serverRuntimeConfig.backendHost;
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/services/SectionService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import { ApplicationFormStatus } from '../types/ApplicationForm';
import getConfig from 'next/config';
import { ApplicationFormStatus } from '../types/ApplicationForm';
import { axios } from '../utils/axios';
import { AxiosConfig, axiosSessionConfig } from '../utils/session';
import { UpdateSectionTitleProps } from '../types/Section';

Expand Down
6 changes: 3 additions & 3 deletions packages/admin/src/services/SessionService.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import axios from 'axios';
import getConfig from 'next/config';
import { axios } from '../utils/axios';
import {
addFieldsToSession,
addToSession,
getSummaryFromSession,
getValueFromSession,
} from './SessionService';
import getConfig from 'next/config';

jest.mock('axios');
jest.mock('../utils/axios');

describe('SessionService', () => {
const mockedAxios = axios as jest.Mocked<typeof axios>;
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/services/SessionService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import getConfig from 'next/config';
import { axios } from '../utils/axios';
import { axiosSessionConfig } from '../utils/session';

const { serverRuntimeConfig } = getConfig();
Expand Down
5 changes: 3 additions & 2 deletions packages/admin/src/services/SpotlightBatchService.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import axios from 'axios';
import getConfig from 'next/config';
import { axios } from '../utils/axios';
import { SpotlightError } from '../types/SpotlightError';
import { getSpotlightErrors } from './SpotlightBatchService';

jest.mock('axios');
jest.mock('../utils/axios');

const mockedAxios = axios as jest.Mocked<typeof axios>;
const { serverRuntimeConfig } = getConfig();
const BACKEND_HOST = serverRuntimeConfig.backendHost;
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/services/SpotlightBatchService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import getConfig from 'next/config';
import { SpotlightError } from '../types/SpotlightError';
import { axios } from '../utils/axios';
import { axiosSessionConfig } from '../utils/session';

const { serverRuntimeConfig } = getConfig();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import axios from 'axios';
import getConfig from 'next/config';
import {
GetSpotlightSubmissionDataBySchemeIdDto,
downloadSpotlightSubmissionsDueDiligenceData,
getSpotlightSubmissionSentData,
} from './SpotlightSubmissionService';
import { axios } from '../utils/axios';

jest.mock('../utils/axios');

jest.mock('axios');
const mockedAxios = axios as jest.Mocked<typeof axios>;
const { serverRuntimeConfig } = getConfig();
const BACKEND_HOST = serverRuntimeConfig.backendHost;
Expand Down
Loading

0 comments on commit 0ced5b9

Please sign in to comment.