coveo.analytics 2.30.56 → 2.32.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.
Files changed (84) hide show
  1. package/README.md +37 -43
  2. package/dist/browser.mjs +513 -357
  3. package/dist/coveoua.browser.js +1 -1
  4. package/dist/coveoua.browser.js.map +1 -1
  5. package/dist/coveoua.debug.js +542 -359
  6. package/dist/coveoua.debug.js.map +1 -1
  7. package/dist/coveoua.js +1 -1
  8. package/dist/coveoua.js.map +1 -1
  9. package/dist/definitions/client/analytics.d.ts +3 -2
  10. package/dist/definitions/client/runtimeEnvironment.d.ts +1 -1
  11. package/dist/definitions/donottrack.d.ts +1 -0
  12. package/dist/definitions/react-native/index.d.ts +1 -2
  13. package/dist/definitions/version.d.ts +1 -1
  14. package/dist/library.cjs +15350 -3699
  15. package/dist/library.es.js +513 -357
  16. package/dist/library.js +15350 -3699
  17. package/dist/library.mjs +15350 -3699
  18. package/dist/react-native.es.js +634 -460
  19. package/modules/package.json +9 -9
  20. package/package.json +60 -91
  21. package/react-native/package.json +7 -7
  22. package/src/caseAssist/caseAssistActions.ts +51 -50
  23. package/src/caseAssist/caseAssistClient.spec.ts +328 -297
  24. package/src/caseAssist/caseAssistClient.ts +201 -185
  25. package/src/client/analytics.spec.ts +724 -703
  26. package/src/client/analytics.ts +677 -602
  27. package/src/client/analyticsBeaconClient.spec.ts +195 -188
  28. package/src/client/analyticsBeaconClient.ts +99 -88
  29. package/src/client/analyticsFetchClient.ts +77 -61
  30. package/src/client/analyticsRequestClient.ts +17 -17
  31. package/src/client/location.ts +3 -3
  32. package/src/client/measurementProtocolMapper.ts +54 -45
  33. package/src/client/measurementProtocolMapping/baseMeasurementProtocolMapper.ts +48 -44
  34. package/src/client/measurementProtocolMapping/commerceMeasurementProtocolMapper.ts +133 -121
  35. package/src/client/measurementProtocolMapping/serviceMeasurementProtocolMapper.ts +17 -17
  36. package/src/client/noopAnalytics.ts +80 -68
  37. package/src/client/runtimeEnvironment.ts +50 -41
  38. package/src/client/utils.spec.ts +112 -97
  39. package/src/client/utils.ts +39 -39
  40. package/src/cookieutils.spec.ts +59 -0
  41. package/src/cookieutils.ts +40 -39
  42. package/src/coveoua/browser.ts +14 -12
  43. package/src/coveoua/library.ts +4 -4
  44. package/src/coveoua/plugins.ts +36 -34
  45. package/src/coveoua/simpleanalytics.spec.ts +467 -452
  46. package/src/coveoua/simpleanalytics.ts +146 -140
  47. package/src/detector.ts +17 -17
  48. package/src/donottrack.spec.ts +199 -121
  49. package/src/donottrack.ts +31 -8
  50. package/src/events.ts +86 -79
  51. package/src/formatting/format-array-for-coveo-custom-data.spec.ts +13 -12
  52. package/src/formatting/format-array-for-coveo-custom-data.ts +18 -18
  53. package/src/formatting/format-omnibox-metadata.ts +16 -12
  54. package/src/history.spec.ts +197 -195
  55. package/src/history.ts +143 -133
  56. package/src/hook/addDefaultValues.ts +13 -8
  57. package/src/hook/enhanceViewEvent.ts +17 -17
  58. package/src/insight/insightClient.spec.ts +1848 -1717
  59. package/src/insight/insightClient.ts +866 -761
  60. package/src/insight/insightEvents.ts +57 -56
  61. package/src/plugins/BasePlugin.ts +125 -121
  62. package/src/plugins/ec.spec.ts +457 -429
  63. package/src/plugins/ec.ts +202 -199
  64. package/src/plugins/link.spec.ts +183 -159
  65. package/src/plugins/link.ts +88 -85
  66. package/src/plugins/svc.spec.ts +161 -155
  67. package/src/plugins/svc.ts +93 -91
  68. package/src/react-native/index.ts +8 -1
  69. package/src/react-native/react-native-runtime.ts +33 -33
  70. package/src/react-native/react-native-utils.ts +1 -1
  71. package/src/react-native/react-native.spec.ts +31 -21
  72. package/src/searchPage/searchPageClient.spec.ts +1944 -1794
  73. package/src/searchPage/searchPageClient.ts +1261 -1040
  74. package/src/searchPage/searchPageEvents.ts +524 -511
  75. package/src/storage.spec.ts +51 -51
  76. package/src/storage.ts +47 -47
  77. package/dist/definitions/bundle/browser-fetch.d.ts +0 -1
  78. package/dist/definitions/src/coveoua/browser.d.ts +0 -6
  79. package/dist/definitions/src/coveoua/headless.d.ts +0 -6
  80. package/dist/definitions/src/coveoua/library.d.ts +0 -17
  81. package/dist/definitions/src/coveoua/plugins.d.ts +0 -10
  82. package/dist/definitions/src/coveoua/simpleanalytics.d.ts +0 -33
  83. package/dist/definitions/src/react-native/index.d.ts +0 -3
  84. package/dist/definitions/src/react-native/react-native-runtime.d.ts +0 -19
