@coveo/quantic 3.16.0 → 3.16.1-pre.1a6fc4649f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/docs/out/quantic-docs.json +2 -2
  2. package/force-app/main/default/lwc/quanticNumberButton/quanticNumberButton.html +1 -1
  3. package/force-app/main/default/lwc/quanticResultsPerPage/quanticResultsPerPage.js +27 -17
  4. package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +6 -6
  5. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
  6. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.d.ts +0 -1
  7. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
  8. package/force-app/main/default/staticresources/coveoheadless/definitions/features/parameter-manager/parameter-manager-selectors.d.ts +5 -0
  9. package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-parameters/search-parameter-actions-loader.d.ts +36 -0
  10. package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-parameters/search-parameter-actions.d.ts +6 -0
  11. package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -10
  12. package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +9 -9
  13. package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +5 -5
  14. package/package.json +6 -4
  15. package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +0 -604
  16. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/fixture.ts +0 -76
  17. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/pageObject.ts +0 -282
  18. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/quanticBreadcrumbManager.e2e.ts +0 -167
  19. package/force-app/main/default/lwc/quanticCarousel/__tests__/quanticCarousel.test.js +0 -262
  20. package/force-app/main/default/lwc/quanticCaseClassification/__tests__/quanticCaseClassification.test.js +0 -819
  21. package/force-app/main/default/lwc/quanticCaseClassification/e2e/data.ts +0 -23
  22. package/force-app/main/default/lwc/quanticCaseClassification/e2e/fixture.ts +0 -51
  23. package/force-app/main/default/lwc/quanticCaseClassification/e2e/pageObject.ts +0 -152
  24. package/force-app/main/default/lwc/quanticCaseClassification/e2e/quanticCaseClassification.e2e.ts +0 -269
  25. package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +0 -327
  26. package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +0 -269
  27. package/force-app/main/default/lwc/quanticColoredResultBadge/__tests__/quanticColoredResultBadge.test.js +0 -212
  28. package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +0 -321
  29. package/force-app/main/default/lwc/quanticDidYouMean/__tests__/quanticDidYouMean.test.js +0 -199
  30. package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +0 -341
  31. package/force-app/main/default/lwc/quanticFacetCaption/__tests__/quanticFacetCaption.test.js +0 -28
  32. package/force-app/main/default/lwc/quanticFacetManager/__tests__/quanticFacetManager.test.js +0 -178
  33. package/force-app/main/default/lwc/quanticFacetManager/e2e/fixture.ts +0 -63
  34. package/force-app/main/default/lwc/quanticFacetManager/e2e/pageObject.ts +0 -23
  35. package/force-app/main/default/lwc/quanticFacetManager/e2e/quanticFacetManager.e2e.ts +0 -82
  36. package/force-app/main/default/lwc/quanticFeedback/__tests__/quanticFeedback.test.js +0 -392
  37. package/force-app/main/default/lwc/quanticFeedbackModal/__tests__/quanticFeedbackModal.test.js +0 -448
  38. package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +0 -298
  39. package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +0 -814
  40. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +0 -56
  41. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +0 -87
  42. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +0 -283
  43. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +0 -199
  44. package/force-app/main/default/lwc/quanticGeneratedAnswerContent/__tests__/quanticGeneratedAnswerContent.test.js +0 -151
  45. package/force-app/main/default/lwc/quanticHeading/__tests__/quanticHeading.test.js +0 -71
  46. package/force-app/main/default/lwc/quanticHeadlessLoader/__tests__/quanticHeadlessLoader.test.js +0 -651
  47. package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +0 -335
  48. package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +0 -343
  49. package/force-app/main/default/lwc/quanticPager/e2e/fixture.ts +0 -63
  50. package/force-app/main/default/lwc/quanticPager/e2e/pageObject.ts +0 -69
  51. package/force-app/main/default/lwc/quanticPager/e2e/quanticPager.e2e.ts +0 -101
  52. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/defaultTestCase.json +0 -13
  53. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/youtubeTestCase.json +0 -14
  54. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/quanticQuickviewContent.test.js +0 -82
  55. package/force-app/main/default/lwc/quanticRadioButtonsGroup/__tests__/quanticRadioButtonsGroup.test.js +0 -273
  56. package/force-app/main/default/lwc/quanticRefineModalContent/__tests__/quanticRefineModalContent.test.js +0 -501
  57. package/force-app/main/default/lwc/quanticResultAction/__tests__/quanticResultAction.test.js +0 -262
  58. package/force-app/main/default/lwc/quanticResultActionBar/__tests__/quanticResultActionBar.test.js +0 -141
  59. package/force-app/main/default/lwc/quanticResultChildren/__tests__/quanticResultChildren.test.js +0 -340
  60. package/force-app/main/default/lwc/quanticResultDate/__tests__/quanticResultDate.test.js +0 -144
  61. package/force-app/main/default/lwc/quanticResultField/__tests__/quanticResultField.test.js +0 -120
  62. package/force-app/main/default/lwc/quanticResultHighlightedTextField/__tests__/quanticResultHighlightedTextField.test.js +0 -209
  63. package/force-app/main/default/lwc/quanticResultLink/__tests__/quanticResultLink.test.js +0 -261
  64. package/force-app/main/default/lwc/quanticResultMultiValueText/__tests__/quanticResultMultiValueText.test.js +0 -235
  65. package/force-app/main/default/lwc/quanticResultNumber/__tests__/quanticResultNumber.test.js +0 -144
  66. package/force-app/main/default/lwc/quanticResultPrintableUri/__tests__/quanticResultPrintableUri.test.js +0 -324
  67. package/force-app/main/default/lwc/quanticResultQuickview/__tests__/quanticResultQuickview.test.js +0 -171
  68. package/force-app/main/default/lwc/quanticResultText/__tests__/quanticResultText.test.js +0 -155
  69. package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js +0 -404
  70. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +0 -74
  71. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/pageObject.ts +0 -85
  72. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/quanticResultsPerPage.e2e.ts +0 -97
  73. package/force-app/main/default/lwc/quanticSearchBox/__tests__/quanticSearchBox.test.js +0 -168
  74. package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js +0 -823
  75. package/force-app/main/default/lwc/quanticSmartSnippet/__tests__/quanticSmartSnippet.test.js +0 -341
  76. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/data.ts +0 -21
  77. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/fixture.ts +0 -91
  78. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +0 -196
  79. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +0 -168
  80. package/force-app/main/default/lwc/quanticSmartSnippetAnswer/__tests__/quanticSmartSnippetAnswer.test.js +0 -126
  81. package/force-app/main/default/lwc/quanticSmartSnippetSource/__tests__/quanticSmartSnippetSource.test.js +0 -290
  82. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/__tests__/quanticSmartSnippetSuggestions.test.js +0 -329
  83. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/data.ts +0 -31
  84. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/fixture.ts +0 -93
  85. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/pageObject.ts +0 -160
  86. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/quanticSmartSnippetSuggestions.e2e.ts +0 -127
  87. package/force-app/main/default/lwc/quanticSort/__tests__/quanticSort.test.js +0 -416
  88. package/force-app/main/default/lwc/quanticSort/e2e/fixture.ts +0 -61
  89. package/force-app/main/default/lwc/quanticSort/e2e/pageObject.ts +0 -89
  90. package/force-app/main/default/lwc/quanticSort/e2e/quanticSort.e2e.ts +0 -91
  91. package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +0 -123
  92. package/force-app/main/default/lwc/quanticStandaloneSearchBox/__tests__/quanticStandaloneSearchBox.test.js +0 -186
  93. package/force-app/main/default/lwc/quanticStatefulButton/__tests__/quanticStatefulButton.test.js +0 -222
  94. package/force-app/main/default/lwc/quanticTab/__tests__/quanticTab.test.js +0 -287
  95. package/force-app/main/default/lwc/quanticTab/e2e/fixture.ts +0 -62
  96. package/force-app/main/default/lwc/quanticTab/e2e/pageObject.ts +0 -67
  97. package/force-app/main/default/lwc/quanticTab/e2e/quanticTab.e2e.ts +0 -77
  98. package/force-app/main/default/lwc/quanticTabBar/__tests__/quanticTabBar.test.js +0 -331
  99. package/force-app/main/default/lwc/quanticTabBar/e2e/fixture.ts +0 -61
  100. package/force-app/main/default/lwc/quanticTabBar/e2e/pageObject.ts +0 -80
  101. package/force-app/main/default/lwc/quanticTabBar/e2e/quanticTabBar.e2e.ts +0 -173
  102. package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +0 -339
  103. package/force-app/main/default/lwc/quanticTooltip/__tests__/quanticTooltip.test.js +0 -107
  104. package/force-app/main/default/lwc/quanticUserAction/__tests__/quanticUserAction.test.js +0 -427
  105. package/force-app/main/default/lwc/quanticUserActionsSession/__tests__/quanticUserActionsSession.test.js +0 -269
  106. package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/data/userActionsState.json +0 -89
  107. package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/quanticUserActionsTimeline.test.js +0 -511
  108. package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +0 -229
  109. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +0 -32
  110. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +0 -32
  111. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +0 -71
  112. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +0 -39
  113. package/force-app/main/default/lwc/quanticUtils/__tests__/facetDependenciesUtils.test.js +0 -92
  114. package/force-app/main/default/lwc/quanticUtils/__tests__/markdownUtils.test.js +0 -71
  115. package/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js +0 -223
  116. package/force-app/main/default/lwc/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +0 -131
