@coveo/quantic 3.10.0 → 3.11.1

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.
Files changed (79) hide show
  1. package/README.md +52 -12
  2. package/docs/out/quantic-docs.json +27 -0
  3. package/force-app/main/default/labels/CustomLabels.labels-meta.xml +7 -0
  4. package/force-app/main/default/lwc/quanticBreadcrumbManager/__tests__/quanticBreadcrumbManager.test.js +341 -0
  5. package/force-app/main/default/lwc/quanticBreadcrumbManager/quanticBreadcrumbManager.html +8 -8
  6. package/force-app/main/default/lwc/quanticBreadcrumbManager/quanticBreadcrumbManager.js +8 -8
  7. package/force-app/main/default/lwc/quanticFeedbackModalQna/templates/quanticFeedbackModalQna.html +1 -0
  8. package/force-app/main/default/lwc/quanticGeneratedAnswer/__tests__/quanticGeneratedAnswer.test.js +538 -21
  9. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/data.ts +56 -0
  10. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/fixture.ts +87 -0
  11. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/pageObject.ts +279 -0
  12. package/force-app/main/default/lwc/quanticGeneratedAnswer/e2e/quanticGeneratedAnswer.e2e.ts +178 -0
  13. package/force-app/main/default/lwc/quanticGeneratedAnswer/templates/generatedAnswer.html +24 -10
  14. package/force-app/main/default/lwc/quanticGeneratedAnswer/templates/retryPrompt.html +2 -2
  15. package/force-app/main/default/lwc/quanticGeneratedAnswerToggle/quanticGeneratedAnswerToggle.html +1 -1
  16. package/force-app/main/default/lwc/quanticNotifications/__tests__/quanticNotifications.test.js +112 -4
  17. package/force-app/main/default/lwc/quanticNotifications/quanticNotifications.css +8 -0
  18. package/force-app/main/default/lwc/quanticNotifications/quanticNotifications.html +20 -7
  19. package/force-app/main/default/lwc/quanticNotifications/quanticNotifications.js +57 -18
  20. package/force-app/main/default/lwc/quanticPager/e2e/pagerObject.ts +1 -1
  21. package/force-app/main/default/lwc/quanticUserActionsToggle/__tests__/quanticUserActionsToggle.test.js +18 -0
  22. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/data.ts +32 -0
  23. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/fixture.ts +32 -0
  24. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/pageObject.ts +71 -0
  25. package/force-app/main/default/lwc/quanticUserActionsToggle/e2e/quanticUserActionsToggle.e2e.ts +39 -0
  26. package/force-app/main/default/lwc/quanticUserActionsToggle/quanticUserActionsToggle.js +4 -0
  27. package/force-app/main/default/staticresources/coveobueno/browser/bueno.js +4 -4
  28. package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +8 -10
  29. package/force-app/main/default/staticresources/coveoheadless/definitions/api/analytics/instant-result-analytics.d.ts +1 -1
  30. package/force-app/main/default/staticresources/coveoheadless/definitions/api/analytics/search-analytics.d.ts +1 -1
  31. package/force-app/main/default/staticresources/coveoheadless/definitions/api/knowledge/stream-answer-api.d.ts +3 -1
  32. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-engine/commerce-engine.ssr.d.ts +2 -0
  33. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/build-factory.d.ts +2 -0
  34. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/factories/utils/recommendation-filter.d.ts +11 -0
  35. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/build.d.ts +4 -8
  36. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/common.d.ts +178 -7
  37. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/core-engine.d.ts +3 -3
  38. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/fetch-static-state.d.ts +4 -12
  39. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/from-build-result.d.ts +1 -1
  40. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/hydrate-static-state.d.ts +4 -11
  41. package/force-app/main/default/staticresources/coveoheadless/definitions/app/commerce-ssr-engine/types/kind.d.ts +6 -0
  42. package/force-app/main/default/staticresources/coveoheadless/definitions/app/ssr-engine/types/common.d.ts +6 -0
  43. package/force-app/main/default/staticresources/coveoheadless/definitions/commerce.index.d.ts +1 -1
  44. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/context/cart/headless-cart.ssr.d.ts +2 -2
  45. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/context/headless-context.ssr.d.ts +2 -2
  46. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.ssr.d.ts +1 -0
  47. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.d.ts +3 -0
  48. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.d.ts +8 -7
  49. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ssr.d.ts +3 -1
  50. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/sub-controller/headless-sub-controller.d.ts +1 -2
  51. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/core/url-manager/headless-core-url-manager.d.ts +11 -2
  52. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/product-list/headless-product-list.ssr.d.ts +1 -1
  53. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/product-view/headless-product-view.ssr.d.ts +1 -0
  54. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recommendations/headless-recommendations.d.ts +1 -0
  55. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/recommendations/headless-recommendations.ssr.d.ts +4 -4
  56. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr.d.ts +2 -2
  57. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/parameters/parameters-actions.d.ts +22 -6
  58. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/parameters/parameters-schema.d.ts +4 -0
  59. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/parameters/parameters-selectors.d.ts +0 -11
  60. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/parameters/parameters-serializer.d.ts +6 -1
  61. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/parameters/parameters-serializer.ssr.d.ts +44 -0
  62. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/parameters/parameters-slice.d.ts +4 -0
  63. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/parameters/parameters-state.d.ts +4 -0
  64. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/recommendations/recommendations-actions.d.ts +1 -0
  65. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/recommendations/recommendations-state.d.ts +1 -0
  66. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/search/search-selectors.d.ts +0 -12
  67. package/force-app/main/default/staticresources/coveoheadless/definitions/features/debug/debug-selectors.d.ts +1 -1
  68. package/force-app/main/default/staticresources/coveoheadless/definitions/features/question-answering/question-answering-selectors.d.ts +1 -1
  69. package/force-app/main/default/staticresources/coveoheadless/definitions/features/search/search-selectors.d.ts +1 -1
  70. package/force-app/main/default/staticresources/coveoheadless/definitions/features/search-parameters/search-parameter-serializer.d.ts +5 -2
  71. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce.index.d.ts +4 -3
  72. package/force-app/main/default/staticresources/coveoheadless/definitions/state/commerce-app-state.d.ts +2 -2
  73. package/force-app/main/default/staticresources/coveoheadless/definitions/state/state-sections.d.ts +4 -0
  74. package/force-app/main/default/staticresources/coveoheadless/definitions/utils/errors.d.ts +3 -0
  75. package/force-app/main/default/staticresources/coveoheadless/headless.js +10 -12
  76. package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +9 -11
  77. package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +8 -10
  78. package/force-app/main/default/staticresources/dompurify/purify.min.js +2 -1339
  79. package/package.json +23 -19
