@coveo/quantic 3.16.0 → 3.16.1-pre.17ed3a22d0

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 (112) 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 +2 -2
  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/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
  7. package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -10
  8. package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +2 -2
  9. package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +2 -2
  10. package/package.json +6 -4
  11. package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +0 -604
  12. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/fixture.ts +0 -76
  13. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/pageObject.ts +0 -282
  14. package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/quanticBreadcrumbManager.e2e.ts +0 -167
  15. package/force-app/main/default/lwc/quanticCarousel/__tests__/quanticCarousel.test.js +0 -262
  16. package/force-app/main/default/lwc/quanticCaseClassification/__tests__/quanticCaseClassification.test.js +0 -819
  17. package/force-app/main/default/lwc/quanticCaseClassification/e2e/data.ts +0 -23
  18. package/force-app/main/default/lwc/quanticCaseClassification/e2e/fixture.ts +0 -51
  19. package/force-app/main/default/lwc/quanticCaseClassification/e2e/pageObject.ts +0 -152
  20. package/force-app/main/default/lwc/quanticCaseClassification/e2e/quanticCaseClassification.e2e.ts +0 -269
  21. package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +0 -327
  22. package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +0 -269
  23. package/force-app/main/default/lwc/quanticColoredResultBadge/__tests__/quanticColoredResultBadge.test.js +0 -212
  24. package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +0 -321
  25. package/force-app/main/default/lwc/quanticDidYouMean/__tests__/quanticDidYouMean.test.js +0 -199
  26. package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +0 -341
  27. package/force-app/main/default/lwc/quanticFacetCaption/__tests__/quanticFacetCaption.test.js +0 -28
  28. package/force-app/main/default/lwc/quanticFacetManager/__tests__/quanticFacetManager.test.js +0 -178
  29. package/force-app/main/default/lwc/quanticFacetManager/e2e/fixture.ts +0 -63
  30. package/force-app/main/default/lwc/quanticFacetManager/e2e/pageObject.ts +0 -23
  31. package/force-app/main/default/lwc/quanticFacetManager/e2e/quanticFacetManager.e2e.ts +0 -82
  32. package/force-app/main/default/lwc/quanticFeedback/__tests__/quanticFeedback.test.js +0 -392
  33. package/force-app/main/default/lwc/quanticFeedbackModal/__tests__/quanticFeedbackModal.test.js +0 -448
  34. package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +0 -298
  35. package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +0 -814
  36. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +0 -56
  37. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +0 -87
  38. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +0 -283
  39. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +0 -199
  40. package/force-app/main/default/lwc/quanticGeneratedAnswerContent/__tests__/quanticGeneratedAnswerContent.test.js +0 -151
  41. package/force-app/main/default/lwc/quanticHeading/__tests__/quanticHeading.test.js +0 -71
  42. package/force-app/main/default/lwc/quanticHeadlessLoader/__tests__/quanticHeadlessLoader.test.js +0 -651
  43. package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +0 -335
  44. package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +0 -343
  45. package/force-app/main/default/lwc/quanticPager/e2e/fixture.ts +0 -63
  46. package/force-app/main/default/lwc/quanticPager/e2e/pageObject.ts +0 -69
  47. package/force-app/main/default/lwc/quanticPager/e2e/quanticPager.e2e.ts +0 -101
  48. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/defaultTestCase.json +0 -13
  49. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/youtubeTestCase.json +0 -14
  50. package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/quanticQuickviewContent.test.js +0 -82
  51. package/force-app/main/default/lwc/quanticRadioButtonsGroup/__tests__/quanticRadioButtonsGroup.test.js +0 -273
  52. package/force-app/main/default/lwc/quanticRefineModalContent/__tests__/quanticRefineModalContent.test.js +0 -501
  53. package/force-app/main/default/lwc/quanticResultAction/__tests__/quanticResultAction.test.js +0 -262
  54. package/force-app/main/default/lwc/quanticResultActionBar/__tests__/quanticResultActionBar.test.js +0 -141
  55. package/force-app/main/default/lwc/quanticResultChildren/__tests__/quanticResultChildren.test.js +0 -340
  56. package/force-app/main/default/lwc/quanticResultDate/__tests__/quanticResultDate.test.js +0 -144
  57. package/force-app/main/default/lwc/quanticResultField/__tests__/quanticResultField.test.js +0 -120
  58. package/force-app/main/default/lwc/quanticResultHighlightedTextField/__tests__/quanticResultHighlightedTextField.test.js +0 -209
  59. package/force-app/main/default/lwc/quanticResultLink/__tests__/quanticResultLink.test.js +0 -261
  60. package/force-app/main/default/lwc/quanticResultMultiValueText/__tests__/quanticResultMultiValueText.test.js +0 -235
  61. package/force-app/main/default/lwc/quanticResultNumber/__tests__/quanticResultNumber.test.js +0 -144
  62. package/force-app/main/default/lwc/quanticResultPrintableUri/__tests__/quanticResultPrintableUri.test.js +0 -324
  63. package/force-app/main/default/lwc/quanticResultQuickview/__tests__/quanticResultQuickview.test.js +0 -171
  64. package/force-app/main/default/lwc/quanticResultText/__tests__/quanticResultText.test.js +0 -155
  65. package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js +0 -404
  66. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +0 -74
  67. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/pageObject.ts +0 -85
  68. package/force-app/main/default/lwc/quanticResultsPerPage/e2e/quanticResultsPerPage.e2e.ts +0 -97
  69. package/force-app/main/default/lwc/quanticSearchBox/__tests__/quanticSearchBox.test.js +0 -168
  70. package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js +0 -823
  71. package/force-app/main/default/lwc/quanticSmartSnippet/__tests__/quanticSmartSnippet.test.js +0 -341
  72. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/data.ts +0 -21
  73. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/fixture.ts +0 -91
  74. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +0 -196
  75. package/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +0 -168
  76. package/force-app/main/default/lwc/quanticSmartSnippetAnswer/__tests__/quanticSmartSnippetAnswer.test.js +0 -126
  77. package/force-app/main/default/lwc/quanticSmartSnippetSource/__tests__/quanticSmartSnippetSource.test.js +0 -290
  78. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/__tests__/quanticSmartSnippetSuggestions.test.js +0 -329
  79. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/data.ts +0 -31
  80. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/fixture.ts +0 -93
  81. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/pageObject.ts +0 -160
  82. package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/quanticSmartSnippetSuggestions.e2e.ts +0 -127
  83. package/force-app/main/default/lwc/quanticSort/__tests__/quanticSort.test.js +0 -416
  84. package/force-app/main/default/lwc/quanticSort/e2e/fixture.ts +0 -61
  85. package/force-app/main/default/lwc/quanticSort/e2e/pageObject.ts +0 -89
  86. package/force-app/main/default/lwc/quanticSort/e2e/quanticSort.e2e.ts +0 -91
  87. package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +0 -123
  88. package/force-app/main/default/lwc/quanticStandaloneSearchBox/__tests__/quanticStandaloneSearchBox.test.js +0 -186
  89. package/force-app/main/default/lwc/quanticStatefulButton/__tests__/quanticStatefulButton.test.js +0 -222
  90. package/force-app/main/default/lwc/quanticTab/__tests__/quanticTab.test.js +0 -287
  91. package/force-app/main/default/lwc/quanticTab/e2e/fixture.ts +0 -62
  92. package/force-app/main/default/lwc/quanticTab/e2e/pageObject.ts +0 -67
  93. package/force-app/main/default/lwc/quanticTab/e2e/quanticTab.e2e.ts +0 -77
  94. package/force-app/main/default/lwc/quanticTabBar/__tests__/quanticTabBar.test.js +0 -331
  95. package/force-app/main/default/lwc/quanticTabBar/e2e/fixture.ts +0 -61
  96. package/force-app/main/default/lwc/quanticTabBar/e2e/pageObject.ts +0 -80
  97. package/force-app/main/default/lwc/quanticTabBar/e2e/quanticTabBar.e2e.ts +0 -173
  98. package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +0 -339
  99. package/force-app/main/default/lwc/quanticTooltip/__tests__/quanticTooltip.test.js +0 -107
  100. package/force-app/main/default/lwc/quanticUserAction/__tests__/quanticUserAction.test.js +0 -427
  101. package/force-app/main/default/lwc/quanticUserActionsSession/__tests__/quanticUserActionsSession.test.js +0 -269
  102. package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/data/userActionsState.json +0 -89
  103. package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/quanticUserActionsTimeline.test.js +0 -511
  104. package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +0 -229
  105. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +0 -32
  106. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +0 -32
  107. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +0 -71
  108. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +0 -39
  109. package/force-app/main/default/lwc/quanticUtils/__tests__/facetDependenciesUtils.test.js +0 -92
  110. package/force-app/main/default/lwc/quanticUtils/__tests__/markdownUtils.test.js +0 -71
  111. package/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js +0 -223
  112. package/force-app/main/default/lwc/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +0 -131
