@nyaruka/temba-components 0.35.0 → 0.35.2

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 (51) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{30636513.js → 41042aab.js} +89 -64
  3. package/dist/index.js +89 -64
  4. package/dist/sw.js +1 -1
  5. package/dist/sw.js.map +1 -1
  6. package/dist/templates/components-body.html +1 -1
  7. package/dist/templates/components-head.html +1 -1
  8. package/out-tsc/src/contacts/ContactPending.js +30 -35
  9. package/out-tsc/src/contacts/ContactPending.js.map +1 -1
  10. package/out-tsc/src/contacts/events.js +24 -10
  11. package/out-tsc/src/contacts/events.js.map +1 -1
  12. package/out-tsc/src/date/TembaDate.js +37 -11
  13. package/out-tsc/src/date/TembaDate.js.map +1 -1
  14. package/out-tsc/src/dropdown/Dropdown.js +30 -5
  15. package/out-tsc/src/dropdown/Dropdown.js.map +1 -1
  16. package/out-tsc/src/list/RunList.js +17 -16
  17. package/out-tsc/src/list/RunList.js.map +1 -1
  18. package/out-tsc/src/store/Store.js +12 -26
  19. package/out-tsc/src/store/Store.js.map +1 -1
  20. package/out-tsc/src/vectoricon/index.js +3 -0
  21. package/out-tsc/src/vectoricon/index.js.map +1 -1
  22. package/out-tsc/test/temba-contact-history.test.js +5 -8
  23. package/out-tsc/test/temba-contact-history.test.js.map +1 -1
  24. package/out-tsc/test/temba-date.test.js +3 -9
  25. package/out-tsc/test/temba-date.test.js.map +1 -1
  26. package/out-tsc/test/utils.test.js +9 -0
  27. package/out-tsc/test/utils.test.js.map +1 -1
  28. package/package.json +1 -1
  29. package/screenshots/truth/contacts/contact-active-default.png +0 -0
  30. package/screenshots/truth/contacts/contact-active-show-chat-history.png +0 -0
  31. package/screenshots/truth/contacts/contact-active-show-chat-msg.png +0 -0
  32. package/screenshots/truth/contacts/contact-archived-hide-chat-msg.png +0 -0
  33. package/screenshots/truth/contacts/contact-archived-show-chat-history.png +0 -0
  34. package/screenshots/truth/contacts/contact-blocked-hide-chat-msg.png +0 -0
  35. package/screenshots/truth/contacts/contact-blocked-show-chat-history.png +0 -0
  36. package/screenshots/truth/contacts/contact-stopped-hide-chat-msg.png +0 -0
  37. package/screenshots/truth/contacts/contact-stopped-show-chat-history.png +0 -0
  38. package/screenshots/truth/contacts/fields-updated.png +0 -0
  39. package/screenshots/truth/contacts/history-expanded.png +0 -0
  40. package/screenshots/truth/contacts/history.png +0 -0
  41. package/screenshots/truth/date/duration.png +0 -0
  42. package/src/contacts/ContactPending.ts +38 -34
  43. package/src/contacts/events.ts +24 -10
  44. package/src/date/TembaDate.ts +40 -11
  45. package/src/dropdown/Dropdown.ts +29 -5
  46. package/src/list/RunList.ts +17 -28
  47. package/src/store/Store.ts +13 -37
  48. package/src/vectoricon/index.ts +3 -0
  49. package/test/temba-contact-history.test.ts +7 -7
  50. package/test/temba-date.test.ts +3 -8
  51. package/test/utils.test.ts +10 -1
@@ -1,12 +1,12 @@
1
1
  import { fixture, assert, expect } from '@open-wc/testing';
2
- import * as sinon from 'sinon';
3
2
  import { ContactHistory } from '../src/contacts/ContactHistory';
4
- import { stubbable } from '../src/utils';
5
3
  import {
6
4
  assertScreenshot,
7
5
  getClip,
8
6
  getHTML,
7
+ loadStore,
9
8
  mockGET,
9
+ mockNow,
10
10
  } from '../test/utils.test';
11
11
  import './utils.test';
12
12
 
@@ -41,12 +41,10 @@ const getHistoryClip = (ele: ContactHistory) => {
41
41
  };
42
42
 
43
43
  // stub our current date for consistent screenshots
44
- sinon.stub(stubbable, 'getCurrentDate').callsFake(() => {
45
- return new Date('2021-03-31T00:00:00.000-00:00');
46
- });
44
+ mockNow('2021-03-31T00:31:00.000-00:00');
47
45
 
48
46
  describe('temba-contact-history', () => {
49
- beforeEach(() => {
47
+ beforeEach(async () => {
50
48
  mockGET(
51
49
  /\/contact\/history\/contact-dave-active\/.*/,
52
50
  '/test-assets/contacts/history.json'
@@ -56,6 +54,8 @@ describe('temba-contact-history', () => {
56
54
  /\/api\/v2\/tickets\.json\?contact=contact-dave-active/,
57
55
  '/test-assets/api/tickets.json'
58
56
  );
57
+
58
+ await loadStore();
59
59
  });
60
60
 
61
61
  it('can be created', async () => {
@@ -76,7 +76,7 @@ describe('temba-contact-history', () => {
76
76
  const events = history.shadowRoot.querySelector('.events');
77
77
  const top = events.scrollHeight - events.getBoundingClientRect().height;
78
78
 
79
- expect(top).to.equal(520);
79
+ expect(top).to.equal(549);
80
80
 
81
81
  // make sure we actually scrolled to there
82
82
  expect(events.scrollTop).to.equal(top);
@@ -1,12 +1,11 @@
1
- import * as sinon from 'sinon';
2
1
  import { TembaDate } from '../src/date/TembaDate';
3
2
  import {
4
3
  assertScreenshot,
5
4
  getClip,
6
5
  getComponent,
7
6
  loadStore,
7
+ mockNow,
8
8
  } from './utils.test';
9
- import { DateTime } from 'luxon';
10
9
  import { expect } from '@open-wc/testing';
11
10
 
12
11
  const TAG = 'temba-date';
@@ -16,11 +15,7 @@ export const getDate = async (attrs: any = {}) => {
16
15
  return (await getComponent(TAG, attrs)) as TembaDate;
17
16
  };
18
17
 
19
- // mock the current time
20
- const now = DateTime.fromISO('2022-12-02T21:00:00.000000-07:00');
21
- sinon.replace(DateTime, 'now', () => {
22
- return now;
23
- });
18
+ mockNow('2022-12-02T21:00:00.000000-07:00');
24
19
 
25
20
  describe('temba-date', () => {
26
21
  beforeEach(() => {
@@ -47,7 +42,7 @@ describe('temba-date', () => {
47
42
  ).innerText;
48
43
 
49
44
  await assertScreenshot('date/duration', getClip(date));
50
- expect(dateString).to.equal('44 years');
45
+ expect(dateString).to.equal('44 years ago');
51
46
  });
52
47
 
53
48
  it('renders datetime', async () => {
@@ -1,5 +1,6 @@
1
1
  import '../temba-modules';
2
-
2
+ import { DateTime } from 'luxon';
3
+ import * as sinon from 'sinon';
3
4
  interface Clip {
4
5
  x: number;
5
6
  y: number;
@@ -228,3 +229,11 @@ export const loadStore = async () => {
228
229
 
229
230
  return store;
230
231
  };
232
+
233
+ export const mockNow = (isodate: string) => {
234
+ const now = DateTime.fromISO(isodate);
235
+ // mock the current time
236
+ sinon.replace(DateTime, 'now', () => {
237
+ return now;
238
+ });
239
+ };