From cff283225b606c0cfe7b7621a08f4d284e0f9e1e Mon Sep 17 00:00:00 2001 From: Mariia Aloshyna <55138456+mariia-aloshyna@users.noreply.github.com> Date: Wed, 20 Apr 2022 23:51:06 +0300 Subject: [PATCH] UIIN-2012: After using the Chrome "go back" button, following the link "Holdings Created" from Data import to Inventory causes an error. (#1656) --- src/ViewHoldingsRecord.js | 3 ++- src/ViewHoldingsRecord.test.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ViewHoldingsRecord.js b/src/ViewHoldingsRecord.js index 4aae3d7b7..de8b5de77 100644 --- a/src/ViewHoldingsRecord.js +++ b/src/ViewHoldingsRecord.js @@ -408,6 +408,7 @@ class ViewHoldingsRecord extends React.Component { }; isAwaitingResource = () => { + const { referenceTables } = this.props; const { holdingsRecords, instances1, @@ -425,7 +426,7 @@ class ViewHoldingsRecord extends React.Component { return true; } - return false; + return isEmpty(referenceTables); }; getEntity = () => this.getMostRecentHolding(); diff --git a/src/ViewHoldingsRecord.test.js b/src/ViewHoldingsRecord.test.js index c40cf8a12..a36fbe0cc 100644 --- a/src/ViewHoldingsRecord.test.js +++ b/src/ViewHoldingsRecord.test.js @@ -9,6 +9,10 @@ import { renderWithIntl, translationsProperties } from '../test/jest/helpers'; import ViewHoldingsRecord from './ViewHoldingsRecord'; jest.mock('./withLocation', () => jest.fn(c => c)); +jest.mock('@folio/stripes/components', () => ({ + ...jest.requireActual('@folio/stripes/components'), + LoadingView: () => 'LoadingView', +})); const defaultProps = { id: 'id', @@ -67,6 +71,12 @@ describe('ViewHoldingsRecord actions', () => { defaultProps.history.push.mockClear(); }); + it('should render Loading when awaiting resource', () => { + const { getByText } = renderViewHoldingsRecord({ referenceTables: {} }) + + expect(getByText('LoadingView')).toBeDefined(); + }); + it('should close view holding page', async () => { renderViewHoldingsRecord();