coveo.analytics 2.18.63 → 2.18.64

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.
@@ -58,6 +58,7 @@ export interface FieldSuggestion {
58
58
  value: string;
59
59
  confidence: number;
60
60
  };
61
+ autoSelection?: boolean;
61
62
  }
62
63
  export interface DocumentSuggestion {
63
64
  suggestionId: string;
@@ -69,4 +70,6 @@ export interface DocumentSuggestion {
69
70
  documentUrl: string;
70
71
  documentPosition: number;
71
72
  };
73
+ fromQuickview?: boolean;
74
+ openDocument?: boolean;
72
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coveo.analytics",
3
- "version": "2.18.63",
3
+ "version": "2.18.64",
4
4
  "description": "📈 Coveo analytics client (node and browser compatible) ",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.es.js",
@@ -71,6 +71,7 @@ export interface FieldSuggestion {
71
71
  value: string;
72
72
  confidence: number;
73
73
  };
74
+ autoSelection?: boolean;
74
75
  }
75
76
 
76
77
  export interface DocumentSuggestion {
@@ -83,4 +84,6 @@ export interface DocumentSuggestion {
83
84
  documentUrl: string;
84
85
  documentPosition: number;
85
86
  };
87
+ fromQuickview?: boolean;
88
+ openDocument?: boolean;
86
89
  }
@@ -50,26 +50,30 @@ describe('CaseAssistClient', () => {
50
50
  },
51
51
  };
52
52
 
53
- const fakeFieldSuggestion: FieldSuggestion = {
54
- classification: {
55
- value: 'some-field-value',
56
- confidence: 0.5,
57
- },
58
- classificationId: 'field-suggestion-id',
59
- fieldName: 'some-field',
60
- responseId: 'field-suggestion-response-id',
53
+ const fakeFieldSuggestion = (): FieldSuggestion => {
54
+ return {
55
+ classification: {
56
+ value: 'some-field-value',
57
+ confidence: 0.5,
58
+ },
59
+ classificationId: 'field-suggestion-id',
60
+ fieldName: 'some-field',
61
+ responseId: 'field-suggestion-response-id',
62
+ };
61
63
  };
62
64
 
63
- const fakeDocumentSuggestion: DocumentSuggestion = {
64
- responseId: 'document-suggestion-response-id',
65
- suggestionId: 'document-suggestion-id',
66
- suggestion: {
67
- documentPosition: 0,
68
- documentTitle: 'the document title',
69
- documentUri: 'some-document-uri',
70
- documentUriHash: 'documenturihash',
71
- documentUrl: 'some-document-url',
72
- },
65
+ const fakeDocumentSuggestion = (): DocumentSuggestion => {
66
+ return {
67
+ responseId: 'document-suggestion-response-id',
68
+ suggestionId: 'document-suggestion-id',
69
+ suggestion: {
70
+ documentPosition: 0,
71
+ documentTitle: 'the document title',
72
+ documentUri: 'some-document-uri',
73
+ documentUriHash: 'documenturihash',
74
+ documentUrl: 'some-document-url',
75
+ },
76
+ };
73
77
  };
74
78
 
75
79
  const expectMatchPayload = (actionName: CaseAssistActions, actionData: Object, ticket: TicketProperties) => {
@@ -181,20 +185,53 @@ describe('CaseAssistClient', () => {
181
185
 
182
186
  it('should send proper payload for #logSelectFieldSuggestion', async () => {
183
187
  await client.logSelectFieldSuggestion({
184
- suggestion: fakeFieldSuggestion,
188
+ suggestion: fakeFieldSuggestion(),
185
189
  ticket: fakeTicket,
186
190
  });
187
191
 
188
- expectMatchPayload(CaseAssistActions.fieldSuggestionClick, fakeFieldSuggestion, fakeTicket);
192
+ expectMatchPayload(CaseAssistActions.fieldSuggestionClick, fakeFieldSuggestion(), fakeTicket);
193
+ });
194
+
195
+ it('should send proper payload for #logSelectFieldSuggestion when the autoSelection property is set to true', async () => {
196
+ const myFakeFieldSuggestion = fakeFieldSuggestion();
197
+ myFakeFieldSuggestion.autoSelection = true;
198
+ await client.logSelectFieldSuggestion({
199
+ suggestion: myFakeFieldSuggestion,
200
+ ticket: fakeTicket,
201
+ });
202
+
203
+ expectMatchPayload(CaseAssistActions.fieldSuggestionClick, myFakeFieldSuggestion, fakeTicket);
189
204
  });
190
205
 
191
206
  it('should send proper payload for #logSelectDocumentSuggestion', async () => {
192
207
  await client.logSelectDocumentSuggestion({
193
- suggestion: fakeDocumentSuggestion,
208
+ suggestion: fakeDocumentSuggestion(),
209
+ ticket: fakeTicket,
210
+ });
211
+
212
+ expectMatchPayload(CaseAssistActions.suggestionClick, fakeDocumentSuggestion(), fakeTicket);
213
+ });
214
+
215
+ it('should send proper payload for #logSelectDocumentSuggestion when the fromQuickview property is set to true', async () => {
216
+ const myFakeDocumentSuggestion = fakeDocumentSuggestion();
217
+ myFakeDocumentSuggestion.fromQuickview = true;
218
+ await client.logSelectDocumentSuggestion({
219
+ suggestion: myFakeDocumentSuggestion,
220
+ ticket: fakeTicket,
221
+ });
222
+
223
+ expectMatchPayload(CaseAssistActions.suggestionClick, myFakeDocumentSuggestion, fakeTicket);
224
+ });
225
+
226
+ it('should send proper payload for #logSelectDocumentSuggestion when the openDocument property is set to true', async () => {
227
+ const myFakeDocumentSuggestion = fakeDocumentSuggestion();
228
+ myFakeDocumentSuggestion.openDocument = true;
229
+ await client.logSelectDocumentSuggestion({
230
+ suggestion: myFakeDocumentSuggestion,
194
231
  ticket: fakeTicket,
195
232
  });
196
233
 
197
- expectMatchPayload(CaseAssistActions.suggestionClick, fakeDocumentSuggestion, fakeTicket);
234
+ expectMatchPayload(CaseAssistActions.suggestionClick, myFakeDocumentSuggestion, fakeTicket);
198
235
  });
199
236
 
200
237
  it('should send proper payload for #logRateDocumentSuggestion', async () => {
@@ -202,14 +239,14 @@ describe('CaseAssistClient', () => {
202
239
 
203
240
  await client.logRateDocumentSuggestion({
204
241
  rating,
205
- suggestion: fakeDocumentSuggestion,
242
+ suggestion: fakeDocumentSuggestion(),
206
243
  ticket: fakeTicket,
207
244
  });
208
245
 
209
246
  expectMatchPayload(
210
247
  CaseAssistActions.suggestionRate,
211
248
  {
212
- ...fakeDocumentSuggestion,
249
+ ...fakeDocumentSuggestion(),
213
250
  rate: rating,
214
251
  },
215
252
  fakeTicket