Skip to content

Commit

Permalink
UIQM-725 Fix wrong error message while saving MARC Bib record with in…
Browse files Browse the repository at this point in the history
…valid LDR position values. (#754)
  • Loading branch information
BogdanDenis authored Nov 5, 2024
1 parent 54a44c6 commit 31ace6d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change history for ui-quick-marc

## [9.0.1] (IN PROGRESS)

* [UIQM-725](https://issues.folio.org/browse/UIQM-725) Fix wrong error message while saving MARC Bib record with invalid LDR position values.

## [9.0.0](https://github.com/folio-org/ui-quick-marc/tree/v9.0.0) (2024-11-01)

* [UIQM-647](https://issues.folio.org/browse/UIQM-647) Import `useUserTenantPermissions` from `@folio/stripes/core`.
Expand Down
4 changes: 4 additions & 0 deletions src/QuickMarcEditor/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,10 @@ export const isDiacritic = (char) => {
};

export const getVisibleNonSelectable008Subfields = (fixedFieldType) => {
if (!fixedFieldType) {
return [];
}

return fixedFieldType.items
.filter(field => !field.readOnly)
.filter(field => !field.isArray);
Expand Down
32 changes: 19 additions & 13 deletions src/QuickMarcEditor/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1865,21 +1865,19 @@ describe('QuickMarcEditor utils', () => {
});

describe('getFixedFieldStringPositions', () => {
beforeEach(() => {
jest.spyOn(FixedFieldFactory, 'getFixedFieldType').mockReturnValue({
items: [{
code: 'test1',
isArray: true,
}, {
code: 'test2',
isArray: false,
readOnly: false,
}],
});
});

describe('when a field is an 008', () => {
it('should return an 008 config', () => {
jest.spyOn(FixedFieldFactory, 'getFixedFieldType').mockReturnValueOnce({
items: [{
code: 'test1',
isArray: true,
}, {
code: 'test2',
isArray: false,
readOnly: false,
}],
});

const field = { tag: '008' };

expect(utils.getFixedFieldStringPositions('a', 'm', field, fixedFieldSpecBib)).toEqual([
Expand All @@ -1890,6 +1888,14 @@ describe('QuickMarcEditor utils', () => {
},
]);
});

describe('when type or subtype are invalid', () => {
it('should return an empty array', () => {
const field = { tag: '008' };

expect(utils.getFixedFieldStringPositions('|', '|', field, fixedFieldSpecBib)).toEqual([]);
});
});
});

describe('when a field is an 007', () => {
Expand Down

0 comments on commit 31ace6d

Please sign in to comment.