@coveo/quantic 3.13.1 → 3.14.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/docs/out/quantic-docs.json +11 -2
- package/force-app/main/default/labels/CustomLabels.labels-meta.xml +2 -2
- package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +6 -12
- package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +113 -6
- package/force-app/main/default/lwc/quanticGeneratedAnswer/quanticGeneratedAnswer.js +32 -5
- package/force-app/main/default/lwc/quanticGeneratedAnswer/templates/generatedAnswer.html +1 -1
- package/force-app/main/default/lwc/quanticResultsPerPage/__tests__/quanticResultsPerPage.test.js +404 -0
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/fixture.ts +74 -0
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/pageObject.ts +85 -0
- package/force-app/main/default/lwc/quanticResultsPerPage/e2e/quanticResultsPerPage.e2e.ts +97 -0
- package/force-app/main/default/lwc/quanticResultsPerPage/quanticResultsPerPage.html +1 -1
- package/force-app/main/default/lwc/quanticResultsPerPage/quanticResultsPerPage.js +44 -9
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/data.ts +2 -11
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/fixture.ts +9 -5
- package/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +1 -1
- package/force-app/main/default/lwc/quanticSmartSnippetAnswer/quanticSmartSnippetAnswer.html +1 -1
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/__tests__/quanticSmartSnippetSuggestions.test.js +329 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/data.ts +31 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/fixture.ts +93 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/pageObject.ts +160 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/e2e/quanticSmartSnippetSuggestions.e2e.ts +127 -0
- package/force-app/main/default/lwc/quanticSmartSnippetSuggestions/quanticSmartSnippetSuggestions.html +2 -1
- package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +6 -6
- package/force-app/main/default/staticresources/coveoheadless/definitions/api/service/insight/get-interface/get-interface-config-response.d.ts +4 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/commerce.index.d.ts +1 -0
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/context/cart/headless-cart.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/context/headless-context.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/pagination/headless-core-commerce-pagination.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/sort/headless-core-commerce-sort.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/summary/headless-core-summary.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/instant-products/headless-instant-products.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/product-list/headless-product-list.ssr.d.ts +1 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/product-view/headless-product-view.ssr.d.ts +0 -1
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recommendations/headless-recommendations.ssr.d.ts +0 -4
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/search/did-you-mean/headless-did-you-mean.ssr.d.ts +1 -3
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/search-box/headless-search-box.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/triggers/headless-notify-trigger.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/triggers/headless-query-trigger.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/triggers/headless-redirection-trigger.ssr.d.ts +0 -2
- package/force-app/main/default/staticresources/coveoheadless/definitions/features/recent-queries/recent-queries-slice.d.ts +4 -2
- package/force-app/main/default/staticresources/coveoheadless/headless.js +8 -8
- package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +7 -7
- package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +6 -6
- package/package.json +10 -10
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type {Locator, Page, Request} from '@playwright/test';
|
|
2
|
+
import {
|
|
3
|
+
isUaCustomEvent,
|
|
4
|
+
isUaClickEvent,
|
|
5
|
+
} from '../../../../../../playwright/utils/requests';
|
|
6
|
+
|
|
7
|
+
export class SmartSnippetSuggestionsObject {
|
|
8
|
+
constructor(public page: Page) {
|
|
9
|
+
this.page = page;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get smartSnippetSuggestions(): Locator {
|
|
13
|
+
return this.page.locator('c-quantic-smart-snippet-suggestions');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get smartSnippetSuggestionHeading(): Locator {
|
|
17
|
+
return this.page.locator(
|
|
18
|
+
'lightning-accordion-section .slds-accordion__summary-heading'
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get smartSnippetSuggestionSourceUri(): Locator {
|
|
23
|
+
return this.page.getByTestId('smart-snippet__source-uri');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get smartSnippetSuggestionSourceTitle(): Locator {
|
|
27
|
+
return this.page.getByTestId('smart-snippet__source-title');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get smartSnippetSuggestionInlineLink(): Locator {
|
|
31
|
+
return this.page.getByTestId('smart-snippet-answer').locator('a');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async clickOnSmartSnippetSuggestionHeading(index: number): Promise<void> {
|
|
35
|
+
await this.smartSnippetSuggestionHeading.nth(index).click();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async clickOnSmartSnippetSuggestionSourceUri(index: number): Promise<void> {
|
|
39
|
+
await this.smartSnippetSuggestionSourceUri.nth(index).click();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async clickOnSmartSnippetSuggestionSourceTitle(index: number): Promise<void> {
|
|
43
|
+
await this.smartSnippetSuggestionSourceTitle.nth(index).click();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async clickOnSmartSnippetSuggestionInlineLink(index: number): Promise<void> {
|
|
47
|
+
await this.smartSnippetSuggestionInlineLink.nth(index).click();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async waitForExpandSmartSnippetSuggestionUaAnalytics(
|
|
51
|
+
expectedFields: Record<string, any>
|
|
52
|
+
): Promise<Request> {
|
|
53
|
+
return this.waitForSmartSnippetSuggestionsCustomUaAnalytics(
|
|
54
|
+
'expandSmartSnippetSuggestion',
|
|
55
|
+
(customData: Record<string, any>) => {
|
|
56
|
+
return Object.keys(expectedFields).every(
|
|
57
|
+
(key) => customData?.[key] === expectedFields[key]
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async waitForCollapseSmartSnippetSuggestionUaAnalytics(
|
|
64
|
+
expectedFields: Record<string, any>
|
|
65
|
+
): Promise<Request> {
|
|
66
|
+
return this.waitForSmartSnippetSuggestionsCustomUaAnalytics(
|
|
67
|
+
'collapseSmartSnippetSuggestion',
|
|
68
|
+
(customData: Record<string, any>) => {
|
|
69
|
+
return Object.keys(expectedFields).every(
|
|
70
|
+
(key) => customData?.[key] === expectedFields[key]
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async waitForSmartSnippetSuggestionSourceClickUaAnalytics(
|
|
77
|
+
expectedCustomFields: Record<string, any>
|
|
78
|
+
): Promise<Request> {
|
|
79
|
+
return this.waitForSmartSnippetSuggestionsClickUaAnalytics(
|
|
80
|
+
'openSmartSnippetSuggestionSource',
|
|
81
|
+
(customData: Record<string, any>) => {
|
|
82
|
+
return Object.keys(expectedCustomFields).every(
|
|
83
|
+
(key) => customData?.[key] === expectedCustomFields[key]
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async waitForSmartSnippetSuggestionInlineLinkClickUaAnalytics(
|
|
90
|
+
expectedCustomFields: Record<string, any>
|
|
91
|
+
): Promise<Request> {
|
|
92
|
+
return this.waitForSmartSnippetSuggestionsClickUaAnalytics(
|
|
93
|
+
'openSmartSnippetSuggestionInlineLink',
|
|
94
|
+
(customData: Record<string, any>) => {
|
|
95
|
+
return Object.keys(expectedCustomFields).every(
|
|
96
|
+
(key) => customData?.[key] === expectedCustomFields[key]
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async waitForSmartSnippetSuggestionsClickUaAnalytics(
|
|
103
|
+
actionCause: string,
|
|
104
|
+
customChecker?: Function
|
|
105
|
+
): Promise<Request> {
|
|
106
|
+
const uaRequest = this.page.waitForRequest((request) => {
|
|
107
|
+
if (isUaClickEvent(request)) {
|
|
108
|
+
const requestBody = request.postDataJSON?.();
|
|
109
|
+
const requestData = JSON.parse(requestBody.clickEvent);
|
|
110
|
+
|
|
111
|
+
const expectedFields: Record<string, any> = {
|
|
112
|
+
actionCause,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const matchesExpectedFields = Object.keys(expectedFields).every(
|
|
116
|
+
(key) => requestData?.[key] === expectedFields[key]
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const customData = requestData?.customData;
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
matchesExpectedFields &&
|
|
123
|
+
(customChecker
|
|
124
|
+
? customChecker(requestData.customData, customData)
|
|
125
|
+
: true)
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
});
|
|
130
|
+
return uaRequest;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async waitForSmartSnippetSuggestionsCustomUaAnalytics(
|
|
134
|
+
eventValue: string,
|
|
135
|
+
customChecker?: Function
|
|
136
|
+
): Promise<Request> {
|
|
137
|
+
const uaRequest = this.page.waitForRequest((request) => {
|
|
138
|
+
if (isUaCustomEvent(request)) {
|
|
139
|
+
const requestBody = request.postDataJSON?.();
|
|
140
|
+
const expectedFields: Record<string, any> = {
|
|
141
|
+
eventType: 'smartSnippetSuggestions',
|
|
142
|
+
eventValue: eventValue,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const matchesExpectedFields = Object.keys(expectedFields).every(
|
|
146
|
+
(key) => requestBody?.[key] === expectedFields[key]
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const customData = requestBody?.customData;
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
matchesExpectedFields &&
|
|
153
|
+
(customChecker ? customChecker(customData) : true)
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
});
|
|
158
|
+
return uaRequest;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {testSearch, testInsight} from './fixture';
|
|
2
|
+
import {useCaseTestCases} from '../../../../../../playwright/utils/useCase';
|
|
3
|
+
import smartSnippetSuggestionsData from './data';
|
|
4
|
+
|
|
5
|
+
const fixtures = {
|
|
6
|
+
search: testSearch,
|
|
7
|
+
insight: testInsight,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
useCaseTestCases.forEach((useCase) => {
|
|
11
|
+
let test = fixtures[useCase.value];
|
|
12
|
+
|
|
13
|
+
test.describe(`quantic smart snippet suggestions ${useCase.label}`, () => {
|
|
14
|
+
test.use({
|
|
15
|
+
smartSnippetSuggestionsData,
|
|
16
|
+
});
|
|
17
|
+
test.describe('when expanding and collapsing the smart snippet suggestions', () => {
|
|
18
|
+
test('should send the expand and collapse analytics events', async ({
|
|
19
|
+
smartSnippetSuggestions,
|
|
20
|
+
}) => {
|
|
21
|
+
const smartSnippetSuggestionIndex = 0;
|
|
22
|
+
const {question, answerSnippet} =
|
|
23
|
+
smartSnippetSuggestionsData.relatedQuestions[
|
|
24
|
+
smartSnippetSuggestionIndex
|
|
25
|
+
];
|
|
26
|
+
const expandSmartSnippetSuggestionsPromise =
|
|
27
|
+
smartSnippetSuggestions.waitForExpandSmartSnippetSuggestionUaAnalytics(
|
|
28
|
+
{
|
|
29
|
+
question,
|
|
30
|
+
answerSnippet,
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
await smartSnippetSuggestions.clickOnSmartSnippetSuggestionHeading(
|
|
35
|
+
smartSnippetSuggestionIndex
|
|
36
|
+
);
|
|
37
|
+
await expandSmartSnippetSuggestionsPromise;
|
|
38
|
+
|
|
39
|
+
const collapseSmartSnippetSuggestionsPromise =
|
|
40
|
+
smartSnippetSuggestions.waitForCollapseSmartSnippetSuggestionUaAnalytics(
|
|
41
|
+
{
|
|
42
|
+
question,
|
|
43
|
+
answerSnippet,
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
await smartSnippetSuggestions.clickOnSmartSnippetSuggestionHeading(
|
|
48
|
+
smartSnippetSuggestionIndex
|
|
49
|
+
);
|
|
50
|
+
await collapseSmartSnippetSuggestionsPromise;
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test.describe('when clicking on elements of the smart snippet suggestion', () => {
|
|
55
|
+
test.beforeEach(async ({smartSnippetSuggestions}) => {
|
|
56
|
+
await smartSnippetSuggestions.clickOnSmartSnippetSuggestionHeading(0);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('should send the source title analytics event when the title is clicked', async ({
|
|
60
|
+
smartSnippetSuggestions,
|
|
61
|
+
}) => {
|
|
62
|
+
const smartSnippetSuggestionIndex = 0;
|
|
63
|
+
const {question, answerSnippet} =
|
|
64
|
+
smartSnippetSuggestionsData.relatedQuestions[
|
|
65
|
+
smartSnippetSuggestionIndex
|
|
66
|
+
];
|
|
67
|
+
const smartSnippetSuggestionsTitleClickPromise =
|
|
68
|
+
smartSnippetSuggestions.waitForSmartSnippetSuggestionSourceClickUaAnalytics(
|
|
69
|
+
{
|
|
70
|
+
question,
|
|
71
|
+
answerSnippet,
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
await smartSnippetSuggestions.clickOnSmartSnippetSuggestionSourceTitle(
|
|
76
|
+
smartSnippetSuggestionIndex
|
|
77
|
+
);
|
|
78
|
+
await smartSnippetSuggestionsTitleClickPromise;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('should send the source uri analytics event when the uri is clicked', async ({
|
|
82
|
+
smartSnippetSuggestions,
|
|
83
|
+
}) => {
|
|
84
|
+
const smartSnippetSuggestionIndex = 0;
|
|
85
|
+
const {question, answerSnippet} =
|
|
86
|
+
smartSnippetSuggestionsData.relatedQuestions[
|
|
87
|
+
smartSnippetSuggestionIndex
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
const smartSnippetSuggestionsSourceUriClickPromise =
|
|
91
|
+
smartSnippetSuggestions.waitForSmartSnippetSuggestionSourceClickUaAnalytics(
|
|
92
|
+
{
|
|
93
|
+
question,
|
|
94
|
+
answerSnippet,
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
await smartSnippetSuggestions.clickOnSmartSnippetSuggestionSourceUri(
|
|
99
|
+
smartSnippetSuggestionIndex
|
|
100
|
+
);
|
|
101
|
+
await smartSnippetSuggestionsSourceUriClickPromise;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('should send the inline link analytics event when an inline link is clicked', async ({
|
|
105
|
+
smartSnippetSuggestions,
|
|
106
|
+
}) => {
|
|
107
|
+
const smartSnippetSuggestionIndex = 0;
|
|
108
|
+
const {question, answerSnippet} =
|
|
109
|
+
smartSnippetSuggestionsData.relatedQuestions[
|
|
110
|
+
smartSnippetSuggestionIndex
|
|
111
|
+
];
|
|
112
|
+
const smartSnippetSuggestionsInlineLinkClickPromise =
|
|
113
|
+
smartSnippetSuggestions.waitForSmartSnippetSuggestionInlineLinkClickUaAnalytics(
|
|
114
|
+
{
|
|
115
|
+
question,
|
|
116
|
+
answerSnippet,
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
await smartSnippetSuggestions.clickOnSmartSnippetSuggestionInlineLink(
|
|
121
|
+
smartSnippetSuggestionIndex
|
|
122
|
+
);
|
|
123
|
+
await smartSnippetSuggestionsInlineLinkClickPromise;
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
</template>
|
|
6
6
|
<template lwc:else>
|
|
7
7
|
<template if:true={shouldDisplaySmartSnippetSuggestions}>
|
|
8
|
-
<div data-
|
|
8
|
+
<div data-testid="smart-snippet-suggestions-card" class="slds-card">
|
|
9
9
|
<p
|
|
10
10
|
class="slds-text-heading_small slds-var-p-around_small slds-border_bottom smart-snippet-suggestions__title"
|
|
11
11
|
>
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
<template for:each={suggestions} for:item="suggestion">
|
|
19
19
|
<lightning-accordion-section
|
|
20
20
|
data-id={suggestion.questionAnswerId}
|
|
21
|
+
data-testid="smart-snippet-suggestion"
|
|
21
22
|
key={suggestion.questionAnswerId}
|
|
22
23
|
name={suggestion.question}
|
|
23
24
|
label={suggestion.question}
|