@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,287 +0,0 @@
1
- /* eslint-disable jest/no-conditional-expect */
2
- /* eslint-disable no-import-assign */
3
- import QuanticTab from '../quanticTab';
4
- // @ts-ignore
5
- import {createElement} from 'lwc';
6
- import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
7
-
8
- jest.mock('c/quanticHeadlessLoader');
9
-
10
- let isInitialized = false;
11
-
12
- const exampleEngine = {
13
- id: 'exampleEngineId',
14
- };
15
-
16
- const defaultOptions = {
17
- engineId: exampleEngine.id,
18
- label: 'Example Tab',
19
- expression: 'exampleExpression',
20
- isActive: false,
21
- };
22
-
23
- const selectors = {
24
- initializationError: 'c-quantic-component-error',
25
- tabButton: 'button',
26
- };
27
-
28
- const defaultSearchStatusState = {
29
- hasResults: true,
30
- firstSearchExecuted: true,
31
- };
32
- let searchStatusState = defaultSearchStatusState;
33
-
34
- const defaultTabState = {
35
- isActive: false,
36
- };
37
- let tabState = defaultTabState;
38
-
39
- const functionsMocks = {
40
- buildTab: jest.fn(() => ({
41
- state: tabState,
42
- subscribe: functionsMocks.tabStateSubscriber,
43
- select: functionsMocks.select,
44
- })),
45
- buildSearchStatus: jest.fn(() => ({
46
- state: searchStatusState,
47
- subscribe: functionsMocks.searchStatusStateSubscriber,
48
- })),
49
- tabStateSubscriber: jest.fn((cb) => {
50
- cb();
51
- return functionsMocks.tabStateUnsubscriber;
52
- }),
53
- searchStatusStateSubscriber: jest.fn((cb) => {
54
- cb();
55
- return functionsMocks.searchStatusStateUnsubscriber;
56
- }),
57
- tabStateUnsubscriber: jest.fn(),
58
- searchStatusStateUnsubscriber: jest.fn(),
59
- exampleTabRendered: jest.fn(),
60
- select: jest.fn(),
61
- };
62
-
63
- const expectedActiveTabClass = 'slds-is-active';
64
-
65
- function createTestComponent(options = defaultOptions) {
66
- const element = createElement('c-quantic-tab', {
67
- is: QuanticTab,
68
- });
69
- for (const [key, value] of Object.entries(options)) {
70
- element[key] = value;
71
- }
72
- document.body.appendChild(element);
73
- return element;
74
- }
75
-
76
- function prepareHeadlessState() {
77
- // @ts-ignore
78
- mockHeadlessLoader.getHeadlessBundle = () => {
79
- return {
80
- buildTab: functionsMocks.buildTab,
81
- buildSearchStatus: functionsMocks.buildSearchStatus,
82
- };
83
- };
84
- }
85
-
86
- // Helper function to wait until the microtask queue is empty.
87
- function flushPromises() {
88
- return new Promise((resolve) => setTimeout(resolve, 0));
89
- }
90
-
91
- function mockSuccessfulHeadlessInitialization() {
92
- // @ts-ignore
93
- mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
94
- if (element instanceof QuanticTab && !isInitialized) {
95
- isInitialized = true;
96
- initialize(exampleEngine);
97
- }
98
- };
99
- }
100
-
101
- function mockErroneousHeadlessInitialization() {
102
- // @ts-ignore
103
- mockHeadlessLoader.initializeWithHeadless = (element) => {
104
- if (element instanceof QuanticTab) {
105
- element.setInitializationError();
106
- }
107
- };
108
- }
109
-
110
- function setupEventListeners(element) {
111
- element.addEventListener(
112
- 'quantic__tabrendered',
113
- functionsMocks.exampleTabRendered
114
- );
115
- }
116
-
117
- function cleanup() {
118
- // The jsdom instance is shared across test cases in a single file so reset the DOM
119
- while (document.body.firstChild) {
120
- document.body.removeChild(document.body.firstChild);
121
- }
122
- jest.clearAllMocks();
123
- isInitialized = false;
124
- }
125
-
126
- describe('c-quantic-tab', () => {
127
- beforeEach(() => {
128
- mockSuccessfulHeadlessInitialization();
129
- prepareHeadlessState();
130
- });
131
-
132
- afterEach(() => {
133
- tabState = defaultTabState;
134
- searchStatusState = defaultSearchStatusState;
135
- cleanup();
136
- });
137
-
138
- describe('component initialization', () => {
139
- it('should build the tab and search status controllers with the proper parameters', async () => {
140
- createTestComponent();
141
- await flushPromises();
142
-
143
- expect(functionsMocks.buildTab).toHaveBeenCalledTimes(1);
144
- expect(functionsMocks.buildTab).toHaveBeenCalledWith(exampleEngine, {
145
- options: {
146
- expression: defaultOptions.expression,
147
- id: defaultOptions.label,
148
- },
149
- initialState: {
150
- isActive: defaultOptions.isActive,
151
- },
152
- });
153
- expect(functionsMocks.buildSearchStatus).toHaveBeenCalledTimes(1);
154
- expect(functionsMocks.buildSearchStatus).toHaveBeenCalledWith(
155
- exampleEngine
156
- );
157
- });
158
-
159
- it('should subscribe to the headless tab and search status state changes', async () => {
160
- createTestComponent();
161
- await flushPromises();
162
-
163
- expect(functionsMocks.tabStateSubscriber).toHaveBeenCalledTimes(1);
164
- expect(functionsMocks.searchStatusStateSubscriber).toHaveBeenCalledTimes(
165
- 1
166
- );
167
- });
168
-
169
- it('should dispatch the quantic__tabrendered event', async () => {
170
- const element = createTestComponent();
171
- setupEventListeners(element);
172
- await flushPromises();
173
-
174
- expect(functionsMocks.exampleTabRendered).toHaveBeenCalledTimes(1);
175
- });
176
- });
177
-
178
- describe('when an initialization error occurs', () => {
179
- beforeEach(() => {
180
- mockErroneousHeadlessInitialization();
181
- });
182
-
183
- afterAll(() => {
184
- mockSuccessfulHeadlessInitialization();
185
- });
186
-
187
- it('should display the initialization error component', async () => {
188
- const element = createTestComponent();
189
- await flushPromises();
190
-
191
- const initializationError = element.shadowRoot.querySelector(
192
- selectors.initializationError
193
- );
194
-
195
- expect(initializationError).not.toBeNull();
196
- });
197
- });
198
-
199
- describe('component behavior during the initial search', () => {
200
- describe('when the initial search is not yet executed', () => {
201
- beforeAll(() => {
202
- searchStatusState = {...searchStatusState, firstSearchExecuted: false};
203
- });
204
-
205
- it('should not show the tab before the initial search completes', async () => {
206
- const element = createTestComponent();
207
- await flushPromises();
208
-
209
- const tab = element.shadowRoot.querySelector(selectors.tabButton);
210
-
211
- expect(tab).toBeNull();
212
- });
213
- });
214
-
215
- describe('when the initial search is executed', () => {
216
- beforeAll(() => {
217
- searchStatusState = {...searchStatusState, firstSearchExecuted: true};
218
- });
219
-
220
- it('should show the tab after the initial search completes', async () => {
221
- const element = createTestComponent();
222
- await flushPromises();
223
-
224
- const tab = element.shadowRoot.querySelector(selectors.tabButton);
225
-
226
- expect(tab).not.toBeNull();
227
- expect(tab.textContent).toBe(defaultOptions.label);
228
- expect(tab.title).toEqual(defaultOptions.label);
229
- expect(tab.getAttribute('aria-pressed')).toBe('false');
230
- expect(tab.getAttribute('aria-label')).toBe(defaultOptions.label);
231
- });
232
- });
233
- });
234
-
235
- describe('when the tab is not active', () => {
236
- beforeAll(() => {
237
- tabState = {...tabState, isActive: false};
238
- });
239
-
240
- it('should not display the tab as an active tab', async () => {
241
- const element = createTestComponent();
242
- await flushPromises();
243
-
244
- const tab = element.shadowRoot.querySelector(selectors.tabButton);
245
- expect(tab).not.toBeNull();
246
-
247
- expect(tab.classList).not.toContain(expectedActiveTabClass);
248
- expect(element.isActive).toBe(false);
249
- });
250
- });
251
-
252
- describe('when the tab is active', () => {
253
- beforeAll(() => {
254
- tabState = {...tabState, isActive: true};
255
- });
256
-
257
- it('should display the tab as an active tab', async () => {
258
- const element = createTestComponent();
259
- await flushPromises();
260
-
261
- const tab = element.shadowRoot.querySelector(selectors.tabButton);
262
-
263
- expect(tab.classList).toContain(expectedActiveTabClass);
264
- expect(element.isActive).toBe(true);
265
- });
266
- });
267
-
268
- describe('when the tab is clicked or the select method is called', () => {
269
- it('should call the select method of the tab controller', async () => {
270
- const element = createTestComponent();
271
- await flushPromises();
272
-
273
- const tab = element.shadowRoot.querySelector(selectors.tabButton);
274
- expect(tab).not.toBeNull();
275
-
276
- await tab.click();
277
- await flushPromises();
278
-
279
- expect(functionsMocks.select).toHaveBeenCalledTimes(1);
280
-
281
- await element.select();
282
- await flushPromises();
283
-
284
- expect(functionsMocks.select).toHaveBeenCalledTimes(2);
285
- });
286
- });
287
- });
@@ -1,62 +0,0 @@
1
- import {TabObject} from './pageObject';
2
- import {SearchObject} from '../../../../../../playwright/page-object/searchObject';
3
- import {quanticBase} from '../../../../../../playwright/fixtures/baseFixture';
4
- import {useCaseEnum} from '../../../../../../playwright/utils/useCase';
5
- import {InsightSetupObject} from '../../../../../../playwright/page-object/insightSetupObject';
6
- import {
7
- searchRequestRegex,
8
- insightSearchRequestRegex,
9
- } from '../../../../../../playwright/utils/requests';
10
-
11
- const pageUrl = 's/quantic-tab';
12
-
13
- interface TabOptions {}
14
-
15
- type QuanticTabE2EFixtures = {
16
- tab: TabObject;
17
- search: SearchObject;
18
- options: Partial<TabOptions>;
19
- };
20
-
21
- type QuanticTabE2ESearchFixtures = QuanticTabE2EFixtures & {
22
- urlHash: string;
23
- };
24
-
25
- type QuanticTabE2EInsightFixtures = QuanticTabE2EFixtures & {
26
- insightSetup: InsightSetupObject;
27
- };
28
-
29
- export const testSearch = quanticBase.extend<QuanticTabE2ESearchFixtures>({
30
- options: {},
31
- urlHash: '',
32
- search: async ({page}, use) => {
33
- await use(new SearchObject(page, searchRequestRegex));
34
- },
35
- tab: async ({page, options, configuration, search, urlHash}, use) => {
36
- await page.goto(urlHash ? `${pageUrl}#${urlHash}` : pageUrl);
37
- configuration.configure(options);
38
- await search.waitForSearchResponse();
39
-
40
- await use(new TabObject(page));
41
- },
42
- });
43
-
44
- export const testInsight = quanticBase.extend<QuanticTabE2EInsightFixtures>({
45
- options: {},
46
- search: async ({page}, use) => {
47
- await use(new SearchObject(page, insightSearchRequestRegex));
48
- },
49
- insightSetup: async ({page}, use) => {
50
- await use(new InsightSetupObject(page));
51
- },
52
- tab: async ({page, options, search, configuration, insightSetup}, use) => {
53
- await page.goto(pageUrl);
54
- configuration.configure({...options, useCase: useCaseEnum.insight});
55
- await insightSetup.waitForInsightInterfaceInitialization();
56
- await search.performSearch();
57
- await search.waitForSearchResponse();
58
- await use(new TabObject(page));
59
- },
60
- });
61
-
62
- export {expect} from '@playwright/test';
@@ -1,67 +0,0 @@
1
- import type {Locator, Page, Request, Response} from '@playwright/test';
2
- import {isUaSearchEvent} from '../../../../../../playwright/utils/requests';
3
-
4
- export class TabObject {
5
- constructor(public page: Page) {
6
- this.page = page;
7
- }
8
-
9
- get tab(): Locator {
10
- return this.page.locator('c-quantic-tab');
11
- }
12
-
13
- tabButton(tabLabel): Locator {
14
- return this.tab.getByRole('button', {name: new RegExp(`^${tabLabel}$`)});
15
- }
16
-
17
- get activeTabLabel(): Promise<string | null> {
18
- return this.tab.locator('button.slds-is-active').textContent();
19
- }
20
-
21
- async clickTabButton(tabLabel: string): Promise<void> {
22
- await this.tabButton(tabLabel).click();
23
- }
24
-
25
- async waitForTabSearchUaAnalytics(
26
- actionCause,
27
- customChecker?: Function
28
- ): Promise<Request> {
29
- const uaRequest = this.page.waitForRequest((request) => {
30
- if (isUaSearchEvent(request)) {
31
- const requestBody = request.postDataJSON?.();
32
- const {customData} = requestBody;
33
-
34
- const expectedFields = {
35
- actionCause: actionCause,
36
- originContext: 'Search',
37
- };
38
- const matchesExpectedFields = Object.keys(expectedFields).every(
39
- (key) => requestBody?.[key] === expectedFields[key]
40
- );
41
-
42
- return (
43
- matchesExpectedFields &&
44
- (customChecker ? customChecker(customData) : true)
45
- );
46
- }
47
- return false;
48
- });
49
- return uaRequest;
50
- }
51
-
52
- async waitForTabSelectUaAnalytics(expectedFields: object): Promise<Request> {
53
- return this.waitForTabSearchUaAnalytics(
54
- 'interfaceChange',
55
- (customData: object) => {
56
- return Object.keys(expectedFields).every(
57
- (key) => customData?.[key] === expectedFields[key]
58
- );
59
- }
60
- );
61
- }
62
-
63
- extractActionCauseFromSearchResponse(response: Response) {
64
- const {analytics} = response.request().postDataJSON();
65
- return analytics.actionCause;
66
- }
67
- }
@@ -1,77 +0,0 @@
1
- import {testSearch, testInsight, expect} from './fixture';
2
- import {
3
- useCaseEnum,
4
- useCaseTestCases,
5
- } from '../../../../../../playwright/utils/useCase';
6
-
7
- const fixtures = {
8
- search: testSearch as typeof testSearch,
9
- insight: testInsight as typeof testInsight,
10
- };
11
-
12
- const expectedActionCause = 'interfaceChange';
13
- const exampleTabs = ['All', 'Case', 'Knowledge'];
14
-
15
- useCaseTestCases.forEach((useCase) => {
16
- let test;
17
- if (useCase.value === useCaseEnum.search) {
18
- test = fixtures[useCase.value] as typeof testSearch;
19
- } else {
20
- test = fixtures[useCase.value] as typeof testInsight;
21
- }
22
-
23
- test.describe(`quantic tab ${useCase.label}`, () => {
24
- test.describe('when clicking on a tab', () => {
25
- test('should trigger a new search and send the correct UA analytics event', async ({
26
- tab,
27
- search,
28
- }) => {
29
- const selectedTabIndex = 0;
30
- const searchResponsePromise = search.waitForSearchResponse();
31
- const uaRequestPromise = tab.waitForTabSelectUaAnalytics({
32
- interfaceChangeTo: exampleTabs[selectedTabIndex],
33
- });
34
- await tab.clickTabButton(exampleTabs[selectedTabIndex]);
35
-
36
- const searchResponse = await searchResponsePromise;
37
- await uaRequestPromise;
38
-
39
- const actionCause =
40
- tab.extractActionCauseFromSearchResponse(searchResponse);
41
- expect(actionCause).toEqual(expectedActionCause);
42
- });
43
- });
44
-
45
- if (useCase.value === useCaseEnum.search) {
46
- test.describe('when loading selected tab from URL', () => {
47
- const expectedTab = exampleTabs[2];
48
- test.use({
49
- urlHash: `tab=${expectedTab}`,
50
- });
51
-
52
- test('should make the right tab active', async ({tab}) => {
53
- expect(await tab.activeTabLabel).toBe(expectedTab);
54
- });
55
- });
56
- }
57
-
58
- test.describe('when testing accessibility', () => {
59
- test('should be accessible to keyboard', async ({tab, page}) => {
60
- await tab.clickTabButton(exampleTabs[0]);
61
-
62
- let activeTabLabel = await tab.activeTabLabel;
63
- expect(activeTabLabel).toEqual(exampleTabs[0]);
64
-
65
- await page.keyboard.press('Tab');
66
- await page.keyboard.press('Enter');
67
- activeTabLabel = await tab.activeTabLabel;
68
- expect(activeTabLabel).toEqual(exampleTabs[1]);
69
-
70
- await page.keyboard.press('Shift+Tab');
71
- await page.keyboard.press('Space');
72
- activeTabLabel = await tab.activeTabLabel;
73
- expect(activeTabLabel).toEqual(exampleTabs[0]);
74
- });
75
- });
76
- });
77
- });