@coveo/quantic 3.10.0-pre.fa559154a7 → 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 +8 -6
- 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
package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js
CHANGED
|
@@ -12,17 +12,22 @@ jest.mock('c/quanticUtils', () => ({
|
|
|
12
12
|
NUMERICFACETS: 'numericFacets',
|
|
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 exampleFilterId = `${exampleFacetId}_input`;
|
|
24
29
|
const defaultOptions = {
|
|
25
|
-
field:
|
|
30
|
+
field: exampleField,
|
|
26
31
|
};
|
|
27
32
|
const numericFacetControllerMock = {
|
|
28
33
|
subscribe: jest.fn((callback) => callback()),
|
|
@@ -31,6 +36,8 @@ const numericFacetControllerMock = {
|
|
|
31
36
|
values: [],
|
|
32
37
|
},
|
|
33
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.`;
|
|
34
41
|
|
|
35
42
|
function createTestComponent(options = defaultOptions) {
|
|
36
43
|
prepareHeadlessState();
|
|
@@ -87,6 +94,21 @@ const exampleEngine = {
|
|
|
87
94
|
};
|
|
88
95
|
let isInitialized = false;
|
|
89
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
|
+
|
|
90
112
|
function mockSuccessfulHeadlessInitialization() {
|
|
91
113
|
// @ts-ignore
|
|
92
114
|
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
@@ -109,6 +131,7 @@ function cleanup() {
|
|
|
109
131
|
describe('c-quantic-numeric-facet', () => {
|
|
110
132
|
beforeAll(() => {
|
|
111
133
|
mockSuccessfulHeadlessInitialization();
|
|
134
|
+
mockBueno();
|
|
112
135
|
});
|
|
113
136
|
|
|
114
137
|
afterEach(() => {
|
|
@@ -214,6 +237,89 @@ describe('c-quantic-numeric-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
|
+
});
|
|
322
|
+
|
|
217
323
|
describe('when the component is disconnected', () => {
|
|
218
324
|
it('should make the condition manager stop watching the facet', async () => {
|
|
219
325
|
const exampleFacetDependency = {
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
getHeadlessBindings,
|
|
19
19
|
registerToStore,
|
|
20
20
|
getHeadlessBundle,
|
|
21
|
+
getBueno,
|
|
21
22
|
} from 'c/quanticHeadlessLoader';
|
|
22
23
|
import {
|
|
23
24
|
I18nUtils,
|
|
@@ -264,6 +265,7 @@ export default class QuanticNumericFacet extends LightningElement {
|
|
|
264
265
|
* @param {SearchEngine} engine
|
|
265
266
|
*/
|
|
266
267
|
initialize = (engine) => {
|
|
268
|
+
this.validateDependsOnProperty();
|
|
267
269
|
this.headless = getHeadlessBundle(this.engineId);
|
|
268
270
|
this.searchStatus = this.headless.buildSearchStatus(engine);
|
|
269
271
|
this.unsubscribeSearchStatus = this.searchStatus.subscribe(() =>
|
|
@@ -288,6 +290,26 @@ export default class QuanticNumericFacet extends LightningElement {
|
|
|
288
290
|
});
|
|
289
291
|
};
|
|
290
292
|
|
|
293
|
+
validateDependsOnProperty() {
|
|
294
|
+
if (this.dependsOn) {
|
|
295
|
+
getBueno(this).then(() => {
|
|
296
|
+
const {parentFacetId, expectedValue} = this.dependsOn;
|
|
297
|
+
if (!Bueno.isString(parentFacetId)) {
|
|
298
|
+
console.error(
|
|
299
|
+
`The ${this.field} ${this.template.host.localName} requires dependsOn.parentFacetId to be a valid string.`
|
|
300
|
+
);
|
|
301
|
+
this.setInitializationError();
|
|
302
|
+
}
|
|
303
|
+
if (expectedValue && !Bueno.isString(expectedValue)) {
|
|
304
|
+
console.error(
|
|
305
|
+
`The ${this.field} ${this.template.host.localName} requires dependsOn.expectedValue to be a valid string.`
|
|
306
|
+
);
|
|
307
|
+
this.setInitializationError();
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
291
313
|
/**
|
|
292
314
|
* @param {import("coveo").SearchEngine} engine
|
|
293
315
|
*/
|
package/force-app/main/default/lwc/quanticRecommendationInterface/quanticRecommendationInterface.js
CHANGED
|
@@ -82,6 +82,14 @@ export default class QuanticRecommendationInterface extends LightningElement {
|
|
|
82
82
|
...(document.referrer && {
|
|
83
83
|
originLevel3: document.referrer.substring(0, 256),
|
|
84
84
|
}),
|
|
85
|
+
analyticsClientMiddleware: (_event, payload) => {
|
|
86
|
+
if (!payload.customData) {
|
|
87
|
+
payload.customData = {};
|
|
88
|
+
}
|
|
89
|
+
payload.customData.coveoQuanticVersion =
|
|
90
|
+
window.coveoQuanticVersion;
|
|
91
|
+
return payload;
|
|
92
|
+
},
|
|
85
93
|
},
|
|
86
94
|
...rest,
|
|
87
95
|
},
|
|
@@ -107,6 +107,14 @@ export default class QuanticSearchInterface extends LightningElement {
|
|
|
107
107
|
...(document.referrer && {
|
|
108
108
|
originLevel3: document.referrer.substring(0, 256),
|
|
109
109
|
}),
|
|
110
|
+
analyticsClientMiddleware: (_event, payload) => {
|
|
111
|
+
if (!payload.customData) {
|
|
112
|
+
payload.customData = {};
|
|
113
|
+
}
|
|
114
|
+
payload.customData.coveoQuanticVersion =
|
|
115
|
+
window.coveoQuanticVersion;
|
|
116
|
+
return payload;
|
|
117
|
+
},
|
|
110
118
|
},
|
|
111
119
|
...rest,
|
|
112
120
|
},
|
package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js
CHANGED
|
@@ -12,17 +12,22 @@ 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 exampleFilterId = `${exampleFacetId}_input`;
|
|
24
29
|
const defaultOptions = {
|
|
25
|
-
field:
|
|
30
|
+
field: exampleField,
|
|
26
31
|
};
|
|
27
32
|
const timeframeFacetControllerMock = {
|
|
28
33
|
subscribe: jest.fn((callback) => callback()),
|
|
@@ -31,6 +36,8 @@ const timeframeFacetControllerMock = {
|
|
|
31
36
|
values: [],
|
|
32
37
|
},
|
|
33
38
|
};
|
|
39
|
+
const parentFacetIdError = `The ${exampleField} c-quantic-timeframe-facet requires dependsOn.parentFacetId to be a valid string.`;
|
|
40
|
+
const expectedValueError = `The ${exampleField} c-quantic-timeframe-facet requires dependsOn.expectedValue to be a valid string.`;
|
|
34
41
|
|
|
35
42
|
function createTestComponent(options = defaultOptions) {
|
|
36
43
|
prepareHeadlessState();
|
|
@@ -87,6 +94,21 @@ const exampleEngine = {
|
|
|
87
94
|
};
|
|
88
95
|
let isInitialized = false;
|
|
89
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
|
+
|
|
90
112
|
function mockSuccessfulHeadlessInitialization() {
|
|
91
113
|
// @ts-ignore
|
|
92
114
|
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
@@ -109,6 +131,7 @@ function cleanup() {
|
|
|
109
131
|
describe('c-quantic-timeframe-facet', () => {
|
|
110
132
|
beforeAll(() => {
|
|
111
133
|
mockSuccessfulHeadlessInitialization();
|
|
134
|
+
mockBueno();
|
|
112
135
|
});
|
|
113
136
|
|
|
114
137
|
afterEach(() => {
|
|
@@ -211,6 +234,89 @@ describe('c-quantic-timeframe-facet', () => {
|
|
|
211
234
|
});
|
|
212
235
|
});
|
|
213
236
|
|
|
237
|
+
describe('validation of the dependsOn property', () => {
|
|
238
|
+
let consoleError;
|
|
239
|
+
beforeAll(() => {
|
|
240
|
+
consoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
241
|
+
});
|
|
242
|
+
describe('when dependsOn.parentFacetId is not provided', () => {
|
|
243
|
+
it('should display the error component', async () => {
|
|
244
|
+
const invalidFacetDependency = {
|
|
245
|
+
expectedValue: 'txt',
|
|
246
|
+
};
|
|
247
|
+
const element = createTestComponent({
|
|
248
|
+
...defaultOptions,
|
|
249
|
+
dependsOn: invalidFacetDependency,
|
|
250
|
+
});
|
|
251
|
+
await flushPromises();
|
|
252
|
+
|
|
253
|
+
const componentError = element.shadowRoot.querySelector(
|
|
254
|
+
selectors.componentError
|
|
255
|
+
);
|
|
256
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
257
|
+
selectors.facetContent
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
261
|
+
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
262
|
+
expect(componentError).not.toBeNull();
|
|
263
|
+
expect(facetContent).toBeNull();
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
describe('when dependsOn.parentFacetId is not a string', () => {
|
|
268
|
+
it('should display the error component', async () => {
|
|
269
|
+
const invalidFacetDependency = {
|
|
270
|
+
parentFacetId: 1,
|
|
271
|
+
expectedValue: 'txt',
|
|
272
|
+
};
|
|
273
|
+
const element = createTestComponent({
|
|
274
|
+
...defaultOptions,
|
|
275
|
+
dependsOn: invalidFacetDependency,
|
|
276
|
+
});
|
|
277
|
+
await flushPromises();
|
|
278
|
+
|
|
279
|
+
const componentError = element.shadowRoot.querySelector(
|
|
280
|
+
selectors.componentError
|
|
281
|
+
);
|
|
282
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
283
|
+
selectors.facetContent
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
287
|
+
expect(consoleError).toHaveBeenCalledWith(parentFacetIdError);
|
|
288
|
+
expect(componentError).not.toBeNull();
|
|
289
|
+
expect(facetContent).toBeNull();
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
describe('when dependsOn.expectedValue is not a string', () => {
|
|
294
|
+
it('should display the error component', async () => {
|
|
295
|
+
const invalidFacetDependency = {
|
|
296
|
+
parentFacetId: 'filetype',
|
|
297
|
+
expectedValue: 2,
|
|
298
|
+
};
|
|
299
|
+
const element = createTestComponent({
|
|
300
|
+
...defaultOptions,
|
|
301
|
+
dependsOn: invalidFacetDependency,
|
|
302
|
+
});
|
|
303
|
+
await flushPromises();
|
|
304
|
+
|
|
305
|
+
const componentError = element.shadowRoot.querySelector(
|
|
306
|
+
selectors.componentError
|
|
307
|
+
);
|
|
308
|
+
const facetContent = element.shadowRoot.querySelector(
|
|
309
|
+
selectors.facetContent
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
expect(consoleError).toHaveBeenCalledTimes(1);
|
|
313
|
+
expect(consoleError).toHaveBeenCalledWith(expectedValueError);
|
|
314
|
+
expect(componentError).not.toBeNull();
|
|
315
|
+
expect(facetContent).toBeNull();
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
|
|
214
320
|
describe('when the component is disconnected', () => {
|
|
215
321
|
it('should make the condition manager stop watching the facet', async () => {
|
|
216
322
|
const exampleFacetDependency = {
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
initializeWithHeadless,
|
|
13
13
|
registerComponentForInit,
|
|
14
14
|
registerToStore,
|
|
15
|
+
getBueno,
|
|
15
16
|
} from 'c/quanticHeadlessLoader';
|
|
16
17
|
import {
|
|
17
18
|
DateUtils,
|
|
@@ -414,6 +415,7 @@ export default class QuanticTimeframeFacet extends LightningElement {
|
|
|
414
415
|
* @param {SearchEngine} engine
|
|
415
416
|
*/
|
|
416
417
|
initialize = (engine) => {
|
|
418
|
+
this.validateDependsOnProperty();
|
|
417
419
|
this.headless = getHeadlessBundle(this.engineId);
|
|
418
420
|
this.initializeSearchStatusController(engine);
|
|
419
421
|
this.initializeFacetController(engine);
|
|
@@ -427,6 +429,26 @@ export default class QuanticTimeframeFacet extends LightningElement {
|
|
|
427
429
|
});
|
|
428
430
|
};
|
|
429
431
|
|
|
432
|
+
validateDependsOnProperty() {
|
|
433
|
+
if (this.dependsOn) {
|
|
434
|
+
getBueno(this).then(() => {
|
|
435
|
+
const {parentFacetId, expectedValue} = this.dependsOn;
|
|
436
|
+
if (!Bueno.isString(parentFacetId)) {
|
|
437
|
+
console.error(
|
|
438
|
+
`The ${this.field} ${this.template.host.localName} requires dependsOn.parentFacetId to be a valid string.`
|
|
439
|
+
);
|
|
440
|
+
this.setInitializationError();
|
|
441
|
+
}
|
|
442
|
+
if (expectedValue && !Bueno.isString(expectedValue)) {
|
|
443
|
+
console.error(
|
|
444
|
+
`The ${this.field} ${this.template.host.localName} requires dependsOn.expectedValue to be a valid string.`
|
|
445
|
+
);
|
|
446
|
+
this.setInitializationError();
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
430
452
|
/**
|
|
431
453
|
* @param {SearchEngine} engine
|
|
432
454
|
*/
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/(function
|
|
17
|
+
*/(function(g,f){if(typeof exports=="object"&&typeof module<"u"){module.exports=f()}else if("function"==typeof define && define.amd){define("Bueno",f)}else {g["Bueno"]=f()}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports};
|
|
18
18
|
"use strict";
|
|
19
19
|
var __defProp = Object.defineProperty;
|
|
20
20
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -393,20 +393,5 @@ var EnumValue = class {
|
|
|
393
393
|
return this.value.required;
|
|
394
394
|
}
|
|
395
395
|
};
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if ((from && typeof from === "object") || typeof from === "function") {
|
|
399
|
-
for (let key of Object.getOwnPropertyNames(from)) {
|
|
400
|
-
if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
|
|
401
|
-
Object.defineProperty(to, key, {
|
|
402
|
-
get: () => from[key],
|
|
403
|
-
enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
return to;
|
|
408
|
-
};
|
|
409
|
-
module.exports = __cp(module.exports, exports);
|
|
410
|
-
}
|
|
411
|
-
return module.exports;
|
|
412
|
-
}))
|
|
396
|
+
|
|
397
|
+
if(__exports != exports)module.exports = exports;return module.exports}));
|