@adatechnology/conversations-ui 0.15.1 → 0.17.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 (39) hide show
  1. package/README.md +23 -0
  2. package/dist/{ConversationSimulatorPanel-P6eqTSAO.d.ts → ConversationSimulatorPanel-DSVIch04.d.ts} +3 -1
  3. package/dist/{chunk-Y326LLEP.js → chunk-7OLYCCLX.js} +1 -1
  4. package/dist/{chunk-WCZNIJ3M.js → chunk-Z7U22M3K.js} +7 -0
  5. package/dist/flows/index.d.ts +90 -7
  6. package/dist/flows/index.js +1151 -455
  7. package/dist/index.d.ts +36 -5
  8. package/dist/index.js +88 -23
  9. package/dist/participant/index.js +1 -1
  10. package/dist/preview/index.d.ts +13 -29
  11. package/dist/preview/index.js +2 -2
  12. package/package.json +2 -2
  13. package/src/flows/FlowKeywordRoutesField.tsx +105 -0
  14. package/src/flows/FlowLegend.tsx +2 -2
  15. package/src/flows/FlowNodeCard.tsx +39 -10
  16. package/src/flows/FlowNodePanel.tsx +34 -10
  17. package/src/flows/FlowPalette.tsx +25 -2
  18. package/src/flows/FlowPossibleNextField.tsx +89 -0
  19. package/src/flows/FlowRunnerFields.tsx +321 -0
  20. package/src/flows/FlowWhatsAppPreview.tsx +39 -6
  21. package/src/flows/flowCanvasModel.test.ts +3 -2
  22. package/src/flows/flowCanvasModel.ts +28 -1
  23. package/src/flows/flowEditorOps.ts +41 -4
  24. package/src/flows/flowGraph.ts +124 -21
  25. package/src/flows/flowPanelStyles.ts +11 -0
  26. package/src/flows/flowPossibleNext.test.ts +70 -0
  27. package/src/flows/flowRunnerEditor.test.ts +116 -0
  28. package/src/flows/labels.ts +116 -2
  29. package/src/index.ts +2 -1
  30. package/src/lib/phone.test.ts +20 -0
  31. package/src/lib/phone.ts +13 -0
  32. package/src/preview/createPreviewBridgeClient.test.ts +23 -0
  33. package/src/preview/createPreviewBridgeClient.ts +13 -8
  34. package/src/preview/createPreviewWebhookClient.ts +2 -0
  35. package/src/workspace/ConversationPane.tsx +13 -2
  36. package/src/workspace/ConversationsWorkspace.tsx +117 -18
  37. package/src/workspace/index.ts +1 -0
  38. package/src/workspace/labels.ts +2 -0
  39. package/src/workspace/workspaceTestContactDom.test.tsx +96 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Copyright (c) 2026 Ada Technology. MIT License.
3
+ *
4
+ * Simulador sem conversa selecionada: o host cria um contato de teste e o painel abre direto.
5
+ */
6
+
7
+ import { act } from 'react'
8
+
9
+ import { afterAll, beforeAll, describe, expect, it } from 'bun:test'
10
+
11
+ import { setupDom, wait, type DomHarness } from '../domHarness.test-helper'
12
+ import { ConversationsProvider } from '../providers/ConversationsProvider'
13
+ import { createMockConversationsApi } from '../preview/createMockConversationsApi'
14
+ import { createMockSSEProvider } from '../preview/createMockSSEProvider'
15
+ import { createPreviewStore } from '../preview/previewStore'
16
+ import { PREVIEW_CONVERSATIONS, PREVIEW_MESSAGES } from '../preview/previewFixtures'
17
+ import { ConversationsWorkspace, type ConversationsWorkspaceSimulator } from './ConversationsWorkspace'
18
+
19
+ let harness: DomHarness
20
+
21
+ beforeAll(async () => {
22
+ harness = await setupDom()
23
+ })
24
+
25
+ afterAll(() => harness.teardown())
26
+
27
+ function mountWorkspace(simulator: ConversationsWorkspaceSimulator) {
28
+ const store = createPreviewStore({ conversations: [], messages: {} })
29
+ return harness.mount(
30
+ <ConversationsProvider api={createMockConversationsApi({ store, latencyMs: 0 })} sse={createMockSSEProvider({ store })}>
31
+ <ConversationsWorkspace simulator={simulator} />
32
+ </ConversationsProvider>,
33
+ )
34
+ }
35
+
36
+ function newContactButton(container: HTMLElement): HTMLButtonElement | undefined {
37
+ return Array.from(container.querySelectorAll('button')).find(
38
+ (button) => button.getAttribute('aria-label') === 'Novo contato de teste',
39
+ )
40
+ }
41
+
42
+ describe('novo contato de teste', () => {
43
+ it('sem createTestContact o botão não existe', async () => {
44
+ const { container, unmount } = mountWorkspace({ transports: { whatsapp: () => ({ sendText: async () => {}, sendReply: async () => {} }) } })
45
+ await wait(5)
46
+
47
+ expect(newContactButton(container)).toBeUndefined()
48
+ unmount()
49
+ })
50
+
51
+ it('abre o simulador sem conversa selecionada, com o contato do host', async () => {
52
+ const sent: string[] = []
53
+ const handles: string[] = []
54
+ const { container, unmount } = mountWorkspace({
55
+ createTestContact: () => ({ handle: '05511900001234' }),
56
+ transports: {
57
+ whatsapp: ({ handle }) => {
58
+ handles.push(handle)
59
+ return { sendText: async (text) => void sent.push(text), sendReply: async () => {} }
60
+ },
61
+ },
62
+ })
63
+ await wait(5)
64
+
65
+ await act(async () => {
66
+ newContactButton(container)?.click()
67
+ })
68
+ await wait(5)
69
+
70
+ const panel = container.querySelector('.cv-simulator-panel')
71
+ expect(panel).not.toBeNull()
72
+ expect(panel?.textContent).toContain('Contato de teste 1234')
73
+ expect(handles).toContain('05511900001234')
74
+ unmount()
75
+ })
76
+ })
77
+
78
+ describe('rótulos do painel de contexto', () => {
79
+ it('o workspace repassa contextLabels ao painel', async () => {
80
+ const store = createPreviewStore({ conversations: PREVIEW_CONVERSATIONS, messages: PREVIEW_MESSAGES })
81
+ const first = PREVIEW_CONVERSATIONS[0]
82
+ const { container, unmount } = harness.mount(
83
+ <ConversationsProvider api={createMockConversationsApi({ store, latencyMs: 0 })} sse={createMockSSEProvider({ store })}>
84
+ <ConversationsWorkspace
85
+ initialConversationId={first?.id}
86
+ contextEntriesOf={() => [{ key: 'date', label: 'Data', value: undefined, status: 'pending' }]}
87
+ contextLabels={{ title: 'Dados da reserva', notCollected: 'ainda não informado' }}
88
+ />
89
+ </ConversationsProvider>,
90
+ )
91
+ await wait(20)
92
+
93
+ expect(container.textContent).toContain('Dados da reserva')
94
+ unmount()
95
+ })
96
+ })