package/README.md CHANGED
@@ -55,8 +55,8 @@ Or you can run the individual commands below.
55
55
  - Make sure you are in the `packages/quantic` root folder.
56
56
  - Run this command to create the default scratch org. `npm run scratch:create`.
57
57
  - In VS Code, press Command + Shift P, enter sfdx, and select SFDX: Create a Default Scratch Org.
58
- - You can also run this command from the command line. `sf org create scratch --set-default --definition-file config/project-scratch-def.json --alias "LWC"`
59
- - `LWC` is an alias for the scratch org that you can use in other Salesforce CLI commands. You can create any alias that you like.
58
+ - You can also run this command from the command line. `sf org create scratch --set-default --definition-file config/lws-enabled-scratch-def.json --alias Quantic__LWS_enabled`
59
+ - `Quantic__LWS_enabled` is an alias for the scratch org that you can use in other Salesforce CLI commands. You can create any alias that you like.
60
60
 
61
61
  #### Deploy the Quantic code
62
62
 
@@ -64,39 +64,55 @@ Or you can run the individual commands below.
64
64
 
65
65
  ## Testing
66
66
 
67
- ### Deploy the Quantic Examples Community
67
+ ### Deploy the Quantic Examples Communities
68
68
 
69
- Example components are available as a Salesforce community (Digital Experience) allowing you to experiment with Quantic components.
69
+ Example components are available as Salesforce communities (Digital Experiences), allowing you to experiment with Quantic components in two separate environments: one with Lightning Web Security (LWS) enabled and one with LWS disabled.
70
70
 
71
- To setup the community in the `LWC` scratch org, run:
71
+ To set up both communities in scratch orgs, run:
72
72
 
73
73
  ```bash
74
74
  npm run setup:examples
75
75
  ```
76
76
 
77
- This script creates, configures, and deploys everything required to have fully working examples. The community URL is provided at the end of the script output, as in the following example:
77
+ This script creates, configures, and deploys everything required to have fully working examples in **two scratch orgs**:
78
+
79
+ - An org with **LWS enabled**.
80
+ - An org with **LWS disabled**.
81
+
82
+ At the end of the script, the URLs for the two communities are provided, as in the following example:
78
83
 
79
84
  ```
80
- ...
81
85
 
82
- The 'Quantic Examples' community is ready, you can access it at the following URL:
83
- https://your-salesforce-scratch-org-instance.force.com/examples
86
+ The 'Quantic Examples' community (LWS enabled) is ready, you can access it at the following URL:
87
+ https://your-salesforce-lws-enabled-scratch-org-instance.force.com/examples
88
+
89
+ The 'Quantic Examples' community (LWS disabled) is ready, you can access it at the following URL:
90
+ https://your-salesforce-lws-disabled-scratch-org-instance.force.com/examples
84
91
 
85
92
  To open Cypress, run:
86
93
  npm run e2e:watch
87
94
  ```
