diff --git a/app/src/components/fields/CbSelectField.tsx b/app/src/components/fields/CbSelectField.tsx index dacd6d1611..a36d8d627b 100644 --- a/app/src/components/fields/CbSelectField.tsx +++ b/app/src/components/fields/CbSelectField.tsx @@ -19,6 +19,7 @@ export interface ICbSelectField extends ICbSelectSharedProps { route: string; param?: string; query?: string; + disabledValues?: Record; handleChangeSideEffect?: (value: string, label: string) => void; } @@ -35,7 +36,7 @@ interface ICbSelectOption { **/ const CbSelectField: React.FC = (props) => { - const { name, label, route, param, query, handleChangeSideEffect, controlProps } = props; + const { name, label, route, param, query, handleChangeSideEffect, controlProps, disabledValues } = props; const api = useCritterbaseApi(); const isMounted = useIsMounted(); @@ -83,13 +84,13 @@ const CbSelectField: React.FC = (props) => { {data?.map((a) => { const item = typeof a === 'string' ? { label: a, value: a } : { label: a.value, value: a.id }; return ( - + {item.label} ); diff --git a/app/src/constants/i18n.ts b/app/src/constants/i18n.ts index 9e0c76285b..77bd79ec7e 100644 --- a/app/src/constants/i18n.ts +++ b/app/src/constants/i18n.ts @@ -331,11 +331,17 @@ export const SurveyAnimalsI18N = { animalMortalityHelp: "Mortality Events describe an individual's death, including the suspected location, date, and cause of death. An individual can only have one Mortality Event.", animalMortalityAddBtn: 'Add Mortality', - + animalCollectionUnitTitle: 'Ecological Units', + animalCollectionUnitTitle2: 'Ecological Unit', + animalCollectionUnitHelp: + 'Ecological units are groups such as population units, herds, and packs. Different species may different units and unit names.', + animalCollectionUnitAddBtn: 'Add Unit', // Input help strings taxonHelp: 'The species or taxon of the animal. If the species is unknown, select the lowest-ranking known taxon, such as the genus or family', - taxonLabelHelp: 'A custom and unique name for you to recognize this individual' + taxonLabelHelp: 'A custom and unique name for you to recognize this individual', + wlhIdHelp: 'The Wildlife Health ID associated with this critter.', + sexHelp: 'The sex of this critter. Leave as Unknown if unsure.' }; export const FundingSourceI18N = { diff --git a/app/src/features/surveys/view/SurveyAnimals.test.tsx b/app/src/features/surveys/view/SurveyAnimals.test.tsx index 9b7b233750..84e4592a16 100644 --- a/app/src/features/surveys/view/SurveyAnimals.test.tsx +++ b/app/src/features/surveys/view/SurveyAnimals.test.tsx @@ -101,7 +101,14 @@ describe('SurveyAnimals', () => { it('renders correctly with animals', async () => { mockUseBiohub.survey.getSurveyCritters.mockResolvedValueOnce([ - { critter_id: 'critter_uuid', survey_critter_id: 1, animal_id: 'a', taxon: 'a', created_at: 'a' } + { + critter_id: 'critter_uuid', + survey_critter_id: 1, + animal_id: 'a', + taxon: 'a', + created_at: 'a', + wlh_id: '123-45' + } ]); mockUseBiohub.survey.getDeploymentsInSurvey.mockResolvedValue([{ critter_id: 'critter_uuid', device_id: 123 }]); @@ -119,7 +126,7 @@ describe('SurveyAnimals', () => { ); await waitFor(() => { - expect(getByText('critter_uuid')).toBeInTheDocument(); + expect(getByText('123-45')).toBeInTheDocument(); expect(getByTestId('survey-animal-table')).toBeInTheDocument(); fireEvent.click(getByTestId('animal actions')); fireEvent.click(getByTestId('animal-table-row-edit-timespan')); diff --git a/app/src/features/surveys/view/SurveyAnimals.tsx b/app/src/features/surveys/view/SurveyAnimals.tsx index b205d2034b..cbdeb2eb2f 100644 --- a/app/src/features/surveys/view/SurveyAnimals.tsx +++ b/app/src/features/surveys/view/SurveyAnimals.tsx @@ -15,7 +15,7 @@ import React, { useContext, useState } from 'react'; import { datesSameNullable, pluralize } from 'utils/Utils'; import yup from 'utils/YupSchema'; import NoSurveySectionData from '../components/NoSurveySectionData'; -import { AnimalSchema, Critter, IAnimal } from './survey-animals/animal'; +import { AnimalSchema, AnimalSex, Critter, IAnimal } from './survey-animals/animal'; import { AnimalTelemetryDeviceSchema, Device, IAnimalTelemetryDevice } from './survey-animals/device'; import IndividualAnimalForm from './survey-animals/IndividualAnimalForm'; import { SurveyAnimalsTable } from './survey-animals/SurveyAnimalsTable'; @@ -74,10 +74,11 @@ const SurveyAnimals: React.FC = () => { }; const AnimalFormValues: IAnimal = { - general: { taxon_id: '', taxon_name: '', animal_id: '' }, + general: { wlh_id: '', taxon_id: '', taxon_name: '', animal_id: '', sex: AnimalSex.UNKNOWN }, captures: [], markings: [], mortality: [], + collectionUnits: [], measurements: [], family: [], images: [], diff --git a/app/src/features/surveys/view/survey-animals/IndividualAnimalForm.tsx b/app/src/features/surveys/view/survey-animals/IndividualAnimalForm.tsx index 8b71888fac..061192142a 100644 --- a/app/src/features/surveys/view/survey-animals/IndividualAnimalForm.tsx +++ b/app/src/features/surveys/view/survey-animals/IndividualAnimalForm.tsx @@ -4,6 +4,7 @@ import { Form, useFormikContext } from 'formik'; import { useEffect } from 'react'; import { Critter, IAnimal } from './animal'; import CaptureAnimalForm from './form-sections/CaptureAnimalForm'; +import CollectionUnitAnimalForm from './form-sections/CollectionUnitAnimalForm'; import FamilyAnimalForm from './form-sections/FamilyAnimalForm'; import GeneralAnimalForm from './form-sections/GeneralAnimalForm'; import MarkingAnimalForm from './form-sections/MarkingAnimalForm'; @@ -37,6 +38,7 @@ const IndividualAnimalForm = ({ getAnimalCount }: IndividualAnimalFormProps) =>
Add New Individual + diff --git a/app/src/features/surveys/view/survey-animals/SurveyAnimalsTable.tsx b/app/src/features/surveys/view/survey-animals/SurveyAnimalsTable.tsx index 71f22497b5..4e58d83afe 100644 --- a/app/src/features/surveys/view/survey-animals/SurveyAnimalsTable.tsx +++ b/app/src/features/surveys/view/survey-animals/SurveyAnimalsTable.tsx @@ -3,6 +3,7 @@ import { GridColDef } from '@mui/x-data-grid'; import { CustomDataGrid } from 'components/tables/CustomDataGrid'; import { DATE_FORMAT } from 'constants/dateTimeFormats'; import { IDetailedCritterWithInternalId } from 'interfaces/useSurveyApi.interface'; +import moment from 'moment'; import { getFormattedDate } from 'utils/Utils'; import { IAnimalDeployment } from './device'; import SurveyAnimalsTableActions from './SurveyAnimalsTableActions'; @@ -47,17 +48,17 @@ export const SurveyAnimalsTable = ({ : animalData; const columns: GridColDef[] = [ - { - field: 'critter_id', - headerName: 'Critter ID', - flex: 1, - minWidth: 300 - }, { field: 'animal_id', - headerName: 'Animal ID', + headerName: 'Alias', flex: 1 }, + { + field: 'wlh_id', + headerName: 'WLH ID', + flex: 1, + renderCell: (params) => {params.value ? params.value : 'None'} + }, { field: 'taxon', headerName: 'Taxon', @@ -72,16 +73,30 @@ export const SurveyAnimalsTable = ({ ) }, { - field: 'deployments', - headerName: 'Device ID', + field: 'current_devices', + headerName: 'Current Devices', flex: 1, - renderCell: (params) => ( - - {params.value?.length - ? params.value?.map((device: IAnimalDeployment) => device.device_id).join(', ') - : 'No Device'} - - ) + valueGetter: (params) => { + const currentDeploys = params.row.deployments?.filter( + (device: IAnimalDeployment) => !device.attachment_end || moment(device.attachment_end).isAfter(moment()) + ); + return currentDeploys?.length + ? currentDeploys.map((device: IAnimalDeployment) => device.device_id).join(', ') + : 'No Devices'; + } + }, + { + field: 'previous_devices', + headerName: 'Previous Devices', + flex: 1, + valueGetter: (params) => { + const previousDeploys = params.row.deployments?.filter( + (device: IAnimalDeployment) => device.attachment_end && moment(device.attachment_end).isBefore(moment()) + ); + return previousDeploys?.length + ? previousDeploys.map((device: IAnimalDeployment) => device.device_id).join(', ') + : 'No Devices'; + } }, { field: 'actions', diff --git a/app/src/features/surveys/view/survey-animals/animal.test.ts b/app/src/features/surveys/view/survey-animals/animal.test.ts index fe7921674e..a7eb1e2fd6 100644 --- a/app/src/features/surveys/view/survey-animals/animal.test.ts +++ b/app/src/features/surveys/view/survey-animals/animal.test.ts @@ -1,18 +1,18 @@ import yup from 'utils/YupSchema'; import { v4 } from 'uuid'; import { + AnimalSex, Critter, getAnimalFieldName, glt, IAnimal, IAnimalMarking, - ICritterMarking, isRequiredInSchema, lastAnimalValueValid } from './animal'; const animal: IAnimal = { - general: { taxon_id: 'a', taxon_name: 'taxon', animal_id: 'animal' }, + general: { taxon_id: 'a', taxon_name: 'taxon', animal_id: 'animal', wlh_id: 'a', sex: AnimalSex.MALE }, captures: [ { _id: v4(), @@ -50,7 +50,8 @@ const animal: IAnimal = { measurements: [], family: [], images: [], - device: undefined + device: undefined, + collectionUnits: [{ collection_category_id: 'a', collection_unit_id: 'b', _id: v4() }] }; describe('Animal', () => { @@ -170,11 +171,22 @@ describe('Animal', () => { it('constructor should create critter markings', () => { const c_marking = critter.markings[0]; - const a_marking = critter.markings[0]; + const a_marking = animal.markings[0]; expect(c_marking.critter_id).toBe(critter.critter_id); - for (const prop in c_marking) { - expect(c_marking[prop as keyof ICritterMarking]).toBe(a_marking[prop as keyof ICritterMarking]); - } + + expect(c_marking.marking_type_id).toBe(a_marking.marking_type_id); + expect(c_marking.taxon_marking_body_location_id).toBe(a_marking.taxon_marking_body_location_id); + expect(c_marking.primary_colour_id).toBe(a_marking.primary_colour_id); + expect(c_marking.secondary_colour_id).toBe(a_marking.secondary_colour_id); + expect(c_marking.marking_comment).toBe(a_marking.marking_comment); + }); + + it('constructor should create collections and strip extra vals', () => { + const c_collection = critter.collections[0]; + const a_collection = animal.collectionUnits[0]; + expect(c_collection.critter_id).toBe(critter.critter_id); + expect((c_collection as any)['collection_category_id']).not.toBeDefined(); + expect(c_collection.collection_unit_id).toBe(a_collection.collection_unit_id); }); }); }); diff --git a/app/src/features/surveys/view/survey-animals/animal.ts b/app/src/features/surveys/view/survey-animals/animal.ts index bd30ff0ccb..9128528663 100644 --- a/app/src/features/surveys/view/survey-animals/animal.ts +++ b/app/src/features/surveys/view/survey-animals/animal.ts @@ -6,6 +6,13 @@ import { v4 } from 'uuid'; import { AnyObjectSchema, InferType, reach } from 'yup'; import { AnimalTelemetryDeviceSchema } from './device'; +export enum AnimalSex { + MALE = 'Male', + FEMALE = 'Female', + UNKNOWN = 'Unknown', + HERM = 'Hermaphroditic' +} + /** * Provides an acceptable amount of type security with formik field names for animal forms * Returns formatted field name in regular or array format @@ -56,7 +63,9 @@ export type ProjectionMode = 'wgs' | 'utm'; export const AnimalGeneralSchema = yup.object({}).shape({ taxon_id: yup.string().required(req), animal_id: yup.string().required(req), - taxon_name: yup.string() + taxon_name: yup.string(), + wlh_id: yup.string(), + sex: yup.mixed().oneOf(Object.values(AnimalSex)) }); export const AnimalCaptureSchema = yup.object({}).shape({ @@ -101,7 +110,13 @@ export const AnimalMarkingSchema = yup.object({}).shape({ secondary_colour_id: yup.string().optional(), marking_comment: yup.string() }); -//proprietaryDataForm + +export const AnimalCollectionUnitSchema = yup.object({}).shape({ + _id: yup.string().required(), + collection_unit_id: yup.string().required(), + collection_category_id: yup.string().required() +}); + export const AnimalMeasurementSchema = yup.object({}).shape( { _id: yup.string().required(), @@ -159,6 +174,7 @@ export const AnimalSchema = yup.object({}).shape({ mortality: yup.array().of(AnimalMortalitySchema).required(), family: yup.array().of(AnimalRelationshipSchema).required(), images: yup.array().of(AnimalImageSchema).required(), + collectionUnits: yup.array().of(AnimalCollectionUnitSchema).required(), device: AnimalTelemetryDeviceSchema.default(undefined) }); @@ -178,6 +194,8 @@ export type IAnimalCapture = InferType; export type IAnimalMarking = InferType; +export type IAnimalCollectionUnit = InferType; + export type IAnimalMeasurement = InferType; export type IAnimalMortality = InferType; @@ -220,6 +238,8 @@ type ICritterCapture = Omit< export type ICritterMarking = Omit; +export type ICritterCollection = Omit; + type ICritterQualitativeMeasurement = Omit; type ICritterQuantitativeMeasurement = Omit; @@ -256,6 +276,8 @@ export class Critter { critter_id: string; taxon_id: string; animal_id: string; + wlh_id?: string; + sex?: AnimalSex; captures: ICritterCapture[]; markings: ICritterMarking[]; measurements: { @@ -265,6 +287,7 @@ export class Critter { mortalities: Omit[]; families: ICritterRelationships; locations: ICritterLocation[]; + collections: ICritterCollection[]; private taxon_name?: string; @@ -355,6 +378,13 @@ export class Critter { }); } + _formatCritterCollectionUnits(animal_collections: IAnimalCollectionUnit[]): ICritterCollection[] { + return animal_collections.map((collection) => ({ + critter_id: this.critter_id, + ...omit(collection, ['_id', 'collection_category_id']) + })); + } + _formatCritterQualitativeMeasurements(animal_measurements: IAnimalMeasurement[]): ICritterQualitativeMeasurement[] { const filteredQualitativeMeasurements = animal_measurements.filter((measurement) => { if (measurement.qualitative_option_id && measurement.value) { @@ -421,6 +451,8 @@ export class Critter { this.taxon_id = animal.general.taxon_id; this.taxon_name = animal.general.taxon_name; this.animal_id = animal.general.animal_id; + this.wlh_id = animal.general.wlh_id; + this.sex = animal.general.sex; const { captures, capture_locations } = this._formatCritterCaptures(animal.captures); const { mortalities, mortalities_locations } = this._formatCritterMortalities(animal.mortality); @@ -429,6 +461,7 @@ export class Critter { this.locations = [...capture_locations, ...mortalities_locations]; this.markings = this._formatCritterMarkings(animal.markings); + this.collections = this._formatCritterCollectionUnits(animal.collectionUnits); this.measurements = { qualitative: this._formatCritterQualitativeMeasurements(animal.measurements), diff --git a/app/src/features/surveys/view/survey-animals/form-sections/CollectionUnitAnimalForm.test.tsx b/app/src/features/surveys/view/survey-animals/form-sections/CollectionUnitAnimalForm.test.tsx new file mode 100644 index 0000000000..d52d4469a2 --- /dev/null +++ b/app/src/features/surveys/view/survey-animals/form-sections/CollectionUnitAnimalForm.test.tsx @@ -0,0 +1,40 @@ +import { SurveyAnimalsI18N } from 'constants/i18n'; +import { Formik } from 'formik'; +import { useCritterbaseApi } from 'hooks/useCritterbaseApi'; +import { fireEvent, render, waitFor } from 'test-helpers/test-utils'; +import CollectionUnitAnimalForm from './CollectionUnitAnimalForm'; + +jest.mock('hooks/useCritterbaseApi'); + +const mockUseCritterbaseApi = useCritterbaseApi as jest.Mock; + +const mockUseCritterbase = { + lookup: { + getSelectOptions: jest.fn() + } +}; + +describe('CollectionUnitAnimalForm', () => { + beforeEach(() => { + mockUseCritterbaseApi.mockImplementation(() => mockUseCritterbase); + mockUseCritterbase.lookup.getSelectOptions.mockClear(); + }); + it('should display a new part of the form when add unit clicked', async () => { + mockUseCritterbase.lookup.getSelectOptions.mockResolvedValueOnce([ + { id: 'a', value: 'a', label: 'category_label' } + ]); + + const { getByText } = render( + {}}> + {() => } + + ); + + await waitFor(() => { + fireEvent.click(getByText(SurveyAnimalsI18N.animalCollectionUnitAddBtn)); + expect(getByText(SurveyAnimalsI18N.animalCollectionUnitTitle2)).toBeInTheDocument(); + expect(getByText('Unit Category')).toBeInTheDocument(); + expect(getByText('Unit Name')).toBeInTheDocument(); + }); + }); +}); diff --git a/app/src/features/surveys/view/survey-animals/form-sections/CollectionUnitAnimalForm.tsx b/app/src/features/surveys/view/survey-animals/form-sections/CollectionUnitAnimalForm.tsx new file mode 100644 index 0000000000..ce983a04c2 --- /dev/null +++ b/app/src/features/surveys/view/survey-animals/form-sections/CollectionUnitAnimalForm.tsx @@ -0,0 +1,101 @@ +import { Grid } from '@mui/material'; +import CbSelectField from 'components/fields/CbSelectField'; +import { SurveyAnimalsI18N } from 'constants/i18n'; +import { FieldArray, FieldArrayRenderProps, useFormikContext } from 'formik'; +import { useCritterbaseApi } from 'hooks/useCritterbaseApi'; +import useDataLoader from 'hooks/useDataLoader'; +import { Fragment, useEffect } from 'react'; +import { v4 } from 'uuid'; +import { + AnimalCollectionUnitSchema, + getAnimalFieldName, + IAnimal, + IAnimalCollectionUnit, + isRequiredInSchema, + lastAnimalValueValid +} from '../animal'; +import FormSectionWrapper from './FormSectionWrapper'; + +const CollectionUnitAnimalForm = () => { + const api = useCritterbaseApi(); + const { values } = useFormikContext(); + const { data: categoriesData, refresh } = useDataLoader(api.lookup.getSelectOptions); + + useEffect(() => { + if (values.general.taxon_id) { + refresh({ route: 'lookups/taxon-collection-categories', query: `taxon_id=${values.general.taxon_id}` }); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [values.general.taxon_id]); + + const name: keyof IAnimal = 'collectionUnits'; + const newCollectionUnit = (): IAnimalCollectionUnit => ({ + _id: v4(), + collection_unit_id: '', + collection_category_id: '' + }); + + //Animals may have multiple collection units, but only one instance of each category. + //We use this and pass to the select component to ensure categories already used in the form can't be selected again. + const disabledCategories = values.collectionUnits.reduce((acc: Record, curr) => { + if (curr.collection_category_id) { + acc[curr.collection_category_id] = true; + } + return acc; + }, {}); + + return ( + + {({ remove, push }: FieldArrayRenderProps) => ( + <> + push(newCollectionUnit())} + handleRemoveSection={remove}> + {values.collectionUnits.map((unit, index) => ( + + + (name, 'collection_category_id', index)} + id={'collection_category_id'} + disabledValues={disabledCategories} + query={`taxon_id=${values.general.taxon_id}`} + route={'lookups/taxon-collection-categories'} + controlProps={{ + size: 'small', + required: isRequiredInSchema(AnimalCollectionUnitSchema, 'collection_category_id') + }} + /> + + + (name, 'collection_unit_id', index)} + controlProps={{ + size: 'small', + required: isRequiredInSchema(AnimalCollectionUnitSchema, 'collection_unit_id') + }} + /> + + + ))} + + + )} + + ); +}; + +export default CollectionUnitAnimalForm; diff --git a/app/src/features/surveys/view/survey-animals/form-sections/GeneralAnimalForm.tsx b/app/src/features/surveys/view/survey-animals/form-sections/GeneralAnimalForm.tsx index 65bc776455..7a9e24196b 100644 --- a/app/src/features/surveys/view/survey-animals/form-sections/GeneralAnimalForm.tsx +++ b/app/src/features/surveys/view/survey-animals/form-sections/GeneralAnimalForm.tsx @@ -16,7 +16,7 @@ import FormSectionWrapper from './FormSectionWrapper'; */ const GeneralAnimalForm = () => { - const { setFieldValue, handleBlur } = useFormikContext(); + const { setFieldValue, handleBlur, values } = useFormikContext(); const name: keyof IAnimal = 'general'; const handleTaxonName = (_value: string, label: string) => { @@ -33,7 +33,11 @@ const GeneralAnimalForm = () => { (name, 'taxon_id')} - controlProps={{ required: isRequiredInSchema(AnimalGeneralSchema, 'taxon_id'), size: 'small' }} + controlProps={{ + required: isRequiredInSchema(AnimalGeneralSchema, 'taxon_id'), + size: 'small', + disabled: !!values.collectionUnits.length + }} label={'Taxon'} id={'taxon'} route={'lookups/taxons'} @@ -41,11 +45,32 @@ const GeneralAnimalForm = () => { /> + + + (name, 'animal_id')} + handleBlur={handleBlur} + /> + + + + + (name, 'sex')} + controlProps={{ required: isRequiredInSchema(AnimalGeneralSchema, 'sex'), size: 'small' }} + label={'Sex'} + id={'sex'} + route={'lookups/sex'} + /> + + (name, 'animal_id')} + other={{ size: 'small', required: isRequiredInSchema(AnimalGeneralSchema, 'wlh_id') }} + label="Wildlife Health ID" + name={getAnimalFieldName(name, 'wlh_id')} handleBlur={handleBlur} /> diff --git a/app/src/hooks/api/useSurveyApi.test.ts b/app/src/hooks/api/useSurveyApi.test.ts index a6e5de3d69..d36f025958 100644 --- a/app/src/hooks/api/useSurveyApi.test.ts +++ b/app/src/hooks/api/useSurveyApi.test.ts @@ -1,6 +1,6 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; -import { Critter, IAnimal } from 'features/surveys/view/survey-animals/animal'; +import { AnimalSex, Critter, IAnimal } from 'features/surveys/view/survey-animals/animal'; import { IAnimalDeployment } from 'features/surveys/view/survey-animals/device'; import { v4 } from 'uuid'; import useSurveyApi from './useSurveyApi'; @@ -23,14 +23,15 @@ describe('useSurveyApi', () => { describe('createCritterAndAddToSurvey', () => { it('creates a critter successfully', async () => { const animal: IAnimal = { - general: { animal_id: '1', taxon_id: v4(), taxon_name: '1' }, + general: { animal_id: '1', taxon_id: v4(), taxon_name: '1', wlh_id: 'a', sex: AnimalSex.UNKNOWN }, captures: [], markings: [], measurements: [], mortality: [], family: [], images: [], - device: undefined + device: undefined, + collectionUnits: [] }; const critter = new Critter(animal); diff --git a/app/src/hooks/api/useSurveyApi.ts b/app/src/hooks/api/useSurveyApi.ts index 4f4edd71f9..cf78fcf115 100644 --- a/app/src/hooks/api/useSurveyApi.ts +++ b/app/src/hooks/api/useSurveyApi.ts @@ -455,7 +455,13 @@ const useSurveyApi = (axios: AxiosInstance) => { ): Promise => { const payload = { critters: [ - { critter_id: critter.critter_id, animal_id: critter.animal_id, sex: 'Unknown', taxon_id: critter.taxon_id } + { + critter_id: critter.critter_id, + animal_id: critter.animal_id, + sex: critter.sex, + taxon_id: critter.taxon_id, + wlh_id: critter.wlh_id + } ], qualitative_measurements: critter.measurements.qualitative, quantitative_measurements: critter.measurements.quantitative, diff --git a/app/src/hooks/cb_api/useCritterApi.test.tsx b/app/src/hooks/cb_api/useCritterApi.test.tsx index a7da80bee3..863a0bf33e 100644 --- a/app/src/hooks/cb_api/useCritterApi.test.tsx +++ b/app/src/hooks/cb_api/useCritterApi.test.tsx @@ -1,6 +1,6 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; -import { Critter, IAnimal } from 'features/surveys/view/survey-animals/animal'; +import { AnimalSex, Critter, IAnimal } from 'features/surveys/view/survey-animals/animal'; import { v4 } from 'uuid'; import { useCritterApi } from './useCritterApi'; @@ -21,7 +21,7 @@ describe('useCritterApi', () => { critter_id: mockId, wlh_id: '17-10748', animal_id: '6', - sex: 'Female', + sex: AnimalSex.FEMALE, taxon: 'Caribou', collection_units: [ { @@ -64,12 +64,15 @@ describe('useCritterApi', () => { general: { taxon_id: mockCritter.taxon, animal_id: mockCritter.animal_id, - taxon_name: 'Joe' + taxon_name: 'Joe', + wlh_id: 'a', + sex: AnimalSex.MALE }, mortality: [], family: [], images: [], - device: undefined + device: undefined, + collectionUnits: [] }; const payload = new Critter(forCritter);