@nyaruka/temba-components 0.109.1 → 0.110.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 (86) hide show
  1. package/CHANGELOG.md +19 -2
  2. package/dist/static/svg/index.svg +1 -1
  3. package/dist/temba-components.js +362 -355
  4. package/dist/temba-components.js.map +1 -1
  5. package/out-tsc/src/compose/Compose.js +62 -106
  6. package/out-tsc/src/compose/Compose.js.map +1 -1
  7. package/out-tsc/src/contacts/ContactChat.js +64 -59
  8. package/out-tsc/src/contacts/ContactChat.js.map +1 -1
  9. package/out-tsc/src/vectoricon/index.js +1 -2
  10. package/out-tsc/src/vectoricon/index.js.map +1 -1
  11. package/out-tsc/test/temba-compose.test.js +24 -440
  12. package/out-tsc/test/temba-compose.test.js.map +1 -1
  13. package/out-tsc/test/temba-contact-chat.test.js +30 -167
  14. package/out-tsc/test/temba-contact-chat.test.js.map +1 -1
  15. package/package.json +1 -1
  16. package/screenshots/truth/compose/attachments-tab.png +0 -0
  17. package/screenshots/truth/compose/attachments-with-failures.png +0 -0
  18. package/screenshots/truth/compose/attachments-with-files-and-failures.png +0 -0
  19. package/screenshots/truth/compose/attachments-with-files-focused.png +0 -0
  20. package/screenshots/truth/compose/attachments-with-files.png +0 -0
  21. package/screenshots/truth/compose/intial-text.png +0 -0
  22. package/screenshots/truth/compose/no-counter.png +0 -0
  23. package/screenshots/truth/compose/wraps-text-and-spaces.png +0 -0
  24. package/screenshots/truth/compose/wraps-text-and-url.png +0 -0
  25. package/screenshots/truth/compose/wraps-text-no-spaces.png +0 -0
  26. package/screenshots/truth/contacts/chat-failure.png +0 -0
  27. package/src/compose/Compose.ts +69 -103
  28. package/src/contacts/ContactChat.ts +69 -70
  29. package/src/untyped.d.ts +1 -1
  30. package/src/vectoricon/index.ts +1 -2
  31. package/static/svg/index.svg +1 -1
  32. package/test/temba-compose.test.ts +29 -590
  33. package/test/temba-contact-chat.test.ts +30 -263
  34. package/web-test-runner.config.mjs +1 -0
  35. package/screenshots/truth/compose/attachments-and-send-button.png +0 -0
  36. package/screenshots/truth/compose/attachments-no-send-button.png +0 -0
  37. package/screenshots/truth/compose/attachments-with-all-files-and-click-send.png +0 -0
  38. package/screenshots/truth/compose/attachments-with-all-files.png +0 -0
  39. package/screenshots/truth/compose/attachments-with-failure-files.png +0 -0
  40. package/screenshots/truth/compose/attachments-with-success-files-and-click-send.png +0 -0
  41. package/screenshots/truth/compose/attachments-with-success-files.png +0 -0
  42. package/screenshots/truth/compose/chatbox-attachments-counter-and-send-button.png +0 -0
  43. package/screenshots/truth/compose/chatbox-attachments-counter-no-send-button.png +0 -0
  44. package/screenshots/truth/compose/chatbox-attachments-no-counter-and-send-button.png +0 -0
  45. package/screenshots/truth/compose/chatbox-attachments-no-counter-no-send-button.png +0 -0
  46. package/screenshots/truth/compose/chatbox-counter-and-send-button.png +0 -0
  47. package/screenshots/truth/compose/chatbox-counter-no-send-button.png +0 -0
  48. package/screenshots/truth/compose/chatbox-no-counter-and-send-button.png +0 -0
  49. package/screenshots/truth/compose/chatbox-no-counter-no-send-button.png +0 -0
  50. package/screenshots/truth/compose/chatbox-no-text-attachments-with-all-files-and-click-send.png +0 -0
  51. package/screenshots/truth/compose/chatbox-no-text-attachments-with-all-files.png +0 -0
  52. package/screenshots/truth/compose/chatbox-no-text-attachments-with-failure-files.png +0 -0
  53. package/screenshots/truth/compose/chatbox-no-text-attachments-with-success-files-and-click-send.png +0 -0
  54. package/screenshots/truth/compose/chatbox-no-text-attachments-with-success-files.png +0 -0
  55. package/screenshots/truth/compose/chatbox-with-text-and-click-send.png +0 -0
  56. package/screenshots/truth/compose/chatbox-with-text-and-hit-enter.png +0 -0
  57. package/screenshots/truth/compose/chatbox-with-text-and-spaces.png +0 -0
  58. package/screenshots/truth/compose/chatbox-with-text-and-url.png +0 -0
  59. package/screenshots/truth/compose/chatbox-with-text-attachments-no-files-and-click-send.png +0 -0
  60. package/screenshots/truth/compose/chatbox-with-text-attachments-no-files-and-hit-enter.png +0 -0
  61. package/screenshots/truth/compose/chatbox-with-text-attachments-no-files.png +0 -0
  62. package/screenshots/truth/compose/chatbox-with-text-attachments-with-all-files-and-click-send.png +0 -0
  63. package/screenshots/truth/compose/chatbox-with-text-attachments-with-all-files-and-hit-enter.png +0 -0
  64. package/screenshots/truth/compose/chatbox-with-text-attachments-with-all-files.png +0 -0
  65. package/screenshots/truth/compose/chatbox-with-text-attachments-with-failure-files.png +0 -0
  66. package/screenshots/truth/compose/chatbox-with-text-attachments-with-success-files-and-click-send.png +0 -0
  67. package/screenshots/truth/compose/chatbox-with-text-attachments-with-success-files-and-hit-enter.png +0 -0
  68. package/screenshots/truth/compose/chatbox-with-text-attachments-with-success-files.png +0 -0
  69. package/screenshots/truth/compose/chatbox-with-text-no-spaces.png +0 -0
  70. package/screenshots/truth/compose/chatbox-with-text.png +0 -0
  71. package/screenshots/truth/contacts/compose-attachments-no-text-failure.png +0 -0
  72. package/screenshots/truth/contacts/compose-text-and-attachments-failure-attachments.png +0 -0
  73. package/screenshots/truth/contacts/compose-text-and-attachments-failure-generic.png +0 -0
  74. package/screenshots/truth/contacts/compose-text-and-attachments-failure-text-and-attachments.png +0 -0
  75. package/screenshots/truth/contacts/compose-text-and-attachments-failure-text.png +0 -0
  76. package/screenshots/truth/contacts/compose-text-no-attachments-failure.png +0 -0
  77. package/screenshots/truth/contacts/compose-text-no-attachments-success.png +0 -0
  78. package/static/svg/work/traced/folder-shield.svg +0 -1
  79. package/static/svg/work/used/folder-shield.svg +0 -3
  80. /package/screenshots/truth/contacts/{compose-attachments-no-text-success.png → chat-for-active-contact.png} +0 -0
  81. /package/screenshots/truth/contacts/{contact-archived-hide-chatbox.png → chat-for-archived-contact.png} +0 -0
  82. /package/screenshots/truth/contacts/{contact-blocked-hide-chatbox.png → chat-for-blocked-contact.png} +0 -0
  83. /package/screenshots/truth/contacts/{contact-stopped-hide-chatbox.png → chat-for-stopped-contact.png} +0 -0
  84. /package/screenshots/truth/contacts/{compose-text-and-attachments-success.png → chat-sends-attachments-only.png} +0 -0
  85. /package/screenshots/truth/contacts/{contact-active-default.png → chat-sends-text-and-attachments.png} +0 -0
  86. /package/screenshots/truth/contacts/{contact-active-show-chatbox.png → chat-sends-text-only.png} +0 -0