@@ -1,339 +0,0 @@
1
- /* eslint-disable no-import-assign */
2
- // @ts-ignore
3
- import {createElement} from 'lwc';
4
- import QuanticTimeframeFacet from 'c/quanticTimeframeFacet';
5
- import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
6
- import {generateFacetDependencyConditions} from 'c/quanticUtils';
7
-
8
- jest.mock('c/quanticUtils', () => ({
9
- generateFacetDependencyConditions: jest.fn(),
10
- Store: {
11
- facetTypes: {
12
- DATEFACETS: 'dateFacets',
13
- },
14
- },
15
- I18nUtils: {
16
- format: jest.fn(),
17
- },
18
- }));
19
- jest.mock('c/quanticHeadlessLoader');
20
-
21
- const selectors = {
22
- facetContent: '[data-test="facet-content"]',
23
- componentError: 'c-quantic-component-error',
24
- };
25
-
26
- const exampleFacetId = 'example facet id';
27
- const exampleField = 'exampleField';
28
- const exampleFilterId = `${exampleFacetId}_input`;
29
- const defaultOptions = {
30
- field: exampleField,
31
- };
32
- const timeframeFacetControllerMock = {
33
- subscribe: jest.fn((callback) => callback()),
34
- state: {
35
- facetId: exampleFacetId,
36
- values: [],
37
- },
38
- };
39
- const parentFacetIdError = `The ${exampleField} c-quantic-timeframe-facet requires dependsOn.parentFacetId to be a valid string.`;
40
- const expectedValueError = `The ${exampleField} c-quantic-timeframe-facet requires dependsOn.expectedValue to be a valid string.`;
41
-
42
- function createTestComponent(options = defaultOptions) {
43
- prepareHeadlessState();
44
-
45
- const element = createElement('c-quantic-timeframe-facet', {
46
- is: QuanticTimeframeFacet,
47
- });
48
- for (const [key, value] of Object.entries(options)) {
49
- element[key] = value;
50
- }
51
-
52
- document.body.appendChild(element);
53
- return element;
54
- }
55
-
56
- const functionsMocks = {
57
- buildDateFacet: jest.fn(() => timeframeFacetControllerMock),
58
- buildDateFilter: jest.fn(() => ({
59
- subscribe: jest.fn((callback) => callback()),
60
- state: {
61
- facetId: exampleFilterId,
62
- },
63
- })),
64
- stopWatching: jest.fn(),
65
- buildFacetConditionsManager: jest.fn(() => ({
66
- stopWatching: functionsMocks.stopWatching,
67
- })),
68
- buildSearchStatus: jest.fn(() => ({
69
- subscribe: jest.fn((callback) => callback()),
70
- state: {},
71
- })),
72
- };
73
-
74
- function prepareHeadlessState() {
75
- // @ts-ignore
76
- mockHeadlessLoader.getHeadlessBundle = () => {
77
- return {
78
- buildDateFacet: functionsMocks.buildDateFacet,
79
- buildDateFilter: functionsMocks.buildDateFilter,
80
- buildSearchStatus: functionsMocks.buildSearchStatus,
81
- buildFacetConditionsManager: functionsMocks.buildFacetConditionsManager,
82
- };
83
- };
84
- }
85
-
86
- // Helper function to wait until the microtask queue is empty.
87
- function flushPromises() {
88
- // eslint-disable-next-line @lwc/lwc/no-async-operation
89
- return new Promise((resolve) => setTimeout(resolve, 0));
90
- }
91
-
92
- const exampleEngine = {
93
- id: 'dummy engine',
94
- };
95
- let isInitialized = false;
96
-
97
- function mockBueno() {
98
- // @ts-ignore
99
- mockHeadlessLoader.getBueno = () => {
100
- // @ts-ignore
101
- global.Bueno = {
102
- isString: jest
103
- .fn()
104
- .mockImplementation(
105
- (value) => Object.prototype.toString.call(value) === '[object String]'
106
- ),
107
- };
108
- return new Promise((resolve) => resolve());
109
- };
110
- }
111
-
112
- function mockSuccessfulHeadlessInitialization() {
113
- // @ts-ignore
114
- mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
115
- if (element instanceof QuanticTimeframeFacet && !isInitialized) {
116
- isInitialized = true;
117
- initialize(exampleEngine);
118
- }
119
- };
120
- }
121
-
122
- function cleanup() {
123
- // The jsdom instance is shared across test cases in a single file so reset the DOM
124
- while (document.body.firstChild) {
125
- document.body.removeChild(document.body.firstChild);
126
- }
127
- jest.clearAllMocks();
128
- isInitialized = false;
129
- }
130
-
131
- describe('c-quantic-timeframe-facet', () => {
132
- beforeAll(() => {
133
- mockSuccessfulHeadlessInitialization();
134
- mockBueno();
135
- });
136
-
137
- afterEach(() => {
138
- cleanup();
139
- });
140
-
141
- describe('the facet conditions manager', () => {
142
- it('should build the controller when the dependsOn property is set', async () => {
143
- const exampleFacetDependency = {
144
- parentFacetId: 'filetype',
145
- expectedValue: 'txt',
146
- };
147
- createTestComponent({
148
- ...defaultOptions,
149
- dependsOn: exampleFacetDependency,
150
- });
151
- await flushPromises();
152
-
153
- expect(functionsMocks.buildDateFacet).toHaveBeenCalledTimes(1);
154
- expect(functionsMocks.buildDateFilter).toHaveBeenCalledTimes(1);
155
- expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledTimes(
156
- 2
157
- );
158
- expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledWith(
159
- exampleEngine,
160
- {
161
- facetId: exampleFacetId,
162
- }
163
- );
164
- expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledWith(
165
- exampleEngine,
166
- {
167
- facetId: exampleFilterId,
168
- }
169
- );
170
-
171
- expect(generateFacetDependencyConditions).toHaveBeenCalledTimes(2);
172
- expect(generateFacetDependencyConditions).toHaveBeenCalledWith({
173
- [exampleFacetDependency.parentFacetId]:
174
- exampleFacetDependency.expectedValue,
175
- });
176
- });
177
-
178
- it('should not build the controller when the dependsOn property is not set', async () => {
179
- createTestComponent();
180
- await flushPromises();
181
-
182
- expect(functionsMocks.buildDateFacet).toHaveBeenCalledTimes(1);
183
- expect(functionsMocks.buildDateFilter).toHaveBeenCalledTimes(1);
184
- expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledTimes(
185
- 0
186
- );
187
- expect(generateFacetDependencyConditions).toHaveBeenCalledTimes(0);
188
- });
189
- });
190
-
191
- describe('the facet enablement', () => {
192
- describe('when the facet is enabled', () => {
193
- beforeAll(() => {
194
- functionsMocks.buildDateFacet.mockReturnValue({
195
- ...timeframeFacetControllerMock,
196
- state: {...timeframeFacetControllerMock.state, enabled: true},
197
- });
198
- });
199
-
200
- it('should display the facet content', async () => {
201
- const element = createTestComponent();
202
- await flushPromises();
203
-
204
- const facetContent = element.shadowRoot.querySelector(
205
- selectors.facetContent
206
- );
207
- expect(facetContent).not.toBeNull();
208
- });
209
- });
210
-
211
- describe('when the facet is not enabled', () => {
212
- beforeAll(() => {
213
- functionsMocks.buildDateFacet.mockReturnValue({
214
- ...timeframeFacetControllerMock,
215
- state: {...timeframeFacetControllerMock.state, enabled: false},
216
- });
217
- });
218
-
219
- it('should not display the facet content', async () => {
220
- const element = createTestComponent();
221
- await flushPromises();
222
-
223
- const facetContent = element.shadowRoot.querySelector(
224
- selectors.facetContent
225
- );
226
- expect(facetContent).toBeNull();
227
- });
228
- });
229
-
230
- afterAll(() => {
231
- functionsMocks.buildDateFacet.mockReturnValue(
232
- timeframeFacetControllerMock
233
- );
234
- });
235
- });
236
-
237
- describe('validation of the dependsOn property', () => {
238
- let consoleError;
239
- beforeAll(() => {
240
- consoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
241
- });
242
- describe('when dependsOn.parentFacetId is not provided', () => {
243
- it('should display the error component', async () => {
244
- const invalidFacetDependency = {
245
- expectedValue: 'txt',
246
- };
247
- const element = createTestComponent({
248
- ...defaultOptions,
249
- dependsOn: invalidFacetDependency,
250
- });
251
- await flushPromises();
252
-
253
- const componentError = element.shadowRoot.querySelector(
254
- selectors.componentError
255
- );
256
- const facetContent = element.shadowRoot.querySelector(
257
- selectors.facetContent
258
- );
259
-
260
- expect(consoleError).toHaveBeenCalledTimes(1);
261
- expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
262
- expect(componentError).not.toBeNull();
263
- expect(facetContent).toBeNull();
264
- });
265
- });
266
-
267
- describe('when dependsOn.parentFacetId is not a string', () => {
268
- it('should display the error component', async () => {
269
- const invalidFacetDependency = {
270
- parentFacetId: 1,
271
- expectedValue: 'txt',
272
- };
273
- const element = createTestComponent({
274
- ...defaultOptions,
275
- dependsOn: invalidFacetDependency,
276
- });
277
- await flushPromises();
278
-
279
- const componentError = element.shadowRoot.querySelector(
280
- selectors.componentError
281
- );
282
- const facetContent = element.shadowRoot.querySelector(
283
- selectors.facetContent
284
- );
285
-
286
- expect(consoleError).toHaveBeenCalledTimes(1);
287
- expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
288
- expect(componentError).not.toBeNull();
289
- expect(facetContent).toBeNull();
290
- });
291
- });
292
-
293
- describe('when dependsOn.expectedValue is not a string', () => {
294
- it('should display the error component', async () => {
295
- const invalidFacetDependency = {
296
- parentFacetId: 'filetype',
297
- expectedValue: 2,
298
- };
299
- const element = createTestComponent({
300
- ...defaultOptions,
301
- dependsOn: invalidFacetDependency,
302
- });
303
- await flushPromises();
304
-
305
- const componentError = element.shadowRoot.querySelector(
306
- selectors.componentError
307
- );
308
- const facetContent = element.shadowRoot.querySelector(
309
- selectors.facetContent
310
- );
311
-
312
- expect(consoleError).toHaveBeenCalledTimes(1);
313
- expect(consoleError).toHaveBeenCalledWith(expectedValueError);
314
- expect(componentError).not.toBeNull();
315
- expect(facetContent).toBeNull();
316
- });
317
- });
318
- });
319
-
320
- describe('when the component is disconnected', () => {
321
- it('should make the condition manager stop watching the facet', async () => {
322
- const exampleFacetDependency = {
323
- parentFacetId: 'filetype',
324
- expectedValue: 'txt',
325
- };
326
- const element = createTestComponent({
327
- ...defaultOptions,
328
- dependsOn: exampleFacetDependency,
329
- });
330
- await flushPromises();
331
- expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledTimes(
332
- 2
333
- );
334
-
335
- document.body.removeChild(element);
336
- expect(functionsMocks.stopWatching).toHaveBeenCalledTimes(2);
337
- });
338
- });
339
- });
@@ -1,107 +0,0 @@
1
- // @ts-ignore
2
- import {createElement} from 'lwc';
3
- import QuanticTooltip from '../quanticTooltip';
4
-
5
- const exampleItemOne = document.createElement('div');
6
- exampleItemOne.innerText = 'Item One';
7
- const exampleValue = 'Example value';
8
- const exampleAssignedElements = [exampleItemOne];
9
-
10
- const selectors = {
11
- tooltip: '.tooltip__content',
12
- };
13
-
14
- const exampleOptions = {
15
- value: exampleValue,
16
- };
17
-
18
- function createTestComponent(
19
- options = exampleOptions,
20
- assignedElements = exampleAssignedElements
21
- ) {
22
- mockSlotAssignedNodes(assignedElements);
23
-
24
- const element = createElement('c-quantic-tooltip', {
25
- is: QuanticTooltip,
26
- });
27
-
28
- for (const [key, value] of Object.entries(options)) {
29
- element[key] = value;
30
- }
31
-
32
- document.body.appendChild(element);
33
- return element;
34
- }
35
-
36
- // Helper function to wait until the microtask queue is empty.
37
- function flushPromises() {
38
- // eslint-disable-next-line @lwc/lwc/no-async-operation
39
- return new Promise((resolve) => setTimeout(resolve, 0));
40
- }
41
-
42
- /**
43
- * Mocks the return value of the assignedNodes method.
44
- * @param {Array<Element>} assignedElements
45
- */
46
- function mockSlotAssignedNodes(assignedElements) {
47
- HTMLSlotElement.prototype.assignedNodes = function () {
48
- return assignedElements;
49
- };
50
- }
51
-
52
- describe('c-quantic-tooltip', () => {
53
- function cleanup() {
54
- // The jsdom instance is shared across test cases in a single file so reset the DOM
55
- while (document.body.firstChild) {
56
- document.body.removeChild(document.body.firstChild);
57
- }
58
- jest.clearAllMocks();
59
- }
60
-
61
- afterEach(() => {
62
- cleanup();
63
- });
64
-
65
- it('should display the tooltip when the method showTooltip is called', async () => {
66
- const element = createTestComponent();
67
- await flushPromises();
68
-
69
- const tooltip = element.shadowRoot.querySelector(selectors.tooltip);
70
-
71
- expect(tooltip).not.toBeNull();
72
- expect(tooltip.classList.contains('tooltip__content--visible')).toBe(false);
73
-
74
- await element.showTooltip();
75
-
76
- expect(tooltip.classList.contains('tooltip__content--visible')).toBe(true);
77
- });
78
-
79
- it('should hide the tooltip when the method hideTooltip method is called', async () => {
80
- const element = createTestComponent();
81
- await flushPromises();
82
- await element.showTooltip();
83
-
84
- const tooltip = element.shadowRoot.querySelector(selectors.tooltip);
85
-
86
- expect(tooltip).not.toBeNull();
87
- expect(tooltip.classList.contains('tooltip__content--visible')).toBe(true);
88
-
89
- await element.hideTooltip();
90
-
91
- expect(tooltip.classList.contains('tooltip__content--visible')).toBe(false);
92
- });
93
-
94
- it('should not display the tooltip when the slot content is empty', async () => {
95
- const element = createTestComponent(exampleOptions, []);
96
- await flushPromises();
97
-
98
- const tooltip = element.shadowRoot.querySelector(selectors.tooltip);
99
-
100
- expect(tooltip).not.toBeNull();
101
- expect(tooltip.classList.contains('tooltip__content--visible')).toBe(false);
102
-
103
- await element.showTooltip();
104
-
105
- expect(tooltip.classList.contains('tooltip__content--visible')).toBe(false);
106
- });
107
- });