@coveo/quantic 3.44.1 → 3.44.2

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.
Files changed (203) hide show
  1. package/force-app/main/default/classes/OrganizationEndpointsTest.cls +71 -15
  2. package/force-app/main/default/classes/RecommendationsControllerTest.cls +1 -1
  3. package/force-app/main/default/lwc/quanticTabBar/quanticTabBar.js +148 -125
  4. package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +16 -16
  5. package/force-app/main/default/staticresources/coveoheadless/headless.js +17 -17
  6. package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +16 -16
  7. package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +16 -16
  8. package/package.json +33 -31
  9. package/force-app/main/default/lwc/quanticAriaLive/__tests__/quanticAriaLive.test.js +0 -106
  10. package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +0 -752
  11. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/data.ts +0 -130
  12. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/fixture.ts +0 -87
  13. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/pageObject.ts +0 -282
  14. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/quanticBreadcrumbManager.e2e.ts +0 -208
  15. package/force-app/main/default/lwc/quanticCarousel/__tests__/quanticCarousel.test.js +0 -262
  16. package/force-app/main/default/lwc/quanticCaseClassification/__tests__/quanticCaseClassification.test.js +0 -819
  17. package/force-app/main/default/lwc/quanticCaseClassification/e2e/data.ts +0 -23
  18. package/force-app/main/default/lwc/quanticCaseClassification/e2e/fixture.ts +0 -51
  19. package/force-app/main/default/lwc/quanticCaseClassification/e2e/pageObject.ts +0 -152
  20. package/force-app/main/default/lwc/quanticCaseClassification/e2e/quanticCaseClassification.e2e.ts +0 -269
  21. package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +0 -1183
  22. package/force-app/main/default/lwc/quanticCategoryFacet/e2e/data.ts +0 -91
  23. package/force-app/main/default/lwc/quanticCategoryFacet/e2e/fixture.ts +0 -79
  24. package/force-app/main/default/lwc/quanticCategoryFacet/e2e/pageObject.ts +0 -55
  25. package/force-app/main/default/lwc/quanticCategoryFacet/e2e/quanticCategoryFacet.e2e.ts +0 -219
  26. package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +0 -581
  27. package/force-app/main/default/lwc/quanticColoredResultBadge/__tests__/quanticColoredResultBadge.test.js +0 -212
  28. package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +0 -688
  29. package/force-app/main/default/lwc/quanticDateFacet/e2e/data.ts +0 -44
  30. package/force-app/main/default/lwc/quanticDateFacet/e2e/fixture.ts +0 -72
  31. package/force-app/main/default/lwc/quanticDateFacet/e2e/pageObject.ts +0 -27
  32. package/force-app/main/default/lwc/quanticDateFacet/e2e/quanticDateFacet.e2e.ts +0 -167
  33. package/force-app/main/default/lwc/quanticDidYouMean/__tests__/quanticDidYouMean.test.js +0 -348
  34. package/force-app/main/default/lwc/quanticDidYouMean/e2e/data.ts +0 -48
  35. package/force-app/main/default/lwc/quanticDidYouMean/e2e/fixture.ts +0 -84
  36. package/force-app/main/default/lwc/quanticDidYouMean/e2e/pageObject.ts +0 -173
  37. package/force-app/main/default/lwc/quanticDidYouMean/e2e/quanticDidYouMean.e2e.ts +0 -219
  38. package/force-app/main/default/lwc/quanticDocumentSuggestion/__tests__/quanticDocumentSuggestion.test.js +0 -404
  39. package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/fixture.ts +0 -38
  40. package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/pageObject.ts +0 -52
  41. package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/quanticDocumentSuggestion.e2e.ts +0 -102
  42. package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +0 -1105
  43. package/force-app/main/default/lwc/quanticFacet/e2e/data.ts +0 -62
  44. package/force-app/main/default/lwc/quanticFacet/e2e/fixture.ts +0 -78
  45. package/force-app/main/default/lwc/quanticFacet/e2e/pageObject.ts +0 -67
  46. package/force-app/main/default/lwc/quanticFacet/e2e/quanticFacet.e2e.ts +0 -242
  47. package/force-app/main/default/lwc/quanticFacetCaption/__tests__/quanticFacetCaption.test.js +0 -28
  48. package/force-app/main/default/lwc/quanticFacetManager/__tests__/quanticFacetManager.test.js +0 -178
  49. package/force-app/main/default/lwc/quanticFacetManager/e2e/data.ts +0 -59
  50. package/force-app/main/default/lwc/quanticFacetManager/e2e/fixture.ts +0 -75
  51. package/force-app/main/default/lwc/quanticFacetManager/e2e/pageObject.ts +0 -23
  52. package/force-app/main/default/lwc/quanticFacetManager/e2e/quanticFacetManager.e2e.ts +0 -82
  53. package/force-app/main/default/lwc/quanticFeedback/__tests__/quanticFeedback.test.js +0 -403
  54. package/force-app/main/default/lwc/quanticFeedbackModal/__tests__/quanticFeedbackModal.test.js +0 -448
  55. package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +0 -298
  56. package/force-app/main/default/lwc/quanticFoldedResultList/__tests__/quanticFoldedResultList.test.js +0 -323
  57. package/force-app/main/default/lwc/quanticFoldedResultList/e2e/fixture.ts +0 -74
  58. package/force-app/main/default/lwc/quanticFoldedResultList/e2e/pageObject.ts +0 -81
  59. package/force-app/main/default/lwc/quanticFoldedResultList/e2e/quanticFoldedResultList.e2e.ts +0 -69
  60. package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +0 -1575
  61. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/agentData.ts +0 -279
  62. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +0 -56
  63. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture-agent.ts +0 -77
  64. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +0 -194
  65. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +0 -599
  66. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +0 -333
  67. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswerAgent.e2e.ts +0 -298
  68. package/force-app/main/default/lwc/quanticGeneratedAnswerBody/__tests__/quanticGeneratedAnswerBody.test.js +0 -418
  69. package/force-app/main/default/lwc/quanticGeneratedAnswerContent/__tests__/quanticGeneratedAnswerContent.test.js +0 -447
  70. package/force-app/main/default/lwc/quanticGeneratedAnswerCopyToClipboard/__tests__/quanticGeneratedAnswerCopyToClipboard.test.js +0 -129
  71. package/force-app/main/default/lwc/quanticGeneratedAnswerFollowUpInput/__tests__/quanticGeneratedAnswerFollowUpInput.test.js +0 -466
  72. package/force-app/main/default/lwc/quanticGeneratedAnswerStreamOfThought/__tests__/quanticGeneratedAnswerStreamOfThought.test.js +0 -402
  73. package/force-app/main/default/lwc/quanticGeneratedAnswerStreamOfThought/__tests__/stepsUtils.test.js +0 -118
  74. package/force-app/main/default/lwc/quanticGeneratedAnswerThread/__tests__/quanticGeneratedAnswerThread.test.js +0 -285
  75. package/force-app/main/default/lwc/quanticHeading/__tests__/quanticHeading.test.js +0 -71
  76. package/force-app/main/default/lwc/quanticHeadlessLoader/__tests__/quanticHeadlessLoader.test.js +0 -651
  77. package/force-app/main/default/lwc/quanticInsightInterface/__tests__/quanticInsightInterface.test.js +0 -194
  78. package/force-app/main/default/lwc/quanticInsightSummary/__tests__/quanticInsightSummary.test.js +0 -230
  79. package/force-app/main/default/lwc/quanticModal/__tests__/quanticModal.test.js +0 -205
  80. package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +0 -309
  81. package/force-app/main/default/lwc/quanticNotifications/e2e/fixture.ts +0 -62
  82. package/force-app/main/default/lwc/quanticNotifications/e2e/pageObject.ts +0 -55
  83. package/force-app/main/default/lwc/quanticNotifications/e2e/quanticNotifications.e2e.ts +0 -47
  84. package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +0 -953
  85. package/force-app/main/default/lwc/quanticNumericFacet/e2e/data.ts +0 -48
  86. package/force-app/main/default/lwc/quanticNumericFacet/e2e/fixture.ts +0 -75
  87. package/force-app/main/default/lwc/quanticNumericFacet/e2e/pageObject.ts +0 -59
  88. package/force-app/main/default/lwc/quanticNumericFacet/e2e/quanticNumericFacet.e2e.ts +0 -186
  89. package/force-app/main/default/lwc/quanticPager/__tests__/quanticPager.test.js +0 -430
  90. package/force-app/main/default/lwc/quanticPager/e2e/fixture.ts +0 -65
  91. package/force-app/main/default/lwc/quanticPager/e2e/pageObject.ts +0 -69
  92. package/force-app/main/default/lwc/quanticPager/e2e/quanticPager.e2e.ts +0 -106
  93. package/force-app/main/default/lwc/quanticPlaceholder/__tests__/quanticPlaceholder.test.js +0 -47
  94. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/defaultTestCase.json +0 -13
  95. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/youtubeTestCase.json +0 -14
  96. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/quanticQuickviewContent.test.js +0 -82
  97. package/force-app/main/default/lwc/quanticRadioButtonsGroup/__tests__/quanticRadioButtonsGroup.test.js +0 -273
  98. package/force-app/main/default/lwc/quanticRecentQueriesList/__tests__/quanticRecentQueriesList.test.js +0 -448
  99. package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/fixture.ts +0 -43
  100. package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/pageObject.ts +0 -55
  101. package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/quanticRecentQueriesList.e2e.ts +0 -93
  102. package/force-app/main/default/lwc/quanticRecentResultsList/__tests__/quanticRecentResultsList.test.js +0 -516
  103. package/force-app/main/default/lwc/quanticRecentResultsList/e2e/fixture.ts +0 -43
  104. package/force-app/main/default/lwc/quanticRecentResultsList/e2e/pageObject.ts +0 -61
  105. package/force-app/main/default/lwc/quanticRecentResultsList/e2e/quanticRecentResultsList.e2e.ts +0 -48
  106. package/force-app/main/default/lwc/quanticRecommendationList/__tests__/quanticRecommendationList.test.js +0 -491
  107. package/force-app/main/default/lwc/quanticRecommendationList/e2e/fixture.ts +0 -36
  108. package/force-app/main/default/lwc/quanticRecommendationList/e2e/pageObject.ts +0 -52
  109. package/force-app/main/default/lwc/quanticRecommendationList/e2e/quanticRecommendationList.e2e.ts +0 -53
  110. package/force-app/main/default/lwc/quanticRefineModalContent/__tests__/quanticRefineModalContent.test.js +0 -747
  111. package/force-app/main/default/lwc/quanticRefineToggle/__tests__/quanticRefineToggle.test.js +0 -544
  112. package/force-app/main/default/lwc/quanticResultAction/__tests__/quanticResultAction.test.js +0 -262
  113. package/force-app/main/default/lwc/quanticResultActionBar/__tests__/quanticResultActionBar.test.js +0 -141
  114. package/force-app/main/default/lwc/quanticResultChildren/__tests__/quanticResultChildren.test.js +0 -340
  115. package/force-app/main/default/lwc/quanticResultCopyToClipboard/__tests__/quanticResultCopyToClipboard.test.js +0 -300
  116. package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/fixture.ts +0 -49
  117. package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/pageObject.ts +0 -49
  118. package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/quanticResultCopyToClipboard.e2e.ts +0 -40
  119. package/force-app/main/default/lwc/quanticResultDate/__tests__/quanticResultDate.test.js +0 -144
  120. package/force-app/main/default/lwc/quanticResultField/__tests__/quanticResultField.test.js +0 -120
  121. package/force-app/main/default/lwc/quanticResultHighlightedTextField/__tests__/quanticResultHighlightedTextField.test.js +0 -209
  122. package/force-app/main/default/lwc/quanticResultLink/__tests__/quanticResultLink.test.js +0 -302
  123. package/force-app/main/default/lwc/quanticResultList/__tests__/quanticResultList.test.js +0 -342
  124. package/force-app/main/default/lwc/quanticResultList/e2e/fixture.ts +0 -70
  125. package/force-app/main/default/lwc/quanticResultList/e2e/pageObject.ts +0 -81
  126. package/force-app/main/default/lwc/quanticResultList/e2e/quanticResultList.e2e.ts +0 -69
  127. package/force-app/main/default/lwc/quanticResultMultiValueText/__tests__/quanticResultMultiValueText.test.js +0 -235
  128. package/force-app/main/default/lwc/quanticResultNumber/__tests__/quanticResultNumber.test.js +0 -144
  129. package/force-app/main/default/lwc/quanticResultPrintableUri/__tests__/quanticResultPrintableUri.test.js +0 -324
  130. package/force-app/main/default/lwc/quanticResultQuickview/__tests__/quanticResultQuickview.test.js +0 -308
  131. package/force-app/main/default/lwc/quanticResultQuickview/e2e/fixture.ts +0 -85
  132. package/force-app/main/default/lwc/quanticResultQuickview/e2e/pageObject.ts +0 -38
  133. package/force-app/main/default/lwc/quanticResultQuickview/e2e/quanticResultQuickView.e2e.ts +0 -66
  134. package/force-app/main/default/lwc/quanticResultTemplate/__tests__/quanticResultTemplate.test.js +0 -90
  135. package/force-app/main/default/lwc/quanticResultText/__tests__/quanticResultText.test.js +0 -155
  136. package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js +0 -464
  137. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +0 -78
  138. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/pageObject.ts +0 -85
  139. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/quanticResultsPerPage.e2e.ts +0 -97
  140. package/force-app/main/default/lwc/quanticSearchBox/__tests__/quanticSearchBox.test.js +0 -487
  141. package/force-app/main/default/lwc/quanticSearchBox/e2e/fixture.ts +0 -86
  142. package/force-app/main/default/lwc/quanticSearchBox/e2e/pageObject.ts +0 -45
  143. package/force-app/main/default/lwc/quanticSearchBox/e2e/quanticSearchBox.e2e.ts +0 -159
  144. package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js +0 -743
  145. package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/__tests__/quanticSearchBoxSuggestionsList.test.js +0 -571
  146. package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/fixture.ts +0 -113
  147. package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/pageObject.ts +0 -113
  148. package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/quanticSearchBoxSuggestionsList.e2e.ts +0 -282
  149. package/force-app/main/default/lwc/quanticSmartSnippet/__tests__/quanticSmartSnippet.test.js +0 -341
  150. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/data.ts +0 -21
  151. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/fixture.ts +0 -93
  152. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +0 -196
  153. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +0 -168
  154. package/force-app/main/default/lwc/quanticSmartSnippetAnswer/__tests__/quanticSmartSnippetAnswer.test.js +0 -126
  155. package/force-app/main/default/lwc/quanticSmartSnippetSource/__tests__/quanticSmartSnippetSource.test.js +0 -290
  156. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/__tests__/quanticSmartSnippetSuggestions.test.js +0 -329
  157. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/data.ts +0 -31
  158. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/fixture.ts +0 -95
  159. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/pageObject.ts +0 -160
  160. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/quanticSmartSnippetSuggestions.e2e.ts +0 -127
  161. package/force-app/main/default/lwc/quanticSort/__tests__/quanticSort.test.js +0 -416
  162. package/force-app/main/default/lwc/quanticSort/e2e/fixture.ts +0 -62
  163. package/force-app/main/default/lwc/quanticSort/e2e/pageObject.ts +0 -100
  164. package/force-app/main/default/lwc/quanticSort/e2e/quanticSort.e2e.ts +0 -86
  165. package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +0 -156
  166. package/force-app/main/default/lwc/quanticStandaloneSearchBox/__tests__/quanticStandaloneSearchBox.test.js +0 -387
  167. package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/fixture.ts +0 -54
  168. package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/pageObject.ts +0 -54
  169. package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/quanticStandaloneSearchBox.e2e.ts +0 -72
  170. package/force-app/main/default/lwc/quanticStatefulButton/__tests__/quanticStatefulButton.test.js +0 -222
  171. package/force-app/main/default/lwc/quanticSummary/__tests__/quanticSummary.test.js +0 -244
  172. package/force-app/main/default/lwc/quanticTab/__tests__/quanticTab.test.js +0 -333
  173. package/force-app/main/default/lwc/quanticTab/e2e/fixture.ts +0 -60
  174. package/force-app/main/default/lwc/quanticTab/e2e/pageObject.ts +0 -68
  175. package/force-app/main/default/lwc/quanticTab/e2e/quanticTab.e2e.ts +0 -72
  176. package/force-app/main/default/lwc/quanticTabBar/__tests__/quanticTabBar.test.js +0 -331
  177. package/force-app/main/default/lwc/quanticTabBar/e2e/fixture.ts +0 -65
  178. package/force-app/main/default/lwc/quanticTabBar/e2e/pageObject.ts +0 -80
  179. package/force-app/main/default/lwc/quanticTabBar/e2e/quanticTabBar.e2e.ts +0 -172
  180. package/force-app/main/default/lwc/quanticThreadItem/__tests__/quanticThreadItem.test.js +0 -314
  181. package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +0 -1059
  182. package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/data.ts +0 -66
  183. package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/fixture.ts +0 -74
  184. package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/pageObject.ts +0 -43
  185. package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/quanticTimeframeFacet.e2e.ts +0 -184
  186. package/force-app/main/default/lwc/quanticTooltip/__tests__/quanticTooltip.test.js +0 -107
  187. package/force-app/main/default/lwc/quanticUserAction/__tests__/quanticUserAction.test.js +0 -427
  188. package/force-app/main/default/lwc/quanticUserActionsSession/__tests__/quanticUserActionsSession.test.js +0 -269
  189. package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/data/userActionsState.json +0 -89
  190. package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/quanticUserActionsTimeline.test.js +0 -511
  191. package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +0 -229
  192. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +0 -32
  193. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +0 -32
  194. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +0 -71
  195. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +0 -39
  196. package/force-app/main/default/lwc/quanticUtils/__tests__/accessibilityUtils.test.js +0 -214
  197. package/force-app/main/default/lwc/quanticUtils/__tests__/citationAnchoringUtils.test.js +0 -84
  198. package/force-app/main/default/lwc/quanticUtils/__tests__/facetDependenciesUtils.test.js +0 -92
  199. package/force-app/main/default/lwc/quanticUtils/__tests__/facetStoreUtils.test.js +0 -86
  200. package/force-app/main/default/lwc/quanticUtils/__tests__/markdownUtils.test.js +0 -109
  201. package/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js +0 -233
  202. package/force-app/main/default/lwc/quanticUtils/__tests__/timeAndDateUtils.test.js +0 -22
  203. package/force-app/main/default/lwc/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +0 -131
@@ -1,1183 +0,0 @@
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
- });