@@ -1,7 +1,6 @@
1
1
  import { assert, expect } from '@open-wc/testing';
2
2
  import { Compose } from '../src/compose/Compose';
3
3
  import { assertScreenshot, getClip, getComponent } from './utils.test';
4
- import { Completion } from '../src/completion/Completion';
5
4
  import { DEFAULT_MEDIA_ENDPOINT } from '../src/utils';
6
5
  import { Attachment } from '../src/interfaces';
7
6
 
@@ -52,10 +51,6 @@ const getComposeValue = (value: any): string => {
52
51
  export const getValidText = () => {
53
52
  return 'sà-wàd-dee!';
54
53
  };
55
- // for a server limit of 640 chars, return a string that is 640+ chars
56
- export const getInvalidText = () => {
57
- return "p}h<r0P<?SCIbV1+pwW1Hj8g^J&=Sm2f)K=5LjFFUZ№5@ybpoLZ7DJ(27qdWxQMaO)I1nB4(D%d3c(H)QXOF6F?4>&d{lhd5?0`Lio!yAGMO№*AxN5{z5s.IO*dy?tm}vXJ#Lf-HlD;xmNp}0<P42=w#ll9)B-e9>Q#'{~Vp<dl:xC9`T^lhh@TosCZ^:(H<Ji<E(~PojvYk^rPB+poYy^Ne~Su1:9?IgH'4S5Q9v0g№FEIUc~!{S7;746j'Sd@Nfu3=x?CsuR;YLP4j+AOzDARZG?0(Ji(NMg=r%n0Fq?R1?E%Yf`bcoVZAJ^bl0J'^@;lH>T.HmxYxwS;1?(bfrh?pRdd73:iMxrfx5luQ(}<dCD1b3g'G0CtkB№;8KkbL=>krG{RO%Va4wwr%P>jE*+n(E11}Ju9#<.f^)<MTH09^b{RQv7~H`#@Hda6{MV&H@xdyEKq#M@nZng8WTU66!F@*!)w*EpQ+65XKuQCaESgq=PHmtqi@l;F?PHvl^g@Z:+}}Xyr`IC2=3?20^I'qSU*tkyinM^JF.ZI>}~XzRQJn№v3o-w?Vy&gC:c.l(&9{`M#-'N}{T#7lw8(4:iY621'>C^.&hVZn:R!G}Ek){D#'KkiJWawq#7~GLBN*?V!ncw)d%&(tXj";
58
- };
59
54
 
60
55
  // valid = attachments that are uploaded sent to the server when the user clicks send
61
56
  export const getValidAttachments = (numFiles = 2): Attachment[] => {
@@ -77,40 +72,17 @@ export const getValidAttachments = (numFiles = 2): Attachment[] => {
77
72
  }
78
73
  return attachments;
79
74
  };
80
- // invalid = attachments that are not uploaded and are not sent to the server when the user clicks send
81
- export const getInvalidAttachments = (): Attachment[] => {
82
- const f1 = 'f1';
83
- const fail1 = {
84
- uuid: f1,
85
- content_type: 'image/png',
86
- type: 'image/png',
87
- filename: 'name_' + f1,
88
- url: 'url_' + f1,
89
- size: 26624,
90
- error: 'Limit for file uploads is 25.0 MB'
91
- } as Attachment;
92
- const f2 = 'f2';
93
- const fail2 = {
94
- uuid: f2,
95
- content_type: 'application/octet-stream',
96
- type: 'application/octet-stream',
97
- filename: 'name_' + f2,
98
- url: 'url_' + f2,
99
- size: 1024,
100
- error: 'Unsupported file type'
101
- } as Attachment;
102
-
103
- return [fail1, fail2];
104
- };
105
75
 
106
76
  // for a test width of 500, return a string that is 60+ chars with spaces
107
77
  // to test that line breaks / word wrapping works as expected
108
78
  const getValidText_Long_WithSpaces = () => {
109
79
  return 'bbbbbbbbbb bbbbbbbbbb bbbbbbbbbb bbbbbbbbbb bbbbbbbbbb bbbbbbbbbb bbbbbbbbbb ';
110
80
  };
81
+
111
82
  const getValidText_Long_WithNoSpaces = () => {
112
83
  return 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
113
84
  };
85
+
114
86
  const getValidText_Long_WithUrl = () => {
115
87
  return 'http://www.yourmomyourmomyourmomyourmomyourmomyourmomyourmomyourmomyourmomyourmomyourmom.com';
116
88
  };
@@ -130,444 +102,94 @@ describe('temba-compose chatbox', () => {
130
102
  expect(compose.endpoint).equals(DEFAULT_MEDIA_ENDPOINT);
131
103
  });
132
104
 
133
- it('chatbox no counter no send button', async () => {
105
+ it('no counter', async () => {
134
106
  const compose: Compose = await getCompose({
135
107
  chatbox: true
136
108
  });
137
- await assertScreenshot(
138
- 'compose/chatbox-no-counter-no-send-button',
139
- getClip(compose)
140
- );
109
+ await assertScreenshot('compose/no-counter', getClip(compose));
141
110
  });
142
111
 
143
- it('chatbox no counter and send button', async () => {
112
+ it('initializes with text', async () => {
144
113
  const compose: Compose = await getCompose({
145
- chatbox: true,
146
- button: true
147
- });
148
- await assertScreenshot(
149
- 'compose/chatbox-no-counter-and-send-button',
150
- getClip(compose)
151
- );
152
- });
153
-
154
- it('chatbox counter no send button', async () => {
155
- const compose: Compose = await getCompose({
156
- chatbox: true,
157
114
  counter: true
158
115
  });
159
- await assertScreenshot(
160
- 'compose/chatbox-counter-no-send-button',
161
- getClip(compose)
162
- );
163
- });
164
-
165
- it('chatbox counter and send button', async () => {
166
- const compose: Compose = await getCompose({
167
- chatbox: true,
168
- counter: true,
169
- button: true
170
- });
171
- await assertScreenshot(
172
- 'compose/chatbox-counter-and-send-button',
173
- getClip(compose)
174
- );
175
- });
176
-
177
- it('chatbox counter and send button deserialize and serialize', async () => {
178
- const initialValue = getInitialValue();
179
- const composeValue = getComposeValue(initialValue);
180
-
181
- const compose: Compose = await getCompose({
182
- chatbox: true,
183
- counter: true,
184
- button: true,
185
- value: composeValue
186
- });
187
- // deserialize
188
- expect(compose.currentText).to.equal('');
189
- expect(compose.currentAttachments).to.deep.equal([]);
190
- // serialize
191
- expect(compose.value).to.equal('{}');
192
- });
193
-
194
- it('chatbox with text', async () => {
195
- const compose: Compose = await getCompose({
196
- chatbox: true,
197
- counter: true,
198
- button: true
199
- });
200
116
  await updateComponent(compose, getValidText());
201
- await assertScreenshot('compose/chatbox-with-text', getClip(compose));
117
+ await assertScreenshot('compose/intial-text', getClip(compose));
202
118
  });
203
119
 
204
- it('chatbox with text deserialize and serialize', async () => {
120
+ it('serializes', async () => {
205
121
  const initialValue = getInitialValue(getValidText());
206
122
  const composeValue = getComposeValue(initialValue);
207
123
 
208
124
  const compose: Compose = await getCompose({
209
- chatbox: true,
210
125
  counter: true,
211
- button: true,
212
126
  value: composeValue
213
127
  });
128
+
214
129
  // deserialize
215
130
  expect(compose.currentText).to.equal(getValidText());
216
131
  expect(compose.currentAttachments).to.deep.equal([]);
132
+
217
133
  // serialize
218
134
  expect(compose.value).to.equal(composeValue);
219
135
  });
220
136
 
221
- it('chatbox with text and spaces', async () => {
137
+ // TODO: these are better suited for textinput tests
138
+ it('wraps text and spaces', async () => {
222
139
  const compose: Compose = await getCompose({
223
- chatbox: true,
224
- counter: true,
225
- button: true
140
+ counter: true
226
141
  });
227
142
  await updateComponent(compose, getValidText_Long_WithSpaces());
228
- await assertScreenshot(
229
- 'compose/chatbox-with-text-and-spaces',
230
- getClip(compose)
231
- );
143
+ await assertScreenshot('compose/wraps-text-and-spaces', getClip(compose));
232
144
  });
233
145
 
234
- it('chatbox with text and no spaces', async () => {
146
+ it('wraps text and no spaces', async () => {
235
147
  const compose: Compose = await getCompose({
236
- chatbox: true,
237
- counter: true,
238
- button: true
148
+ counter: true
239
149
  });
240
150
  await updateComponent(compose, getValidText_Long_WithNoSpaces());
241
- await assertScreenshot(
242
- 'compose/chatbox-with-text-no-spaces',
243
- getClip(compose)
244
- );
151
+ await assertScreenshot('compose/wraps-text-no-spaces', getClip(compose));
245
152
  });
246
153
 
247
- it('chatbox with text and url', async () => {
154
+ it('wraps with text and url', async () => {
248
155
  const compose: Compose = await getCompose({
249
- chatbox: true,
250
- counter: true,
251
- button: true
156
+ counter: true
252
157
  });
253
158
  await updateComponent(compose, getValidText_Long_WithUrl());
254
- await assertScreenshot(
255
- 'compose/chatbox-with-text-and-url',
256
- getClip(compose)
257
- );
258
- });
259
-
260
- it('chatbox with text and click send', async () => {
261
- const compose: Compose = await getCompose({
262
- chatbox: true,
263
- counter: true,
264
- button: true
265
- });
266
- await updateComponent(compose, getValidText());
267
- // press enter
268
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as Completion;
269
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
270
- await assertScreenshot(
271
- 'compose/chatbox-with-text-and-click-send',
272
- getClip(compose)
273
- );
274
- });
275
-
276
- it('chatbox with text and hit enter', async () => {
277
- const compose: Compose = await getCompose({
278
- chatbox: true,
279
- counter: true,
280
- button: true
281
- });
282
- await updateComponent(compose, getValidText());
283
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as Completion;
284
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
285
- await assertScreenshot(
286
- 'compose/chatbox-with-text-and-hit-enter',
287
- getClip(compose)
288
- );
159
+ await assertScreenshot('compose/wraps-text-and-url', getClip(compose));
289
160
  });
290
161
  });
291
162
 
292
163
  describe('temba-compose attachments', () => {
293
- it('attachments no send button', async () => {
164
+ it('supports attachments tab', async () => {
294
165
  const compose: Compose = await getCompose({
295
166
  attachments: true
296
167
  });
297
- await assertScreenshot(
298
- 'compose/attachments-no-send-button',
299
- getClip(compose)
300
- );
301
- });
302
-
303
- it('attachments and send button', async () => {
304
- const compose: Compose = await getCompose({
305
- attachments: true,
306
- button: true
307
- });
308
- await assertScreenshot(
309
- 'compose/attachments-and-send-button',
310
- getClip(compose)
311
- );
168
+ await assertScreenshot('compose/attachments-tab', getClip(compose));
312
169
  });
313
170
 
314
- it('attachments and send button deserialize and serialize', async () => {
315
- const initialValue = getInitialValue();
316
- const composeValue = getComposeValue(initialValue);
317
-
171
+ it('shows valid attachments', async () => {
318
172
  const compose: Compose = await getCompose({
319
- attachments: true,
320
- button: true,
321
- value: composeValue
322
- });
323
- // deserialize
324
- expect(compose.currentText).to.equal('');
325
- expect(compose.currentAttachments).to.deep.equal([]);
326
- // serialize
327
- expect(compose.value).to.equal('{}');
328
- });
329
-
330
- it('attachments with success uploaded files', async () => {
331
- const compose: Compose = await getCompose({
332
- attachments: true,
333
- button: true
334
- });
335
- await updateComponent(compose, null, getValidAttachments());
336
- await assertScreenshot(
337
- 'compose/attachments-with-success-files',
338
- getClip(compose)
339
- );
340
- });
341
-
342
- it('attachments with success uploaded files deserialize and serialize', async () => {
343
- const initialValue = getInitialValue(null, getValidAttachments());
344
- const composeValue = getComposeValue(initialValue);
345
- const compose: Compose = await getCompose({
346
- attachments: true,
347
- button: true,
348
- value: composeValue
349
- });
350
- // deserialize
351
- expect(compose.currentText).to.equal('');
352
- expect(compose.currentAttachments).to.deep.equal(getValidAttachments());
353
- // serialize
354
- expect(compose.value).to.equal(composeValue);
355
- });
356
-
357
- it('attachments with failure uploaded files', async () => {
358
- const compose: Compose = await getCompose({
359
- attachments: true,
360
- button: true
361
- });
362
- await updateComponent(compose, null, null);
363
- await assertScreenshot(
364
- 'compose/attachments-with-failure-files',
365
- getClip(compose)
366
- );
367
- });
368
-
369
- it('attachments with success and failure uploaded files', async () => {
370
- const compose: Compose = await getCompose({
371
- attachments: true,
372
- button: true
373
- });
374
- await updateComponent(compose, null, getValidAttachments());
375
- await assertScreenshot(
376
- 'compose/attachments-with-all-files',
377
- getClip(compose)
378
- );
379
- });
380
-
381
- it('attachments with success uploaded files and click send', async () => {
382
- const compose: Compose = await getCompose({
383
- attachments: true,
384
- chatbox: true
385
- });
386
- await updateComponent(compose, null, getValidAttachments());
387
-
388
- // press enter
389
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as Completion;
390
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
391
-
392
- await assertScreenshot(
393
- 'compose/attachments-with-success-files-and-click-send',
394
- getClip(compose)
395
- );
396
- });
397
-
398
- it('attachments with success and failure uploaded files and click send', async () => {
399
- const compose: Compose = await getCompose({
400
- attachments: true,
401
- chatbox: true
402
- });
403
- await updateComponent(compose, null, getValidAttachments());
404
- // press enter
405
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as Completion;
406
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
407
- await assertScreenshot(
408
- 'compose/attachments-with-all-files-and-click-send',
409
- getClip(compose)
410
- );
411
- });
412
- });
413
-
414
- describe('temba-compose chatbox and attachments', () => {
415
- it('chatbox and attachments no counter no send button', async () => {
416
- const compose: Compose = await getCompose({
417
- chatbox: true,
418
173
  attachments: true
419
174
  });
420
- await assertScreenshot(
421
- 'compose/chatbox-attachments-no-counter-no-send-button',
422
- getClip(compose)
423
- );
424
- });
425
-
426
- it('chatbox and attachments no counter and send button', async () => {
427
- const compose: Compose = await getCompose({
428
- chatbox: true,
429
- attachments: true,
430
- button: true
431
- });
432
- await assertScreenshot(
433
- 'compose/chatbox-attachments-no-counter-and-send-button',
434
- getClip(compose)
435
- );
436
- });
437
-
438
- it('chatbox and attachments counter no send button', async () => {
439
- const compose: Compose = await getCompose({
440
- chatbox: true,
441
- attachments: true,
442
- counter: true
443
- });
444
- await assertScreenshot(
445
- 'compose/chatbox-attachments-counter-no-send-button',
446
- getClip(compose)
447
- );
448
- });
449
-
450
- it('chatbox and attachments counter and send button', async () => {
451
- const compose: Compose = await getCompose({
452
- chatbox: true,
453
- attachments: true,
454
- counter: true,
455
- button: true
456
- });
457
- await assertScreenshot(
458
- 'compose/chatbox-attachments-counter-and-send-button',
459
- getClip(compose)
460
- );
461
- });
462
-
463
- it('chatbox and attachments counter and send button deserialize and serialize', async () => {
464
- const initialValue = getInitialValue();
465
- const composeValue = getComposeValue(initialValue);
466
-
467
- const compose: Compose = await getCompose({
468
- chatbox: true,
469
- attachments: true,
470
- counter: true,
471
- button: true,
472
- value: composeValue
473
- });
474
- // deserialize
475
- expect(compose.currentText).to.equal('');
476
- expect(compose.currentAttachments).to.deep.equal([]);
477
- // serialize
478
- expect(compose.value).to.equal('{}');
479
- });
480
- });
481
-
482
- describe('temba-compose chatbox with text and attachments no files', () => {
483
- it('chatbox with text, attachments no files', async () => {
484
- const compose: Compose = await getCompose({
485
- chatbox: true,
486
- attachments: true,
487
- counter: true,
488
- button: true
489
- });
490
- updateComponent(compose, getValidText());
491
- await assertScreenshot(
492
- 'compose/chatbox-with-text-attachments-no-files',
493
- getClip(compose)
494
- );
495
- });
496
-
497
- it('chatbox with text, attachments no files deserialize and serialize', async () => {
498
- const initialValue = getInitialValue(getValidText());
499
- const composeValue = getComposeValue(initialValue);
500
-
501
- const compose: Compose = await getCompose({
502
- chatbox: true,
503
- attachments: true,
504
- counter: true,
505
- button: true,
506
- value: composeValue
507
- });
508
- // deserialize
509
- expect(compose.currentText).to.equal(getValidText());
510
- expect(compose.currentAttachments).to.deep.equal([]);
511
- // serialize
512
- expect(compose.value).to.equal(composeValue);
513
- });
175
+ await updateComponent(compose, null, getValidAttachments());
176
+ await assertScreenshot('compose/attachments-with-files', getClip(compose));
514
177
 
515
- it('chatbox with text, attachments no files, and click send', async () => {
516
- const compose: Compose = await getCompose({
517
- chatbox: true,
518
- attachments: true,
519
- counter: true,
520
- button: true
521
- });
522
- updateComponent(compose, getValidText());
523
- // press enter
524
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as Completion;
525
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
526
- await assertScreenshot(
527
- 'compose/chatbox-with-text-attachments-no-files-and-click-send',
528
- getClip(compose)
529
- );
530
- });
178
+ // click on tab
179
+ const tabs = compose.getTabs();
180
+ tabs.focusTab('Attachments');
531
181
 
532
- it('chatbox with text, attachments no files, and hit enter', async () => {
533
- const compose: Compose = await getCompose({
534
- chatbox: true,
535
- attachments: true,
536
- counter: true,
537
- button: true
538
- });
539
- await updateComponent(compose, getValidText());
540
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as HTMLElement;
541
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
542
182
  await assertScreenshot(
543
- 'compose/chatbox-with-text-attachments-no-files-and-hit-enter',
183
+ 'compose/attachments-with-files-focused',
544
184
  getClip(compose)
545
185
  );
546
186
  });
547
- });
548
187
 
549
- describe('temba-compose chatbox no text and attachments with files', () => {
550
- it('chatbox no text, attachments with success uploaded files', async () => {
551
- const compose: Compose = await getCompose({
552
- chatbox: true,
553
- attachments: true,
554
- button: true
555
- });
556
- await updateComponent(compose, null, getValidAttachments());
557
- await assertScreenshot(
558
- 'compose/chatbox-no-text-attachments-with-success-files',
559
- getClip(compose)
560
- );
561
- });
562
-
563
- it('chatbox no text, attachments with success uploaded files deserialize and serialize', async () => {
188
+ it('serializes attachments', async () => {
564
189
  const initialValue = getInitialValue(null, getValidAttachments());
565
190
  const composeValue = getComposeValue(initialValue);
566
-
567
191
  const compose: Compose = await getCompose({
568
- chatbox: true,
569
192
  attachments: true,
570
- button: true,
571
193
  value: composeValue
572
194
  });
573
195
  // deserialize
@@ -576,187 +198,4 @@ describe('temba-compose chatbox no text and attachments with files', () => {
576
198
  // serialize
577
199
  expect(compose.value).to.equal(composeValue);
578
200
  });
579
-
580
- it('chatbox no text, attachments with failure uploaded files', async () => {
581
- const compose: Compose = await getCompose({
582
- chatbox: true,
583
- attachments: true,
584
- button: true
585
- });
586
- await updateComponent(compose, null, null);
587
- await assertScreenshot(
588
- 'compose/chatbox-no-text-attachments-with-failure-files',
589
- getClip(compose)
590
- );
591
- });
592
-
593
- it('chatbox no text, attachments with success and failure uploaded files', async () => {
594
- const compose: Compose = await getCompose({
595
- chatbox: true,
596
- attachments: true,
597
- button: true
598
- });
599
- await updateComponent(compose, null, getValidAttachments());
600
- await assertScreenshot(
601
- 'compose/chatbox-no-text-attachments-with-all-files',
602
- getClip(compose)
603
- );
604
- });
605
-
606
- it('chatbox no text, attachments with success uploaded files, and click send', async () => {
607
- const compose: Compose = await getCompose({
608
- chatbox: true,
609
- attachments: true,
610
- button: true
611
- });
612
- await updateComponent(compose, null, getValidAttachments());
613
- // press enter
614
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as Completion;
615
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
616
- await assertScreenshot(
617
- 'compose/chatbox-no-text-attachments-with-success-files-and-click-send',
618
- getClip(compose)
619
- );
620
- });
621
-
622
- it('chatbox no text, attachments with success and failure uploaded files, and click send', async () => {
623
- const compose: Compose = await getCompose({
624
- chatbox: true,
625
- attachments: true,
626
- button: true
627
- });
628
- await updateComponent(compose, null, getValidAttachments());
629
- // press enter
630
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as Completion;
631
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
632
- await assertScreenshot(
633
- 'compose/chatbox-no-text-attachments-with-all-files-and-click-send',
634
- getClip(compose)
635
- );
636
- });
637
- });
638
-
639
- describe('temba-compose chatbox with text and attachments with files', () => {
640
- it('chatbox with text, attachments with success uploaded files', async () => {
641
- const compose: Compose = await getCompose({
642
- chatbox: true,
643
- attachments: true,
644
- button: true
645
- });
646
- await updateComponent(compose, getValidText(), getValidAttachments());
647
- await assertScreenshot(
648
- 'compose/chatbox-with-text-attachments-with-success-files',
649
- getClip(compose)
650
- );
651
- });
652
-
653
- it('chatbox with text, attachments with success uploaded files deserialize and serialize', async () => {
654
- const initialValue = getInitialValue(getValidText(), getValidAttachments());
655
- const composeValue = getComposeValue(initialValue);
656
-
657
- const compose: Compose = await getCompose({
658
- chatbox: true,
659
- attachments: true,
660
- button: true,
661
- value: composeValue
662
- });
663
-
664
- // deserialize
665
- expect(compose.currentText).to.equal(getValidText());
666
-
667
- expect(compose.currentAttachments).to.deep.equal(getValidAttachments());
668
- // serialize
669
- expect(compose.value).to.equal(composeValue);
670
- });
671
-
672
- it('chatbox with text, attachments with failure uploaded files', async () => {
673
- const compose: Compose = await getCompose({
674
- chatbox: true,
675
- attachments: true,
676
- button: true
677
- });
678
- await updateComponent(compose, getValidText(), null);
679
- await assertScreenshot(
680
- 'compose/chatbox-with-text-attachments-with-failure-files',
681
- getClip(compose)
682
- );
683
- });
684
-
685
- it('chatbox with text, attachments with success and failure uploaded files', async () => {
686
- const compose: Compose = await getCompose({
687
- chatbox: true,
688
- attachments: true,
689
- button: true
690
- });
691
- await updateComponent(compose, getValidText(), getValidAttachments());
692
- await assertScreenshot(
693
- 'compose/chatbox-with-text-attachments-with-all-files',
694
- getClip(compose)
695
- );
696
- });
697
-
698
- it('chatbox with text, attachments with success uploaded files, and click send', async () => {
699
- const compose: Compose = await getCompose({
700
- chatbox: true,
701
- attachments: true,
702
- button: true
703
- });
704
- await updateComponent(compose, getValidText(), getValidAttachments());
705
- // press enter
706
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as Completion;
707
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
708
- await assertScreenshot(
709
- 'compose/chatbox-with-text-attachments-with-success-files-and-click-send',
710
- getClip(compose)
711
- );
712
- });
713
-
714
- it('chatbox with text, attachments with success and failure uploaded files, and click send', async () => {
715
- const compose: Compose = await getCompose({
716
- chatbox: true,
717
- attachments: true,
718
- button: true
719
- });
720
- await updateComponent(compose, getValidText(), getValidAttachments());
721
- // press enter
722
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as Completion;
723
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
724
- await assertScreenshot(
725
- 'compose/chatbox-with-text-attachments-with-all-files-and-click-send',
726
- getClip(compose)
727
- );
728
- });
729
-
730
- it('chatbox with text, attachments with success uploaded files, and hit enter', async () => {
731
- const compose: Compose = await getCompose({
732
- chatbox: true,
733
- attachments: true,
734
- button: true
735
- });
736
- await updateComponent(compose, getValidText(), getValidAttachments());
737
- const chatbox = compose.shadowRoot.querySelector('.chatbox') as HTMLElement;
738
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
739
- await assertScreenshot(
740
- 'compose/chatbox-with-text-attachments-with-success-files-and-hit-enter',
741
- getClip(compose)
742
- );
743
- });
744
-
745
- it('chatbox with text, attachments with success and failure uploaded files, and hit enter', async () => {
746
- const compose: Compose = await getCompose({
747
- chatbox: true,
748
- attachments: true,
749
- button: true
750
- });
751
- await updateComponent(compose, getValidText(), getValidAttachments());
752
- const chatbox = compose.shadowRoot.querySelector(
753
- '.chatbox'
754
- ) as HTMLInputElement;
755
- chatbox.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
756
- const newClip = getClip(compose);
757
- await assertScreenshot(
758
- 'compose/chatbox-with-text-attachments-with-all-files-and-hit-enter',
759
- newClip
760
- );
761
- });
762
201
  });