@coveo/quantic 3.32.0 → 3.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/docs/out/quantic-docs.json +1 -1
- package/force-app/main/default/lwc/quanticAriaLive/__tests__/quanticAriaLive.test.js +106 -0
- package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +752 -0
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/fixture.ts +76 -0
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/pageObject.ts +282 -0
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/quanticBreadcrumbManager.e2e.ts +167 -0
- package/force-app/main/default/lwc/quanticCarousel/__tests__/quanticCarousel.test.js +262 -0
- package/force-app/main/default/lwc/quanticCaseClassification/__tests__/quanticCaseClassification.test.js +819 -0
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/data.ts +23 -0
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/fixture.ts +51 -0
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/pageObject.ts +152 -0
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/quanticCaseClassification.e2e.ts +269 -0
- package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +1183 -0
- package/force-app/main/default/lwc/quanticCategoryFacet/e2e/data.ts +27 -0
- package/force-app/main/default/lwc/quanticCategoryFacet/e2e/fixture.ts +75 -0
- package/force-app/main/default/lwc/quanticCategoryFacet/e2e/pageObject.ts +55 -0
- package/force-app/main/default/lwc/quanticCategoryFacet/e2e/quanticCategoryFacet.e2e.ts +199 -0
- package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +371 -0
- package/force-app/main/default/lwc/quanticColoredResultBadge/__tests__/quanticColoredResultBadge.test.js +212 -0
- package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +688 -0
- package/force-app/main/default/lwc/quanticDateFacet/e2e/data.ts +24 -0
- package/force-app/main/default/lwc/quanticDateFacet/e2e/fixture.ts +68 -0
- package/force-app/main/default/lwc/quanticDateFacet/e2e/pageObject.ts +27 -0
- package/force-app/main/default/lwc/quanticDateFacet/e2e/quanticDateFacet.e2e.ts +145 -0
- package/force-app/main/default/lwc/quanticDidYouMean/__tests__/quanticDidYouMean.test.js +348 -0
- package/force-app/main/default/lwc/quanticDidYouMean/e2e/data.ts +48 -0
- package/force-app/main/default/lwc/quanticDidYouMean/e2e/fixture.ts +80 -0
- package/force-app/main/default/lwc/quanticDidYouMean/e2e/pageObject.ts +173 -0
- package/force-app/main/default/lwc/quanticDidYouMean/e2e/quanticDidYouMean.e2e.ts +219 -0
- package/force-app/main/default/lwc/quanticDocumentSuggestion/__tests__/quanticDocumentSuggestion.test.js +404 -0
- package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/fixture.ts +38 -0
- package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/pageObject.ts +52 -0
- package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/quanticDocumentSuggestion.e2e.ts +102 -0
- package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +1105 -0
- package/force-app/main/default/lwc/quanticFacet/e2e/data.ts +21 -0
- package/force-app/main/default/lwc/quanticFacet/e2e/fixture.ts +73 -0
- package/force-app/main/default/lwc/quanticFacet/e2e/pageObject.ts +67 -0
- package/force-app/main/default/lwc/quanticFacet/e2e/quanticFacet.e2e.ts +208 -0
- package/force-app/main/default/lwc/quanticFacetCaption/__tests__/quanticFacetCaption.test.js +28 -0
- package/force-app/main/default/lwc/quanticFacetManager/__tests__/quanticFacetManager.test.js +178 -0
- package/force-app/main/default/lwc/quanticFacetManager/e2e/fixture.ts +64 -0
- package/force-app/main/default/lwc/quanticFacetManager/e2e/pageObject.ts +23 -0
- package/force-app/main/default/lwc/quanticFacetManager/e2e/quanticFacetManager.e2e.ts +82 -0
- package/force-app/main/default/lwc/quanticFeedback/__tests__/quanticFeedback.test.js +392 -0
- package/force-app/main/default/lwc/quanticFeedbackModal/__tests__/quanticFeedbackModal.test.js +448 -0
- package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +298 -0
- package/force-app/main/default/lwc/quanticFoldedResultList/__tests__/quanticFoldedResultList.test.js +323 -0
- package/force-app/main/default/lwc/quanticFoldedResultList/e2e/fixture.ts +70 -0
- package/force-app/main/default/lwc/quanticFoldedResultList/e2e/pageObject.ts +81 -0
- package/force-app/main/default/lwc/quanticFoldedResultList/e2e/quanticFoldedResultList.e2e.ts +69 -0
- package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +1158 -0
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +56 -0
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +185 -0
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +451 -0
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +337 -0
- package/force-app/main/default/lwc/quanticGeneratedAnswerContent/__tests__/quanticGeneratedAnswerContent.test.js +151 -0
- package/force-app/main/default/lwc/quanticHeading/__tests__/quanticHeading.test.js +71 -0
- package/force-app/main/default/lwc/quanticHeadlessLoader/__tests__/quanticHeadlessLoader.test.js +651 -0
- package/force-app/main/default/lwc/quanticInsightInterface/__tests__/quanticInsightInterface.test.js +194 -0
- package/force-app/main/default/lwc/quanticInsightInterface/quanticInsightInterface.js +1 -1
- package/force-app/main/default/lwc/quanticInsightSummary/__tests__/quanticInsightSummary.test.js +230 -0
- package/force-app/main/default/lwc/quanticModal/__tests__/quanticModal.test.js +205 -0
- package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +309 -0
- package/force-app/main/default/lwc/quanticNotifications/e2e/fixture.ts +58 -0
- package/force-app/main/default/lwc/quanticNotifications/e2e/pageObject.ts +55 -0
- package/force-app/main/default/lwc/quanticNotifications/e2e/quanticNotifications.e2e.ts +47 -0
- package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +953 -0
- package/force-app/main/default/lwc/quanticNumericFacet/e2e/data.ts +28 -0
- package/force-app/main/default/lwc/quanticNumericFacet/e2e/fixture.ts +71 -0
- package/force-app/main/default/lwc/quanticNumericFacet/e2e/pageObject.ts +59 -0
- package/force-app/main/default/lwc/quanticNumericFacet/e2e/quanticNumericFacet.e2e.ts +164 -0
- package/force-app/main/default/lwc/quanticPager/__tests__/quanticPager.test.js +430 -0
- package/force-app/main/default/lwc/quanticPager/e2e/fixture.ts +65 -0
- package/force-app/main/default/lwc/quanticPager/e2e/pageObject.ts +69 -0
- package/force-app/main/default/lwc/quanticPager/e2e/quanticPager.e2e.ts +106 -0
- package/force-app/main/default/lwc/quanticPlaceholder/__tests__/quanticPlaceholder.test.js +47 -0
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/defaultTestCase.json +13 -0
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/youtubeTestCase.json +14 -0
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/quanticQuickviewContent.test.js +82 -0
- package/force-app/main/default/lwc/quanticRadioButtonsGroup/__tests__/quanticRadioButtonsGroup.test.js +273 -0
- package/force-app/main/default/lwc/quanticRecentQueriesList/__tests__/quanticRecentQueriesList.test.js +448 -0
- package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/fixture.ts +42 -0
- package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/pageObject.ts +55 -0
- package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/quanticRecentQueriesList.e2e.ts +93 -0
- package/force-app/main/default/lwc/quanticRecentResultsList/__tests__/quanticRecentResultsList.test.js +516 -0
- package/force-app/main/default/lwc/quanticRecentResultsList/e2e/fixture.ts +42 -0
- package/force-app/main/default/lwc/quanticRecentResultsList/e2e/pageObject.ts +61 -0
- package/force-app/main/default/lwc/quanticRecentResultsList/e2e/quanticRecentResultsList.e2e.ts +48 -0
- package/force-app/main/default/lwc/quanticRecommendationList/__tests__/quanticRecommendationList.test.js +491 -0
- package/force-app/main/default/lwc/quanticRecommendationList/e2e/fixture.ts +35 -0
- package/force-app/main/default/lwc/quanticRecommendationList/e2e/pageObject.ts +52 -0
- package/force-app/main/default/lwc/quanticRecommendationList/e2e/quanticRecommendationList.e2e.ts +53 -0
- package/force-app/main/default/lwc/quanticRefineModalContent/__tests__/quanticRefineModalContent.test.js +747 -0
- package/force-app/main/default/lwc/quanticRefineToggle/__tests__/quanticRefineToggle.test.js +542 -0
- package/force-app/main/default/lwc/quanticResultAction/__tests__/quanticResultAction.test.js +262 -0
- package/force-app/main/default/lwc/quanticResultActionBar/__tests__/quanticResultActionBar.test.js +141 -0
- package/force-app/main/default/lwc/quanticResultChildren/__tests__/quanticResultChildren.test.js +340 -0
- package/force-app/main/default/lwc/quanticResultCopyToClipboard/__tests__/quanticResultCopyToClipboard.test.js +300 -0
- package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/fixture.ts +46 -0
- package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/pageObject.ts +49 -0
- package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/quanticResultCopyToClipboard.e2e.ts +40 -0
- package/force-app/main/default/lwc/quanticResultDate/__tests__/quanticResultDate.test.js +144 -0
- package/force-app/main/default/lwc/quanticResultField/__tests__/quanticResultField.test.js +120 -0
- package/force-app/main/default/lwc/quanticResultHighlightedTextField/__tests__/quanticResultHighlightedTextField.test.js +209 -0
- package/force-app/main/default/lwc/quanticResultLink/__tests__/quanticResultLink.test.js +261 -0
- package/force-app/main/default/lwc/quanticResultList/__tests__/quanticResultList.test.js +342 -0
- package/force-app/main/default/lwc/quanticResultList/e2e/fixture.ts +66 -0
- package/force-app/main/default/lwc/quanticResultList/e2e/pageObject.ts +81 -0
- package/force-app/main/default/lwc/quanticResultList/e2e/quanticResultList.e2e.ts +69 -0
- package/force-app/main/default/lwc/quanticResultMultiValueText/__tests__/quanticResultMultiValueText.test.js +235 -0
- package/force-app/main/default/lwc/quanticResultNumber/__tests__/quanticResultNumber.test.js +144 -0
- package/force-app/main/default/lwc/quanticResultPrintableUri/__tests__/quanticResultPrintableUri.test.js +324 -0
- package/force-app/main/default/lwc/quanticResultQuickview/__tests__/quanticResultQuickview.test.js +301 -0
- package/force-app/main/default/lwc/quanticResultQuickview/e2e/fixture.ts +81 -0
- package/force-app/main/default/lwc/quanticResultQuickview/e2e/pageObject.ts +38 -0
- package/force-app/main/default/lwc/quanticResultQuickview/e2e/quanticResultQuickView.e2e.ts +66 -0
- package/force-app/main/default/lwc/quanticResultTemplate/__tests__/quanticResultTemplate.test.js +90 -0
- package/force-app/main/default/lwc/quanticResultText/__tests__/quanticResultText.test.js +155 -0
- package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js +464 -0
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +74 -0
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/pageObject.ts +85 -0
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/quanticResultsPerPage.e2e.ts +97 -0
- package/force-app/main/default/lwc/quanticSearchBox/__tests__/quanticSearchBox.test.js +487 -0
- package/force-app/main/default/lwc/quanticSearchBox/e2e/fixture.ts +84 -0
- package/force-app/main/default/lwc/quanticSearchBox/e2e/pageObject.ts +45 -0
- package/force-app/main/default/lwc/quanticSearchBox/e2e/quanticSearchBox.e2e.ts +159 -0
- package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js +743 -0
- package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/__tests__/quanticSearchBoxSuggestionsList.test.js +571 -0
- package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/fixture.ts +110 -0
- package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/pageObject.ts +113 -0
- package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/quanticSearchBoxSuggestionsList.e2e.ts +299 -0
- package/force-app/main/default/lwc/quanticSmartSnippet/__tests__/quanticSmartSnippet.test.js +341 -0
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/data.ts +21 -0
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/fixture.ts +91 -0
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +196 -0
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +192 -0
- package/force-app/main/default/lwc/quanticSmartSnippetAnswer/__tests__/quanticSmartSnippetAnswer.test.js +126 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSource/__tests__/quanticSmartSnippetSource.test.js +290 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/__tests__/quanticSmartSnippetSuggestions.test.js +329 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/data.ts +31 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/fixture.ts +93 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/pageObject.ts +160 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/quanticSmartSnippetSuggestions.e2e.ts +127 -0
- package/force-app/main/default/lwc/quanticSort/__tests__/quanticSort.test.js +416 -0
- package/force-app/main/default/lwc/quanticSort/e2e/fixture.ts +61 -0
- package/force-app/main/default/lwc/quanticSort/e2e/pageObject.ts +89 -0
- package/force-app/main/default/lwc/quanticSort/e2e/quanticSort.e2e.ts +91 -0
- package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +136 -0
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/__tests__/quanticStandaloneSearchBox.test.js +387 -0
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/fixture.ts +53 -0
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/pageObject.ts +54 -0
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/quanticStandaloneSearchBox.e2e.ts +72 -0
- package/force-app/main/default/lwc/quanticStatefulButton/__tests__/quanticStatefulButton.test.js +222 -0
- package/force-app/main/default/lwc/quanticSummary/__tests__/quanticSummary.test.js +244 -0
- package/force-app/main/default/lwc/quanticTab/__tests__/quanticTab.test.js +333 -0
- package/force-app/main/default/lwc/quanticTab/e2e/fixture.ts +56 -0
- package/force-app/main/default/lwc/quanticTab/e2e/pageObject.ts +68 -0
- package/force-app/main/default/lwc/quanticTab/e2e/quanticTab.e2e.ts +72 -0
- package/force-app/main/default/lwc/quanticTabBar/__tests__/quanticTabBar.test.js +331 -0
- package/force-app/main/default/lwc/quanticTabBar/e2e/fixture.ts +61 -0
- package/force-app/main/default/lwc/quanticTabBar/e2e/pageObject.ts +80 -0
- package/force-app/main/default/lwc/quanticTabBar/e2e/quanticTabBar.e2e.ts +171 -0
- package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +1037 -0
- package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/fixture.ts +58 -0
- package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/pageObject.ts +43 -0
- package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/quanticTimeframeFacet.e2e.ts +160 -0
- package/force-app/main/default/lwc/quanticTooltip/__tests__/quanticTooltip.test.js +107 -0
- package/force-app/main/default/lwc/quanticUserAction/__tests__/quanticUserAction.test.js +427 -0
- package/force-app/main/default/lwc/quanticUserActionsSession/__tests__/quanticUserActionsSession.test.js +269 -0
- package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/data/userActionsState.json +89 -0
- package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/quanticUserActionsTimeline.test.js +511 -0
- package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +229 -0
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +32 -0
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +32 -0
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +71 -0
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +39 -0
- package/force-app/main/default/lwc/quanticUtils/__tests__/citationAnchoringUtils.test.js +84 -0
- package/force-app/main/default/lwc/quanticUtils/__tests__/facetDependenciesUtils.test.js +92 -0
- package/force-app/main/default/lwc/quanticUtils/__tests__/markdownUtils.test.js +71 -0
- package/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js +223 -0
- package/force-app/main/default/lwc/quanticUtils/recentQueriesUtils.js +20 -12
- package/force-app/main/default/lwc/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +131 -0
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/case-assist-engine/case-assist-engine.d.ts +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-engine/commerce-engine.d.ts +16 -16
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/common-reducers.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/insight-engine/insight-engine.d.ts +5 -5
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/recommendation-engine/recommendation-engine.d.ts +4 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/search-engine/search-engine.d.ts +4 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/store.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/facets/headless-core-commerce-facet.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/facets/range-facet/headless-core-range-facet.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/recent-queries-list/headless-core-recent-queries-list.d.ts +91 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/insight/attach-to-case/headless-attach-to-case.d.ts +2 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/insight/attached-results/headless-attached-results.d.ts +68 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/insight/recent-queries-list/headless-insight-recent-queries-list.d.ts +14 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/recent-queries-list/headless-recent-queries-list.d.ts +2 -79
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/actions-history/ipx-actions-history-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/advanced-search-queries/advanced-search-queries-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/analytics/search-action-cause.d.ts +9 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/attached-results/attached-results-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/attached-results/attached-results-state.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/case-assist-configuration/case-assist-configuration-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/case-context/case-context-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/case-field/case-field-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/case-field/case-field-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/case-input/case-input-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/configuration/configuration-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/context/cart/cart-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/context/cart/cart-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/context/context-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/did-you-mean/did-you-mean-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/facets/facet-search-set/commerce-facet-search-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/facets/facet-set/facet-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/instant-products/instant-products-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/pagination/pagination-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/parameters/parameters-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/product/product-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/product-listing/product-listing-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/product-listing/product-listing-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/query/query-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/query-suggest/query-suggest-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/recent-queries/recent-queries-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/recommendations/recommendations-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/recommendations/recommendations-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/search/search-actions.d.ts +4 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/search/search-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/sort/sort-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/standalone-search-box-set/standalone-search-box-set-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/triggers/triggers-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/configuration/configuration-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/context/context-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/debug/debug-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/debug/version-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/dictionary-field-context/dictionary-field-context-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/did-you-mean/did-you-mean-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/document-suggestion/document-suggestion-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/document-suggestion/document-suggestion-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/excerpt-length/excerpt-length-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facet-options/facet-options-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/automatic-facet-set/automatic-facet-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/category-facet-set/category-facet-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-order/facet-order-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-search-set/category/category-facet-search-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-search-set/generic/generic-facet-search-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-search-set/specific/specific-facet-search-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-set/facet-set-controller-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-set/facet-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/range-facets/date-facet-set/date-facet-controller-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/range-facets/date-facet-set/date-facet-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/fields/fields-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/fields/fields-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/folding/folding-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/folding/folding-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/folding/insight-folding-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/history/history-actions.d.ts +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/history/history-slice.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-configuration/insight-configuration-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-interface/insight-interface-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-interface/insight-interface-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-search/insight-search-actions.d.ts +5 -5
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-search/legacy/insight-search-actions.d.ts +4 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-user-actions/insight-user-actions-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-user-actions/insight-user-actions-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/instant-results/instant-results-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/pagination/pagination-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/pipeline/pipeline-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/query/query-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/query-set/query-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/query-suggest/query-suggest-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/query-suggest/query-suggest-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/question-answering/question-answering-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/recent-queries/recent-queries-insight-analytics-actions.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/recent-queries/recent-queries-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/recent-results/recent-results-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/recommendation/recommendation-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/recommendation/recommendation-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/result-preview/result-preview-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/result-preview/result-preview-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/legacy/search-actions.d.ts +5 -5
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-actions.d.ts +6 -6
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-hub/search-hub-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/sort-criteria/sort-criteria-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/standalone-search-box-set/standalone-search-box-set-actions.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/standalone-search-box-set/standalone-search-box-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/static-filter-set/static-filter-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/tab-set/tab-set-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/triggers/triggers-slice.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/insight.index.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/factories/build-factory.d.ts +6 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/fetch-static-state.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/from-build-result.d.ts +6 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/hydrate-static-state.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/access-token-manager.d.ts +19 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/augment-preprocess-request.d.ts +7 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/types/fetch-static-state.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/types/hydrate-static-state.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/engine.d.ts +4 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/access-token-manager.d.ts +19 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/augment-preprocess-request.d.ts +7 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/engine/search-engine.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/state/insight-app-state.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/test/mock-ssr-controller-definitions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -10
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +9 -9
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +3 -3
- package/package.json +46 -44
package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js
ADDED
|
@@ -0,0 +1,1183 @@
|
|
|
1
|
+
/* eslint-disable no-import-assign */
|
|
2
|
+
import QuanticCategoryFacet from 'c/quanticCategoryFacet';
|
|
3
|
+
import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
|
|
4
|
+
import {generateFacetDependencyConditions} from 'c/quanticUtils';
|
|
5
|
+
import {buildCreateTestComponent, cleanup, flushPromises} from 'c/testUtils';
|
|
6
|
+
|
|
7
|
+
jest.mock('c/quanticUtils', () => ({
|
|
8
|
+
generateFacetDependencyConditions: jest.fn(),
|
|
9
|
+
regexEncode: jest.fn(),
|
|
10
|
+
Store: {
|
|
11
|
+
facetTypes: {
|
|
12
|
+
FACETS: 'facets',
|
|
13
|
+
NUMERICFACETS: 'numericFacets',
|
|
14
|
+
DATEFACETS: 'dateFacets',
|
|
15
|
+
CATEGORYFACETS: 'categoryFacets',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
I18nUtils: {
|
|
19
|
+
format: jest.fn(),
|
|
20
|
+
getLabelNameWithCount: jest.fn(),
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
jest.mock('c/quanticHeadlessLoader');
|
|
24
|
+
|
|
25
|
+
const selectors = {
|
|
26
|
+
facetContent: '[data-testid="facet-content"]',
|
|
27
|
+
componentError: 'c-quantic-component-error',
|
|
28
|
+
placeholder: 'c-quantic-placeholder',
|
|
29
|
+
cardContainer: 'c-quantic-card-container',
|
|
30
|
+
facetValue: 'c-quantic-category-facet-value[data-testid="facet-value"]',
|
|
31
|
+
facetValueNoActiveParent:
|
|
32
|
+
'c-quantic-category-facet-value[data-testid="no-active-parent-facet-value"]',
|
|
33
|
+
activeParent: '[data-testid="facet__active-parent"]',
|
|
34
|
+
facetSearchValue:
|
|
35
|
+
'c-quantic-category-facet-value[data-testid="facet-search-value"]',
|
|
36
|
+
allCategoriesButton: '[data-testid="facet__all-categories__button"]',
|
|
37
|
+
facetSearchboxInput: '[data-testid="facet__searchbox-input"]',
|
|
38
|
+
facetSearchNoMatch: '[data-testid="facet-search__no-match"]',
|
|
39
|
+
facetSearchMoreMatches: '[data-testid="facet-search__more-matches"]',
|
|
40
|
+
facetValuesShowLess: '[data-testid="facet-values__show-less"]',
|
|
41
|
+
facetValuesShowMore: '[data-testid="facet-values__show-more"]',
|
|
42
|
+
facetBody: '[data-testid="facet__body"]',
|
|
43
|
+
facetCollapseToggle: 'lightning-button-icon',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const exampleFacetId = 'example facet id';
|
|
47
|
+
const exampleField = 'exampleField';
|
|
48
|
+
const exampleEngineId = 'exampleEngineId';
|
|
49
|
+
|
|
50
|
+
const exampleFacetValues = [
|
|
51
|
+
{
|
|
52
|
+
value: 'North America',
|
|
53
|
+
state: 'idle',
|
|
54
|
+
numberOfResults: 112,
|
|
55
|
+
children: [],
|
|
56
|
+
path: ['North America'],
|
|
57
|
+
isLeafValue: false,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
value: 'Africa',
|
|
61
|
+
state: 'idle',
|
|
62
|
+
numberOfResults: 58,
|
|
63
|
+
children: [],
|
|
64
|
+
path: ['Africa'],
|
|
65
|
+
isLeafValue: false,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const defaultOptions = {
|
|
70
|
+
engineId: exampleEngineId,
|
|
71
|
+
field: exampleField,
|
|
72
|
+
facetId: exampleFacetId,
|
|
73
|
+
delimitingCharacter: ';',
|
|
74
|
+
numberOfValues: 10,
|
|
75
|
+
sortCriteria: 'occurrences',
|
|
76
|
+
basePath: '',
|
|
77
|
+
noFilterByBasePath: false,
|
|
78
|
+
noFilterFacetCount: false,
|
|
79
|
+
label: 'example label',
|
|
80
|
+
};
|
|
81
|
+
const parentFacetIdError = `The ${exampleField} c-quantic-category-facet requires dependsOn.parentFacetId to be a valid string.`;
|
|
82
|
+
const expectedValueError = `The ${exampleField} c-quantic-category-facet requires dependsOn.expectedValue to be a valid string.`;
|
|
83
|
+
|
|
84
|
+
const initialFacetState = {
|
|
85
|
+
facetId: exampleFacetId,
|
|
86
|
+
valuesAsTrees: [],
|
|
87
|
+
enabled: true,
|
|
88
|
+
facetSearch: {},
|
|
89
|
+
};
|
|
90
|
+
let facetState = initialFacetState;
|
|
91
|
+
|
|
92
|
+
const initialSearchStatusState = {
|
|
93
|
+
hasError: false,
|
|
94
|
+
};
|
|
95
|
+
let searchStatusState = initialSearchStatusState;
|
|
96
|
+
|
|
97
|
+
const createTestComponent = buildCreateTestComponent(
|
|
98
|
+
QuanticCategoryFacet,
|
|
99
|
+
'c-quantic-category-facet',
|
|
100
|
+
defaultOptions
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const functionsMocks = {
|
|
104
|
+
buildCategoryFacet: jest.fn(() => ({
|
|
105
|
+
subscribe: functionsMocks.facetStateSubscriber,
|
|
106
|
+
state: facetState,
|
|
107
|
+
deselectAll: functionsMocks.deselectAll,
|
|
108
|
+
toggleSelect: functionsMocks.toggleSelect,
|
|
109
|
+
showLessValues: functionsMocks.showLessValues,
|
|
110
|
+
showMoreValues: functionsMocks.showMoreValues,
|
|
111
|
+
facetSearch: {
|
|
112
|
+
updateText: functionsMocks.updateText,
|
|
113
|
+
search: functionsMocks.search,
|
|
114
|
+
select: functionsMocks.select,
|
|
115
|
+
},
|
|
116
|
+
})),
|
|
117
|
+
stopWatching: jest.fn(),
|
|
118
|
+
buildFacetConditionsManager: jest.fn(() => ({
|
|
119
|
+
stopWatching: functionsMocks.stopWatching,
|
|
120
|
+
})),
|
|
121
|
+
buildSearchStatus: jest.fn(() => ({
|
|
122
|
+
subscribe: functionsMocks.searchStatusStateSubscriber,
|
|
123
|
+
state: searchStatusState,
|
|
124
|
+
})),
|
|
125
|
+
facetStateSubscriber: jest.fn((cb) => {
|
|
126
|
+
cb();
|
|
127
|
+
return functionsMocks.facetStateUnsubscriber;
|
|
128
|
+
}),
|
|
129
|
+
searchStatusStateSubscriber: jest.fn((cb) => {
|
|
130
|
+
cb();
|
|
131
|
+
return functionsMocks.searchStatusStateUnsubscriber;
|
|
132
|
+
}),
|
|
133
|
+
facetStateUnsubscriber: jest.fn(),
|
|
134
|
+
searchStatusStateUnsubscriber: jest.fn(),
|
|
135
|
+
deselectAll: jest.fn(),
|
|
136
|
+
toggleSelect: jest.fn(),
|
|
137
|
+
select: jest.fn(),
|
|
138
|
+
registerToStore: jest.fn(),
|
|
139
|
+
eventHandler: jest.fn(),
|
|
140
|
+
updateText: jest.fn(),
|
|
141
|
+
search: jest.fn(),
|
|
142
|
+
showLessValues: jest.fn(),
|
|
143
|
+
showMoreValues: jest.fn(),
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// @ts-ignore
|
|
147
|
+
mockHeadlessLoader.registerToStore = functionsMocks.registerToStore;
|
|
148
|
+
|
|
149
|
+
function prepareHeadlessState() {
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
mockHeadlessLoader.getHeadlessBundle = () => {
|
|
152
|
+
return {
|
|
153
|
+
buildCategoryFacet: functionsMocks.buildCategoryFacet,
|
|
154
|
+
buildSearchStatus: functionsMocks.buildSearchStatus,
|
|
155
|
+
buildFacetConditionsManager: functionsMocks.buildFacetConditionsManager,
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const exampleEngine = {
|
|
161
|
+
id: exampleEngineId,
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
let isInitialized = false;
|
|
165
|
+
|
|
166
|
+
function mockBueno() {
|
|
167
|
+
// @ts-ignore
|
|
168
|
+
mockHeadlessLoader.getBueno = () => {
|
|
169
|
+
// @ts-ignore
|
|
170
|
+
global.Bueno = {
|
|
171
|
+
isString: jest
|
|
172
|
+
.fn()
|
|
173
|
+
.mockImplementation(
|
|
174
|
+
(value) => Object.prototype.toString.call(value) === '[object String]'
|
|
175
|
+
),
|
|
176
|
+
};
|
|
177
|
+
return new Promise((resolve) => resolve());
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function mockSuccessfulHeadlessInitialization() {
|
|
182
|
+
// @ts-ignore
|
|
183
|
+
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
184
|
+
if (element instanceof QuanticCategoryFacet && !isInitialized) {
|
|
185
|
+
isInitialized = true;
|
|
186
|
+
initialize(exampleEngine);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function mockErroneousHeadlessInitialization() {
|
|
192
|
+
// @ts-ignore
|
|
193
|
+
mockHeadlessLoader.initializeWithHeadless = (element) => {
|
|
194
|
+
if (element instanceof QuanticCategoryFacet) {
|
|
195
|
+
element.setInitializationError();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
describe('c-quantic-category-facet', () => {
|
|
201
|
+
beforeEach(() => {
|
|
202
|
+
prepareHeadlessState();
|
|
203
|
+
mockSuccessfulHeadlessInitialization();
|
|
204
|
+
mockBueno();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
afterEach(() => {
|
|
208
|
+
cleanup();
|
|
209
|
+
isInitialized = false;
|
|
210
|
+
searchStatusState = initialSearchStatusState;
|
|
211
|
+
facetState = initialFacetState;
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
describe('component initialization', () => {
|
|
215
|
+
it('should initialize the facet controller and the search status controller', async () => {
|
|
216
|
+
createTestComponent();
|
|
217
|
+
await flushPromises();
|
|
218
|
+
|
|
219
|
+
expect(functionsMocks.buildCategoryFacet).toHaveBeenCalledTimes(1);
|
|
220
|
+
expect(functionsMocks.buildSearchStatus).toHaveBeenCalledTimes(1);
|
|
221
|
+
expect(functionsMocks.buildCategoryFacet).toHaveBeenCalledWith(
|
|
222
|
+
exampleEngine,
|
|
223
|
+
expect.objectContaining({
|
|
224
|
+
options: expect.objectContaining({
|
|
225
|
+
field: defaultOptions.field,
|
|
226
|
+
facetId: defaultOptions.facetId,
|
|
227
|
+
sortCriteria: defaultOptions.sortCriteria,
|
|
228
|
+
numberOfValues: defaultOptions.numberOfValues,
|
|
229
|
+
delimitingCharacter: defaultOptions.delimitingCharacter,
|
|
230
|
+
basePath: [],
|
|
231
|
+
filterFacetCount: !defaultOptions.noFilterFacetCount,
|
|
232
|
+
filterByBasePath: !defaultOptions.noFilterByBasePath,
|
|
233
|
+
}),
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('should register the facet to the quantic store', async () => {
|
|
239
|
+
const expectedFacetType = 'categoryFacets';
|
|
240
|
+
const element = createTestComponent();
|
|
241
|
+
await flushPromises();
|
|
242
|
+
|
|
243
|
+
expect(functionsMocks.registerToStore).toHaveBeenCalledTimes(1);
|
|
244
|
+
expect(functionsMocks.registerToStore).toHaveBeenCalledWith(
|
|
245
|
+
exampleEngine.id,
|
|
246
|
+
expectedFacetType,
|
|
247
|
+
expect.objectContaining({
|
|
248
|
+
label: defaultOptions.label,
|
|
249
|
+
facetId: defaultOptions.facetId,
|
|
250
|
+
element: element,
|
|
251
|
+
})
|
|
252
|
+
);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('should subscribe to the headless category facet state and search status state changes', async () => {
|
|
256
|
+
createTestComponent();
|
|
257
|
+
await flushPromises();
|
|
258
|
+
|
|
259
|
+
expect(functionsMocks.facetStateSubscriber).toHaveBeenCalledTimes(1);
|
|
260
|
+
expect(functionsMocks.searchStatusStateSubscriber).toHaveBeenCalledTimes(
|
|
261
|
+
1
|
|
262
|
+
);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
describe('the facet conditions manager', () => {
|
|
266
|
+
it('should build the controller when the dependsOn property is set', async () => {
|
|
267
|
+
const exampleFacetDependency = {
|
|
268
|
+
parentFacetId: 'filetype',
|
|
269
|
+
expectedValue: 'txt',
|
|
270
|
+
};
|
|
271
|
+
createTestComponent({
|
|
272
|
+
...defaultOptions,
|
|
273
|
+
dependsOn: exampleFacetDependency,
|
|
274
|
+
});
|
|
275
|
+
await flushPromises();
|
|
276
|
+
|
|
277
|
+
expect(functionsMocks.buildCategoryFacet).toHaveBeenCalledTimes(1);
|
|
278
|
+
expect(
|
|
279
|
+
functionsMocks.buildFacetConditionsManager
|
|
280
|
+
).toHaveBeenCalledTimes(1);
|
|
281
|
+
expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledWith(
|
|
282
|
+
exampleEngine,
|
|
283
|
+
{
|
|
284
|
+
facetId: exampleFacetId,
|
|
285
|
+
}
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
expect(generateFacetDependencyConditions).toHaveBeenCalledTimes(1);
|
|
289
|
+
expect(generateFacetDependencyConditions).toHaveBeenCalledWith({
|
|
290
|
+
[exampleFacetDependency.parentFacetId]:
|
|
291
|
+
exampleFacetDependency.expectedValue,
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('should not build the controller when the dependsOn property is not set', async () => {
|
|
296
|
+
createTestComponent();
|
|
297
|
+
await flushPromises();
|
|
298
|
+
|
|
299
|
+
expect(functionsMocks.buildCategoryFacet).toHaveBeenCalledTimes(1);
|
|
300
|
+
expect(
|
|
301
|
+
functionsMocks.buildFacetConditionsManager
|
|
302
|
+
).toHaveBeenCalledTimes(0);
|
|
303
|
+
expect(generateFacetDependencyConditions).toHaveBeenCalledTimes(0);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
describe('when an initialization error occurs', () => {
|
|
308
|
+
beforeEach(() => {
|
|
309
|
+
mockErroneousHeadlessInitialization();
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('should display the initialization error component', async () => {
|
|
313
|
+
const element = createTestComponent();
|
|
314
|
+
await flushPromises();
|
|
315
|
+
|
|
316
|
+
const componentError = element.shadowRoot.querySelector(
|
|
317
|
+
selectors.componentError
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
expect(componentError).not.toBeNull();
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
describe('the facet enablement', () => {
|
|
326
|
+
describe('when the facet is enabled', () => {
|
|
327
|
+
beforeAll(() => {
|
|
328
|
+
facetState = {...initialFacetState, enabled: true};
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('should display the facet content', async () => {
|
|
332
|
+
const element = createTestComponent();
|
|
333
|
+
await flushPromises();
|
|
334
|
+
|
|
335
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
336
|
+
selectors.facetContent
|
|
337
|
+
);
|
|
338
|
+
expect(facetContent).not.toBeNull();
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
describe('when the facet is not enabled', () => {
|
|
343
|
+
beforeAll(() => {
|
|
344
|
+
facetState = {...initialFacetState, enabled: false};
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('should not display the facet content', async () => {
|
|
348
|
+
const element = createTestComponent();
|
|
349
|
+
await flushPromises();
|
|
350
|
+
|
|
351
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
352
|
+
selectors.facetContent
|
|
353
|
+
);
|
|
354
|
+
expect(facetContent).toBeNull();
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
describe('when the component is loading', () => {
|
|
360
|
+
beforeEach(() => {
|
|
361
|
+
searchStatusState = {
|
|
362
|
+
...initialSearchStatusState,
|
|
363
|
+
isLoading: true,
|
|
364
|
+
hasError: false,
|
|
365
|
+
firstSearchExecuted: false,
|
|
366
|
+
};
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('should display the placeholder component', async () => {
|
|
370
|
+
const element = createTestComponent();
|
|
371
|
+
await flushPromises();
|
|
372
|
+
|
|
373
|
+
const placeholder = element.shadowRoot.querySelector(
|
|
374
|
+
selectors.placeholder
|
|
375
|
+
);
|
|
376
|
+
expect(placeholder).not.toBeNull();
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
describe('when the interface has an error', () => {
|
|
380
|
+
beforeEach(() => {
|
|
381
|
+
searchStatusState = {
|
|
382
|
+
...initialSearchStatusState,
|
|
383
|
+
isLoading: true,
|
|
384
|
+
hasError: true,
|
|
385
|
+
firstSearchExecuted: false,
|
|
386
|
+
};
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
it('should not display the placeholder component', async () => {
|
|
390
|
+
const element = createTestComponent();
|
|
391
|
+
await flushPromises();
|
|
392
|
+
|
|
393
|
+
const placeholder = element.shadowRoot.querySelector(
|
|
394
|
+
selectors.placeholder
|
|
395
|
+
);
|
|
396
|
+
expect(placeholder).toBeNull();
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
describe('when the component is ready', () => {
|
|
402
|
+
describe('when the facet has values', () => {
|
|
403
|
+
beforeEach(() => {
|
|
404
|
+
facetState = {
|
|
405
|
+
...initialFacetState,
|
|
406
|
+
valuesAsTrees: exampleFacetValues,
|
|
407
|
+
};
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it('should display the facet card', async () => {
|
|
411
|
+
const element = createTestComponent();
|
|
412
|
+
await flushPromises();
|
|
413
|
+
|
|
414
|
+
const cardContainer = element.shadowRoot.querySelector(
|
|
415
|
+
selectors.cardContainer
|
|
416
|
+
);
|
|
417
|
+
expect(cardContainer).not.toBeNull();
|
|
418
|
+
expect(cardContainer.title).toBe(defaultOptions.label);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
it('should display the facet values', async () => {
|
|
422
|
+
const element = createTestComponent();
|
|
423
|
+
await flushPromises();
|
|
424
|
+
|
|
425
|
+
const facetValueElements = element.shadowRoot.querySelectorAll(
|
|
426
|
+
selectors.facetValue
|
|
427
|
+
);
|
|
428
|
+
expect(facetValueElements.length).toBe(exampleFacetValues.length);
|
|
429
|
+
exampleFacetValues.forEach((facetValue, index) => {
|
|
430
|
+
expect(facetValueElements[index].item).toEqual(facetValue);
|
|
431
|
+
expect(facetValueElements[index].activeParent).toBeUndefined();
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('should call the controller function toggleSingleSelect when clicked', async () => {
|
|
436
|
+
const element = createTestComponent({
|
|
437
|
+
...defaultOptions,
|
|
438
|
+
});
|
|
439
|
+
const selectedIndex = 0;
|
|
440
|
+
await flushPromises();
|
|
441
|
+
|
|
442
|
+
const facetValueElement = element.shadowRoot.querySelector(
|
|
443
|
+
selectors.facetValue
|
|
444
|
+
);
|
|
445
|
+
const selection = exampleFacetValues[selectedIndex];
|
|
446
|
+
facetValueElement.dispatchEvent(
|
|
447
|
+
new CustomEvent('quantic__selectvalue', {
|
|
448
|
+
bubbles: true,
|
|
449
|
+
detail: {
|
|
450
|
+
value: selection.value,
|
|
451
|
+
},
|
|
452
|
+
})
|
|
453
|
+
);
|
|
454
|
+
await flushPromises();
|
|
455
|
+
|
|
456
|
+
expect(functionsMocks.toggleSelect).toHaveBeenCalledTimes(1);
|
|
457
|
+
expect(functionsMocks.toggleSelect).toHaveBeenCalledWith(selection);
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
describe('when a facet value has an active parent nested under a non-active parent', () => {
|
|
461
|
+
const exampleFacetValue = {
|
|
462
|
+
value: 'example facet value',
|
|
463
|
+
state: 'idle',
|
|
464
|
+
numberOfResults: 1,
|
|
465
|
+
children: [],
|
|
466
|
+
path: ['non active parent', 'active parent', 'example facet value'],
|
|
467
|
+
isLeafValue: true,
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
const exampleActiveParent = {
|
|
471
|
+
value: 'active parent',
|
|
472
|
+
state: 'selected',
|
|
473
|
+
numberOfResults: 10,
|
|
474
|
+
children: [exampleFacetValue],
|
|
475
|
+
moreValuesAvailable: false,
|
|
476
|
+
path: ['non active parent', 'active parent'],
|
|
477
|
+
isLeafValue: false,
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
const exampleNonActiveParent = {
|
|
481
|
+
value: 'non active parent',
|
|
482
|
+
state: 'idle',
|
|
483
|
+
numberOfResults: 100,
|
|
484
|
+
children: [exampleActiveParent],
|
|
485
|
+
path: ['non active parent'],
|
|
486
|
+
isLeafValue: false,
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
beforeEach(() => {
|
|
490
|
+
facetState = {
|
|
491
|
+
...initialFacetState,
|
|
492
|
+
activeValue: exampleActiveParent,
|
|
493
|
+
selectedValueAncestry: [
|
|
494
|
+
exampleNonActiveParent,
|
|
495
|
+
exampleActiveParent,
|
|
496
|
+
],
|
|
497
|
+
valuesAsTrees: [exampleNonActiveParent],
|
|
498
|
+
};
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
it('should display the all categories button', async () => {
|
|
502
|
+
const element = createTestComponent();
|
|
503
|
+
await flushPromises();
|
|
504
|
+
|
|
505
|
+
const allCategoriesButton = element.shadowRoot.querySelector(
|
|
506
|
+
selectors.allCategoriesButton
|
|
507
|
+
);
|
|
508
|
+
|
|
509
|
+
expect(allCategoriesButton).not.toBeNull();
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
describe('when the all categories button is clicked', () => {
|
|
513
|
+
it('should call the deselectAll method of the controller', async () => {
|
|
514
|
+
const element = createTestComponent();
|
|
515
|
+
await flushPromises();
|
|
516
|
+
|
|
517
|
+
const allCategoriesButton = element.shadowRoot.querySelector(
|
|
518
|
+
selectors.allCategoriesButton
|
|
519
|
+
);
|
|
520
|
+
await allCategoriesButton.click();
|
|
521
|
+
|
|
522
|
+
expect(functionsMocks.deselectAll).toHaveBeenCalledTimes(1);
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it('should display the non active parent of the facet values', async () => {
|
|
527
|
+
const element = createTestComponent();
|
|
528
|
+
await flushPromises();
|
|
529
|
+
|
|
530
|
+
const nonActiveParents = element.shadowRoot.querySelectorAll(
|
|
531
|
+
selectors.facetValueNoActiveParent
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
expect(nonActiveParents.length).toBe(1);
|
|
535
|
+
expect(nonActiveParents[0].item).toEqual(
|
|
536
|
+
expect.objectContaining(exampleNonActiveParent)
|
|
537
|
+
);
|
|
538
|
+
expect(nonActiveParents[0].nonActiveParent).toBe('true');
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
describe('when the non active parent is clicked', () => {
|
|
542
|
+
it('should call the toggleSelect method of the controller', async () => {
|
|
543
|
+
const element = createTestComponent();
|
|
544
|
+
await flushPromises();
|
|
545
|
+
|
|
546
|
+
const nonActiveParents = element.shadowRoot.querySelectorAll(
|
|
547
|
+
selectors.facetValueNoActiveParent
|
|
548
|
+
);
|
|
549
|
+
nonActiveParents[0].dispatchEvent(
|
|
550
|
+
new CustomEvent('quantic__selectvalue', {
|
|
551
|
+
bubbles: true,
|
|
552
|
+
detail: {
|
|
553
|
+
value: exampleNonActiveParent.value,
|
|
554
|
+
},
|
|
555
|
+
})
|
|
556
|
+
);
|
|
557
|
+
|
|
558
|
+
expect(functionsMocks.toggleSelect).toHaveBeenCalledTimes(1);
|
|
559
|
+
expect(functionsMocks.toggleSelect).toHaveBeenCalledWith(
|
|
560
|
+
exampleNonActiveParent
|
|
561
|
+
);
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
it('should display the active parent of the facet values', async () => {
|
|
566
|
+
const element = createTestComponent();
|
|
567
|
+
await flushPromises();
|
|
568
|
+
|
|
569
|
+
const activeParent = element.shadowRoot.querySelector(
|
|
570
|
+
selectors.activeParent
|
|
571
|
+
);
|
|
572
|
+
|
|
573
|
+
expect(activeParent).not.toBeNull();
|
|
574
|
+
expect(activeParent.textContent).toBe(
|
|
575
|
+
`${exampleActiveParent.value}(${exampleActiveParent.numberOfResults})`
|
|
576
|
+
);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
it('should display the facet values', async () => {
|
|
580
|
+
const element = createTestComponent();
|
|
581
|
+
await flushPromises();
|
|
582
|
+
|
|
583
|
+
const facetValues = element.shadowRoot.querySelectorAll(
|
|
584
|
+
selectors.facetValue
|
|
585
|
+
);
|
|
586
|
+
|
|
587
|
+
expect(facetValues.length).toBe(1);
|
|
588
|
+
expect(facetValues[0].item).toEqual(
|
|
589
|
+
expect.objectContaining(exampleFacetValue)
|
|
590
|
+
);
|
|
591
|
+
expect(facetValues[0].nonActiveParent).toBeFalsy();
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
describe('when the facet value is clicked', () => {
|
|
595
|
+
it('should call the deselectAll method of the controller', async () => {
|
|
596
|
+
const element = createTestComponent();
|
|
597
|
+
await flushPromises();
|
|
598
|
+
|
|
599
|
+
const facetValues = element.shadowRoot.querySelectorAll(
|
|
600
|
+
selectors.facetValue
|
|
601
|
+
);
|
|
602
|
+
facetValues[0].dispatchEvent(
|
|
603
|
+
new CustomEvent('quantic__selectvalue', {
|
|
604
|
+
bubbles: true,
|
|
605
|
+
detail: {
|
|
606
|
+
value: exampleFacetValue.value,
|
|
607
|
+
},
|
|
608
|
+
})
|
|
609
|
+
);
|
|
610
|
+
|
|
611
|
+
expect(functionsMocks.toggleSelect).toHaveBeenCalledTimes(1);
|
|
612
|
+
expect(functionsMocks.toggleSelect).toHaveBeenCalledWith(
|
|
613
|
+
exampleFacetValue
|
|
614
|
+
);
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
describe('when the property withSearch is set to true', () => {
|
|
620
|
+
it('should display the search input', async () => {
|
|
621
|
+
const element = createTestComponent({
|
|
622
|
+
...defaultOptions,
|
|
623
|
+
withSearch: true,
|
|
624
|
+
});
|
|
625
|
+
await flushPromises();
|
|
626
|
+
|
|
627
|
+
const facetSearchboxInput = element.shadowRoot.querySelector(
|
|
628
|
+
selectors.facetSearchboxInput
|
|
629
|
+
);
|
|
630
|
+
expect(facetSearchboxInput).not.toBeNull();
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
it('should call the updateText method and the search of the facet search controller when the input value changes', async () => {
|
|
634
|
+
const element = createTestComponent({
|
|
635
|
+
...defaultOptions,
|
|
636
|
+
withSearch: true,
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
await flushPromises();
|
|
640
|
+
|
|
641
|
+
const facetSearchboxInput = element.shadowRoot.querySelector(
|
|
642
|
+
selectors.facetSearchboxInput
|
|
643
|
+
);
|
|
644
|
+
facetSearchboxInput.value = 'test';
|
|
645
|
+
facetSearchboxInput.dispatchEvent(
|
|
646
|
+
new CustomEvent('change', {
|
|
647
|
+
bubbles: true,
|
|
648
|
+
})
|
|
649
|
+
);
|
|
650
|
+
|
|
651
|
+
expect(functionsMocks.updateText).toHaveBeenCalledTimes(1);
|
|
652
|
+
expect(functionsMocks.updateText).toHaveBeenCalledWith('test');
|
|
653
|
+
expect(functionsMocks.search).toHaveBeenCalledTimes(1);
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
describe('when the search input contains a value', () => {
|
|
657
|
+
describe('when facet search values are available', () => {
|
|
658
|
+
const exampleFacetSearchValues = [
|
|
659
|
+
{
|
|
660
|
+
displayValue: 'value one',
|
|
661
|
+
rawValue: 'valueOne',
|
|
662
|
+
count: 1,
|
|
663
|
+
path: ['example parent one'],
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
displayValue: 'value two',
|
|
667
|
+
rawValue: 'valueTwo',
|
|
668
|
+
count: 1,
|
|
669
|
+
path: ['example parent two'],
|
|
670
|
+
},
|
|
671
|
+
];
|
|
672
|
+
|
|
673
|
+
beforeEach(() => {
|
|
674
|
+
facetState = {
|
|
675
|
+
...facetState,
|
|
676
|
+
facetSearch: {
|
|
677
|
+
values: exampleFacetSearchValues,
|
|
678
|
+
},
|
|
679
|
+
};
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
it('should display facet search values', async () => {
|
|
683
|
+
const element = createTestComponent({
|
|
684
|
+
...defaultOptions,
|
|
685
|
+
withSearch: true,
|
|
686
|
+
});
|
|
687
|
+
await flushPromises();
|
|
688
|
+
const facetSearchboxInput = element.shadowRoot.querySelector(
|
|
689
|
+
selectors.facetSearchboxInput
|
|
690
|
+
);
|
|
691
|
+
facetSearchboxInput.value = 'test';
|
|
692
|
+
await flushPromises();
|
|
693
|
+
|
|
694
|
+
const facetSearchValueElements =
|
|
695
|
+
element.shadowRoot.querySelectorAll(selectors.facetSearchValue);
|
|
696
|
+
expect(facetSearchValueElements.length).toBe(
|
|
697
|
+
exampleFacetSearchValues.length
|
|
698
|
+
);
|
|
699
|
+
exampleFacetSearchValues.forEach((facetValue, index) => {
|
|
700
|
+
expect(facetSearchValueElements[index].item).toEqual(
|
|
701
|
+
expect.objectContaining({
|
|
702
|
+
value: facetValue.rawValue,
|
|
703
|
+
numberOfResults: facetValue.count,
|
|
704
|
+
path: facetValue.path,
|
|
705
|
+
highlightedResult: facetValue.displayValue,
|
|
706
|
+
})
|
|
707
|
+
);
|
|
708
|
+
});
|
|
709
|
+
});
|
|
710
|
+
|
|
711
|
+
it('should not display the facet search no match label', async () => {
|
|
712
|
+
const element = createTestComponent({
|
|
713
|
+
...defaultOptions,
|
|
714
|
+
withSearch: true,
|
|
715
|
+
});
|
|
716
|
+
await flushPromises();
|
|
717
|
+
const facetSearchboxInput = element.shadowRoot.querySelector(
|
|
718
|
+
selectors.facetSearchboxInput
|
|
719
|
+
);
|
|
720
|
+
facetSearchboxInput.value = 'test';
|
|
721
|
+
await flushPromises();
|
|
722
|
+
|
|
723
|
+
const facetSearchNoMatch = element.shadowRoot.querySelector(
|
|
724
|
+
selectors.facetSearchNoMatch
|
|
725
|
+
);
|
|
726
|
+
expect(facetSearchNoMatch).toBeNull();
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
it('should call the controller function select when clicking a facet search value', async () => {
|
|
730
|
+
const element = createTestComponent({
|
|
731
|
+
...defaultOptions,
|
|
732
|
+
withSearch: true,
|
|
733
|
+
});
|
|
734
|
+
const selectedIndex = 0;
|
|
735
|
+
await flushPromises();
|
|
736
|
+
const facetSearchboxInput = element.shadowRoot.querySelector(
|
|
737
|
+
selectors.facetSearchboxInput
|
|
738
|
+
);
|
|
739
|
+
facetSearchboxInput.value = 'test';
|
|
740
|
+
await flushPromises();
|
|
741
|
+
|
|
742
|
+
const facetSearchValueElements =
|
|
743
|
+
element.shadowRoot.querySelectorAll(selectors.facetSearchValue);
|
|
744
|
+
|
|
745
|
+
const selection = exampleFacetSearchValues[selectedIndex];
|
|
746
|
+
facetSearchValueElements[selectedIndex].dispatchEvent(
|
|
747
|
+
new CustomEvent('quantic__selectvalue', {
|
|
748
|
+
bubbles: true,
|
|
749
|
+
detail: {
|
|
750
|
+
value: selection.rawValue,
|
|
751
|
+
},
|
|
752
|
+
})
|
|
753
|
+
);
|
|
754
|
+
await flushPromises();
|
|
755
|
+
|
|
756
|
+
expect(functionsMocks.select).toHaveBeenCalledTimes(1);
|
|
757
|
+
expect(functionsMocks.select).toHaveBeenCalledWith({
|
|
758
|
+
count: selection.count,
|
|
759
|
+
path: selection.path,
|
|
760
|
+
rawValue: selection.rawValue,
|
|
761
|
+
displayValue: selection.rawValue,
|
|
762
|
+
});
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
describe('when more facet search values are available', () => {
|
|
766
|
+
beforeEach(() => {
|
|
767
|
+
facetState = {
|
|
768
|
+
...facetState,
|
|
769
|
+
facetSearch: {
|
|
770
|
+
values: exampleFacetSearchValues,
|
|
771
|
+
moreValuesAvailable: true,
|
|
772
|
+
},
|
|
773
|
+
};
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
it('should display the facet search more matches message', async () => {
|
|
777
|
+
const element = createTestComponent({
|
|
778
|
+
...defaultOptions,
|
|
779
|
+
withSearch: true,
|
|
780
|
+
});
|
|
781
|
+
await flushPromises();
|
|
782
|
+
const facetSearchboxInput = element.shadowRoot.querySelector(
|
|
783
|
+
selectors.facetSearchboxInput
|
|
784
|
+
);
|
|
785
|
+
facetSearchboxInput.value = 'test';
|
|
786
|
+
await flushPromises();
|
|
787
|
+
|
|
788
|
+
const facetSearchMoreMatches = element.shadowRoot.querySelector(
|
|
789
|
+
selectors.facetSearchMoreMatches
|
|
790
|
+
);
|
|
791
|
+
expect(facetSearchMoreMatches).not.toBeNull();
|
|
792
|
+
});
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
describe('when canShowMoreValues is set to true in the state', () => {
|
|
796
|
+
beforeEach(() => {
|
|
797
|
+
facetState = {
|
|
798
|
+
...facetState,
|
|
799
|
+
facetSearch: {
|
|
800
|
+
values: exampleFacetSearchValues,
|
|
801
|
+
},
|
|
802
|
+
canShowMoreValues: true,
|
|
803
|
+
};
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
it('should not display the facet show more button', async () => {
|
|
807
|
+
const element = createTestComponent({
|
|
808
|
+
...defaultOptions,
|
|
809
|
+
withSearch: true,
|
|
810
|
+
});
|
|
811
|
+
await flushPromises();
|
|
812
|
+
const facetSearchboxInput = element.shadowRoot.querySelector(
|
|
813
|
+
selectors.facetSearchboxInput
|
|
814
|
+
);
|
|
815
|
+
facetSearchboxInput.value = 'test';
|
|
816
|
+
await flushPromises();
|
|
817
|
+
|
|
818
|
+
const facetValuesShowMore = element.shadowRoot.querySelector(
|
|
819
|
+
selectors.facetValuesShowMore
|
|
820
|
+
);
|
|
821
|
+
expect(facetValuesShowMore).toBeNull();
|
|
822
|
+
});
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
describe('when canShowLessValues is set to true in the state', () => {
|
|
826
|
+
beforeEach(() => {
|
|
827
|
+
facetState = {
|
|
828
|
+
...facetState,
|
|
829
|
+
facetSearch: {
|
|
830
|
+
values: exampleFacetSearchValues,
|
|
831
|
+
},
|
|
832
|
+
canShowLessValues: true,
|
|
833
|
+
};
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
it('should not display the facet show less button', async () => {
|
|
837
|
+
const element = createTestComponent({
|
|
838
|
+
...defaultOptions,
|
|
839
|
+
withSearch: true,
|
|
840
|
+
});
|
|
841
|
+
await flushPromises();
|
|
842
|
+
const facetSearchboxInput = element.shadowRoot.querySelector(
|
|
843
|
+
selectors.facetSearchboxInput
|
|
844
|
+
);
|
|
845
|
+
facetSearchboxInput.value = 'test';
|
|
846
|
+
await flushPromises();
|
|
847
|
+
|
|
848
|
+
const facetValuesShowLess = element.shadowRoot.querySelector(
|
|
849
|
+
selectors.facetValuesShowLess
|
|
850
|
+
);
|
|
851
|
+
expect(facetValuesShowLess).toBeNull();
|
|
852
|
+
});
|
|
853
|
+
});
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
describe('when facet search values are not available', () => {
|
|
857
|
+
beforeEach(() => {
|
|
858
|
+
facetState = {
|
|
859
|
+
...facetState,
|
|
860
|
+
facetSearch: {
|
|
861
|
+
values: [],
|
|
862
|
+
},
|
|
863
|
+
};
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
it('should not display any facet search values', async () => {
|
|
867
|
+
const element = createTestComponent({
|
|
868
|
+
...defaultOptions,
|
|
869
|
+
withSearch: true,
|
|
870
|
+
});
|
|
871
|
+
await flushPromises();
|
|
872
|
+
const facetSearchboxInput = element.shadowRoot.querySelector(
|
|
873
|
+
selectors.facetSearchboxInput
|
|
874
|
+
);
|
|
875
|
+
facetSearchboxInput.value = 'test';
|
|
876
|
+
await flushPromises();
|
|
877
|
+
|
|
878
|
+
const facetSearchValueElements =
|
|
879
|
+
element.shadowRoot.querySelectorAll(selectors.facetSearchValue);
|
|
880
|
+
expect(facetSearchValueElements.length).toBe(0);
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
it('should display the facet search no match label', async () => {
|
|
884
|
+
const element = createTestComponent({
|
|
885
|
+
...defaultOptions,
|
|
886
|
+
withSearch: true,
|
|
887
|
+
});
|
|
888
|
+
await flushPromises();
|
|
889
|
+
const facetSearchboxInput = element.shadowRoot.querySelector(
|
|
890
|
+
selectors.facetSearchboxInput
|
|
891
|
+
);
|
|
892
|
+
facetSearchboxInput.value = 'test';
|
|
893
|
+
await flushPromises();
|
|
894
|
+
|
|
895
|
+
const facetSearchNoMatch = element.shadowRoot.querySelector(
|
|
896
|
+
selectors.facetSearchNoMatch
|
|
897
|
+
);
|
|
898
|
+
expect(facetSearchNoMatch).not.toBeNull();
|
|
899
|
+
});
|
|
900
|
+
});
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
|
|
904
|
+
describe('when canShowLessValues is set to true in the state', () => {
|
|
905
|
+
beforeEach(() => {
|
|
906
|
+
facetState = {
|
|
907
|
+
...facetState,
|
|
908
|
+
canShowLessValues: true,
|
|
909
|
+
};
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
it('should display the facet show less button', async () => {
|
|
913
|
+
const element = createTestComponent({
|
|
914
|
+
...defaultOptions,
|
|
915
|
+
withSearch: true,
|
|
916
|
+
});
|
|
917
|
+
await flushPromises();
|
|
918
|
+
|
|
919
|
+
const facetValuesShowLess = element.shadowRoot.querySelector(
|
|
920
|
+
selectors.facetValuesShowLess
|
|
921
|
+
);
|
|
922
|
+
expect(facetValuesShowLess).not.toBeNull();
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
it('should call the controller function showLessValues when the facet show less button is clicked', async () => {
|
|
926
|
+
const element = createTestComponent({
|
|
927
|
+
...defaultOptions,
|
|
928
|
+
withSearch: true,
|
|
929
|
+
});
|
|
930
|
+
await flushPromises();
|
|
931
|
+
|
|
932
|
+
const facetValuesShowLess = element.shadowRoot.querySelector(
|
|
933
|
+
selectors.facetValuesShowLess
|
|
934
|
+
);
|
|
935
|
+
facetValuesShowLess.click();
|
|
936
|
+
|
|
937
|
+
expect(functionsMocks.showLessValues).toHaveBeenCalledTimes(1);
|
|
938
|
+
});
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
describe('when canShowMoreValues is set to true in the state', () => {
|
|
942
|
+
beforeEach(() => {
|
|
943
|
+
facetState = {
|
|
944
|
+
...facetState,
|
|
945
|
+
canShowMoreValues: true,
|
|
946
|
+
};
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
it('should display the facet show more button', async () => {
|
|
950
|
+
const element = createTestComponent({
|
|
951
|
+
...defaultOptions,
|
|
952
|
+
withSearch: true,
|
|
953
|
+
});
|
|
954
|
+
await flushPromises();
|
|
955
|
+
|
|
956
|
+
const facetValuesShowMore = element.shadowRoot.querySelector(
|
|
957
|
+
selectors.facetValuesShowMore
|
|
958
|
+
);
|
|
959
|
+
expect(facetValuesShowMore).not.toBeNull();
|
|
960
|
+
});
|
|
961
|
+
|
|
962
|
+
it('should call the controller function showMoreValues when the facet show more button is clicked', async () => {
|
|
963
|
+
const element = createTestComponent({
|
|
964
|
+
...defaultOptions,
|
|
965
|
+
withSearch: true,
|
|
966
|
+
});
|
|
967
|
+
await flushPromises();
|
|
968
|
+
|
|
969
|
+
const facetValuesShowMore = element.shadowRoot.querySelector(
|
|
970
|
+
selectors.facetValuesShowMore
|
|
971
|
+
);
|
|
972
|
+
facetValuesShowMore.click();
|
|
973
|
+
|
|
974
|
+
expect(functionsMocks.showMoreValues).toHaveBeenCalledTimes(1);
|
|
975
|
+
});
|
|
976
|
+
});
|
|
977
|
+
|
|
978
|
+
describe('when the facet is not collapsed', () => {
|
|
979
|
+
it('should display the facet body', async () => {
|
|
980
|
+
const element = createTestComponent();
|
|
981
|
+
await flushPromises();
|
|
982
|
+
|
|
983
|
+
const facetBody = element.shadowRoot.querySelector(
|
|
984
|
+
selectors.facetBody
|
|
985
|
+
);
|
|
986
|
+
expect(facetBody).not.toBeNull();
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
it('should correctly display the facet collapse toggle', async () => {
|
|
990
|
+
const expectedIcon = 'utility:dash';
|
|
991
|
+
const expectedCSSClass = 'facet__collapse';
|
|
992
|
+
const element = createTestComponent();
|
|
993
|
+
await flushPromises();
|
|
994
|
+
|
|
995
|
+
const facetCollapseToggle = element.shadowRoot.querySelector(
|
|
996
|
+
selectors.facetCollapseToggle
|
|
997
|
+
);
|
|
998
|
+
expect(facetCollapseToggle).not.toBeNull();
|
|
999
|
+
expect(facetCollapseToggle.iconName).toBe(expectedIcon);
|
|
1000
|
+
expect(facetCollapseToggle.classList.contains(expectedCSSClass)).toBe(
|
|
1001
|
+
true
|
|
1002
|
+
);
|
|
1003
|
+
});
|
|
1004
|
+
});
|
|
1005
|
+
|
|
1006
|
+
describe('when the facet is collapsed', () => {
|
|
1007
|
+
it('should not display the facet body', async () => {
|
|
1008
|
+
const element = createTestComponent({
|
|
1009
|
+
...defaultOptions,
|
|
1010
|
+
isCollapsed: true,
|
|
1011
|
+
});
|
|
1012
|
+
await flushPromises();
|
|
1013
|
+
|
|
1014
|
+
const facetBody = element.shadowRoot.querySelector(
|
|
1015
|
+
selectors.facetBody
|
|
1016
|
+
);
|
|
1017
|
+
expect(facetBody).toBeNull();
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
it('should correctly display the facet collapse toggle', async () => {
|
|
1021
|
+
const expectedIcon = 'utility:add';
|
|
1022
|
+
const expectedCSSClass = 'facet__expand';
|
|
1023
|
+
|
|
1024
|
+
const element = createTestComponent({
|
|
1025
|
+
...defaultOptions,
|
|
1026
|
+
isCollapsed: true,
|
|
1027
|
+
});
|
|
1028
|
+
await flushPromises();
|
|
1029
|
+
|
|
1030
|
+
const facetCollapseToggle = element.shadowRoot.querySelector(
|
|
1031
|
+
selectors.facetCollapseToggle
|
|
1032
|
+
);
|
|
1033
|
+
expect(facetCollapseToggle).not.toBeNull();
|
|
1034
|
+
expect(facetCollapseToggle.iconName).toBe(expectedIcon);
|
|
1035
|
+
expect(facetCollapseToggle.classList.contains(expectedCSSClass)).toBe(
|
|
1036
|
+
true
|
|
1037
|
+
);
|
|
1038
|
+
});
|
|
1039
|
+
});
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1042
|
+
describe('when the facet has no values', () => {
|
|
1043
|
+
beforeEach(() => {
|
|
1044
|
+
facetState = {
|
|
1045
|
+
...initialFacetState,
|
|
1046
|
+
valuesAsTrees: [],
|
|
1047
|
+
};
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
it('should not display the facet card', async () => {
|
|
1051
|
+
const element = createTestComponent();
|
|
1052
|
+
await flushPromises();
|
|
1053
|
+
|
|
1054
|
+
const cardContainer = element.shadowRoot.querySelector(
|
|
1055
|
+
selectors.cardContainer
|
|
1056
|
+
);
|
|
1057
|
+
expect(cardContainer).toBeNull();
|
|
1058
|
+
});
|
|
1059
|
+
|
|
1060
|
+
it('should dispatch quantic__renderfacet event', async () => {
|
|
1061
|
+
document.addEventListener(
|
|
1062
|
+
'quantic__renderfacet',
|
|
1063
|
+
// @ts-ignore
|
|
1064
|
+
(event) => functionsMocks.eventHandler(event.detail),
|
|
1065
|
+
{once: true}
|
|
1066
|
+
);
|
|
1067
|
+
createTestComponent();
|
|
1068
|
+
|
|
1069
|
+
await flushPromises();
|
|
1070
|
+
|
|
1071
|
+
expect(functionsMocks.eventHandler).toHaveBeenCalledTimes(1);
|
|
1072
|
+
expect(functionsMocks.eventHandler).toHaveBeenCalledWith({
|
|
1073
|
+
id: exampleFacetId,
|
|
1074
|
+
shouldRenderFacet: false,
|
|
1075
|
+
});
|
|
1076
|
+
});
|
|
1077
|
+
});
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
describe('validation of the dependsOn property', () => {
|
|
1081
|
+
let consoleError;
|
|
1082
|
+
beforeAll(() => {
|
|
1083
|
+
consoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
1084
|
+
});
|
|
1085
|
+
|
|
1086
|
+
describe('when dependsOn.parentFacetId is not provided', () => {
|
|
1087
|
+
it('should display the error component', async () => {
|
|
1088
|
+
const invalidFacetDependency = {
|
|
1089
|
+
expectedValue: 'txt',
|
|
1090
|
+
};
|
|
1091
|
+
const element = createTestComponent({
|
|
1092
|
+
...defaultOptions,
|
|
1093
|
+
dependsOn: invalidFacetDependency,
|
|
1094
|
+
});
|
|
1095
|
+
await flushPromises();
|
|
1096
|
+
|
|
1097
|
+
const componentError = element.shadowRoot.querySelector(
|
|
1098
|
+
selectors.componentError
|
|
1099
|
+
);
|
|
1100
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
1101
|
+
selectors.facetContent
|
|
1102
|
+
);
|
|
1103
|
+
|
|
1104
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
1105
|
+
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
1106
|
+
expect(componentError).not.toBeNull();
|
|
1107
|
+
expect(facetContent).toBeNull();
|
|
1108
|
+
});
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
describe('when dependsOn.parentFacetId is not a string', () => {
|
|
1112
|
+
it('should display the error component', async () => {
|
|
1113
|
+
const invalidFacetDependency = {
|
|
1114
|
+
parentFacetId: 1,
|
|
1115
|
+
expectedValue: 'txt',
|
|
1116
|
+
};
|
|
1117
|
+
const element = createTestComponent({
|
|
1118
|
+
...defaultOptions,
|
|
1119
|
+
dependsOn: invalidFacetDependency,
|
|
1120
|
+
});
|
|
1121
|
+
await flushPromises();
|
|
1122
|
+
|
|
1123
|
+
const componentError = element.shadowRoot.querySelector(
|
|
1124
|
+
selectors.componentError
|
|
1125
|
+
);
|
|
1126
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
1127
|
+
selectors.facetContent
|
|
1128
|
+
);
|
|
1129
|
+
|
|
1130
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
1131
|
+
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
1132
|
+
expect(componentError).not.toBeNull();
|
|
1133
|
+
expect(facetContent).toBeNull();
|
|
1134
|
+
});
|
|
1135
|
+
});
|
|
1136
|
+
|
|
1137
|
+
describe('when dependsOn.expectedValue is not a string', () => {
|
|
1138
|
+
it('should display the error component', async () => {
|
|
1139
|
+
const invalidFacetDependency = {
|
|
1140
|
+
parentFacetId: 'filetype',
|
|
1141
|
+
expectedValue: 2,
|
|
1142
|
+
};
|
|
1143
|
+
const element = createTestComponent({
|
|
1144
|
+
...defaultOptions,
|
|
1145
|
+
dependsOn: invalidFacetDependency,
|
|
1146
|
+
});
|
|
1147
|
+
await flushPromises();
|
|
1148
|
+
|
|
1149
|
+
const componentError = element.shadowRoot.querySelector(
|
|
1150
|
+
selectors.componentError
|
|
1151
|
+
);
|
|
1152
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
1153
|
+
selectors.facetContent
|
|
1154
|
+
);
|
|
1155
|
+
|
|
1156
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
1157
|
+
expect(consoleError).toHaveBeenCalledWith(expectedValueError);
|
|
1158
|
+
expect(componentError).not.toBeNull();
|
|
1159
|
+
expect(facetContent).toBeNull();
|
|
1160
|
+
});
|
|
1161
|
+
});
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
describe('when the component is disconnected', () => {
|
|
1165
|
+
it('should make the condition manager stop watching the facet', async () => {
|
|
1166
|
+
const exampleFacetDependency = {
|
|
1167
|
+
parentFacetId: 'filetype',
|
|
1168
|
+
expectedValue: 'txt',
|
|
1169
|
+
};
|
|
1170
|
+
const element = createTestComponent({
|
|
1171
|
+
...defaultOptions,
|
|
1172
|
+
dependsOn: exampleFacetDependency,
|
|
1173
|
+
});
|
|
1174
|
+
await flushPromises();
|
|
1175
|
+
expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledTimes(
|
|
1176
|
+
1
|
|
1177
|
+
);
|
|
1178
|
+
|
|
1179
|
+
document.body.removeChild(element);
|
|
1180
|
+
expect(functionsMocks.stopWatching).toHaveBeenCalledTimes(1);
|
|
1181
|
+
});
|
|
1182
|
+
});
|
|
1183
|
+
});
|