@coveo/quantic 3.44.1 → 3.44.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -3
- package/force-app/main/default/classes/OrganizationEndpointsTest.cls +71 -15
- package/force-app/main/default/classes/RecommendationsControllerTest.cls +1 -1
- package/force-app/main/default/lwc/quanticCitation/quanticCitation.js +2 -2
- package/force-app/main/default/lwc/quanticHeadlessLoader/quanticHeadlessLoader.js +158 -87
- package/force-app/main/default/lwc/quanticTabBar/quanticTabBar.js +148 -125
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +16 -16
- package/force-app/main/default/staticresources/coveoheadless/headless.js +17 -17
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +16 -16
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +16 -16
- package/force-app/main/default/staticresources/dompurify/purify.min.js +2 -2
- package/package.json +43 -41
- package/force-app/main/default/lwc/quanticAriaLive/__tests__/quanticAriaLive.test.js +0 -106
- package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +0 -752
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/data.ts +0 -130
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/fixture.ts +0 -87
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/pageObject.ts +0 -282
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/quanticBreadcrumbManager.e2e.ts +0 -208
- package/force-app/main/default/lwc/quanticCarousel/__tests__/quanticCarousel.test.js +0 -262
- package/force-app/main/default/lwc/quanticCaseClassification/__tests__/quanticCaseClassification.test.js +0 -819
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/data.ts +0 -23
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/fixture.ts +0 -51
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/pageObject.ts +0 -152
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/quanticCaseClassification.e2e.ts +0 -269
- package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +0 -1183
- package/force-app/main/default/lwc/quanticCategoryFacet/e2e/data.ts +0 -91
- package/force-app/main/default/lwc/quanticCategoryFacet/e2e/fixture.ts +0 -79
- package/force-app/main/default/lwc/quanticCategoryFacet/e2e/pageObject.ts +0 -55
- package/force-app/main/default/lwc/quanticCategoryFacet/e2e/quanticCategoryFacet.e2e.ts +0 -219
- package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +0 -581
- package/force-app/main/default/lwc/quanticColoredResultBadge/__tests__/quanticColoredResultBadge.test.js +0 -212
- package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +0 -688
- package/force-app/main/default/lwc/quanticDateFacet/e2e/data.ts +0 -44
- package/force-app/main/default/lwc/quanticDateFacet/e2e/fixture.ts +0 -72
- package/force-app/main/default/lwc/quanticDateFacet/e2e/pageObject.ts +0 -27
- package/force-app/main/default/lwc/quanticDateFacet/e2e/quanticDateFacet.e2e.ts +0 -167
- package/force-app/main/default/lwc/quanticDidYouMean/__tests__/quanticDidYouMean.test.js +0 -348
- package/force-app/main/default/lwc/quanticDidYouMean/e2e/data.ts +0 -48
- package/force-app/main/default/lwc/quanticDidYouMean/e2e/fixture.ts +0 -84
- package/force-app/main/default/lwc/quanticDidYouMean/e2e/pageObject.ts +0 -173
- package/force-app/main/default/lwc/quanticDidYouMean/e2e/quanticDidYouMean.e2e.ts +0 -219
- package/force-app/main/default/lwc/quanticDocumentSuggestion/__tests__/quanticDocumentSuggestion.test.js +0 -404
- package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/fixture.ts +0 -38
- package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/pageObject.ts +0 -52
- package/force-app/main/default/lwc/quanticDocumentSuggestion/e2e/quanticDocumentSuggestion.e2e.ts +0 -102
- package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +0 -1105
- package/force-app/main/default/lwc/quanticFacet/e2e/data.ts +0 -62
- package/force-app/main/default/lwc/quanticFacet/e2e/fixture.ts +0 -78
- package/force-app/main/default/lwc/quanticFacet/e2e/pageObject.ts +0 -67
- package/force-app/main/default/lwc/quanticFacet/e2e/quanticFacet.e2e.ts +0 -242
- package/force-app/main/default/lwc/quanticFacetCaption/__tests__/quanticFacetCaption.test.js +0 -28
- package/force-app/main/default/lwc/quanticFacetManager/__tests__/quanticFacetManager.test.js +0 -178
- package/force-app/main/default/lwc/quanticFacetManager/e2e/data.ts +0 -59
- package/force-app/main/default/lwc/quanticFacetManager/e2e/fixture.ts +0 -75
- package/force-app/main/default/lwc/quanticFacetManager/e2e/pageObject.ts +0 -23
- package/force-app/main/default/lwc/quanticFacetManager/e2e/quanticFacetManager.e2e.ts +0 -82
- package/force-app/main/default/lwc/quanticFeedback/__tests__/quanticFeedback.test.js +0 -403
- package/force-app/main/default/lwc/quanticFeedbackModal/__tests__/quanticFeedbackModal.test.js +0 -448
- package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +0 -298
- package/force-app/main/default/lwc/quanticFoldedResultList/__tests__/quanticFoldedResultList.test.js +0 -323
- package/force-app/main/default/lwc/quanticFoldedResultList/e2e/fixture.ts +0 -74
- package/force-app/main/default/lwc/quanticFoldedResultList/e2e/pageObject.ts +0 -81
- package/force-app/main/default/lwc/quanticFoldedResultList/e2e/quanticFoldedResultList.e2e.ts +0 -69
- package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +0 -1575
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/agentData.ts +0 -279
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +0 -56
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture-agent.ts +0 -77
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +0 -194
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +0 -599
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +0 -333
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswerAgent.e2e.ts +0 -298
- package/force-app/main/default/lwc/quanticGeneratedAnswerBody/__tests__/quanticGeneratedAnswerBody.test.js +0 -418
- package/force-app/main/default/lwc/quanticGeneratedAnswerContent/__tests__/quanticGeneratedAnswerContent.test.js +0 -447
- package/force-app/main/default/lwc/quanticGeneratedAnswerCopyToClipboard/__tests__/quanticGeneratedAnswerCopyToClipboard.test.js +0 -129
- package/force-app/main/default/lwc/quanticGeneratedAnswerFollowUpInput/__tests__/quanticGeneratedAnswerFollowUpInput.test.js +0 -466
- package/force-app/main/default/lwc/quanticGeneratedAnswerStreamOfThought/__tests__/quanticGeneratedAnswerStreamOfThought.test.js +0 -402
- package/force-app/main/default/lwc/quanticGeneratedAnswerStreamOfThought/__tests__/stepsUtils.test.js +0 -118
- package/force-app/main/default/lwc/quanticGeneratedAnswerThread/__tests__/quanticGeneratedAnswerThread.test.js +0 -285
- package/force-app/main/default/lwc/quanticHeading/__tests__/quanticHeading.test.js +0 -71
- package/force-app/main/default/lwc/quanticHeadlessLoader/__tests__/quanticHeadlessLoader.test.js +0 -651
- package/force-app/main/default/lwc/quanticInsightInterface/__tests__/quanticInsightInterface.test.js +0 -194
- package/force-app/main/default/lwc/quanticInsightSummary/__tests__/quanticInsightSummary.test.js +0 -230
- package/force-app/main/default/lwc/quanticModal/__tests__/quanticModal.test.js +0 -205
- package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +0 -309
- package/force-app/main/default/lwc/quanticNotifications/e2e/fixture.ts +0 -62
- package/force-app/main/default/lwc/quanticNotifications/e2e/pageObject.ts +0 -55
- package/force-app/main/default/lwc/quanticNotifications/e2e/quanticNotifications.e2e.ts +0 -47
- package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +0 -953
- package/force-app/main/default/lwc/quanticNumericFacet/e2e/data.ts +0 -48
- package/force-app/main/default/lwc/quanticNumericFacet/e2e/fixture.ts +0 -75
- package/force-app/main/default/lwc/quanticNumericFacet/e2e/pageObject.ts +0 -59
- package/force-app/main/default/lwc/quanticNumericFacet/e2e/quanticNumericFacet.e2e.ts +0 -186
- package/force-app/main/default/lwc/quanticPager/__tests__/quanticPager.test.js +0 -430
- package/force-app/main/default/lwc/quanticPager/e2e/fixture.ts +0 -65
- package/force-app/main/default/lwc/quanticPager/e2e/pageObject.ts +0 -69
- package/force-app/main/default/lwc/quanticPager/e2e/quanticPager.e2e.ts +0 -106
- package/force-app/main/default/lwc/quanticPlaceholder/__tests__/quanticPlaceholder.test.js +0 -47
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/defaultTestCase.json +0 -13
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/youtubeTestCase.json +0 -14
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/quanticQuickviewContent.test.js +0 -82
- package/force-app/main/default/lwc/quanticRadioButtonsGroup/__tests__/quanticRadioButtonsGroup.test.js +0 -273
- package/force-app/main/default/lwc/quanticRecentQueriesList/__tests__/quanticRecentQueriesList.test.js +0 -448
- package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/fixture.ts +0 -43
- package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/pageObject.ts +0 -55
- package/force-app/main/default/lwc/quanticRecentQueriesList/e2e/quanticRecentQueriesList.e2e.ts +0 -93
- package/force-app/main/default/lwc/quanticRecentResultsList/__tests__/quanticRecentResultsList.test.js +0 -516
- package/force-app/main/default/lwc/quanticRecentResultsList/e2e/fixture.ts +0 -43
- package/force-app/main/default/lwc/quanticRecentResultsList/e2e/pageObject.ts +0 -61
- package/force-app/main/default/lwc/quanticRecentResultsList/e2e/quanticRecentResultsList.e2e.ts +0 -48
- package/force-app/main/default/lwc/quanticRecommendationList/__tests__/quanticRecommendationList.test.js +0 -491
- package/force-app/main/default/lwc/quanticRecommendationList/e2e/fixture.ts +0 -36
- package/force-app/main/default/lwc/quanticRecommendationList/e2e/pageObject.ts +0 -52
- package/force-app/main/default/lwc/quanticRecommendationList/e2e/quanticRecommendationList.e2e.ts +0 -53
- package/force-app/main/default/lwc/quanticRefineModalContent/__tests__/quanticRefineModalContent.test.js +0 -747
- package/force-app/main/default/lwc/quanticRefineToggle/__tests__/quanticRefineToggle.test.js +0 -544
- package/force-app/main/default/lwc/quanticResultAction/__tests__/quanticResultAction.test.js +0 -262
- package/force-app/main/default/lwc/quanticResultActionBar/__tests__/quanticResultActionBar.test.js +0 -141
- package/force-app/main/default/lwc/quanticResultChildren/__tests__/quanticResultChildren.test.js +0 -340
- package/force-app/main/default/lwc/quanticResultCopyToClipboard/__tests__/quanticResultCopyToClipboard.test.js +0 -300
- package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/fixture.ts +0 -49
- package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/pageObject.ts +0 -49
- package/force-app/main/default/lwc/quanticResultCopyToClipboard/e2e/quanticResultCopyToClipboard.e2e.ts +0 -40
- package/force-app/main/default/lwc/quanticResultDate/__tests__/quanticResultDate.test.js +0 -144
- package/force-app/main/default/lwc/quanticResultField/__tests__/quanticResultField.test.js +0 -120
- package/force-app/main/default/lwc/quanticResultHighlightedTextField/__tests__/quanticResultHighlightedTextField.test.js +0 -209
- package/force-app/main/default/lwc/quanticResultLink/__tests__/quanticResultLink.test.js +0 -302
- package/force-app/main/default/lwc/quanticResultList/__tests__/quanticResultList.test.js +0 -342
- package/force-app/main/default/lwc/quanticResultList/e2e/fixture.ts +0 -70
- package/force-app/main/default/lwc/quanticResultList/e2e/pageObject.ts +0 -81
- package/force-app/main/default/lwc/quanticResultList/e2e/quanticResultList.e2e.ts +0 -69
- package/force-app/main/default/lwc/quanticResultMultiValueText/__tests__/quanticResultMultiValueText.test.js +0 -235
- package/force-app/main/default/lwc/quanticResultNumber/__tests__/quanticResultNumber.test.js +0 -144
- package/force-app/main/default/lwc/quanticResultPrintableUri/__tests__/quanticResultPrintableUri.test.js +0 -324
- package/force-app/main/default/lwc/quanticResultQuickview/__tests__/quanticResultQuickview.test.js +0 -308
- package/force-app/main/default/lwc/quanticResultQuickview/e2e/fixture.ts +0 -85
- package/force-app/main/default/lwc/quanticResultQuickview/e2e/pageObject.ts +0 -38
- package/force-app/main/default/lwc/quanticResultQuickview/e2e/quanticResultQuickView.e2e.ts +0 -66
- package/force-app/main/default/lwc/quanticResultTemplate/__tests__/quanticResultTemplate.test.js +0 -90
- package/force-app/main/default/lwc/quanticResultText/__tests__/quanticResultText.test.js +0 -155
- package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js +0 -464
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +0 -78
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/pageObject.ts +0 -85
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/quanticResultsPerPage.e2e.ts +0 -97
- package/force-app/main/default/lwc/quanticSearchBox/__tests__/quanticSearchBox.test.js +0 -487
- package/force-app/main/default/lwc/quanticSearchBox/e2e/fixture.ts +0 -86
- package/force-app/main/default/lwc/quanticSearchBox/e2e/pageObject.ts +0 -45
- package/force-app/main/default/lwc/quanticSearchBox/e2e/quanticSearchBox.e2e.ts +0 -159
- package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js +0 -743
- package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/__tests__/quanticSearchBoxSuggestionsList.test.js +0 -571
- package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/fixture.ts +0 -113
- package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/pageObject.ts +0 -113
- package/force-app/main/default/lwc/quanticSearchBoxSuggestionsList/e2e/quanticSearchBoxSuggestionsList.e2e.ts +0 -282
- package/force-app/main/default/lwc/quanticSmartSnippet/__tests__/quanticSmartSnippet.test.js +0 -341
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/data.ts +0 -21
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/fixture.ts +0 -93
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +0 -196
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +0 -168
- package/force-app/main/default/lwc/quanticSmartSnippetAnswer/__tests__/quanticSmartSnippetAnswer.test.js +0 -126
- package/force-app/main/default/lwc/quanticSmartSnippetSource/__tests__/quanticSmartSnippetSource.test.js +0 -290
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/__tests__/quanticSmartSnippetSuggestions.test.js +0 -329
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/data.ts +0 -31
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/fixture.ts +0 -95
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/pageObject.ts +0 -160
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/quanticSmartSnippetSuggestions.e2e.ts +0 -127
- package/force-app/main/default/lwc/quanticSort/__tests__/quanticSort.test.js +0 -416
- package/force-app/main/default/lwc/quanticSort/e2e/fixture.ts +0 -62
- package/force-app/main/default/lwc/quanticSort/e2e/pageObject.ts +0 -100
- package/force-app/main/default/lwc/quanticSort/e2e/quanticSort.e2e.ts +0 -86
- package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +0 -156
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/__tests__/quanticStandaloneSearchBox.test.js +0 -387
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/fixture.ts +0 -54
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/pageObject.ts +0 -54
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/e2e/quanticStandaloneSearchBox.e2e.ts +0 -72
- package/force-app/main/default/lwc/quanticStatefulButton/__tests__/quanticStatefulButton.test.js +0 -222
- package/force-app/main/default/lwc/quanticSummary/__tests__/quanticSummary.test.js +0 -244
- package/force-app/main/default/lwc/quanticTab/__tests__/quanticTab.test.js +0 -333
- package/force-app/main/default/lwc/quanticTab/e2e/fixture.ts +0 -60
- package/force-app/main/default/lwc/quanticTab/e2e/pageObject.ts +0 -68
- package/force-app/main/default/lwc/quanticTab/e2e/quanticTab.e2e.ts +0 -72
- package/force-app/main/default/lwc/quanticTabBar/__tests__/quanticTabBar.test.js +0 -331
- package/force-app/main/default/lwc/quanticTabBar/e2e/fixture.ts +0 -65
- package/force-app/main/default/lwc/quanticTabBar/e2e/pageObject.ts +0 -80
- package/force-app/main/default/lwc/quanticTabBar/e2e/quanticTabBar.e2e.ts +0 -172
- package/force-app/main/default/lwc/quanticThreadItem/__tests__/quanticThreadItem.test.js +0 -314
- package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +0 -1059
- package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/data.ts +0 -66
- package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/fixture.ts +0 -74
- package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/pageObject.ts +0 -43
- package/force-app/main/default/lwc/quanticTimeframeFacet/e2e/quanticTimeframeFacet.e2e.ts +0 -184
- package/force-app/main/default/lwc/quanticTooltip/__tests__/quanticTooltip.test.js +0 -107
- package/force-app/main/default/lwc/quanticUserAction/__tests__/quanticUserAction.test.js +0 -427
- package/force-app/main/default/lwc/quanticUserActionsSession/__tests__/quanticUserActionsSession.test.js +0 -269
- package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/data/userActionsState.json +0 -89
- package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/quanticUserActionsTimeline.test.js +0 -511
- package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +0 -229
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +0 -32
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +0 -32
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +0 -71
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +0 -39
- package/force-app/main/default/lwc/quanticUtils/__tests__/accessibilityUtils.test.js +0 -214
- package/force-app/main/default/lwc/quanticUtils/__tests__/citationAnchoringUtils.test.js +0 -84
- package/force-app/main/default/lwc/quanticUtils/__tests__/facetDependenciesUtils.test.js +0 -92
- package/force-app/main/default/lwc/quanticUtils/__tests__/facetStoreUtils.test.js +0 -86
- package/force-app/main/default/lwc/quanticUtils/__tests__/markdownUtils.test.js +0 -109
- package/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js +0 -233
- package/force-app/main/default/lwc/quanticUtils/__tests__/timeAndDateUtils.test.js +0 -22
- package/force-app/main/default/lwc/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +0 -131
package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js
DELETED
|
@@ -1,743 +0,0 @@
|
|
|
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
|
-
});
|