@handled-ai/design-system 0.18.3 → 0.18.4

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 (38) hide show
  1. package/dist/charts/chart.d.ts +1 -1
  2. package/dist/components/feedback-primitives.d.ts +41 -2
  3. package/dist/components/feedback-primitives.js +241 -6
  4. package/dist/components/feedback-primitives.js.map +1 -1
  5. package/dist/components/score-why-chips.d.ts +1 -1
  6. package/dist/components/score-why-chips.js +26 -5
  7. package/dist/components/score-why-chips.js.map +1 -1
  8. package/dist/components/signal-priority-popover.d.ts +1 -1
  9. package/dist/components/signal-priority-popover.js +32 -6
  10. package/dist/components/signal-priority-popover.js.map +1 -1
  11. package/dist/components/timeline-activity.d.ts +1 -16
  12. package/dist/components/timeline-activity.js +1 -69
  13. package/dist/components/timeline-activity.js.map +1 -1
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +2 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/prototype/index.d.ts +1 -1
  18. package/dist/prototype/prototype-accounts-view.d.ts +1 -1
  19. package/dist/prototype/prototype-admin-view.d.ts +1 -1
  20. package/dist/prototype/prototype-config.d.ts +1 -1
  21. package/dist/prototype/prototype-inbox-view.d.ts +2 -12
  22. package/dist/prototype/prototype-inbox-view.js +37 -102
  23. package/dist/prototype/prototype-inbox-view.js.map +1 -1
  24. package/dist/prototype/prototype-insights-view.d.ts +1 -1
  25. package/dist/prototype/prototype-shell.d.ts +1 -1
  26. package/dist/{signal-priority-popover-DQ_VuHac.d.ts → signal-priority-popover-DWaAMhPI.d.ts} +26 -2
  27. package/package.json +3 -1
  28. package/src/components/__tests__/wit-636-feedback-states.test.tsx +546 -0
  29. package/src/components/feedback-primitives.tsx +333 -26
  30. package/src/components/score-why-chips.tsx +28 -2
  31. package/src/components/signal-priority-popover.tsx +44 -4
  32. package/src/components/timeline-activity.tsx +1 -112
  33. package/src/index.ts +2 -2
  34. package/src/prototype/__tests__/detail-view-attention.test.tsx +2 -2
  35. package/src/prototype/prototype-config.ts +11 -1
  36. package/src/prototype/prototype-inbox-view.tsx +33 -131
  37. package/src/components/__tests__/timeline-activity.test.tsx +0 -137
  38. package/src/prototype/__tests__/detail-view-timeline-system-events.test.tsx +0 -322
