@coveo/quantic 3.44.1 → 3.44.3

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