@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
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-import-assign */
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import QuanticUserActionsToggle from 'c/quanticUserActionsToggle';
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import {createElement} from 'lwc';
|
|
6
|
-
import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
|
|
7
|
-
|
|
8
|
-
jest.mock('c/quanticHeadlessLoader');
|
|
9
|
-
|
|
10
|
-
const userActionsIcon = 'utility:clock';
|
|
11
|
-
const userActionsLabel = 'User actions';
|
|
12
|
-
jest.mock(
|
|
13
|
-
'@salesforce/label/c.quantic_UserActions',
|
|
14
|
-
() => ({default: userActionsLabel}),
|
|
15
|
-
{
|
|
16
|
-
virtual: true,
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const functionsMocks = {
|
|
21
|
-
buildUserActions: jest.fn(() => ({
|
|
22
|
-
logOpenUserActions: functionsMocks.logOpenUserActions,
|
|
23
|
-
})),
|
|
24
|
-
logOpenUserActions: jest.fn(() => {}),
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const selectors = {
|
|
28
|
-
userActionsToggleButton: '[data-test="user-actions-toggle-button"]',
|
|
29
|
-
userActionsToggleButtonIcon:
|
|
30
|
-
'[data-test="user-actions-toggle-button"] lightning-icon',
|
|
31
|
-
userActionsTimeline:
|
|
32
|
-
'c-quantic-modal [slot="content"] c-quantic-user-actions-timeline',
|
|
33
|
-
modalHeaderIcon: 'c-quantic-modal [slot="header"] lightning-icon',
|
|
34
|
-
modalHeaderLabel:
|
|
35
|
-
'c-quantic-modal [slot="header"] [data-test="user-actions-modal-label"]',
|
|
36
|
-
initializationError: 'c-quantic-component-error',
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const exampleTicketCreationDateTime = '2024-01-01T00:00:00Z';
|
|
40
|
-
const exampleExcludedCustomActions = ['dummyEvent'];
|
|
41
|
-
const exampleUserId = 'someone@company.com';
|
|
42
|
-
const exampleEngineId = 'exampleEngineId';
|
|
43
|
-
const exampleEngine = {
|
|
44
|
-
id: exampleEngineId,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const defaultOptions = {
|
|
48
|
-
engineId: exampleEngineId,
|
|
49
|
-
ticketCreationDateTime: exampleTicketCreationDateTime,
|
|
50
|
-
excludedCustomActions: exampleExcludedCustomActions,
|
|
51
|
-
userId: exampleUserId,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
function createTestComponent(options = defaultOptions) {
|
|
55
|
-
prepareHeadlessState();
|
|
56
|
-
|
|
57
|
-
const element = createElement('c-quantic-user-actions-toggle', {
|
|
58
|
-
is: QuanticUserActionsToggle,
|
|
59
|
-
});
|
|
60
|
-
for (const [key, value] of Object.entries(options)) {
|
|
61
|
-
element[key] = value;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
document.body.appendChild(element);
|
|
65
|
-
return element;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function prepareHeadlessState() {
|
|
69
|
-
// @ts-ignore
|
|
70
|
-
mockHeadlessLoader.getHeadlessBundle = () => {
|
|
71
|
-
return {
|
|
72
|
-
buildUserActions: functionsMocks.buildUserActions,
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Helper function to wait until the microtask queue is empty.
|
|
78
|
-
function flushPromises() {
|
|
79
|
-
// eslint-disable-next-line @lwc/lwc/no-async-operation
|
|
80
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let isInitialized = false;
|
|
84
|
-
|
|
85
|
-
function mockSuccessfulHeadlessInitialization() {
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
88
|
-
if (element instanceof QuanticUserActionsToggle && !isInitialized) {
|
|
89
|
-
isInitialized = true;
|
|
90
|
-
initialize(exampleEngine);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function mockErroneousHeadlessInitialization() {
|
|
96
|
-
// @ts-ignore
|
|
97
|
-
mockHeadlessLoader.initializeWithHeadless = (element) => {
|
|
98
|
-
if (element instanceof QuanticUserActionsToggle) {
|
|
99
|
-
element.setInitializationError();
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function cleanup() {
|
|
105
|
-
// The jsdom instance is shared across test cases in a single file so reset the DOM
|
|
106
|
-
while (document.body.firstChild) {
|
|
107
|
-
document.body.removeChild(document.body.firstChild);
|
|
108
|
-
}
|
|
109
|
-
jest.clearAllMocks();
|
|
110
|
-
isInitialized = false;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
describe('c-quantic-user-actions-toggle', () => {
|
|
114
|
-
beforeAll(() => {
|
|
115
|
-
mockSuccessfulHeadlessInitialization();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
afterEach(() => {
|
|
119
|
-
cleanup();
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('controller initialization', () => {
|
|
123
|
-
it('should build the controller with the right parameters', async () => {
|
|
124
|
-
createTestComponent();
|
|
125
|
-
await flushPromises();
|
|
126
|
-
|
|
127
|
-
expect(functionsMocks.buildUserActions).toHaveBeenCalledTimes(1);
|
|
128
|
-
expect(functionsMocks.buildUserActions).toHaveBeenCalledWith(
|
|
129
|
-
exampleEngine,
|
|
130
|
-
{
|
|
131
|
-
options: {
|
|
132
|
-
ticketCreationDate: exampleTicketCreationDateTime,
|
|
133
|
-
excludedCustomActions: exampleExcludedCustomActions,
|
|
134
|
-
},
|
|
135
|
-
}
|
|
136
|
-
);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('should display the user actions toggle button', async () => {
|
|
141
|
-
const element = createTestComponent();
|
|
142
|
-
await flushPromises();
|
|
143
|
-
|
|
144
|
-
const userActionsToggleButton = element.shadowRoot.querySelector(
|
|
145
|
-
selectors.userActionsToggleButton
|
|
146
|
-
);
|
|
147
|
-
const userActionsToggleButtonIcon = element.shadowRoot.querySelector(
|
|
148
|
-
selectors.userActionsToggleButtonIcon
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
expect(userActionsToggleButton).not.toBeNull();
|
|
152
|
-
expect(userActionsToggleButton.title).toBe(userActionsLabel);
|
|
153
|
-
expect(userActionsToggleButtonIcon.iconName).toBe(userActionsIcon);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('should log analytics when the user action modal is opened', async () => {
|
|
157
|
-
const element = createTestComponent();
|
|
158
|
-
await flushPromises();
|
|
159
|
-
|
|
160
|
-
const userActionsToggleButton = element.shadowRoot.querySelector(
|
|
161
|
-
selectors.userActionsToggleButton
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
expect(userActionsToggleButton).not.toBeNull();
|
|
165
|
-
await userActionsToggleButton.click();
|
|
166
|
-
await flushPromises();
|
|
167
|
-
|
|
168
|
-
expect(functionsMocks.logOpenUserActions).toHaveBeenCalledTimes(1);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('should properly display the user actions modal header', async () => {
|
|
172
|
-
const element = createTestComponent();
|
|
173
|
-
await flushPromises();
|
|
174
|
-
|
|
175
|
-
const modalHeaderIcon = element.shadowRoot.querySelector(
|
|
176
|
-
selectors.modalHeaderIcon
|
|
177
|
-
);
|
|
178
|
-
const modalHeaderLabel = element.shadowRoot.querySelector(
|
|
179
|
-
selectors.modalHeaderLabel
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
expect(modalHeaderIcon).not.toBeNull();
|
|
183
|
-
expect(modalHeaderLabel).not.toBeNull();
|
|
184
|
-
|
|
185
|
-
expect(modalHeaderIcon.iconName).toBe(userActionsIcon);
|
|
186
|
-
expect(modalHeaderIcon.title).toBe(userActionsLabel);
|
|
187
|
-
expect(modalHeaderLabel.textContent).toBe(userActionsLabel);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it('should properly display the user actions timeline inside the modal', async () => {
|
|
191
|
-
const element = createTestComponent();
|
|
192
|
-
await flushPromises();
|
|
193
|
-
|
|
194
|
-
const userActionsTimeline = element.shadowRoot.querySelector(
|
|
195
|
-
selectors.userActionsTimeline
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
expect(userActionsTimeline).not.toBeNull();
|
|
199
|
-
expect(userActionsTimeline.engineId).toBe(exampleEngineId);
|
|
200
|
-
expect(userActionsTimeline.userId).toBe(exampleUserId);
|
|
201
|
-
expect(userActionsTimeline.ticketCreationDateTime).toBe(
|
|
202
|
-
exampleTicketCreationDateTime
|
|
203
|
-
);
|
|
204
|
-
expect(userActionsTimeline.excludedCustomActions).toEqual(
|
|
205
|
-
exampleExcludedCustomActions
|
|
206
|
-
);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
describe('when an initialization error occurs', () => {
|
|
210
|
-
beforeEach(() => {
|
|
211
|
-
mockErroneousHeadlessInitialization();
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
afterAll(() => {
|
|
215
|
-
mockSuccessfulHeadlessInitialization();
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('should display the initialization error component', async () => {
|
|
219
|
-
const element = createTestComponent();
|
|
220
|
-
await flushPromises();
|
|
221
|
-
|
|
222
|
-
const initializationError = element.shadowRoot.querySelector(
|
|
223
|
-
selectors.initializationError
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
expect(initializationError).not.toBeNull();
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const followingSessionsActions = [
|
|
2
|
-
{
|
|
3
|
-
name: 'CUSTOM',
|
|
4
|
-
value:
|
|
5
|
-
'{"event_type":"example","event_value":"exampleCustomAction","origin_level_1":"default"}',
|
|
6
|
-
time: new Date('2024-09-01T15:30:00Z').valueOf(),
|
|
7
|
-
},
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
const ticketCreationSessionActions = [
|
|
11
|
-
{
|
|
12
|
-
name: 'CUSTOM',
|
|
13
|
-
value:
|
|
14
|
-
'{"event_type":"errors","event_value":"One","origin_level_1":"default","origin_level_2":"default"}',
|
|
15
|
-
time: new Date('2024-08-30T00:10:00Z').valueOf(),
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
const precedingSessionsActions = [
|
|
20
|
-
{
|
|
21
|
-
name: 'CUSTOM',
|
|
22
|
-
value:
|
|
23
|
-
'{"event_type":"example","event_value":"exampleCustomAction","origin_level_1":"default"}',
|
|
24
|
-
time: new Date('2024-08-29T15:40:00Z').valueOf(),
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
export const exampleUserActionsData = [
|
|
29
|
-
...followingSessionsActions,
|
|
30
|
-
...ticketCreationSessionActions,
|
|
31
|
-
...precedingSessionsActions,
|
|
32
|
-
];
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {quanticBase} from '../../../../../../playwright/fixtures/baseFixture';
|
|
2
|
-
import {UserActionsToggleObject} from './pageObject';
|
|
3
|
-
import {exampleUserActionsData} from './data';
|
|
4
|
-
|
|
5
|
-
const pageUrl = 's/quantic-user-actions-toggle';
|
|
6
|
-
|
|
7
|
-
interface UserActionsToggleOptions {
|
|
8
|
-
userId: string;
|
|
9
|
-
ticketCreationDateTime: string;
|
|
10
|
-
}
|
|
11
|
-
type QuanticUserActionsToggleE2EFixtures = {
|
|
12
|
-
userActionsToggle: UserActionsToggleObject;
|
|
13
|
-
options: UserActionsToggleOptions;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const testInsight =
|
|
17
|
-
quanticBase.extend<QuanticUserActionsToggleE2EFixtures>({
|
|
18
|
-
options: {
|
|
19
|
-
userId: 'someone@company.com',
|
|
20
|
-
ticketCreationDateTime: '2024-01-01T00:00:00Z',
|
|
21
|
-
},
|
|
22
|
-
userActionsToggle: async ({page, options, configuration}, use) => {
|
|
23
|
-
await page.goto(pageUrl);
|
|
24
|
-
configuration.configure({...options});
|
|
25
|
-
const userActionsToggleObject = new UserActionsToggleObject(page);
|
|
26
|
-
userActionsToggleObject.mockUserActions(exampleUserActionsData);
|
|
27
|
-
await userActionsToggleObject.waitForUserActionsResponse(options.userId);
|
|
28
|
-
await use(userActionsToggleObject);
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export {expect} from '@playwright/test';
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type {Locator, Page, Request, Response} from '@playwright/test';
|
|
2
|
-
import {isUaCustomEvent} from '../../../../../../playwright/utils/requests';
|
|
3
|
-
|
|
4
|
-
const userActionsRequestRegex =
|
|
5
|
-
/\/rest\/organizations\/.*\/machinelearning\/user\/actions$/;
|
|
6
|
-
|
|
7
|
-
export class UserActionsToggleObject {
|
|
8
|
-
constructor(public page: Page) {
|
|
9
|
-
this.page = page;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get userActionsToggleButton(): Locator {
|
|
13
|
-
return this.page.getByRole('button', {name: /User actions/i});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get userActionsModal(): Locator {
|
|
17
|
-
return this.page.locator(
|
|
18
|
-
'c-quantic-user-actions-toggle > c-quantic-modal > div'
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get userActionsModalCloseButton(): Locator {
|
|
23
|
-
return this.page
|
|
24
|
-
.locator('c-quantic-user-actions-toggle > c-quantic-modal')
|
|
25
|
-
.getByRole('button', {name: 'Close'});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async mockUserActions(
|
|
29
|
-
userActions: Array<{name: string; value: string; time: number}>
|
|
30
|
-
) {
|
|
31
|
-
await this.page.route(userActionsRequestRegex, async (route) => {
|
|
32
|
-
const body = {value: userActions};
|
|
33
|
-
|
|
34
|
-
await route.fulfill({
|
|
35
|
-
body: JSON.stringify(body),
|
|
36
|
-
status: 200,
|
|
37
|
-
headers: {
|
|
38
|
-
'content-type': 'text/html',
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async waitForUserActionsResponse(userId: string): Promise<Response> {
|
|
45
|
-
return this.page.waitForResponse((response) => {
|
|
46
|
-
const request = response.request();
|
|
47
|
-
if (request.url().match(userActionsRequestRegex)) {
|
|
48
|
-
const requestBody = request.postDataJSON?.();
|
|
49
|
-
return requestBody?.objectId === userId;
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async waitForOpenUserActionsUaAnalytics(): Promise<Request> {
|
|
56
|
-
const uaRequest = this.page.waitForRequest((request) => {
|
|
57
|
-
if (isUaCustomEvent(request)) {
|
|
58
|
-
const requestBody = request.postDataJSON?.();
|
|
59
|
-
const expectedFields = {
|
|
60
|
-
eventType: 'User Actions',
|
|
61
|
-
eventValue: 'openUserActions',
|
|
62
|
-
};
|
|
63
|
-
return Object.keys(expectedFields).every(
|
|
64
|
-
(key) => requestBody?.[key] === expectedFields[key]
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
});
|
|
69
|
-
return uaRequest;
|
|
70
|
-
}
|
|
71
|
-
}
|
package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {testInsight, expect} from './fixture';
|
|
2
|
-
|
|
3
|
-
const exampleUserId = 'exampleUserId';
|
|
4
|
-
const exampleTicketCreateDateTime = encodeURIComponent('2024-08-30');
|
|
5
|
-
|
|
6
|
-
testInsight.use({
|
|
7
|
-
options: {
|
|
8
|
-
userId: exampleUserId,
|
|
9
|
-
ticketCreationDateTime: exampleTicketCreateDateTime,
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
testInsight.describe('quantic user actions toggle', () => {
|
|
14
|
-
testInsight.describe('when opening the user action modal', () => {
|
|
15
|
-
testInsight(
|
|
16
|
-
'should open the user actions timeline and log analytics',
|
|
17
|
-
async ({userActionsToggle}) => {
|
|
18
|
-
await expect(userActionsToggle.userActionsModal).not.toBeVisible();
|
|
19
|
-
const uaPromise = userActionsToggle.waitForOpenUserActionsUaAnalytics();
|
|
20
|
-
await userActionsToggle.userActionsToggleButton.click();
|
|
21
|
-
await expect(userActionsToggle.userActionsModal).toBeVisible();
|
|
22
|
-
await uaPromise;
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
testInsight.describe('when closing the user action modal', () => {
|
|
28
|
-
testInsight(
|
|
29
|
-
'should close the user actions timeline',
|
|
30
|
-
async ({userActionsToggle}) => {
|
|
31
|
-
await expect(userActionsToggle.userActionsModal).not.toBeVisible();
|
|
32
|
-
await userActionsToggle.userActionsToggleButton.click();
|
|
33
|
-
await expect(userActionsToggle.userActionsModal).toBeVisible();
|
|
34
|
-
await userActionsToggle.userActionsModalCloseButton.click();
|
|
35
|
-
await expect(userActionsToggle.userActionsModal).not.toBeVisible();
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AriaLiveRegion,
|
|
3
|
-
isFocusable,
|
|
4
|
-
getFirstFocusableElement,
|
|
5
|
-
getLastFocusableElement,
|
|
6
|
-
isCustomElement,
|
|
7
|
-
isParentOf,
|
|
8
|
-
} from 'c/quanticUtils';
|
|
9
|
-
|
|
10
|
-
describe('accessibilityUtils', () => {
|
|
11
|
-
describe('AriaLiveRegion', () => {
|
|
12
|
-
let elem;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
elem = {dispatchEvent: jest.fn()};
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should dispatch a register region event on creation', () => {
|
|
19
|
-
AriaLiveRegion('test-region', elem);
|
|
20
|
-
expect(elem.dispatchEvent).toHaveBeenCalledTimes(1);
|
|
21
|
-
const event = elem.dispatchEvent.mock.calls[0][0];
|
|
22
|
-
expect(event.type).toBe('quantic__registerregion');
|
|
23
|
-
expect(event.detail).toEqual({
|
|
24
|
-
regionName: 'test-region',
|
|
25
|
-
assertive: false,
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should dispatch a register region event with assertive flag', () => {
|
|
30
|
-
AriaLiveRegion('test-region', elem, true);
|
|
31
|
-
const event = elem.dispatchEvent.mock.calls[0][0];
|
|
32
|
-
expect(event.detail.assertive).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should dispatch an aria live message event when dispatchMessage is called', () => {
|
|
36
|
-
const region = AriaLiveRegion('test-region', elem);
|
|
37
|
-
region.dispatchMessage('hello');
|
|
38
|
-
expect(elem.dispatchEvent).toHaveBeenCalledTimes(2);
|
|
39
|
-
const event = elem.dispatchEvent.mock.calls[1][0];
|
|
40
|
-
expect(event.type).toBe('quantic__arialivemessage');
|
|
41
|
-
expect(event.detail).toEqual({
|
|
42
|
-
regionName: 'test-region',
|
|
43
|
-
assertive: false,
|
|
44
|
-
message: 'hello',
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('isFocusable', () => {
|
|
50
|
-
function createElement(tag, attrs = {}) {
|
|
51
|
-
const el = document.createElement(tag);
|
|
52
|
-
Object.entries(attrs).forEach(([k, v]) => el.setAttribute(k, v));
|
|
53
|
-
return el;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
it('should return true for a button', () => {
|
|
57
|
-
expect(isFocusable(createElement('button'))).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should return false for a disabled button', () => {
|
|
61
|
-
expect(isFocusable(createElement('button', {disabled: ''}))).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should return true for an anchor with href', () => {
|
|
65
|
-
expect(isFocusable(createElement('a', {href: '#'}))).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('should return false for an anchor without href', () => {
|
|
69
|
-
expect(isFocusable(createElement('a'))).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should return true for an input', () => {
|
|
73
|
-
expect(isFocusable(createElement('input'))).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should return false for a disabled input', () => {
|
|
77
|
-
expect(isFocusable(createElement('input', {disabled: ''}))).toBe(false);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should return true for an element with tabindex >= 0', () => {
|
|
81
|
-
expect(isFocusable(createElement('div', {tabindex: '0'}))).toBe(true);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should return false for an element with tabindex -1', () => {
|
|
85
|
-
expect(isFocusable(createElement('div', {tabindex: '-1'}))).toBe(false);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('should return true for a contentEditable element', () => {
|
|
89
|
-
expect(isFocusable(createElement('div', {contentEditable: 'true'}))).toBe(
|
|
90
|
-
true
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should return false for a plain div', () => {
|
|
95
|
-
expect(isFocusable(createElement('div'))).toBe(false);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('should return true for an iframe', () => {
|
|
99
|
-
expect(isFocusable(createElement('iframe'))).toBe(true);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should return true for a select', () => {
|
|
103
|
-
expect(isFocusable(createElement('select'))).toBe(true);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should return true for a textarea', () => {
|
|
107
|
-
expect(isFocusable(createElement('textarea'))).toBe(true);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('isCustomElement', () => {
|
|
112
|
-
it('should return true for elements with a hyphen in the tag name', () => {
|
|
113
|
-
const el = document.createElement('my-component');
|
|
114
|
-
expect(isCustomElement(el)).toBe(true);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('should return false for standard elements', () => {
|
|
118
|
-
const el = document.createElement('div');
|
|
119
|
-
expect(isCustomElement(el)).toBe(false);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('should return false for null', () => {
|
|
123
|
-
expect(isCustomElement(null)).toBe(false);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe('getFirstFocusableElement', () => {
|
|
128
|
-
it('should return null for null input', () => {
|
|
129
|
-
expect(getFirstFocusableElement(null)).toBeNull();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('should return the element itself if it is focusable and has no focusable children', () => {
|
|
133
|
-
const btn = document.createElement('button');
|
|
134
|
-
expect(getFirstFocusableElement(btn)).toBe(btn);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('should return the first focusable child', () => {
|
|
138
|
-
const div = document.createElement('div');
|
|
139
|
-
const span = document.createElement('span');
|
|
140
|
-
const btn1 = document.createElement('button');
|
|
141
|
-
const btn2 = document.createElement('button');
|
|
142
|
-
div.appendChild(span);
|
|
143
|
-
div.appendChild(btn1);
|
|
144
|
-
div.appendChild(btn2);
|
|
145
|
-
expect(getFirstFocusableElement(div)).toBe(btn1);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('should return null for a custom element without data-focusable', () => {
|
|
149
|
-
const el = document.createElement('my-component');
|
|
150
|
-
expect(getFirstFocusableElement(el)).toBeNull();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('should return the custom element if data-focusable is true', () => {
|
|
154
|
-
const el = document.createElement('my-component');
|
|
155
|
-
el.dataset.focusable = 'true';
|
|
156
|
-
expect(getFirstFocusableElement(el)).toBe(el);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('should return null for a text node', () => {
|
|
160
|
-
const text = document.createTextNode('hello');
|
|
161
|
-
expect(getFirstFocusableElement(text)).toBeNull();
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
describe('getLastFocusableElement', () => {
|
|
166
|
-
it('should return null for null input', () => {
|
|
167
|
-
expect(getLastFocusableElement(null)).toBeNull();
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('should return the last focusable child', () => {
|
|
171
|
-
const div = document.createElement('div');
|
|
172
|
-
const btn1 = document.createElement('button');
|
|
173
|
-
const btn2 = document.createElement('button');
|
|
174
|
-
div.appendChild(btn1);
|
|
175
|
-
div.appendChild(btn2);
|
|
176
|
-
expect(getLastFocusableElement(div)).toBe(btn2);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('should return the element itself if it is focusable and has no focusable children', () => {
|
|
180
|
-
const input = document.createElement('input');
|
|
181
|
-
expect(getLastFocusableElement(input)).toBe(input);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
describe('isParentOf', () => {
|
|
186
|
-
it('should return false for null', () => {
|
|
187
|
-
expect(isParentOf(null, 'MY-COMPONENT')).toBe(false);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it('should return true if the element itself matches the target tag', () => {
|
|
191
|
-
const el = document.createElement('my-component');
|
|
192
|
-
expect(isParentOf(el, 'MY-COMPONENT')).toBe(true);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('should return true if a descendant matches the target tag', () => {
|
|
196
|
-
const wrapper = document.createElement('div');
|
|
197
|
-
const child = document.createElement('my-component');
|
|
198
|
-
wrapper.appendChild(child);
|
|
199
|
-
expect(isParentOf(wrapper, 'MY-COMPONENT')).toBe(true);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('should return false if no descendant matches', () => {
|
|
203
|
-
const wrapper = document.createElement('div');
|
|
204
|
-
const child = document.createElement('span');
|
|
205
|
-
wrapper.appendChild(child);
|
|
206
|
-
expect(isParentOf(wrapper, 'MY-COMPONENT')).toBe(false);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('should return false for a text node', () => {
|
|
210
|
-
const text = document.createTextNode('hello');
|
|
211
|
-
expect(isParentOf(text, 'MY-COMPONENT')).toBe(false);
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
});
|