@coveo/quantic 3.16.0 → 3.16.1-pre.9c01cf606f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +2 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/recent-queries-list/headless-recent-queries-list.d.ts +5 -0
- package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -10
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +2 -2
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +2 -2
- package/package.json +5 -3
- package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +0 -604
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/fixture.ts +0 -76
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/pageObject.ts +0 -282
- package/force-app/main/default/lwc/quanticBreadcrumbManager/e2e/quanticBreadcrumbManager.e2e.ts +0 -167
- package/force-app/main/default/lwc/quanticCarousel/__tests__/quanticCarousel.test.js +0 -262
- package/force-app/main/default/lwc/quanticCaseClassification/__tests__/quanticCaseClassification.test.js +0 -819
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/data.ts +0 -23
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/fixture.ts +0 -51
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/pageObject.ts +0 -152
- package/force-app/main/default/lwc/quanticCaseClassification/e2e/quanticCaseClassification.e2e.ts +0 -269
- package/force-app/main/default/lwc/quanticCategoryFacet/__tests__/quanticCategoryFacet.test.js +0 -327
- package/force-app/main/default/lwc/quanticCitation/__tests__/quanticCitation.test.js +0 -269
- package/force-app/main/default/lwc/quanticColoredResultBadge/__tests__/quanticColoredResultBadge.test.js +0 -212
- package/force-app/main/default/lwc/quanticDateFacet/__tests__/quanticDateFacet.test.js +0 -321
- package/force-app/main/default/lwc/quanticDidYouMean/__tests__/quanticDidYouMean.test.js +0 -199
- package/force-app/main/default/lwc/quanticFacet/__tests__/quanticFacet.test.js +0 -341
- package/force-app/main/default/lwc/quanticFacetCaption/__tests__/quanticFacetCaption.test.js +0 -28
- package/force-app/main/default/lwc/quanticFacetManager/__tests__/quanticFacetManager.test.js +0 -178
- package/force-app/main/default/lwc/quanticFacetManager/e2e/fixture.ts +0 -63
- package/force-app/main/default/lwc/quanticFacetManager/e2e/pageObject.ts +0 -23
- package/force-app/main/default/lwc/quanticFacetManager/e2e/quanticFacetManager.e2e.ts +0 -82
- package/force-app/main/default/lwc/quanticFeedback/__tests__/quanticFeedback.test.js +0 -392
- package/force-app/main/default/lwc/quanticFeedbackModal/__tests__/quanticFeedbackModal.test.js +0 -448
- package/force-app/main/default/lwc/quanticFeedbackModalQna/__tests__/quanticFeedbackModalQna.test.js +0 -298
- package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +0 -814
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +0 -56
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +0 -87
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +0 -283
- package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +0 -199
- package/force-app/main/default/lwc/quanticGeneratedAnswerContent/__tests__/quanticGeneratedAnswerContent.test.js +0 -151
- package/force-app/main/default/lwc/quanticHeading/__tests__/quanticHeading.test.js +0 -71
- package/force-app/main/default/lwc/quanticHeadlessLoader/__tests__/quanticHeadlessLoader.test.js +0 -651
- package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +0 -335
- package/force-app/main/default/lwc/quanticNumericFacet/__tests__/quanticNumericFacet.test.js +0 -343
- package/force-app/main/default/lwc/quanticPager/e2e/fixture.ts +0 -63
- package/force-app/main/default/lwc/quanticPager/e2e/pageObject.ts +0 -69
- package/force-app/main/default/lwc/quanticPager/e2e/quanticPager.e2e.ts +0 -101
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/defaultTestCase.json +0 -13
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/data/youtubeTestCase.json +0 -14
- package/force-app/main/default/lwc/quanticQuickviewContent/__tests__/quanticQuickviewContent.test.js +0 -82
- package/force-app/main/default/lwc/quanticRadioButtonsGroup/__tests__/quanticRadioButtonsGroup.test.js +0 -273
- package/force-app/main/default/lwc/quanticRefineModalContent/__tests__/quanticRefineModalContent.test.js +0 -501
- package/force-app/main/default/lwc/quanticResultAction/__tests__/quanticResultAction.test.js +0 -262
- package/force-app/main/default/lwc/quanticResultActionBar/__tests__/quanticResultActionBar.test.js +0 -141
- package/force-app/main/default/lwc/quanticResultChildren/__tests__/quanticResultChildren.test.js +0 -340
- package/force-app/main/default/lwc/quanticResultDate/__tests__/quanticResultDate.test.js +0 -144
- package/force-app/main/default/lwc/quanticResultField/__tests__/quanticResultField.test.js +0 -120
- package/force-app/main/default/lwc/quanticResultHighlightedTextField/__tests__/quanticResultHighlightedTextField.test.js +0 -209
- package/force-app/main/default/lwc/quanticResultLink/__tests__/quanticResultLink.test.js +0 -261
- package/force-app/main/default/lwc/quanticResultMultiValueText/__tests__/quanticResultMultiValueText.test.js +0 -235
- package/force-app/main/default/lwc/quanticResultNumber/__tests__/quanticResultNumber.test.js +0 -144
- package/force-app/main/default/lwc/quanticResultPrintableUri/__tests__/quanticResultPrintableUri.test.js +0 -324
- package/force-app/main/default/lwc/quanticResultQuickview/__tests__/quanticResultQuickview.test.js +0 -171
- package/force-app/main/default/lwc/quanticResultText/__tests__/quanticResultText.test.js +0 -155
- package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js +0 -404
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +0 -74
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/pageObject.ts +0 -85
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/quanticResultsPerPage.e2e.ts +0 -97
- package/force-app/main/default/lwc/quanticSearchBox/__tests__/quanticSearchBox.test.js +0 -168
- package/force-app/main/default/lwc/quanticSearchBoxInput/__tests__/quanticSearchBoxInput.test.js +0 -823
- package/force-app/main/default/lwc/quanticSmartSnippet/__tests__/quanticSmartSnippet.test.js +0 -341
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/data.ts +0 -21
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/fixture.ts +0 -91
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +0 -196
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +0 -168
- package/force-app/main/default/lwc/quanticSmartSnippetAnswer/__tests__/quanticSmartSnippetAnswer.test.js +0 -126
- package/force-app/main/default/lwc/quanticSmartSnippetSource/__tests__/quanticSmartSnippetSource.test.js +0 -290
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/__tests__/quanticSmartSnippetSuggestions.test.js +0 -329
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/data.ts +0 -31
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/fixture.ts +0 -93
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/pageObject.ts +0 -160
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/quanticSmartSnippetSuggestions.e2e.ts +0 -127
- package/force-app/main/default/lwc/quanticSort/__tests__/quanticSort.test.js +0 -416
- package/force-app/main/default/lwc/quanticSort/e2e/fixture.ts +0 -61
- package/force-app/main/default/lwc/quanticSort/e2e/pageObject.ts +0 -89
- package/force-app/main/default/lwc/quanticSort/e2e/quanticSort.e2e.ts +0 -91
- package/force-app/main/default/lwc/quanticSourceCitations/__tests__/quanticSourceCitations.test.js +0 -123
- package/force-app/main/default/lwc/quanticStandaloneSearchBox/__tests__/quanticStandaloneSearchBox.test.js +0 -186
- package/force-app/main/default/lwc/quanticStatefulButton/__tests__/quanticStatefulButton.test.js +0 -222
- package/force-app/main/default/lwc/quanticTab/__tests__/quanticTab.test.js +0 -287
- package/force-app/main/default/lwc/quanticTab/e2e/fixture.ts +0 -62
- package/force-app/main/default/lwc/quanticTab/e2e/pageObject.ts +0 -67
- package/force-app/main/default/lwc/quanticTab/e2e/quanticTab.e2e.ts +0 -77
- package/force-app/main/default/lwc/quanticTabBar/__tests__/quanticTabBar.test.js +0 -331
- package/force-app/main/default/lwc/quanticTabBar/e2e/fixture.ts +0 -61
- package/force-app/main/default/lwc/quanticTabBar/e2e/pageObject.ts +0 -80
- package/force-app/main/default/lwc/quanticTabBar/e2e/quanticTabBar.e2e.ts +0 -173
- package/force-app/main/default/lwc/quanticTimeframeFacet/__tests__/quanticTimeframeFacet.test.js +0 -339
- package/force-app/main/default/lwc/quanticTooltip/__tests__/quanticTooltip.test.js +0 -107
- package/force-app/main/default/lwc/quanticUserAction/__tests__/quanticUserAction.test.js +0 -427
- package/force-app/main/default/lwc/quanticUserActionsSession/__tests__/quanticUserActionsSession.test.js +0 -269
- package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/data/userActionsState.json +0 -89
- package/force-app/main/default/lwc/quanticUserActionsTimeline/__tests__/quanticUserActionsTimeline.test.js +0 -511
- package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +0 -229
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +0 -32
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +0 -32
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +0 -71
- package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +0 -39
- package/force-app/main/default/lwc/quanticUtils/__tests__/facetDependenciesUtils.test.js +0 -92
- package/force-app/main/default/lwc/quanticUtils/__tests__/markdownUtils.test.js +0 -71
- package/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js +0 -223
- package/force-app/main/default/lwc/quanticViewedByCustomerBadge/__tests__/quanticViewedByCustomerBadge.test.js +0 -131
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type {Locator, Page, Request} from '@playwright/test';
|
|
2
|
-
import {isUaCustomEvent} from '../../../../../../playwright/utils/requests';
|
|
3
|
-
|
|
4
|
-
const resultsPerPageElementsSelectors = {
|
|
5
|
-
component: 'c-quantic-results-per-page',
|
|
6
|
-
componentError: 'c-quantic-component-error',
|
|
7
|
-
resultsPerPageTestId: 'results-per-page',
|
|
8
|
-
resultsPerPageOptionButton: 'c-quantic-number-button',
|
|
9
|
-
selectedResultsPerPageOptionButton: 'button.slds-button_brand',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export class ResultsPerPageObject {
|
|
13
|
-
constructor(public page: Page) {
|
|
14
|
-
this.page = page;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
get component(): Locator {
|
|
18
|
-
return this.page.getByTestId(
|
|
19
|
-
resultsPerPageElementsSelectors.resultsPerPageTestId
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get allResultsPerPageOptionsButtons(): Locator {
|
|
24
|
-
return this.component.locator(
|
|
25
|
-
resultsPerPageElementsSelectors.resultsPerPageOptionButton
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get selectedResultsPerPageOption(): Locator {
|
|
30
|
-
return this.allResultsPerPageOptionsButtons.filter({
|
|
31
|
-
has: this.page.locator(
|
|
32
|
-
resultsPerPageElementsSelectors.selectedResultsPerPageOptionButton
|
|
33
|
-
),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
getResultPerPageOptionByValue(value: number): Locator {
|
|
38
|
-
return this.allResultsPerPageOptionsButtons.getByText(value.toString());
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async clickResultsPerPageOptionByValue(value: number): Promise<void> {
|
|
42
|
-
await this.getResultPerPageOptionByValue(value).click();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async waitForResultsPerPageClickUA(
|
|
46
|
-
customChecker?: Function
|
|
47
|
-
): Promise<Request> {
|
|
48
|
-
const uaRequest = this.page.waitForRequest((request) => {
|
|
49
|
-
if (isUaCustomEvent(request)) {
|
|
50
|
-
const requestBody = request.postDataJSON?.();
|
|
51
|
-
const {customData} = requestBody;
|
|
52
|
-
|
|
53
|
-
const expectedFields = {
|
|
54
|
-
eventType: 'getMoreResults',
|
|
55
|
-
eventValue: 'pagerResize',
|
|
56
|
-
};
|
|
57
|
-
const matchesExpectedFields = Object.keys(expectedFields).every(
|
|
58
|
-
(key) => requestBody?.[key] === expectedFields[key]
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
matchesExpectedFields &&
|
|
63
|
-
(customChecker ? customChecker(customData) : true)
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
return false;
|
|
67
|
-
});
|
|
68
|
-
return uaRequest;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async waitForResultsPerPageUA(
|
|
72
|
-
expectedCustomFields: Record<string, any>
|
|
73
|
-
): Promise<Request> {
|
|
74
|
-
return this.waitForResultsPerPageClickUA(
|
|
75
|
-
(customData: Record<string, any>) => {
|
|
76
|
-
return Object.keys(expectedCustomFields).every((key) =>
|
|
77
|
-
typeof expectedCustomFields[key] === 'object'
|
|
78
|
-
? JSON.stringify(customData?.[key]) ===
|
|
79
|
-
JSON.stringify(expectedCustomFields[key])
|
|
80
|
-
: customData?.[key] === expectedCustomFields[key]
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import {testSearch, testInsight} from './fixture';
|
|
2
|
-
import {
|
|
3
|
-
useCaseEnum,
|
|
4
|
-
useCaseTestCases,
|
|
5
|
-
} from '../../../../../../playwright/utils/useCase';
|
|
6
|
-
|
|
7
|
-
const fixtures = {
|
|
8
|
-
search: testSearch,
|
|
9
|
-
insight: testInsight,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const defaultChoices = [10, 25, 50, 100];
|
|
13
|
-
const defaultInitialChoice = 10;
|
|
14
|
-
|
|
15
|
-
useCaseTestCases.forEach((useCase) => {
|
|
16
|
-
let test = fixtures[useCase.value];
|
|
17
|
-
|
|
18
|
-
test.describe(`quantic results per page ${useCase.label}`, () => {
|
|
19
|
-
test.describe('with default options', () => {
|
|
20
|
-
test('should load as expected', async ({resultsPerPage}) => {
|
|
21
|
-
await test.expect(resultsPerPage.component).toBeVisible();
|
|
22
|
-
test
|
|
23
|
-
.expect(await resultsPerPage.allResultsPerPageOptionsButtons.count())
|
|
24
|
-
.toBe(defaultChoices.length);
|
|
25
|
-
test
|
|
26
|
-
.expect(resultsPerPage.selectedResultsPerPageOption)
|
|
27
|
-
.toHaveText(defaultInitialChoice.toString());
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test.describe('when selecting a new results per page option', () => {
|
|
31
|
-
test('should trigger a new search and log analytics', async ({
|
|
32
|
-
resultsPerPage,
|
|
33
|
-
search,
|
|
34
|
-
}) => {
|
|
35
|
-
const newChoice = 25;
|
|
36
|
-
|
|
37
|
-
const searchResponsePromise = search.waitForSearchResponse();
|
|
38
|
-
const resultsPerPageAnalyticsPromise =
|
|
39
|
-
resultsPerPage.waitForResultsPerPageUA({
|
|
40
|
-
currentResultsPerPage: newChoice,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
await resultsPerPage.clickResultsPerPageOptionByValue(newChoice);
|
|
44
|
-
|
|
45
|
-
const searchResponse = await searchResponsePromise;
|
|
46
|
-
await resultsPerPageAnalyticsPromise;
|
|
47
|
-
|
|
48
|
-
test
|
|
49
|
-
.expect(resultsPerPage.selectedResultsPerPageOption)
|
|
50
|
-
.toHaveText(newChoice.toString());
|
|
51
|
-
test
|
|
52
|
-
.expect(searchResponse.request().postDataJSON()?.numberOfResults)
|
|
53
|
-
.toBe(newChoice);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test.describe('with custom options', () => {
|
|
59
|
-
const customChoices = [20, 40, 80];
|
|
60
|
-
test.use({
|
|
61
|
-
options: {
|
|
62
|
-
choicesDisplayed: customChoices.join(','),
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('should load as expected', async ({resultsPerPage}) => {
|
|
67
|
-
await test.expect(resultsPerPage.component).toBeVisible();
|
|
68
|
-
test
|
|
69
|
-
.expect(await resultsPerPage.allResultsPerPageOptionsButtons.count())
|
|
70
|
-
.toBe(customChoices.length);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
if (useCase.value === useCaseEnum.search) {
|
|
75
|
-
test.describe('when loading from URL hash', () => {
|
|
76
|
-
const expectedResultsPerPage = 50;
|
|
77
|
-
test.use({
|
|
78
|
-
urlHash: `numberOfResults=${expectedResultsPerPage}`,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('should load the right number of results per page', async ({
|
|
82
|
-
resultsPerPage,
|
|
83
|
-
}) => {
|
|
84
|
-
await test.expect(resultsPerPage.component).toBeVisible();
|
|
85
|
-
test
|
|
86
|
-
.expect(
|
|
87
|
-
await resultsPerPage.allResultsPerPageOptionsButtons.count()
|
|
88
|
-
)
|
|
89
|
-
.toBe(defaultChoices.length);
|
|
90
|
-
test
|
|
91
|
-
.expect(resultsPerPage.selectedResultsPerPageOption)
|
|
92
|
-
.toHaveText(expectedResultsPerPage.toString());
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-import-assign */
|
|
2
|
-
import QuanticSearchBox from 'c/quanticSearchBox';
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import {createElement} from 'lwc';
|
|
5
|
-
import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
|
|
6
|
-
|
|
7
|
-
jest.mock('c/quanticHeadlessLoader');
|
|
8
|
-
|
|
9
|
-
let isInitialized = false;
|
|
10
|
-
|
|
11
|
-
const exampleEngine = {
|
|
12
|
-
id: 'dummy engine',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const functionsMocks = {
|
|
16
|
-
buildSearchBox: jest.fn(() => ({
|
|
17
|
-
state: {},
|
|
18
|
-
subscribe: functionsMocks.searchBoxSubscriber,
|
|
19
|
-
})),
|
|
20
|
-
buildRecentQueriesList: jest.fn(() => ({
|
|
21
|
-
state: {},
|
|
22
|
-
subscribe: functionsMocks.recentQueriesSubscriber,
|
|
23
|
-
})),
|
|
24
|
-
|
|
25
|
-
loadQuerySuggestActions: jest.fn(() => {}),
|
|
26
|
-
searchBoxSubscriber: jest.fn((cb) => {
|
|
27
|
-
cb();
|
|
28
|
-
return functionsMocks.unsubscribe;
|
|
29
|
-
}),
|
|
30
|
-
recentQueriesSubscriber: jest.fn((cb) => {
|
|
31
|
-
cb();
|
|
32
|
-
return functionsMocks.unsubscribe;
|
|
33
|
-
}),
|
|
34
|
-
unsubscribe: jest.fn(() => {}),
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const defaultOptions = {
|
|
38
|
-
engineId: exampleEngine.id,
|
|
39
|
-
placeholder: null,
|
|
40
|
-
withoutSubmitButton: false,
|
|
41
|
-
numberOfSuggestions: 7,
|
|
42
|
-
textarea: false,
|
|
43
|
-
disableRecentQueries: false,
|
|
44
|
-
keepFiltersOnSearch: false,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
function createTestComponent(options = defaultOptions) {
|
|
48
|
-
prepareHeadlessState();
|
|
49
|
-
|
|
50
|
-
const element = createElement('c-quantic-search-box', {
|
|
51
|
-
is: QuanticSearchBox,
|
|
52
|
-
});
|
|
53
|
-
for (const [key, value] of Object.entries(options)) {
|
|
54
|
-
element[key] = value;
|
|
55
|
-
}
|
|
56
|
-
document.body.appendChild(element);
|
|
57
|
-
return element;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function prepareHeadlessState() {
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
mockHeadlessLoader.getHeadlessBundle = () => {
|
|
63
|
-
return {
|
|
64
|
-
buildSearchBox: functionsMocks.buildSearchBox,
|
|
65
|
-
buildRecentQueriesList: functionsMocks.buildRecentQueriesList,
|
|
66
|
-
loadQuerySuggestActions: functionsMocks.loadQuerySuggestActions,
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Helper function to wait until the microtask queue is empty.
|
|
72
|
-
function flushPromises() {
|
|
73
|
-
// eslint-disable-next-line @lwc/lwc/no-async-operation
|
|
74
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function mockSuccessfulHeadlessInitialization() {
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
|
|
80
|
-
if (element instanceof QuanticSearchBox && !isInitialized) {
|
|
81
|
-
isInitialized = true;
|
|
82
|
-
initialize(exampleEngine);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function cleanup() {
|
|
88
|
-
// The jsdom instance is shared across test cases in a single file so reset the DOM
|
|
89
|
-
while (document.body.firstChild) {
|
|
90
|
-
document.body.removeChild(document.body.firstChild);
|
|
91
|
-
}
|
|
92
|
-
jest.clearAllMocks();
|
|
93
|
-
isInitialized = false;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
describe('c-quantic-search-box', () => {
|
|
97
|
-
beforeAll(() => {
|
|
98
|
-
mockSuccessfulHeadlessInitialization();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
afterEach(() => {
|
|
102
|
-
cleanup();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
describe('controller initialization', () => {
|
|
106
|
-
it('should subscribe to the headless search box state changes', async () => {
|
|
107
|
-
createTestComponent();
|
|
108
|
-
await flushPromises();
|
|
109
|
-
|
|
110
|
-
expect(functionsMocks.searchBoxSubscriber).toHaveBeenCalledTimes(1);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('should subscribe to the headless recent queries state changes', async () => {
|
|
114
|
-
createTestComponent();
|
|
115
|
-
await flushPromises();
|
|
116
|
-
|
|
117
|
-
expect(functionsMocks.recentQueriesSubscriber).toHaveBeenCalledTimes(1);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('should properly initialize the recent queries controller with the right maxLength value', async () => {
|
|
121
|
-
createTestComponent();
|
|
122
|
-
await flushPromises();
|
|
123
|
-
|
|
124
|
-
expect(functionsMocks.buildRecentQueriesList).toHaveBeenCalledTimes(1);
|
|
125
|
-
expect(functionsMocks.buildRecentQueriesList).toHaveBeenCalledWith(
|
|
126
|
-
exampleEngine,
|
|
127
|
-
expect.objectContaining({
|
|
128
|
-
options: expect.objectContaining({
|
|
129
|
-
maxLength: 20,
|
|
130
|
-
}),
|
|
131
|
-
})
|
|
132
|
-
);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
describe('when keepFiltersOnSearch is false (default)', () => {
|
|
136
|
-
it('should properly initialize the search box controller with clear filters enabled', async () => {
|
|
137
|
-
createTestComponent();
|
|
138
|
-
await flushPromises();
|
|
139
|
-
|
|
140
|
-
expect(functionsMocks.buildSearchBox).toHaveBeenCalledTimes(1);
|
|
141
|
-
expect(functionsMocks.buildSearchBox).toHaveBeenCalledWith(
|
|
142
|
-
exampleEngine,
|
|
143
|
-
expect.objectContaining({
|
|
144
|
-
options: expect.objectContaining({clearFilters: true}),
|
|
145
|
-
})
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
describe('when keepFiltersOnSearch is true', () => {
|
|
151
|
-
it('should properly initialize the search box controller with clear filters disabled', async () => {
|
|
152
|
-
createTestComponent({
|
|
153
|
-
...defaultOptions,
|
|
154
|
-
keepFiltersOnSearch: true,
|
|
155
|
-
});
|
|
156
|
-
await flushPromises();
|
|
157
|
-
|
|
158
|
-
expect(functionsMocks.buildSearchBox).toHaveBeenCalledTimes(1);
|
|
159
|
-
expect(functionsMocks.buildSearchBox).toHaveBeenCalledWith(
|
|
160
|
-
exampleEngine,
|
|
161
|
-
expect.objectContaining({
|
|
162
|
-
options: expect.objectContaining({clearFilters: false}),
|
|
163
|
-
})
|
|
164
|
-
);
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|