diff --git a/CHANGELOG.md b/CHANGELOG.md index b6961a371..55b664cc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Make Inventory search and browse query boxes expandable. Refs UIIN-2493. * Added support for `containsAny` match option in Advanced search. Refs UIIN-2486. * Inventory search/browse: Do not retain checkbox selections when toggling search segment. Refs UIIN-2477. +* Show Instance record after creating with Fast add option. Refs UIIN-2497. ## [10.0.3] IN PROGRESS diff --git a/src/components/InstancesList/InstancesList.js b/src/components/InstancesList/InstancesList.js index 83dce4f6b..7d0e67f4a 100644 --- a/src/components/InstancesList/InstancesList.js +++ b/src/components/InstancesList/InstancesList.js @@ -544,7 +544,19 @@ class InstancesList extends React.Component { } } - toggleNewFastAddModal = () => { + toggleNewFastAddModal = ({ instanceRecord }) => { + const { + history, + location, + } = this.props; + + if (instanceRecord?.id) { + history.push({ + pathname: `/inventory/view/${instanceRecord.id}`, + search: location.search, + }); + } + this.setState((state) => { return { showNewFastAddModal: !state.showNewFastAddModal }; }); diff --git a/src/components/InstancesList/InstancesList.test.js b/src/components/InstancesList/InstancesList.test.js index cb1324a32..fc4d6ffc2 100644 --- a/src/components/InstancesList/InstancesList.test.js +++ b/src/components/InstancesList/InstancesList.test.js @@ -47,6 +47,16 @@ jest.mock('../../hooks', () => ({ }), })); +jest.mock('@folio/stripes/core', () => ({ + ...jest.requireActual('@folio/stripes/core'), + Pluggable: ({ renderTrigger, onClose }) => ( + <> + {renderTrigger()} + + + ), +})); + const data = { contributorTypes: [], contributorNameTypes: [], @@ -331,6 +341,33 @@ describe('InstancesList', () => { }); }); + describe('"New Fast Add record" button', () => { + it('should render', () => { + renderInstancesList({ segment: 'instances' }); + openActionMenu(); + + expect(screen.getByRole('button', { name: 'New Fast Add Record' })).toBeInTheDocument(); + }); + + describe('when saving the record', () => { + it('should redirect to new Instance record', async () => { + jest.spyOn(history, 'push'); + renderInstancesList({ segment: 'instances' }); + openActionMenu(); + + const button = screen.getByRole('button', { name: 'New Fast Add Record' }); + + fireEvent.click(button); + fireEvent.click(screen.getByText('Save & close')); + + expect(history.push).toHaveBeenCalledWith({ + pathname: '/inventory/view/fast-add-record-id', + search: '', + }); + }); + }); + }); + describe('"New MARC Bib Record" button', () => { it('should render', () => { renderInstancesList({ segment: 'instances' });