diff --git a/packages/datagateway-search/src/card/investigationSearchCardView.component.test.tsx b/packages/datagateway-search/src/card/investigationSearchCardView.component.test.tsx index 9bb2b010d..16c86bd0a 100644 --- a/packages/datagateway-search/src/card/investigationSearchCardView.component.test.tsx +++ b/packages/datagateway-search/src/card/investigationSearchCardView.component.test.tsx @@ -246,6 +246,9 @@ describe('Investigation - Card View', () => { }); it('displays correct details panel for ISIS when expanded', async () => { + cardData.investigationinstrument = []; + cardData.investigationfacilitycycle = []; + const user = userEvent.setup(); renderComponent({ hierarchy: FACILITY_NAME.isis }); diff --git a/packages/datagateway-search/src/card/investigationSearchCardView.component.tsx b/packages/datagateway-search/src/card/investigationSearchCardView.component.tsx index ce438ab19..db7b45a70 100644 --- a/packages/datagateway-search/src/card/investigationSearchCardView.component.tsx +++ b/packages/datagateway-search/src/card/investigationSearchCardView.component.tsx @@ -311,7 +311,7 @@ const InvestigationCardView: React.FC = (props) => { instrumentId: investigation.investigationinstrument?.[0]?.['instrument.id'], facilityCycleId: - investigation.investigationfacilitycycle?.[0][ + investigation.investigationfacilitycycle?.[0]?.[ 'facilityCycle.id' ], }, diff --git a/packages/datagateway-search/src/table/investigationSearchTable.component.test.tsx b/packages/datagateway-search/src/table/investigationSearchTable.component.test.tsx index e19b7d9c2..f51ff6b41 100644 --- a/packages/datagateway-search/src/table/investigationSearchTable.component.test.tsx +++ b/packages/datagateway-search/src/table/investigationSearchTable.component.test.tsx @@ -840,9 +840,9 @@ describe('Investigation Search Table component', () => { ).toBeInTheDocument(); }); - it('renders fine with incomplete data', () => { + it('renders fine with incomplete data', async () => { // this can happen when navigating between tables and the previous table's state still exists - // also tests that empty arrays are fine for investigationInstruments + // also tests that empty arrays are fine for investigationInstruments & investigationFacilityCycles searchResponse = { results: [ { @@ -854,12 +854,21 @@ describe('Investigation Search Table component', () => { visitId: '1', doi: 'Test 1', investigationinstrument: [], + investigationfacilitycycle: [], }, }, ], }; - expect(() => renderComponent()).not.toThrowError(); + renderComponent(FACILITY_NAME.isis); + + await user.click( + await screen.findByRole('button', { name: 'Show details' }) + ); + + expect( + await screen.findByTestId('isis-investigation-details-panel') + ).toBeInTheDocument(); }); it('renders generic link correctly correctly', async () => { diff --git a/packages/datagateway-search/src/table/investigationSearchTable.component.tsx b/packages/datagateway-search/src/table/investigationSearchTable.component.tsx index bd694156d..77d5b265f 100644 --- a/packages/datagateway-search/src/table/investigationSearchTable.component.tsx +++ b/packages/datagateway-search/src/table/investigationSearchTable.component.tsx @@ -292,7 +292,7 @@ const InvestigationSearchTable: React.FC = (props) => { instrumentId: investigation.investigationinstrument?.[0]?.['instrument.id'], facilityCycleId: - investigation.investigationfacilitycycle?.[0][ + investigation.investigationfacilitycycle?.[0]?.[ 'facilityCycle.id' ], },