@handled-ai/design-system 0.20.4 → 0.20.6
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/dist/components/conversation-panel.d.ts +28 -1
- package/dist/components/conversation-panel.js +180 -310
- package/dist/components/conversation-panel.js.map +1 -1
- package/dist/components/email-body.d.ts +15 -0
- package/dist/components/email-body.js +101 -0
- package/dist/components/email-body.js.map +1 -0
- package/dist/components/email-display-helpers.d.ts +34 -0
- package/dist/components/email-display-helpers.js +436 -0
- package/dist/components/email-display-helpers.js.map +1 -0
- package/dist/components/email-preview-card.d.ts +7 -4
- package/dist/components/email-preview-card.js +48 -25
- package/dist/components/email-preview-card.js.map +1 -1
- package/dist/components/timeline-activity.js +66 -42
- package/dist/components/timeline-activity.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/safe-html.d.ts +1 -1
- package/dist/internal/safe-html.js +64 -3
- package/dist/internal/safe-html.js.map +1 -1
- package/package.json +1 -1
- package/src/components/__tests__/conversation-panel.test.tsx +230 -22
- package/src/components/__tests__/email-body.test.tsx +83 -0
- package/src/components/__tests__/email-display-helpers.test.ts +91 -0
- package/src/components/__tests__/email-preview-card.test.tsx +36 -2
- package/src/components/__tests__/timeline-activity.test.tsx +53 -1
- package/src/components/conversation-panel.tsx +227 -369
- package/src/components/email-body.tsx +126 -0
- package/src/components/email-display-helpers.ts +557 -0
- package/src/components/email-preview-card.tsx +54 -29
- package/src/components/timeline-activity.tsx +73 -53
- package/src/index.ts +2 -0
- package/src/internal/__tests__/safe-html.test.ts +34 -2
- package/src/internal/safe-html.ts +79 -4
|
@@ -10,6 +10,17 @@ afterEach(() => {
|
|
|
10
10
|
|
|
11
11
|
const from = { name: "Cory Pitt", email: "cory@withhandled.com" }
|
|
12
12
|
|
|
13
|
+
function expectNoVisibleEscapeArtifacts(value: string) {
|
|
14
|
+
expect(value).not.toMatch(/&#(?:x[0-9a-f]+|\d+);?/i)
|
|
15
|
+
expect(value).not.toContain("&")
|
|
16
|
+
expect(value).not.toContain("<")
|
|
17
|
+
expect(value).not.toContain(">")
|
|
18
|
+
expect(value).not.toContain(""")
|
|
19
|
+
expect(value).not.toContain('\\"')
|
|
20
|
+
expect(value).not.toContain("\\'")
|
|
21
|
+
expect(value).not.toContain("\\n")
|
|
22
|
+
}
|
|
23
|
+
|
|
13
24
|
describe("EmailPreviewCard", () => {
|
|
14
25
|
it("renders the subject", () => {
|
|
15
26
|
render(<EmailPreviewCard from={from} subject="Quarterly update" />)
|
|
@@ -29,7 +40,7 @@ describe("EmailPreviewCard", () => {
|
|
|
29
40
|
|
|
30
41
|
it("renders the recipient", () => {
|
|
31
42
|
render(<EmailPreviewCard from={from} to="jane@acme.com" />)
|
|
32
|
-
expect(screen.getByText("
|
|
43
|
+
expect(screen.getByText("jane@acme.com")).toBeTruthy()
|
|
33
44
|
expect(
|
|
34
45
|
screen.getByText(/This is how your email lands in jane@acme.com's inbox/),
|
|
35
46
|
).toBeTruthy()
|
|
@@ -37,7 +48,7 @@ describe("EmailPreviewCard", () => {
|
|
|
37
48
|
|
|
38
49
|
it("renders 'to no recipient yet' when no recipient", () => {
|
|
39
50
|
render(<EmailPreviewCard from={from} />)
|
|
40
|
-
expect(screen.getByText("
|
|
51
|
+
expect(screen.getByText("no recipient yet")).toBeTruthy()
|
|
41
52
|
expect(
|
|
42
53
|
screen.getByText(/This is how your email lands in the recipient's inbox/),
|
|
43
54
|
).toBeTruthy()
|
|
@@ -59,4 +70,27 @@ describe("EmailPreviewCard", () => {
|
|
|
59
70
|
)
|
|
60
71
|
expect(container.querySelector("em")?.textContent).toBe("Best, Cory")
|
|
61
72
|
})
|
|
73
|
+
|
|
74
|
+
it("decodes preview copy, displays To/Cc/Bcc, and renders superscript signatures", () => {
|
|
75
|
+
const { container } = render(
|
|
76
|
+
<EmailPreviewCard
|
|
77
|
+
from={{ name: "Cory & Co", email: "Cory Pitt <cory@withhandled.com>" }}
|
|
78
|
+
to={'"Jane & Team" <jane@example.com>'}
|
|
79
|
+
cc={["Ops <ops@example.com>"]}
|
|
80
|
+
bcc="Audit <audit@example.com>"
|
|
81
|
+
subject="Quarterly & renewal"
|
|
82
|
+
htmlBody="<p>Hello Jane & team — it's ready.</p>"
|
|
83
|
+
signatureHtml="<p>Handled<sup>AI</sup></p>"
|
|
84
|
+
/>,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
expect(screen.getByText("Cory & Co")).toBeTruthy()
|
|
88
|
+
expect(screen.getByText("Quarterly & renewal")).toBeTruthy()
|
|
89
|
+
expect(screen.getByText("Jane & Team <jane@example.com>")).toBeTruthy()
|
|
90
|
+
expect(screen.getByText("Ops <ops@example.com>")).toBeTruthy()
|
|
91
|
+
expect(screen.getByText("Audit <audit@example.com>")).toBeTruthy()
|
|
92
|
+
expect(screen.getByText("Hello Jane & team — it's ready.")).toBeTruthy()
|
|
93
|
+
expect(container.querySelector("sup")?.textContent).toBe("AI")
|
|
94
|
+
expectNoVisibleEscapeArtifacts(container.textContent ?? "")
|
|
95
|
+
})
|
|
62
96
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@testing-library/jest-dom/vitest"
|
|
2
2
|
import { describe, it, expect } from "vitest"
|
|
3
3
|
import React from "react"
|
|
4
|
-
import { render, screen } from "@testing-library/react"
|
|
4
|
+
import { fireEvent, render, screen } from "@testing-library/react"
|
|
5
5
|
import {
|
|
6
6
|
TimelineActivity,
|
|
7
7
|
TONE_CLASSES,
|
|
@@ -12,6 +12,17 @@ import {
|
|
|
12
12
|
// Helpers
|
|
13
13
|
// ---------------------------------------------------------------------------
|
|
14
14
|
|
|
15
|
+
function expectNoVisibleEscapeArtifacts(value: string) {
|
|
16
|
+
expect(value).not.toMatch(/&#(?:x[0-9a-f]+|\d+);?/i)
|
|
17
|
+
expect(value).not.toContain("&")
|
|
18
|
+
expect(value).not.toContain("<")
|
|
19
|
+
expect(value).not.toContain(">")
|
|
20
|
+
expect(value).not.toContain(""")
|
|
21
|
+
expect(value).not.toContain('\\"')
|
|
22
|
+
expect(value).not.toContain("\\'")
|
|
23
|
+
expect(value).not.toContain("\\n")
|
|
24
|
+
}
|
|
25
|
+
|
|
15
26
|
function minimal(overrides: Partial<TimelineEvent> = {}): TimelineEvent {
|
|
16
27
|
return {
|
|
17
28
|
id: "e1",
|
|
@@ -328,4 +339,45 @@ describe("TimelineActivity", () => {
|
|
|
328
339
|
"https://salesforce.example/case/1",
|
|
329
340
|
)
|
|
330
341
|
})
|
|
342
|
+
|
|
343
|
+
it("uses shared helpers for decoded timeline sender, timestamp, snippets, and collapsed details", () => {
|
|
344
|
+
const event = minimal({
|
|
345
|
+
isInteractive: true,
|
|
346
|
+
defaultExpanded: false,
|
|
347
|
+
email: {
|
|
348
|
+
from: "Cory & Co",
|
|
349
|
+
fromEmail: "cory@example.com",
|
|
350
|
+
to: "Jane & Team <jane@example.com>",
|
|
351
|
+
cc: "Ops <ops@example.com>",
|
|
352
|
+
date: "2026-06-08T15:30:00.000Z",
|
|
353
|
+
subject: "Update & next steps",
|
|
354
|
+
body: "plain fallback",
|
|
355
|
+
bodyHtml:
|
|
356
|
+
"<p>Hello Jane & team — it's ready.</p><p>Thanks,</p><p>Cory Pitt</p><p>Handled<sup>AI</sup></p>",
|
|
357
|
+
},
|
|
358
|
+
preview: "Hello Jane & team — it's ready.",
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
const { container } = render(<TimelineActivity events={[event]} />)
|
|
362
|
+
const collapsedText = container.textContent ?? ""
|
|
363
|
+
|
|
364
|
+
expect(collapsedText).toContain("Cory & Co")
|
|
365
|
+
expect(collapsedText).toContain("Update & next steps")
|
|
366
|
+
expect(collapsedText).toContain("Hello Jane & team — it's ready.")
|
|
367
|
+
expectNoVisibleEscapeArtifacts(collapsedText)
|
|
368
|
+
|
|
369
|
+
fireEvent.click(screen.getByRole("button", { name: /Expand/i }))
|
|
370
|
+
|
|
371
|
+
expect(screen.getByText("Jun 8, 2026, 3:30 PM")).toBeTruthy()
|
|
372
|
+
expect(screen.getByText(/Jane & Team <jane@example.com>/)).toBeTruthy()
|
|
373
|
+
expect(container.querySelector('[data-slot="email-body-details"]')).toBeNull()
|
|
374
|
+
expect(screen.getByRole("button", { name: "•••" })).toBeTruthy()
|
|
375
|
+
expect(container.textContent).not.toContain("HandledAI")
|
|
376
|
+
|
|
377
|
+
fireEvent.click(screen.getByRole("button", { name: "•••" }))
|
|
378
|
+
expect(container.querySelector("sup")?.textContent).toBe("AI")
|
|
379
|
+
expect(container.textContent).toContain("HandledAI")
|
|
380
|
+
expectNoVisibleEscapeArtifacts(container.textContent ?? "")
|
|
381
|
+
})
|
|
382
|
+
|
|
331
383
|
})
|