@coveo/quantic 3.44.0 → 3.44.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/quanticNumberButton/quanticNumberButton.js +5 -1
- package/force-app/main/default/lwc/quanticPager/quanticPager.html +8 -5
- 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/package.json +37 -34
- 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
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-import-assign */
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import QuanticGeneratedAnswerContent from 'c/quanticGeneratedAnswerContent';
|
|
4
|
-
import {createElement} from 'lwc';
|
|
5
|
-
import {loadMarkdownDependencies} from 'c/quanticUtils';
|
|
6
|
-
import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
|
|
7
|
-
|
|
8
|
-
const mockAnswerHeight = 250;
|
|
9
|
-
|
|
10
|
-
jest.mock('c/quanticHeadlessLoader');
|
|
11
|
-
jest.mock('c/quanticUtils', () => ({
|
|
12
|
-
loadMarkdownDependencies: jest.fn(
|
|
13
|
-
() =>
|
|
14
|
-
new Promise((resolve) => {
|
|
15
|
-
resolve();
|
|
16
|
-
})
|
|
17
|
-
),
|
|
18
|
-
transformMarkdownToHtml: jest.fn((value) => value),
|
|
19
|
-
LinkUtils: {
|
|
20
|
-
bindAnalyticsToLink: jest.fn(() => jest.fn()),
|
|
21
|
-
},
|
|
22
|
-
getAbsoluteHeight: jest.fn(() => mockAnswerHeight),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
const mockMarkedUse = jest.fn();
|
|
26
|
-
const mockMarkedParse = jest.fn((text) => text);
|
|
27
|
-
global.marked = {
|
|
28
|
-
use: mockMarkedUse,
|
|
29
|
-
parse: mockMarkedParse,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const SELECTORS = {
|
|
33
|
-
textAnswerContainer: 'span.generated-answer-content__answer',
|
|
34
|
-
markdownAnswerContainer: 'div.generated-answer-content__answer',
|
|
35
|
-
inlineLink: 'a[data-answer-inline-link]',
|
|
36
|
-
inlineLinkIconContainer: 'span.slds-icon_container',
|
|
37
|
-
inlineLinkIconSvg: 'svg.slds-icon',
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const exampleEngineId = 'example-engine-id';
|
|
41
|
-
const exampleAnswerId = 'example-answer-id';
|
|
42
|
-
|
|
43
|
-
const defaultOptions = {
|
|
44
|
-
isStreaming: false,
|
|
45
|
-
answerContentFormat: 'text/plain',
|
|
46
|
-
answer: '',
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const exampleEngine = {id: 'dummy-engine'};
|
|
50
|
-
let isInitialized = false;
|
|
51
|
-
|
|
52
|
-
const mockBuildInteractiveGeneratedAnswerInlineLink = jest.fn(() => ({
|
|
53
|
-
select: jest.fn(),
|
|
54
|
-
beginDelayedSelect: jest.fn(),
|
|
55
|
-
cancelPendingSelect: jest.fn(),
|
|
56
|
-
}));
|
|
57
|
-
|
|
58
|
-
function prepareHeadlessState() {
|
|
59
|
-
// @ts-ignore
|
|
60
|
-
mockHeadlessLoader.getHeadlessBundle = () => ({
|
|
61
|
-
buildInteractiveGeneratedAnswerInlineLink:
|
|
62
|
-
mockBuildInteractiveGeneratedAnswerInlineLink,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function mockSuccessfulHeadlessInitialization() {
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
69
|
-
if (element instanceof QuanticGeneratedAnswerContent && !isInitialized) {
|
|
70
|
-
isInitialized = true;
|
|
71
|
-
initialize(exampleEngine);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function createTestComponent(options = defaultOptions) {
|
|
77
|
-
const element = createElement('c-quantic-generated-answer-content', {
|
|
78
|
-
is: QuanticGeneratedAnswerContent,
|
|
79
|
-
});
|
|
80
|
-
for (const [key, value] of Object.entries(options)) {
|
|
81
|
-
element[key] = value;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
document.body.appendChild(element);
|
|
85
|
-
return element;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Builds an HTML string containing anchor tags with the data-answer-inline-link
|
|
90
|
-
* attribute, which is what the component's processInlineLinks method targets.
|
|
91
|
-
* @param {Array<{href: string, text: string}>} links
|
|
92
|
-
* @returns {string}
|
|
93
|
-
*/
|
|
94
|
-
function buildAnswerWithInlineLinks(links) {
|
|
95
|
-
return links
|
|
96
|
-
.map(
|
|
97
|
-
({href, text}) => `<a href="${href}" data-answer-inline-link>${text}</a>`
|
|
98
|
-
)
|
|
99
|
-
.join(' ');
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Helper function to wait until the microtask queue is empty.
|
|
103
|
-
function flushPromises() {
|
|
104
|
-
// eslint-disable-next-line @lwc/lwc/no-async-operation
|
|
105
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
describe('c-quantic-generated-answer-content', () => {
|
|
109
|
-
function cleanup() {
|
|
110
|
-
// The jsdom instance is shared across test cases in a single file so reset the DOM
|
|
111
|
-
while (document.body.firstChild) {
|
|
112
|
-
document.body.removeChild(document.body.firstChild);
|
|
113
|
-
}
|
|
114
|
-
jest.clearAllMocks();
|
|
115
|
-
isInitialized = false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
afterEach(() => {
|
|
119
|
-
cleanup();
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('text/plain answer content', () => {
|
|
123
|
-
it('should render a simple text/plain answer when not streaming', async () => {
|
|
124
|
-
const element = createTestComponent({
|
|
125
|
-
...defaultOptions,
|
|
126
|
-
answer: 'Hello, world!',
|
|
127
|
-
});
|
|
128
|
-
await flushPromises();
|
|
129
|
-
|
|
130
|
-
const answerContent = element.shadowRoot.querySelector(
|
|
131
|
-
SELECTORS.textAnswerContainer
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
expect(answerContent.textContent).toBe('Hello, world!');
|
|
135
|
-
expect(answerContent.className).toBe('generated-answer-content__answer');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('should render a text/plain answer when streaming', async () => {
|
|
139
|
-
const element = createTestComponent({
|
|
140
|
-
...defaultOptions,
|
|
141
|
-
answer: 'Hello, world!',
|
|
142
|
-
isStreaming: true,
|
|
143
|
-
});
|
|
144
|
-
await flushPromises();
|
|
145
|
-
|
|
146
|
-
const answerContent = element.shadowRoot.querySelector(
|
|
147
|
-
SELECTORS.textAnswerContainer
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
expect(answerContent.textContent).toBe('Hello, world!');
|
|
151
|
-
expect(answerContent.className).toContain(
|
|
152
|
-
'generated-answer-content__answer--streaming'
|
|
153
|
-
);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
describe('text/markdown answer content', () => {
|
|
158
|
-
it('should render a simple markdown answer when not streaming', async () => {
|
|
159
|
-
const element = createTestComponent({
|
|
160
|
-
...defaultOptions,
|
|
161
|
-
answerContentFormat: 'text/markdown',
|
|
162
|
-
answer: 'Hello, world!',
|
|
163
|
-
});
|
|
164
|
-
await flushPromises();
|
|
165
|
-
|
|
166
|
-
const answerContent = element.shadowRoot.querySelector(
|
|
167
|
-
SELECTORS.markdownAnswerContainer
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
expect(answerContent.textContent).toBe('Hello, world!');
|
|
171
|
-
expect(answerContent.className).toBe('generated-answer-content__answer');
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('should render a simple markdown answer when streaming', async () => {
|
|
175
|
-
const element = createTestComponent({
|
|
176
|
-
...defaultOptions,
|
|
177
|
-
answerContentFormat: 'text/markdown',
|
|
178
|
-
answer: 'Hello, world!',
|
|
179
|
-
isStreaming: true,
|
|
180
|
-
});
|
|
181
|
-
await flushPromises();
|
|
182
|
-
|
|
183
|
-
const answerContent = element.shadowRoot.querySelector(
|
|
184
|
-
SELECTORS.markdownAnswerContainer
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
expect(answerContent.textContent).toBe('Hello, world!');
|
|
188
|
-
expect(answerContent.className).toContain(
|
|
189
|
-
'generated-answer-content__answer--streaming'
|
|
190
|
-
);
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
describe('the reactivity of the answerContentFormat property', () => {
|
|
195
|
-
it('should load the markdown dependencies when the answerContentFormat property is changed to text/markdown', async () => {
|
|
196
|
-
const element = createTestComponent({
|
|
197
|
-
...defaultOptions,
|
|
198
|
-
answerContentFormat: 'text/plain',
|
|
199
|
-
});
|
|
200
|
-
await flushPromises();
|
|
201
|
-
expect(loadMarkdownDependencies).not.toHaveBeenCalled();
|
|
202
|
-
|
|
203
|
-
element.answerContentFormat = 'text/markdown';
|
|
204
|
-
await flushPromises();
|
|
205
|
-
expect(loadMarkdownDependencies).toHaveBeenCalled();
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
describe('inline links in a markdown answer', () => {
|
|
210
|
-
const exampleLinks = [
|
|
211
|
-
{href: 'https://example.com/1', text: 'Link one'},
|
|
212
|
-
{href: 'https://example.com/2', text: 'Link two'},
|
|
213
|
-
];
|
|
214
|
-
|
|
215
|
-
beforeEach(() => {
|
|
216
|
-
mockSuccessfulHeadlessInitialization();
|
|
217
|
-
prepareHeadlessState();
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
describe('when the answer contains anchors with data-answer-inline-link', () => {
|
|
221
|
-
it('should set target="_blank" and append an icon span to each inline link anchor', async () => {
|
|
222
|
-
const {LinkUtils} = jest.requireMock('c/quanticUtils');
|
|
223
|
-
LinkUtils.bindAnalyticsToLink.mockReturnValue(jest.fn());
|
|
224
|
-
|
|
225
|
-
const element = createTestComponent({
|
|
226
|
-
...defaultOptions,
|
|
227
|
-
engineId: exampleEngineId,
|
|
228
|
-
answerId: exampleAnswerId,
|
|
229
|
-
answerContentFormat: 'text/markdown',
|
|
230
|
-
answer: buildAnswerWithInlineLinks(exampleLinks),
|
|
231
|
-
});
|
|
232
|
-
await flushPromises();
|
|
233
|
-
|
|
234
|
-
const answerContainer = element.shadowRoot.querySelector(
|
|
235
|
-
SELECTORS.markdownAnswerContainer
|
|
236
|
-
);
|
|
237
|
-
const anchors = answerContainer.querySelectorAll(SELECTORS.inlineLink);
|
|
238
|
-
|
|
239
|
-
expect(anchors).toHaveLength(exampleLinks.length);
|
|
240
|
-
anchors.forEach((anchor) => {
|
|
241
|
-
expect(anchor.target).toBe('_blank');
|
|
242
|
-
});
|
|
243
|
-
anchors.forEach((anchor) => {
|
|
244
|
-
const iconSpan = anchor.querySelector(
|
|
245
|
-
SELECTORS.inlineLinkIconContainer
|
|
246
|
-
);
|
|
247
|
-
expect(iconSpan).not.toBeNull();
|
|
248
|
-
expect(iconSpan.classList).toContain('slds-icon-utility-new_window');
|
|
249
|
-
expect(iconSpan.classList).toContain('slds-current-color');
|
|
250
|
-
expect(
|
|
251
|
-
iconSpan.querySelector(SELECTORS.inlineLinkIconSvg)
|
|
252
|
-
).not.toBeNull();
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('should call buildInteractiveGeneratedAnswerInlineLink with the correct parameters for each inline link', async () => {
|
|
257
|
-
const {LinkUtils} = jest.requireMock('c/quanticUtils');
|
|
258
|
-
LinkUtils.bindAnalyticsToLink.mockReturnValue(jest.fn());
|
|
259
|
-
|
|
260
|
-
createTestComponent({
|
|
261
|
-
...defaultOptions,
|
|
262
|
-
engineId: exampleEngineId,
|
|
263
|
-
answerId: exampleAnswerId,
|
|
264
|
-
answerContentFormat: 'text/markdown',
|
|
265
|
-
answer: buildAnswerWithInlineLinks(exampleLinks),
|
|
266
|
-
});
|
|
267
|
-
await flushPromises();
|
|
268
|
-
|
|
269
|
-
expect(
|
|
270
|
-
mockBuildInteractiveGeneratedAnswerInlineLink
|
|
271
|
-
).toHaveBeenCalledTimes(exampleLinks.length);
|
|
272
|
-
expect(LinkUtils.bindAnalyticsToLink).toHaveBeenCalledTimes(
|
|
273
|
-
exampleLinks.length
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
exampleLinks.forEach((anchor, index) => {
|
|
277
|
-
expect(
|
|
278
|
-
mockBuildInteractiveGeneratedAnswerInlineLink
|
|
279
|
-
).toHaveBeenNthCalledWith(index + 1, exampleEngine, {
|
|
280
|
-
options: {
|
|
281
|
-
link: {
|
|
282
|
-
linkURL: anchor.href,
|
|
283
|
-
linkText: anchor.text,
|
|
284
|
-
},
|
|
285
|
-
answerId: exampleAnswerId,
|
|
286
|
-
},
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it('should call LinkUtils.bindAnalyticsToLink for each inline link with the anchor and its controller', async () => {
|
|
292
|
-
const {LinkUtils} = jest.requireMock('c/quanticUtils');
|
|
293
|
-
const mockUnbind = jest.fn();
|
|
294
|
-
LinkUtils.bindAnalyticsToLink.mockReturnValue(mockUnbind);
|
|
295
|
-
|
|
296
|
-
const element = createTestComponent({
|
|
297
|
-
...defaultOptions,
|
|
298
|
-
engineId: exampleEngineId,
|
|
299
|
-
answerId: exampleAnswerId,
|
|
300
|
-
answerContentFormat: 'text/markdown',
|
|
301
|
-
answer: buildAnswerWithInlineLinks(exampleLinks),
|
|
302
|
-
});
|
|
303
|
-
await flushPromises();
|
|
304
|
-
|
|
305
|
-
expect(LinkUtils.bindAnalyticsToLink).toHaveBeenCalledTimes(
|
|
306
|
-
exampleLinks.length
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
const answerContainer = element.shadowRoot.querySelector(
|
|
310
|
-
SELECTORS.markdownAnswerContainer
|
|
311
|
-
);
|
|
312
|
-
const anchors = Array.from(
|
|
313
|
-
answerContainer.querySelectorAll(SELECTORS.inlineLink)
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
anchors.forEach((anchor, index) => {
|
|
317
|
-
expect(LinkUtils.bindAnalyticsToLink).toHaveBeenNthCalledWith(
|
|
318
|
-
index + 1,
|
|
319
|
-
anchor,
|
|
320
|
-
expect.objectContaining({
|
|
321
|
-
select: expect.any(Function),
|
|
322
|
-
beginDelayedSelect: expect.any(Function),
|
|
323
|
-
cancelPendingSelect: expect.any(Function),
|
|
324
|
-
})
|
|
325
|
-
);
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
describe('when the answer does not contain anchors with data-answer-inline-link', () => {
|
|
331
|
-
it('should not call buildInteractiveGeneratedAnswerInlineLink and LinkUtils.bindAnalyticsToLink', async () => {
|
|
332
|
-
const {LinkUtils} = jest.requireMock('c/quanticUtils');
|
|
333
|
-
|
|
334
|
-
createTestComponent({
|
|
335
|
-
...defaultOptions,
|
|
336
|
-
engineId: exampleEngineId,
|
|
337
|
-
answerId: exampleAnswerId,
|
|
338
|
-
answerContentFormat: 'text/markdown',
|
|
339
|
-
answer: '<p>No inline links here</p>',
|
|
340
|
-
});
|
|
341
|
-
await flushPromises();
|
|
342
|
-
|
|
343
|
-
expect(
|
|
344
|
-
mockBuildInteractiveGeneratedAnswerInlineLink
|
|
345
|
-
).not.toHaveBeenCalled();
|
|
346
|
-
expect(LinkUtils.bindAnalyticsToLink).not.toHaveBeenCalled();
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
describe('when the headless bundle does not expose buildInteractiveGeneratedAnswerInlineLink', () => {
|
|
351
|
-
it('should not throw and should not call LinkUtils.bindAnalyticsToLink', async () => {
|
|
352
|
-
// @ts-ignore
|
|
353
|
-
mockHeadlessLoader.getHeadlessBundle = () => ({});
|
|
354
|
-
const {LinkUtils} = jest.requireMock('c/quanticUtils');
|
|
355
|
-
|
|
356
|
-
expect(() => {
|
|
357
|
-
createTestComponent({
|
|
358
|
-
...defaultOptions,
|
|
359
|
-
engineId: exampleEngineId,
|
|
360
|
-
answerId: exampleAnswerId,
|
|
361
|
-
answerContentFormat: 'text/markdown',
|
|
362
|
-
answer: buildAnswerWithInlineLinks(exampleLinks),
|
|
363
|
-
});
|
|
364
|
-
}).not.toThrow();
|
|
365
|
-
|
|
366
|
-
await flushPromises();
|
|
367
|
-
|
|
368
|
-
expect(LinkUtils.bindAnalyticsToLink).not.toHaveBeenCalled();
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
describe('when the answer is updated', () => {
|
|
373
|
-
it('should clean up previous inline link bindings before processing the new answer', async () => {
|
|
374
|
-
const {LinkUtils} = jest.requireMock('c/quanticUtils');
|
|
375
|
-
const mockUnbind = jest.fn();
|
|
376
|
-
LinkUtils.bindAnalyticsToLink.mockReturnValue(mockUnbind);
|
|
377
|
-
|
|
378
|
-
const element = createTestComponent({
|
|
379
|
-
...defaultOptions,
|
|
380
|
-
engineId: exampleEngineId,
|
|
381
|
-
answerId: exampleAnswerId,
|
|
382
|
-
answerContentFormat: 'text/markdown',
|
|
383
|
-
answer: buildAnswerWithInlineLinks(exampleLinks),
|
|
384
|
-
});
|
|
385
|
-
await flushPromises();
|
|
386
|
-
|
|
387
|
-
expect(mockUnbind).not.toHaveBeenCalled();
|
|
388
|
-
|
|
389
|
-
const updatedLinks = [
|
|
390
|
-
{href: 'https://example.com/3', text: 'Link three'},
|
|
391
|
-
];
|
|
392
|
-
element.answer = buildAnswerWithInlineLinks(updatedLinks);
|
|
393
|
-
await flushPromises();
|
|
394
|
-
|
|
395
|
-
expect(mockUnbind).toHaveBeenCalledTimes(exampleLinks.length);
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
describe('when the component is disconnected', () => {
|
|
400
|
-
it('should call the unbind function for each inline link binding', async () => {
|
|
401
|
-
const {LinkUtils} = jest.requireMock('c/quanticUtils');
|
|
402
|
-
const mockUnbind = jest.fn();
|
|
403
|
-
LinkUtils.bindAnalyticsToLink.mockReturnValue(mockUnbind);
|
|
404
|
-
|
|
405
|
-
const element = createTestComponent({
|
|
406
|
-
...defaultOptions,
|
|
407
|
-
engineId: exampleEngineId,
|
|
408
|
-
answerId: exampleAnswerId,
|
|
409
|
-
answerContentFormat: 'text/markdown',
|
|
410
|
-
answer: buildAnswerWithInlineLinks(exampleLinks),
|
|
411
|
-
});
|
|
412
|
-
await flushPromises();
|
|
413
|
-
|
|
414
|
-
expect(mockUnbind).not.toHaveBeenCalled();
|
|
415
|
-
|
|
416
|
-
document.body.removeChild(element);
|
|
417
|
-
await flushPromises();
|
|
418
|
-
|
|
419
|
-
expect(mockUnbind).toHaveBeenCalledTimes(exampleLinks.length);
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
describe('the quantic__answercontentupdated event', () => {
|
|
425
|
-
beforeEach(() => {
|
|
426
|
-
mockSuccessfulHeadlessInitialization();
|
|
427
|
-
prepareHeadlessState();
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
it('should dispatch the event with the measured height when the markdown content is updated', async () => {
|
|
431
|
-
const element = createTestComponent({
|
|
432
|
-
...defaultOptions,
|
|
433
|
-
answerContentFormat: 'text/markdown',
|
|
434
|
-
answer: 'Hello, world!',
|
|
435
|
-
});
|
|
436
|
-
const handler = jest.fn();
|
|
437
|
-
element.addEventListener('quantic__answercontentupdated', handler);
|
|
438
|
-
await flushPromises();
|
|
439
|
-
|
|
440
|
-
expect(handler).toHaveBeenCalledTimes(1);
|
|
441
|
-
const event = handler.mock.calls[0][0];
|
|
442
|
-
expect(event.detail).toEqual({height: mockAnswerHeight});
|
|
443
|
-
expect(event.bubbles).toBe(true);
|
|
444
|
-
expect(event.composed).toBe(true);
|
|
445
|
-
});
|
|
446
|
-
});
|
|
447
|
-
});
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/* eslint-disable jest/no-focused-tests */
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import {createElement} from 'lwc';
|
|
4
|
-
import QuanticGeneratedAnswerCopyToClipboard from '../quanticGeneratedAnswerCopyToClipboard';
|
|
5
|
-
import {copyToClipboard} from 'c/quanticUtils';
|
|
6
|
-
|
|
7
|
-
const defaultCopyLabel = 'Copy';
|
|
8
|
-
const defaultCopiedLabel = 'Copied';
|
|
9
|
-
const defaultSize = 'xx-small';
|
|
10
|
-
|
|
11
|
-
jest.mock(
|
|
12
|
-
'@salesforce/label/c.quantic_Copy',
|
|
13
|
-
() => ({default: defaultCopyLabel}),
|
|
14
|
-
{
|
|
15
|
-
virtual: true,
|
|
16
|
-
}
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
jest.mock(
|
|
20
|
-
'@salesforce/label/c.quantic_Copied',
|
|
21
|
-
() => ({default: defaultCopiedLabel}),
|
|
22
|
-
{
|
|
23
|
-
virtual: true,
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
jest.mock('c/quanticUtils', () => ({
|
|
28
|
-
copyToClipboard: jest.fn(() => Promise.resolve()),
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
const selectors = {
|
|
32
|
-
copyButton: 'c-quantic-stateful-button',
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const defaultOptions = {
|
|
36
|
-
answer: 'Example generated answer',
|
|
37
|
-
answerId: 'example-answer-id',
|
|
38
|
-
size: defaultSize,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
function createTestComponent(options = defaultOptions) {
|
|
42
|
-
const element = createElement(
|
|
43
|
-
'c-quantic-generated-answer-copy-to-clipboard',
|
|
44
|
-
{
|
|
45
|
-
is: QuanticGeneratedAnswerCopyToClipboard,
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
for (const [key, value] of Object.entries(options)) {
|
|
50
|
-
element[key] = value;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
document.body.appendChild(element);
|
|
54
|
-
return element;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Helper function to wait until the microtask queue is empty.
|
|
58
|
-
function flushPromises() {
|
|
59
|
-
// eslint-disable-next-line @lwc/lwc/no-async-operation
|
|
60
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
describe('c-quantic-generated-answer-copy-to-clipboard', () => {
|
|
64
|
-
function cleanup() {
|
|
65
|
-
while (document.body.firstChild) {
|
|
66
|
-
document.body.removeChild(document.body.firstChild);
|
|
67
|
-
}
|
|
68
|
-
jest.clearAllMocks();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
afterEach(() => {
|
|
72
|
-
cleanup();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should render the copy button with default size', async () => {
|
|
76
|
-
const element = createTestComponent();
|
|
77
|
-
await flushPromises();
|
|
78
|
-
|
|
79
|
-
const copyButton = element.shadowRoot.querySelector(selectors.copyButton);
|
|
80
|
-
|
|
81
|
-
expect(copyButton).not.toBeNull();
|
|
82
|
-
expect(copyButton.iconName).toBe('utility:copy');
|
|
83
|
-
expect(copyButton.iconSize).toBe(defaultSize);
|
|
84
|
-
expect(copyButton.tooltip).toBe(defaultCopyLabel);
|
|
85
|
-
expect(copyButton.selected).toBe(false);
|
|
86
|
-
expect(copyButton.withoutBorders).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should apply a custom valid size', async () => {
|
|
90
|
-
const customSize = 'large';
|
|
91
|
-
const element = createTestComponent({...defaultOptions, size: customSize});
|
|
92
|
-
await flushPromises();
|
|
93
|
-
|
|
94
|
-
const copyButton = element.shadowRoot.querySelector(selectors.copyButton);
|
|
95
|
-
|
|
96
|
-
expect(copyButton).not.toBeNull();
|
|
97
|
-
expect(copyButton.iconSize).toBe(customSize);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should ignore an invalid size and keep the default value', async () => {
|
|
101
|
-
const element = createTestComponent({
|
|
102
|
-
...defaultOptions,
|
|
103
|
-
size: 'oliphant',
|
|
104
|
-
});
|
|
105
|
-
await flushPromises();
|
|
106
|
-
|
|
107
|
-
const copyButton = element.shadowRoot.querySelector(selectors.copyButton);
|
|
108
|
-
|
|
109
|
-
expect(copyButton).not.toBeNull();
|
|
110
|
-
expect(copyButton.iconSize).toBe(defaultSize);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('should copy the answer and dispatch the #quantic__generatedanswercopy event with the answerId', async () => {
|
|
114
|
-
const element = createTestComponent();
|
|
115
|
-
const handler = jest.fn();
|
|
116
|
-
element.addEventListener('quantic__generatedanswercopy', handler);
|
|
117
|
-
await flushPromises();
|
|
118
|
-
|
|
119
|
-
const copyButton = element.shadowRoot.querySelector(selectors.copyButton);
|
|
120
|
-
copyButton.dispatchEvent(new CustomEvent('quantic__select'));
|
|
121
|
-
await flushPromises();
|
|
122
|
-
|
|
123
|
-
expect(copyToClipboard).toHaveBeenCalledWith(defaultOptions.answer);
|
|
124
|
-
expect(handler).toHaveBeenCalledTimes(1);
|
|
125
|
-
expect(handler.mock.calls[0][0].detail).toEqual({
|
|
126
|
-
answerId: defaultOptions.answerId,
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|