Skip to content

Commit

Permalink
UIQM-639: Use the '$' sign instead of '{dollar}' for search input and…
Browse files Browse the repository at this point in the history
… search query during manual linking. (#665)
  • Loading branch information
Dmytro-Melnyshyn authored Mar 20, 2024
1 parent 4f26a39 commit 8df1422
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [UIQM-471](https://issues.folio.org/browse/UIQM-471) Added Dropdowns for fixed field 008 bib records.
* [UIQM-610](https://issues.folio.org/browse/UIQM-610) Split LDR by position & add dropdowns for create/edit/derive.
* [UIQM-611](https://issues.folio.org/browse/UIQM-611) Add tooltips for LDR positions.
* [UIQM-611](https://issues.folio.org/browse/UIQM-639) Use the `$` sign instead of `{dollar}` for search input and search query during manual linking.

## [7.0.5](https://github.com/folio-org/ui-quick-marc/tree/v7.0.5) (2023-12-11)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,15 @@ const LinkButton = ({
segment: initialSegment,
};

const fieldContent = getContentSubfieldValue(content);
// To get the desired search result, the search query must contain `$` instead of `{dollar}`.
// BE returns `{dollar}` because the field content already uses the `$` sign and there is no way
// to distinguish whether `$` is the start of the subfield or just some value in the subfield.
const fieldContent = Object.entries(getContentSubfieldValue(content))
.reduce((acc, [subfield, subfieldContent]) => {
acc[subfield] = subfieldContent.map(value => value.replaceAll('{dollar}', '$'));

return acc;
}, {});

if (fieldContent.$0?.length) {
const keywordValue = [fieldContent.$a, fieldContent.$d, fieldContent.$t].flat().filter(Boolean).join(' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,36 @@ describe('Given LinkButton', () => {
});
});

describe('when linking Authority and field content contains "{dollar}"', () => {
it('should be replaced with $ sign for search input and search query', () => {
const { getAllByTestId } = renderComponent({
content: '$a {dollar}{dollar}{dollar} 50.00{dollar} $d currency ({dollar}) $0 n123456789 $t test{dollar}',
});

const searchInputValue = `keyword ${EXACT_PHRASE} $$$ 50.00$ currency ($) test$ or identifiers.value ${EXACT_PHRASE} n123456789`;

const initialValues = {
search: {
dropdownValue: 'advancedSearch',
searchIndex: 'advancedSearch',
searchInputValue,
searchQuery: searchInputValue,
filters: null,
},
browse: {
dropdownValue: 'personalNameTitle',
searchIndex: 'personalNameTitle',
filters: null,
},
segment: 'search',
};

fireEvent.click(getAllByTestId('link-authority-button-fakeId')[0]);

expect(Pluggable).toHaveBeenLastCalledWith(expect.objectContaining({ initialValues }), {});
});
});

describe('when linking Authority to a field with $0', () => {
it('should pass initial values to plugin', async () => {
const { getAllByTestId } = renderComponent({
Expand Down

0 comments on commit 8df1422

Please sign in to comment.