@coveo/quantic 3.32.0 → 3.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/README.md +15 -15
  2. package/docs/out/quantic-docs.json +1 -1
  3. package/force-app/main/default/lwc/quanticAriaLive/__tests__/quanticAriaLive.test.js +106 -0
  4. package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +752 -0
  5. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/fixture.ts +76 -0
  6. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/pageObject.ts +282 -0
  7. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/quanticBreadcrumbManager.e2e.ts +167 -0
  8. package/force-app/main/default/lwc/quanticCarousel/__tests__/quanticCarousel.test.js +262 -0
  9. package/force-app/main/default/lwc/quanticCaseClassification/__tests__/quanticCaseClassification.test.js +819 -0
  10. package/force-app/main/default/lwc/quanticCaseClassification/e2e/data.ts +23 -0
  11. package/force-app/main/default/lwc/quanticCaseClassification/e2e/fixture.ts +51 -0
  12. package/force-app/main/default/lwc/quanticCaseClassification/e2e/pageObject.ts +152 -0
  13. package/force-app/main/default/lwc/quanticCaseClassification/e2e/quanticCaseClassification.e2e.ts +269 -0
  14. package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +1183 -0
  15. package/force-app/main/default/lwc/quanticCategoryFacet/e2e/data.ts +27 -0
  16. package/force-app/main/default/lwc/quanticCategoryFacet/e2e/fixture.ts +75 -0
  17. package/force-app/main/default/lwc/quanticCategoryFacet/e2e/pageObject.ts +55 -0
  18. package/force-app/main/default/lwc/quanticCategoryFacet/e2e/quanticCategoryFacet.e2e.ts +199 -0
  19. package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +371 -0
  20. package/force-app/main/default/lwc/quanticColoredResultBadge/__tests__/quanticColoredResultBadge.test.js +212 -0
  21. package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +688 -0
  22. package/force-app/main/default/lwc/quanticDateFacet/e2e/data.ts +24 -0
  23. package/force-app/main/default/lwc/quanticDateFacet/e2e/fixture.ts +68 -0
  24. package/force-app/main/default/lwc/quanticDateFacet/e2e/pageObject.ts +27 -0
  25. package/force-app/main/default/lwc/quanticDateFacet/e2e/quanticDateFacet.e2e.ts +145 -0
  26. package/force-app/main/default/lwc/quanticDidYouMean/__tests__/quanticDidYouMean.test.js +348 -0
  27. package/force-app/main/default/lwc/quanticDidYouMean/e2e/data.ts +48 -0
  28. package/force-app/main/default/lwc/quanticDidYouMean/e2e/fixture.ts +80 -0
  29. package/force-app/main/default/lwc/quanticDidYouMean/e2e/pageObject.ts +173 -0
  30. package/force-app/main/default/lwc/quanticDidYouMean/e2e/quanticDidYouMean.e2e.ts +219 -0
  31. package/force-app/main/default/lwc/quanticDocumentSuggestion/__tests__/quanticDocumentSuggestion.test.js +404 -0
  32. package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/fixture.ts +38 -0
  33. package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/pageObject.ts +52 -0
  34. package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/quanticDocumentSuggestion.e2e.ts +102 -0
  35. package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +1105 -0
  36. package/force-app/main/default/lwc/quanticFacet/e2e/data.ts +21 -0
  37. package/force-app/main/default/lwc/quanticFacet/e2e/fixture.ts +73 -0
  38. package/force-app/main/default/lwc/quanticFacet/e2e/pageObject.ts +67 -0
  39. package/force-app/main/default/lwc/quanticFacet/e2e/quanticFacet.e2e.ts +208 -0
  40. package/force-app/main/default/lwc/quanticFacetCaption/__tests__/quanticFacetCaption.test.js +28 -0
  41. package/force-app/main/default/lwc/quanticFacetManager/__tests__/quanticFacetManager.test.js +178 -0
  42. package/force-app/main/default/lwc/quanticFacetManager/e2e/fixture.ts +64 -0
  43. package/force-app/main/default/lwc/quanticFacetManager/e2e/pageObject.ts +23 -0
  44. package/force-app/main/default/lwc/quanticFacetManager/e2e/quanticFacetManager.e2e.ts +82 -0
  45. package/force-app/main/default/lwc/quanticFeedback/__tests__/quanticFeedback.test.js +392 -0
  46. package/force-app/main/default/lwc/quanticFeedbackModal/__tests__/quanticFeedbackModal.test.js +448 -0
  47. package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +298 -0
  48. package/force-app/main/default/lwc/quanticFoldedResultList/__tests__/quanticFoldedResultList.test.js +323 -0
  49. package/force-app/main/default/lwc/quanticFoldedResultList/e2e/fixture.ts +70 -0
  50. package/force-app/main/default/lwc/quanticFoldedResultList/e2e/pageObject.ts +81 -0
  51. package/force-app/main/default/lwc/quanticFoldedResultList/e2e/quanticFoldedResultList.e2e.ts +69 -0
  52. package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +1158 -0
  53. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +56 -0
  54. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +185 -0
  55. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +451 -0
  56. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +337 -0
  57. package/force-app/main/default/lwc/quanticGeneratedAnswerContent/__tests__/quanticGeneratedAnswerContent.test.js +151 -0
  58. package/force-app/main/default/lwc/quanticHeading/__tests__/quanticHeading.test.js +71 -0
  59. package/force-app/main/default/lwc/quanticHeadlessLoader/__tests__/quanticHeadlessLoader.test.js +651 -0
  60. package/force-app/main/default/lwc/quanticInsightInterface/__tests__/quanticInsightInterface.test.js +194 -0
  61. package/force-app/main/default/lwc/quanticInsightInterface/quanticInsightInterface.js +1 -1
  62. package/force-app/main/default/lwc/quanticInsightSummary/__tests__/quanticInsightSummary.test.js +230 -0
  63. package/force-app/main/default/lwc/quanticModal/__tests__/quanticModal.test.js +205 -0
  64. package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +309 -0
  65. package/force-app/main/default/lwc/quanticNotifications/e2e/fixture.ts +58 -0
  66. package/force-app/main/default/lwc/quanticNotifications/e2e/pageObject.ts +55 -0
  67. package/force-app/main/default/lwc/quanticNotifications/e2e/quanticNotifications.e2e.ts +47 -0
  68. package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +953 -0
  69. package/force-app/main/default/lwc/quanticNumericFacet/e2e/data.ts +28 -0
  70. package/force-app/main/default/lwc/quanticNumericFacet/e2e/fixture.ts +71 -0
  71. package/force-app/main/default/lwc/quanticNumericFacet/e2e/pageObject.ts +59 -0
  72. package/force-app/main/default/lwc/quanticNumericFacet/e2e/quanticNumericFacet.e2e.ts +164 -0
  73. package/force-app/main/default/lwc/quanticPager/__tests__/quanticPager.test.js +430 -0
  74. package/force-app/main/default/lwc/quanticPager/e2e/fixture.ts +65 -0
  75. package/force-app/main/default/lwc/quanticPager/e2e/pageObject.ts +69 -0
  76. package/force-app/main/default/lwc/quanticPager/e2e/quanticPager.e2e.ts +106 -0
  77. package/force-app/main/default/lwc/quanticPlaceholder/__tests__/quanticPlaceholder.test.js +47 -0
  78. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/defaultTestCase.json +13 -0
  79. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/youtubeTestCase.json +14 -0
  80. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/quanticQuickviewContent.test.js +82 -0
  81. package/force-app/main/default/lwc/quanticRadioButtonsGroup/__tests__/quanticRadioButtonsGroup.test.js +273 -0
  82. package/force-app/main/default/lwc/quanticRecentQueriesList/__tests__/quanticRecentQueriesList.test.js +448 -0
  83. package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/fixture.ts +42 -0
  84. package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/pageObject.ts +55 -0
  85. package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/quanticRecentQueriesList.e2e.ts +93 -0
  86. package/force-app/main/default/lwc/quanticRecentResultsList/__tests__/quanticRecentResultsList.test.js +516 -0
  87. package/force-app/main/default/lwc/quanticRecentResultsList/e2e/fixture.ts +42 -0
  88. package/force-app/main/default/lwc/quanticRecentResultsList/e2e/pageObject.ts +61 -0
  89. package/force-app/main/default/lwc/quanticRecentResultsList/e2e/quanticRecentResultsList.e2e.ts +48 -0
  90. package/force-app/main/default/lwc/quanticRecommendationList/__tests__/quanticRecommendationList.test.js +491 -0
  91. package/force-app/main/default/lwc/quanticRecommendationList/e2e/fixture.ts +35 -0
  92. package/force-app/main/default/lwc/quanticRecommendationList/e2e/pageObject.ts +52 -0
  93. package/force-app/main/default/lwc/quanticRecommendationList/e2e/quanticRecommendationList.e2e.ts +53 -0
  94. package/force-app/main/default/lwc/quanticRefineModalContent/__tests__/quanticRefineModalContent.test.js +747 -0
  95. package/force-app/main/default/lwc/quanticRefineToggle/__tests__/quanticRefineToggle.test.js +542 -0
  96. package/force-app/main/default/lwc/quanticResultAction/__tests__/quanticResultAction.test.js +262 -0
  97. package/force-app/main/default/lwc/quanticResultActionBar/__tests__/quanticResultActionBar.test.js +141 -0
  98. package/force-app/main/default/lwc/quanticResultChildren/__tests__/quanticResultChildren.test.js +340 -0
  99. package/force-app/main/default/lwc/quanticResultCopyToClipboard/__tests__/quanticResultCopyToClipboard.test.js +300 -0
  100. package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/fixture.ts +46 -0
  101. package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/pageObject.ts +49 -0
  102. package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/quanticResultCopyToClipboard.e2e.ts +40 -0
  103. package/force-app/main/default/lwc/quanticResultDate/__tests__/quanticResultDate.test.js +144 -0
  104. package/force-app/main/default/lwc/quanticResultField/__tests__/quanticResultField.test.js +120 -0
  105. package/force-app/main/default/lwc/quanticResultHighlightedTextField/__tests__/quanticResultHighlightedTextField.test.js +209 -0
  106. package/force-app/main/default/lwc/quanticResultLink/__tests__/quanticResultLink.test.js +261 -0
  107. package/force-app/main/default/lwc/quanticResultList/__tests__/quanticResultList.test.js +342 -0
  108. package/force-app/main/default/lwc/quanticResultList/e2e/fixture.ts +66 -0
  109. package/force-app/main/default/lwc/quanticResultList/e2e/pageObject.ts +81 -0
  110. package/force-app/main/default/lwc/quanticResultList/e2e/quanticResultList.e2e.ts +69 -0
  111. package/force-app/main/default/lwc/quanticResultMultiValueText/__tests__/quanticResultMultiValueText.test.js +235 -0
  112. package/force-app/main/default/lwc/quanticResultNumber/__tests__/quanticResultNumber.test.js +144 -0
  113. package/force-app/main/default/lwc/quanticResultPrintableUri/__tests__/quanticResultPrintableUri.test.js +324 -0
  114. package/force-app/main/default/lwc/quanticResultQuickview/__tests__/quanticResultQuickview.test.js +301 -0
  115. package/force-app/main/default/lwc/quanticResultQuickview/e2e/fixture.ts +81 -0
  116. package/force-app/main/default/lwc/quanticResultQuickview/e2e/pageObject.ts +38 -0
  117. package/force-app/main/default/lwc/quanticResultQuickview/e2e/quanticResultQuickView.e2e.ts +66 -0
  118. package/force-app/main/default/lwc/quanticResultTemplate/__tests__/quanticResultTemplate.test.js +90 -0
  119. package/force-app/main/default/lwc/quanticResultText/__tests__/quanticResultText.test.js +155 -0
  120. package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js +464 -0
  121. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +74 -0
  122. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/pageObject.ts +85 -0
  123. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/quanticResultsPerPage.e2e.ts +97 -0
  124. package/force-app/main/default/lwc/quanticSearchBox/__tests__/quanticSearchBox.test.js +487 -0
  125. package/force-app/main/default/lwc/quanticSearchBox/e2e/fixture.ts +84 -0
  126. package/force-app/main/default/lwc/quanticSearchBox/e2e/pageObject.ts +45 -0
  127. package/force-app/main/default/lwc/quanticSearchBox/e2e/quanticSearchBox.e2e.ts +159 -0
  128. package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js +743 -0
  129. package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/__tests__/quanticSearchBoxSuggestionsList.test.js +571 -0
  130. package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/fixture.ts +110 -0
  131. package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/pageObject.ts +113 -0
  132. package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/quanticSearchBoxSuggestionsList.e2e.ts +299 -0
  133. package/force-app/main/default/lwc/quanticSmartSnippet/__tests__/quanticSmartSnippet.test.js +341 -0
  134. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/data.ts +21 -0
  135. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/fixture.ts +91 -0
  136. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +196 -0
  137. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +192 -0
  138. package/force-app/main/default/lwc/quanticSmartSnippetAnswer/__tests__/quanticSmartSnippetAnswer.test.js +126 -0
  139. package/force-app/main/default/lwc/quanticSmartSnippetSource/__tests__/quanticSmartSnippetSource.test.js +290 -0
  140. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/__tests__/quanticSmartSnippetSuggestions.test.js +329 -0
  141. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/data.ts +31 -0
  142. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/fixture.ts +93 -0
  143. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/pageObject.ts +160 -0
  144. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/quanticSmartSnippetSuggestions.e2e.ts +127 -0
  145. package/force-app/main/default/lwc/quanticSort/__tests__/quanticSort.test.js +416 -0
  146. package/force-app/main/default/lwc/quanticSort/e2e/fixture.ts +61 -0
  147. package/force-app/main/default/lwc/quanticSort/e2e/pageObject.ts +89 -0
  148. package/force-app/main/default/lwc/quanticSort/e2e/quanticSort.e2e.ts +91 -0
  149. package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +136 -0
  150. package/force-app/main/default/lwc/quanticStandaloneSearchBox/__tests__/quanticStandaloneSearchBox.test.js +387 -0
  151. package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/fixture.ts +53 -0
  152. package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/pageObject.ts +54 -0
  153. package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/quanticStandaloneSearchBox.e2e.ts +72 -0
  154. package/force-app/main/default/lwc/quanticStatefulButton/__tests__/quanticStatefulButton.test.js +222 -0
  155. package/force-app/main/default/lwc/quanticSummary/__tests__/quanticSummary.test.js +244 -0
  156. package/force-app/main/default/lwc/quanticTab/__tests__/quanticTab.test.js +333 -0
  157. package/force-app/main/default/lwc/quanticTab/e2e/fixture.ts +56 -0
  158. package/force-app/main/default/lwc/quanticTab/e2e/pageObject.ts +68 -0
  159. package/force-app/main/default/lwc/quanticTab/e2e/quanticTab.e2e.ts +72 -0
  160. package/force-app/main/default/lwc/quanticTabBar/__tests__/quanticTabBar.test.js +331 -0
  161. package/force-app/main/default/lwc/quanticTabBar/e2e/fixture.ts +61 -0
  162. package/force-app/main/default/lwc/quanticTabBar/e2e/pageObject.ts +80 -0
  163. package/force-app/main/default/lwc/quanticTabBar/e2e/quanticTabBar.e2e.ts +171 -0
  164. package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +1037 -0
  165. package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/fixture.ts +58 -0
  166. package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/pageObject.ts +43 -0
  167. package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/quanticTimeframeFacet.e2e.ts +160 -0
  168. package/force-app/main/default/lwc/quanticTooltip/__tests__/quanticTooltip.test.js +107 -0
  169. package/force-app/main/default/lwc/quanticUserAction/__tests__/quanticUserAction.test.js +427 -0
  170. package/force-app/main/default/lwc/quanticUserActionsSession/__tests__/quanticUserActionsSession.test.js +269 -0
  171. package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/data/userActionsState.json +89 -0
  172. package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/quanticUserActionsTimeline.test.js +511 -0
  173. package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +229 -0
  174. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +32 -0
  175. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +32 -0
  176. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +71 -0
  177. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +39 -0
  178. package/force-app/main/default/lwc/quanticUtils/__tests__/citationAnchoringUtils.test.js +84 -0
  179. package/force-app/main/default/lwc/quanticUtils/__tests__/facetDependenciesUtils.test.js +92 -0
  180. package/force-app/main/default/lwc/quanticUtils/__tests__/markdownUtils.test.js +71 -0
  181. package/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js +223 -0
  182. package/force-app/main/default/lwc/quanticUtils/recentQueriesUtils.js +20 -12
  183. package/force-app/main/default/lwc/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +131 -0
  184. package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +3 -3
  185. package/force-app/main/default/staticresources/coveoheadless/definitions/app/case-assist-engine/case-assist-engine.d.ts +3 -3
  186. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-engine/commerce-engine.d.ts +16 -16
  187. package/force-app/main/default/staticresources/coveoheadless/definitions/app/common-reducers.d.ts +1 -1
  188. package/force-app/main/default/staticresources/coveoheadless/definitions/app/insight-engine/insight-engine.d.ts +5 -5
  189. package/force-app/main/default/staticresources/coveoheadless/definitions/app/recommendation-engine/recommendation-engine.d.ts +4 -4
  190. package/force-app/main/default/staticresources/coveoheadless/definitions/app/search-engine/search-engine.d.ts +4 -4
  191. package/force-app/main/default/staticresources/coveoheadless/definitions/app/store.d.ts +2 -2
  192. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/facets/headless-core-commerce-facet.d.ts +1 -1
  193. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/facets/range-facet/headless-core-range-facet.d.ts +1 -1
  194. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/recent-queries-list/headless-core-recent-queries-list.d.ts +91 -0
  195. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/insight/attach-to-case/headless-attach-to-case.d.ts +2 -0
  196. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/insight/attached-results/headless-attached-results.d.ts +68 -0
  197. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/insight/recent-queries-list/headless-insight-recent-queries-list.d.ts +14 -0
  198. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/recent-queries-list/headless-recent-queries-list.d.ts +2 -79
  199. package/force-app/main/default/staticresources/coveoheadless/definitions/features/actions-history/ipx-actions-history-actions.d.ts +1 -1
  200. package/force-app/main/default/staticresources/coveoheadless/definitions/features/advanced-search-queries/advanced-search-queries-slice.d.ts +1 -1
  201. package/force-app/main/default/staticresources/coveoheadless/definitions/features/analytics/search-action-cause.d.ts +9 -1
  202. package/force-app/main/default/staticresources/coveoheadless/definitions/features/attached-results/attached-results-slice.d.ts +1 -1
  203. package/force-app/main/default/staticresources/coveoheadless/definitions/features/attached-results/attached-results-state.d.ts +1 -0
  204. package/force-app/main/default/staticresources/coveoheadless/definitions/features/case-assist-configuration/case-assist-configuration-slice.d.ts +1 -1
  205. package/force-app/main/default/staticresources/coveoheadless/definitions/features/case-context/case-context-slice.d.ts +1 -1
  206. package/force-app/main/default/staticresources/coveoheadless/definitions/features/case-field/case-field-actions.d.ts +1 -1
  207. package/force-app/main/default/staticresources/coveoheadless/definitions/features/case-field/case-field-slice.d.ts +1 -1
  208. package/force-app/main/default/staticresources/coveoheadless/definitions/features/case-input/case-input-slice.d.ts +1 -1
  209. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/configuration/configuration-slice.d.ts +1 -1
  210. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/context/cart/cart-actions.d.ts +2 -2
  211. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/context/cart/cart-slice.d.ts +1 -1
  212. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/context/context-slice.d.ts +1 -1
  213. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/did-you-mean/did-you-mean-slice.d.ts +1 -1
  214. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/facets/facet-search-set/commerce-facet-search-actions.d.ts +2 -2
  215. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/facets/facet-set/facet-set-slice.d.ts +1 -1
  216. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.d.ts +1 -1
  217. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.d.ts +1 -1
  218. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/instant-products/instant-products-slice.d.ts +1 -1
  219. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/pagination/pagination-slice.d.ts +1 -1
  220. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/parameters/parameters-slice.d.ts +1 -1
  221. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/product/product-actions.d.ts +2 -2
  222. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/product-listing/product-listing-actions.d.ts +2 -2
  223. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/product-listing/product-listing-slice.d.ts +1 -1
  224. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/query/query-slice.d.ts +1 -1
  225. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/query-suggest/query-suggest-actions.d.ts +1 -1
  226. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/recent-queries/recent-queries-slice.d.ts +1 -1
  227. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/recommendations/recommendations-actions.d.ts +2 -2
  228. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/recommendations/recommendations-slice.d.ts +1 -1
  229. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/search/search-actions.d.ts +4 -4
  230. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/search/search-slice.d.ts +1 -1
  231. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/sort/sort-slice.d.ts +1 -1
  232. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/standalone-search-box-set/standalone-search-box-set-actions.d.ts +1 -1
  233. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.d.ts +1 -1
  234. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/triggers/triggers-slice.d.ts +1 -1
  235. package/force-app/main/default/staticresources/coveoheadless/definitions/features/configuration/configuration-slice.d.ts +1 -1
  236. package/force-app/main/default/staticresources/coveoheadless/definitions/features/context/context-slice.d.ts +1 -1
  237. package/force-app/main/default/staticresources/coveoheadless/definitions/features/debug/debug-slice.d.ts +1 -1
  238. package/force-app/main/default/staticresources/coveoheadless/definitions/features/debug/version-slice.d.ts +1 -1
  239. package/force-app/main/default/staticresources/coveoheadless/definitions/features/dictionary-field-context/dictionary-field-context-slice.d.ts +1 -1
  240. package/force-app/main/default/staticresources/coveoheadless/definitions/features/did-you-mean/did-you-mean-slice.d.ts +1 -1
  241. package/force-app/main/default/staticresources/coveoheadless/definitions/features/document-suggestion/document-suggestion-actions.d.ts +1 -1
  242. package/force-app/main/default/staticresources/coveoheadless/definitions/features/document-suggestion/document-suggestion-slice.d.ts +1 -1
  243. package/force-app/main/default/staticresources/coveoheadless/definitions/features/excerpt-length/excerpt-length-slice.d.ts +1 -1
  244. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facet-options/facet-options-slice.d.ts +1 -1
  245. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/automatic-facet-set/automatic-facet-set-slice.d.ts +1 -1
  246. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/category-facet-set/category-facet-set-slice.d.ts +1 -1
  247. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-order/facet-order-slice.d.ts +1 -1
  248. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-search-set/category/category-facet-search-set-slice.d.ts +1 -1
  249. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-search-set/generic/generic-facet-search-actions.d.ts +2 -2
  250. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-search-set/specific/specific-facet-search-set-slice.d.ts +1 -1
  251. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-set/facet-set-controller-actions.d.ts +2 -2
  252. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-set/facet-set-slice.d.ts +1 -1
  253. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/range-facets/date-facet-set/date-facet-controller-actions.d.ts +2 -2
  254. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/range-facets/date-facet-set/date-facet-set-slice.d.ts +1 -1
  255. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.d.ts +2 -2
  256. package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.d.ts +1 -1
  257. package/force-app/main/default/staticresources/coveoheadless/definitions/features/fields/fields-actions.d.ts +1 -1
  258. package/force-app/main/default/staticresources/coveoheadless/definitions/features/fields/fields-slice.d.ts +1 -1
  259. package/force-app/main/default/staticresources/coveoheadless/definitions/features/folding/folding-actions.d.ts +1 -1
  260. package/force-app/main/default/staticresources/coveoheadless/definitions/features/folding/folding-slice.d.ts +1 -1
  261. package/force-app/main/default/staticresources/coveoheadless/definitions/features/folding/insight-folding-actions.d.ts +1 -1
  262. package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-actions.d.ts +2 -2
  263. package/force-app/main/default/staticresources/coveoheadless/definitions/features/generated-answer/generated-answer-slice.d.ts +1 -1
  264. package/force-app/main/default/staticresources/coveoheadless/definitions/features/history/history-actions.d.ts +3 -3
  265. package/force-app/main/default/staticresources/coveoheadless/definitions/features/history/history-slice.d.ts +2 -2
  266. package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-configuration/insight-configuration-slice.d.ts +1 -1
  267. package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-interface/insight-interface-actions.d.ts +1 -1
  268. package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-interface/insight-interface-slice.d.ts +1 -1
  269. package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-search/insight-search-actions.d.ts +5 -5
  270. package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-search/legacy/insight-search-actions.d.ts +4 -4
  271. package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-user-actions/insight-user-actions-actions.d.ts +1 -1
  272. package/force-app/main/default/staticresources/coveoheadless/definitions/features/insight-user-actions/insight-user-actions-slice.d.ts +1 -1
  273. package/force-app/main/default/staticresources/coveoheadless/definitions/features/instant-results/instant-results-slice.d.ts +1 -1
  274. package/force-app/main/default/staticresources/coveoheadless/definitions/features/pagination/pagination-slice.d.ts +1 -1
  275. package/force-app/main/default/staticresources/coveoheadless/definitions/features/pipeline/pipeline-slice.d.ts +1 -1
  276. package/force-app/main/default/staticresources/coveoheadless/definitions/features/query/query-slice.d.ts +1 -1
  277. package/force-app/main/default/staticresources/coveoheadless/definitions/features/query-set/query-set-slice.d.ts +1 -1
  278. package/force-app/main/default/staticresources/coveoheadless/definitions/features/query-suggest/query-suggest-actions.d.ts +1 -1
  279. package/force-app/main/default/staticresources/coveoheadless/definitions/features/query-suggest/query-suggest-slice.d.ts +1 -1
  280. package/force-app/main/default/staticresources/coveoheadless/definitions/features/question-answering/question-answering-slice.d.ts +1 -1
  281. package/force-app/main/default/staticresources/coveoheadless/definitions/features/recent-queries/recent-queries-insight-analytics-actions.d.ts +3 -0
  282. package/force-app/main/default/staticresources/coveoheadless/definitions/features/recent-queries/recent-queries-slice.d.ts +1 -1
  283. package/force-app/main/default/staticresources/coveoheadless/definitions/features/recent-results/recent-results-slice.d.ts +1 -1
  284. package/force-app/main/default/staticresources/coveoheadless/definitions/features/recommendation/recommendation-actions.d.ts +1 -1
  285. package/force-app/main/default/staticresources/coveoheadless/definitions/features/recommendation/recommendation-slice.d.ts +1 -1
  286. package/force-app/main/default/staticresources/coveoheadless/definitions/features/result-preview/result-preview-actions.d.ts +2 -2
  287. package/force-app/main/default/staticresources/coveoheadless/definitions/features/result-preview/result-preview-slice.d.ts +1 -1
  288. package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/legacy/search-actions.d.ts +5 -5
  289. package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-actions.d.ts +6 -6
  290. package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-slice.d.ts +1 -1
  291. package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-hub/search-hub-slice.d.ts +1 -1
  292. package/force-app/main/default/staticresources/coveoheadless/definitions/features/sort-criteria/sort-criteria-slice.d.ts +1 -1
  293. package/force-app/main/default/staticresources/coveoheadless/definitions/features/standalone-search-box-set/standalone-search-box-set-actions.d.ts +1 -1
  294. package/force-app/main/default/staticresources/coveoheadless/definitions/features/standalone-search-box-set/standalone-search-box-set-slice.d.ts +1 -1
  295. package/force-app/main/default/staticresources/coveoheadless/definitions/features/static-filter-set/static-filter-set-slice.d.ts +1 -1
  296. package/force-app/main/default/staticresources/coveoheadless/definitions/features/tab-set/tab-set-slice.d.ts +1 -1
  297. package/force-app/main/default/staticresources/coveoheadless/definitions/features/triggers/triggers-slice.d.ts +1 -1
  298. package/force-app/main/default/staticresources/coveoheadless/definitions/insight.index.d.ts +4 -0
  299. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/factories/build-factory.d.ts +6 -1
  300. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/fetch-static-state.d.ts +3 -0
  301. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/from-build-result.d.ts +6 -0
  302. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/types/hydrate-static-state.d.ts +3 -0
  303. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/access-token-manager.d.ts +19 -0
  304. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/augment-preprocess-request.d.ts +7 -2
  305. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/types/fetch-static-state.d.ts +3 -0
  306. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/types/hydrate-static-state.d.ts +3 -0
  307. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/engine.d.ts +4 -2
  308. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/access-token-manager.d.ts +19 -0
  309. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/augment-preprocess-request.d.ts +7 -2
  310. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/engine/search-engine.ssr.d.ts +2 -2
  311. package/force-app/main/default/staticresources/coveoheadless/definitions/state/insight-app-state.d.ts +2 -2
  312. package/force-app/main/default/staticresources/coveoheadless/definitions/test/mock-ssr-controller-definitions.d.ts +2 -2
  313. package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -10
  314. package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +9 -9
  315. package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +3 -3
  316. package/package.json +46 -44