@@ -1,10 +1,12 @@
1
+ import {vi} from 'vitest';
2
+ import type {Mock} from 'vitest';
1
3
  import {CaseAssistClient, CaseAssistClientProvider} from './caseAssistClient';
2
4
  import {
3
- CaseAssistActions,
4
- CaseAssistEvents,
5
- CaseCancelledReasons,
6
- DocumentSuggestion,
7
- FieldSuggestion,
5
+ CaseAssistActions,
6
+ CaseAssistEvents,
7
+ CaseCancelledReasons,
8
+ DocumentSuggestion,
9
+ FieldSuggestion,
8
10
  } from './caseAssistActions';
9
11
  import {mockFetch, lastCallBody} from '../../tests/fetchMock';
10
12
  import {TicketProperties} from '../plugins/svc';
@@ -12,351 +14,380 @@ const {fetchMock, fetchMockBeforeEach} = mockFetch();
12
14
  import doNotTrack from '../donottrack';
13
15
  import {Cookie} from '../cookieutils';
14
16
  import {PartialDocumentInformation} from '../searchPage/searchPageEvents';
15
- jest.mock('../donottrack', () => {
16
- return {
17
- default: jest.fn(),
18
- doNotTrack: jest.fn(),
19
- };
17
+ vi.mock('../donottrack', () => {
18
+ const doNotTrack = vi.fn();
19
+ return {
20
+ __esModule: true,
21
+ default: doNotTrack,
22
+ doNotTrack,
23
+ shouldDisableAnalyticsForPrivacy: (disableBrowserPrivacySignals?: boolean) =>
24
+ disableBrowserPrivacySignals === true ? false : doNotTrack(),
25
+ };
20
26
  });
21
27
 
22
28
  describe('CaseAssistClient', () => {
23
- const exampleSearchHub = 'example origin-level-1';
24
- const exampleOriginLevel2 = 'example origin-level-2';
25
- const exampleOriginLevel3 = 'example origin-level-3';
26
- const exampleOriginContext = 'example origin-context';
27
- const exampleSearchUID = 'foo';
28
- const exampleLanguage = 'en';
29
- const exampleClientId = '123-456';
30
-
31
- let client: CaseAssistClient;
32
-
33
- const provider: CaseAssistClientProvider = {
34
- getOriginLevel1: () => exampleSearchHub,
35
- getOriginLevel2: () => exampleOriginLevel2,
36
- getOriginLevel3: () => exampleOriginLevel3,
37
- getOriginContext: () => exampleOriginContext,
38
- getIsAnonymous: () => false,
39
- getSearchUID: () => exampleSearchUID,
40
- getLanguage: () => exampleLanguage,
29
+ const exampleSearchHub = 'example origin-level-1';
30
+ const exampleOriginLevel2 = 'example origin-level-2';
31
+ const exampleOriginLevel3 = 'example origin-level-3';
32
+ const exampleOriginContext = 'example origin-context';
33
+ const exampleSearchUID = 'foo';
34
+ const exampleLanguage = 'en';
35
+ const exampleClientId = '123-456';
36
+
37
+ let client: CaseAssistClient;
38
+
39
+ const provider: CaseAssistClientProvider = {
40
+ getOriginLevel1: () => exampleSearchHub,
41
+ getOriginLevel2: () => exampleOriginLevel2,
42
+ getOriginLevel3: () => exampleOriginLevel3,
43
+ getOriginContext: () => exampleOriginContext,
44
+ getIsAnonymous: () => false,
45
+ getSearchUID: () => exampleSearchUID,
46
+ getLanguage: () => exampleLanguage,
47
+ };
48
+
49
+ beforeEach(() => {
50
+ fetchMockBeforeEach();
51
+
52
+ client = initClient();
53
+ client.coveoAnalyticsClient.runtime.storage.setItem('visitorId', exampleClientId);
54
+ fetchMock.mock(/.*/, {
55
+ visitorId: 'visitor-id',
56
+ });
57
+ });
58
+
59
+ afterEach(() => {
60
+ fetchMock.reset();
61
+ });
62
+
63
+ const initClient = () => {
64
+ return new CaseAssistClient(
65
+ {
66
+ enableAnalytics: true,
67
+ },
68
+ provider
69
+ );
70
+ };
71
+
72
+ const noTicket: Record<string, unknown> = undefined;
73
+ const noActionData: Record<string, unknown> = undefined;
74
+ const emptyTicket: TicketProperties = {};
75
+
76
+ const fakeTicket: TicketProperties = {
77
+ id: 'the-ticket-id',
78
+ subject: 'the ticket subject',
79
+ description: 'the ticket description',
80
+ category: 'ticket-category',
81
+ productId: 'some-product-id',
82
+ custom: {
83
+ customA: 'custom-a-value',
84
+ customB: 'custom-b-value',
85
+ },
86
+ };
87
+
88
+ const fakeFieldSuggestion = (): FieldSuggestion => {
89
+ return {
90
+ classification: {
91
+ value: 'some-field-value',
92
+ confidence: 0.5,
93
+ },
94
+ classificationId: 'field-suggestion-id',
95
+ fieldName: 'some-field',
96
+ responseId: 'field-suggestion-response-id',
41
97
  };
42
-
43
- beforeEach(() => {
44
- fetchMockBeforeEach();
45
-
46
- client = initClient();
47
- client.coveoAnalyticsClient.runtime.storage.setItem('visitorId', exampleClientId);
48
- fetchMock.mock(/.*/, {
49
- visitorId: 'visitor-id',
50
- });
98
+ };
99
+
100
+ const fakeDocumentSuggestion: DocumentSuggestion = {
101
+ responseId: 'document-suggestion-response-id',
102
+ suggestionId: 'document-suggestion-id',
103
+ permanentId: 'example permanent-id',
104
+ suggestion: {
105
+ documentPosition: 0,
106
+ documentTitle: 'the document title',
107
+ documentUri: 'some-document-uri',
108
+ documentUriHash: 'documenturihash',
109
+ documentUrl: 'some-document-url',
110
+ sourceName: 'example source-name',
111
+ },
112
+ };
113
+
114
+ const expectMatchPayload = (
115
+ actionName: CaseAssistActions,
116
+ actionData: object,
117
+ ticket: TicketProperties
118
+ ) => {
119
+ const body: string = lastCallBody(fetchMock);
120
+ const content = JSON.parse(body);
121
+
122
+ expectMatchActionPayload(content, actionName, actionData);
123
+ expectMatchTicketPayload(content, ticket);
124
+ expectMatchProperty(content, 'searchHub', exampleSearchHub);
125
+ };
126
+
127
+ const expectMatchDocumentPayload = (
128
+ actionCause: CaseAssistActions,
129
+ doc: PartialDocumentInformation,
130
+ meta = {}
131
+ ) => {
132
+ const body: string = lastCallBody(fetchMock);
133
+ const customData = {...meta};
134
+ expect(JSON.parse(body.toString())).toMatchObject({
135
+ actionCause,
136
+ customData,
137
+ language: exampleLanguage,
138
+ clientId: exampleClientId,
139
+ originContext: exampleOriginContext,
140
+ originLevel1: exampleSearchHub,
141
+ originLevel2: exampleOriginLevel2,
142
+ originLevel3: exampleOriginLevel3,
143
+ ...doc,
51
144
  });
52
-
53
- afterEach(() => {
54
- fetchMock.reset();
145
+ };
146
+
147
+ const expectMatchActionPayload = (
148
+ content: Record<string, unknown>,
149
+ actionName: CaseAssistActions,
150
+ actionData: object
151
+ ) => {
152
+ expectMatchProperty(content, 'ec', 'svc');
153
+ expectMatchProperty(content, 'svc_action', actionName);
154
+ expectMatchProperty(content, 'svc_action_data', actionData);
155
+
156
+ const expectedEvent =
157
+ actionName === CaseAssistActions.enterInterface
158
+ ? CaseAssistEvents.flowStart
159
+ : CaseAssistEvents.click;
160
+ expectMatchProperty(content, 'ea', expectedEvent);
161
+ };
162
+
163
+ const expectMatchTicketPayload = (
164
+ content: Record<string, unknown>,
165
+ ticket?: TicketProperties
166
+ ) => {
167
+ expectMatchProperty(content, 'svc_ticket_id', ticket?.id);
168
+ expectMatchProperty(content, 'svc_ticket_subject', ticket?.subject);
169
+ expectMatchProperty(content, 'svc_ticket_description', ticket?.description);
170
+ expectMatchProperty(content, 'svc_ticket_category', ticket?.category);
171
+ expectMatchProperty(content, 'svc_ticket_product_id', ticket?.productId);
172
+ expectMatchProperty(content, 'svc_ticket_custom', ticket?.custom);
173
+ };
174
+
175
+ const expectMatchProperty = (
176
+ content: Record<string, unknown>,
177
+ propName: string,
178
+ propValue: unknown
179
+ ) => {
180
+ if (typeof propValue !== 'undefined') {
181
+ if (typeof propValue === 'object') {
182
+ expect(content).toHaveProperty(propName);
183
+ expect(content[propName]).toMatchObject(propValue as object);
184
+ } else {
185
+ expect(content).toHaveProperty(propName, propValue);
186
+ }
187
+ } else {
188
+ expect(content).not.toHaveProperty(propName);
189
+ }
190
+ };
191
+
192
+ it('should have #enableAnalytics default to #true', async () => {
193
+ client = new CaseAssistClient({});
194
+
195
+ await client.logEnterInterface({
196
+ ticket: emptyTicket,
55
197
  });
56
198
 
57
- const initClient = () => {
58
- return new CaseAssistClient(
59
- {
60
- enableAnalytics: true,
61
- },
62
- provider,
63
- );
64
- };
65
-
66
- const noTicket: Record<string, unknown> = undefined;
67
- const noActionData: Record<string, unknown> = undefined;
68
- const emptyTicket: TicketProperties = {};
69
-
70
- const fakeTicket: TicketProperties = {
71
- id: 'the-ticket-id',
72
- subject: 'the ticket subject',
73
- description: 'the ticket description',
74
- category: 'ticket-category',
75
- productId: 'some-product-id',
76
- custom: {
77
- customA: 'custom-a-value',
78
- customB: 'custom-b-value',
79
- },
80
- };
81
-
82
- const fakeFieldSuggestion = (): FieldSuggestion => {
83
- return {
84
- classification: {
85
- value: 'some-field-value',
86
- confidence: 0.5,
87
- },
88
- classificationId: 'field-suggestion-id',
89
- fieldName: 'some-field',
90
- responseId: 'field-suggestion-response-id',
91
- };
92
- };
93
-
94
- const fakeDocumentSuggestion: DocumentSuggestion = {
95
- responseId: 'document-suggestion-response-id',
96
- suggestionId: 'document-suggestion-id',
97
- permanentId: 'example permanent-id',
98
- suggestion: {
99
- documentPosition: 0,
100
- documentTitle: 'the document title',
101
- documentUri: 'some-document-uri',
102
- documentUriHash: 'documenturihash',
103
- documentUrl: 'some-document-url',
104
- sourceName: 'example source-name',
105
- },
106
- };
199
+ expect(fetchMock.called()).toBe(true);
200
+ });
107
201
 
108
- const expectMatchPayload = (actionName: CaseAssistActions, actionData: Object, ticket: TicketProperties) => {
109
- const body: string = lastCallBody(fetchMock);
110
- const content = JSON.parse(body);
111
-
112
- expectMatchActionPayload(content, actionName, actionData);
113
- expectMatchTicketPayload(content, ticket);
114
- expectMatchProperty(content, 'searchHub', exampleSearchHub);
115
- };
116
-
117
- const expectMatchDocumentPayload = (actionCause: CaseAssistActions, doc: PartialDocumentInformation, meta = {}) => {
118
- const body: string = lastCallBody(fetchMock);
119
- const customData = {...meta};
120
- expect(JSON.parse(body.toString())).toMatchObject({
121
- actionCause,
122
- customData,
123
- language: exampleLanguage,
124
- clientId: exampleClientId,
125
- originContext: exampleOriginContext,
126
- originLevel1: exampleSearchHub,
127
- originLevel2: exampleOriginLevel2,
128
- originLevel3: exampleOriginLevel3,
129
- ...doc,
130
- });
131
- };
132
-
133
- const expectMatchActionPayload = (
134
- content: Record<string, unknown>,
135
- actionName: CaseAssistActions,
136
- actionData: Object,
137
- ) => {
138
- expectMatchProperty(content, 'ec', 'svc');
139
- expectMatchProperty(content, 'svc_action', actionName);
140
- expectMatchProperty(content, 'svc_action_data', actionData);
141
-
142
- const expectedEvent =
143
- actionName === CaseAssistActions.enterInterface ? CaseAssistEvents.flowStart : CaseAssistEvents.click;
144
- expectMatchProperty(content, 'ea', expectedEvent);
145
- };
146
-
147
- const expectMatchTicketPayload = (content: Record<string, unknown>, ticket?: TicketProperties) => {
148
- expectMatchProperty(content, 'svc_ticket_id', ticket?.id);
149
- expectMatchProperty(content, 'svc_ticket_subject', ticket?.subject);
150
- expectMatchProperty(content, 'svc_ticket_description', ticket?.description);
151
- expectMatchProperty(content, 'svc_ticket_category', ticket?.category);
152
- expectMatchProperty(content, 'svc_ticket_product_id', ticket?.productId);
153
- expectMatchProperty(content, 'svc_ticket_custom', ticket?.custom);
154
- };
155
-
156
- const expectMatchProperty = (content: Record<string, unknown>, propName: string, propValue: unknown) => {
157
- if (typeof propValue !== 'undefined') {
158
- if (typeof propValue === 'object') {
159
- expect(content).toHaveProperty(propName);
160
- expect(content[propName]).toMatchObject(propValue as object);
161
- } else {
162
- expect(content).toHaveProperty(propName, propValue);
163
- }
164
- } else {
165
- expect(content).not.toHaveProperty(propName);
166
- }
167
- };
168
-
169
- it('should have #enableAnalytics default to #true', async () => {
170
- client = new CaseAssistClient({});
171
-
172
- await client.logEnterInterface({
173
- ticket: emptyTicket,
174
- });
175
-
176
- expect(fetchMock.called()).toBe(true);
202
+ it('should not send events when #enableAnalytics option is #false', async () => {
203
+ client = new CaseAssistClient({
204
+ enableAnalytics: false,
177
205
  });
178
206
 
179
- it('should not send events when #enableAnalytics option is #false', async () => {
180
- client = new CaseAssistClient({
181
- enableAnalytics: false,
182
- });
183
-
184
- await client.logEnterInterface({
185
- ticket: emptyTicket,
186
- });
187
-
188
- expect(fetchMock.called()).toBe(false);
207
+ await client.logEnterInterface({
208
+ ticket: emptyTicket,
189
209
  });
190
210
 
191
- it('should not send events when doNotTrack is enabled', async () => {
192
- (doNotTrack as jest.Mock).mockImplementationOnce(() => true);
211
+ expect(fetchMock.called()).toBe(false);
212
+ });
193
213
 
194
- client = new CaseAssistClient({});
214
+ it('should not send events when doNotTrack is enabled', async () => {
215
+ (doNotTrack as Mock).mockImplementationOnce(() => true);
195
216
 
196
- await client.logEnterInterface({
197
- ticket: emptyTicket,
198
- });
217
+ client = new CaseAssistClient({});
199
218
 
200
- expect(fetchMock.called()).toBe(false);
219
+ await client.logEnterInterface({
220
+ ticket: emptyTicket,
201
221
  });
202
222
 
203
- it('should not send events after #disable function is called', async () => {
204
- client.disable();
223
+ expect(fetchMock.called()).toBe(false);
224
+ });
205
225
 
206
- await client.logEnterInterface({
207
- ticket: emptyTicket,
208
- });
226
+ it('should not send events after #disable function is called', async () => {
227
+ client.disable();
209
228
 
210
- expect(fetchMock.called()).toBe(false);
229
+ await client.logEnterInterface({
230
+ ticket: emptyTicket,
211
231
  });
212
232
 
213
- it('disabling does not delete the visitorId', () => {
214
- const visitorId = 'uuid';
215
- Cookie.set('coveo_visitorId', visitorId);
233
+ expect(fetchMock.called()).toBe(false);
234
+ });
216
235
 
217
- expect(Cookie.get('coveo_visitorId')).toBe(visitorId);
218
- client.disable();
219
- expect(Cookie.get('coveo_visitorId')).toBe(visitorId);
220
- });
236
+ it('disabling does not delete the visitorId', () => {
237
+ const visitorId = 'uuid';
238
+ Cookie.set('coveo_visitorId', visitorId);
221
239
 
222
- it('should send events after #enable function is called', async () => {
223
- client = new CaseAssistClient({
224
- enableAnalytics: false,
225
- });
240
+ expect(Cookie.get('coveo_visitorId')).toBe(visitorId);
241
+ client.disable();
242
+ expect(Cookie.get('coveo_visitorId')).toBe(visitorId);
243
+ });
226
244
 
227
- client.enable();
245
+ it('should send events after #enable function is called', async () => {
246
+ client = new CaseAssistClient({
247
+ enableAnalytics: false,
248
+ });
228
249
 
229
- await client.logEnterInterface({
230
- ticket: emptyTicket,
231
- });
250
+ client.enable();
232
251
 
233
- expect(fetchMock.called()).toBe(true);
252
+ await client.logEnterInterface({
253
+ ticket: emptyTicket,
234
254
  });
235
255
 
236
- it('should send proper payload for #logEnterInterface', async () => {
237
- await client.logEnterInterface({
238
- ticket: emptyTicket,
239
- });
256
+ expect(fetchMock.called()).toBe(true);
257
+ });
240
258
 
241
- expectMatchPayload(CaseAssistActions.enterInterface, noActionData, noTicket);
259
+ it('should send proper payload for #logEnterInterface', async () => {
260
+ await client.logEnterInterface({
261
+ ticket: emptyTicket,
242
262
  });
243
263
 
244
- it('should send proper payload for #logUpdateCaseField', async () => {
245
- await client.logUpdateCaseField({
246
- fieldName: 'subject',
247
- ticket: fakeTicket,
248
- });
264
+ expectMatchPayload(CaseAssistActions.enterInterface, noActionData, noTicket);
265
+ });
249
266
 
250
- expectMatchPayload(CaseAssistActions.fieldUpdate, {fieldName: 'subject'}, fakeTicket);
267
+ it('should send proper payload for #logUpdateCaseField', async () => {
268
+ await client.logUpdateCaseField({
269
+ fieldName: 'subject',
270
+ ticket: fakeTicket,
251
271
  });
252
272
 
253
- it('should send proper payload for #logSelectFieldSuggestion', async () => {
254
- await client.logSelectFieldSuggestion({
255
- suggestion: fakeFieldSuggestion(),
256
- ticket: fakeTicket,
257
- });
273
+ expectMatchPayload(CaseAssistActions.fieldUpdate, {fieldName: 'subject'}, fakeTicket);
274
+ });
258
275
 
259
- expectMatchPayload(CaseAssistActions.fieldSuggestionClick, fakeFieldSuggestion(), fakeTicket);
276
+ it('should send proper payload for #logSelectFieldSuggestion', async () => {
277
+ await client.logSelectFieldSuggestion({
278
+ suggestion: fakeFieldSuggestion(),
279
+ ticket: fakeTicket,
260
280
  });
261
281
 
262
- it('should send proper payload for #logSelectFieldSuggestion when the autoSelection property is set to true', async () => {
263
- const myFakeFieldSuggestion = fakeFieldSuggestion();
264
- myFakeFieldSuggestion.autoSelection = true;
265
- await client.logSelectFieldSuggestion({
266
- suggestion: myFakeFieldSuggestion,
267
- ticket: fakeTicket,
268
- });
282
+ expectMatchPayload(CaseAssistActions.fieldSuggestionClick, fakeFieldSuggestion(), fakeTicket);
283
+ });
269
284
 
270
- expectMatchPayload(CaseAssistActions.fieldSuggestionClick, myFakeFieldSuggestion, fakeTicket);
285
+ it('should send proper payload for #logSelectFieldSuggestion when the autoSelection property is set to true', async () => {
286
+ const myFakeFieldSuggestion = fakeFieldSuggestion();
287
+ myFakeFieldSuggestion.autoSelection = true;
288
+ await client.logSelectFieldSuggestion({
289
+ suggestion: myFakeFieldSuggestion,
290
+ ticket: fakeTicket,
271
291
  });
272
292
 
273
- it('should send proper payload for #logSelectDocumentSuggestion', async () => {
274
- await client.logSelectDocumentSuggestion({
275
- suggestion: fakeDocumentSuggestion,
276
- ticket: fakeTicket,
277
- });
293
+ expectMatchPayload(CaseAssistActions.fieldSuggestionClick, myFakeFieldSuggestion, fakeTicket);
294
+ });
278
295
 
279
- expectMatchDocumentPayload(CaseAssistActions.documentSuggestionClick, fakeDocumentSuggestion.suggestion, {
280
- contentIDKey: 'permanentId',
281
- contentIDValue: fakeDocumentSuggestion.permanentId,
282
- });
296
+ it('should send proper payload for #logSelectDocumentSuggestion', async () => {
297
+ await client.logSelectDocumentSuggestion({
298
+ suggestion: fakeDocumentSuggestion,
299
+ ticket: fakeTicket,
283
300
  });
284
301
 
285
- it('should send proper payload for #logQuickviewDocumentSuggestion', async () => {
286
- await client.logQuickviewDocumentSuggestion({
287
- suggestion: fakeDocumentSuggestion,
288
- ticket: fakeTicket,
289
- });
290
-
291
- expectMatchDocumentPayload(CaseAssistActions.documentSuggestionQuickview, fakeDocumentSuggestion.suggestion, {
292
- contentIDKey: 'permanentId',
293
- contentIDValue: fakeDocumentSuggestion.permanentId,
294
- });
302
+ expectMatchDocumentPayload(
303
+ CaseAssistActions.documentSuggestionClick,
304
+ fakeDocumentSuggestion.suggestion,
305
+ {
306
+ contentIDKey: 'permanentId',
307
+ contentIDValue: fakeDocumentSuggestion.permanentId,
308
+ }
309
+ );
310
+ });
311
+
312
+ it('should send proper payload for #logQuickviewDocumentSuggestion', async () => {
313
+ await client.logQuickviewDocumentSuggestion({
314
+ suggestion: fakeDocumentSuggestion,
315
+ ticket: fakeTicket,
295
316
  });
296
317
 
297
- it('should send proper payload for #logRateDocumentSuggestion', async () => {
298
- const rating = 0.8;
299
-
300
- await client.logRateDocumentSuggestion({
301
- rating,
302
- suggestion: fakeDocumentSuggestion,
303
- ticket: fakeTicket,
304
- });
305
-
306
- expectMatchPayload(
307
- CaseAssistActions.suggestionRate,
308
- {
309
- ...fakeDocumentSuggestion,
310
- rate: rating,
311
- },
312
- fakeTicket,
313
- );
318
+ expectMatchDocumentPayload(
319
+ CaseAssistActions.documentSuggestionQuickview,
320
+ fakeDocumentSuggestion.suggestion,
321
+ {
322
+ contentIDKey: 'permanentId',
323
+ contentIDValue: fakeDocumentSuggestion.permanentId,
324
+ }
325
+ );
326
+ });
327
+
328
+ it('should send proper payload for #logRateDocumentSuggestion', async () => {
329
+ const rating = 0.8;
330
+
331
+ await client.logRateDocumentSuggestion({
332
+ rating,
333
+ suggestion: fakeDocumentSuggestion,
334
+ ticket: fakeTicket,
314
335
  });
315
336
 
316
- it('should send proper payload for #logMoveToNextCaseStep', async () => {
317
- const stageName = 'stage 1';
337
+ expectMatchPayload(
338
+ CaseAssistActions.suggestionRate,
339
+ {
340
+ ...fakeDocumentSuggestion,
341
+ rate: rating,
342
+ },
343
+ fakeTicket
344
+ );
345
+ });
346
+
347
+ it('should send proper payload for #logMoveToNextCaseStep', async () => {
348
+ const stageName = 'stage 1';
349
+
350
+ await client.logMoveToNextCaseStep({
351
+ ticket: fakeTicket,
352
+ stage: stageName,
353
+ });
318
354
 
319
- await client.logMoveToNextCaseStep({
320
- ticket: fakeTicket,
321
- stage: stageName,
322
- });
355
+ expectMatchPayload(CaseAssistActions.nextCaseStep, {stage: stageName}, fakeTicket);
356
+ });
323
357
 
324
- expectMatchPayload(CaseAssistActions.nextCaseStep, {stage: stageName}, fakeTicket);
358
+ it('should send proper payload for #logCaseCancelled', async () => {
359
+ await client.logCaseCancelled({
360
+ ticket: fakeTicket,
325
361
  });
326
362
 
327
- it('should send proper payload for #logCaseCancelled', async () => {
328
- await client.logCaseCancelled({
329
- ticket: fakeTicket,
330
- });
331
-
332
- expectMatchPayload(
333
- CaseAssistActions.caseCancelled,
334
- {
335
- reason: CaseCancelledReasons.quit,
336
- },
337
- fakeTicket,
338
- );
363
+ expectMatchPayload(
364
+ CaseAssistActions.caseCancelled,
365
+ {
366
+ reason: CaseCancelledReasons.quit,
367
+ },
368
+ fakeTicket
369
+ );
370
+ });
371
+
372
+ it('should send proper payload for #logCaseSolved', async () => {
373
+ await client.logCaseSolved({
374
+ ticket: fakeTicket,
339
375
  });
340
376
 
341
- it('should send proper payload for #logCaseSolved', async () => {
342
- await client.logCaseSolved({
343
- ticket: fakeTicket,
344
- });
345
-
346
- expectMatchPayload(
347
- CaseAssistActions.caseSolved,
348
- {
349
- reason: CaseCancelledReasons.solved,
350
- },
351
- fakeTicket,
352
- );
377
+ expectMatchPayload(
378
+ CaseAssistActions.caseSolved,
379
+ {
380
+ reason: CaseCancelledReasons.solved,
381
+ },
382
+ fakeTicket
383
+ );
384
+ });
385
+
386
+ it('should send proper payload for #logCaseCreated', async () => {
387
+ await client.logCaseCreated({
388
+ ticket: fakeTicket,
353
389
  });
354
390
 
355
- it('should send proper payload for #logCaseCreated', async () => {
356
- await client.logCaseCreated({
357
- ticket: fakeTicket,
358
- });
359
-
360
- expectMatchPayload(CaseAssistActions.caseCreated, noActionData, fakeTicket);
361
- });
391
+ expectMatchPayload(CaseAssistActions.caseCreated, noActionData, fakeTicket);
392
+ });
362
393
  });