@@ -1,322 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest"
2
- import React from "react"
3
- import { render, fireEvent } from "@testing-library/react"
4
- import { DetailView, type DetailViewProps } from "../prototype-inbox-view"
5
- import type { QueueItem, SignalScoreData } from "../prototype-config"
6
- import type { TimelineEvent } from "../../components/timeline-activity"
7
-
8
- // ---------------------------------------------------------------------------
9
- // Helpers
10
- // ---------------------------------------------------------------------------
11
-
12
- const baseItem: QueueItem = {
13
- id: "1",
14
- title: "Test Signal",
15
- details: "Some details",
16
- statusColor: "green",
17
- time: "2h ago",
18
- company: "Acme Inc",
19
- tag1: "renewal",
20
- }
21
-
22
- function makeSignalScore(): SignalScoreData {
23
- return {
24
- score: 75,
25
- factors: [
26
- { key: "trigger", label: "Trigger strength", score: 70, why: "Strong signal" },
27
- ],
28
- whyNow: "Strong signals detected.",
29
- evidence: ["Evidence line 1"],
30
- confidence: 80,
31
- }
32
- }
33
-
34
- const normalEvents: TimelineEvent[] = [
35
- {
36
- id: "t1",
37
- icon: React.createElement("span", null, "📧"),
38
- title: "Email sent",
39
- time: "1h ago",
40
- },
41
- {
42
- id: "t2",
43
- icon: React.createElement("span", null, "📞"),
44
- title: "Call logged",
45
- time: "3h ago",
46
- },
47
- ]
48
-
49
- const noiseEvents: TimelineEvent[] = [
50
- {
51
- id: "t3",
52
- icon: React.createElement("span", null, "📊"),
53
- title: "Score updated +3",
54
- time: "2h ago",
55
- isSystemNoise: true,
56
- },
57
- {
58
- id: "t4",
59
- icon: React.createElement("span", null, "📊"),
60
- title: "Score updated -1",
61
- time: "4h ago",
62
- isSystemNoise: true,
63
- },
64
- ]
65
-
66
- const mixedEvents: TimelineEvent[] = [...normalEvents, ...noiseEvents]
67
-
68
- function baseProps(overrides: Partial<DetailViewProps> = {}): DetailViewProps {
69
- return {
70
- item: baseItem,
71
- sections: { signalBrief: true, suggestedActions: false, timeline: true },
72
- getSignalScore: () => makeSignalScore(),
73
- buildSuggestedActions: () => [],
74
- buildSourceItems: () => [],
75
- getTimelineEvents: () => mixedEvents,
76
- accountContacts: [],
77
- emailSignature: "",
78
- iconMap: {},
79
- timelineSystemEventsToggleLabel: "Score changes",
80
- timelineSystemEventsStorageKey: "test-show-score-changes",
81
- timelineSystemEventsHiddenHint: "Score changes are hidden.",
82
- timelineSystemEventsVisibleHint: "Showing {count} score changes.",
83
- ...overrides,
84
- }
85
- }
86
-
87
- // Mock localStorage
88
- let store: Record<string, string> = {}
89
-
90
- const localStorageMock = {
91
- getItem: vi.fn((key: string) => store[key] ?? null),
92
- setItem: vi.fn((key: string, value: string) => {
93
- store[key] = value
94
- }),
95
- removeItem: vi.fn((key: string) => {
96
- delete store[key]
97
- }),
98
- clear: vi.fn(() => {
99
- store = {}
100
- }),
101
- }
102
-
103
- beforeEach(() => {
104
- store = {}
105
- localStorageMock.getItem.mockClear()
106
- localStorageMock.setItem.mockClear()
107
- localStorageMock.removeItem.mockClear()
108
- localStorageMock.clear.mockClear()
109
- // Reset getItem to default implementation
110
- localStorageMock.getItem.mockImplementation((key: string) => store[key] ?? null)
111
- Object.defineProperty(window, "localStorage", { value: localStorageMock, writable: true })
112
- })
113
-
114
- // ---------------------------------------------------------------------------
115
- // Helper to expand the timeline
116
- // ---------------------------------------------------------------------------
117
-
118
- function expandTimeline(container: HTMLElement) {
119
- const collapseBtn = container.querySelector(
120
- '[data-testid="timeline-collapse-btn"]',
121
- ) as HTMLElement
122
- if (collapseBtn) fireEvent.click(collapseBtn)
123
- }
124
-
125
- // ---------------------------------------------------------------------------
126
- // Tests
127
- // ---------------------------------------------------------------------------
128
-
129
- describe("DetailView timeline system-events toggle", () => {
130
- it("hides events with isSystemNoise: true by default", () => {
131
- const { container } = render(<DetailView {...baseProps()} />)
132
- // Expand the timeline
133
- expandTimeline(container)
134
- // Should only show 2 normal events, not the 2 noise events
135
- const eventCount = container.querySelector('[data-testid="event-count"]')
136
- expect(eventCount?.textContent).toBe("2 events")
137
- // Noise event titles should not appear
138
- expect(container.textContent).not.toContain("Score updated +3")
139
- expect(container.textContent).not.toContain("Score updated -1")
140
- })
141
-
142
- it("reveals system-noise events when toggle is clicked", () => {
143
- const { container } = render(<DetailView {...baseProps()} />)
144
- expandTimeline(container)
145
- // Click the toggle
146
- const toggle = container.querySelector(
147
- '[data-testid="system-events-toggle"]',
148
- ) as HTMLElement
149
- expect(toggle).not.toBeNull()
150
- fireEvent.click(toggle)
151
- // Now all 4 events should be visible
152
- const eventCount = container.querySelector('[data-testid="event-count"]')
153
- expect(eventCount?.textContent).toBe("4 events")
154
- expect(container.textContent).toContain("Score updated +3")
155
- })
156
-
157
- it("clicking the toggle does NOT collapse/expand the timeline", () => {
158
- const { container } = render(<DetailView {...baseProps()} />)
159
- expandTimeline(container)
160
- // Timeline should be expanded — normal events visible
161
- expect(container.textContent).toContain("Email sent")
162
-
163
- // Click the system-events toggle
164
- const toggle = container.querySelector(
165
- '[data-testid="system-events-toggle"]',
166
- ) as HTMLElement
167
- fireEvent.click(toggle)
168
-
169
- // Timeline should still be expanded
170
- expect(container.textContent).toContain("Email sent")
171
- })
172
-
173
- it("clicking the collapse button does NOT toggle system-event visibility", () => {
174
- const { container } = render(<DetailView {...baseProps()} />)
175
- expandTimeline(container)
176
-
177
- // Toggle system events on
178
- const toggle = container.querySelector(
179
- '[data-testid="system-events-toggle"]',
180
- ) as HTMLElement
181
- fireEvent.click(toggle)
182
- expect(container.textContent).toContain("Score updated +3")
183
-
184
- // Collapse the timeline
185
- expandTimeline(container)
186
- // Re-expand
187
- expandTimeline(container)
188
-
189
- // System events should still be visible (toggle didn't change)
190
- expect(container.textContent).toContain("Score updated +3")
191
- })
192
-
193
- it("header event count reflects visible events, not total events", () => {
194
- const { container } = render(<DetailView {...baseProps()} />)
195
- const eventCount = container.querySelector('[data-testid="event-count"]')
196
- expect(eventCount?.textContent).toBe("2 events")
197
- })
198
-
199
- it("hidden count badge shows the correct number", () => {
200
- const { container } = render(<DetailView {...baseProps()} />)
201
- const badge = container.querySelector('[data-testid="hidden-count-badge"]')
202
- expect(badge).not.toBeNull()
203
- expect(badge?.textContent).toBe("2")
204
- })
205
-
206
- it("calls localStorage.setItem when toggle changes", () => {
207
- const { container } = render(<DetailView {...baseProps()} />)
208
- expandTimeline(container)
209
- const toggle = container.querySelector(
210
- '[data-testid="system-events-toggle"]',
211
- ) as HTMLElement
212
- fireEvent.click(toggle)
213
- expect(localStorageMock.setItem).toHaveBeenCalledWith(
214
- "test-show-score-changes",
215
- "true",
216
- )
217
- })
218
-
219
- it("reads localStorage.getItem on mount and honors stored value", () => {
220
- store["test-show-score-changes"] = "true"
221
- const { container } = render(<DetailView {...baseProps()} />)
222
- expandTimeline(container)
223
- // With stored value "true", system events should be visible
224
- const eventCount = container.querySelector('[data-testid="event-count"]')
225
- expect(eventCount?.textContent).toBe("4 events")
226
- expect(localStorageMock.getItem).toHaveBeenCalledWith(
227
- "test-show-score-changes",
228
- )
229
- })
230
-
231
- it("renders header and toggle when all events are system noise and toggle is off", () => {
232
- const allNoiseProps = baseProps({
233
- getTimelineEvents: () => noiseEvents,
234
- })
235
- const { container } = render(<DetailView {...allNoiseProps} />)
236
- // Header should still be rendered
237
- const header = container.querySelector('[data-testid="timeline-header"]')
238
- expect(header).not.toBeNull()
239
- // Toggle should be present
240
- const toggle = container.querySelector(
241
- '[data-testid="system-events-toggle"]',
242
- )
243
- expect(toggle).not.toBeNull()
244
- // Event count should show 0 events
245
- const eventCount = container.querySelector('[data-testid="event-count"]')
246
- expect(eventCount?.textContent).toBe("0 events")
247
- })
248
-
249
- it("'Last activity' uses the first visible event's time, not a hidden system-noise event", () => {
250
- // Arrange: first event is system noise (time "30m ago"),
251
- // second event is normal (time "1h ago")
252
- const orderedEvents: TimelineEvent[] = [
253
- {
254
- id: "noise-first",
255
- icon: React.createElement("span", null, "📊"),
256
- title: "Score change",
257
- time: "30m ago",
258
- isSystemNoise: true,
259
- },
260
- {
261
- id: "normal-second",
262
- icon: React.createElement("span", null, "📧"),
263
- title: "Email sent",
264
- time: "1h ago",
265
- },
266
- ]
267
- const props = baseProps({ getTimelineEvents: () => orderedEvents })
268
- const { container } = render(<DetailView {...props} />)
269
- const hint = container.querySelector('[data-testid="last-activity-hint"]')
270
- expect(hint).not.toBeNull()
271
- // Should show "1h ago" (the first visible event), not "30m ago" (the hidden noise event)
272
- expect(hint?.textContent).toContain("1h ago")
273
- expect(hint?.textContent).not.toContain("30m ago")
274
- })
275
-
276
- it("uses singular grammar for 1 event and plural for multiple", () => {
277
- const singleEvent: TimelineEvent[] = [
278
- {
279
- id: "s1",
280
- icon: React.createElement("span", null, "📧"),
281
- title: "Email sent",
282
- time: "1h ago",
283
- },
284
- ]
285
- const props = baseProps({ getTimelineEvents: () => singleEvent })
286
- const { container } = render(<DetailView {...props} />)
287
- const eventCount = container.querySelector('[data-testid="event-count"]')
288
- expect(eventCount?.textContent).toBe("1 event")
289
- })
290
-
291
- it("does not render toggle when there are no system-noise events", () => {
292
- const props = baseProps({
293
- getTimelineEvents: () => normalEvents,
294
- })
295
- const { container } = render(<DetailView {...props} />)
296
- const toggle = container.querySelector(
297
- '[data-testid="system-events-toggle"]',
298
- )
299
- expect(toggle).toBeNull()
300
- })
301
-
302
- it("shows footer hint when timeline is expanded and system events are hidden", () => {
303
- const { container } = render(<DetailView {...baseProps()} />)
304
- expandTimeline(container)
305
- const hint = container.querySelector('[data-testid="timeline-footer-hint"]')
306
- expect(hint).not.toBeNull()
307
- expect(hint?.textContent).toBe("Score changes are hidden.")
308
- })
309
-
310
- it("shows visible footer hint with count when system events are shown", () => {
311
- const { container } = render(<DetailView {...baseProps()} />)
312
- expandTimeline(container)
313
- // Toggle on
314
- const toggle = container.querySelector(
315
- '[data-testid="system-events-toggle"]',
316
- ) as HTMLElement
317
- fireEvent.click(toggle)
318
- const hint = container.querySelector('[data-testid="timeline-footer-hint"]')
319
- expect(hint).not.toBeNull()
320
- expect(hint?.textContent).toBe("Showing 2 score changes.")
321
- })
322
- })