Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro-Melnyshyn committed Oct 16, 2023
1 parent 2216347 commit 47c989d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change history for ui-inventory

## [10.0.1](IN PROGRESS)
* If Shared & Held by facets were selected in the Browse search, then retain them in the Search lookup after clicking the record. Refs UIIN-2608.

## [10.0.0](https://github.com/folio-org/ui-inventory/tree/v10.0.0) (2023-10-13)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v9.4.12...v10.0.0)

Expand Down Expand Up @@ -107,7 +110,6 @@
* Bump @folio/stripes-acq-components dependency version to 5.0.0. Refs UIIN-2620.
* ECS: Check when sharing instance with source=MARC is complete before re-fetching it. Refs UIIN-2605.
* Update all facets after changing a term or selecting a facet option. Refs UIIN-2610.
* If Shared & Held by facets were selected in the Browse search, then retain them in the Search lookup after clicking the record. Refs UIIN-2608.

## [9.4.12](https://github.com/folio-org/ui-inventory/tree/v9.4.12) (2023-09-21)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v9.4.11...v9.4.12)
Expand Down
44 changes: 22 additions & 22 deletions src/components/BrowseResultsList/BrowseResultsList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ const mockContext = {

const contributorsData = [
{
"name": "Toth, Josh",
"contributorTypeId": [
"6e09d47d-95e2-4d8a-831b-f777b8ef6d81"
'name': 'Toth, Josh',
'contributorTypeId': [
'6e09d47d-95e2-4d8a-831b-f777b8ef6d81'
],
"contributorNameTypeId": "2b94c631-fca9-4892-a730-03ee529ffe2a",
"isAnchor": false,
"totalRecords": 1
'contributorNameTypeId': '2b94c631-fca9-4892-a730-03ee529ffe2a',
'isAnchor': false,
'totalRecords': 1
},
];
const subjectsData = [
{
"value": "Trivia and miscellanea",
"totalRecords": 8
'value': 'Trivia and miscellanea',
'totalRecords': 8
},
];

Expand Down Expand Up @@ -129,7 +129,7 @@ describe('BrowseResultsList', () => {
});

describe.each([
{ searchOption: browseCallNumberOptions.CALL_NUMBERS, shared: FACETS.SHARED, heldBy: FACETS.CALL_NUMBERS_HELD_BY },
{ searchOption: browseCallNumberOptions.CALL_NUMBERS, shared: FACETS.SHARED, heldBy: FACETS.CALL_NUMBERS_HELD_BY },
{ searchOption: browseCallNumberOptions.DEWEY, shared: FACETS.SHARED, heldBy: FACETS.CALL_NUMBERS_HELD_BY },
{ searchOption: browseCallNumberOptions.LIBRARY_OF_CONGRESS, shared: FACETS.SHARED, heldBy: FACETS.CALL_NUMBERS_HELD_BY },
{ searchOption: browseCallNumberOptions.LOCAL, shared: FACETS.SHARED, heldBy: FACETS.CALL_NUMBERS_HELD_BY },
Expand All @@ -151,16 +151,16 @@ describe('BrowseResultsList', () => {
qindex: searchOption,
query: 'a',
[shared]: ['true', 'false'],
[heldBy]: ["college"],
[heldBy]: ['college'],
},
});

await act(async () => fireEvent.click(screen.getByText(defaultProps.browseData[2].fullCallNumber)));

expect(history.location.search).toContain('?filters=shared.true%2Cshared.false%2CtenantId.college');
})
})
})
});
});
});

describe('when the search option is Contributors and the Shared and/or HeldBy facets are selected', () => {
describe('and the user clicks on a record in the list', () => {
Expand All @@ -176,7 +176,7 @@ describe('BrowseResultsList', () => {
filters: {
qindex: 'contributors',
contributorsShared: ['true', 'false'],
contributorsTenantId: ["college"],
contributorsTenantId: ['college'],
},
browseData: contributorsData,
});
Expand All @@ -186,11 +186,11 @@ describe('BrowseResultsList', () => {
expect(history.location.search).toContain(
'?filters=searchContributors.2b94c631-fca9-4892-a730-03ee529ffe2a%2Cshared.true%2Cshared.false%2CtenantId.college'
);
})
})
})
});
});
});

describe(`when the search option is Subjects and the Shared and/or HeldBy facets are selected`, () => {
describe('when the search option is Subjects and the Shared and/or HeldBy facets are selected', () => {
describe('and the user clicks on a record in the list', () => {
it('should be navigated to the Search lookup with those filters', async () => {
history = createMemoryHistory({
Expand All @@ -204,17 +204,17 @@ describe('BrowseResultsList', () => {
filters: {
qindex: 'browseSubjects',
subjectsShared: ['true', 'false'],
subjectsTenantId: ["college"],
subjectsTenantId: ['college'],
},
browseData: subjectsData,
});

await act(async () => fireEvent.click(screen.getByText(subjectsData[0].value)));

expect(history.location.search).toContain('?filters=shared.true%2Cshared.false%2CtenantId.college');
})
})
})
});
});
});

describe('when Instance record is linked to an authority record', () => {
describe('by clicking on the icon of an authority app', () => {
Expand Down
5 changes: 2 additions & 3 deletions src/components/BrowseResultsList/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ export const isRowPreventsClick = (row, browseOption) => {
);
};

// [true, false] => 'shared.true,shared.false'
const facetsToString = (filters, facetNameInBrowse, facetNameInSearch) => {
return filters[facetNameInBrowse]?.map(value => `${facetNameInSearch}.${value}`).join(',');
}
};

const getExtraFilters = (row, qindex, allFilters) => {
const filtersOnly = omit(allFilters, 'qindex', 'query');
Expand Down Expand Up @@ -51,7 +50,7 @@ const getExtraFilters = (row, qindex, allFilters) => {
const extraFacetsString = [...extraFacets, sharedExtraFacets, heldByExtraFacets].filter(Boolean).join(',');

return extraFacetsString ? { filters: extraFacetsString } : {};
}
};

export const getSearchParams = (row, qindex, allFilters) => {
const filters = getExtraFilters(row, qindex, allFilters);
Expand Down

0 comments on commit 47c989d

Please sign in to comment.