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