@@ -1,341 +0,0 @@
1
- /* eslint-disable jest/no-conditional-expect */
2
- /* eslint-disable no-import-assign */
3
- import QuanticSmartSnippet from '../quanticSmartSnippet';
4
- // @ts-ignore
5
- import {createElement} from 'lwc';
6
- import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
7
-
8
- let mockAnswerHeight = 300;
9
-
10
- jest.mock('c/quanticHeadlessLoader');
11
- jest.mock('c/quanticUtils', () => ({
12
- getAbsoluteHeight: jest.fn(() => {
13
- return mockAnswerHeight;
14
- }),
15
- I18nUtils: {
16
- format: jest.fn(),
17
- },
18
- LinkUtils: {
19
- bindAnalyticsToLink: jest.fn(),
20
- },
21
- }));
22
-
23
- jest.mock(
24
- '@salesforce/label/c.quantic_SmartSnippetShowMore',
25
- () => ({default: 'Show more'}),
26
- {
27
- virtual: true,
28
- }
29
- );
30
-
31
- jest.mock(
32
- '@salesforce/label/c.quantic_SmartSnippetShowLess',
33
- () => ({default: 'Show less'}),
34
- {
35
- virtual: true,
36
- }
37
- );
38
-
39
- let isInitialized = false;
40
-
41
- const exampleEngine = {
42
- id: 'exampleEngineId',
43
- };
44
-
45
- const defaultOptions = {
46
- engineId: exampleEngine.id,
47
- };
48
-
49
- const selectors = {
50
- initializationError: 'c-quantic-component-error',
51
- smartSnippet: 'c-quantic-smart-snippet',
52
- smartSnippetAnswer: 'c-quantic-smart-snippet-answer',
53
- smartSnippetToggleButton: '[data-testid="smart-snippet__toggle-button"]',
54
- smartSnippetSource: 'c-quantic-smart-snippet-source',
55
- smartSnippetFeedback: 'c-quantic-feedback',
56
- };
57
-
58
- const defaultSearchStatusState = {
59
- hasResults: true,
60
- firstSearchExecuted: true,
61
- };
62
-
63
- let searchStatusState = defaultSearchStatusState;
64
-
65
- const mockSmartSnippetSource = {
66
- title: 'The Lord of the Rings',
67
- uri: 'https://en.wikipedia.org/wiki/The_Lord_of_the_Rings',
68
- };
69
-
70
- const defaultSmartSnippetState = {
71
- question: 'Where was Gondor when Westfold fell?',
72
- answer: 'Gondor was obviously busy with other things.',
73
- documentId: '1',
74
- expanded: false,
75
- answerFound: true,
76
- liked: false,
77
- disliked: false,
78
- feedbackModalOpen: false,
79
- source: mockSmartSnippetSource,
80
- };
81
-
82
- let smartSnippetState = defaultSmartSnippetState;
83
-
84
- const functionsMocks = {
85
- buildSmartSnippet: jest.fn(() => ({
86
- state: smartSnippetState,
87
- subscribe: functionsMocks.smartSnippetStateSubscriber,
88
- expand: functionsMocks.expand,
89
- collapse: functionsMocks.collapse,
90
- })),
91
- buildSearchStatus: jest.fn(() => ({
92
- state: searchStatusState,
93
- subscribe: functionsMocks.searchStatusStateSubscriber,
94
- })),
95
- smartSnippetStateSubscriber: jest.fn((cb) => {
96
- cb();
97
- return functionsMocks.smartSnippetStateUnsubscriber;
98
- }),
99
- searchStatusStateSubscriber: jest.fn((cb) => {
100
- cb();
101
- return functionsMocks.searchStatusStateUnsubscriber;
102
- }),
103
- smartSnippetStateUnsubscriber: jest.fn(),
104
- searchStatusStateUnsubscriber: jest.fn(),
105
- expand: jest.fn(),
106
- collapse: jest.fn(),
107
- };
108
-
109
- function createTestComponent(options = defaultOptions) {
110
- const element = createElement('c-quantic-smart-snippet', {
111
- is: QuanticSmartSnippet,
112
- });
113
- for (const [key, value] of Object.entries(options)) {
114
- element[key] = value;
115
- }
116
- document.body.appendChild(element);
117
- return element;
118
- }
119
-
120
- // Helper function to wait until the microtask queue is empty.
121
- function flushPromises() {
122
- return new Promise((resolve) => setTimeout(resolve, 0));
123
- }
124
-
125
- function prepareHeadlessState() {
126
- // @ts-ignore
127
- mockHeadlessLoader.getHeadlessBundle = () => {
128
- return {
129
- buildSmartSnippet: functionsMocks.buildSmartSnippet,
130
- buildSearchStatus: functionsMocks.buildSearchStatus,
131
- };
132
- };
133
- }
134
-
135
- function mockSuccessfulHeadlessInitialization() {
136
- // @ts-ignore
137
- mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
138
- if (element instanceof QuanticSmartSnippet && !isInitialized) {
139
- isInitialized = true;
140
- initialize(exampleEngine);
141
- }
142
- };
143
- }
144
-
145
- function mockErroneousHeadlessInitialization() {
146
- // @ts-ignore
147
- mockHeadlessLoader.initializeWithHeadless = (element) => {
148
- if (element instanceof QuanticSmartSnippet) {
149
- element.setInitializationError();
150
- }
151
- };
152
- }
153
-
154
- function cleanup() {
155
- // The jsdom instance is shared across test cases in a single file so reset the DOM
156
- while (document.body.firstChild) {
157
- document.body.removeChild(document.body.firstChild);
158
- }
159
- jest.clearAllMocks();
160
- isInitialized = false;
161
- }
162
-
163
- describe('c-quantic-smart-snippet', () => {
164
- afterEach(() => {
165
- smartSnippetState = defaultSmartSnippetState;
166
- searchStatusState = defaultSearchStatusState;
167
- cleanup();
168
- });
169
-
170
- describe('controller initialization', () => {
171
- beforeEach(() => {
172
- mockSuccessfulHeadlessInitialization();
173
- prepareHeadlessState();
174
- });
175
-
176
- it('should build the smart snippet controller with the proper parameters and subscribe to its state change', async () => {
177
- createTestComponent();
178
- await flushPromises();
179
-
180
- expect(functionsMocks.buildSmartSnippet).toHaveBeenCalledTimes(1);
181
- expect(functionsMocks.buildSmartSnippet).toHaveBeenCalledWith(
182
- exampleEngine
183
- );
184
- expect(functionsMocks.smartSnippetStateSubscriber).toHaveBeenCalledTimes(
185
- 1
186
- );
187
- });
188
-
189
- it('should build the search status controller with the proper parameters and subscribe to its state change', async () => {
190
- createTestComponent();
191
- await flushPromises();
192
-
193
- expect(functionsMocks.buildSearchStatus).toHaveBeenCalledTimes(1);
194
- expect(functionsMocks.buildSearchStatus).toHaveBeenCalledWith(
195
- exampleEngine
196
- );
197
- expect(functionsMocks.searchStatusStateSubscriber).toHaveBeenCalledTimes(
198
- 1
199
- );
200
- });
201
- });
202
-
203
- describe('when an initialization error occurs', () => {
204
- beforeEach(() => {
205
- mockErroneousHeadlessInitialization();
206
- });
207
-
208
- it('should display the initialization error component', async () => {
209
- const element = createTestComponent();
210
- await flushPromises();
211
-
212
- const initializationError = element.shadowRoot.querySelector(
213
- selectors.initializationError
214
- );
215
-
216
- expect(initializationError).not.toBeNull();
217
- });
218
- });
219
-
220
- describe('when the query does not return a smart snippet', () => {
221
- beforeAll(() => {
222
- smartSnippetState = {...defaultSmartSnippetState, answerFound: false};
223
- });
224
- it('should not display the smart snippet component', async () => {
225
- const element = createTestComponent();
226
- await flushPromises();
227
-
228
- const smartSnippet = element.shadowRoot.querySelector(
229
- selectors.smartSnippet
230
- );
231
- expect(smartSnippet).toBeNull();
232
- });
233
- });
234
-
235
- describe('when the query returns a smart snippet', () => {
236
- beforeEach(() => {
237
- mockSuccessfulHeadlessInitialization();
238
- prepareHeadlessState();
239
- smartSnippetState = defaultSmartSnippetState;
240
- });
241
-
242
- afterEach(() => {
243
- smartSnippetState = defaultSmartSnippetState;
244
- });
245
-
246
- it('should properly display the smart snippet', async () => {
247
- const element = createTestComponent();
248
- await flushPromises();
249
-
250
- const smartSnippetAnswer = element.shadowRoot.querySelector(
251
- selectors.smartSnippetAnswer
252
- );
253
-
254
- expect(smartSnippetAnswer).not.toBeNull();
255
- expect(smartSnippetAnswer.answer).toEqual(smartSnippetState.answer);
256
-
257
- const smartSnippetSource = element.shadowRoot.querySelector(
258
- selectors.smartSnippetSource
259
- );
260
- expect(smartSnippetSource).not.toBeNull();
261
- expect(smartSnippetSource.source).toEqual(smartSnippetState.source);
262
-
263
- const smartSnippetFeedback = element.shadowRoot.querySelector(
264
- selectors.smartSnippetFeedback
265
- );
266
- expect(smartSnippetFeedback).not.toBeNull();
267
- });
268
-
269
- describe('when the smart snippet exceeds the maximum height', () => {
270
- describe('when the smart snippet is collapsed', () => {
271
- it('should properly display the toggle button of the smart snippet component', async () => {
272
- const expectedShowMoreLabel = 'Show more';
273
- const expectedShowMoreIcon = 'utility:chevrondown';
274
- const element = createTestComponent();
275
- await flushPromises();
276
-
277
- const smartSnippetToggleButton = element.shadowRoot.querySelector(
278
- selectors.smartSnippetToggleButton
279
- );
280
-
281
- expect(smartSnippetToggleButton).not.toBeNull();
282
- expect(smartSnippetToggleButton.label).toBe(expectedShowMoreLabel);
283
- expect(smartSnippetToggleButton.iconName).toBe(expectedShowMoreIcon);
284
- });
285
-
286
- describe('when clicking on the smart snippet toggle button', () => {
287
- it('should call the expand method from the smartSnippet controller', async () => {
288
- const element = createTestComponent();
289
- await flushPromises();
290
-
291
- const smartSnippetToggleButton = element.shadowRoot.querySelector(
292
- selectors.smartSnippetToggleButton
293
- );
294
- expect(smartSnippetToggleButton).not.toBeNull();
295
-
296
- await smartSnippetToggleButton.click();
297
- await flushPromises();
298
-
299
- expect(functionsMocks.expand).toHaveBeenCalledTimes(1);
300
- });
301
- });
302
- });
303
-
304
- describe('when the smart snippet is expanded', () => {
305
- beforeEach(() => {
306
- smartSnippetState = {...defaultSmartSnippetState, expanded: true};
307
- });
308
-
309
- it('should properly display the smart snippet component', async () => {
310
- const expectedShowLessLabel = 'Show less';
311
- const expectedShowLessIcon = 'utility:chevronup';
312
- const element = createTestComponent();
313
- await flushPromises();
314
-
315
- const smartSnippetToggleButton = element.shadowRoot.querySelector(
316
- selectors.smartSnippetToggleButton
317
- );
318
- expect(smartSnippetToggleButton).not.toBeNull();
319
- expect(smartSnippetToggleButton.label).toBe(expectedShowLessLabel);
320
- expect(smartSnippetToggleButton.iconName).toBe(expectedShowLessIcon);
321
- });
322
-
323
- describe('when clicking on the smart snippet toggle button', () => {
324
- it('should call the collapse method from the smartSnippet controller', async () => {
325
- const element = createTestComponent();
326
- await flushPromises();
327
-
328
- const smartSnippetToggleButton = element.shadowRoot.querySelector(
329
- selectors.smartSnippetToggleButton
330
- );
331
-
332
- await smartSnippetToggleButton.click();
333
- await flushPromises();
334
-
335
- expect(functionsMocks.collapse).toHaveBeenCalledTimes(1);
336
- });
337
- });
338
- });
339
- });
340
- });
341
- });
@@ -1,21 +0,0 @@
1
- import {QuestionAnswerData} from '../../../../../../playwright/page-object/searchObjectWithSmartSnippet';
2
-
3
- const exampleQuestion = 'Where was Gondor when the Westfold fell?';
4
- const exampleAnswerSnippet = `<a href="#">Gondor</a> was on the brink of destruction when the Westfold fell. Gondor did not come to Rohan's aid when the Westfold fell because it was overwhelmed by its own dire circumstances and unable to spare resources or manpower. The alliance between the two kingdoms, forged by the Oath of Eorl, was based on a promise of mutual defense in times of extreme need. However, by the time of the War of the Ring, Gondor was facing unprecedented threats from Sauron, whose forces in Mordor were massing for a full-scale assault on Minas Tirith. The Steward of Gondor, Denethor II, was deeply concerned about the security of his own kingdom and could not afford to weaken its defenses to send aid across the vast distances that separated Gondor from the Westfold. Even if assistance had been feasible, the logistical challenge of moving troops through potentially hostile territory would have delayed their arrival, rendering their efforts ineffective. Moreover, the threat to Rohan came not only from Sauron's influence but also from the unexpected betrayal of Saruman, who, until then, had been perceived as an ally. His treachery, combined with the swiftness and brutality of his attacks, left Rohan vulnerable and isolated, as neither Rohan nor Gondor had anticipated such aggression from Isengard. While the alliance between the two realms remained strong in spirit, Gondor's immediate need to safeguard its own survival against the growing shadow of Mordor took precedence, leaving Rohan to fend for itself during the fall of the Westfold.`;
5
- const exampleScore = 0.42;
6
- const exampleContentIdKey = 'permanentid';
7
- const mockPermanentId = '1234';
8
- const exampleContentIdValue = mockPermanentId;
9
-
10
- const smartSnippetData: QuestionAnswerData = {
11
- answerFound: true,
12
- question: exampleQuestion,
13
- answerSnippet: exampleAnswerSnippet,
14
- documentId: {
15
- contentIdKey: exampleContentIdKey,
16
- contentIdValue: exampleContentIdValue,
17
- },
18
- score: exampleScore,
19
- };
20
-
21
- export default smartSnippetData;
@@ -1,91 +0,0 @@
1
- import {SmartSnippetObject} from './pageObject';
2
- import {quanticBase} from '../../../../../../playwright/fixtures/baseFixture';
3
- import {
4
- SearchObjectWithSmartSnippet,
5
- QuestionAnswerData,
6
- } from '../../../../../../playwright/page-object/searchObjectWithSmartSnippet';
7
- import {
8
- searchRequestRegex,
9
- insightSearchRequestRegex,
10
- } from '../../../../../../playwright/utils/requests';
11
- import {InsightSetupObject} from '../../../../../../playwright/page-object/insightSetupObject';
12
- import {useCaseEnum} from '../../../../../../playwright/utils/useCase';
13
- import smartSnippetData from './data';
14
-
15
- const pageUrl = 's/quantic-smart-snippet';
16
-
17
- interface SmartSnippetOptions {
18
- maximumSnippetHeight: number;
19
- }
20
-
21
- type QuanticSmartSnippetE2ESearchFixtures = {
22
- smartSnippetData: QuestionAnswerData;
23
- smartSnippet: SmartSnippetObject;
24
- search: SearchObjectWithSmartSnippet;
25
- options: Partial<SmartSnippetOptions>;
26
- };
27
-
28
- type QuanticSmartSnippetE2EInsightFixtures =
29
- QuanticSmartSnippetE2ESearchFixtures & {
30
- insightSetup: InsightSetupObject;
31
- };
32
-
33
- export const testSearch =
34
- quanticBase.extend<QuanticSmartSnippetE2ESearchFixtures>({
35
- smartSnippetData,
36
- options: {},
37
- search: async ({page}, use) => {
38
- await use(new SearchObjectWithSmartSnippet(page, searchRequestRegex));
39
- },
40
- smartSnippet: async (
41
- {page, options, configuration, search, smartSnippetData: data},
42
- use
43
- ) => {
44
- const smartSnippetObject = new SmartSnippetObject(page);
45
-
46
- await page.goto(pageUrl);
47
- await search.mockSearchWithSmartSnippetResponse(data);
48
-
49
- configuration.configure(options);
50
- await search.waitForSearchResponse();
51
- await use(smartSnippetObject);
52
- },
53
- });
54
-
55
- export const testInsight =
56
- quanticBase.extend<QuanticSmartSnippetE2EInsightFixtures>({
57
- smartSnippetData,
58
- options: {},
59
- search: async ({page}, use) => {
60
- await use(
61
- new SearchObjectWithSmartSnippet(page, insightSearchRequestRegex)
62
- );
63
- },
64
- insightSetup: async ({page}, use) => {
65
- await use(new InsightSetupObject(page));
66
- },
67
- smartSnippet: async (
68
- {
69
- page,
70
- options,
71
- search,
72
- configuration,
73
- insightSetup,
74
- smartSnippetData: data,
75
- },
76
- use
77
- ) => {
78
- const smartSnippetObject = new SmartSnippetObject(page);
79
-
80
- await page.goto(pageUrl);
81
- await search.mockSearchWithSmartSnippetResponse(data);
82
-
83
- configuration.configure({...options, useCase: useCaseEnum.insight});
84
- await insightSetup.waitForInsightInterfaceInitialization();
85
- await search.performSearch();
86
- await search.waitForSearchResponse();
87
- await use(smartSnippetObject);
88
- },
89
- });
90
-
91
- export {expect} from '@playwright/test';
@@ -1,196 +0,0 @@
1
- import type {Locator, Page, Request} from '@playwright/test';
2
- import {
3
- isUaClickEvent,
4
- isUaCustomEvent,
5
- } from '../../../../../../playwright/utils/requests';
6
-
7
- export class SmartSnippetObject {
8
- constructor(public page: Page) {
9
- this.page = page;
10
- }
11
-
12
- get smartSnippet(): Locator {
13
- return this.page.locator('c-quantic-smart-snippet');
14
- }
15
-
16
- get smartSnippetSourceTitle(): Locator {
17
- return this.page.getByTestId('smart-snippet__source-title');
18
- }
19
-
20
- get smartSnippetSourceUri(): Locator {
21
- return this.page.getByTestId('smart-snippet__source-uri');
22
- }
23
-
24
- get smartSnippetAnwerInlineLink(): Locator {
25
- return this.page.locator('[data-testid="smart-snippet-answer"] > a');
26
- }
27
-
28
- get smartSnippetToggleButton(): Locator {
29
- return this.page.getByTestId('smart-snippet__toggle-button');
30
- }
31
-
32
- get likeButton(): Locator {
33
- return this.page.getByTestId('feedback__like-button');
34
- }
35
-
36
- get dislikeButton(): Locator {
37
- return this.page.getByTestId('feedback__dislike-button');
38
- }
39
-
40
- get explainWhyButton(): Locator {
41
- return this.page.getByTestId('feedback__explain-why-button');
42
- }
43
-
44
- get feedbackModalCancelButton(): Locator {
45
- return this.page.getByTestId('feedback-modal-footer__cancel');
46
- }
47
-
48
- get feedbackModalDoneButton(): Locator {
49
- return this.page.getByTestId('feedback-modal-footer__done');
50
- }
51
-
52
- get firstFeedbackOptionLabel(): Locator {
53
- const labelFirstOption = "Didn't answer my question at all";
54
- return this.page.getByText(labelFirstOption);
55
- }
56
-
57
- get feedbackSubmitButton(): Locator {
58
- return this.page.getByTestId('feedback-modal-footer__submit');
59
- }
60
-
61
- async clickToggleButton(): Promise<void> {
62
- await this.smartSnippetToggleButton.click();
63
- }
64
-
65
- async clickOnSourceTitle(): Promise<void> {
66
- await this.smartSnippetSourceTitle.click();
67
- }
68
-
69
- async clickOnSourceUri(): Promise<void> {
70
- await this.smartSnippetSourceUri.click();
71
- }
72
-
73
- async clickOnFirstInlineLink(): Promise<void> {
74
- await this.smartSnippetAnwerInlineLink.first().click();
75
- }
76
-
77
- async clickLikeButton(): Promise<void> {
78
- await this.likeButton.click();
79
- }
80
-
81
- async clickDislikeButton(): Promise<void> {
82
- await this.dislikeButton.click();
83
- }
84
-
85
- async clickExplainWhyButton(): Promise<void> {
86
- await this.explainWhyButton.click();
87
- }
88
-
89
- async clickFeedbackModalCancelButton(): Promise<void> {
90
- await this.feedbackModalCancelButton.click();
91
- }
92
-
93
- async selectFirstFeedbackOptionLabel(): Promise<void> {
94
- await this.firstFeedbackOptionLabel.click({force: true});
95
- }
96
-
97
- async clickFeedbackSubmitButton(): Promise<void> {
98
- await this.feedbackSubmitButton.click();
99
- }
100
-
101
- async clickFeedbackModalDoneButton(): Promise<void> {
102
- await this.feedbackModalDoneButton.click();
103
- }
104
-
105
- async waitForExpandSmartSnippetUaAnalytics(): Promise<Request> {
106
- return this.waitForSmartSnippetCustomUaAnalytics('expandSmartSnippet');
107
- }
108
-
109
- async waitForCollapseSmartSnippetUaAnalytics(): Promise<Request> {
110
- return this.waitForSmartSnippetCustomUaAnalytics('collapseSmartSnippet');
111
- }
112
-
113
- async waitForLikeSmartSnippetUaAnalytics(): Promise<Request> {
114
- return this.waitForSmartSnippetCustomUaAnalytics('likeSmartSnippet');
115
- }
116
-
117
- async waitForDislikeSmartSnippetUaAnalytics(): Promise<Request> {
118
- return this.waitForSmartSnippetCustomUaAnalytics('dislikeSmartSnippet');
119
- }
120
-
121
- async waitForOpenFeedbackModalUaAnalytics(): Promise<Request> {
122
- return this.waitForSmartSnippetCustomUaAnalytics(
123
- 'openSmartSnippetFeedbackModal'
124
- );
125
- }
126
-
127
- async waitForCloseFeedbackModalUaAnalytics(): Promise<Request> {
128
- return this.waitForSmartSnippetCustomUaAnalytics(
129
- 'closeSmartSnippetFeedbackModal'
130
- );
131
- }
132
-
133
- async waitForFeedbackSubmitUaAnalytics(
134
- expectedReason: string
135
- ): Promise<Request> {
136
- return this.waitForSmartSnippetCustomUaAnalytics(
137
- 'sendSmartSnippetReason',
138
- expectedReason
139
- );
140
- }
141
-
142
- async waitForSmartSnippetSourceClickUaAnalytics(): Promise<Request> {
143
- return this.waitForSmartSnippetClickUaAnalytics('openSmartSnippetSource');
144
- }
145
-
146
- async waitForSmartSnippetInlineLinkClickUaAnalytics(): Promise<Request> {
147
- return this.waitForSmartSnippetClickUaAnalytics(
148
- 'openSmartSnippetInlineLink'
149
- );
150
- }
151
-
152
- async waitForSmartSnippetClickUaAnalytics(
153
- actionCause: string
154
- ): Promise<Request> {
155
- const uaRequest = this.page.waitForRequest((request) => {
156
- if (isUaClickEvent(request)) {
157
- const requestBody = request.postDataJSON?.();
158
- const requestData = JSON.parse(requestBody.clickEvent);
159
-
160
- const expectedFields: Record<string, any> = {
161
- actionCause,
162
- };
163
-
164
- return requestData?.actionCause === expectedFields.actionCause;
165
- }
166
- return false;
167
- });
168
- return uaRequest;
169
- }
170
-
171
- async waitForSmartSnippetCustomUaAnalytics(
172
- eventValue: any,
173
- reason?: string
174
- ): Promise<Request> {
175
- const uaRequest = this.page.waitForRequest((request) => {
176
- if (isUaCustomEvent(request)) {
177
- const requestBody = request.postDataJSON?.();
178
- const expectedFields: Record<string, any> = {
179
- eventType: 'smartSnippet',
180
- eventValue: eventValue,
181
- };
182
-
183
- const matchesExpectedFields = Object.keys(expectedFields).every(
184
- (key) => requestBody?.[key] === expectedFields[key]
185
- );
186
-
187
- const customData = requestBody?.customData;
188
- const matchesReason = customData?.reason === reason;
189
-
190
- return matchesExpectedFields && matchesReason;
191
- }
192
- return false;
193
- });
194
- return uaRequest;
195
- }
196
- }