88
95
 
89
- Once the community has been deployed, you can deploy the `main` or `example` components only when needed. To do so, run:
96
+ Once the community has been deployed, you can deploy the `main` or `example` components to a specific org only when needed by running the corresponding commands:
97
+
98
+ ```bash
99
+ npm run deploy:main --target-org Quantic__LWS_enabled
100
+ npm run deploy:examples --target-org Quantic__LWS_enabled
101
+ ```
102
+
103
+ You can replace Quantic\_\_LWS_enabled with your target org alias. For example:
90
104
 
91
105
  ```bash
92
- npm run deploy:main
93
- npm run deploy:examples
106
+ npm run deploy:main --target-org MyCustomOrg
107
+ npm run deploy:examples --target-org MyCustomOrg
94
108
  ```
95
109
 
96
110
  ### Run Cypress for Quantic Components
97
111
 
98
112
  **Note** Before attempting to run [Cypress](https://docs.cypress.io) tests, make sure the `Quantic Examples` community is deployed as described in the previous section.
99
113
 
114
+ **Note** Cypress tests run on the org with **LWS enabled**, aliased as `Quantic__LWS_enabled`.
115
+
100
116
  To learn how to add tests, see [adding tests](./docs/adding-tests.md).
101
117
 
102
118
  - All the tests will need to be under folder `cypress/integration`.
@@ -119,6 +135,30 @@ To get the [detailed report](./docs/detailed-reporting.md), run:
119
135
  npm run e2e:detailed
120
136
  ```
121
137
 
138
+ ### Run Playwright for Quantic Components
139
+
140
+ **Note** Before attempting to run [Playwright](https://playwright.dev/) tests, make sure the `Quantic Examples` community is deployed as described in the previous section in both orgs, the one where LWS is enabled and the one where it is disabled.
141
+
142
+ **Note** For more information on how to add tests, please refer to our [Quantic Testing Strategy](https://github.com/coveo/ui-kit/blob/master/packages/quantic/decisions/0001-testing-strategy.md), which provides detailed guidelines on testing Quantic components.
143
+
144
+ To run Playwright tests, run:
145
+
146
+ ```bash
147
+ npm run e2e:playwright
148
+ ```
149
+
150
+ To run Playwright tests only for the scratch org where LWS is enabled, run:
151
+
152
+ ```bash
153
+ npm run e2e:playwright:lws-enabled
154
+ ```
155
+
156
+ To run Playwright tests only for the scratch org where LWS is disabled, run:
157
+
158
+ ```bash
159
+ npm run e2e:playwright:lws-disabled
160
+ ```
161
+
122
162
  ### Run LWC unit tests for Quantic Components
123
163
 
124
164
  To run LWC unit tests directly in your console, run:
@@ -6163,6 +6163,33 @@
6163
6163
  "required": true,
6164
6164
  "defaultValue": "",
6165
6165
  "type": "string"
6166
+ },
6167
+ {
6168
+ "name": "userId",
6169
+ "attribute": "user-id",
6170
+ "access": "@api",
6171
+ "description": "<p>The ID of the user whose actions are being displayed. For example in email format &quot;someone@company.com&quot;.</p>",
6172
+ "required": true,
6173
+ "defaultValue": "",
6174
+ "type": "string"
6175
+ },
6176
+ {
6177
+ "name": "ticketCreationDateTime",
6178
+ "attribute": "ticket-creation-date-time",
6179
+ "access": "@api",
6180
+ "description": "<p>The date and time when the ticket was created. For example &quot;2024-01-01T00:00:00Z&quot;</p>",
6181
+ "required": true,
6182
+ "defaultValue": "",
6183
+ "type": "string"
6184
+ },
6185
+ {
6186
+ "name": "excludedCustomActions",
6187
+ "attribute": "excluded-custom-actions",
6188
+ "access": "@api",
6189
+ "description": "<p>The names of custom events to exclude.</p>",
6190
+ "required": false,
6191
+ "defaultValue": "[]",
6192
+ "type": "Array.<string>"
6166
6193
  }
6167
6194
  ]
6168
6195
  }
@@ -1603,4 +1603,11 @@
1603
1603
  <protected>false</protected>
1604
1604
  <shortDescription>User actions</shortDescription>
1605
1605
  </labels>
1606
+ <labels>
1607
+ <fullName>quantic_CloseNotification</fullName>
1608
+ <value>Close notification</value>
1609
+ <language>en_US</language>
1610
+ <protected>false</protected>
1611
+ <shortDescription>Close notification</shortDescription>
1612
+ </labels>
1606
1613
  </CustomLabels>
@@ -0,0 +1,341 @@
1
+ /* eslint-disable no-import-assign */
2
+ // @ts-ignore
3
+ import QuanticBreadcrumbManager from 'c/quanticBreadcrumbManager';
4
+ // @ts-ignore
5
+ import {createElement} from 'lwc';
6
+ import * as mockHeadlessLoader from 'c/quanticHeadlessLoader';
7
+
8
+ const initialBreadcrumbManagerState = {
9
+ hasBreadcrumbs: false,
10
+ numericFacetBreadcrumbs: [],
11
+ categoryFacetBreadcrumbs: [],
12
+ dateFacetBreadcrumbs: [],
13
+ facetBreadcrumbs: [],
14
+ };
15
+ let breadcrumbManagerState = initialBreadcrumbManagerState;
16
+
17
+ const initialStoreState = {};
18
+ let storeState = initialStoreState;
19
+
20
+ const functionsMocks = {
21
+ buildBreadcrumbManager: jest.fn(() => ({
22
+ state: breadcrumbManagerState,
23
+ subscribe: functionsMocks.subscribe,
24
+ })),
25
+ subscribe: jest.fn((cb) => {
26
+ cb();
27
+ return functionsMocks.unsubscribe;
28
+ }),
29
+ unsubscribe: jest.fn(() => {}),
30
+ };
31
+
32
+ const selectors = {
33
+ facetBreadcrumb: '[data-test="facet-breadcrumb"]',
34
+ facetBreadcrumbValue: '[data-test="facet-breadcrumb-value"]',
35
+ categoryFacetBreadcrumb: '[data-test="category-facet-breadcrumb"]',
36
+ categoryFacetBreadcrumbValue: '[data-test="category-facet-breadcrumb-value"]',
37
+ numericFacetBreadcrumb: '[data-test="numeric-facet-breadcrumb"]',
38
+ numericFacetBreadcrumbValue: '[data-test="numeric-facet-breadcrumb-value"]',
39
+ dateFacetBreadcrumb: '[data-test="date-facet-breadcrumb"]',
40
+ dateFacetBreadcrumbValue: '[data-test="date-facet-breadcrumb-value"]',
41
+ };
42
+
43
+ const exampleEngine = {
44
+ id: 'dummy engine',
45
+ };
46
+ const exampleFacetId = 'idOne';
47
+
48
+ let isInitialized = false;
49
+
50
+ function createTestComponent(options = {}) {
51
+ const element = createElement('c-quantic-breadcrumb-manager', {
52
+ is: QuanticBreadcrumbManager,
53
+ });
54
+ for (const [key, value] of Object.entries(options)) {
55
+ element[key] = value;
56
+ }
57
+
58
+ document.body.appendChild(element);
59
+ return element;
60
+ }
61
+
62
+ function prepareHeadlessState() {
63
+ // @ts-ignore
64
+ mockHeadlessLoader.getHeadlessBundle = () => {
65
+ return {
66
+ buildBreadcrumbManager: functionsMocks.buildBreadcrumbManager,
67
+ };
68
+ };
69
+ }
70
+
71
+ function mockStoreState() {
72
+ // @ts-ignore
73
+ mockHeadlessLoader.getFromStore = () => {
74
+ return storeState;
75
+ };
76
+ }
77
+
78
+ // Helper function to wait until the microtask queue is empty.
79
+ function flushPromises() {
80
+ // eslint-disable-next-line @lwc/lwc/no-async-operation
81
+ return new Promise((resolve) => setTimeout(resolve, 0));
82
+ }
83
+
84
+ function mockSuccessfulHeadlessInitialization() {
85
+ // @ts-ignore
86
+ mockHeadlessLoader.initializeWithHeadless = (element, _, initialize) => {
87
+ if (element instanceof QuanticBreadcrumbManager && !isInitialized) {
88
+ isInitialized = true;
89
+ initialize(exampleEngine);
90
+ }
91
+ };
92
+ }
93
+
94
+ function cleanup() {
95
+ // The jsdom instance is shared across test cases in a single file so reset the DOM
96
+ while (document.body.firstChild) {
97
+ document.body.removeChild(document.body.firstChild);
98
+ }
99
+ jest.clearAllMocks();
100
+ isInitialized = false;
101
+ }
102
+
103
+ describe('c-quantic-breadcrumb-manager', () => {
104
+ beforeEach(() => {
105
+ mockSuccessfulHeadlessInitialization();
106
+ prepareHeadlessState();
107
+ mockStoreState();
108
+ });
109
+
110
+ afterEach(() => {
111
+ breadcrumbManagerState = initialBreadcrumbManagerState;
112
+ storeState = initialStoreState;
113
+ cleanup();
114
+ });
115
+
116
+ describe('facet breadcrumbs', () => {
117
+ const exampleFacetBreadcrumbs = [
118
+ {
119
+ field: 'fieldOne',
120
+ facetId: exampleFacetId,
121
+ values: [{value: 'one'}, {value: 'two'}],
122
+ },
123
+ ];
124
+
125
+ beforeAll(() => {
126
+ breadcrumbManagerState = {
127
+ ...breadcrumbManagerState,
128
+ facetBreadcrumbs: exampleFacetBreadcrumbs,
129
+ hasBreadcrumbs: true,
130
+ };
131
+
132
+ storeState = {
133
+ [exampleFacetId]: {
134
+ facetId: exampleFacetId,
135
+ format: (value) => value,
136
+ },
137
+ };
138
+ });
139
+
140
+ it('should properly display the breadcrumb values', async () => {
141
+ const element = createTestComponent();
142
+ await flushPromises();
143
+
144
+ const facetBreadcrumbs = element.shadowRoot.querySelectorAll(
145
+ selectors.facetBreadcrumb
146
+ );
147
+
148
+ expect(facetBreadcrumbs.length).toBe(exampleFacetBreadcrumbs.length);
149
+ facetBreadcrumbs.forEach((facetBreadcrumb, index) => {
150
+ const exampleFacetBreadcrumb = exampleFacetBreadcrumbs[index];
151
+ const facetBreadcrumbValues = Array.from(
152
+ facetBreadcrumb.querySelectorAll(selectors.facetBreadcrumbValue)
153
+ );
154
+
155
+ expect(facetBreadcrumbValues.length).toBe(
156
+ exampleFacetBreadcrumb.values.length
157
+ );
158
+
159
+ const labels = facetBreadcrumbValues.map(
160
+ (facetBreadcrumbValue) => facetBreadcrumbValue.label
161
+ );
162
+ const values = exampleFacetBreadcrumb.values.map((item) => item.value);
163
+ expect(labels).toEqual(values);
164
+ });
165
+ });
166
+ });
167
+
168
+ describe('category facet breadcrumbs', () => {
169
+ const exampleCategoryFacetBreadcrumbs = [
170
+ {
171
+ field: exampleFacetId,
172
+ facetId: exampleFacetId,
173
+ path: [{value: 'one'}, {value: 'two'}],
174
+ },
175
+ ];
176
+
177
+ beforeAll(() => {
178
+ breadcrumbManagerState = {
179
+ ...breadcrumbManagerState,
180
+ categoryFacetBreadcrumbs: exampleCategoryFacetBreadcrumbs,
181
+ hasBreadcrumbs: true,
182
+ };
183
+
184
+ storeState = {
185
+ [exampleFacetId]: {
186
+ facetId: exampleFacetId,
187
+ format: (item) => item.value,
188
+ },
189
+ };
190
+ });
191
+
192
+ it('should properly display the breadcrumb values', async () => {
193
+ const element = createTestComponent();
194
+ await flushPromises();
195
+
196
+ const categoryFacetBreadcrumbs = element.shadowRoot.querySelectorAll(
197
+ selectors.categoryFacetBreadcrumb
198
+ );
199
+
200
+ expect(categoryFacetBreadcrumbs.length).toBe(
201
+ exampleCategoryFacetBreadcrumbs.length
202
+ );
203
+ categoryFacetBreadcrumbs.forEach((categoryFacetBreadcrumb, index) => {
204
+ const exampleFacetBreadcrumb = exampleCategoryFacetBreadcrumbs[index];
205
+ const categoryFacetBreadcrumbValues = Array.from(
206
+ categoryFacetBreadcrumb.querySelectorAll(
207
+ selectors.categoryFacetBreadcrumbValue
208
+ )
209
+ );
210
+
211
+ expect(categoryFacetBreadcrumbValues.length).toBe(1);
212
+
213
+ const labels = categoryFacetBreadcrumbValues.map(
214
+ (facetBreadcrumbValue) => facetBreadcrumbValue.label
215
+ );
216
+ const values = exampleFacetBreadcrumb.path.map((item) => item.value);
217
+ expect(labels).toEqual([values.join(' / ')]);
218
+ });
219
+ });
220
+ });
221
+
222
+ describe('numeric facet breadcrumbs', () => {
223
+ const exampleNumericFacetBreadcrumbs = [
224
+ {
225
+ field: 'fieldOne',
226
+ facetId: exampleFacetId,
227
+ values: [{value: {start: 0, end: 1}}, {value: {start: 1, end: 2}}],
228
+ },
229
+ ];
230
+
231
+ beforeAll(() => {
232
+ breadcrumbManagerState = {
233
+ ...breadcrumbManagerState,
234
+ numericFacetBreadcrumbs: exampleNumericFacetBreadcrumbs,
235
+ hasBreadcrumbs: true,
236
+ };
237
+
238
+ storeState = {
239
+ [exampleFacetId]: {
240
+ facetId: exampleFacetId,
241
+ format: (item) => `${item.start} - ${item.end}`,
242
+ },
243
+ };
244
+ });
245
+
246
+ it('should properly display the breadcrumb values', async () => {
247
+ const element = createTestComponent();
248
+ await flushPromises();
249
+
250
+ const numericFacetBreadcrumbs = element.shadowRoot.querySelectorAll(
251
+ selectors.numericFacetBreadcrumb
252
+ );
253
+
254
+ expect(numericFacetBreadcrumbs.length).toBe(
255
+ exampleNumericFacetBreadcrumbs.length
256
+ );
257
+ numericFacetBreadcrumbs.forEach((numericFacetBreadcrumb, index) => {
258
+ const exampleFacetBreadcrumb = exampleNumericFacetBreadcrumbs[index];
259
+ const facetBreadcrumbValues = Array.from(
260
+ numericFacetBreadcrumb.querySelectorAll(
261
+ selectors.numericFacetBreadcrumbValue
262
+ )
263
+ );
264
+
265
+ expect(facetBreadcrumbValues.length).toBe(
266
+ exampleFacetBreadcrumb.values.length
267
+ );
268
+
269
+ const labels = facetBreadcrumbValues.map(
270
+ (facetBreadcrumbValue) => facetBreadcrumbValue.label
271
+ );
272
+ const values = exampleFacetBreadcrumb.values.map(
273
+ (item) => `${item.value.start} - ${item.value.end}`
274
+ );
275
+ expect(labels).toEqual(values);
276
+ });
277
+ });
278
+ });
279
+
280
+ describe('date facet breadcrumbs', () => {
281
+ const exampleDateFacetBreadcrumbs = [
282
+ {
283
+ field: 'fieldOne',
284
+ facetId: exampleFacetId,
285
+ values: [
286
+ {value: {start: 'yesterday', end: 'today'}},
287
+ {value: {start: 'today', end: 'tomorrow'}},
288
+ ],
289
+ },
290
+ ];
291
+
292
+ beforeAll(() => {
293
+ breadcrumbManagerState = {
294
+ ...breadcrumbManagerState,
295
+ dateFacetBreadcrumbs: exampleDateFacetBreadcrumbs,
296
+ hasBreadcrumbs: true,
297
+ };
298
+
299
+ storeState = {
300
+ [exampleFacetId]: {
301
+ facetId: exampleFacetId,
302
+ format: (item) => `${item.start} - ${item.end}`,
303
+ },
304
+ };
305
+ });
306
+
307
+ it('should properly display the breadcrumb values', async () => {
308
+ const element = createTestComponent();
309
+ await flushPromises();
310
+
311
+ const dateFacetBreadcrumbs = element.shadowRoot.querySelectorAll(
312
+ selectors.dateFacetBreadcrumb
313
+ );
314
+
315
+ expect(dateFacetBreadcrumbs.length).toBe(
316
+ exampleDateFacetBreadcrumbs.length
317
+ );
318
+
319
+ dateFacetBreadcrumbs.forEach((dateFacetBreadcrumb, index) => {
320
+ const exampleFacetBreadcrumb = exampleDateFacetBreadcrumbs[index];
321
+ const facetBreadcrumbValues = Array.from(
322
+ dateFacetBreadcrumb.querySelectorAll(
323
+ selectors.dateFacetBreadcrumbValue
324
+ )
325
+ );
326
+
327
+ expect(facetBreadcrumbValues.length).toBe(
328
+ exampleFacetBreadcrumb.values.length
329
+ );
330
+
331
+ const labels = facetBreadcrumbValues.map(
332
+ (facetBreadcrumbValue) => facetBreadcrumbValue.label
333
+ );
334
+ const values = exampleFacetBreadcrumb.values.map(
335
+ (item) => `${item.value.start} - ${item.value.end}`
336
+ );
337
+ expect(labels).toEqual(values);
338
+ });
339
+ });
340
+ });
341
+ });
@@ -9,12 +9,12 @@
9
9
  <div class="slds-col slds-truncate slds-col_bump-right breadcrumb-manager__column">
10
10
  <ul>
11
11
  <template for:each={facetBreadcrumbValues} for:item="breadcrumb">
12
- <li key={breadcrumb.facetId} class="slds-list_horizontal breadcrumb-manager__facet-list breadcrumb-manager__line">
12
+ <li data-test="facet-breadcrumb" key={breadcrumb.facetId} class="slds-list_horizontal breadcrumb-manager__facet-list breadcrumb-manager__line">
13
13
  <span class="slds-col breadcrumb-manager__field-name">{breadcrumb.label}{labels.colon} </span>
14
14
  <ul class="slds-col slds-truncate slds-list_horizontal slds-grid slds-wrap">
15
15
  <template for:each={breadcrumb.values} for:item="breadcrumbValue">
16
16
  <li key={breadcrumbValue.value.value} class="breadcrumb__container">
17
- <c-quantic-pill label={breadcrumbValue.formattedValue} onquantic__deselect={breadcrumbValue.deselect} group-name={breadcrumb.label} action-name={labels.clearFilter}></c-quantic-pill>
17
+ <c-quantic-pill data-test="facet-breadcrumb-value" label={breadcrumbValue.formattedValue} onquantic__deselect={breadcrumbValue.deselect} group-name={breadcrumb.label} action-name={labels.clearFilter}></c-quantic-pill>
18
18
  </li>
19
19
  </template>
20
20
  <template if:true={breadcrumb.showMoreButton}>
@@ -26,12 +26,12 @@
26
26
  </li>
27
27
  </template>
28
28
  <template for:each={numericFacetBreadcrumbsValues} for:item="breadcrumb">
29
- <li key={breadcrumb.facetId} class="slds-list_horizontal breadcrumb-manager__numeric-facet-list breadcrumb-manager__line">
29
+ <li data-test="numeric-facet-breadcrumb" key={breadcrumb.facetId} class="slds-list_horizontal breadcrumb-manager__numeric-facet-list breadcrumb-manager__line">
30
30
  <span class="slds-col breadcrumb-manager__field-name">{breadcrumb.label}{labels.colon} </span>
31
31
  <ul class="slds-col slds-truncate slds-list_horizontal slds-grid slds-wrap">
32
32
  <template for:each={breadcrumb.values} for:item="breadcrumbValue">
33
33
  <li key={breadcrumbValue.value} class="breadcrumb__container">
34
- <c-quantic-pill label={breadcrumbValue.formattedValue} onquantic__deselect={breadcrumbValue.deselect} group-name={breadcrumb.label} action-name={labels.clearFilter}></c-quantic-pill>
34
+ <c-quantic-pill data-test="numeric-facet-breadcrumb-value" label={breadcrumbValue.formattedValue} onquantic__deselect={breadcrumbValue.deselect} group-name={breadcrumb.label} action-name={labels.clearFilter}></c-quantic-pill>
35
35
  </li>
36
36
  </template>
37
37
  <template if:true={breadcrumb.showMoreButton}>
@@ -43,22 +43,22 @@
43
43
  </li>
44
44
  </template>
45
45
  <template for:each={categoryFacetBreadcrumbsValues} for:item="breadcrumbValue">
46
- <li key={breadcrumbValue.facetId} class="slds-list_horizontal breadcrumb-manager__category-facet-list breadcrumb-manager__line">
46
+ <li data-test="category-facet-breadcrumb" key={breadcrumbValue.facetId} class="slds-list_horizontal breadcrumb-manager__category-facet-list breadcrumb-manager__line">
47
47
  <span class="slds-col breadcrumb-manager__field-name">{breadcrumbValue.label}{labels.colon} </span>
48
48
  <ul class="slds-col slds-truncate slds-list_horizontal slds-grid slds-wrap">
49
49
  <li class="breadcrumb__container">
50
- <c-quantic-pill label={breadcrumbValue.value} onquantic__deselect={breadcrumbValue.deselect} group-name={breadcrumbValue.label} action-name={labels.clearFilter}></c-quantic-pill>
50
+ <c-quantic-pill data-test="category-facet-breadcrumb-value" label={breadcrumbValue.value} onquantic__deselect={breadcrumbValue.deselect} group-name={breadcrumbValue.label} action-name={labels.clearFilter}></c-quantic-pill>
51
51
  </li>
52
52
  </ul>
53
53
  </li>
54
54
  </template>
55
55
  <template for:each={dateFacetBreadcrumbsValues} for:item="breadcrumb">
56
- <li key={breadcrumb.facetId} class="slds-list_horizontal breadcrumb-manager__date-facet-list breadcrumb-manager__line">
56
+ <li data-test="date-facet-breadcrumb" key={breadcrumb.facetId} class="slds-list_horizontal breadcrumb-manager__date-facet-list breadcrumb-manager__line">
57
57
  <span class="slds-col breadcrumb-manager__field-name">{breadcrumb.label}{labels.colon} </span>
58
58
  <ul class="slds-col slds-truncate slds-list_horizontal slds-grid slds-wrap">
59
59
  <template for:each={breadcrumb.values} for:item="breadcrumbValue">
60
60
  <li key={breadcrumbValue.value} class="breadcrumb__container">
61
- <c-quantic-pill label={breadcrumbValue.value} onquantic__deselect={breadcrumbValue.deselect} group-name={breadcrumb.label} action-name={labels.clearFilter}></c-quantic-pill>
61
+ <c-quantic-pill data-test="date-facet-breadcrumb-value" label={breadcrumbValue.value} onquantic__deselect={breadcrumbValue.deselect} group-name={breadcrumb.label} action-name={labels.clearFilter}></c-quantic-pill>
62
62
  </li>
63
63
  </template>
64
64
  <template if:true={breadcrumb.showMoreButton}>
@@ -120,18 +120,18 @@ export default class QuanticBreadcrumbManager extends LightningElement {
120
120
  const data = getFromStore(this.engineId, Store.facetTypes.NUMERICFACETS);
121
121
  return {
122
122
  ...breadcrumb,
123
- label: data ? data[breadcrumb.field]?.label : breadcrumb.field,
123
+ label: data ? data[breadcrumb.facetId]?.label : breadcrumb.field,
124
124
  values: breadcrumb.values.map((range) => ({
125
125
  ...range,
126
126
  value: `${range.value.start} - ${range.value.end}`,
127
- formattedValue: data[breadcrumb.field]?.format(range.value),
127
+ formattedValue: data[breadcrumb.facetId]?.format(range.value),
128
128
  })),
129
129
  };
130
130
  }
131
131
 
132
132
  formatCategoryBreadcrumbValue(breadcrumb) {
133
133
  const data = getFromStore(this.engineId, Store.facetTypes.CATEGORYFACETS);
134
- const format = data[breadcrumb.field]?.format ?? ((item) => item.value);
134
+ const format = data[breadcrumb.facetId]?.format ?? ((item) => item.value);
135
135
 
136
136
  if (breadcrumb.path.length <= 3) {
137
137
  return breadcrumb.path.map((breadcrumbValue) => format(breadcrumbValue));
@@ -175,10 +175,10 @@ export default class QuanticBreadcrumbManager extends LightningElement {
175
175
  const data = getFromStore(this.engineId, Store.facetTypes.DATEFACETS);
176
176
  return {
177
177
  ...breadcrumb,
178
- label: data ? data[breadcrumb.field]?.label : breadcrumb.field,
178
+ label: data ? data[breadcrumb.facetId]?.label : breadcrumb.field,
179
179
  values: breadcrumb.values.map((range) => ({
180
180
  ...range,
181
- value: data[breadcrumb.field]?.format(range.value),
181
+ value: data[breadcrumb.facetId]?.format(range.value),
182
182
  })),
183
183
  };
184
184
  }
@@ -187,10 +187,10 @@ export default class QuanticBreadcrumbManager extends LightningElement {
187
187
  const data = getFromStore(this.engineId, Store.facetTypes.FACETS);
188
188
  return {
189
189
  ...breadcrumb,
190
- label: data ? data[breadcrumb.field]?.label : breadcrumb.field,
190
+ label: data ? data[breadcrumb.facetId]?.label : breadcrumb.field,
191
191
  values: breadcrumb.values.map((item) => ({
192
192
  ...item,
193
- formattedValue: data[breadcrumb.field]?.format(item.value),
193
+ formattedValue: data[breadcrumb.facetId]?.format(item.value),
194
194
  })),
195
195
  };
196
196
  }
@@ -266,7 +266,7 @@ export default class QuanticBreadcrumbManager extends LightningElement {
266
266
  return {
267
267
  facetId: breadcrumb.facetId,
268
268
  field: breadcrumb.field,
269
- label: data ? data[breadcrumb.field]?.label : breadcrumb.field,
269
+ label: data ? data[breadcrumb.facetId]?.label : breadcrumb.field,
270
270
  deselect: breadcrumb.deselect,
271
271
  value: breadcrumbValues.join(` ${this.categoryDivider} `),
272
272
  };
@@ -17,6 +17,7 @@
17
17
  <div
18
18
  class="slds-grid slds-grid_align-spread slds-grid_vertical-align-start slds-var-p-bottom_x-small feedback-modal-qna__question"
19
19
  key={question.id}
20
+ data-testid={question.id}
20
21
  >
21
22
  <div class="slds-col slds-var-p-top_x-small">
22
23
  {question.question}