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

psp-7896 add acquisition properties request to generate letter logic. #3837

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import { mockAcquisitionFileResponse } from '@/mocks/acquisitionFiles.mock';
import { ApiGen_Concepts_AcquisitionFile } from '@/models/api/generated/ApiGen_Concepts_AcquisitionFile';

import { useGenerateLetter } from '../hooks/useGenerateLetter';
import { ApiGen_Concepts_AcquisitionFileProperty } from '@/models/api/generated/ApiGen_Concepts_AcquisitionFileProperty';

const generateFn = jest.fn();
const getAcquisitionFileFn = jest.fn<ApiGen_Concepts_AcquisitionFile | undefined, any[]>();
const getAcquisitionFilePropertiesFn = jest.fn<ApiGen_Concepts_AcquisitionFileProperty | undefined, any[]>();
const getPersonConceptFn = jest.fn();
const getOrganizationConceptFn = jest.fn();

Expand All @@ -25,6 +27,7 @@ jest.mock('@/features/documents/hooks/useDocumentGenerationRepository');
jest.mock('@/hooks/repositories/useAcquisitionProvider');
(useAcquisitionProvider as jest.Mock).mockImplementation(() => ({
getAcquisitionFile: { execute: getAcquisitionFileFn },
getAcquisitionProperties: { execute: getAcquisitionFilePropertiesFn },
}));

jest.mock('@/hooks/pims-api/useApiContacts');
Expand All @@ -35,7 +38,7 @@ jest.mock('@/hooks/pims-api/useApiContacts');

let currentStore: MockStoreEnhanced<any, {}>;
const mockStore = configureMockStore([thunk]);
const getStore = (values?: any) => {
const getStore = (values?: any) => {
currentStore = mockStore(values ?? {});
return currentStore;
};
Expand All @@ -62,10 +65,12 @@ const setup = (params?: {
};

describe('useGenerateLetter functions', () => {
it('makes requests to expected api endpoints', async () => {
it('makes requests to expected base api endpoints', async () => {
const generate = setup();
await act(async () => {
await generate(0);
expect(getAcquisitionFileFn).toHaveBeenCalled();
expect(getAcquisitionFilePropertiesFn).toHaveBeenCalled();
expect(generateFn).toHaveBeenCalled();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const useGenerateLetter = () => {
const { getPersonConcept, getOrganizationConcept } = useApiContacts();
const {
getAcquisitionFile: { execute: getAcquisitionFile },
getAcquisitionProperties: { execute: getAcquisitionProperties },
} = useAcquisitionProvider();

const { generateDocumentDownloadWrappedRequest: generate } = useDocumentGenerationRepository();
Expand All @@ -22,6 +23,8 @@ export const useGenerateLetter = () => {
) => {
const file = await getAcquisitionFile(acquisitionFileId);
if (file) {
const properties = await getAcquisitionProperties(acquisitionFileId);
file.fileProperties = properties ?? [];
const coordinator = file.acquisitionTeam?.find(
team => team.teamProfileTypeCode === 'PROPCOORD',
);
Expand Down
Loading