@coveo/quantic 3.10.0-pre.faaf12d7a7 → 3.10.0
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/lwc/quanticCaseAssistInterface/quanticCaseAssistInterface.js +8 -0
- package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +108 -1
- package/force-app/main/default/lwc/quanticCategoryFacet/quanticCategoryFacet.js +22 -0
- package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +107 -1
- package/force-app/main/default/lwc/quanticDateFacet/quanticDateFacet.js +22 -0
- package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +106 -1
- package/force-app/main/default/lwc/quanticFacet/quanticFacet.js +21 -1
- package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +1 -1
- package/force-app/main/default/lwc/quanticFeedbackModalQna/quanticFeedbackModalQna.js +1 -1
- package/force-app/main/default/lwc/quanticGeneratedAnswer/templates/generatedAnswer.css +0 -1
- package/force-app/main/default/lwc/quanticGeneratedAnswerContent/templates/generatedMarkdownContent.css +1 -0
- package/force-app/main/default/lwc/quanticInsightInterface/quanticInsightInterface.js +8 -0
- package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +107 -1
- package/force-app/main/default/lwc/quanticNumericFacet/quanticNumericFacet.js +22 -0
- package/force-app/main/default/lwc/quanticRecommendationInterface/quanticRecommendationInterface.js +8 -0
- package/force-app/main/default/lwc/quanticSearchInterface/quanticSearchInterface.js +8 -0
- package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +107 -1
- package/force-app/main/default/lwc/quanticTimeframeFacet/quanticTimeframeFacet.js +22 -0
- package/force-app/main/default/staticresources/coveobueno/browser/bueno.js +3 -18
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +9 -6
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/common/request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/recommendations/recommendations-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/search/query-suggest/query-suggest-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/stream-answer-api.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/case-assist/get-case-classifications/get-case-classifications-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/case-assist/get-document-suggestions/get-document-suggestions-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/insight/get-interface/get-interface-config-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/insight/query/query-request.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/insight/user-actions/user-actions-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-engine/commerce-engine.ssr.d.ts +4 -13
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/common.d.ts +8 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/build-factory.d.ts +19 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/hydrated-state-factory.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/recommendation-hydrated-state-factory.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/recommendation-static-state-factory.d.ts +3 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/static-state-factory.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/build.d.ts +17 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/common.d.ts +20 -6
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/core-engine.d.ts +29 -10
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/fetch-static-state.d.ts +23 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/from-build-result.d.ts +20 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/hydrate-static-state.d.ts +25 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/logger.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/navigatorContextProvider.d.ts +17 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/app/ssr-engine/types/from-build-result.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/context/cart/headless-cart.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/context/headless-context.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/instant-products/headless-instant-products.ssr.d.ts +3 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/product-view/headless-product-view.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recommendations/headless-recommendations.ssr.d.ts +9 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/analytics/search-action-cause.d.ts +0 -82
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/facets/facet-set/facet-set-analytics-actions.d.ts +0 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/history/history-analytics-actions.d.ts +0 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/legacy/search-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-actions.d.ts +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-request.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/static-filter-set/static-filter-set-actions.d.ts +0 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce.index.d.ts +4 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/test/mock-engine-v2.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/utils/facet-utils.d.ts +1 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/utils/utils.d.ts +4 -0
- package/force-app/main/default/staticresources/coveoheadless/headless.js +11 -8
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +10 -7
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +9 -6
- package/force-app/main/default/staticresources/dompurify/purify.min.js +1339 -2
- package/package.json +14 -14
|
@@ -64,6 +64,14 @@ export default class QuanticCaseAssistInterface extends LightningElement {
|
|
|
64
64
|
...(document.referrer && {
|
|
65
65
|
originLevel3: document.referrer.substring(0, 256),
|
|
66
66
|
}),
|
|
67
|
+
analyticsClientMiddleware: (_event, payload) => {
|
|
68
|
+
if (!payload.customData) {
|
|
69
|
+
payload.customData = {};
|
|
70
|
+
}
|
|
71
|
+
payload.customData.coveoQuanticVersion =
|
|
72
|
+
window.coveoQuanticVersion;
|
|
73
|
+
return payload;
|
|
74
|
+
},
|
|
67
75
|
},
|
|
68
76
|
...rest,
|
|
69
77
|
},
|
package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js
CHANGED
|
@@ -15,16 +15,21 @@ jest.mock('c/quanticUtils', () => ({
|
|
|
15
15
|
CATEGORYFACETS: 'categoryFacets',
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
|
+
I18nUtils: {
|
|
19
|
+
format: jest.fn(),
|
|
20
|
+
},
|
|
18
21
|
}));
|
|
19
22
|
jest.mock('c/quanticHeadlessLoader');
|
|
20
23
|
|
|
21
24
|
const selectors = {
|
|
22
25
|
facetContent: '[data-test="facet-content"]',
|
|
26
|
+
componentError: 'c-quantic-component-error',
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
const exampleFacetId = 'example facet id';
|
|
30
|
+
const exampleField = 'exampleField';
|
|
26
31
|
const defaultOptions = {
|
|
27
|
-
field:
|
|
32
|
+
field: exampleField,
|
|
28
33
|
};
|
|
29
34
|
const categoryFacetControllerMock = {
|
|
30
35
|
subscribe: jest.fn((callback) => callback()),
|
|
@@ -33,6 +38,8 @@ const categoryFacetControllerMock = {
|
|
|
33
38
|
values: [],
|
|
34
39
|
},
|
|
35
40
|
};
|
|
41
|
+
const parentFacetIdError = `The ${exampleField} c-quantic-category-facet requires dependsOn.parentFacetId to be a valid string.`;
|
|
42
|
+
const expectedValueError = `The ${exampleField} c-quantic-category-facet requires dependsOn.expectedValue to be a valid string.`;
|
|
36
43
|
|
|
37
44
|
function createTestComponent(options = defaultOptions) {
|
|
38
45
|
prepareHeadlessState();
|
|
@@ -82,6 +89,21 @@ const exampleEngine = {
|
|
|
82
89
|
};
|
|
83
90
|
let isInitialized = false;
|
|
84
91
|
|
|
92
|
+
function mockBueno() {
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
mockHeadlessLoader.getBueno = () => {
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
global.Bueno = {
|
|
97
|
+
isString: jest
|
|
98
|
+
.fn()
|
|
99
|
+
.mockImplementation(
|
|
100
|
+
(value) => Object.prototype.toString.call(value) === '[object String]'
|
|
101
|
+
),
|
|
102
|
+
};
|
|
103
|
+
return new Promise((resolve) => resolve());
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
85
107
|
function mockSuccessfulHeadlessInitialization() {
|
|
86
108
|
// @ts-ignore
|
|
87
109
|
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
@@ -104,6 +126,7 @@ function cleanup() {
|
|
|
104
126
|
describe('c-quantic-category-facet', () => {
|
|
105
127
|
beforeAll(() => {
|
|
106
128
|
mockSuccessfulHeadlessInitialization();
|
|
129
|
+
mockBueno();
|
|
107
130
|
});
|
|
108
131
|
|
|
109
132
|
afterEach(() => {
|
|
@@ -198,6 +221,90 @@ describe('c-quantic-category-facet', () => {
|
|
|
198
221
|
});
|
|
199
222
|
});
|
|
200
223
|
|
|
224
|
+
describe('validation of the dependsOn property', () => {
|
|
225
|
+
let consoleError;
|
|
226
|
+
beforeAll(() => {
|
|
227
|
+
consoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('when dependsOn.parentFacetId is not provided', () => {
|
|
231
|
+
it('should display the error component', async () => {
|
|
232
|
+
const invalidFacetDependency = {
|
|
233
|
+
expectedValue: 'txt',
|
|
234
|
+
};
|
|
235
|
+
const element = createTestComponent({
|
|
236
|
+
...defaultOptions,
|
|
237
|
+
dependsOn: invalidFacetDependency,
|
|
238
|
+
});
|
|
239
|
+
await flushPromises();
|
|
240
|
+
|
|
241
|
+
const componentError = element.shadowRoot.querySelector(
|
|
242
|
+
selectors.componentError
|
|
243
|
+
);
|
|
244
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
245
|
+
selectors.facetContent
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
249
|
+
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
250
|
+
expect(componentError).not.toBeNull();
|
|
251
|
+
expect(facetContent).toBeNull();
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
describe('when dependsOn.parentFacetId is not a string', () => {
|
|
256
|
+
it('should display the error component', async () => {
|
|
257
|
+
const invalidFacetDependency = {
|
|
258
|
+
parentFacetId: 1,
|
|
259
|
+
expectedValue: 'txt',
|
|
260
|
+
};
|
|
261
|
+
const element = createTestComponent({
|
|
262
|
+
...defaultOptions,
|
|
263
|
+
dependsOn: invalidFacetDependency,
|
|
264
|
+
});
|
|
265
|
+
await flushPromises();
|
|
266
|
+
|
|
267
|
+
const componentError = element.shadowRoot.querySelector(
|
|
268
|
+
selectors.componentError
|
|
269
|
+
);
|
|
270
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
271
|
+
selectors.facetContent
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
275
|
+
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
276
|
+
expect(componentError).not.toBeNull();
|
|
277
|
+
expect(facetContent).toBeNull();
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
describe('when dependsOn.expectedValue is not a string', () => {
|
|
282
|
+
it('should display the error component', async () => {
|
|
283
|
+
const invalidFacetDependency = {
|
|
284
|
+
parentFacetId: 'filetype',
|
|
285
|
+
expectedValue: 2,
|
|
286
|
+
};
|
|
287
|
+
const element = createTestComponent({
|
|
288
|
+
...defaultOptions,
|
|
289
|
+
dependsOn: invalidFacetDependency,
|
|
290
|
+
});
|
|
291
|
+
await flushPromises();
|
|
292
|
+
|
|
293
|
+
const componentError = element.shadowRoot.querySelector(
|
|
294
|
+
selectors.componentError
|
|
295
|
+
);
|
|
296
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
297
|
+
selectors.facetContent
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
301
|
+
expect(consoleError).toHaveBeenCalledWith(expectedValueError);
|
|
302
|
+
expect(componentError).not.toBeNull();
|
|
303
|
+
expect(facetContent).toBeNull();
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
|
|
201
308
|
describe('when the component is disconnected', () => {
|
|
202
309
|
it('should make the condition manager stop watching the facet', async () => {
|
|
203
310
|
const exampleFacetDependency = {
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
initializeWithHeadless,
|
|
15
15
|
registerToStore,
|
|
16
16
|
getHeadlessBundle,
|
|
17
|
+
getBueno,
|
|
17
18
|
} from 'c/quanticHeadlessLoader';
|
|
18
19
|
import {
|
|
19
20
|
I18nUtils,
|
|
@@ -301,6 +302,7 @@ export default class QuanticCategoryFacet extends LightningElement {
|
|
|
301
302
|
},
|
|
302
303
|
});
|
|
303
304
|
if (this.dependsOn) {
|
|
305
|
+
this.validateDependsOnProperty();
|
|
304
306
|
this.initFacetConditionManager(engine);
|
|
305
307
|
}
|
|
306
308
|
this.unsubscribe = this.facet.subscribe(() => this.updateState());
|
|
@@ -330,6 +332,26 @@ export default class QuanticCategoryFacet extends LightningElement {
|
|
|
330
332
|
this.dispatchEvent(renderFacetEvent);
|
|
331
333
|
}
|
|
332
334
|
|
|
335
|
+
validateDependsOnProperty() {
|
|
336
|
+
if (this.dependsOn) {
|
|
337
|
+
getBueno(this).then(() => {
|
|
338
|
+
const {parentFacetId, expectedValue} = this.dependsOn;
|
|
339
|
+
if (!Bueno.isString(parentFacetId)) {
|
|
340
|
+
console.error(
|
|
341
|
+
`The ${this.field} ${this.template.host.localName} requires dependsOn.parentFacetId to be a valid string.`
|
|
342
|
+
);
|
|
343
|
+
this.setInitializationError();
|
|
344
|
+
}
|
|
345
|
+
if (expectedValue && !Bueno.isString(expectedValue)) {
|
|
346
|
+
console.error(
|
|
347
|
+
`The ${this.field} ${this.template.host.localName} requires dependsOn.expectedValue to be a valid string.`
|
|
348
|
+
);
|
|
349
|
+
this.setInitializationError();
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
333
355
|
initFacetConditionManager(engine) {
|
|
334
356
|
this.categoryFacetConditionsManager =
|
|
335
357
|
this.headless.buildFacetConditionsManager(engine, {
|
|
@@ -12,16 +12,21 @@ jest.mock('c/quanticUtils', () => ({
|
|
|
12
12
|
DATEFACETS: 'dateFacets',
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
|
+
I18nUtils: {
|
|
16
|
+
format: jest.fn(),
|
|
17
|
+
},
|
|
15
18
|
}));
|
|
16
19
|
jest.mock('c/quanticHeadlessLoader');
|
|
17
20
|
|
|
18
21
|
const selectors = {
|
|
19
22
|
facetContent: '[data-test="facet-content"]',
|
|
23
|
+
componentError: 'c-quantic-component-error',
|
|
20
24
|
};
|
|
21
25
|
|
|
22
26
|
const exampleFacetId = 'example facet id';
|
|
27
|
+
const exampleField = 'exampleField';
|
|
23
28
|
const defaultOptions = {
|
|
24
|
-
field:
|
|
29
|
+
field: exampleField,
|
|
25
30
|
};
|
|
26
31
|
const dateFacetControllerMock = {
|
|
27
32
|
subscribe: jest.fn((callback) => callback()),
|
|
@@ -30,6 +35,8 @@ const dateFacetControllerMock = {
|
|
|
30
35
|
values: [],
|
|
31
36
|
},
|
|
32
37
|
};
|
|
38
|
+
const parentFacetIdError = `The ${exampleField} c-quantic-date-facet requires dependsOn.parentFacetId to be a valid string.`;
|
|
39
|
+
const expectedValueError = `The ${exampleField} c-quantic-date-facet requires dependsOn.expectedValue to be a valid string.`;
|
|
33
40
|
|
|
34
41
|
function createTestComponent(options = defaultOptions) {
|
|
35
42
|
prepareHeadlessState();
|
|
@@ -79,6 +86,21 @@ const exampleEngine = {
|
|
|
79
86
|
};
|
|
80
87
|
let isInitialized = false;
|
|
81
88
|
|
|
89
|
+
function mockBueno() {
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
mockHeadlessLoader.getBueno = () => {
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
global.Bueno = {
|
|
94
|
+
isString: jest
|
|
95
|
+
.fn()
|
|
96
|
+
.mockImplementation(
|
|
97
|
+
(value) => Object.prototype.toString.call(value) === '[object String]'
|
|
98
|
+
),
|
|
99
|
+
};
|
|
100
|
+
return new Promise((resolve) => resolve());
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
82
104
|
function mockSuccessfulHeadlessInitialization() {
|
|
83
105
|
// @ts-ignore
|
|
84
106
|
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
@@ -101,6 +123,7 @@ function cleanup() {
|
|
|
101
123
|
describe('c-quantic-date-facet', () => {
|
|
102
124
|
beforeAll(() => {
|
|
103
125
|
mockSuccessfulHeadlessInitialization();
|
|
126
|
+
mockBueno();
|
|
104
127
|
});
|
|
105
128
|
|
|
106
129
|
afterEach(() => {
|
|
@@ -193,6 +216,89 @@ describe('c-quantic-date-facet', () => {
|
|
|
193
216
|
});
|
|
194
217
|
});
|
|
195
218
|
|
|
219
|
+
describe('validation of the dependsOn property', () => {
|
|
220
|
+
let consoleError;
|
|
221
|
+
beforeAll(() => {
|
|
222
|
+
consoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
223
|
+
});
|
|
224
|
+
describe('when dependsOn.parentFacetId is not provided', () => {
|
|
225
|
+
it('should display the error component', async () => {
|
|
226
|
+
const invalidFacetDependency = {
|
|
227
|
+
expectedValue: 'txt',
|
|
228
|
+
};
|
|
229
|
+
const element = createTestComponent({
|
|
230
|
+
...defaultOptions,
|
|
231
|
+
dependsOn: invalidFacetDependency,
|
|
232
|
+
});
|
|
233
|
+
await flushPromises();
|
|
234
|
+
|
|
235
|
+
const componentError = element.shadowRoot.querySelector(
|
|
236
|
+
selectors.componentError
|
|
237
|
+
);
|
|
238
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
239
|
+
selectors.facetContent
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
243
|
+
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
244
|
+
expect(componentError).not.toBeNull();
|
|
245
|
+
expect(facetContent).toBeNull();
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
describe('when dependsOn.parentFacetId is not a string', () => {
|
|
250
|
+
it('should display the error component', async () => {
|
|
251
|
+
const invalidFacetDependency = {
|
|
252
|
+
parentFacetId: 1,
|
|
253
|
+
expectedValue: 'txt',
|
|
254
|
+
};
|
|
255
|
+
const element = createTestComponent({
|
|
256
|
+
...defaultOptions,
|
|
257
|
+
dependsOn: invalidFacetDependency,
|
|
258
|
+
});
|
|
259
|
+
await flushPromises();
|
|
260
|
+
|
|
261
|
+
const componentError = element.shadowRoot.querySelector(
|
|
262
|
+
selectors.componentError
|
|
263
|
+
);
|
|
264
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
265
|
+
selectors.facetContent
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
269
|
+
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
270
|
+
expect(componentError).not.toBeNull();
|
|
271
|
+
expect(facetContent).toBeNull();
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
describe('when dependsOn.expectedValue is not a string', () => {
|
|
276
|
+
it('should display the error component', async () => {
|
|
277
|
+
const invalidFacetDependency = {
|
|
278
|
+
parentFacetId: 'filetype',
|
|
279
|
+
expectedValue: 2,
|
|
280
|
+
};
|
|
281
|
+
const element = createTestComponent({
|
|
282
|
+
...defaultOptions,
|
|
283
|
+
dependsOn: invalidFacetDependency,
|
|
284
|
+
});
|
|
285
|
+
await flushPromises();
|
|
286
|
+
|
|
287
|
+
const componentError = element.shadowRoot.querySelector(
|
|
288
|
+
selectors.componentError
|
|
289
|
+
);
|
|
290
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
291
|
+
selectors.facetContent
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
295
|
+
expect(consoleError).toHaveBeenCalledWith(expectedValueError);
|
|
296
|
+
expect(componentError).not.toBeNull();
|
|
297
|
+
expect(facetContent).toBeNull();
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
|
|
196
302
|
describe('when the component is disconnected', () => {
|
|
197
303
|
it('should make the condition manager stop watching the facet', async () => {
|
|
198
304
|
const exampleFacetDependency = {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
initializeWithHeadless,
|
|
10
10
|
registerToStore,
|
|
11
11
|
getHeadlessBundle,
|
|
12
|
+
getBueno,
|
|
12
13
|
} from 'c/quanticHeadlessLoader';
|
|
13
14
|
import {
|
|
14
15
|
I18nUtils,
|
|
@@ -210,6 +211,7 @@ export default class QuanticDateFacet extends LightningElement {
|
|
|
210
211
|
element: this.template.host,
|
|
211
212
|
});
|
|
212
213
|
if (this.dependsOn) {
|
|
214
|
+
this.validateDependsOnProperty();
|
|
213
215
|
this.initFacetConditionManager(engine);
|
|
214
216
|
}
|
|
215
217
|
};
|
|
@@ -238,6 +240,26 @@ export default class QuanticDateFacet extends LightningElement {
|
|
|
238
240
|
this.dispatchEvent(renderFacetEvent);
|
|
239
241
|
}
|
|
240
242
|
|
|
243
|
+
validateDependsOnProperty() {
|
|
244
|
+
if (this.dependsOn) {
|
|
245
|
+
getBueno(this).then(() => {
|
|
246
|
+
const {parentFacetId, expectedValue} = this.dependsOn;
|
|
247
|
+
if (!Bueno.isString(parentFacetId)) {
|
|
248
|
+
console.error(
|
|
249
|
+
`The ${this.field} ${this.template.host.localName} requires dependsOn.parentFacetId to be a valid string.`
|
|
250
|
+
);
|
|
251
|
+
this.setInitializationError();
|
|
252
|
+
}
|
|
253
|
+
if (expectedValue && !Bueno.isString(expectedValue)) {
|
|
254
|
+
console.error(
|
|
255
|
+
`The ${this.field} ${this.template.host.localName} requires dependsOn.expectedValue to be a valid string.`
|
|
256
|
+
);
|
|
257
|
+
this.setInitializationError();
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
241
263
|
initFacetConditionManager(engine) {
|
|
242
264
|
this.dateFacetConditionsManager = this.headless.buildFacetConditionsManager(
|
|
243
265
|
engine,
|
|
@@ -12,16 +12,21 @@ jest.mock('c/quanticUtils', () => ({
|
|
|
12
12
|
FACETS: 'facets',
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
|
+
I18nUtils: {
|
|
16
|
+
format: jest.fn(),
|
|
17
|
+
},
|
|
15
18
|
}));
|
|
16
19
|
jest.mock('c/quanticHeadlessLoader');
|
|
17
20
|
|
|
18
21
|
const selectors = {
|
|
19
22
|
facetContent: '[data-test="facet-content"]',
|
|
23
|
+
componentError: 'c-quantic-component-error',
|
|
20
24
|
};
|
|
21
25
|
|
|
22
26
|
const exampleFacetId = 'example facet id';
|
|
27
|
+
const exampleField = 'exampleField';
|
|
23
28
|
const defaultOptions = {
|
|
24
|
-
field:
|
|
29
|
+
field: exampleField,
|
|
25
30
|
};
|
|
26
31
|
const facetControllerMock = {
|
|
27
32
|
subscribe: jest.fn((callback) => callback()),
|
|
@@ -30,6 +35,8 @@ const facetControllerMock = {
|
|
|
30
35
|
values: [],
|
|
31
36
|
},
|
|
32
37
|
};
|
|
38
|
+
const parentFacetIdError = `The ${exampleField} c-quantic-facet requires dependsOn.parentFacetId to be a valid string.`;
|
|
39
|
+
const expectedValueError = `The ${exampleField} c-quantic-facet requires dependsOn.expectedValue to be a valid string.`;
|
|
33
40
|
|
|
34
41
|
function createTestComponent(options = defaultOptions) {
|
|
35
42
|
prepareHeadlessState();
|
|
@@ -89,6 +96,21 @@ function mockSuccessfulHeadlessInitialization() {
|
|
|
89
96
|
};
|
|
90
97
|
}
|
|
91
98
|
|
|
99
|
+
function mockBueno() {
|
|
100
|
+
// @ts-ignore
|
|
101
|
+
mockHeadlessLoader.getBueno = () => {
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
global.Bueno = {
|
|
104
|
+
isString: jest
|
|
105
|
+
.fn()
|
|
106
|
+
.mockImplementation(
|
|
107
|
+
(value) => Object.prototype.toString.call(value) === '[object String]'
|
|
108
|
+
),
|
|
109
|
+
};
|
|
110
|
+
return new Promise((resolve) => resolve());
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
92
114
|
function cleanup() {
|
|
93
115
|
// The jsdom instance is shared across test cases in a single file so reset the DOM
|
|
94
116
|
while (document.body.firstChild) {
|
|
@@ -101,6 +123,7 @@ function cleanup() {
|
|
|
101
123
|
describe('c-quantic-facet', () => {
|
|
102
124
|
beforeAll(() => {
|
|
103
125
|
mockSuccessfulHeadlessInitialization();
|
|
126
|
+
mockBueno();
|
|
104
127
|
});
|
|
105
128
|
|
|
106
129
|
afterEach(() => {
|
|
@@ -214,6 +237,88 @@ describe('c-quantic-facet', () => {
|
|
|
214
237
|
});
|
|
215
238
|
});
|
|
216
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
|
+
});
|
|
217
322
|
describe('when the component is disconnected', () => {
|
|
218
323
|
it('should make the condition manager stop watching the facet', async () => {
|
|
219
324
|
const exampleFacetDependency = {
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
initializeWithHeadless,
|
|
16
16
|
registerToStore,
|
|
17
17
|
getHeadlessBundle,
|
|
18
|
+
getBueno,
|
|
18
19
|
} from 'c/quanticHeadlessLoader';
|
|
19
20
|
import {
|
|
20
21
|
I18nUtils,
|
|
@@ -177,7 +178,6 @@ export default class QuanticFacet extends LightningElement {
|
|
|
177
178
|
* @type {DependsOn}
|
|
178
179
|
*/
|
|
179
180
|
@api dependsOn;
|
|
180
|
-
|
|
181
181
|
/**
|
|
182
182
|
* Whether the facet is collapsed.
|
|
183
183
|
* @api
|
|
@@ -315,6 +315,7 @@ export default class QuanticFacet extends LightningElement {
|
|
|
315
315
|
element: this.template.host,
|
|
316
316
|
});
|
|
317
317
|
if (this.dependsOn) {
|
|
318
|
+
this.validateDependsOnProperty();
|
|
318
319
|
this.initFacetConditionManager(engine);
|
|
319
320
|
}
|
|
320
321
|
};
|
|
@@ -342,6 +343,25 @@ export default class QuanticFacet extends LightningElement {
|
|
|
342
343
|
});
|
|
343
344
|
this.dispatchEvent(renderFacetEvent);
|
|
344
345
|
}
|
|
346
|
+
validateDependsOnProperty() {
|
|
347
|
+
if (this.dependsOn) {
|
|
348
|
+
getBueno(this).then(() => {
|
|
349
|
+
const {parentFacetId, expectedValue} = this.dependsOn;
|
|
350
|
+
if (!Bueno.isString(parentFacetId)) {
|
|
351
|
+
console.error(
|
|
352
|
+
`The ${this.field} ${this.template.host.localName} requires dependsOn.parentFacetId to be a valid string.`
|
|
353
|
+
);
|
|
354
|
+
this.setInitializationError();
|
|
355
|
+
}
|
|
356
|
+
if (expectedValue && !Bueno.isString(expectedValue)) {
|
|
357
|
+
console.error(
|
|
358
|
+
`The ${this.field} ${this.template.host.localName} requires dependsOn.expectedValue to be a valid string.`
|
|
359
|
+
);
|
|
360
|
+
this.setInitializationError();
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
345
365
|
|
|
346
366
|
initFacetConditionManager(engine) {
|
|
347
367
|
this.facetConditionsManager = this.headless.buildFacetConditionsManager(
|
package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js
CHANGED
|
@@ -193,7 +193,7 @@ describe('c-quantic-feedback-modal-qna', () => {
|
|
|
193
193
|
|
|
194
194
|
expect(functionsMocks.handleSubmit).toHaveBeenCalledWith(
|
|
195
195
|
expect.objectContaining({
|
|
196
|
-
|
|
196
|
+
correctTopic: 'yes',
|
|
197
197
|
hallucinationFree: 'yes',
|
|
198
198
|
documented: 'yes',
|
|
199
199
|
readable: 'yes',
|
|
@@ -168,7 +168,7 @@ export default class QuanticFeedbackModalQna extends LightningModal {
|
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
170
|
this.handleSubmit({
|
|
171
|
-
|
|
171
|
+
correctTopic: this.correctTopicValue,
|
|
172
172
|
hallucinationFree: this.hallucinationFreeValue,
|
|
173
173
|
documented: this.documentedValue,
|
|
174
174
|
readable: this.readableValue,
|
|
@@ -80,6 +80,14 @@ export default class QuanticInsightInterface extends LightningElement {
|
|
|
80
80
|
...(document.referrer && {
|
|
81
81
|
originLevel3: document.referrer.substring(0, 256),
|
|
82
82
|
}),
|
|
83
|
+
analyticsClientMiddleware: (_event, payload) => {
|
|
84
|
+
if (!payload.customData) {
|
|
85
|
+
payload.customData = {};
|
|
86
|
+
}
|
|
87
|
+
payload.customData.coveoQuanticVersion =
|
|
88
|
+
window.coveoQuanticVersion;
|
|
89
|
+
return payload;
|
|
90
|
+
},
|
|
83
91
|
},
|
|
84
92
|
...rest,
|
|
85
93
|
},
|