@remit/ui 0.0.164 → 0.0.166
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/package.json +1 -1
- package/src/components/calendar-clash-strip.render.test.ts +51 -0
- package/src/components/calendar-clash-strip.stories.tsx +56 -0
- package/src/components/calendar-clash-strip.tsx +64 -0
- package/src/components/calendar-invite-card.render.test.ts +110 -0
- package/src/components/calendar-invite-card.stories.tsx +132 -0
- package/src/components/calendar-invite-card.tsx +288 -0
- package/src/components/calendar-parse-badge.render.test.ts +40 -0
- package/src/components/calendar-parse-badge.stories.tsx +46 -0
- package/src/components/calendar-parse-badge.tsx +59 -0
- package/src/components/calendar-slot-offers.render.test.ts +67 -0
- package/src/components/calendar-slot-offers.stories.tsx +79 -0
- package/src/components/calendar-slot-offers.tsx +67 -0
- package/src/components/calendar-suggestion-deck.render.test.ts +69 -0
- package/src/components/calendar-suggestion-deck.stories.tsx +165 -0
- package/src/components/calendar-suggestion-deck.tsx +116 -0
- package/src/components/calendar-types.ts +57 -0
- package/src/components/event-suggestion-card.tsx +8 -1
- package/src/components/intelligence-calendar-fixtures.ts +384 -0
- package/src/components/intelligence-calendar.deck-zone-gate.test.ts +142 -0
- package/src/components/intelligence-calendar.render.test.ts +122 -0
- package/src/components/intelligence-calendar.tsx +288 -0
- package/src/components/intelligence-panel-calendar.stories.tsx +401 -0
- package/src/components/intelligence-panel.render.test.ts +64 -1
- package/src/components/intelligence-panel.stories.tsx +21 -0
- package/src/components/intelligence-panel.tab-strip.test.ts +163 -0
- package/src/components/intelligence-panel.tsx +265 -179
- package/src/components/intelligence-section.tsx +24 -0
- package/src/components/selection-wizard.render.test.ts +32 -0
- package/src/components/selection-wizard.tsx +28 -12
- package/src/index.ts +46 -0
- package/src/lib/semantic-off.ts +20 -0
|
@@ -3,7 +3,12 @@ import { describe, it } from "node:test";
|
|
|
3
3
|
import { createElement } from "react";
|
|
4
4
|
import { renderToString } from "react-dom/server";
|
|
5
5
|
import { categoryTone, isThreadCategory } from "./app-shell-types.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { IntelligenceCalendarActions } from "./intelligence-calendar.js";
|
|
7
|
+
import { inviteWithClash } from "./intelligence-calendar-fixtures.js";
|
|
8
|
+
import type {
|
|
9
|
+
IntelligenceData,
|
|
10
|
+
IntelligenceTabId,
|
|
11
|
+
} from "./intelligence-panel.js";
|
|
7
12
|
import { IntelligencePanel } from "./intelligence-panel.js";
|
|
8
13
|
|
|
9
14
|
const vipWithFailingAuthenticity: IntelligenceData = {
|
|
@@ -79,6 +84,64 @@ describe("IntelligencePanel category chip", () => {
|
|
|
79
84
|
});
|
|
80
85
|
});
|
|
81
86
|
|
|
87
|
+
const inertCalendar: IntelligenceCalendarActions = {
|
|
88
|
+
onAddInvite: () => undefined,
|
|
89
|
+
onTentativeInvite: () => undefined,
|
|
90
|
+
onDeclineInvite: () => undefined,
|
|
91
|
+
onReopenInvite: () => undefined,
|
|
92
|
+
onOfferOtherTimes: () => undefined,
|
|
93
|
+
onRemoveInvite: () => undefined,
|
|
94
|
+
onOpenNewerInvite: () => undefined,
|
|
95
|
+
onToggleSlot: () => undefined,
|
|
96
|
+
onAddSuggestion: () => undefined,
|
|
97
|
+
onReviewSuggestion: () => undefined,
|
|
98
|
+
onDismissSuggestion: () => undefined,
|
|
99
|
+
onOpenThread: () => undefined,
|
|
100
|
+
onSelectEvent: () => undefined,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
function panel(tab: IntelligenceTabId): string {
|
|
104
|
+
return renderToString(
|
|
105
|
+
createElement(IntelligencePanel, {
|
|
106
|
+
data: vipWithFailingAuthenticity,
|
|
107
|
+
calendar: { data: inviteWithClash, actions: inertCalendar },
|
|
108
|
+
tab,
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
describe("IntelligencePanel tab strip", () => {
|
|
114
|
+
it("offers no strip to a host that wired no calendar", () => {
|
|
115
|
+
const html = renderToString(
|
|
116
|
+
createElement(IntelligencePanel, { data: vipWithFailingAuthenticity }),
|
|
117
|
+
);
|
|
118
|
+
assert.doesNotMatch(html, /radiogroup/);
|
|
119
|
+
assert.match(html, /Authenticity/);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("leaves the sender stack exactly where it was", () => {
|
|
123
|
+
const withStrip = panel("sender");
|
|
124
|
+
assert.match(withStrip, /radiogroup/);
|
|
125
|
+
for (const section of [
|
|
126
|
+
"Sender",
|
|
127
|
+
"Authenticity",
|
|
128
|
+
"Category",
|
|
129
|
+
"Quick actions",
|
|
130
|
+
"Coming soon",
|
|
131
|
+
]) {
|
|
132
|
+
assert.match(withStrip, new RegExp(section), section);
|
|
133
|
+
}
|
|
134
|
+
assert.doesNotMatch(withStrip, /Add to calendar/);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("swaps the stack for the calendar rather than stacking both", () => {
|
|
138
|
+
const calendar = panel("calendar");
|
|
139
|
+
assert.match(calendar, /Add to calendar/);
|
|
140
|
+
assert.doesNotMatch(calendar, /Coming soon/);
|
|
141
|
+
assert.doesNotMatch(calendar, /Quick actions/);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
82
145
|
describe("isThreadCategory", () => {
|
|
83
146
|
it("accepts every category the tone map covers", () => {
|
|
84
147
|
for (const category of Object.keys(categoryTone)) {
|
|
@@ -201,6 +201,27 @@ export const WithSimilarMessages: Story = {
|
|
|
201
201
|
},
|
|
202
202
|
};
|
|
203
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Semantic search is off on this instance (#1068). The section states the
|
|
206
|
+
* setting, what turning it on buys — the Organize widen and semantic filters —
|
|
207
|
+
* and the command, rather than rendering nothing and reading as a sender
|
|
208
|
+
* nothing resembles.
|
|
209
|
+
*/
|
|
210
|
+
export const SimilarMessagesOff: Story = {
|
|
211
|
+
args: {
|
|
212
|
+
data: base,
|
|
213
|
+
similarState: "off",
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/** The runtime failure, for contrast: a retry might work, so it says no more. */
|
|
218
|
+
export const SimilarMessagesUnavailable: Story = {
|
|
219
|
+
args: {
|
|
220
|
+
data: base,
|
|
221
|
+
similarState: "error",
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
|
|
204
225
|
/**
|
|
205
226
|
* The spam quick actions are a contextual pair, decided by whether the message
|
|
206
227
|
* carries a spam report — never by the mailbox it happens to sit in, since a
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The strip against each host shape. A host that only wants to hear about the
|
|
3
|
+
* change — it passes `onTabChange` and no `tab` — still has to see the strip
|
|
4
|
+
* move, or the panel is stuck on whatever it opened with.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import "@remit/test-dom";
|
|
8
|
+
import assert from "node:assert/strict";
|
|
9
|
+
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
10
|
+
import { act, createElement } from "react";
|
|
11
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
12
|
+
import type { IntelligenceCalendarActions } from "./intelligence-calendar.js";
|
|
13
|
+
import { inviteWithClash } from "./intelligence-calendar-fixtures.js";
|
|
14
|
+
import {
|
|
15
|
+
type IntelligenceData,
|
|
16
|
+
IntelligencePanel,
|
|
17
|
+
type IntelligenceTabId,
|
|
18
|
+
} from "./intelligence-panel.js";
|
|
19
|
+
|
|
20
|
+
const sender: IntelligenceData = {
|
|
21
|
+
sender: {
|
|
22
|
+
name: "Priya Natarajan",
|
|
23
|
+
email: "priya@northwind.example",
|
|
24
|
+
trust: "wellknown",
|
|
25
|
+
firstSeenLabel: "Jan 2024",
|
|
26
|
+
inboundCount: 41,
|
|
27
|
+
replyCount: 29,
|
|
28
|
+
},
|
|
29
|
+
authenticity: {
|
|
30
|
+
verdict: "aligned",
|
|
31
|
+
fromDomain: "northwind.example",
|
|
32
|
+
summary: "Nothing looks unusual about this sender.",
|
|
33
|
+
},
|
|
34
|
+
category: { value: "personal" },
|
|
35
|
+
flags: {},
|
|
36
|
+
similar: [],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const inertCalendar: IntelligenceCalendarActions = {
|
|
40
|
+
onAddInvite: () => undefined,
|
|
41
|
+
onTentativeInvite: () => undefined,
|
|
42
|
+
onDeclineInvite: () => undefined,
|
|
43
|
+
onReopenInvite: () => undefined,
|
|
44
|
+
onOfferOtherTimes: () => undefined,
|
|
45
|
+
onRemoveInvite: () => undefined,
|
|
46
|
+
onOpenNewerInvite: () => undefined,
|
|
47
|
+
onToggleSlot: () => undefined,
|
|
48
|
+
onAddSuggestion: () => undefined,
|
|
49
|
+
onReviewSuggestion: () => undefined,
|
|
50
|
+
onDismissSuggestion: () => undefined,
|
|
51
|
+
onOpenThread: () => undefined,
|
|
52
|
+
onSelectEvent: () => undefined,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
let container: HTMLElement;
|
|
56
|
+
let root: Root;
|
|
57
|
+
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
container = document.getElementById("root") as unknown as HTMLElement;
|
|
60
|
+
container.innerHTML = "";
|
|
61
|
+
root = createRoot(container);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
afterEach(() => {
|
|
65
|
+
act(() => {
|
|
66
|
+
root.unmount();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
function mount(props: {
|
|
71
|
+
tab?: IntelligenceTabId;
|
|
72
|
+
onTabChange?: (next: IntelligenceTabId) => void;
|
|
73
|
+
}) {
|
|
74
|
+
act(() => {
|
|
75
|
+
root.render(
|
|
76
|
+
createElement(IntelligencePanel, {
|
|
77
|
+
data: sender,
|
|
78
|
+
calendar: { data: inviteWithClash, actions: inertCalendar },
|
|
79
|
+
...props,
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function pickTab(label: string) {
|
|
86
|
+
const segment = Array.from(container.querySelectorAll("label")).find(
|
|
87
|
+
(candidate) => candidate.textContent?.includes(label),
|
|
88
|
+
);
|
|
89
|
+
assert.ok(segment, `no segment reading ${label}`);
|
|
90
|
+
const radio = segment.querySelector("input");
|
|
91
|
+
assert.ok(radio, "the segment carries no radio to press");
|
|
92
|
+
act(() => {
|
|
93
|
+
radio.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function showingCalendar(): boolean {
|
|
98
|
+
return container.textContent?.includes("Add to calendar") ?? false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
describe("the tab strip", () => {
|
|
102
|
+
it("moves for a host that listens but holds no tab of its own", () => {
|
|
103
|
+
const heard: IntelligenceTabId[] = [];
|
|
104
|
+
mount({ onTabChange: (next) => heard.push(next) });
|
|
105
|
+
|
|
106
|
+
assert.equal(showingCalendar(), false);
|
|
107
|
+
pickTab("Calendar");
|
|
108
|
+
|
|
109
|
+
assert.deepEqual(heard, ["calendar"]);
|
|
110
|
+
assert.equal(showingCalendar(), true);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("moves for a host that neither holds nor listens", () => {
|
|
114
|
+
mount({});
|
|
115
|
+
|
|
116
|
+
pickTab("Calendar");
|
|
117
|
+
|
|
118
|
+
assert.equal(showingCalendar(), true);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("leaves the tab to a host that holds it", () => {
|
|
122
|
+
const heard: IntelligenceTabId[] = [];
|
|
123
|
+
mount({ tab: "sender", onTabChange: (next) => heard.push(next) });
|
|
124
|
+
|
|
125
|
+
pickTab("Calendar");
|
|
126
|
+
|
|
127
|
+
assert.deepEqual(heard, ["calendar"]);
|
|
128
|
+
assert.equal(
|
|
129
|
+
showingCalendar(),
|
|
130
|
+
false,
|
|
131
|
+
"a controlled panel moves only when its host says so",
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe("two panels on one page", () => {
|
|
137
|
+
it("group their radios apart, so answering one never clears the other", () => {
|
|
138
|
+
const second = document.createElement("div");
|
|
139
|
+
document.body.appendChild(second);
|
|
140
|
+
const secondRoot = createRoot(second);
|
|
141
|
+
mount({});
|
|
142
|
+
act(() => {
|
|
143
|
+
secondRoot.render(
|
|
144
|
+
createElement(IntelligencePanel, {
|
|
145
|
+
data: sender,
|
|
146
|
+
calendar: { data: inviteWithClash, actions: inertCalendar },
|
|
147
|
+
}),
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const names = [container, second].map((host) =>
|
|
152
|
+
host.querySelector("input")?.getAttribute("name"),
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
assert.ok(names[0]);
|
|
156
|
+
assert.notEqual(names[0], names[1]);
|
|
157
|
+
|
|
158
|
+
act(() => {
|
|
159
|
+
secondRoot.unmount();
|
|
160
|
+
});
|
|
161
|
+
second.remove();
|
|
162
|
+
});
|
|
163
|
+
});
|