@nyaruka/temba-components 0.91.6 → 0.92.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.
- package/CHANGELOG.md +9 -0
- package/demo/index.html +1 -1
- package/dist/temba-components.js +760 -1189
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/chat/Chat.js +714 -0
- package/out-tsc/src/chat/Chat.js.map +1 -0
- package/out-tsc/src/completion/helpers.js +1 -29
- package/out-tsc/src/completion/helpers.js.map +1 -1
- package/out-tsc/src/compose/Compose.js +6 -2
- package/out-tsc/src/compose/Compose.js.map +1 -1
- package/out-tsc/src/contacts/ContactChat.js +518 -54
- package/out-tsc/src/contacts/ContactChat.js.map +1 -1
- package/out-tsc/src/contacts/events.js +1 -998
- package/out-tsc/src/contacts/events.js.map +1 -1
- package/out-tsc/src/lightbox/Lightbox.js +4 -0
- package/out-tsc/src/lightbox/Lightbox.js.map +1 -1
- package/out-tsc/src/list/TembaMenu.js +0 -1
- package/out-tsc/src/list/TembaMenu.js.map +1 -1
- package/out-tsc/src/markdown.js +33 -0
- package/out-tsc/src/markdown.js.map +1 -0
- package/out-tsc/src/select/Select.js +6 -1
- package/out-tsc/src/select/Select.js.map +1 -1
- package/out-tsc/src/textinput/TextInput.js +1 -1
- package/out-tsc/src/textinput/TextInput.js.map +1 -1
- package/out-tsc/src/thumbnail/Thumbnail.js +128 -81
- package/out-tsc/src/thumbnail/Thumbnail.js.map +1 -1
- package/out-tsc/src/utils/index.js +9 -11
- package/out-tsc/src/utils/index.js.map +1 -1
- package/out-tsc/src/webchat/WebChat.js +109 -358
- package/out-tsc/src/webchat/WebChat.js.map +1 -1
- package/out-tsc/src/webchat/index.js +17 -0
- package/out-tsc/src/webchat/index.js.map +1 -1
- package/out-tsc/temba-modules.js +2 -2
- package/out-tsc/temba-modules.js.map +1 -1
- package/out-tsc/temba-webchat.js +2 -0
- package/out-tsc/temba-webchat.js.map +1 -1
- package/out-tsc/test/temba-contact-chat.test.js +1 -0
- package/out-tsc/test/temba-contact-chat.test.js.map +1 -1
- package/out-tsc/test/temba-lightbox.test.js +4 -4
- package/out-tsc/test/temba-lightbox.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/contacts/compose-attachments-no-text-failure.png +0 -0
- package/screenshots/truth/contacts/compose-attachments-no-text-success.png +0 -0
- package/screenshots/truth/contacts/compose-text-and-attachments-failure-attachments.png +0 -0
- package/screenshots/truth/contacts/compose-text-and-attachments-failure-generic.png +0 -0
- package/screenshots/truth/contacts/compose-text-and-attachments-failure-text-and-attachments.png +0 -0
- package/screenshots/truth/contacts/compose-text-and-attachments-failure-text.png +0 -0
- package/screenshots/truth/contacts/compose-text-and-attachments-success.png +0 -0
- package/screenshots/truth/contacts/compose-text-no-attachments-failure.png +0 -0
- package/screenshots/truth/contacts/compose-text-no-attachments-success.png +0 -0
- package/screenshots/truth/contacts/contact-active-default.png +0 -0
- package/screenshots/truth/contacts/contact-active-show-chatbox.png +0 -0
- package/screenshots/truth/contacts/contact-archived-hide-chatbox.png +0 -0
- package/screenshots/truth/contacts/contact-blocked-hide-chatbox.png +0 -0
- package/screenshots/truth/contacts/contact-stopped-hide-chatbox.png +0 -0
- package/screenshots/truth/lightbox/img-zoomed.png +0 -0
- package/screenshots/truth/lightbox/img.png +0 -0
- package/src/chat/Chat.ts +791 -0
- package/src/completion/helpers.ts +2 -40
- package/src/compose/Compose.ts +6 -2
- package/src/contacts/ContactChat.ts +609 -59
- package/src/contacts/events.ts +1 -1068
- package/src/lightbox/Lightbox.ts +5 -0
- package/src/list/TembaMenu.ts +0 -1
- package/src/markdown.ts +41 -0
- package/src/select/Select.ts +5 -1
- package/src/textinput/TextInput.ts +1 -1
- package/src/thumbnail/Thumbnail.ts +130 -81
- package/src/utils/index.ts +12 -13
- package/src/webchat/WebChat.ts +196 -413
- package/src/webchat/index.ts +23 -1
- package/static/css/temba-components.css +2 -0
- package/temba-modules.ts +2 -2
- package/temba-webchat.ts +2 -0
- package/test/temba-contact-chat.test.ts +1 -0
- package/test/temba-lightbox.test.ts +4 -4
- package/test-assets/contacts/history.json +1 -56
- package/out-tsc/src/contacts/ContactHistory.js +0 -691
- package/out-tsc/src/contacts/ContactHistory.js.map +0 -1
- package/out-tsc/test/temba-contact-history.test.js +0 -69
- package/out-tsc/test/temba-contact-history.test.js.map +0 -1
- package/src/contacts/ContactHistory.ts +0 -875
- package/test/temba-contact-history.test.ts +0 -107
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { fixture, assert, expect } from '@open-wc/testing';
|
|
2
|
-
import { useFakeTimers } from 'sinon';
|
|
3
|
-
import { ContactHistory } from '../src/contacts/ContactHistory';
|
|
4
|
-
import {
|
|
5
|
-
assertScreenshot,
|
|
6
|
-
getClip,
|
|
7
|
-
getHTML,
|
|
8
|
-
loadStore,
|
|
9
|
-
mockGET,
|
|
10
|
-
mockNow
|
|
11
|
-
} from '../test/utils.test';
|
|
12
|
-
import './utils.test';
|
|
13
|
-
|
|
14
|
-
export const createHistory = async (def: string) => {
|
|
15
|
-
const parentNode = document.createElement('div');
|
|
16
|
-
parentNode.setAttribute(
|
|
17
|
-
'style',
|
|
18
|
-
'width: 500px;height:750px;display:flex;flex-direction:column;flex-grow:1;min-height:0;'
|
|
19
|
-
);
|
|
20
|
-
const history = (await fixture(def, { parentNode })) as ContactHistory;
|
|
21
|
-
|
|
22
|
-
// make sure our initial fetch is made
|
|
23
|
-
await history.httpComplete;
|
|
24
|
-
|
|
25
|
-
return history;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const getHistoryHTML = (attrs: any = {} as any) =>
|
|
29
|
-
// attrs = "min-height:0;display:flex;flex-grow:1;flex-direction:column";
|
|
30
|
-
getHTML('temba-contact-history', attrs);
|
|
31
|
-
|
|
32
|
-
const getHistoryClip = (ele: ContactHistory) => {
|
|
33
|
-
const clip = getClip(ele);
|
|
34
|
-
clip.height = Math.min(clip.height, 750);
|
|
35
|
-
clip.bottom = clip.top + clip.height;
|
|
36
|
-
return clip;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// stub our current date for consistent screenshots
|
|
40
|
-
mockNow('2021-03-31T00:31:00.000-00:00');
|
|
41
|
-
let clock: any;
|
|
42
|
-
|
|
43
|
-
describe('temba-contact-history', () => {
|
|
44
|
-
beforeEach(async () => {
|
|
45
|
-
clock = useFakeTimers();
|
|
46
|
-
|
|
47
|
-
mockGET(
|
|
48
|
-
/\/contact\/history\/contact-dave-active\/.*/,
|
|
49
|
-
'/test-assets/contacts/history.json'
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
mockGET(
|
|
53
|
-
/\/api\/v2\/tickets\.json\?contact=contact-dave-active/,
|
|
54
|
-
'/test-assets/api/tickets.json'
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
await loadStore();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
afterEach(function () {
|
|
61
|
-
clock.restore();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('can be created', async () => {
|
|
65
|
-
const history = await createHistory(getHistoryHTML());
|
|
66
|
-
assert.instanceOf(history, ContactHistory);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('renders history', async () => {
|
|
70
|
-
const history = await createHistory(
|
|
71
|
-
getHistoryHTML({
|
|
72
|
-
uuid: 'contact-dave-active'
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
// we should have scrolled to the bottom, but the scroll
|
|
77
|
-
// happens in a window timeout
|
|
78
|
-
await clock.runAllAsync();
|
|
79
|
-
await history.updateComplete;
|
|
80
|
-
|
|
81
|
-
const events = history.shadowRoot.querySelector('.events');
|
|
82
|
-
const top = events.scrollHeight - events.getBoundingClientRect().height;
|
|
83
|
-
expect(top).to.equal(571);
|
|
84
|
-
// make sure we actually scrolled to there
|
|
85
|
-
expect(events.scrollTop).to.equal(top);
|
|
86
|
-
await assertScreenshot('contacts/history', getHistoryClip(history));
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('expands event groups', async () => {
|
|
90
|
-
const history = await createHistory(
|
|
91
|
-
getHistoryHTML({
|
|
92
|
-
uuid: 'contact-dave-active'
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
// our groups with collapsed events
|
|
97
|
-
const groups = [3, 5, 7];
|
|
98
|
-
for (const idx of groups) {
|
|
99
|
-
const group = history.shadowRoot.querySelector(
|
|
100
|
-
`.event-count[data-group-index='${idx}']`
|
|
101
|
-
) as HTMLDivElement;
|
|
102
|
-
group.click();
|
|
103
|
-
await clock.runAllAsync();
|
|
104
|
-
expect(group.parentElement.classList.contains('expanded')).equal(true);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|