Skip to content

Commit

Permalink
UIQM-562 Optimistic locking error doesn't appear when edit "MARC auth…
Browse files Browse the repository at this point in the history
…ority" record
  • Loading branch information
BogdanDenis committed Sep 22, 2023
1 parent 4b28c4f commit 8a75d48
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* [UIQM-558](https://issues.folio.org/browse/UIQM-558) *BREAKING* bump `react-intl` to `v6.4.4`.
* [UIQM-559](https://issues.folio.org/browse/UIQM-559) Make auto-linking for the consortium.
* [UIQM-558](https://issues.folio.org/browse/UIQM-558) Allow a user to select a location code from the plugin.
* [UIQM-562](https://issues.folio.org/browse/UIQM-562) Fix optimistic locking error doesn't appear when edit "MARC authority" record.

## [6.0.2](https://github.com/folio-org/ui-quick-marc/tree/v6.0.2) (2023-03-30)

Expand Down
3 changes: 2 additions & 1 deletion src/QuickMarcEditor/QuickMarcEditWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useLocation } from 'react-router';
import PropTypes from 'prop-types';
import flow from 'lodash/flow';
import noop from 'lodash/noop';
import isNil from 'lodash/isNil';

import {
useStripes,
Expand Down Expand Up @@ -184,7 +185,7 @@ const QuickMarcEditWrapper = ({
const prevVersion = instance._version;
const lastVersion = instanceResponse._version;

if (prevVersion && lastVersion && prevVersion !== lastVersion) {
if (!isNil(prevVersion) && !isNil(lastVersion) && prevVersion !== lastVersion) {
setHttpError({
errorType: ERROR_TYPES.OPTIMISTIC_LOCKING,
message: 'ui-quick-marc.record.save.error.derive',
Expand Down
6 changes: 3 additions & 3 deletions src/QuickMarcEditor/QuickMarcEditWrapper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ jest.mock('./constants', () => ({
const getInstance = () => ({
id: faker.random.uuid(),
title: 'ui-quick-marc.record.edit.title',
_version: 1,
_version: 0,
});

const linkingRules = [{
Expand Down Expand Up @@ -494,13 +494,13 @@ describe('Given QuickMarcEditWrapper', () => {
it('should show up a conflict detection banner and not make an update request', async () => {
mutator.quickMarcEditInstance.GET = jest.fn(() => Promise.resolve({
...instance,
_version: '2',
_version: 1,
}));

const { getByText } = renderQuickMarcEditWrapper({
instance: {
...instance,
_version: '1',
_version: 0,
},
mutator,
});
Expand Down

0 comments on commit 8a75d48

Please sign in to comment.