Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement#536 faceted search examples #551

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions src/component/search/facet/FacetedSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ INITIAL_STATE[VocabularyUtils.SKOS_NOTATION] = {
value: [""],
matchType: MatchType.EXACT_MATCH,
};
INITIAL_STATE[VocabularyUtils.SKOS_EXAMPLE] = {
property: VocabularyUtils.SKOS_EXAMPLE,
value: [""],
matchType: MatchType.SUBSTRING,
};
INITIAL_STATE[VocabularyUtils.RDF_TYPE] = {
property: VocabularyUtils.RDF_TYPE,
value: [],
Expand Down Expand Up @@ -96,33 +101,43 @@ const FacetedSearch: React.FC = () => {
<Card className="mb-0">
<CardBody>
<Row>
<Col xl={3} xs={6}>
<TextFacet
id="faceted-search-notation"
label={i18n("term.metadata.notation.label")}
value={params[VocabularyUtils.SKOS_NOTATION]}
onChange={onChange}
/>
</Col>
<Col xl={3} xs={6}>
<Col xl={4} xs={6}>
<VocabularyFacet
value={params[VocabularyUtils.IS_TERM_FROM_VOCABULARY]}
onChange={onChange}
/>
</Col>
<Col xl={3} xs={6}>
<Col xl={4} xs={6}>
<TermTypeFacet
value={params[VocabularyUtils.RDF_TYPE]}
onChange={onChange}
/>
</Col>
<Col xl={3} xs={6}>
<Col xl={4} xs={6}>
<TermStateFacet
value={params[VocabularyUtils.HAS_TERM_STATE]}
onChange={onChange}
/>
</Col>
</Row>
<Row>
<Col xl={4} xs={6}>
<TextFacet
id="faceted-search-notation"
label={i18n("term.metadata.notation.label")}
value={params[VocabularyUtils.SKOS_NOTATION]}
onChange={onChange}
/>
</Col>
<Col xl={4} xs={6}>
<TextFacet
id="faceted-search-examples"
label={i18n("term.metadata.example.label")}
value={params[VocabularyUtils.SKOS_EXAMPLE]}
onChange={onChange}
/>
</Col>
</Row>
</CardBody>
</Card>
<Card>
Expand Down
10 changes: 5 additions & 5 deletions src/component/search/facet/__tests__/FacetedSearch.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("FacetedSearch", () => {
matchType: MatchType.SUBSTRING,
};
await act(async () => {
wrapper.find(TextFacet).prop("onChange")(firstNotationValue);
wrapper.find(TextFacet).at(0).prop("onChange")(firstNotationValue);
});
wrapper.update();
act(() => {
Expand All @@ -58,7 +58,7 @@ describe("FacetedSearch", () => {
matchType: MatchType.SUBSTRING,
};
await act(async () => {
wrapper.find(TextFacet).prop("onChange")(secondNotationValue);
wrapper.find(TextFacet).at(0).prop("onChange")(secondNotationValue);
});
wrapper.update();
expect(wrapper.find(SimplePagination).prop("page")).toEqual(0);
Expand All @@ -84,7 +84,7 @@ describe("FacetedSearch", () => {
matchType: MatchType.SUBSTRING,
};
await act(async () => {
wrapper.find(TextFacet).prop("onChange")(firstNotationValue);
wrapper.find(TextFacet).at(0).prop("onChange")(firstNotationValue);
});
wrapper.update();
(SearchActions.executeFacetedTermSearch as jest.Mock).mockReset();
Expand Down Expand Up @@ -140,7 +140,7 @@ describe("FacetedSearch", () => {
expect(wrapper.exists(FacetedSearchResults)).toBeFalsy();
expect(wrapper.exists(SimplePagination)).toBeFalsy();
await act(async () => {
wrapper.find(TextFacet).prop("onChange")(firstNotationValue);
wrapper.find(TextFacet).at(0).prop("onChange")(firstNotationValue);
});
wrapper.update();
act(() => {
Expand All @@ -155,7 +155,7 @@ describe("FacetedSearch", () => {
matchType: MatchType.SUBSTRING,
};
act(() => {
wrapper.find(TextFacet).prop("onChange")(secondNotationValue);
wrapper.find(TextFacet).at(0).prop("onChange")(secondNotationValue);
});
await act(async () => {
wrapper.update();
Expand Down