@coveo/quantic 3.16.0 → 3.16.1-pre.1a6fc4649f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/out/quantic-docs.json +2 -2
- package/force-app/main/default/lwc/quanticNumberButton/quanticNumberButton.html +1 -1
- package/force-app/main/default/lwc/quanticResultsPerPage/quanticResultsPerPage.js +27 -17
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +6 -6
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.d.ts +0 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/parameter-manager/parameter-manager-selectors.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-parameters/search-parameter-actions-loader.d.ts +36 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-parameters/search-parameter-actions.d.ts +6 -0
- package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -10
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +9 -9
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +5 -5
- package/package.json +6 -4
- package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +0 -604
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/fixture.ts +0 -76
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/pageObject.ts +0 -282
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/quanticBreadcrumbManager.e2e.ts +0 -167
- package/force-app/main/default/lwc/quanticCarousel/__tests__/quanticCarousel.test.js +0 -262
- package/force-app/main/default/lwc/quanticCaseClassification/__tests__/quanticCaseClassification.test.js +0 -819
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/data.ts +0 -23
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/fixture.ts +0 -51
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/pageObject.ts +0 -152
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/quanticCaseClassification.e2e.ts +0 -269
- package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +0 -327
- package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +0 -269
- package/force-app/main/default/lwc/quanticColoredResultBadge/__tests__/quanticColoredResultBadge.test.js +0 -212
- package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +0 -321
- package/force-app/main/default/lwc/quanticDidYouMean/__tests__/quanticDidYouMean.test.js +0 -199
- package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +0 -341
- package/force-app/main/default/lwc/quanticFacetCaption/__tests__/quanticFacetCaption.test.js +0 -28
- package/force-app/main/default/lwc/quanticFacetManager/__tests__/quanticFacetManager.test.js +0 -178
- package/force-app/main/default/lwc/quanticFacetManager/e2e/fixture.ts +0 -63
- package/force-app/main/default/lwc/quanticFacetManager/e2e/pageObject.ts +0 -23
- package/force-app/main/default/lwc/quanticFacetManager/e2e/quanticFacetManager.e2e.ts +0 -82
- package/force-app/main/default/lwc/quanticFeedback/__tests__/quanticFeedback.test.js +0 -392
- package/force-app/main/default/lwc/quanticFeedbackModal/__tests__/quanticFeedbackModal.test.js +0 -448
- package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +0 -298
- package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +0 -814
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +0 -56
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +0 -87
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +0 -283
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +0 -199
- package/force-app/main/default/lwc/quanticGeneratedAnswerContent/__tests__/quanticGeneratedAnswerContent.test.js +0 -151
- package/force-app/main/default/lwc/quanticHeading/__tests__/quanticHeading.test.js +0 -71
- package/force-app/main/default/lwc/quanticHeadlessLoader/__tests__/quanticHeadlessLoader.test.js +0 -651
- package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +0 -335
- package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +0 -343
- package/force-app/main/default/lwc/quanticPager/e2e/fixture.ts +0 -63
- package/force-app/main/default/lwc/quanticPager/e2e/pageObject.ts +0 -69
- package/force-app/main/default/lwc/quanticPager/e2e/quanticPager.e2e.ts +0 -101
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/defaultTestCase.json +0 -13
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/youtubeTestCase.json +0 -14
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/quanticQuickviewContent.test.js +0 -82
- package/force-app/main/default/lwc/quanticRadioButtonsGroup/__tests__/quanticRadioButtonsGroup.test.js +0 -273
- package/force-app/main/default/lwc/quanticRefineModalContent/__tests__/quanticRefineModalContent.test.js +0 -501
- package/force-app/main/default/lwc/quanticResultAction/__tests__/quanticResultAction.test.js +0 -262
- package/force-app/main/default/lwc/quanticResultActionBar/__tests__/quanticResultActionBar.test.js +0 -141
- package/force-app/main/default/lwc/quanticResultChildren/__tests__/quanticResultChildren.test.js +0 -340
- package/force-app/main/default/lwc/quanticResultDate/__tests__/quanticResultDate.test.js +0 -144
- package/force-app/main/default/lwc/quanticResultField/__tests__/quanticResultField.test.js +0 -120
- package/force-app/main/default/lwc/quanticResultHighlightedTextField/__tests__/quanticResultHighlightedTextField.test.js +0 -209
- package/force-app/main/default/lwc/quanticResultLink/__tests__/quanticResultLink.test.js +0 -261
- package/force-app/main/default/lwc/quanticResultMultiValueText/__tests__/quanticResultMultiValueText.test.js +0 -235
- package/force-app/main/default/lwc/quanticResultNumber/__tests__/quanticResultNumber.test.js +0 -144
- package/force-app/main/default/lwc/quanticResultPrintableUri/__tests__/quanticResultPrintableUri.test.js +0 -324
- package/force-app/main/default/lwc/quanticResultQuickview/__tests__/quanticResultQuickview.test.js +0 -171
- package/force-app/main/default/lwc/quanticResultText/__tests__/quanticResultText.test.js +0 -155
- package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js +0 -404
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +0 -74
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/pageObject.ts +0 -85
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/quanticResultsPerPage.e2e.ts +0 -97
- package/force-app/main/default/lwc/quanticSearchBox/__tests__/quanticSearchBox.test.js +0 -168
- package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js +0 -823
- package/force-app/main/default/lwc/quanticSmartSnippet/__tests__/quanticSmartSnippet.test.js +0 -341
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/data.ts +0 -21
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/fixture.ts +0 -91
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +0 -196
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +0 -168
- package/force-app/main/default/lwc/quanticSmartSnippetAnswer/__tests__/quanticSmartSnippetAnswer.test.js +0 -126
- package/force-app/main/default/lwc/quanticSmartSnippetSource/__tests__/quanticSmartSnippetSource.test.js +0 -290
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/__tests__/quanticSmartSnippetSuggestions.test.js +0 -329
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/data.ts +0 -31
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/fixture.ts +0 -93
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/pageObject.ts +0 -160
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/quanticSmartSnippetSuggestions.e2e.ts +0 -127
- package/force-app/main/default/lwc/quanticSort/__tests__/quanticSort.test.js +0 -416
- package/force-app/main/default/lwc/quanticSort/e2e/fixture.ts +0 -61
- package/force-app/main/default/lwc/quanticSort/e2e/pageObject.ts +0 -89
- package/force-app/main/default/lwc/quanticSort/e2e/quanticSort.e2e.ts +0 -91
- package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +0 -123
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/__tests__/quanticStandaloneSearchBox.test.js +0 -186
- package/force-app/main/default/lwc/quanticStatefulButton/__tests__/quanticStatefulButton.test.js +0 -222
- package/force-app/main/default/lwc/quanticTab/__tests__/quanticTab.test.js +0 -287
- package/force-app/main/default/lwc/quanticTab/e2e/fixture.ts +0 -62
- package/force-app/main/default/lwc/quanticTab/e2e/pageObject.ts +0 -67
- package/force-app/main/default/lwc/quanticTab/e2e/quanticTab.e2e.ts +0 -77
- package/force-app/main/default/lwc/quanticTabBar/__tests__/quanticTabBar.test.js +0 -331
- package/force-app/main/default/lwc/quanticTabBar/e2e/fixture.ts +0 -61
- package/force-app/main/default/lwc/quanticTabBar/e2e/pageObject.ts +0 -80
- package/force-app/main/default/lwc/quanticTabBar/e2e/quanticTabBar.e2e.ts +0 -173
- package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +0 -339
- package/force-app/main/default/lwc/quanticTooltip/__tests__/quanticTooltip.test.js +0 -107
- package/force-app/main/default/lwc/quanticUserAction/__tests__/quanticUserAction.test.js +0 -427
- package/force-app/main/default/lwc/quanticUserActionsSession/__tests__/quanticUserActionsSession.test.js +0 -269
- package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/data/userActionsState.json +0 -89
- package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/quanticUserActionsTimeline.test.js +0 -511
- package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +0 -229
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +0 -32
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +0 -32
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +0 -71
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +0 -39
- package/force-app/main/default/lwc/quanticUtils/__tests__/facetDependenciesUtils.test.js +0 -92
- package/force-app/main/default/lwc/quanticUtils/__tests__/markdownUtils.test.js +0 -71
- package/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js +0 -223
- package/force-app/main/default/lwc/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +0 -131
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import {createElement} from 'lwc';
|
|
3
|
-
import QuanticResultText from '../quanticResultText';
|
|
4
|
-
|
|
5
|
-
const exampleField = 'examplefield';
|
|
6
|
-
const exampleFieldValue = 'example value';
|
|
7
|
-
const exampleLabel = 'example label';
|
|
8
|
-
const exampleResult = {
|
|
9
|
-
raw: {
|
|
10
|
-
[exampleField]: exampleFieldValue,
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const labelSelector = '.result-text__label';
|
|
15
|
-
const valueSelector = '.result-text__value';
|
|
16
|
-
const errorSelector = '.error-message';
|
|
17
|
-
|
|
18
|
-
const defaultOptions = {
|
|
19
|
-
result: exampleResult,
|
|
20
|
-
field: exampleField,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
function createTestComponent(options = defaultOptions) {
|
|
24
|
-
const element = createElement('c-quantic-result-text', {
|
|
25
|
-
is: QuanticResultText,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
for (const [key, value] of Object.entries(options)) {
|
|
29
|
-
element[key] = value;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
document.body.appendChild(element);
|
|
33
|
-
return element;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Helper function to wait until the microtask queue is empty.
|
|
37
|
-
function flushPromises() {
|
|
38
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
describe('c-quantic-result-text', () => {
|
|
42
|
-
function cleanup() {
|
|
43
|
-
// The jsdom instance is shared across test cases in a single file so reset the DOM
|
|
44
|
-
while (document.body.firstChild) {
|
|
45
|
-
document.body.removeChild(document.body.firstChild);
|
|
46
|
-
}
|
|
47
|
-
jest.clearAllMocks();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
beforeEach(() => {
|
|
51
|
-
console.error = jest.fn();
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
global.Bueno = {
|
|
54
|
-
isString: jest
|
|
55
|
-
.fn()
|
|
56
|
-
.mockImplementation(
|
|
57
|
-
(value) => Object.prototype.toString.call(value) === '[object String]'
|
|
58
|
-
),
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
afterEach(() => {
|
|
63
|
-
cleanup();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe('when no result is given', () => {
|
|
67
|
-
it('should show an error', async () => {
|
|
68
|
-
// @ts-ignore
|
|
69
|
-
const element = createTestComponent({field: exampleField});
|
|
70
|
-
await flushPromises();
|
|
71
|
-
|
|
72
|
-
const errorMessage = element.shadowRoot.querySelector(errorSelector);
|
|
73
|
-
|
|
74
|
-
expect(errorMessage).not.toBeNull();
|
|
75
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
76
|
-
'The c-quantic-result-text requires a result and a field to be specified.'
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe('when no field is given', () => {
|
|
82
|
-
it('should show an error', async () => {
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
const element = createTestComponent({result: exampleResult});
|
|
85
|
-
await flushPromises();
|
|
86
|
-
|
|
87
|
-
const errorMessage = element.shadowRoot.querySelector(errorSelector);
|
|
88
|
-
|
|
89
|
-
expect(errorMessage).not.toBeNull();
|
|
90
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
91
|
-
'The c-quantic-result-text requires a result and a field to be specified.'
|
|
92
|
-
);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
describe('when field is given as am empty string', () => {
|
|
97
|
-
it('should show an error', async () => {
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
const element = createTestComponent({...defaultOptions, field: ''});
|
|
100
|
-
await flushPromises();
|
|
101
|
-
|
|
102
|
-
const errorMessage = element.shadowRoot.querySelector(errorSelector);
|
|
103
|
-
|
|
104
|
-
expect(errorMessage).not.toBeNull();
|
|
105
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
106
|
-
'The c-quantic-result-text requires a result and a field to be specified.'
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('when required props are given', () => {
|
|
112
|
-
it('should render the result field value', async () => {
|
|
113
|
-
const element = createTestComponent();
|
|
114
|
-
await flushPromises();
|
|
115
|
-
|
|
116
|
-
const fieldValueElement = element.shadowRoot.querySelector(valueSelector);
|
|
117
|
-
|
|
118
|
-
expect(fieldValueElement.textContent).toBe(exampleFieldValue);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('when a label is given', () => {
|
|
123
|
-
it('should render the field value with a label', async () => {
|
|
124
|
-
const element = createTestComponent({
|
|
125
|
-
...defaultOptions,
|
|
126
|
-
label: exampleLabel,
|
|
127
|
-
});
|
|
128
|
-
await flushPromises();
|
|
129
|
-
|
|
130
|
-
const labelElement = element.shadowRoot.querySelector(labelSelector);
|
|
131
|
-
const fieldValueElement = element.shadowRoot.querySelector(valueSelector);
|
|
132
|
-
|
|
133
|
-
expect(labelElement.textContent).toBe(`${exampleLabel}:`);
|
|
134
|
-
expect(fieldValueElement.textContent).toBe(exampleFieldValue);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
describe('when a formatting function is given', () => {
|
|
139
|
-
const exampleFormattingFunction = (value) => `formatted ${value}`;
|
|
140
|
-
|
|
141
|
-
it('should render the formatted field value', async () => {
|
|
142
|
-
const element = createTestComponent({
|
|
143
|
-
...defaultOptions,
|
|
144
|
-
formattingFunction: exampleFormattingFunction,
|
|
145
|
-
});
|
|
146
|
-
await flushPromises();
|
|
147
|
-
|
|
148
|
-
const fieldValueElement = element.shadowRoot.querySelector(valueSelector);
|
|
149
|
-
|
|
150
|
-
expect(fieldValueElement.textContent).toBe(
|
|
151
|
-
exampleFormattingFunction(exampleFieldValue)
|
|
152
|
-
);
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
});
|
package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-import-assign */
|
|
2
|
-
import QuanticResultsPerPage from 'c/quanticResultsPerPage';
|
|
3
|
-
import {createElement} from 'lwc';
|
|
4
|
-
import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
|
|
5
|
-
|
|
6
|
-
const initialResultsPerPageState = {numberOfResults: 10};
|
|
7
|
-
let resultsPerPageState = initialResultsPerPageState;
|
|
8
|
-
|
|
9
|
-
const initialSearchStatusState = {hasResults: true};
|
|
10
|
-
let searchStatusState = initialSearchStatusState;
|
|
11
|
-
|
|
12
|
-
const initialStoreState = {};
|
|
13
|
-
let storeState = initialStoreState;
|
|
14
|
-
|
|
15
|
-
const functionsMocks = {
|
|
16
|
-
buildResultsPerPage: jest.fn(() => ({
|
|
17
|
-
state: resultsPerPageState,
|
|
18
|
-
subscribe: functionsMocks.resultsPerPageStateSubscriber,
|
|
19
|
-
set: functionsMocks.set,
|
|
20
|
-
})),
|
|
21
|
-
resultsPerPageStateSubscriber: jest.fn((cb) => {
|
|
22
|
-
cb();
|
|
23
|
-
return functionsMocks.resultsPerPageStateUnsubscriber;
|
|
24
|
-
}),
|
|
25
|
-
resultsPerPageStateUnsubscriber: jest.fn(),
|
|
26
|
-
buildSearchStatus: jest.fn(() => ({
|
|
27
|
-
state: searchStatusState,
|
|
28
|
-
subscribe: functionsMocks.searchStatusStateSubscriber,
|
|
29
|
-
})),
|
|
30
|
-
searchStatusStateSubscriber: jest.fn((cb) => {
|
|
31
|
-
cb();
|
|
32
|
-
return functionsMocks.searchStatusStateUnsubscriber;
|
|
33
|
-
}),
|
|
34
|
-
searchStatusStateUnsubscriber: jest.fn(),
|
|
35
|
-
set: jest.fn(),
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const selectors = {
|
|
39
|
-
componentError: 'c-quantic-component-error',
|
|
40
|
-
resultsPerPage: '[data-testid="results-per-page"]',
|
|
41
|
-
resultsPerPageOption: 'c-quantic-number-button',
|
|
42
|
-
selectedResultsPerPageOption:
|
|
43
|
-
'c-quantic-number-button button.slds-button_brand',
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const exampleEngine = {
|
|
47
|
-
id: 'exampleEngine',
|
|
48
|
-
};
|
|
49
|
-
let isInitialized = false;
|
|
50
|
-
|
|
51
|
-
function createTestComponent(options = {}) {
|
|
52
|
-
const element = createElement('c-quantic-results-per-page', {
|
|
53
|
-
is: QuanticResultsPerPage,
|
|
54
|
-
});
|
|
55
|
-
Object.assign(element, options);
|
|
56
|
-
document.body.appendChild(element);
|
|
57
|
-
return element;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function prepareHeadlessState() {
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
mockHeadlessLoader.getHeadlessBundle = () => {
|
|
63
|
-
return {
|
|
64
|
-
buildResultsPerPage: functionsMocks.buildResultsPerPage,
|
|
65
|
-
buildSearchStatus: functionsMocks.buildSearchStatus,
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function mockStoreState() {
|
|
71
|
-
// @ts-ignore
|
|
72
|
-
mockHeadlessLoader.getFromStore = () => {
|
|
73
|
-
return storeState;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Helper function to wait until the microtask queue is empty.
|
|
78
|
-
function flushPromises() {
|
|
79
|
-
// eslint-disable-next-line @lwc/lwc/no-async-operation
|
|
80
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function mockSuccessfulHeadlessInitialization() {
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
86
|
-
if (element instanceof QuanticResultsPerPage && !isInitialized) {
|
|
87
|
-
isInitialized = true;
|
|
88
|
-
initialize(exampleEngine);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function mockErroneousHeadlessInitialization() {
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
mockHeadlessLoader.initializeWithHeadless = (element) => {
|
|
96
|
-
if (element instanceof QuanticResultsPerPage) {
|
|
97
|
-
element.setInitializationError();
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function cleanup() {
|
|
103
|
-
// The jsdom instance is shared across test cases in a single file so reset the DOM
|
|
104
|
-
while (document.body.firstChild) {
|
|
105
|
-
document.body.removeChild(document.body.firstChild);
|
|
106
|
-
}
|
|
107
|
-
jest.clearAllMocks();
|
|
108
|
-
isInitialized = false;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
describe('c-quantic-results-per-page', () => {
|
|
112
|
-
const defaultInitialChoice = 10;
|
|
113
|
-
const defaultChoices = [10, 25, 50, 100];
|
|
114
|
-
|
|
115
|
-
beforeEach(() => {
|
|
116
|
-
mockSuccessfulHeadlessInitialization();
|
|
117
|
-
prepareHeadlessState();
|
|
118
|
-
mockStoreState();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
afterEach(() => {
|
|
122
|
-
resultsPerPageState = initialResultsPerPageState;
|
|
123
|
-
storeState = initialStoreState;
|
|
124
|
-
cleanup();
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe('when an initialization error occurs', () => {
|
|
128
|
-
beforeEach(() => {
|
|
129
|
-
mockErroneousHeadlessInitialization();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('should display the initialization error component', async () => {
|
|
133
|
-
const element = createTestComponent();
|
|
134
|
-
await flushPromises();
|
|
135
|
-
|
|
136
|
-
const initializationError = element.shadowRoot.querySelector(
|
|
137
|
-
selectors.componentError
|
|
138
|
-
);
|
|
139
|
-
expect(initializationError).not.toBeNull();
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
describe('controller initialization', () => {
|
|
144
|
-
beforeEach(() => {
|
|
145
|
-
mockSuccessfulHeadlessInitialization();
|
|
146
|
-
prepareHeadlessState();
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('should build the results per page and search status controllers and subscribe to state', async () => {
|
|
150
|
-
createTestComponent();
|
|
151
|
-
await flushPromises();
|
|
152
|
-
|
|
153
|
-
expect(functionsMocks.buildResultsPerPage).toHaveBeenCalledTimes(1);
|
|
154
|
-
expect(functionsMocks.buildResultsPerPage).toHaveBeenCalledWith(
|
|
155
|
-
exampleEngine,
|
|
156
|
-
{
|
|
157
|
-
initialState: {
|
|
158
|
-
numberOfResults: 10,
|
|
159
|
-
},
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
expect(functionsMocks.buildSearchStatus).toHaveBeenCalledTimes(1);
|
|
163
|
-
expect(functionsMocks.buildSearchStatus).toHaveBeenCalledWith(
|
|
164
|
-
exampleEngine
|
|
165
|
-
);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
describe('with default options', () => {
|
|
170
|
-
it('should properly render with the default choice selected', async () => {
|
|
171
|
-
const element = createTestComponent();
|
|
172
|
-
await flushPromises();
|
|
173
|
-
|
|
174
|
-
const resultsPerPage = element.shadowRoot.querySelector(
|
|
175
|
-
selectors.resultsPerPage
|
|
176
|
-
);
|
|
177
|
-
expect(resultsPerPage).not.toBeNull();
|
|
178
|
-
|
|
179
|
-
const resultsPerPageOptions = Array.from(
|
|
180
|
-
element.shadowRoot.querySelectorAll(selectors.resultsPerPageOption)
|
|
181
|
-
);
|
|
182
|
-
expect(resultsPerPageOptions).toHaveLength(defaultChoices.length);
|
|
183
|
-
|
|
184
|
-
resultsPerPageOptions.forEach((option, index) => {
|
|
185
|
-
expect(option.number).toEqual(defaultChoices[index]);
|
|
186
|
-
expect(option.selected).toBe(
|
|
187
|
-
defaultChoices[index] === defaultInitialChoice
|
|
188
|
-
);
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('should update the state when the results per page is clicked', async () => {
|
|
193
|
-
const element = createTestComponent();
|
|
194
|
-
await flushPromises();
|
|
195
|
-
|
|
196
|
-
const resultsPerPage = element.shadowRoot.querySelector(
|
|
197
|
-
selectors.resultsPerPage
|
|
198
|
-
);
|
|
199
|
-
expect(resultsPerPage).not.toBeNull();
|
|
200
|
-
|
|
201
|
-
const resultsPerPageOptions = Array.from(
|
|
202
|
-
element.shadowRoot.querySelectorAll(selectors.resultsPerPageOption)
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
resultsPerPageOptions[1].dispatchEvent(
|
|
206
|
-
new CustomEvent('quantic__select', {
|
|
207
|
-
detail: defaultChoices[1],
|
|
208
|
-
})
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
expect(functionsMocks.set).toHaveBeenCalledTimes(1);
|
|
212
|
-
expect(functionsMocks.set).toHaveBeenCalledWith(defaultChoices[1]);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
describe('the numberOfResults headless state', () => {
|
|
216
|
-
const expectedValueSelected = 100;
|
|
217
|
-
beforeEach(() => {
|
|
218
|
-
resultsPerPageState = {
|
|
219
|
-
...resultsPerPageState,
|
|
220
|
-
numberOfResults: expectedValueSelected,
|
|
221
|
-
};
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test('should reflect the headless state and select the right option', async () => {
|
|
225
|
-
const element = createTestComponent();
|
|
226
|
-
await flushPromises();
|
|
227
|
-
|
|
228
|
-
const resultsPerPage = element.shadowRoot.querySelector(
|
|
229
|
-
selectors.resultsPerPage
|
|
230
|
-
);
|
|
231
|
-
expect(resultsPerPage).not.toBeNull();
|
|
232
|
-
|
|
233
|
-
const resultsPerPageOptions = Array.from(
|
|
234
|
-
element.shadowRoot.querySelectorAll(selectors.resultsPerPageOption)
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
resultsPerPageOptions.forEach((option) => {
|
|
238
|
-
expect(option.selected).toBe(expectedValueSelected === option.number);
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
describe('with a custom #choicesDisplayed option', () => {
|
|
245
|
-
beforeEach(() => {
|
|
246
|
-
console.error = jest.fn();
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it('should properly render with the choices displayed', async () => {
|
|
250
|
-
const customChoices = [100, 250, 500];
|
|
251
|
-
const element = createTestComponent({
|
|
252
|
-
choicesDisplayed: customChoices.join(','),
|
|
253
|
-
});
|
|
254
|
-
await flushPromises();
|
|
255
|
-
|
|
256
|
-
expect(functionsMocks.buildResultsPerPage).toHaveBeenCalledTimes(1);
|
|
257
|
-
expect(functionsMocks.buildResultsPerPage).toHaveBeenCalledWith(
|
|
258
|
-
exampleEngine,
|
|
259
|
-
{
|
|
260
|
-
initialState: {
|
|
261
|
-
numberOfResults: customChoices[0],
|
|
262
|
-
},
|
|
263
|
-
}
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
const resultsPerPage = element.shadowRoot.querySelector(
|
|
267
|
-
selectors.resultsPerPage
|
|
268
|
-
);
|
|
269
|
-
expect(resultsPerPage).not.toBeNull();
|
|
270
|
-
|
|
271
|
-
const resultsPerPageOptions = Array.from(
|
|
272
|
-
element.shadowRoot.querySelectorAll(selectors.resultsPerPageOption)
|
|
273
|
-
);
|
|
274
|
-
expect(resultsPerPageOptions).toHaveLength(customChoices.length);
|
|
275
|
-
|
|
276
|
-
resultsPerPageOptions.forEach((option, index) => {
|
|
277
|
-
expect(option.number).toEqual(customChoices[index]);
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it('should log an error if the choices displayed are not numbers', async () => {
|
|
282
|
-
const customChoices = ['foo', 'bar', 'baz'];
|
|
283
|
-
const element = createTestComponent({
|
|
284
|
-
choicesDisplayed: customChoices.join(','),
|
|
285
|
-
});
|
|
286
|
-
await flushPromises();
|
|
287
|
-
|
|
288
|
-
const initializationError = element.shadowRoot.querySelector(
|
|
289
|
-
selectors.componentError
|
|
290
|
-
);
|
|
291
|
-
expect(initializationError).not.toBeNull();
|
|
292
|
-
|
|
293
|
-
expect(console.error).toHaveBeenCalledTimes(customChoices.length);
|
|
294
|
-
customChoices.forEach((choice, index) => {
|
|
295
|
-
expect(console.error).toHaveBeenNthCalledWith(
|
|
296
|
-
index + 1,
|
|
297
|
-
`The choice value "${choice}" from the "choicesDisplayed" option is not a number.`
|
|
298
|
-
);
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
describe('with a custom #initialChoice option', () => {
|
|
304
|
-
const customInitialChoiceIndex = 2;
|
|
305
|
-
const customInitialChoice = defaultChoices[customInitialChoiceIndex];
|
|
306
|
-
|
|
307
|
-
beforeEach(() => {
|
|
308
|
-
console.error = jest.fn();
|
|
309
|
-
resultsPerPageState = {
|
|
310
|
-
...resultsPerPageState,
|
|
311
|
-
numberOfResults: customInitialChoice,
|
|
312
|
-
};
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it('should properly render with the initial choice selected', async () => {
|
|
316
|
-
const element = createTestComponent({
|
|
317
|
-
initialChoice: customInitialChoice,
|
|
318
|
-
});
|
|
319
|
-
await flushPromises();
|
|
320
|
-
|
|
321
|
-
expect(functionsMocks.buildResultsPerPage).toHaveBeenCalledTimes(1);
|
|
322
|
-
expect(functionsMocks.buildResultsPerPage).toHaveBeenCalledWith(
|
|
323
|
-
exampleEngine,
|
|
324
|
-
{
|
|
325
|
-
initialState: {
|
|
326
|
-
numberOfResults: customInitialChoice,
|
|
327
|
-
},
|
|
328
|
-
}
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
const resultsPerPageOptions = Array.from(
|
|
332
|
-
element.shadowRoot.querySelectorAll(selectors.resultsPerPageOption)
|
|
333
|
-
);
|
|
334
|
-
expect(resultsPerPageOptions).toHaveLength(defaultChoices.length);
|
|
335
|
-
|
|
336
|
-
resultsPerPageOptions.forEach((option, index) => {
|
|
337
|
-
expect(option.selected).toBe(index === customInitialChoiceIndex);
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
it('should log an error if the initial choice is not included in the choices displayed but not display it to users', async () => {
|
|
341
|
-
const customInvalidInitialChoice = 123;
|
|
342
|
-
const element = createTestComponent({
|
|
343
|
-
initialChoice: customInvalidInitialChoice,
|
|
344
|
-
});
|
|
345
|
-
await flushPromises();
|
|
346
|
-
|
|
347
|
-
expect(functionsMocks.buildResultsPerPage).toHaveBeenCalledTimes(1);
|
|
348
|
-
expect(functionsMocks.buildResultsPerPage).toHaveBeenCalledWith(
|
|
349
|
-
exampleEngine,
|
|
350
|
-
{
|
|
351
|
-
initialState: {
|
|
352
|
-
numberOfResults: defaultChoices[0],
|
|
353
|
-
},
|
|
354
|
-
}
|
|
355
|
-
);
|
|
356
|
-
|
|
357
|
-
const initializationError = element.shadowRoot.querySelector(
|
|
358
|
-
selectors.componentError
|
|
359
|
-
);
|
|
360
|
-
expect(initializationError).toBeNull();
|
|
361
|
-
|
|
362
|
-
expect(console.error).toHaveBeenCalledTimes(1);
|
|
363
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
364
|
-
`The "initialChoice" option value "${customInvalidInitialChoice}" is not included in the "choicesDisplayed" option "${defaultChoices}". Defaulting to the first value of the choices.`
|
|
365
|
-
);
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
describe('when you omit the #initialChoice option', () => {
|
|
370
|
-
const mockNumberOfResults = 100;
|
|
371
|
-
|
|
372
|
-
beforeEach(() => {
|
|
373
|
-
resultsPerPageState = {
|
|
374
|
-
...resultsPerPageState,
|
|
375
|
-
numberOfResults: mockNumberOfResults,
|
|
376
|
-
};
|
|
377
|
-
});
|
|
378
|
-
it('should default to the first choice', async () => {
|
|
379
|
-
const customChoices = [100, 250, 500];
|
|
380
|
-
const element = createTestComponent({
|
|
381
|
-
choicesDisplayed: customChoices.join(','),
|
|
382
|
-
});
|
|
383
|
-
await flushPromises();
|
|
384
|
-
|
|
385
|
-
expect(functionsMocks.buildResultsPerPage).toHaveBeenCalledTimes(1);
|
|
386
|
-
expect(functionsMocks.buildResultsPerPage).toHaveBeenCalledWith(
|
|
387
|
-
exampleEngine,
|
|
388
|
-
{
|
|
389
|
-
initialState: {
|
|
390
|
-
numberOfResults: customChoices[0],
|
|
391
|
-
},
|
|
392
|
-
}
|
|
393
|
-
);
|
|
394
|
-
|
|
395
|
-
const resultsPerPageOptions = Array.from(
|
|
396
|
-
element.shadowRoot.querySelectorAll(selectors.resultsPerPageOption)
|
|
397
|
-
);
|
|
398
|
-
expect(resultsPerPageOptions).toHaveLength(customChoices.length);
|
|
399
|
-
resultsPerPageOptions.forEach((option, index) => {
|
|
400
|
-
expect(option.selected).toBe(index === 0);
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
});
|
|
404
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {ResultsPerPageObject} from './pageObject';
|
|
2
|
-
import {quanticBase} from '../../../../../../playwright/fixtures/baseFixture';
|
|
3
|
-
import {SearchObject} from '../../../../../../playwright/page-object/searchObject';
|
|
4
|
-
import {
|
|
5
|
-
searchRequestRegex,
|
|
6
|
-
insightSearchRequestRegex,
|
|
7
|
-
} from '../../../../../../playwright/utils/requests';
|
|
8
|
-
import {InsightSetupObject} from '../../../../../../playwright/page-object/insightSetupObject';
|
|
9
|
-
import {useCaseEnum} from '../../../../../../playwright/utils/useCase';
|
|
10
|
-
|
|
11
|
-
const resultsPerPageUrl = 's/quantic-results-per-page';
|
|
12
|
-
|
|
13
|
-
interface ResultsPerPageOptions {
|
|
14
|
-
initialChoice: number;
|
|
15
|
-
choicesDisplayed: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type QuanticResultsPerPageE2EFixtures = {
|
|
19
|
-
resultsPerPage: ResultsPerPageObject;
|
|
20
|
-
search: SearchObject;
|
|
21
|
-
options: Partial<ResultsPerPageOptions>;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type QuanticResultsPerPageE2ESearchFixtures =
|
|
25
|
-
QuanticResultsPerPageE2EFixtures & {
|
|
26
|
-
urlHash: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
type QuanticResultsPerPageE2EInsightFixtures =
|
|
30
|
-
QuanticResultsPerPageE2ESearchFixtures & {
|
|
31
|
-
insightSetup: InsightSetupObject;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const testSearch =
|
|
35
|
-
quanticBase.extend<QuanticResultsPerPageE2ESearchFixtures>({
|
|
36
|
-
options: {},
|
|
37
|
-
urlHash: '',
|
|
38
|
-
search: async ({page}, use) => {
|
|
39
|
-
await use(new SearchObject(page, searchRequestRegex));
|
|
40
|
-
},
|
|
41
|
-
resultsPerPage: async (
|
|
42
|
-
{page, options, configuration, search, urlHash},
|
|
43
|
-
use
|
|
44
|
-
) => {
|
|
45
|
-
await page.goto(
|
|
46
|
-
urlHash ? `${resultsPerPageUrl}#${urlHash}` : resultsPerPageUrl
|
|
47
|
-
);
|
|
48
|
-
configuration.configure(options);
|
|
49
|
-
await search.waitForSearchResponse();
|
|
50
|
-
await use(new ResultsPerPageObject(page));
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
export const testInsight =
|
|
55
|
-
quanticBase.extend<QuanticResultsPerPageE2EInsightFixtures>({
|
|
56
|
-
options: {},
|
|
57
|
-
search: async ({page}, use) => {
|
|
58
|
-
await use(new SearchObject(page, insightSearchRequestRegex));
|
|
59
|
-
},
|
|
60
|
-
insightSetup: async ({page}, use) => {
|
|
61
|
-
await use(new InsightSetupObject(page));
|
|
62
|
-
},
|
|
63
|
-
resultsPerPage: async (
|
|
64
|
-
{page, options, search, configuration, insightSetup},
|
|
65
|
-
use
|
|
66
|
-
) => {
|
|
67
|
-
await page.goto(resultsPerPageUrl);
|
|
68
|
-
configuration.configure({...options, useCase: useCaseEnum.insight});
|
|
69
|
-
await insightSetup.waitForInsightInterfaceInitialization();
|
|
70
|
-
await search.performSearch();
|
|
71
|
-
await search.waitForSearchResponse();
|
|
72
|
-
await use(new ResultsPerPageObject(page));
|
|
73
|
-
},
|
|
74
|
-
});
|