@coveo/quantic 3.33.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/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/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/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +131 -0
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +2 -2
- 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/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/attached-results/attached-results-slice.d.ts +1 -1
- 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-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/ssr/commerce/factories/build-factory.d.ts +6 -1
- 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-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/search/engine/search-engine.ssr.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 +2 -2
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +2 -2
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +2 -2
- package/package.json +46 -44
|
@@ -0,0 +1,1105 @@
|
|
|
1
|
+
/* eslint-disable jest/no-conditional-expect */
|
|
2
|
+
/* eslint-disable no-import-assign */
|
|
3
|
+
import QuanticFacet from 'c/quanticFacet';
|
|
4
|
+
import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
|
|
5
|
+
import {generateFacetDependencyConditions} from 'c/quanticUtils';
|
|
6
|
+
import {cleanup, buildCreateTestComponent, flushPromises} from 'c/testUtils';
|
|
7
|
+
|
|
8
|
+
jest.mock('c/quanticUtils', () => ({
|
|
9
|
+
generateFacetDependencyConditions: jest.fn(),
|
|
10
|
+
regexEncode: jest.fn(),
|
|
11
|
+
Store: {
|
|
12
|
+
facetTypes: {
|
|
13
|
+
FACETS: 'facets',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
I18nUtils: {
|
|
17
|
+
format: jest.fn(),
|
|
18
|
+
getLabelNameWithCount: jest.fn(),
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
jest.mock('c/quanticHeadlessLoader');
|
|
22
|
+
|
|
23
|
+
let isInitialized = false;
|
|
24
|
+
|
|
25
|
+
const exampleFacetId = 'example facet id';
|
|
26
|
+
const exampleField = 'exampleField';
|
|
27
|
+
const exampleFacetValues = [
|
|
28
|
+
{value: 'example facet value', numberOfResults: 10},
|
|
29
|
+
{value: 'another facet value', numberOfResults: 10},
|
|
30
|
+
];
|
|
31
|
+
const exampleFacetSearchValues = [
|
|
32
|
+
{
|
|
33
|
+
displayValue: 'example facet search value',
|
|
34
|
+
rawValue: 'exampleFacetSearchValue',
|
|
35
|
+
count: 10,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
const exampleEngine = {
|
|
39
|
+
id: 'dummy engine',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const initialFacetState = {
|
|
43
|
+
facetId: exampleFacetId,
|
|
44
|
+
values: [],
|
|
45
|
+
enabled: true,
|
|
46
|
+
};
|
|
47
|
+
let facetState = initialFacetState;
|
|
48
|
+
|
|
49
|
+
const initialSearchStatusState = {
|
|
50
|
+
hasError: false,
|
|
51
|
+
};
|
|
52
|
+
let searchStatusState = initialSearchStatusState;
|
|
53
|
+
|
|
54
|
+
const selectors = {
|
|
55
|
+
facetContent: '[data-test="facet-content"]',
|
|
56
|
+
componentError: 'c-quantic-component-error',
|
|
57
|
+
initializationError: 'c-quantic-component-error',
|
|
58
|
+
placeholder: 'c-quantic-placeholder',
|
|
59
|
+
cardContainer: 'c-quantic-card-container',
|
|
60
|
+
clearSelectionButton: '[data-testid="clear-selection-button"]',
|
|
61
|
+
facetBody: '[data-testid="facet__body"]',
|
|
62
|
+
searchboxInput: '[data-testid="facet__searchbox-input"]',
|
|
63
|
+
facetValue: 'c-quantic-facet-value',
|
|
64
|
+
facetValuesShowMore: '[data-testid="facet-values__show-more"]',
|
|
65
|
+
facetValuesShowLess: '[data-testid="facet-values__show-less"]',
|
|
66
|
+
facetSearchNoMatchMessage: '[data-testid="facet-search__no-match"]',
|
|
67
|
+
facetSearchMoreMatchMessage: '[data-testid="facet-search__more-match"]',
|
|
68
|
+
facetCollapseToggle: 'lightning-button-icon',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const defaultOptions = {
|
|
72
|
+
engineId: exampleEngine.id,
|
|
73
|
+
field: exampleField,
|
|
74
|
+
facetId: exampleFacetId,
|
|
75
|
+
sortCriteria: 'score',
|
|
76
|
+
numberOfValues: 10,
|
|
77
|
+
injectionDepth: 1000,
|
|
78
|
+
customSort: ['test'],
|
|
79
|
+
label: 'example label',
|
|
80
|
+
};
|
|
81
|
+
const parentFacetIdError = `The ${exampleField} c-quantic-facet requires dependsOn.parentFacetId to be a valid string.`;
|
|
82
|
+
const expectedValueError = `The ${exampleField} c-quantic-facet requires dependsOn.expectedValue to be a valid string.`;
|
|
83
|
+
|
|
84
|
+
const functionsMocks = {
|
|
85
|
+
buildFacet: jest.fn(() => ({
|
|
86
|
+
state: facetState,
|
|
87
|
+
subscribe: functionsMocks.facetStateSubscriber,
|
|
88
|
+
deselectAll: functionsMocks.deselectAll,
|
|
89
|
+
showMoreValues: functionsMocks.showMoreValues,
|
|
90
|
+
showLessValues: functionsMocks.showLessValues,
|
|
91
|
+
toggleSingleSelect: functionsMocks.toggleSingleSelect,
|
|
92
|
+
toggleSelect: functionsMocks.toggleSelect,
|
|
93
|
+
facetSearch: {
|
|
94
|
+
updateText: functionsMocks.updateText,
|
|
95
|
+
singleSelect: functionsMocks.singleSelect,
|
|
96
|
+
select: functionsMocks.select,
|
|
97
|
+
},
|
|
98
|
+
})),
|
|
99
|
+
buildFacetConditionsManager: jest.fn(() => ({
|
|
100
|
+
stopWatching: functionsMocks.stopWatching,
|
|
101
|
+
})),
|
|
102
|
+
buildSearchStatus: jest.fn(() => ({
|
|
103
|
+
state: searchStatusState,
|
|
104
|
+
subscribe: functionsMocks.searchStatusStateSubscriber,
|
|
105
|
+
})),
|
|
106
|
+
stopWatching: jest.fn(),
|
|
107
|
+
facetStateSubscriber: jest.fn((cb) => {
|
|
108
|
+
cb();
|
|
109
|
+
return functionsMocks.facetStateUnsubscriber;
|
|
110
|
+
}),
|
|
111
|
+
searchStatusStateSubscriber: jest.fn((cb) => {
|
|
112
|
+
cb();
|
|
113
|
+
return functionsMocks.searchStatusStateUnsubscriber;
|
|
114
|
+
}),
|
|
115
|
+
facetStateUnsubscriber: jest.fn(),
|
|
116
|
+
searchStatusStateUnsubscriber: jest.fn(),
|
|
117
|
+
deselectAll: jest.fn(),
|
|
118
|
+
showMoreValues: jest.fn(),
|
|
119
|
+
showLessValues: jest.fn(),
|
|
120
|
+
singleSelect: jest.fn(),
|
|
121
|
+
select: jest.fn(),
|
|
122
|
+
toggleSingleSelect: jest.fn(),
|
|
123
|
+
toggleSelect: jest.fn(),
|
|
124
|
+
updateText: jest.fn(),
|
|
125
|
+
registerToStore: jest.fn(),
|
|
126
|
+
eventHandler: jest.fn(),
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
mockHeadlessLoader.registerToStore = functionsMocks.registerToStore;
|
|
131
|
+
|
|
132
|
+
const createTestComponent = buildCreateTestComponent(
|
|
133
|
+
QuanticFacet,
|
|
134
|
+
'c-quantic-facet',
|
|
135
|
+
defaultOptions
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
function prepareHeadlessState() {
|
|
139
|
+
// @ts-ignore
|
|
140
|
+
mockHeadlessLoader.getHeadlessBundle = () => ({
|
|
141
|
+
buildFacet: functionsMocks.buildFacet,
|
|
142
|
+
buildSearchStatus: functionsMocks.buildSearchStatus,
|
|
143
|
+
buildFacetConditionsManager: functionsMocks.buildFacetConditionsManager,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function mockSuccessfulHeadlessInitialization() {
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
150
|
+
if (element instanceof QuanticFacet && !isInitialized) {
|
|
151
|
+
isInitialized = true;
|
|
152
|
+
initialize(exampleEngine);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function mockErroneousHeadlessInitialization() {
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
mockHeadlessLoader.initializeWithHeadless = (element) => {
|
|
160
|
+
if (element instanceof QuanticFacet) {
|
|
161
|
+
element.setInitializationError();
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
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
|
+
describe('c-quantic-facet', () => {
|
|
182
|
+
beforeEach(() => {
|
|
183
|
+
mockSuccessfulHeadlessInitialization();
|
|
184
|
+
mockBueno();
|
|
185
|
+
prepareHeadlessState();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
afterEach(() => {
|
|
189
|
+
cleanup();
|
|
190
|
+
facetState = initialFacetState;
|
|
191
|
+
searchStatusState = initialSearchStatusState;
|
|
192
|
+
isInitialized = false;
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
describe('component initialization', () => {
|
|
196
|
+
it('should initialize the facet controller', async () => {
|
|
197
|
+
createTestComponent();
|
|
198
|
+
await flushPromises();
|
|
199
|
+
|
|
200
|
+
expect(functionsMocks.buildFacet).toHaveBeenCalledTimes(1);
|
|
201
|
+
expect(functionsMocks.buildFacet).toHaveBeenCalledWith(
|
|
202
|
+
exampleEngine,
|
|
203
|
+
expect.objectContaining({
|
|
204
|
+
options: expect.objectContaining({
|
|
205
|
+
field: exampleField,
|
|
206
|
+
facetId: exampleFacetId,
|
|
207
|
+
sortCriteria: defaultOptions.sortCriteria,
|
|
208
|
+
numberOfValues: defaultOptions.numberOfValues,
|
|
209
|
+
injectionDepth: defaultOptions.injectionDepth,
|
|
210
|
+
customSort: defaultOptions.customSort,
|
|
211
|
+
}),
|
|
212
|
+
})
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it('should register the facet to the quantic store', async () => {
|
|
217
|
+
const expectedFacetType = 'facets';
|
|
218
|
+
const element = createTestComponent();
|
|
219
|
+
await flushPromises();
|
|
220
|
+
|
|
221
|
+
expect(functionsMocks.registerToStore).toHaveBeenCalledTimes(1);
|
|
222
|
+
expect(functionsMocks.registerToStore).toHaveBeenCalledWith(
|
|
223
|
+
exampleEngine.id,
|
|
224
|
+
expectedFacetType,
|
|
225
|
+
expect.objectContaining({
|
|
226
|
+
label: defaultOptions.label,
|
|
227
|
+
facetId: exampleFacetId,
|
|
228
|
+
element: element,
|
|
229
|
+
metadata: {
|
|
230
|
+
customCaptions: [],
|
|
231
|
+
},
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
describe('the facet conditions manager controller', () => {
|
|
237
|
+
it('should build the controller when the dependsOn property is set', async () => {
|
|
238
|
+
const exampleFacetDependency = {
|
|
239
|
+
parentFacetId: 'filetype',
|
|
240
|
+
expectedValue: 'txt',
|
|
241
|
+
};
|
|
242
|
+
createTestComponent({
|
|
243
|
+
...defaultOptions,
|
|
244
|
+
dependsOn: exampleFacetDependency,
|
|
245
|
+
});
|
|
246
|
+
await flushPromises();
|
|
247
|
+
|
|
248
|
+
expect(functionsMocks.buildFacet).toHaveBeenCalledTimes(1);
|
|
249
|
+
expect(
|
|
250
|
+
functionsMocks.buildFacetConditionsManager
|
|
251
|
+
).toHaveBeenCalledTimes(1);
|
|
252
|
+
expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledWith(
|
|
253
|
+
exampleEngine,
|
|
254
|
+
{
|
|
255
|
+
facetId: exampleFacetId,
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
expect(generateFacetDependencyConditions).toHaveBeenCalledTimes(1);
|
|
260
|
+
expect(generateFacetDependencyConditions).toHaveBeenCalledWith({
|
|
261
|
+
[exampleFacetDependency.parentFacetId]:
|
|
262
|
+
exampleFacetDependency.expectedValue,
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('should not build the controller when the dependsOn property is not set', async () => {
|
|
267
|
+
createTestComponent();
|
|
268
|
+
await flushPromises();
|
|
269
|
+
|
|
270
|
+
expect(functionsMocks.buildFacet).toHaveBeenCalledTimes(1);
|
|
271
|
+
expect(
|
|
272
|
+
functionsMocks.buildFacetConditionsManager
|
|
273
|
+
).toHaveBeenCalledTimes(0);
|
|
274
|
+
expect(generateFacetDependencyConditions).toHaveBeenCalledTimes(0);
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
describe('when an initialization error occurs', () => {
|
|
279
|
+
beforeEach(() => {
|
|
280
|
+
mockErroneousHeadlessInitialization();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('should display the initialization error component', async () => {
|
|
284
|
+
const element = createTestComponent();
|
|
285
|
+
await flushPromises();
|
|
286
|
+
|
|
287
|
+
const initializationError = element.shadowRoot.querySelector(
|
|
288
|
+
selectors.initializationError
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
expect(initializationError).not.toBeNull();
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
describe('the facet enablement', () => {
|
|
297
|
+
describe('when the facet is enabled', () => {
|
|
298
|
+
beforeEach(() => {
|
|
299
|
+
facetState = {...initialFacetState, enabled: true};
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it('should display the facet content', async () => {
|
|
303
|
+
const element = createTestComponent();
|
|
304
|
+
await flushPromises();
|
|
305
|
+
|
|
306
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
307
|
+
selectors.facetContent
|
|
308
|
+
);
|
|
309
|
+
expect(facetContent).not.toBeNull();
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
describe('when the facet is not enabled', () => {
|
|
314
|
+
beforeEach(() => {
|
|
315
|
+
facetState = {...initialFacetState, enabled: false};
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('should not display the facet content', async () => {
|
|
319
|
+
const element = createTestComponent();
|
|
320
|
+
await flushPromises();
|
|
321
|
+
|
|
322
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
323
|
+
selectors.facetContent
|
|
324
|
+
);
|
|
325
|
+
expect(facetContent).toBeNull();
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
describe('when the component is loading', () => {
|
|
331
|
+
beforeEach(() => {
|
|
332
|
+
searchStatusState = {
|
|
333
|
+
...initialFacetState,
|
|
334
|
+
isLoading: true,
|
|
335
|
+
hasError: false,
|
|
336
|
+
firstSearchExecuted: false,
|
|
337
|
+
};
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it('should display the placeholder component', async () => {
|
|
341
|
+
const element = createTestComponent();
|
|
342
|
+
await flushPromises();
|
|
343
|
+
|
|
344
|
+
const placeholder = element.shadowRoot.querySelector(
|
|
345
|
+
selectors.placeholder
|
|
346
|
+
);
|
|
347
|
+
expect(placeholder).not.toBeNull();
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
describe('when the interface has an error', () => {
|
|
351
|
+
beforeEach(() => {
|
|
352
|
+
searchStatusState = {
|
|
353
|
+
...initialFacetState,
|
|
354
|
+
isLoading: true,
|
|
355
|
+
hasError: true,
|
|
356
|
+
firstSearchExecuted: false,
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('should not display the placeholder component', async () => {
|
|
361
|
+
const element = createTestComponent();
|
|
362
|
+
await flushPromises();
|
|
363
|
+
|
|
364
|
+
const placeholder = element.shadowRoot.querySelector(
|
|
365
|
+
selectors.placeholder
|
|
366
|
+
);
|
|
367
|
+
expect(placeholder).toBeNull();
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
describe('when the component is ready', () => {
|
|
373
|
+
describe('when the facet has values', () => {
|
|
374
|
+
beforeEach(() => {
|
|
375
|
+
facetState = {
|
|
376
|
+
...initialFacetState,
|
|
377
|
+
values: exampleFacetValues,
|
|
378
|
+
};
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it('should display the facet card when the facet values have results', async () => {
|
|
382
|
+
const element = createTestComponent();
|
|
383
|
+
await flushPromises();
|
|
384
|
+
|
|
385
|
+
const cardContainer = element.shadowRoot.querySelector(
|
|
386
|
+
selectors.cardContainer
|
|
387
|
+
);
|
|
388
|
+
expect(cardContainer).not.toBeNull();
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it('should not display the facet card when the facet values have no results', async () => {
|
|
392
|
+
facetState = {
|
|
393
|
+
...initialFacetState,
|
|
394
|
+
values: [{value: 'example value', numberOfResults: 0}],
|
|
395
|
+
};
|
|
396
|
+
const element = createTestComponent();
|
|
397
|
+
await flushPromises();
|
|
398
|
+
|
|
399
|
+
const cardContainer = element.shadowRoot.querySelector(
|
|
400
|
+
selectors.cardContainer
|
|
401
|
+
);
|
|
402
|
+
expect(cardContainer).toBeNull();
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
describe('when the facet has active values', () => {
|
|
406
|
+
beforeEach(() => {
|
|
407
|
+
facetState = {
|
|
408
|
+
...initialFacetState,
|
|
409
|
+
values: [{value: 'example value', numberOfResults: 10}],
|
|
410
|
+
hasActiveValues: true,
|
|
411
|
+
};
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it('should display the clear selection button', async () => {
|
|
415
|
+
const element = createTestComponent();
|
|
416
|
+
await flushPromises();
|
|
417
|
+
|
|
418
|
+
const clearSelectionButton = element.shadowRoot.querySelector(
|
|
419
|
+
selectors.clearSelectionButton
|
|
420
|
+
);
|
|
421
|
+
expect(clearSelectionButton).not.toBeNull();
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
it('should call the deselectAll and the updateText functions of the facet controller when clicking on the clear selection button', async () => {
|
|
425
|
+
const element = createTestComponent();
|
|
426
|
+
await flushPromises();
|
|
427
|
+
|
|
428
|
+
const clearSelectionButton = element.shadowRoot.querySelector(
|
|
429
|
+
selectors.clearSelectionButton
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
await clearSelectionButton.click();
|
|
433
|
+
|
|
434
|
+
expect(functionsMocks.deselectAll).toHaveBeenCalledTimes(1);
|
|
435
|
+
expect(functionsMocks.updateText).toHaveBeenCalledTimes(1);
|
|
436
|
+
expect(functionsMocks.updateText).toHaveBeenCalledWith('');
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
describe('when the facet is not collapsed', () => {
|
|
441
|
+
it('should display the facet body', async () => {
|
|
442
|
+
const element = createTestComponent();
|
|
443
|
+
await flushPromises();
|
|
444
|
+
|
|
445
|
+
const facetBody = element.shadowRoot.querySelector(
|
|
446
|
+
selectors.facetBody
|
|
447
|
+
);
|
|
448
|
+
expect(facetBody).not.toBeNull();
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
it('should correctly display the facet collapse toggle', async () => {
|
|
452
|
+
const expectedIcon = 'utility:dash';
|
|
453
|
+
const expectedCSSClass = 'facet__collapse';
|
|
454
|
+
const element = createTestComponent();
|
|
455
|
+
await flushPromises();
|
|
456
|
+
|
|
457
|
+
const facetCollapseToggle = element.shadowRoot.querySelector(
|
|
458
|
+
selectors.facetCollapseToggle
|
|
459
|
+
);
|
|
460
|
+
expect(facetCollapseToggle).not.toBeNull();
|
|
461
|
+
expect(facetCollapseToggle.iconName).toBe(expectedIcon);
|
|
462
|
+
expect(facetCollapseToggle.classList.contains(expectedCSSClass)).toBe(
|
|
463
|
+
true
|
|
464
|
+
);
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
describe('when the facet is collapsed', () => {
|
|
469
|
+
it('should not display the facet body', async () => {
|
|
470
|
+
const element = createTestComponent({
|
|
471
|
+
...defaultOptions,
|
|
472
|
+
isCollapsed: true,
|
|
473
|
+
});
|
|
474
|
+
await flushPromises();
|
|
475
|
+
|
|
476
|
+
const facetBody = element.shadowRoot.querySelector(
|
|
477
|
+
selectors.facetBody
|
|
478
|
+
);
|
|
479
|
+
expect(facetBody).toBeNull();
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
it('should correctly display the facet collapse toggle', async () => {
|
|
483
|
+
const expectedIcon = 'utility:add';
|
|
484
|
+
const expectedCSSClass = 'facet__expand';
|
|
485
|
+
|
|
486
|
+
const element = createTestComponent({
|
|
487
|
+
...defaultOptions,
|
|
488
|
+
isCollapsed: true,
|
|
489
|
+
});
|
|
490
|
+
await flushPromises();
|
|
491
|
+
|
|
492
|
+
const facetCollapseToggle = element.shadowRoot.querySelector(
|
|
493
|
+
selectors.facetCollapseToggle
|
|
494
|
+
);
|
|
495
|
+
expect(facetCollapseToggle).not.toBeNull();
|
|
496
|
+
expect(facetCollapseToggle.iconName).toBe(expectedIcon);
|
|
497
|
+
expect(facetCollapseToggle.classList.contains(expectedCSSClass)).toBe(
|
|
498
|
+
true
|
|
499
|
+
);
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
describe('when a facet value is selected', () => {
|
|
503
|
+
beforeEach(() => {
|
|
504
|
+
facetState = {
|
|
505
|
+
...initialFacetState,
|
|
506
|
+
values: [{value: 'example value', numberOfResults: 10}],
|
|
507
|
+
hasActiveValues: true,
|
|
508
|
+
};
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it('should display the clear selection button', async () => {
|
|
512
|
+
const element = createTestComponent({
|
|
513
|
+
...defaultOptions,
|
|
514
|
+
isCollapsed: true,
|
|
515
|
+
});
|
|
516
|
+
await flushPromises();
|
|
517
|
+
|
|
518
|
+
const clearSelectionButton = element.shadowRoot.querySelector(
|
|
519
|
+
selectors.clearSelectionButton
|
|
520
|
+
);
|
|
521
|
+
expect(clearSelectionButton).not.toBeNull();
|
|
522
|
+
});
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
describe('when the property noSearch is set to false', () => {
|
|
527
|
+
describe('when there are no more facet values to show', () => {
|
|
528
|
+
beforeEach(() => {
|
|
529
|
+
facetState = {
|
|
530
|
+
...initialFacetState,
|
|
531
|
+
values: exampleFacetValues,
|
|
532
|
+
canShowMoreValues: false,
|
|
533
|
+
};
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
it('should not display the facet search box input', async () => {
|
|
537
|
+
const element = createTestComponent();
|
|
538
|
+
await flushPromises();
|
|
539
|
+
|
|
540
|
+
const searchboxInput = element.shadowRoot.querySelector(
|
|
541
|
+
selectors.searchboxInput
|
|
542
|
+
);
|
|
543
|
+
expect(searchboxInput).toBeNull();
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
it('should display the facet values as standard facet values', async () => {
|
|
547
|
+
const expectedFacetValues = exampleFacetValues.map(
|
|
548
|
+
(facetValue) => ({
|
|
549
|
+
...facetValue,
|
|
550
|
+
checked: false,
|
|
551
|
+
highlightedResult: facetValue.value,
|
|
552
|
+
})
|
|
553
|
+
);
|
|
554
|
+
const element = createTestComponent({
|
|
555
|
+
...defaultOptions,
|
|
556
|
+
noSearch: true,
|
|
557
|
+
});
|
|
558
|
+
await flushPromises();
|
|
559
|
+
|
|
560
|
+
const facetValueElements = element.shadowRoot.querySelectorAll(
|
|
561
|
+
selectors.facetValue
|
|
562
|
+
);
|
|
563
|
+
expect(facetValueElements.length).toBe(expectedFacetValues.length);
|
|
564
|
+
expectedFacetValues.forEach((facetValue, index) => {
|
|
565
|
+
expect(facetValueElements[index].item).toEqual(facetValue);
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
describe('when there are more facet values to show', () => {
|
|
571
|
+
beforeEach(() => {
|
|
572
|
+
facetState = {
|
|
573
|
+
...initialFacetState,
|
|
574
|
+
values: exampleFacetValues,
|
|
575
|
+
canShowMoreValues: true,
|
|
576
|
+
facetSearch: {
|
|
577
|
+
values: exampleFacetSearchValues,
|
|
578
|
+
},
|
|
579
|
+
};
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
it('should display the facet search box input', async () => {
|
|
583
|
+
const element = createTestComponent();
|
|
584
|
+
await flushPromises();
|
|
585
|
+
|
|
586
|
+
const searchboxInput = element.shadowRoot.querySelector(
|
|
587
|
+
selectors.searchboxInput
|
|
588
|
+
);
|
|
589
|
+
expect(searchboxInput).not.toBeNull();
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
describe('when the facet search input is empty', () => {
|
|
593
|
+
it('should display the facet values as standard facet values', async () => {
|
|
594
|
+
const expectedFacetValues = exampleFacetValues.map(
|
|
595
|
+
(facetValue) => ({
|
|
596
|
+
...facetValue,
|
|
597
|
+
checked: false,
|
|
598
|
+
highlightedResult: facetValue.value,
|
|
599
|
+
})
|
|
600
|
+
);
|
|
601
|
+
const element = createTestComponent();
|
|
602
|
+
await flushPromises();
|
|
603
|
+
|
|
604
|
+
const facetValueElements = element.shadowRoot.querySelectorAll(
|
|
605
|
+
selectors.facetValue
|
|
606
|
+
);
|
|
607
|
+
expect(facetValueElements.length).toBe(
|
|
608
|
+
expectedFacetValues.length
|
|
609
|
+
);
|
|
610
|
+
expectedFacetValues.forEach((facetValue, index) => {
|
|
611
|
+
expect(facetValueElements[index].item).toEqual(facetValue);
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
describe('when the facet search input is not empty', () => {
|
|
617
|
+
it('should display the facet values as facet search values', async () => {
|
|
618
|
+
const expectedFacetValues = exampleFacetSearchValues.map(
|
|
619
|
+
(facetValue) => ({
|
|
620
|
+
checked: false,
|
|
621
|
+
highlightedResult: facetValue.displayValue,
|
|
622
|
+
value: facetValue.rawValue,
|
|
623
|
+
numberOfResults: facetValue.count,
|
|
624
|
+
state: 'idle',
|
|
625
|
+
})
|
|
626
|
+
);
|
|
627
|
+
const element = createTestComponent();
|
|
628
|
+
await flushPromises();
|
|
629
|
+
|
|
630
|
+
const searchboxInput = element.shadowRoot.querySelector(
|
|
631
|
+
selectors.searchboxInput
|
|
632
|
+
);
|
|
633
|
+
searchboxInput.value = 'foo';
|
|
634
|
+
await flushPromises();
|
|
635
|
+
|
|
636
|
+
const facetValueElements = element.shadowRoot.querySelectorAll(
|
|
637
|
+
selectors.facetValue
|
|
638
|
+
);
|
|
639
|
+
expect(facetValueElements.length).toBe(
|
|
640
|
+
exampleFacetSearchValues.length
|
|
641
|
+
);
|
|
642
|
+
expectedFacetValues.forEach((facetValue, index) => {
|
|
643
|
+
expect(facetValueElements[index].item).toEqual(facetValue);
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
['checkbox', 'link'].forEach((propertyValue) => {
|
|
648
|
+
describe(`when the property displayValuesAs is set to "${propertyValue}"`, () => {
|
|
649
|
+
it(`should display the facet search value as ${propertyValue}`, async () => {
|
|
650
|
+
const element = createTestComponent({
|
|
651
|
+
...defaultOptions,
|
|
652
|
+
displayValuesAs: propertyValue,
|
|
653
|
+
});
|
|
654
|
+
await flushPromises();
|
|
655
|
+
|
|
656
|
+
const searchboxInput = element.shadowRoot.querySelector(
|
|
657
|
+
selectors.searchboxInput
|
|
658
|
+
);
|
|
659
|
+
searchboxInput.value = 'foo';
|
|
660
|
+
await flushPromises();
|
|
661
|
+
|
|
662
|
+
const facetValueElement = element.shadowRoot.querySelector(
|
|
663
|
+
selectors.facetValue
|
|
664
|
+
);
|
|
665
|
+
expect(facetValueElement.displayAsLink).toEqual(
|
|
666
|
+
propertyValue === 'link'
|
|
667
|
+
);
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
const expectedFunctionToBeCalled =
|
|
671
|
+
propertyValue === 'link' ? 'singleSelect' : 'select';
|
|
672
|
+
|
|
673
|
+
it(`should call the controller function ${expectedFunctionToBeCalled} when clicked`, async () => {
|
|
674
|
+
const element = createTestComponent({
|
|
675
|
+
...defaultOptions,
|
|
676
|
+
displayValuesAs: propertyValue,
|
|
677
|
+
});
|
|
678
|
+
const selectedIndex = 0;
|
|
679
|
+
await flushPromises();
|
|
680
|
+
|
|
681
|
+
const searchboxInput = element.shadowRoot.querySelector(
|
|
682
|
+
selectors.searchboxInput
|
|
683
|
+
);
|
|
684
|
+
searchboxInput.value = 'foo';
|
|
685
|
+
await flushPromises();
|
|
686
|
+
|
|
687
|
+
const facetValueElement = element.shadowRoot.querySelector(
|
|
688
|
+
selectors.facetValue
|
|
689
|
+
);
|
|
690
|
+
const selection = exampleFacetSearchValues[selectedIndex];
|
|
691
|
+
facetValueElement.dispatchEvent(
|
|
692
|
+
new CustomEvent('quantic__selectvalue', {
|
|
693
|
+
bubbles: true,
|
|
694
|
+
detail: {
|
|
695
|
+
value: selection.rawValue,
|
|
696
|
+
},
|
|
697
|
+
})
|
|
698
|
+
);
|
|
699
|
+
await flushPromises();
|
|
700
|
+
|
|
701
|
+
expect(
|
|
702
|
+
functionsMocks[expectedFunctionToBeCalled]
|
|
703
|
+
).toHaveBeenCalledTimes(1);
|
|
704
|
+
expect(
|
|
705
|
+
functionsMocks[expectedFunctionToBeCalled]
|
|
706
|
+
).toHaveBeenCalledWith(
|
|
707
|
+
expect.objectContaining({
|
|
708
|
+
...selection,
|
|
709
|
+
displayValue: selection.rawValue,
|
|
710
|
+
})
|
|
711
|
+
);
|
|
712
|
+
});
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
describe('when facet search does not have results', () => {
|
|
718
|
+
beforeEach(() => {
|
|
719
|
+
facetState = {
|
|
720
|
+
...initialFacetState,
|
|
721
|
+
values: exampleFacetValues,
|
|
722
|
+
canShowMoreValues: true,
|
|
723
|
+
facetSearch: {
|
|
724
|
+
values: [],
|
|
725
|
+
},
|
|
726
|
+
};
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
it('should display the facet search no match message', async () => {
|
|
730
|
+
const element = createTestComponent();
|
|
731
|
+
await flushPromises();
|
|
732
|
+
|
|
733
|
+
const searchboxInput = element.shadowRoot.querySelector(
|
|
734
|
+
selectors.searchboxInput
|
|
735
|
+
);
|
|
736
|
+
searchboxInput.value = 'foo';
|
|
737
|
+
await flushPromises();
|
|
738
|
+
|
|
739
|
+
const facetSearchNoMatchMessage =
|
|
740
|
+
element.shadowRoot.querySelector(
|
|
741
|
+
selectors.facetSearchNoMatchMessage
|
|
742
|
+
);
|
|
743
|
+
expect(facetSearchNoMatchMessage).not.toBeNull();
|
|
744
|
+
});
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
describe('when more facet search values are available', () => {
|
|
748
|
+
beforeEach(() => {
|
|
749
|
+
facetState = {
|
|
750
|
+
...initialFacetState,
|
|
751
|
+
values: exampleFacetValues,
|
|
752
|
+
canShowMoreValues: true,
|
|
753
|
+
facetSearch: {
|
|
754
|
+
moreValuesAvailable: true,
|
|
755
|
+
values: exampleFacetSearchValues,
|
|
756
|
+
},
|
|
757
|
+
};
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
it('should display the facet search more match message', async () => {
|
|
761
|
+
const element = createTestComponent();
|
|
762
|
+
await flushPromises();
|
|
763
|
+
|
|
764
|
+
const searchboxInput = element.shadowRoot.querySelector(
|
|
765
|
+
selectors.searchboxInput
|
|
766
|
+
);
|
|
767
|
+
searchboxInput.value = 'foo';
|
|
768
|
+
await flushPromises();
|
|
769
|
+
|
|
770
|
+
const facetSearchMoreMatchMessage =
|
|
771
|
+
element.shadowRoot.querySelector(
|
|
772
|
+
selectors.facetSearchMoreMatchMessage
|
|
773
|
+
);
|
|
774
|
+
expect(facetSearchMoreMatchMessage).not.toBeNull();
|
|
775
|
+
});
|
|
776
|
+
});
|
|
777
|
+
});
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
describe('when the property noSearch is set to true', () => {
|
|
781
|
+
it('should not display the facet search box input', async () => {
|
|
782
|
+
const element = createTestComponent({
|
|
783
|
+
...defaultOptions,
|
|
784
|
+
noSearch: true,
|
|
785
|
+
});
|
|
786
|
+
await flushPromises();
|
|
787
|
+
|
|
788
|
+
const searchboxInput = element.shadowRoot.querySelector(
|
|
789
|
+
selectors.searchboxInput
|
|
790
|
+
);
|
|
791
|
+
expect(searchboxInput).toBeNull();
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
describe('facet values', () => {
|
|
795
|
+
it('should display the facet values', async () => {
|
|
796
|
+
const expectedFacetValues = exampleFacetValues.map(
|
|
797
|
+
(facetValue) => ({
|
|
798
|
+
...facetValue,
|
|
799
|
+
checked: false,
|
|
800
|
+
highlightedResult: facetValue.value,
|
|
801
|
+
})
|
|
802
|
+
);
|
|
803
|
+
const element = createTestComponent({
|
|
804
|
+
...defaultOptions,
|
|
805
|
+
noSearch: true,
|
|
806
|
+
});
|
|
807
|
+
await flushPromises();
|
|
808
|
+
|
|
809
|
+
const facetValueElements = element.shadowRoot.querySelectorAll(
|
|
810
|
+
selectors.facetValue
|
|
811
|
+
);
|
|
812
|
+
expect(facetValueElements.length).toBe(expectedFacetValues.length);
|
|
813
|
+
expectedFacetValues.forEach((facetValue, index) => {
|
|
814
|
+
expect(facetValueElements[index].item).toEqual(facetValue);
|
|
815
|
+
});
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
describe('the show less facet values button', () => {
|
|
819
|
+
[true, false].forEach((canShowLessValues) => {
|
|
820
|
+
it(`should ${canShowLessValues ? '' : 'not'} display show less facet values button when the state indicates that it is ${canShowLessValues ? 'possible' : 'not possible'}`, async () => {
|
|
821
|
+
facetState = {
|
|
822
|
+
...initialFacetState,
|
|
823
|
+
values: exampleFacetValues,
|
|
824
|
+
canShowLessValues: canShowLessValues,
|
|
825
|
+
};
|
|
826
|
+
const element = createTestComponent({
|
|
827
|
+
...defaultOptions,
|
|
828
|
+
noSearch: true,
|
|
829
|
+
});
|
|
830
|
+
await flushPromises();
|
|
831
|
+
|
|
832
|
+
const facetValuesShowLess = element.shadowRoot.querySelector(
|
|
833
|
+
selectors.facetValuesShowLess
|
|
834
|
+
);
|
|
835
|
+
expect(facetValuesShowLess)[
|
|
836
|
+
canShowLessValues ? 'toBeTruthy' : 'toBeNull'
|
|
837
|
+
]();
|
|
838
|
+
});
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
it('should call the controller function showLessValues when clicked', async () => {
|
|
842
|
+
facetState = {
|
|
843
|
+
...initialFacetState,
|
|
844
|
+
values: exampleFacetValues,
|
|
845
|
+
canShowLessValues: true,
|
|
846
|
+
};
|
|
847
|
+
const element = createTestComponent({
|
|
848
|
+
...defaultOptions,
|
|
849
|
+
noSearch: true,
|
|
850
|
+
});
|
|
851
|
+
await flushPromises();
|
|
852
|
+
|
|
853
|
+
const facetValuesShowLess = element.shadowRoot.querySelector(
|
|
854
|
+
selectors.facetValuesShowLess
|
|
855
|
+
);
|
|
856
|
+
facetValuesShowLess.click();
|
|
857
|
+
await flushPromises();
|
|
858
|
+
|
|
859
|
+
expect(functionsMocks.showLessValues).toHaveBeenCalledTimes(1);
|
|
860
|
+
});
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
describe('the show more facet values button', () => {
|
|
864
|
+
[true, false].forEach((canShowMoreValues) => {
|
|
865
|
+
it(`should ${canShowMoreValues ? '' : 'not'} display show more facet values button when the state indicates that it is ${canShowMoreValues ? 'possible' : 'not possible'}`, async () => {
|
|
866
|
+
facetState = {
|
|
867
|
+
...initialFacetState,
|
|
868
|
+
values: exampleFacetValues,
|
|
869
|
+
canShowMoreValues,
|
|
870
|
+
};
|
|
871
|
+
const element = createTestComponent({
|
|
872
|
+
...defaultOptions,
|
|
873
|
+
noSearch: true,
|
|
874
|
+
});
|
|
875
|
+
await flushPromises();
|
|
876
|
+
|
|
877
|
+
const facetValuesShowMore = element.shadowRoot.querySelector(
|
|
878
|
+
selectors.facetValuesShowMore
|
|
879
|
+
);
|
|
880
|
+
expect(facetValuesShowMore)[
|
|
881
|
+
canShowMoreValues ? 'toBeTruthy' : 'toBeNull'
|
|
882
|
+
]();
|
|
883
|
+
});
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
it('should call the controller function showMoreValues when clicked', async () => {
|
|
887
|
+
facetState = {
|
|
888
|
+
...initialFacetState,
|
|
889
|
+
values: exampleFacetValues,
|
|
890
|
+
canShowMoreValues: true,
|
|
891
|
+
};
|
|
892
|
+
const element = createTestComponent({
|
|
893
|
+
...defaultOptions,
|
|
894
|
+
noSearch: true,
|
|
895
|
+
});
|
|
896
|
+
await flushPromises();
|
|
897
|
+
|
|
898
|
+
const facetValuesShowMore = element.shadowRoot.querySelector(
|
|
899
|
+
selectors.facetValuesShowMore
|
|
900
|
+
);
|
|
901
|
+
facetValuesShowMore.click();
|
|
902
|
+
await flushPromises();
|
|
903
|
+
|
|
904
|
+
expect(functionsMocks.showMoreValues).toHaveBeenCalledTimes(1);
|
|
905
|
+
});
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
['checkbox', 'link'].forEach((propertyValue) => {
|
|
909
|
+
describe(`when the property displayValuesAs is set to "${propertyValue}"`, () => {
|
|
910
|
+
it(`should display the facet value as ${propertyValue}`, async () => {
|
|
911
|
+
const element = createTestComponent({
|
|
912
|
+
...defaultOptions,
|
|
913
|
+
noSearch: true,
|
|
914
|
+
displayValuesAs: propertyValue,
|
|
915
|
+
});
|
|
916
|
+
await flushPromises();
|
|
917
|
+
|
|
918
|
+
const facetValueElement = element.shadowRoot.querySelector(
|
|
919
|
+
selectors.facetValue
|
|
920
|
+
);
|
|
921
|
+
expect(facetValueElement.displayAsLink).toEqual(
|
|
922
|
+
propertyValue === 'link'
|
|
923
|
+
);
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
const expectedFunctionToBeCalled =
|
|
927
|
+
propertyValue === 'link'
|
|
928
|
+
? 'toggleSingleSelect'
|
|
929
|
+
: 'toggleSelect';
|
|
930
|
+
|
|
931
|
+
it(`should call the controller function ${expectedFunctionToBeCalled} when clicked`, async () => {
|
|
932
|
+
const element = createTestComponent({
|
|
933
|
+
...defaultOptions,
|
|
934
|
+
noSearch: true,
|
|
935
|
+
displayValuesAs: propertyValue,
|
|
936
|
+
});
|
|
937
|
+
const selectedIndex = 0;
|
|
938
|
+
await flushPromises();
|
|
939
|
+
|
|
940
|
+
const facetValueElement = element.shadowRoot.querySelector(
|
|
941
|
+
selectors.facetValue
|
|
942
|
+
);
|
|
943
|
+
facetValueElement.dispatchEvent(
|
|
944
|
+
new CustomEvent('quantic__selectvalue', {
|
|
945
|
+
bubbles: true,
|
|
946
|
+
detail: {value: exampleFacetValues[selectedIndex].value},
|
|
947
|
+
})
|
|
948
|
+
);
|
|
949
|
+
await flushPromises();
|
|
950
|
+
|
|
951
|
+
expect(
|
|
952
|
+
functionsMocks[expectedFunctionToBeCalled]
|
|
953
|
+
).toHaveBeenCalledTimes(1);
|
|
954
|
+
expect(
|
|
955
|
+
functionsMocks[expectedFunctionToBeCalled]
|
|
956
|
+
).toHaveBeenCalledWith(
|
|
957
|
+
expect.objectContaining(exampleFacetValues[selectedIndex])
|
|
958
|
+
);
|
|
959
|
+
});
|
|
960
|
+
});
|
|
961
|
+
});
|
|
962
|
+
});
|
|
963
|
+
});
|
|
964
|
+
});
|
|
965
|
+
|
|
966
|
+
describe('when the facet has no values', () => {
|
|
967
|
+
beforeEach(() => {
|
|
968
|
+
facetState = {
|
|
969
|
+
...initialFacetState,
|
|
970
|
+
values: [],
|
|
971
|
+
};
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
it('should not display the facet card', async () => {
|
|
975
|
+
const element = createTestComponent();
|
|
976
|
+
await flushPromises();
|
|
977
|
+
|
|
978
|
+
const cardContainer = element.shadowRoot.querySelector(
|
|
979
|
+
selectors.cardContainer
|
|
980
|
+
);
|
|
981
|
+
expect(cardContainer).toBeNull();
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
it('should dispatch quantic__renderfacet event', async () => {
|
|
985
|
+
document.addEventListener(
|
|
986
|
+
'quantic__renderfacet',
|
|
987
|
+
// @ts-ignore
|
|
988
|
+
(event) => functionsMocks.eventHandler(event.detail),
|
|
989
|
+
{once: true}
|
|
990
|
+
);
|
|
991
|
+
createTestComponent();
|
|
992
|
+
|
|
993
|
+
await flushPromises();
|
|
994
|
+
|
|
995
|
+
expect(functionsMocks.eventHandler).toHaveBeenCalledTimes(1);
|
|
996
|
+
expect(functionsMocks.eventHandler).toHaveBeenCalledWith({
|
|
997
|
+
id: exampleFacetId,
|
|
998
|
+
shouldRenderFacet: false,
|
|
999
|
+
});
|
|
1000
|
+
});
|
|
1001
|
+
});
|
|
1002
|
+
});
|
|
1003
|
+
|
|
1004
|
+
describe('validation of the dependsOn property', () => {
|
|
1005
|
+
let consoleError;
|
|
1006
|
+
beforeAll(() => {
|
|
1007
|
+
consoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
1008
|
+
});
|
|
1009
|
+
describe('when dependsOn.parentFacetId is not provided', () => {
|
|
1010
|
+
it('should display the error component', async () => {
|
|
1011
|
+
const invalidFacetDependency = {
|
|
1012
|
+
expectedValue: 'txt',
|
|
1013
|
+
};
|
|
1014
|
+
const element = createTestComponent({
|
|
1015
|
+
...defaultOptions,
|
|
1016
|
+
dependsOn: invalidFacetDependency,
|
|
1017
|
+
});
|
|
1018
|
+
await flushPromises();
|
|
1019
|
+
|
|
1020
|
+
const componentError = element.shadowRoot.querySelector(
|
|
1021
|
+
selectors.componentError
|
|
1022
|
+
);
|
|
1023
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
1024
|
+
selectors.facetContent
|
|
1025
|
+
);
|
|
1026
|
+
|
|
1027
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
1028
|
+
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
1029
|
+
expect(componentError).not.toBeNull();
|
|
1030
|
+
expect(facetContent).toBeNull();
|
|
1031
|
+
});
|
|
1032
|
+
});
|
|
1033
|
+
|
|
1034
|
+
describe('when dependsOn.parentFacetId is not a string', () => {
|
|
1035
|
+
it('should display the error component', async () => {
|
|
1036
|
+
const invalidFacetDependency = {
|
|
1037
|
+
parentFacetId: 1,
|
|
1038
|
+
expectedValue: 'txt',
|
|
1039
|
+
};
|
|
1040
|
+
const element = createTestComponent({
|
|
1041
|
+
...defaultOptions,
|
|
1042
|
+
dependsOn: invalidFacetDependency,
|
|
1043
|
+
});
|
|
1044
|
+
await flushPromises();
|
|
1045
|
+
|
|
1046
|
+
const componentError = element.shadowRoot.querySelector(
|
|
1047
|
+
selectors.componentError
|
|
1048
|
+
);
|
|
1049
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
1050
|
+
selectors.facetContent
|
|
1051
|
+
);
|
|
1052
|
+
|
|
1053
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
1054
|
+
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
1055
|
+
expect(componentError).not.toBeNull();
|
|
1056
|
+
expect(facetContent).toBeNull();
|
|
1057
|
+
});
|
|
1058
|
+
});
|
|
1059
|
+
|
|
1060
|
+
describe('when dependsOn.expectedValue is not a string', () => {
|
|
1061
|
+
it('should display the error component', async () => {
|
|
1062
|
+
const invalidFacetDependency = {
|
|
1063
|
+
parentFacetId: 'filetype',
|
|
1064
|
+
expectedValue: 2,
|
|
1065
|
+
};
|
|
1066
|
+
const element = createTestComponent({
|
|
1067
|
+
...defaultOptions,
|
|
1068
|
+
dependsOn: invalidFacetDependency,
|
|
1069
|
+
});
|
|
1070
|
+
await flushPromises();
|
|
1071
|
+
|
|
1072
|
+
const componentError = element.shadowRoot.querySelector(
|
|
1073
|
+
selectors.componentError
|
|
1074
|
+
);
|
|
1075
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
1076
|
+
selectors.facetContent
|
|
1077
|
+
);
|
|
1078
|
+
|
|
1079
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
1080
|
+
expect(consoleError).toHaveBeenCalledWith(expectedValueError);
|
|
1081
|
+
expect(componentError).not.toBeNull();
|
|
1082
|
+
expect(facetContent).toBeNull();
|
|
1083
|
+
});
|
|
1084
|
+
});
|
|
1085
|
+
});
|
|
1086
|
+
describe('when the component is disconnected', () => {
|
|
1087
|
+
it('should make the condition manager stop watching the facet', async () => {
|
|
1088
|
+
const exampleFacetDependency = {
|
|
1089
|
+
parentFacetId: 'filetype',
|
|
1090
|
+
expectedValue: 'txt',
|
|
1091
|
+
};
|
|
1092
|
+
const element = createTestComponent({
|
|
1093
|
+
...defaultOptions,
|
|
1094
|
+
dependsOn: exampleFacetDependency,
|
|
1095
|
+
});
|
|
1096
|
+
await flushPromises();
|
|
1097
|
+
expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledTimes(
|
|
1098
|
+
1
|
|
1099
|
+
);
|
|
1100
|
+
|
|
1101
|
+
document.body.removeChild(element);
|
|
1102
|
+
expect(functionsMocks.stopWatching).toHaveBeenCalledTimes(1);
|
|
1103
|
+
});
|
|
1104
|
+
});
|
|
1105
|
+
});
|