@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.
- package/docs/out/quantic-docs.json +2 -2
- package/force-app/main/default/lwc/quanticNumberButton/quanticNumberButton.html +1 -1
- package/force-app/main/default/lwc/quanticResultsPerPage/quanticResultsPerPage.js +27 -17
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +6 -6
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.d.ts +0 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/parameter-manager/parameter-manager-selectors.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-parameters/search-parameter-actions-loader.d.ts +36 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-parameters/search-parameter-actions.d.ts +6 -0
- package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -10
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +9 -9
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +5 -5
- package/package.json +6 -4
- package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +0 -604
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/fixture.ts +0 -76
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/pageObject.ts +0 -282
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/quanticBreadcrumbManager.e2e.ts +0 -167
- 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 -327
- package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +0 -269
- 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 -321
- package/force-app/main/default/lwc/quanticDidYouMean/__tests__/quanticDidYouMean.test.js +0 -199
- package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +0 -341
- 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/fixture.ts +0 -63
- 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 -392
- 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/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +0 -814
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +0 -56
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +0 -87
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +0 -283
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +0 -199
- package/force-app/main/default/lwc/quanticGeneratedAnswerContent/__tests__/quanticGeneratedAnswerContent.test.js +0 -151
- 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/quanticNotifications/__tests__/quanticNotifications.test.js +0 -335
- package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +0 -343
- package/force-app/main/default/lwc/quanticPager/e2e/fixture.ts +0 -63
- package/force-app/main/default/lwc/quanticPager/e2e/pageObject.ts +0 -69
- package/force-app/main/default/lwc/quanticPager/e2e/quanticPager.e2e.ts +0 -101
- 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/quanticRefineModalContent/__tests__/quanticRefineModalContent.test.js +0 -501
- 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/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 -261
- 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 -171
- 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 -404
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +0 -74
- 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 -168
- package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js +0 -823
- 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 -91
- 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 -93
- 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 -61
- package/force-app/main/default/lwc/quanticSort/e2e/pageObject.ts +0 -89
- package/force-app/main/default/lwc/quanticSort/e2e/quanticSort.e2e.ts +0 -91
- package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +0 -123
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/__tests__/quanticStandaloneSearchBox.test.js +0 -186
- package/force-app/main/default/lwc/quanticStatefulButton/__tests__/quanticStatefulButton.test.js +0 -222
- package/force-app/main/default/lwc/quanticTab/__tests__/quanticTab.test.js +0 -287
- package/force-app/main/default/lwc/quanticTab/e2e/fixture.ts +0 -62
- package/force-app/main/default/lwc/quanticTab/e2e/pageObject.ts +0 -67
- package/force-app/main/default/lwc/quanticTab/e2e/quanticTab.e2e.ts +0 -77
- package/force-app/main/default/lwc/quanticTabBar/__tests__/quanticTabBar.test.js +0 -331
- package/force-app/main/default/lwc/quanticTabBar/e2e/fixture.ts +0 -61
- package/force-app/main/default/lwc/quanticTabBar/e2e/pageObject.ts +0 -80
- package/force-app/main/default/lwc/quanticTabBar/e2e/quanticTabBar.e2e.ts +0 -173
- package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +0 -339
- 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__/facetDependenciesUtils.test.js +0 -92
- package/force-app/main/default/lwc/quanticUtils/__tests__/markdownUtils.test.js +0 -71
- package/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js +0 -223
- package/force-app/main/default/lwc/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +0 -131
package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js
DELETED
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-import-assign */
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import QuanticNotifications from 'c/quanticNotifications';
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import {createElement} from 'lwc';
|
|
6
|
-
import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
|
|
7
|
-
import {AriaLiveRegion} from 'c/quanticUtils';
|
|
8
|
-
|
|
9
|
-
jest.mock('c/quanticHeadlessLoader');
|
|
10
|
-
jest.mock('c/quanticUtils');
|
|
11
|
-
|
|
12
|
-
const exampleNotifications = ['notification1', 'notification2'];
|
|
13
|
-
|
|
14
|
-
let notificationsState = {
|
|
15
|
-
notifications: exampleNotifications,
|
|
16
|
-
};
|
|
17
|
-
let isInitialized = false;
|
|
18
|
-
|
|
19
|
-
const exampleEngine = {
|
|
20
|
-
id: 'mock engine',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const mockSearchStatusState = {
|
|
24
|
-
hasResults: true,
|
|
25
|
-
hasError: false,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const functionsMocks = {
|
|
29
|
-
buildNotifyTrigger: jest.fn(() => ({
|
|
30
|
-
state: notificationsState,
|
|
31
|
-
subscribe: functionsMocks.subscribe,
|
|
32
|
-
})),
|
|
33
|
-
dispatchMessage: jest.fn(() => {}),
|
|
34
|
-
buildSearchStatus: jest.fn(() => ({
|
|
35
|
-
state: mockSearchStatusState,
|
|
36
|
-
subscribe: jest.fn((callback) => {
|
|
37
|
-
functionsMocks.subscribe.callback = callback;
|
|
38
|
-
return functionsMocks.unsubscribeSearchStatus;
|
|
39
|
-
}),
|
|
40
|
-
})),
|
|
41
|
-
subscribe: jest.fn((callback) => {
|
|
42
|
-
callback();
|
|
43
|
-
return functionsMocks.unsubscribe;
|
|
44
|
-
}),
|
|
45
|
-
unsubscribe: jest.fn(() => {}),
|
|
46
|
-
unsubscribeSearchStatus: jest.fn(() => {}),
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
AriaLiveRegion.mockImplementation(() => {
|
|
51
|
-
return {
|
|
52
|
-
dispatchMessage: functionsMocks.dispatchMessage,
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const selectors = {
|
|
57
|
-
notifications: '[data-test="notification"]',
|
|
58
|
-
initializationError: 'c-quantic-component-error',
|
|
59
|
-
notificationCloseButton: 'lightning-button-icon',
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const defaultOptions = {
|
|
63
|
-
engineId: 'exampleEngineId',
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
function createTestComponent(options = defaultOptions) {
|
|
67
|
-
prepareHeadlessState();
|
|
68
|
-
|
|
69
|
-
const element = createElement('c-quantic-notifications', {
|
|
70
|
-
is: QuanticNotifications,
|
|
71
|
-
});
|
|
72
|
-
for (const [key, value] of Object.entries(options)) {
|
|
73
|
-
element[key] = value;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
document.body.appendChild(element);
|
|
77
|
-
return element;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function prepareHeadlessState() {
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
mockHeadlessLoader.getHeadlessBundle = () => {
|
|
83
|
-
return {
|
|
84
|
-
buildNotifyTrigger: functionsMocks.buildNotifyTrigger,
|
|
85
|
-
buildSearchStatus: functionsMocks.buildSearchStatus,
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Helper function to wait until the microtask queue is empty.
|
|
91
|
-
function flushPromises() {
|
|
92
|
-
// eslint-disable-next-line @lwc/lwc/no-async-operation
|
|
93
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function mockSuccessfulHeadlessInitialization() {
|
|
97
|
-
// @ts-ignore
|
|
98
|
-
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
99
|
-
if (element instanceof QuanticNotifications && !isInitialized) {
|
|
100
|
-
isInitialized = true;
|
|
101
|
-
initialize(exampleEngine);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function mockErroneousHeadlessInitialization() {
|
|
107
|
-
// @ts-ignore
|
|
108
|
-
mockHeadlessLoader.initializeWithHeadless = (element) => {
|
|
109
|
-
if (element instanceof QuanticNotifications) {
|
|
110
|
-
element.setInitializationError();
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function cleanup() {
|
|
116
|
-
// The jsdom instance is shared across test cases in a single file so reset the DOM
|
|
117
|
-
while (document.body.firstChild) {
|
|
118
|
-
document.body.removeChild(document.body.firstChild);
|
|
119
|
-
}
|
|
120
|
-
jest.clearAllMocks();
|
|
121
|
-
isInitialized = false;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
describe('c-quantic-notifications', () => {
|
|
125
|
-
beforeAll(() => {
|
|
126
|
-
mockSuccessfulHeadlessInitialization();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
afterEach(() => {
|
|
130
|
-
cleanup();
|
|
131
|
-
notificationsState = {
|
|
132
|
-
notifications: exampleNotifications,
|
|
133
|
-
};
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe('when an error occurs during initialization', () => {
|
|
137
|
-
beforeEach(() => {
|
|
138
|
-
mockErroneousHeadlessInitialization();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
afterAll(() => {
|
|
142
|
-
mockSuccessfulHeadlessInitialization();
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('should display the initialization error component', async () => {
|
|
146
|
-
const element = createTestComponent();
|
|
147
|
-
await flushPromises();
|
|
148
|
-
|
|
149
|
-
const initializationError = element.shadowRoot.querySelector(
|
|
150
|
-
selectors.initializationError
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
const notification = element.shadowRoot.querySelector(
|
|
154
|
-
selectors.notifications
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
expect(initializationError).not.toBeNull();
|
|
158
|
-
expect(notification).toBeNull();
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
describe('component initialization', () => {
|
|
163
|
-
it('should build the notifyTrigger and searchStatus controllers with the proper parameters', async () => {
|
|
164
|
-
createTestComponent();
|
|
165
|
-
await flushPromises();
|
|
166
|
-
|
|
167
|
-
expect(functionsMocks.buildNotifyTrigger).toHaveBeenCalledTimes(1);
|
|
168
|
-
expect(functionsMocks.buildNotifyTrigger).toHaveBeenCalledWith(
|
|
169
|
-
exampleEngine
|
|
170
|
-
);
|
|
171
|
-
expect(functionsMocks.buildSearchStatus).toHaveBeenCalledTimes(1);
|
|
172
|
-
expect(functionsMocks.buildSearchStatus).toHaveBeenCalledWith(
|
|
173
|
-
exampleEngine
|
|
174
|
-
);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('should subscribe to the headless notify trigger state changes', async () => {
|
|
178
|
-
createTestComponent();
|
|
179
|
-
await flushPromises();
|
|
180
|
-
|
|
181
|
-
expect(functionsMocks.subscribe).toHaveBeenCalledTimes(1);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('should call AriaLiveRegion with the right parameters', async () => {
|
|
185
|
-
await createTestComponent();
|
|
186
|
-
await flushPromises();
|
|
187
|
-
|
|
188
|
-
expect(AriaLiveRegion).toHaveBeenCalledTimes(1);
|
|
189
|
-
expect(AriaLiveRegion).toHaveBeenCalledWith(
|
|
190
|
-
'notifications',
|
|
191
|
-
expect.anything()
|
|
192
|
-
);
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
describe('when the component is initialized successfully', () => {
|
|
197
|
-
describe('when some notifications are present in the state', () => {
|
|
198
|
-
it('should render the notifications component', async () => {
|
|
199
|
-
const element = createTestComponent();
|
|
200
|
-
await flushPromises();
|
|
201
|
-
|
|
202
|
-
const notifications = element.shadowRoot.querySelectorAll(
|
|
203
|
-
selectors.notifications
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
expect(notifications).not.toBeNull();
|
|
207
|
-
expect(notifications.length).toBe(exampleNotifications.length);
|
|
208
|
-
notifications.forEach((notification, index) => {
|
|
209
|
-
expect(notification.textContent).toEqual(exampleNotifications[index]);
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('should call dispatchMessage with the correct message', async () => {
|
|
214
|
-
await createTestComponent();
|
|
215
|
-
await flushPromises();
|
|
216
|
-
|
|
217
|
-
const expectedMessage =
|
|
218
|
-
' Notification 1: notification1 Notification 2: notification2';
|
|
219
|
-
|
|
220
|
-
expect(functionsMocks.dispatchMessage).toHaveBeenCalledTimes(1);
|
|
221
|
-
expect(functionsMocks.dispatchMessage).toHaveBeenCalledWith(
|
|
222
|
-
expectedMessage
|
|
223
|
-
);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
describe('when no notifications are present in the state', () => {
|
|
228
|
-
beforeEach(() => {
|
|
229
|
-
notificationsState = {
|
|
230
|
-
notifications: [],
|
|
231
|
-
};
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('should not render the notifications component', async () => {
|
|
235
|
-
const element = createTestComponent();
|
|
236
|
-
await flushPromises();
|
|
237
|
-
|
|
238
|
-
const notifications = element.shadowRoot.querySelectorAll(
|
|
239
|
-
selectors.notifications
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
expect(notifications.length).toEqual(0);
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
describe('when there is an error following a search', () => {
|
|
247
|
-
it('should not render the notifications component', async () => {
|
|
248
|
-
const element = createTestComponent();
|
|
249
|
-
mockSearchStatusState.hasError = true;
|
|
250
|
-
functionsMocks.subscribe.callback();
|
|
251
|
-
await flushPromises();
|
|
252
|
-
|
|
253
|
-
const notifications = element.shadowRoot.querySelectorAll(
|
|
254
|
-
selectors.notifications
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
expect(notifications.length).toEqual(0);
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
describe('when clicking on a notification close button', () => {
|
|
263
|
-
it('should properly dismiss that notification', async () => {
|
|
264
|
-
const element = createTestComponent();
|
|
265
|
-
await flushPromises();
|
|
266
|
-
|
|
267
|
-
const notificationsBeforeClose = element.shadowRoot.querySelectorAll(
|
|
268
|
-
selectors.notifications
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
const firstNotificationCloseButton =
|
|
272
|
-
notificationsBeforeClose[0].querySelector(
|
|
273
|
-
selectors.notificationCloseButton
|
|
274
|
-
);
|
|
275
|
-
firstNotificationCloseButton.click();
|
|
276
|
-
await flushPromises();
|
|
277
|
-
|
|
278
|
-
const notificationsAfterClose = element.shadowRoot.querySelectorAll(
|
|
279
|
-
selectors.notifications
|
|
280
|
-
);
|
|
281
|
-
|
|
282
|
-
expect(notificationsAfterClose.length).toEqual(
|
|
283
|
-
exampleNotifications.length - 1
|
|
284
|
-
);
|
|
285
|
-
expect(notificationsAfterClose[0].textContent).toEqual(
|
|
286
|
-
exampleNotifications[1]
|
|
287
|
-
);
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
describe('when triggering another search with the same query', () => {
|
|
291
|
-
it('should reset the visibility of the notifications', async () => {
|
|
292
|
-
const element = createTestComponent();
|
|
293
|
-
await flushPromises();
|
|
294
|
-
|
|
295
|
-
const notificationsBeforeClose = element.shadowRoot.querySelectorAll(
|
|
296
|
-
selectors.notifications
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
expect(notificationsBeforeClose.length).toEqual(
|
|
300
|
-
exampleNotifications.length
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
const firstNotificationCloseButton =
|
|
304
|
-
notificationsBeforeClose[0].querySelector(
|
|
305
|
-
selectors.notificationCloseButton
|
|
306
|
-
);
|
|
307
|
-
firstNotificationCloseButton.click();
|
|
308
|
-
await flushPromises();
|
|
309
|
-
|
|
310
|
-
const notificationsAfterClose = element.shadowRoot.querySelectorAll(
|
|
311
|
-
selectors.notifications
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
expect(notificationsAfterClose.length).toEqual(
|
|
315
|
-
exampleNotifications.length - 1
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
mockSearchStatusState.hasError = false;
|
|
319
|
-
functionsMocks.subscribe.callback();
|
|
320
|
-
await flushPromises();
|
|
321
|
-
|
|
322
|
-
const notificationsAfterSearch = element.shadowRoot.querySelectorAll(
|
|
323
|
-
selectors.notifications
|
|
324
|
-
);
|
|
325
|
-
|
|
326
|
-
expect(notificationsAfterSearch.length).toEqual(
|
|
327
|
-
exampleNotifications.length
|
|
328
|
-
);
|
|
329
|
-
notificationsAfterSearch.forEach((notification, index) => {
|
|
330
|
-
expect(notification.textContent).toEqual(exampleNotifications[index]);
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
});
|
package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js
DELETED
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-import-assign */
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import {createElement} from 'lwc';
|
|
4
|
-
import QuanticNumericFacet from 'c/quanticNumericFacet';
|
|
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
|
-
NUMERICFACETS: 'numericFacets',
|
|
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 numericFacetControllerMock = {
|
|
33
|
-
subscribe: jest.fn((callback) => callback()),
|
|
34
|
-
state: {
|
|
35
|
-
facetId: exampleFacetId,
|
|
36
|
-
values: [],
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
const parentFacetIdError = `The ${exampleField} c-quantic-numeric-facet requires dependsOn.parentFacetId to be a valid string.`;
|
|
40
|
-
const expectedValueError = `The ${exampleField} c-quantic-numeric-facet requires dependsOn.expectedValue to be a valid string.`;
|
|
41
|
-
|
|
42
|
-
function createTestComponent(options = defaultOptions) {
|
|
43
|
-
prepareHeadlessState();
|
|
44
|
-
|
|
45
|
-
const element = createElement('c-quantic-numeric-facet', {
|
|
46
|
-
is: QuanticNumericFacet,
|
|
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
|
-
buildNumericFacet: jest.fn(() => numericFacetControllerMock),
|
|
58
|
-
buildNumericFilter: 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
|
-
buildNumericFacet: functionsMocks.buildNumericFacet,
|
|
79
|
-
buildNumericFilter: functionsMocks.buildNumericFilter,
|
|
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 QuanticNumericFacet && !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-numeric-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
|
-
withInput: true,
|
|
151
|
-
});
|
|
152
|
-
await flushPromises();
|
|
153
|
-
|
|
154
|
-
expect(functionsMocks.buildNumericFacet).toHaveBeenCalledTimes(1);
|
|
155
|
-
expect(functionsMocks.buildNumericFilter).toHaveBeenCalledTimes(1);
|
|
156
|
-
expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledTimes(
|
|
157
|
-
2
|
|
158
|
-
);
|
|
159
|
-
expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledWith(
|
|
160
|
-
exampleEngine,
|
|
161
|
-
{
|
|
162
|
-
facetId: exampleFacetId,
|
|
163
|
-
}
|
|
164
|
-
);
|
|
165
|
-
expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledWith(
|
|
166
|
-
exampleEngine,
|
|
167
|
-
{
|
|
168
|
-
facetId: exampleFilterId,
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
expect(generateFacetDependencyConditions).toHaveBeenCalledTimes(2);
|
|
173
|
-
expect(generateFacetDependencyConditions).toHaveBeenCalledWith({
|
|
174
|
-
[exampleFacetDependency.parentFacetId]:
|
|
175
|
-
exampleFacetDependency.expectedValue,
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('should not build the controller when the dependsOn property is not set', async () => {
|
|
180
|
-
createTestComponent({
|
|
181
|
-
...defaultOptions,
|
|
182
|
-
withInput: true,
|
|
183
|
-
});
|
|
184
|
-
await flushPromises();
|
|
185
|
-
|
|
186
|
-
expect(functionsMocks.buildNumericFacet).toHaveBeenCalledTimes(1);
|
|
187
|
-
expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledTimes(
|
|
188
|
-
0
|
|
189
|
-
);
|
|
190
|
-
expect(generateFacetDependencyConditions).toHaveBeenCalledTimes(0);
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
describe('the facet enablement', () => {
|
|
195
|
-
describe('when the facet is enabled', () => {
|
|
196
|
-
beforeAll(() => {
|
|
197
|
-
functionsMocks.buildNumericFacet.mockReturnValue({
|
|
198
|
-
...numericFacetControllerMock,
|
|
199
|
-
state: {...numericFacetControllerMock.state, enabled: true},
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it('should display the facet content', async () => {
|
|
204
|
-
const element = createTestComponent();
|
|
205
|
-
await flushPromises();
|
|
206
|
-
|
|
207
|
-
const facetContent = element.shadowRoot.querySelector(
|
|
208
|
-
selectors.facetContent
|
|
209
|
-
);
|
|
210
|
-
expect(facetContent).not.toBeNull();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe('when the facet is not enabled', () => {
|
|
215
|
-
beforeAll(() => {
|
|
216
|
-
functionsMocks.buildNumericFacet.mockReturnValue({
|
|
217
|
-
...numericFacetControllerMock,
|
|
218
|
-
state: {...numericFacetControllerMock.state, enabled: false},
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('should not display the facet content', async () => {
|
|
223
|
-
const element = createTestComponent();
|
|
224
|
-
await flushPromises();
|
|
225
|
-
|
|
226
|
-
const facetContent = element.shadowRoot.querySelector(
|
|
227
|
-
selectors.facetContent
|
|
228
|
-
);
|
|
229
|
-
expect(facetContent).toBeNull();
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
afterAll(() => {
|
|
234
|
-
functionsMocks.buildNumericFacet.mockReturnValue(
|
|
235
|
-
numericFacetControllerMock
|
|
236
|
-
);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
describe('validation of the dependsOn property', () => {
|
|
241
|
-
let consoleError;
|
|
242
|
-
beforeAll(() => {
|
|
243
|
-
consoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
244
|
-
});
|
|
245
|
-
describe('when dependsOn.parentFacetId is not provided', () => {
|
|
246
|
-
it('should display the error component', async () => {
|
|
247
|
-
const invalidFacetDependency = {
|
|
248
|
-
expectedValue: 'txt',
|
|
249
|
-
};
|
|
250
|
-
const element = createTestComponent({
|
|
251
|
-
...defaultOptions,
|
|
252
|
-
dependsOn: invalidFacetDependency,
|
|
253
|
-
});
|
|
254
|
-
await flushPromises();
|
|
255
|
-
|
|
256
|
-
const componentError = element.shadowRoot.querySelector(
|
|
257
|
-
selectors.componentError
|
|
258
|
-
);
|
|
259
|
-
const facetContent = element.shadowRoot.querySelector(
|
|
260
|
-
selectors.facetContent
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
264
|
-
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
265
|
-
expect(componentError).not.toBeNull();
|
|
266
|
-
expect(facetContent).toBeNull();
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
describe('when dependsOn.parentFacetId is not a string', () => {
|
|
271
|
-
it('should display the error component', async () => {
|
|
272
|
-
const invalidFacetDependency = {
|
|
273
|
-
parentFacetId: 1,
|
|
274
|
-
expectedValue: 'txt',
|
|
275
|
-
};
|
|
276
|
-
const element = createTestComponent({
|
|
277
|
-
...defaultOptions,
|
|
278
|
-
dependsOn: invalidFacetDependency,
|
|
279
|
-
});
|
|
280
|
-
await flushPromises();
|
|
281
|
-
|
|
282
|
-
const componentError = element.shadowRoot.querySelector(
|
|
283
|
-
selectors.componentError
|
|
284
|
-
);
|
|
285
|
-
const facetContent = element.shadowRoot.querySelector(
|
|
286
|
-
selectors.facetContent
|
|
287
|
-
);
|
|
288
|
-
|
|
289
|
-
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
290
|
-
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
291
|
-
expect(componentError).not.toBeNull();
|
|
292
|
-
expect(facetContent).toBeNull();
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
describe('when dependsOn.expectedValue is not a string', () => {
|
|
297
|
-
it('should display the error component', async () => {
|
|
298
|
-
const invalidFacetDependency = {
|
|
299
|
-
parentFacetId: 'filetype',
|
|
300
|
-
expectedValue: 2,
|
|
301
|
-
};
|
|
302
|
-
const element = createTestComponent({
|
|
303
|
-
...defaultOptions,
|
|
304
|
-
dependsOn: invalidFacetDependency,
|
|
305
|
-
});
|
|
306
|
-
await flushPromises();
|
|
307
|
-
|
|
308
|
-
const componentError = element.shadowRoot.querySelector(
|
|
309
|
-
selectors.componentError
|
|
310
|
-
);
|
|
311
|
-
const facetContent = element.shadowRoot.querySelector(
|
|
312
|
-
selectors.facetContent
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
316
|
-
expect(consoleError).toHaveBeenCalledWith(expectedValueError);
|
|
317
|
-
expect(componentError).not.toBeNull();
|
|
318
|
-
expect(facetContent).toBeNull();
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
describe('when the component is disconnected', () => {
|
|
324
|
-
it('should make the condition manager stop watching the facet', async () => {
|
|
325
|
-
const exampleFacetDependency = {
|
|
326
|
-
parentFacetId: 'filetype',
|
|
327
|
-
expectedValue: 'txt',
|
|
328
|
-
};
|
|
329
|
-
const element = createTestComponent({
|
|
330
|
-
...defaultOptions,
|
|
331
|
-
dependsOn: exampleFacetDependency,
|
|
332
|
-
withInput: true,
|
|
333
|
-
});
|
|
334
|
-
await flushPromises();
|
|
335
|
-
expect(functionsMocks.buildFacetConditionsManager).toHaveBeenCalledTimes(
|
|
336
|
-
2
|
|
337
|
-
);
|
|
338
|
-
|
|
339
|
-
document.body.removeChild(element);
|
|
340
|
-
expect(functionsMocks.stopWatching).toHaveBeenCalledTimes(2);
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
});
|