@@ -0,0 +1,743 @@
1
+ import QuanticSearchBoxInput from '../quanticSearchBoxInput';
2
+ import {buildCreateTestComponent, cleanup, flushPromises} from 'c/testUtils';
3
+
4
+ const functionsMocks = {
5
+ exampleHandleInputValueChange: jest.fn(),
6
+ exampleHandleSubmitSearch: jest.fn(),
7
+ exampleShowSuggestions: jest.fn(),
8
+ exampleSelectSuggestion: jest.fn(),
9
+ };
10
+
11
+ const defaultPlaceholder = 'Search...';
12
+ const mockInputValue = 'Test input value';
13
+ const mockLongInputValue =
14
+ 'Test input value that is longer than the default input value length to test the textarea expanding feature';
15
+ const mockSuggestions = [
16
+ {key: '1', value: 'suggestion1', rawValue: 'suggestion1'},
17
+ {key: '2', value: 'suggestion2', rawValue: 'suggestion2'},
18
+ {key: '3', value: 'suggestion3', rawValue: 'suggestion3'},
19
+ ];
20
+ const exampleRecentQueries = ['foo', 'bar'];
21
+
22
+ const defaultOptions = {
23
+ withoutSubmitButton: false,
24
+ textarea: true,
25
+ placeholder: defaultPlaceholder,
26
+ suggestions: [],
27
+ };
28
+
29
+ const selectors = {
30
+ searchBoxInput: '[data-testid="search-box-input"]',
31
+ searchBoxTextArea: '[data-testid="search-box-textarea"]',
32
+ searchBoxSubmitBtn: '.searchbox__submit-button',
33
+ searchBoxClearIcon: '.searchbox__clear-button',
34
+ searchBoxSuggestionsList: 'c-quantic-search-box-suggestions-list',
35
+ SuggestionsListBox: '[role="listbox"]',
36
+ searchBoxContainer: '.searchbox__container',
37
+ searchBoxComboBox: '.slds-combobox_container .slds-combobox',
38
+ searchBoxSearchIcon: '.searchbox__search-icon',
39
+ clearRecentQueryButton: '[data-testid="clear-recent-queries-button"]',
40
+ };
41
+
42
+ function setupEventListeners(element) {
43
+ element.addEventListener(
44
+ 'quantic__inputvaluechange',
45
+ functionsMocks.exampleHandleInputValueChange
46
+ );
47
+ element.addEventListener(
48
+ 'quantic__submitsearch',
49
+ functionsMocks.exampleHandleSubmitSearch
50
+ );
51
+ element.addEventListener(
52
+ 'quantic__showsuggestions',
53
+ functionsMocks.exampleShowSuggestions
54
+ );
55
+ element.addEventListener(
56
+ 'quantic__selectsuggestion',
57
+ functionsMocks.exampleSelectSuggestion
58
+ );
59
+ }
60
+
61
+ const createTestComponent = buildCreateTestComponent(
62
+ QuanticSearchBoxInput,
63
+ 'c-quantic-search-box-input',
64
+ defaultOptions
65
+ );
66
+
67
+ describe('c-quantic-search-box-input', () => {
68
+ beforeAll(() => {
69
+ window.coveoHeadless = {
70
+ test: {
71
+ bundle: {
72
+ HighlightUtils: {
73
+ highlightString: () => {},
74
+ },
75
+ },
76
+ components: [],
77
+ options: undefined,
78
+ bindings: undefined,
79
+ enginePromise: undefined,
80
+ },
81
+ };
82
+ });
83
+
84
+ afterEach(() => {
85
+ cleanup();
86
+ jest.clearAllMocks();
87
+ });
88
+
89
+ [false, true].forEach((textareaValue) => {
90
+ describe(`when the textarea property is set to ${textareaValue}`, () => {
91
+ it(`should display the ${
92
+ textareaValue ? 'expandable' : 'default'
93
+ } search box properly`, async () => {
94
+ const element = createTestComponent({
95
+ ...defaultOptions,
96
+ textarea: textareaValue,
97
+ });
98
+ await flushPromises();
99
+
100
+ const submitButton = element.shadowRoot.querySelector(
101
+ selectors.searchBoxSubmitBtn
102
+ );
103
+ const clearIcon = element.shadowRoot.querySelector(
104
+ selectors.searchBoxClearIcon
105
+ );
106
+ const input = element.shadowRoot.querySelector(
107
+ textareaValue ? selectors.searchBoxTextArea : selectors.searchBoxInput
108
+ );
109
+
110
+ expect(input).not.toBeNull();
111
+ expect(input.placeholder).toEqual(defaultOptions.placeholder);
112
+ expect(submitButton).not.toBeNull();
113
+ expect(clearIcon).toBeNull();
114
+ });
115
+
116
+ describe('when the withoutSubmitButton is set to false', () => {
117
+ it('should display the submit button correctly to the right only', async () => {
118
+ const element = createTestComponent({
119
+ ...defaultOptions,
120
+ withoutSubmitButton: false,
121
+ textarea: textareaValue,
122
+ });
123
+ await flushPromises();
124
+
125
+ const submitButton = element.shadowRoot.querySelector(
126
+ selectors.searchBoxSubmitBtn
127
+ );
128
+
129
+ const searchIcon = element.shadowRoot.querySelector(
130
+ selectors.searchBoxSearchIcon
131
+ );
132
+
133
+ expect(submitButton).not.toBeNull();
134
+ expect(searchIcon).toBeNull();
135
+ });
136
+ });
137
+
138
+ describe('when the withoutSubmitButton is set to true', () => {
139
+ it('should not display the submit button to the right of the searchbox', async () => {
140
+ const element = createTestComponent({
141
+ ...defaultOptions,
142
+ withoutSubmitButton: true,
143
+ textarea: textareaValue,
144
+ });
145
+ await flushPromises();
146
+
147
+ const searchIcon = element.shadowRoot.querySelector(
148
+ selectors.searchBoxSearchIcon
149
+ );
150
+ const submitButton = element.shadowRoot.querySelector(
151
+ selectors.searchBoxSubmitBtn
152
+ );
153
+
154
+ expect(submitButton).toBeNull();
155
+ expect(searchIcon).not.toBeNull();
156
+ expect(searchIcon.classList.contains('slds-input__icon_left')).toBe(
157
+ true
158
+ );
159
+ });
160
+ });
161
+
162
+ describe('when the placeholder property receives a custom placeholder value', () => {
163
+ it('should display the custom value as the searchbox placeholder', async () => {
164
+ const customPlaceholder = 'Custom placeholder';
165
+ const element = createTestComponent({
166
+ ...defaultOptions,
167
+ placeholder: customPlaceholder,
168
+ textarea: textareaValue,
169
+ });
170
+ await flushPromises();
171
+
172
+ const input = element.shadowRoot.querySelector(
173
+ textareaValue
174
+ ? selectors.searchBoxTextArea
175
+ : selectors.searchBoxInput
176
+ );
177
+
178
+ expect(input.placeholder).toEqual(customPlaceholder);
179
+ });
180
+ });
181
+
182
+ describe('when the suggestions list is not empty', () => {
183
+ describe('when only query suggestions are displayed', () => {
184
+ it('should pass the suggestions to the suggestions list', async () => {
185
+ const element = createTestComponent({
186
+ ...defaultOptions,
187
+ suggestions: mockSuggestions,
188
+ textarea: textareaValue,
189
+ });
190
+ await flushPromises();
191
+
192
+ const input = element.shadowRoot.querySelector(
193
+ textareaValue
194
+ ? selectors.searchBoxTextArea
195
+ : selectors.searchBoxInput
196
+ );
197
+ expect(input).not.toBeNull();
198
+ await input.focus();
199
+
200
+ const suggestionsList = element.shadowRoot.querySelector(
201
+ selectors.searchBoxSuggestionsList
202
+ );
203
+ expect(suggestionsList).not.toBeNull();
204
+ expect(suggestionsList.suggestions).toEqual(mockSuggestions);
205
+ });
206
+ });
207
+
208
+ describe('with both query suggestions and recent queries available', () => {
209
+ it('should display the query suggestions and the recent queries in the suggestions list', async () => {
210
+ const element = createTestComponent({
211
+ ...defaultOptions,
212
+ suggestions: mockSuggestions,
213
+ recentQueries: exampleRecentQueries,
214
+ textarea: textareaValue,
215
+ inputValue: '',
216
+ });
217
+ await flushPromises();
218
+
219
+ const input = element.shadowRoot.querySelector(
220
+ textareaValue
221
+ ? selectors.searchBoxTextArea
222
+ : selectors.searchBoxInput
223
+ );
224
+ expect(input).not.toBeNull();
225
+ await input.focus();
226
+
227
+ const suggestionsList = element.shadowRoot.querySelector(
228
+ selectors.searchBoxSuggestionsList
229
+ );
230
+ expect(suggestionsList).not.toBeNull();
231
+ expect(suggestionsList.suggestions).toEqual(mockSuggestions);
232
+ expect(suggestionsList.recentQueries).toEqual(exampleRecentQueries);
233
+ });
234
+
235
+ describe('when pressing the DOWN to select a suggestion', () => {
236
+ it('should persist the value of the suggestion on blur', async () => {
237
+ const element = createTestComponent({
238
+ ...defaultOptions,
239
+ suggestions: mockSuggestions,
240
+ recentQueries: exampleRecentQueries,
241
+ textarea: textareaValue,
242
+ inputValue: '',
243
+ });
244
+ await flushPromises();
245
+
246
+ const input = element.shadowRoot.querySelector(
247
+ textareaValue
248
+ ? selectors.searchBoxTextArea
249
+ : selectors.searchBoxInput
250
+ );
251
+ expect(input).not.toBeNull();
252
+
253
+ await input.focus();
254
+ // First keydown to navigate to the clear recent queries option.
255
+ input.dispatchEvent(
256
+ new KeyboardEvent('keydown', {key: 'ArrowDown'})
257
+ );
258
+ // Second keydown to navigate to the first recent query option.
259
+ input.dispatchEvent(
260
+ new KeyboardEvent('keydown', {key: 'ArrowDown'})
261
+ );
262
+ await flushPromises();
263
+
264
+ expect(input.value).toBe(exampleRecentQueries[0]);
265
+
266
+ await input.blur();
267
+ await flushPromises();
268
+
269
+ expect(input.value).toBe(exampleRecentQueries[0]);
270
+ });
271
+
272
+ it('should persist the value of the suggestion when pressing the Escape key', async () => {
273
+ const element = createTestComponent({
274
+ ...defaultOptions,
275
+ suggestions: mockSuggestions,
276
+ recentQueries: exampleRecentQueries,
277
+ textarea: textareaValue,
278
+ inputValue: '',
279
+ });
280
+ await flushPromises();
281
+
282
+ const input = element.shadowRoot.querySelector(
283
+ textareaValue
284
+ ? selectors.searchBoxTextArea
285
+ : selectors.searchBoxInput
286
+ );
287
+ expect(input).not.toBeNull();
288
+
289
+ await input.focus();
290
+ // First keydown to navigate to the clear recent queries option.
291
+ input.dispatchEvent(
292
+ new KeyboardEvent('keydown', {key: 'ArrowDown'})
293
+ );
294
+ // Second keydown to navigate to the first recent query option.
295
+ input.dispatchEvent(
296
+ new KeyboardEvent('keydown', {key: 'ArrowDown'})
297
+ );
298
+ await flushPromises();
299
+
300
+ expect(input.value).toBe(exampleRecentQueries[0]);
301
+
302
+ input.dispatchEvent(
303
+ new KeyboardEvent('keydown', {key: 'Escape'})
304
+ );
305
+ await flushPromises();
306
+
307
+ expect(input.value).toBe(exampleRecentQueries[0]);
308
+ });
309
+ });
310
+ });
311
+ });
312
+
313
+ describe('when the suggestions list is empty', () => {
314
+ it('should not display the quanticSearchBoxSuggestionsList component', async () => {
315
+ const element = createTestComponent({
316
+ ...defaultOptions,
317
+ suggestions: [],
318
+ textarea: textareaValue,
319
+ });
320
+ await flushPromises();
321
+
322
+ const suggestionsList = element.shadowRoot.querySelector(
323
+ selectors.searchBoxSuggestionsList
324
+ );
325
+ expect(suggestionsList).toBeNull();
326
+ });
327
+ });
328
+
329
+ describe('when focusing on the input', () => {
330
+ it('should dispatch a #quantic__showsuggestions custom event', async () => {
331
+ const element = createTestComponent({
332
+ ...defaultOptions,
333
+ textarea: textareaValue,
334
+ });
335
+ setupEventListeners(element);
336
+ await flushPromises();
337
+
338
+ const input = element.shadowRoot.querySelector(
339
+ textareaValue
340
+ ? selectors.searchBoxTextArea
341
+ : selectors.searchBoxInput
342
+ );
343
+ expect(input).not.toBeNull();
344
+
345
+ await input.focus();
346
+
347
+ expect(functionsMocks.exampleShowSuggestions).toHaveBeenCalledTimes(
348
+ 1
349
+ );
350
+ });
351
+
352
+ describe('when selecting a suggestion from the suggestions list', () => {
353
+ it('should dispatch a #quantic__selectsuggestion event with the selected suggestion as payload', async () => {
354
+ const element = createTestComponent({
355
+ ...defaultOptions,
356
+ suggestions: mockSuggestions,
357
+ textarea: textareaValue,
358
+ });
359
+ setupEventListeners(element);
360
+ await flushPromises();
361
+
362
+ const input = element.shadowRoot.querySelector(
363
+ textareaValue
364
+ ? selectors.searchBoxTextArea
365
+ : selectors.searchBoxInput
366
+ );
367
+ expect(input).not.toBeNull();
368
+
369
+ await input.focus();
370
+
371
+ const suggestionsList = element.shadowRoot.querySelector(
372
+ selectors.searchBoxSuggestionsList
373
+ );
374
+ expect(suggestionsList).not.toBeNull();
375
+
376
+ const mockSuggestion = {
377
+ value: 'mock suggestion',
378
+ isClearRecentQueryButton: false,
379
+ isRecentQuery: false,
380
+ };
381
+
382
+ suggestionsList.dispatchEvent(
383
+ new CustomEvent('quantic__selection', {
384
+ detail: {selection: mockSuggestion},
385
+ })
386
+ );
387
+
388
+ expect(
389
+ functionsMocks.exampleSelectSuggestion
390
+ ).toHaveBeenCalledTimes(1);
391
+ const eventData =
392
+ functionsMocks.exampleSelectSuggestion.mock.calls[0][0];
393
+
394
+ expect(eventData?.detail).toMatchObject({
395
+ selectedSuggestion: mockSuggestion,
396
+ });
397
+ });
398
+ });
399
+
400
+ describe('when selecting the clear recent query option from the suggestions list', () => {
401
+ it('should dispatch a #quantic__selectsuggestion event with the selected suggestion as payload', async () => {
402
+ const element = createTestComponent({
403
+ ...defaultOptions,
404
+ suggestions: mockSuggestions,
405
+ textarea: textareaValue,
406
+ recentQueries: exampleRecentQueries,
407
+ inputValue: '',
408
+ });
409
+ setupEventListeners(element);
410
+ await flushPromises();
411
+
412
+ const input = element.shadowRoot.querySelector(
413
+ textareaValue
414
+ ? selectors.searchBoxTextArea
415
+ : selectors.searchBoxInput
416
+ );
417
+ expect(input).not.toBeNull();
418
+
419
+ await input.focus();
420
+
421
+ const suggestionsList = element.shadowRoot.querySelector(
422
+ selectors.searchBoxSuggestionsList
423
+ );
424
+ expect(suggestionsList).not.toBeNull();
425
+
426
+ const mockSuggestion = {
427
+ value: undefined,
428
+ isClearRecentQueryButton: true,
429
+ isRecentQuery: false,
430
+ };
431
+
432
+ suggestionsList.dispatchEvent(
433
+ new CustomEvent('quantic__selection', {
434
+ detail: {selection: mockSuggestion},
435
+ })
436
+ );
437
+
438
+ expect(
439
+ functionsMocks.exampleSelectSuggestion
440
+ ).toHaveBeenCalledTimes(1);
441
+ const eventData =
442
+ functionsMocks.exampleSelectSuggestion.mock.calls[0][0];
443
+
444
+ expect(eventData?.detail).toMatchObject({
445
+ selectedSuggestion: mockSuggestion,
446
+ });
447
+ });
448
+ });
449
+
450
+ describe('when selecting a recent query from the suggestions list', () => {
451
+ it('should dispatch a #quantic__selectsuggestion event with the selected recent query as payload', async () => {
452
+ const element = createTestComponent({
453
+ ...defaultOptions,
454
+ suggestions: mockSuggestions,
455
+ textarea: textareaValue,
456
+ recentQueries: exampleRecentQueries,
457
+ inputValue: '',
458
+ });
459
+ setupEventListeners(element);
460
+ await flushPromises();
461
+
462
+ const input = element.shadowRoot.querySelector(
463
+ textareaValue
464
+ ? selectors.searchBoxTextArea
465
+ : selectors.searchBoxInput
466
+ );
467
+ expect(input).not.toBeNull();
468
+
469
+ await input.focus();
470
+
471
+ const suggestionsList = element.shadowRoot.querySelector(
472
+ selectors.searchBoxSuggestionsList
473
+ );
474
+ expect(suggestionsList).not.toBeNull();
475
+
476
+ const mockRecentQuery = {
477
+ value: 'recent query',
478
+ isClearRecentQueryButton: false,
479
+ isRecentQuery: true,
480
+ };
481
+
482
+ suggestionsList.dispatchEvent(
483
+ new CustomEvent('quantic__selection', {
484
+ detail: {selection: mockRecentQuery},
485
+ })
486
+ );
487
+
488
+ expect(
489
+ functionsMocks.exampleSelectSuggestion
490
+ ).toHaveBeenCalledTimes(1);
491
+ const eventData =
492
+ functionsMocks.exampleSelectSuggestion.mock.calls[0][0];
493
+
494
+ expect(eventData?.detail).toMatchObject({
495
+ selectedSuggestion: mockRecentQuery,
496
+ });
497
+ });
498
+ });
499
+ });
500
+
501
+ describe('when typing something in the input', () => {
502
+ it('should dispatch a #quantic__inputvaluechange custom event with the input value as payload', async () => {
503
+ const element = createTestComponent({
504
+ ...defaultOptions,
505
+ textarea: textareaValue,
506
+ inputValue: mockInputValue,
507
+ });
508
+ setupEventListeners(element);
509
+ await flushPromises();
510
+
511
+ const input = element.shadowRoot.querySelector(
512
+ textareaValue
513
+ ? selectors.searchBoxTextArea
514
+ : selectors.searchBoxInput
515
+ );
516
+ expect(input).not.toBeNull();
517
+
518
+ input.dispatchEvent(new KeyboardEvent('input'));
519
+ expect(
520
+ functionsMocks.exampleHandleInputValueChange
521
+ ).toHaveBeenCalledTimes(1);
522
+
523
+ /** @type{{detail: {value: string}}} */
524
+ const eventData =
525
+ functionsMocks.exampleHandleInputValueChange.mock.calls[0][0];
526
+ expect(eventData.detail.value).toEqual(mockInputValue);
527
+ });
528
+
529
+ describe('when clicking on the submit button', () => {
530
+ it('should dispatch a #quantic__submitsearch custom event', async () => {
531
+ const element = createTestComponent({
532
+ ...defaultOptions,
533
+ textarea: textareaValue,
534
+ });
535
+ setupEventListeners(element);
536
+ await flushPromises();
537
+
538
+ const submitButton = element.shadowRoot.querySelector(
539
+ selectors.searchBoxSubmitBtn
540
+ );
541
+ expect(submitButton).not.toBeNull();
542
+
543
+ submitButton.click();
544
+
545
+ expect(
546
+ functionsMocks.exampleHandleSubmitSearch
547
+ ).toHaveBeenCalledTimes(1);
548
+ });
549
+ });
550
+
551
+ describe('when pressing the ENTER key', () => {
552
+ it('should dispatch a #quantic__submitsearch custom event', async () => {
553
+ const element = createTestComponent({
554
+ ...defaultOptions,
555
+ textarea: textareaValue,
556
+ });
557
+ setupEventListeners(element);
558
+ await flushPromises();
559
+
560
+ const input = element.shadowRoot.querySelector(
561
+ textareaValue
562
+ ? selectors.searchBoxTextArea
563
+ : selectors.searchBoxInput
564
+ );
565
+ expect(input).not.toBeNull();
566
+
567
+ await input.focus();
568
+ input.dispatchEvent(new KeyboardEvent('keydown', {key: 'Enter'}));
569
+
570
+ expect(
571
+ functionsMocks.exampleHandleSubmitSearch
572
+ ).toHaveBeenCalledTimes(1);
573
+ });
574
+
575
+ it(`${
576
+ textareaValue ? 'should not' : 'should'
577
+ } dispatch a #quantic__submitsearch custom event when the shift key is pressed along with the enter key`, async () => {
578
+ const element = createTestComponent({
579
+ ...defaultOptions,
580
+ textarea: textareaValue,
581
+ });
582
+ setupEventListeners(element);
583
+ await flushPromises();
584
+
585
+ const input = element.shadowRoot.querySelector(
586
+ textareaValue
587
+ ? selectors.searchBoxTextArea
588
+ : selectors.searchBoxInput
589
+ );
590
+ expect(input).not.toBeNull();
591
+
592
+ await input.focus();
593
+ input.dispatchEvent(
594
+ new KeyboardEvent('keydown', {key: 'Enter', shiftKey: true})
595
+ );
596
+
597
+ expect(
598
+ functionsMocks.exampleHandleSubmitSearch
599
+ ).toHaveBeenCalledTimes(textareaValue ? 0 : 1);
600
+ });
601
+ });
602
+
603
+ describe('accessibility', () => {
604
+ describe('when pressing the DOWN and UP arrow keys', () => {
605
+ it('should set the aria-activedescendant attribute of the input according to the currently active suggestion', async () => {
606
+ const element = createTestComponent({
607
+ ...defaultOptions,
608
+ suggestions: mockSuggestions,
609
+ textarea: textareaValue,
610
+ });
611
+ await flushPromises();
612
+
613
+ const input = element.shadowRoot.querySelector(
614
+ textareaValue
615
+ ? selectors.searchBoxTextArea
616
+ : selectors.searchBoxInput
617
+ );
618
+ expect(input).not.toBeNull();
619
+
620
+ await input.focus();
621
+ const suggestionsList = element.shadowRoot.querySelector(
622
+ selectors.searchBoxSuggestionsList
623
+ );
624
+ expect(suggestionsList).not.toBeNull();
625
+
626
+ const selectionDownSpy = jest.spyOn(
627
+ suggestionsList,
628
+ 'selectionDown'
629
+ );
630
+
631
+ input.dispatchEvent(
632
+ new KeyboardEvent('keydown', {key: 'ArrowDown'})
633
+ );
634
+ await flushPromises();
635
+
636
+ expect(selectionDownSpy).toHaveBeenCalledTimes(1);
637
+ const {id: selectionDownId} =
638
+ selectionDownSpy.mock.results[0].value;
639
+ expect(input.getAttribute('aria-activedescendant')).toBe(
640
+ selectionDownId
641
+ );
642
+
643
+ const selectionUpSpy = jest.spyOn(suggestionsList, 'selectionUp');
644
+
645
+ input.dispatchEvent(
646
+ new KeyboardEvent('keydown', {key: 'ArrowUp'})
647
+ );
648
+ await flushPromises();
649
+
650
+ expect(selectionUpSpy).toHaveBeenCalledTimes(1);
651
+ const {id: selectionUpId} = selectionUpSpy.mock.results[0].value;
652
+ expect(input.getAttribute('aria-activedescendant')).toBe(
653
+ selectionUpId
654
+ );
655
+
656
+ await input.blur();
657
+ expect(input.getAttribute('aria-activedescendant')).toBeNull();
658
+ });
659
+ });
660
+
661
+ describe('when the search box input is rendered', () => {
662
+ it('should set the aria-controls attribute of the input according to the id of the suggestions listbox', async () => {
663
+ const element = createTestComponent({
664
+ ...defaultOptions,
665
+ suggestions: mockSuggestions,
666
+ textarea: textareaValue,
667
+ });
668
+ await flushPromises();
669
+
670
+ const input = element.shadowRoot.querySelector(
671
+ textareaValue
672
+ ? selectors.searchBoxTextArea
673
+ : selectors.searchBoxInput
674
+ );
675
+ expect(input).not.toBeNull();
676
+
677
+ await input.focus();
678
+ const suggestionsList = element.shadowRoot.querySelector(
679
+ selectors.searchBoxSuggestionsList
680
+ );
681
+ const suggestionsListBox =
682
+ suggestionsList.shadowRoot.querySelector(
683
+ selectors.SuggestionsListBox
684
+ );
685
+ expect(suggestionsList).not.toBeNull();
686
+ expect(suggestionsListBox).not.toBeNull();
687
+
688
+ expect(input.getAttribute('aria-controls')).toBe(
689
+ suggestionsListBox.id
690
+ );
691
+ });
692
+ });
693
+ });
694
+ });
695
+
696
+ describe('when clicking on the clear icon after typing something', () => {
697
+ it('should properly clear the input value', async () => {
698
+ const element = createTestComponent({
699
+ ...defaultOptions,
700
+ textarea: textareaValue,
701
+ });
702
+ await flushPromises();
703
+
704
+ element.inputValue = mockLongInputValue;
705
+ await flushPromises();
706
+
707
+ const clearIcon = element.shadowRoot.querySelector(
708
+ selectors.searchBoxClearIcon
709
+ );
710
+ const input = element.shadowRoot.querySelector(
711
+ textareaValue
712
+ ? selectors.searchBoxTextArea
713
+ : selectors.searchBoxInput
714
+ );
715
+
716
+ expect(input).not.toBeNull();
717
+ expect(input.value).toEqual(mockLongInputValue);
718
+
719
+ clearIcon.click();
720
+ expect(input.value).toEqual('');
721
+ const expectedCollapsedInputHeight = textareaValue ? '0px' : '';
722
+ expect(input.style.height).toEqual(expectedCollapsedInputHeight);
723
+ });
724
+ });
725
+
726
+ describe('when the component renders with a value in the input', () => {
727
+ it('should display the clear icon', async () => {
728
+ const element = createTestComponent({
729
+ ...defaultOptions,
730
+ inputValue: mockInputValue,
731
+ textarea: textareaValue,
732
+ });
733
+ await flushPromises();
734
+
735
+ const clearIcon = element.shadowRoot.querySelector(
736
+ selectors.searchBoxClearIcon
737
+ );
738
+ expect(clearIcon).not.toBeNull();
739
+ });
740
+ });
741
+ });
742
+ });
743
+ });