@coveo/quantic 3.16.0 → 3.16.1-pre.9c01cf606f
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/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +2 -2
- 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/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -10
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +2 -2
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +2 -2
- package/package.json +5 -3
- 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
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-import-assign */
|
|
2
|
-
import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import {createElement} from 'lwc';
|
|
5
|
-
import QuanticResultHighlightedTextField from '../quanticResultHighlightedTextField';
|
|
6
|
-
|
|
7
|
-
const componentName = 'c-quantic-result-highlighted-text-field';
|
|
8
|
-
|
|
9
|
-
const expectedConsoleErrorMessage = `The ${componentName} requires a result and a field to be specified.`;
|
|
10
|
-
|
|
11
|
-
const exampleField = 'examplefield';
|
|
12
|
-
const exampleFieldValue = 'example highlight';
|
|
13
|
-
const highlightedValue = 'highlight';
|
|
14
|
-
const exampleHighlightedFieldValue = `example <b>${highlightedValue}</b>`;
|
|
15
|
-
|
|
16
|
-
const exampleLabel = 'example label';
|
|
17
|
-
const exampleResult = {
|
|
18
|
-
[exampleField]: exampleFieldValue,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const selectors = {
|
|
22
|
-
labelSelector: '.result-text__label',
|
|
23
|
-
valueSelector: '.result-text__value',
|
|
24
|
-
errorSelector: '.error-message',
|
|
25
|
-
highlightedSection: 'b',
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const defaultOptions = {
|
|
29
|
-
result: exampleResult,
|
|
30
|
-
field: exampleField,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
let isInitialized = false;
|
|
34
|
-
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
mockHeadlessLoader.initializeWithHeadless = (element, engineId, initialize) => {
|
|
37
|
-
if (element instanceof QuanticResultHighlightedTextField) {
|
|
38
|
-
if (!isInitialized) {
|
|
39
|
-
isInitialized = true;
|
|
40
|
-
initialize();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
mockHeadlessLoader.getHeadlessBundle = () => {
|
|
47
|
-
return {
|
|
48
|
-
ResultTemplatesHelpers: {
|
|
49
|
-
getResultProperty: (result, field) => result[`${field}`],
|
|
50
|
-
},
|
|
51
|
-
HighlightUtils: {
|
|
52
|
-
highlightString: () => exampleHighlightedFieldValue,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function createTestComponent(options = defaultOptions) {
|
|
58
|
-
const element = createElement(componentName, {
|
|
59
|
-
is: QuanticResultHighlightedTextField,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
for (const [key, value] of Object.entries(options)) {
|
|
63
|
-
element[key] = value;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
document.body.appendChild(element);
|
|
67
|
-
return element;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Helper function to wait until the microtask queue is empty.
|
|
71
|
-
function flushPromises() {
|
|
72
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
describe('c-quantic-result-highlighted-text-field', () => {
|
|
76
|
-
function cleanup() {
|
|
77
|
-
// The jsdom instance is shared across test cases in a single file so reset the DOM
|
|
78
|
-
while (document.body.firstChild) {
|
|
79
|
-
document.body.removeChild(document.body.firstChild);
|
|
80
|
-
}
|
|
81
|
-
isInitialized = false;
|
|
82
|
-
jest.clearAllMocks();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
beforeEach(() => {
|
|
86
|
-
console.error = jest.fn();
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
global.Bueno = {
|
|
89
|
-
isString: jest
|
|
90
|
-
.fn()
|
|
91
|
-
.mockImplementation(
|
|
92
|
-
(value) => Object.prototype.toString.call(value) === '[object String]'
|
|
93
|
-
),
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
afterEach(() => {
|
|
98
|
-
cleanup();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe('error handeling when the componentis used with missing properties', () => {
|
|
102
|
-
describe('when no result is given', () => {
|
|
103
|
-
it('should show an error', async () => {
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
const element = createTestComponent({field: exampleField});
|
|
106
|
-
await flushPromises();
|
|
107
|
-
|
|
108
|
-
const errorMessage = element.shadowRoot.querySelector(
|
|
109
|
-
selectors.errorSelector
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
expect(errorMessage).not.toBeNull();
|
|
113
|
-
expect(console.error).toHaveBeenCalledWith(expectedConsoleErrorMessage);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe('when no field is given', () => {
|
|
118
|
-
it('should show an error', async () => {
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
const element = createTestComponent({result: exampleResult});
|
|
121
|
-
await flushPromises();
|
|
122
|
-
|
|
123
|
-
const errorMessage = element.shadowRoot.querySelector(
|
|
124
|
-
selectors.errorSelector
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
expect(errorMessage).not.toBeNull();
|
|
128
|
-
expect(console.error).toHaveBeenCalledWith(expectedConsoleErrorMessage);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
describe('when an empty string is given as a field', () => {
|
|
133
|
-
it('should show an error', async () => {
|
|
134
|
-
const element = createTestComponent({...defaultOptions, field: ''});
|
|
135
|
-
await flushPromises();
|
|
136
|
-
|
|
137
|
-
const errorMessage = element.shadowRoot.querySelector(
|
|
138
|
-
selectors.errorSelector
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
expect(errorMessage).not.toBeNull();
|
|
142
|
-
expect(console.error).toHaveBeenCalledWith(expectedConsoleErrorMessage);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
describe('displaying highlights', () => {
|
|
148
|
-
describe('when field highlights are found in the result', () => {
|
|
149
|
-
it('should render the result field value with proper highlights', async () => {
|
|
150
|
-
const element = createTestComponent({
|
|
151
|
-
...defaultOptions,
|
|
152
|
-
result: {
|
|
153
|
-
...defaultOptions.result,
|
|
154
|
-
[`${exampleField}Highlights`]: exampleFieldValue,
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
await flushPromises();
|
|
158
|
-
|
|
159
|
-
const fieldValueElement = element.shadowRoot.querySelector(
|
|
160
|
-
selectors.valueSelector
|
|
161
|
-
);
|
|
162
|
-
const highlightedSection = fieldValueElement.querySelector(
|
|
163
|
-
selectors.highlightedSection
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
expect(fieldValueElement.textContent).toBe(exampleFieldValue);
|
|
167
|
-
expect(highlightedSection).not.toBeNull();
|
|
168
|
-
expect(highlightedSection.textContent).toBe(highlightedValue);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('when field highlights are not found in the result', () => {
|
|
173
|
-
it('should render the result field value without highlights', async () => {
|
|
174
|
-
const element = createTestComponent();
|
|
175
|
-
await flushPromises();
|
|
176
|
-
|
|
177
|
-
const fieldValueElement = element.shadowRoot.querySelector(
|
|
178
|
-
selectors.valueSelector
|
|
179
|
-
);
|
|
180
|
-
const highlightedSection = fieldValueElement.querySelector(
|
|
181
|
-
selectors.highlightedSection
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
expect(fieldValueElement.textContent).toBe(exampleFieldValue);
|
|
185
|
-
expect(highlightedSection).toBeNull();
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe('displaying the component with a label', () => {
|
|
191
|
-
it('should render the field value with a label', async () => {
|
|
192
|
-
const element = createTestComponent({
|
|
193
|
-
...defaultOptions,
|
|
194
|
-
label: exampleLabel,
|
|
195
|
-
});
|
|
196
|
-
await flushPromises();
|
|
197
|
-
|
|
198
|
-
const labelElement = element.shadowRoot.querySelector(
|
|
199
|
-
selectors.labelSelector
|
|
200
|
-
);
|
|
201
|
-
const fieldValueElement = element.shadowRoot.querySelector(
|
|
202
|
-
selectors.valueSelector
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
expect(labelElement.textContent).toBe(`${exampleLabel}:`);
|
|
206
|
-
expect(fieldValueElement.textContent).toBe(exampleFieldValue);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
});
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
|
|
2
|
-
import {
|
|
3
|
-
getNavigateCalledWith,
|
|
4
|
-
getGenerateUrlCalledWith,
|
|
5
|
-
} from 'lightning/navigation';
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
import {createElement} from 'lwc';
|
|
8
|
-
import QuanticResultLink from '../quanticResultLink';
|
|
9
|
-
|
|
10
|
-
const exampleResult = {
|
|
11
|
-
clickUri: 'https://coveo.com/',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const selectors = {
|
|
15
|
-
quanticTextField: 'c-quantic-result-highlighted-text-field',
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
jest.mock('c/quanticHeadlessLoader');
|
|
19
|
-
|
|
20
|
-
function createTestComponent(options) {
|
|
21
|
-
const element = createElement('c-quantic-result-link', {
|
|
22
|
-
is: QuanticResultLink,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
for (const [key, value] of Object.entries(options)) {
|
|
26
|
-
element[key] = value;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
document.body.appendChild(element);
|
|
30
|
-
return element;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Helper function to wait until the microtask queue is empty.
|
|
34
|
-
function flushPromises() {
|
|
35
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Helper function to mock headless for this suite of tests.
|
|
39
|
-
function mockHeadlessAndBueno() {
|
|
40
|
-
jest.spyOn(mockHeadlessLoader, 'getHeadlessBundle').mockReturnValue({
|
|
41
|
-
buildInteractiveResult: () => ({
|
|
42
|
-
select: jest.fn(),
|
|
43
|
-
beginDelayedSelect: jest.fn(),
|
|
44
|
-
cancelPendingSelect: jest.fn(),
|
|
45
|
-
}),
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
jest.spyOn(mockHeadlessLoader, 'getHeadlessEnginePromise').mockReturnValue(
|
|
49
|
-
new Promise((resolve) => {
|
|
50
|
-
resolve();
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
jest.spyOn(mockHeadlessLoader, 'getBueno').mockReturnValue(
|
|
55
|
-
new Promise(() => {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
global.Bueno = {
|
|
58
|
-
isString: jest
|
|
59
|
-
.fn()
|
|
60
|
-
.mockImplementation(
|
|
61
|
-
(value) =>
|
|
62
|
-
Object.prototype.toString.call(value) === '[object String]'
|
|
63
|
-
),
|
|
64
|
-
};
|
|
65
|
-
})
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
describe('c-quantic-result-link', () => {
|
|
70
|
-
function cleanup() {
|
|
71
|
-
// The jsdom instance is shared across test cases in a single file so reset the DOM.
|
|
72
|
-
while (document.body.firstChild) {
|
|
73
|
-
document.body.removeChild(document.body.firstChild);
|
|
74
|
-
}
|
|
75
|
-
jest.clearAllMocks();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
beforeEach(() => {
|
|
79
|
-
mockHeadlessAndBueno();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
afterEach(() => {
|
|
83
|
-
cleanup();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
describe('when the result is of type Salesforce', () => {
|
|
87
|
-
const exampleSalesforceResult = {
|
|
88
|
-
...exampleResult,
|
|
89
|
-
raw: {
|
|
90
|
-
sfid: '123',
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
it('should call the navigation mixin to get the Salesforce record URL', async () => {
|
|
94
|
-
createTestComponent({result: exampleSalesforceResult});
|
|
95
|
-
await flushPromises();
|
|
96
|
-
|
|
97
|
-
const {pageReference} = getGenerateUrlCalledWith();
|
|
98
|
-
|
|
99
|
-
expect(pageReference.attributes.recordId).toBe(
|
|
100
|
-
exampleSalesforceResult.raw.sfid
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('should open the result link in a Salesforce console subtab', async () => {
|
|
105
|
-
const element = createTestComponent({result: exampleSalesforceResult});
|
|
106
|
-
await flushPromises();
|
|
107
|
-
|
|
108
|
-
const linkSalesforce = element.shadowRoot.querySelector('a');
|
|
109
|
-
linkSalesforce.click();
|
|
110
|
-
|
|
111
|
-
const {pageReference} = getNavigateCalledWith();
|
|
112
|
-
|
|
113
|
-
expect(pageReference.attributes.recordId).toBe(
|
|
114
|
-
exampleSalesforceResult.raw.sfid
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
describe('when the result is a knowledge article', () => {
|
|
119
|
-
const exampleKnowledgeArticleResult = {
|
|
120
|
-
...exampleResult,
|
|
121
|
-
raw: {
|
|
122
|
-
sfid: '1234',
|
|
123
|
-
sfkavid: '1234',
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
it('should open the result link in a Salesforce console subtab', async () => {
|
|
127
|
-
const element = createTestComponent({
|
|
128
|
-
result: exampleKnowledgeArticleResult,
|
|
129
|
-
});
|
|
130
|
-
await flushPromises();
|
|
131
|
-
|
|
132
|
-
const LinkKnowledgeArticle = element.shadowRoot.querySelector('a');
|
|
133
|
-
LinkKnowledgeArticle.click();
|
|
134
|
-
|
|
135
|
-
const {pageReference} = getNavigateCalledWith();
|
|
136
|
-
|
|
137
|
-
expect(pageReference.attributes.recordId).toBe(
|
|
138
|
-
exampleKnowledgeArticleResult.raw.sfkavid
|
|
139
|
-
);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
describe('when the result is a case comment', () => {
|
|
144
|
-
const exampleCaseCommentResult = {
|
|
145
|
-
...exampleResult,
|
|
146
|
-
raw: {
|
|
147
|
-
sfid: '1234',
|
|
148
|
-
sfparentid: '5678',
|
|
149
|
-
documenttype: 'CaseComment',
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
it('should open the parent of the result in a Salesforce console subtab', async () => {
|
|
153
|
-
const element = createTestComponent({result: exampleCaseCommentResult});
|
|
154
|
-
await flushPromises();
|
|
155
|
-
|
|
156
|
-
const link = element.shadowRoot.querySelector('a');
|
|
157
|
-
link.click();
|
|
158
|
-
|
|
159
|
-
const {pageReference} = getNavigateCalledWith();
|
|
160
|
-
|
|
161
|
-
expect(pageReference.attributes.recordId).toBe(
|
|
162
|
-
exampleCaseCommentResult.raw.sfparentid
|
|
163
|
-
);
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
describe('when the result is NOT of type salesforce', () => {
|
|
169
|
-
it('should open the result link in the current browser tab', async () => {
|
|
170
|
-
const element = createTestComponent({result: exampleResult});
|
|
171
|
-
await flushPromises();
|
|
172
|
-
|
|
173
|
-
const link = element.shadowRoot.querySelector('a');
|
|
174
|
-
|
|
175
|
-
expect(link.getAttribute('href')).toEqual(exampleResult.clickUri);
|
|
176
|
-
expect(link.getAttribute('target')).toEqual('_self');
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
describe('with a custom value for the target property', () => {
|
|
180
|
-
it('should open the result link based on the value of the target property', async () => {
|
|
181
|
-
const customTarget = '_blank';
|
|
182
|
-
const element = createTestComponent({
|
|
183
|
-
result: exampleResult,
|
|
184
|
-
target: customTarget,
|
|
185
|
-
});
|
|
186
|
-
await flushPromises();
|
|
187
|
-
|
|
188
|
-
const link = element.shadowRoot.querySelector('a');
|
|
189
|
-
|
|
190
|
-
expect(link.getAttribute('href')).toEqual(exampleResult.clickUri);
|
|
191
|
-
expect(link.getAttribute('target')).toEqual(customTarget);
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
describe('with a custom value for the displayed field property', () => {
|
|
197
|
-
it('should display the correct field as the link text', async () => {
|
|
198
|
-
const customFieldToDisplay = 'exampleField';
|
|
199
|
-
|
|
200
|
-
const element = createTestComponent({
|
|
201
|
-
result: {
|
|
202
|
-
...exampleResult,
|
|
203
|
-
raw: {[customFieldToDisplay]: 'exampleValue'},
|
|
204
|
-
},
|
|
205
|
-
displayedField: customFieldToDisplay,
|
|
206
|
-
});
|
|
207
|
-
await flushPromises();
|
|
208
|
-
|
|
209
|
-
const quanticTextFieldComponent = element.shadowRoot.querySelector(
|
|
210
|
-
selectors.quanticTextField
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
expect(quanticTextFieldComponent).not.toBeNull();
|
|
214
|
-
expect(quanticTextFieldComponent.field).toBe(customFieldToDisplay);
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
describe('with the default value for the displayed field property', () => {
|
|
219
|
-
describe('when the title field exists on the result', () => {
|
|
220
|
-
it('should display the title field as the link text', async () => {
|
|
221
|
-
const defaultFieldToDisplay = 'title';
|
|
222
|
-
|
|
223
|
-
const element = createTestComponent({
|
|
224
|
-
result: {
|
|
225
|
-
...exampleResult,
|
|
226
|
-
[defaultFieldToDisplay]: 'example title',
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
await flushPromises();
|
|
230
|
-
|
|
231
|
-
const quanticTextFieldComponent = element.shadowRoot.querySelector(
|
|
232
|
-
selectors.quanticTextField
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
expect(quanticTextFieldComponent).not.toBeNull();
|
|
236
|
-
expect(quanticTextFieldComponent.field).toBe(defaultFieldToDisplay);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
describe('when the title field does not exist on the result', () => {
|
|
241
|
-
it('should fall back to display the click uri field as the link text', async () => {
|
|
242
|
-
const fallbackFieldToDisplay = 'clickUri';
|
|
243
|
-
|
|
244
|
-
const element = createTestComponent({
|
|
245
|
-
result: {
|
|
246
|
-
...exampleResult,
|
|
247
|
-
[fallbackFieldToDisplay]: 'example clickUri',
|
|
248
|
-
},
|
|
249
|
-
});
|
|
250
|
-
await flushPromises();
|
|
251
|
-
|
|
252
|
-
const quanticTextFieldComponent = element.shadowRoot.querySelector(
|
|
253
|
-
selectors.quanticTextField
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
expect(quanticTextFieldComponent).not.toBeNull();
|
|
257
|
-
expect(quanticTextFieldComponent.field).toBe(fallbackFieldToDisplay);
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
});
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import {createElement} from 'lwc';
|
|
3
|
-
import QuanticResultMultiValueText from '../quanticResultMultiValueText';
|
|
4
|
-
|
|
5
|
-
const exampleField = 'examplemultivaluefield';
|
|
6
|
-
const exampleFieldValue = ['One', 'Two', 'Three'];
|
|
7
|
-
const exampleResult = {
|
|
8
|
-
raw: {
|
|
9
|
-
[exampleField]: exampleFieldValue,
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const labelSelector = '.result-text__label';
|
|
14
|
-
const valueSelector = '.result-text__value';
|
|
15
|
-
const errorSelector = '.error-message';
|
|
16
|
-
|
|
17
|
-
const defaultOptions = {
|
|
18
|
-
result: exampleResult,
|
|
19
|
-
field: exampleField,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function createTestComponent(options = defaultOptions) {
|
|
23
|
-
const element = createElement('c-quantic-result-multi-value-text', {
|
|
24
|
-
is: QuanticResultMultiValueText,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
for (const [key, value] of Object.entries(options)) {
|
|
28
|
-
element[key] = value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
document.body.appendChild(element);
|
|
32
|
-
return element;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Helper function to wait until the microtask queue is empty.
|
|
36
|
-
function flushPromises() {
|
|
37
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
describe('c-quantic-result-multi-value-text', () => {
|
|
41
|
-
function cleanup() {
|
|
42
|
-
// The jsdom instance is shared across test cases in a single file so reset the DOM
|
|
43
|
-
while (document.body.firstChild) {
|
|
44
|
-
document.body.removeChild(document.body.firstChild);
|
|
45
|
-
}
|
|
46
|
-
jest.clearAllMocks();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
beforeEach(() => {
|
|
50
|
-
console.error = jest.fn();
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
global.Bueno = {
|
|
53
|
-
isString: jest
|
|
54
|
-
.fn()
|
|
55
|
-
.mockImplementation(
|
|
56
|
-
(value) => Object.prototype.toString.call(value) === '[object String]'
|
|
57
|
-
),
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
afterEach(() => {
|
|
62
|
-
cleanup();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe('when no result is given', () => {
|
|
66
|
-
it('should show an error', async () => {
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
const element = createTestComponent({field: exampleField});
|
|
69
|
-
await flushPromises();
|
|
70
|
-
const errorMessage = element.shadowRoot.querySelector(errorSelector);
|
|
71
|
-
|
|
72
|
-
expect(errorMessage).not.toBeNull();
|
|
73
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
74
|
-
'The c-quantic-result-multi-value-text requires a result and a multi-value field to be specified.'
|
|
75
|
-
);
|
|
76
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
77
|
-
'Could not parse value from field "examplemultivaluefield" as a string array.'
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe('when no field is given', () => {
|
|
83
|
-
it('should show an error', async () => {
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
const element = createTestComponent({result: exampleResult});
|
|
86
|
-
await flushPromises();
|
|
87
|
-
|
|
88
|
-
const errorMessage = element.shadowRoot.querySelector(errorSelector);
|
|
89
|
-
|
|
90
|
-
expect(errorMessage).not.toBeNull();
|
|
91
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
92
|
-
'The c-quantic-result-multi-value-text requires a result and a multi-value field to be specified.'
|
|
93
|
-
);
|
|
94
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
95
|
-
'Could not parse value from field "undefined" as a string array.'
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('when the field value is an empty string', () => {
|
|
101
|
-
it('should show an error', async () => {
|
|
102
|
-
const element = createTestComponent({
|
|
103
|
-
...defaultOptions,
|
|
104
|
-
result: {
|
|
105
|
-
raw: {
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
[exampleField]: '',
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
await flushPromises();
|
|
112
|
-
|
|
113
|
-
const errorMessage = element.shadowRoot.querySelector(errorSelector);
|
|
114
|
-
|
|
115
|
-
expect(errorMessage).not.toBeNull();
|
|
116
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
117
|
-
'Could not parse value from field "examplemultivaluefield" as a string array.'
|
|
118
|
-
);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('when the field value is not a valid multi-value field', () => {
|
|
123
|
-
it('should show an error', async () => {
|
|
124
|
-
const element = createTestComponent({
|
|
125
|
-
...defaultOptions,
|
|
126
|
-
result: {
|
|
127
|
-
raw: {
|
|
128
|
-
// @ts-ignore
|
|
129
|
-
[exampleField]: 1,
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
await flushPromises();
|
|
134
|
-
|
|
135
|
-
const errorMessage = element.shadowRoot.querySelector(errorSelector);
|
|
136
|
-
|
|
137
|
-
expect(errorMessage).not.toBeNull();
|
|
138
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
139
|
-
'Could not parse value from field "examplemultivaluefield" as a string array.'
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe('when required props are given', () => {
|
|
145
|
-
it('should render the result field value', async () => {
|
|
146
|
-
const element = createTestComponent();
|
|
147
|
-
await flushPromises();
|
|
148
|
-
|
|
149
|
-
const fieldValueElement = element.shadowRoot.querySelector(valueSelector);
|
|
150
|
-
|
|
151
|
-
expect(fieldValueElement.textContent).toBe('One, Two, Three');
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe('when the number of values exceeds the maximum', () => {
|
|
155
|
-
const options = {
|
|
156
|
-
...defaultOptions,
|
|
157
|
-
maxValuesToDisplay: 2,
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
it('should hide the extra values', async () => {
|
|
161
|
-
const element = createTestComponent(options);
|
|
162
|
-
await flushPromises();
|
|
163
|
-
|
|
164
|
-
const fieldValueElement =
|
|
165
|
-
element.shadowRoot.querySelector(valueSelector);
|
|
166
|
-
|
|
167
|
-
expect(fieldValueElement.textContent).toBe('One, Two, c.quantic_NMore');
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
describe('when the field value is a string with a delimiter', () => {
|
|
172
|
-
const testResult = {
|
|
173
|
-
raw: {
|
|
174
|
-
[exampleField]: 'One-Two-Three',
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
const options = {
|
|
178
|
-
...defaultOptions,
|
|
179
|
-
result: testResult,
|
|
180
|
-
delimiter: '-',
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
it('should render the result field value', async () => {
|
|
184
|
-
// @ts-ignore
|
|
185
|
-
const element = createTestComponent(options);
|
|
186
|
-
await flushPromises();
|
|
187
|
-
|
|
188
|
-
const fieldValueElement =
|
|
189
|
-
element.shadowRoot.querySelector(valueSelector);
|
|
190
|
-
|
|
191
|
-
expect(fieldValueElement.textContent).toBe('One, Two, Three');
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe('when a label is provided', () => {
|
|
196
|
-
const testLabel = 'Numbers';
|
|
197
|
-
const options = {
|
|
198
|
-
...defaultOptions,
|
|
199
|
-
label: testLabel,
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
it('should hide the extra values', async () => {
|
|
203
|
-
const element = createTestComponent(options);
|
|
204
|
-
await flushPromises();
|
|
205
|
-
|
|
206
|
-
const fieldValueElement =
|
|
207
|
-
element.shadowRoot.querySelector(valueSelector);
|
|
208
|
-
const labelElement = element.shadowRoot.querySelector(labelSelector);
|
|
209
|
-
|
|
210
|
-
expect(fieldValueElement.textContent).toBe('One, Two, Three');
|
|
211
|
-
expect(labelElement.textContent).toBe(`${testLabel}:`);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe('when the label is not a valid string', () => {
|
|
215
|
-
const invalidLabel = {};
|
|
216
|
-
const invalidOptions = {
|
|
217
|
-
...defaultOptions,
|
|
218
|
-
label: invalidLabel,
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
it('should show an error', async () => {
|
|
222
|
-
const element = createTestComponent(invalidOptions);
|
|
223
|
-
await flushPromises();
|
|
224
|
-
|
|
225
|
-
const errorMessage = element.shadowRoot.querySelector(errorSelector);
|
|
226
|
-
|
|
227
|
-
expect(errorMessage).not.toBeNull();
|
|
228
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
229
|
-
`The "${invalidLabel}" label is not a valid string.`
|
|
230
|
-
);
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
});
|