@crvouga/mockingbird-notifications 0.1.0 → 0.2.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/README.md +96 -17
- package/dist/{chunk-QE3TRUI6.js → chunk-3HF2NSFV.js} +280 -10
- package/dist/chunk-3HF2NSFV.js.map +7 -0
- package/dist/chunk-4QVURMVP.js +400 -0
- package/dist/chunk-4QVURMVP.js.map +7 -0
- package/dist/{chunk-LM7R7AR7.js → chunk-FBJ2DRHH.js} +58 -6
- package/dist/chunk-FBJ2DRHH.js.map +7 -0
- package/dist/chunk-GHIEYY5B.js +1177 -0
- package/dist/chunk-GHIEYY5B.js.map +7 -0
- package/dist/cli.js +12 -4
- package/dist/cli.js.map +2 -2
- package/dist/index.d.ts +130 -11
- package/dist/index.js +9 -6
- package/dist/index.js.map +2 -2
- package/dist/server.d.ts +91 -6
- package/dist/server.js +7 -3
- package/dist/ui.d.ts +383 -229
- package/dist/ui.js +808 -133
- package/dist/ui.js.map +4 -4
- package/package.json +14 -10
- package/dist/chunk-GRGR3QZM.js +0 -1066
- package/dist/chunk-GRGR3QZM.js.map +0 -7
- package/dist/chunk-JQ6KPT2C.js +0 -202
- package/dist/chunk-JQ6KPT2C.js.map +0 -7
- package/dist/chunk-LM7R7AR7.js.map +0 -7
- package/dist/chunk-QE3TRUI6.js.map +0 -7
package/dist/ui.d.ts
CHANGED
|
@@ -1,7 +1,254 @@
|
|
|
1
|
-
/** The
|
|
2
|
-
|
|
1
|
+
/** The class on the UI root. Every rule below is scoped to it. */
|
|
2
|
+
declare const ROOT_CLASS = "mb-notifications";
|
|
3
|
+
/** The stylesheet, every rule scoped to `.mb-notifications`. */
|
|
4
|
+
declare const STYLES: string;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Every `data-testid` the harness UI renders, and selector helpers for browser tests.
|
|
8
|
+
*
|
|
9
|
+
* Elements that show one notification also carry its fields as attributes, so a test can narrow by
|
|
10
|
+
* what it knows instead of by position:
|
|
11
|
+
*
|
|
12
|
+
* data-notification-id data-channel data-service data-source data-to data-from
|
|
13
|
+
* data-status data-created-at data-unread ("true" | "false")
|
|
14
|
+
* data-via ("whatsapp", only on WhatsApp messages)
|
|
15
|
+
*
|
|
16
|
+
* The UI root (`TEST_IDS.app`) reports its state the same way: `data-ready` ("true" once the first
|
|
17
|
+
* read finished), `data-view`, `data-namespace`, `data-count`, `data-version`, `data-connected`,
|
|
18
|
+
* `data-sound`, `data-motion`, `data-layout` ("grid" = devices side by side, "tabs" = one device at
|
|
19
|
+
* a time) and `data-tab` (the selected channel tab: "all", "sms", "push", "email" or "chat").
|
|
20
|
+
*
|
|
21
|
+
* This module has no dependencies, so Playwright, Cypress or WebdriverIO specs can import it.
|
|
22
|
+
*/
|
|
23
|
+
declare const TEST_IDS: {
|
|
24
|
+
/** The UI root. */
|
|
25
|
+
readonly app: "notifications-app";
|
|
26
|
+
readonly topbar: "topbar";
|
|
27
|
+
/** `<select>` of namespaces. */
|
|
28
|
+
readonly namespace: "namespace";
|
|
29
|
+
/** Filter `<input>` (recipient, sender, text). */
|
|
30
|
+
readonly search: "search";
|
|
31
|
+
/** View tabs; `aria-pressed="true"` on the active one. */
|
|
32
|
+
readonly viewDevices: "view-devices";
|
|
33
|
+
readonly viewTimeline: "view-timeline";
|
|
34
|
+
/** "Follow new" checkbox. */
|
|
35
|
+
readonly follow: "follow";
|
|
36
|
+
/** Sound on/off button; `aria-pressed`. */
|
|
37
|
+
readonly sound: "sound-toggle";
|
|
38
|
+
/** Live stream indicator; `data-state="live" | "reconnecting"`. */
|
|
39
|
+
readonly connection: "connection";
|
|
40
|
+
/** One pill per emulator; `data-name`, `data-service`, `data-ok`, `data-count`. */
|
|
41
|
+
readonly source: "source";
|
|
42
|
+
/** Discovery or emulator errors, or the "no emulators" hint; `data-kind="error" | "empty"`. */
|
|
43
|
+
readonly notice: "notice";
|
|
44
|
+
/** Bottom-left message after an action, e.g. "Conversation archived." */
|
|
45
|
+
readonly toast: "toast";
|
|
46
|
+
readonly toastUndo: "toast-undo";
|
|
47
|
+
/** The `role="tablist"` that switches between devices; `data-layout="grid" | "tabs"`. */
|
|
48
|
+
readonly channelTabs: "channel-tabs";
|
|
49
|
+
/** One `role="tab"`; `data-value="all" | "sms" | "push" | "email" | "chat"`, `aria-selected`, `data-unread` (a count). */
|
|
50
|
+
readonly channelTab: "channel-tab";
|
|
51
|
+
/** Unread badge on a tab whose device is not showing its newest arrivals (absent when 0). */
|
|
52
|
+
readonly channelTabUnread: "channel-tab-unread";
|
|
53
|
+
/** The phone; `data-screen="threads" | "conversation"`, `data-recipient`, `data-thread`, and `data-via="whatsapp"` while a WhatsApp chat is open. */
|
|
54
|
+
readonly smsDevice: "sms-device";
|
|
55
|
+
/** Phone number `<select>`; option values are E.164 numbers. */
|
|
56
|
+
readonly smsRecipient: "sms-recipient";
|
|
57
|
+
/** Unread SMS badge next to the column title (absent when 0). */
|
|
58
|
+
readonly smsUnreadCount: "sms-unread-count";
|
|
59
|
+
/** One conversation in the list; `data-from` (the sender address), `data-unread`, `data-pinned`, `data-muted`, `data-via`. */
|
|
60
|
+
readonly smsThread: "sms-thread";
|
|
61
|
+
readonly smsThreadName: "sms-thread-name";
|
|
62
|
+
readonly smsThreadPreview: "sms-thread-preview";
|
|
63
|
+
readonly smsThreadTime: "sms-thread-time";
|
|
64
|
+
readonly smsThreadUnread: "sms-thread-unread";
|
|
65
|
+
/** "WhatsApp" label on a WhatsApp conversation in the list. */
|
|
66
|
+
readonly smsThreadVia: "sms-thread-via";
|
|
67
|
+
/** Swipe actions behind a thread (also reachable with the keyboard: focus the thread, press Delete). */
|
|
68
|
+
readonly smsThreadDelete: "sms-thread-delete";
|
|
69
|
+
readonly smsThreadMute: "sms-thread-mute";
|
|
70
|
+
readonly smsThreadPin: "sms-thread-pin";
|
|
71
|
+
readonly smsThreadToggleUnread: "sms-thread-toggle-unread";
|
|
72
|
+
/** Shown when the phone has no messages. */
|
|
73
|
+
readonly smsEmpty: "sms-empty";
|
|
74
|
+
/** An open conversation; `data-from`, `data-via="sms" | "whatsapp"`. */
|
|
75
|
+
readonly smsConversation: "sms-conversation";
|
|
76
|
+
readonly smsConversationTitle: "sms-conversation-title";
|
|
77
|
+
readonly smsBack: "sms-back";
|
|
78
|
+
/** One message; carries the notification attributes plus `data-code` when it holds a one-time code. */
|
|
79
|
+
readonly smsBubble: "sms-bubble";
|
|
80
|
+
readonly smsBubbleMedia: "sms-bubble-media";
|
|
81
|
+
/** The time revealed by swiping the conversation left. */
|
|
82
|
+
readonly smsBubbleTime: "sms-bubble-time";
|
|
83
|
+
/** A reaction added with the long-press menu; `data-tapback`. */
|
|
84
|
+
readonly smsTapback: "sms-tapback";
|
|
85
|
+
/** Centered date stamp between messages. */
|
|
86
|
+
readonly smsTimestamp: "sms-timestamp";
|
|
87
|
+
/** One-time code suggestion above the keyboard; `data-code`. */
|
|
88
|
+
readonly smsCode: "sms-code";
|
|
89
|
+
/** Long-press menu on a bubble. */
|
|
90
|
+
readonly smsMenu: "sms-menu";
|
|
91
|
+
readonly smsMenuCopy: "sms-menu-copy";
|
|
92
|
+
/** One tapback in the menu; `data-tapback="heart" | "like" | "dislike" | "laugh" | "emphasize" | "question"`. */
|
|
93
|
+
readonly smsMenuTapback: "sms-menu-tapback";
|
|
94
|
+
/** The phone; `data-skin="ios" | "android"`, `data-recipient`, `data-platform`. */
|
|
95
|
+
readonly pushDevice: "push-device";
|
|
96
|
+
/** Device token `<select>`. */
|
|
97
|
+
readonly pushRecipient: "push-recipient";
|
|
98
|
+
/** Skin buttons; `data-value`, `aria-pressed`. */
|
|
99
|
+
readonly pushSkin: "push-skin";
|
|
100
|
+
readonly pushUnreadCount: "push-unread-count";
|
|
101
|
+
/** One notification; notification attributes plus `data-expanded`, `data-platform`, `data-app`, `data-stacked`. */
|
|
102
|
+
readonly pushNotification: "push-notification";
|
|
103
|
+
readonly pushNotificationApp: "push-notification-app";
|
|
104
|
+
readonly pushNotificationTitle: "push-notification-title";
|
|
105
|
+
readonly pushNotificationBody: "push-notification-body";
|
|
106
|
+
readonly pushNotificationTime: "push-notification-time";
|
|
107
|
+
readonly pushNotificationImage: "push-notification-image";
|
|
108
|
+
/** The `data` payload, shown when expanded. */
|
|
109
|
+
readonly pushNotificationData: "push-notification-data";
|
|
110
|
+
/** Service, status, badge and sound, shown when expanded. */
|
|
111
|
+
readonly pushNotificationMeta: "push-notification-meta";
|
|
112
|
+
/** iOS: a group of notifications from one app; `data-app`, `data-count`, `data-open`. */
|
|
113
|
+
readonly pushGroup: "push-group";
|
|
114
|
+
/** iOS: "N more notifications" under a collapsed group (click to open it); `data-count`. */
|
|
115
|
+
readonly pushGroupMore: "push-group-more";
|
|
116
|
+
/** iOS: "Show less" on an open group. */
|
|
117
|
+
readonly pushGroupCollapse: "push-group-collapse";
|
|
118
|
+
/** iOS: swipe-left actions. */
|
|
119
|
+
readonly pushClear: "push-clear";
|
|
120
|
+
readonly pushOptions: "push-options";
|
|
121
|
+
/** iOS long-press preview; Android long-press settings. */
|
|
122
|
+
readonly pushPreview: "push-preview";
|
|
123
|
+
readonly pushSettings: "push-settings";
|
|
124
|
+
/** Android "Clear all". */
|
|
125
|
+
readonly pushClearAll: "push-clear-all";
|
|
126
|
+
readonly pushEmpty: "push-empty";
|
|
127
|
+
/** The browser window; `data-screen="inbox" | "message"`, `data-recipient`. */
|
|
128
|
+
readonly emailDevice: "email-device";
|
|
129
|
+
/** Mailbox `<select>`; option values are lower-case addresses. */
|
|
130
|
+
readonly emailRecipient: "email-recipient";
|
|
131
|
+
readonly emailUnreadCount: "email-unread-count";
|
|
132
|
+
/** One inbox row; notification attributes plus `data-starred`. */
|
|
133
|
+
readonly emailRow: "email-row";
|
|
134
|
+
readonly emailRowFrom: "email-row-from";
|
|
135
|
+
readonly emailRowSubject: "email-row-subject";
|
|
136
|
+
readonly emailRowSnippet: "email-row-snippet";
|
|
137
|
+
readonly emailRowDate: "email-row-date";
|
|
138
|
+
readonly emailRowService: "email-row-service";
|
|
139
|
+
readonly emailRowAttachment: "email-row-attachment";
|
|
140
|
+
readonly emailRowStar: "email-row-star";
|
|
141
|
+
/** Hover actions on a row. */
|
|
142
|
+
readonly emailRowArchive: "email-row-archive";
|
|
143
|
+
readonly emailRowDelete: "email-row-delete";
|
|
144
|
+
readonly emailRowToggleRead: "email-row-toggle-read";
|
|
145
|
+
readonly emailRefresh: "email-refresh";
|
|
146
|
+
readonly emailEmpty: "email-empty";
|
|
147
|
+
/** The open message; notification attributes. */
|
|
148
|
+
readonly emailOpen: "email-open";
|
|
149
|
+
readonly emailBack: "email-back";
|
|
150
|
+
readonly emailArchive: "email-archive";
|
|
151
|
+
readonly emailDelete: "email-delete";
|
|
152
|
+
readonly emailMarkUnread: "email-mark-unread";
|
|
153
|
+
readonly emailSubject: "email-subject";
|
|
154
|
+
readonly emailFromName: "email-from-name";
|
|
155
|
+
readonly emailFromAddress: "email-from-address";
|
|
156
|
+
/** "to me, …" line; click to toggle the details. */
|
|
157
|
+
readonly emailTo: "email-to";
|
|
158
|
+
readonly emailDate: "email-date";
|
|
159
|
+
readonly emailDetails: "email-details";
|
|
160
|
+
/** One row of the details; `data-field="from" | "to" | "cc" | "bcc" | "reply-to" | "date" | "subject" | "mailed-by" | "message-id"`. */
|
|
161
|
+
readonly emailDetail: "email-detail";
|
|
162
|
+
/** The HTML body `<iframe>` (same origin: use `frameLocator`). */
|
|
163
|
+
readonly emailBody: "email-body";
|
|
164
|
+
/** The plain-text body when there is no HTML. */
|
|
165
|
+
readonly emailText: "email-text";
|
|
166
|
+
readonly emailAttachments: "email-attachments";
|
|
167
|
+
/** One attachment; `data-filename`, `data-content-type`, `data-size`. */
|
|
168
|
+
readonly emailAttachment: "email-attachment";
|
|
169
|
+
/** The chat window; `data-recipient` (the open channel), `data-workspace`. */
|
|
170
|
+
readonly chatDevice: "chat-device";
|
|
171
|
+
/** Channel `<select>`; option values are channel names (`#alerts`) or webhook paths. */
|
|
172
|
+
readonly chatRecipient: "chat-recipient";
|
|
173
|
+
readonly chatUnreadCount: "chat-unread-count";
|
|
174
|
+
readonly chatWorkspace: "chat-workspace";
|
|
175
|
+
/** One channel in the sidebar; `data-to`, `data-unread` (a count), `aria-current`. */
|
|
176
|
+
readonly chatChannel: "chat-channel";
|
|
177
|
+
/** The open channel's name in the header. */
|
|
178
|
+
readonly chatTitle: "chat-title";
|
|
179
|
+
/** One message; notification attributes plus `data-method`, `data-ephemeral`, `data-thread`. */
|
|
180
|
+
readonly chatMessage: "chat-message";
|
|
181
|
+
readonly chatMessageAuthor: "chat-message-author";
|
|
182
|
+
readonly chatMessageTime: "chat-message-time";
|
|
183
|
+
/** The message text, with mrkdwn formatting applied. */
|
|
184
|
+
readonly chatMessageText: "chat-message-text";
|
|
185
|
+
/** Block Kit blocks; each block inside carries `data-block="<type>"`. */
|
|
186
|
+
readonly chatMessageBlocks: "chat-message-blocks";
|
|
187
|
+
/** Legacy attachments; each one inside carries `data-color`. */
|
|
188
|
+
readonly chatMessageAttachments: "chat-message-attachments";
|
|
189
|
+
/** One reaction; `data-name`, `data-count`. */
|
|
190
|
+
readonly chatMessageReaction: "chat-message-reaction";
|
|
191
|
+
readonly chatEmpty: "chat-empty";
|
|
192
|
+
readonly timeline: "timeline";
|
|
193
|
+
/** One row; notification attributes. Click it to inspect. */
|
|
194
|
+
readonly timelineRow: "timeline-row";
|
|
195
|
+
readonly timelineEmpty: "timeline-empty";
|
|
196
|
+
/** The JSON inspector; notification attributes. Opened by clicking a timeline row or double-clicking any notification. */
|
|
197
|
+
readonly inspector: "inspector";
|
|
198
|
+
readonly inspectorTitle: "inspector-title";
|
|
199
|
+
readonly inspectorClose: "inspector-close";
|
|
200
|
+
readonly inspectorShowOnDevice: "inspector-show-on-device";
|
|
201
|
+
/** One normalized field; `data-field`. */
|
|
202
|
+
readonly inspectorField: "inspector-field";
|
|
203
|
+
/** The full record, normalized fields plus `raw`, as JSON text. */
|
|
204
|
+
readonly inspectorJson: "inspector-json";
|
|
205
|
+
/** The dashboard root; `data-tab` is the open tab's id. */
|
|
206
|
+
readonly dashboard: "dashboard";
|
|
207
|
+
/** One tab button; `data-tab` (`emulators`, `notifications`, or an embedder's id), `aria-selected`. */
|
|
208
|
+
readonly dashboardTab: "dashboard-tab";
|
|
209
|
+
/** One tab's panel; `data-tab`. Hidden unless its tab is open. */
|
|
210
|
+
readonly dashboardPanel: "dashboard-panel";
|
|
211
|
+
/** Notifications that arrived while another tab was open; `data-count`. Hidden at 0. */
|
|
212
|
+
readonly dashboardBadge: "dashboard-badge";
|
|
213
|
+
};
|
|
214
|
+
type TestId = (typeof TEST_IDS)[keyof typeof TEST_IDS];
|
|
215
|
+
/** CSS selectors for the harness UI. Each one works with `page.locator()` or `querySelector`. */
|
|
216
|
+
declare const selectors: {
|
|
217
|
+
/** `[data-testid="…"]` */
|
|
218
|
+
testId: (id: TestId) => string;
|
|
219
|
+
/** The ready UI root: wait for this before asserting. */
|
|
220
|
+
ready: () => string;
|
|
221
|
+
/** Any element showing this notification (bubble, thread, card, row, open email, timeline row). */
|
|
222
|
+
notification: (id: string) => string;
|
|
223
|
+
/** A message bubble, optionally from one sender. */
|
|
224
|
+
smsBubble: (filter?: {
|
|
225
|
+
from?: string;
|
|
226
|
+
id?: string;
|
|
227
|
+
}) => string;
|
|
228
|
+
/** A conversation in the Messages list. */
|
|
229
|
+
smsThread: (from: string) => string;
|
|
230
|
+
/** A channel tab: `"all"`, `"sms"`, `"push"`, `"email"` or `"chat"`. */
|
|
231
|
+
channelTab: (value: "all" | "sms" | "push" | "email" | "chat") => string;
|
|
232
|
+
/** A chat message, optionally by id. */
|
|
233
|
+
chatMessage: (id?: string) => string;
|
|
234
|
+
/** A channel in the chat sidebar. */
|
|
235
|
+
chatChannel: (to: string) => string;
|
|
236
|
+
/** A push notification card, optionally by id. */
|
|
237
|
+
pushNotification: (id?: string) => string;
|
|
238
|
+
/** An inbox row, optionally by id. */
|
|
239
|
+
emailRow: (id?: string) => string;
|
|
240
|
+
/** A timeline row, optionally by id. */
|
|
241
|
+
timelineRow: (id?: string) => string;
|
|
242
|
+
/** A dashboard tab button by tab id (`emulators`, `notifications`, …). */
|
|
243
|
+
dashboardTab: (id: string) => string;
|
|
244
|
+
/** A dashboard tab's panel by tab id. */
|
|
245
|
+
dashboardPanel: (id: string) => string;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/** The kinds of device a notification lands on. */
|
|
249
|
+
type Channel = "sms" | "email" | "push" | "chat";
|
|
3
250
|
/** Emulators the harness knows how to read. */
|
|
4
|
-
type ServiceKind = "twilio" | "resend" | "fcm" | "ses" | "sns" | "customerio" | "mailosaur";
|
|
251
|
+
type ServiceKind = "twilio" | "resend" | "fcm" | "ses" | "sns" | "customerio" | "mailosaur" | "slack";
|
|
5
252
|
type Address = {
|
|
6
253
|
name: string | null;
|
|
7
254
|
address: string;
|
|
@@ -11,6 +258,8 @@ type SmsContent = {
|
|
|
11
258
|
/** One-time code the sender included (Twilio Verify), when known. */
|
|
12
259
|
code: string | null;
|
|
13
260
|
media: string[];
|
|
261
|
+
/** `whatsapp` when the message went to a `whatsapp:` address; plain text messages omit it. */
|
|
262
|
+
via?: "sms" | "whatsapp";
|
|
14
263
|
};
|
|
15
264
|
type EmailAttachment = {
|
|
16
265
|
filename: string;
|
|
@@ -39,6 +288,31 @@ type PushContent = {
|
|
|
39
288
|
badge: number | null;
|
|
40
289
|
sound: string | null;
|
|
41
290
|
};
|
|
291
|
+
type ChatReaction = {
|
|
292
|
+
name: string;
|
|
293
|
+
count: number;
|
|
294
|
+
};
|
|
295
|
+
/** A message posted into a team chat channel (Slack). */
|
|
296
|
+
type ChatContent = {
|
|
297
|
+
/** The message text, in the provider's own markup (Slack mrkdwn). */
|
|
298
|
+
text: string;
|
|
299
|
+
/** Workspace the message was posted in. */
|
|
300
|
+
workspace: string | null;
|
|
301
|
+
/** How it arrived: `chat.postMessage`, `chat.postEphemeral` or `incoming-webhook`. */
|
|
302
|
+
method: string;
|
|
303
|
+
/** Block Kit blocks, exactly as sent. */
|
|
304
|
+
blocks: unknown[];
|
|
305
|
+
/** Legacy attachments, exactly as sent. */
|
|
306
|
+
attachments: unknown[];
|
|
307
|
+
/** Parent message timestamp when this is a threaded reply. */
|
|
308
|
+
threadTs: string | null;
|
|
309
|
+
/** Shown to one member only. */
|
|
310
|
+
ephemeral: boolean;
|
|
311
|
+
edited: boolean;
|
|
312
|
+
reactions: ChatReaction[];
|
|
313
|
+
/** Display names of the users and channels the message mentions by id (`U…` → `ada`). */
|
|
314
|
+
names?: Record<string, string>;
|
|
315
|
+
};
|
|
42
316
|
/** One message as a recipient would receive it, normalized across emulators. */
|
|
43
317
|
type Notification = {
|
|
44
318
|
/** Stable across polls: `<service entry>:<namespace>:<provider id>`. */
|
|
@@ -50,7 +324,7 @@ type Notification = {
|
|
|
50
324
|
source: string;
|
|
51
325
|
service: ServiceKind;
|
|
52
326
|
namespace: string;
|
|
53
|
-
/** Phone number, email address,
|
|
327
|
+
/** Phone number, email address, push registration token, or chat channel (`#alerts`). */
|
|
54
328
|
to: string;
|
|
55
329
|
from: Address;
|
|
56
330
|
/** ISO-8601, on the emulator's clock. */
|
|
@@ -62,6 +336,8 @@ type Notification = {
|
|
|
62
336
|
sms: SmsContent | null;
|
|
63
337
|
email: EmailContent | null;
|
|
64
338
|
push: PushContent | null;
|
|
339
|
+
/** Set on `chat` notifications; absent or null on every other channel. */
|
|
340
|
+
chat?: ChatContent | null;
|
|
65
341
|
/** The record exactly as the emulator reported it. */
|
|
66
342
|
raw: unknown;
|
|
67
343
|
};
|
|
@@ -87,22 +363,14 @@ type SourceStatus = {
|
|
|
87
363
|
lastSyncAt: string | null;
|
|
88
364
|
};
|
|
89
365
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
sync(namespace?: string): Promise<void>;
|
|
99
|
-
/** Notifications matching `filter`, oldest first, after a fresh sync. */
|
|
100
|
-
list(filter?: NotificationFilter): Promise<Notification[]>;
|
|
101
|
-
/** Resolve once at least `count` (default 1) notifications match; reject after `timeoutMs`. */
|
|
102
|
-
waitFor(filter: NotificationFilter, options?: WaitOptions): Promise<Notification[]>;
|
|
103
|
-
sources(): SourceStatus[];
|
|
104
|
-
close(): void;
|
|
105
|
-
};
|
|
366
|
+
/**
|
|
367
|
+
* The channel tab bar's rules, kept free of the DOM so they are unit-tested directly.
|
|
368
|
+
*
|
|
369
|
+
* Wide, the bar is `All | Text | Push | Email | Chat` and "All" lays every device side by side.
|
|
370
|
+
* Narrow (or with `layout: "tabs"`), there is no "All": exactly one device shows at a time.
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
type DeviceLayout = "auto" | "tabs" | "grid";
|
|
106
374
|
|
|
107
375
|
/**
|
|
108
376
|
* The harness UI. Plain DOM: each device re-renders from `state` when the harness reports a change.
|
|
@@ -137,10 +405,23 @@ type AppOptions = {
|
|
|
137
405
|
motion?: MotionPreference;
|
|
138
406
|
/** Fill the host element and scroll inside it, for a tab or panel in another app. */
|
|
139
407
|
embedded?: boolean;
|
|
140
|
-
/** Which devices to show. Default all
|
|
408
|
+
/** Which devices to show. Default all of them: `sms`, `push`, `email` and `chat`. */
|
|
141
409
|
channels?: Channel[];
|
|
410
|
+
/**
|
|
411
|
+
* How the devices share the space. `auto` (default) lays them side by side and switches to one
|
|
412
|
+
* device at a time, picked with the channel tabs, when the host element is narrower than 800px.
|
|
413
|
+
* `tabs` always shows one device; `grid` never collapses.
|
|
414
|
+
*/
|
|
415
|
+
layout?: DeviceLayout;
|
|
416
|
+
/** Show the channel tabs (`All | Text | Push | Email | Chat`). Default true; with `false`, `auto` never collapses. */
|
|
417
|
+
tabs?: boolean;
|
|
142
418
|
/** Show the top bar (namespace, filter, view tabs, sound, emulator status). Default true. */
|
|
143
419
|
chrome?: boolean;
|
|
420
|
+
/**
|
|
421
|
+
* Draw the devices at this fraction of their full size (a phone is 362 by 760px), from 0.5 to 1,
|
|
422
|
+
* for a host with less room than the full-size devices need. Default 1.
|
|
423
|
+
*/
|
|
424
|
+
scale?: number;
|
|
144
425
|
/** Called with each batch of new notifications. */
|
|
145
426
|
onArrive?: (added: Notification[]) => void;
|
|
146
427
|
/** Fixed notifications to draw when not live. */
|
|
@@ -184,6 +465,9 @@ type AppOptions = {
|
|
|
184
465
|
to?: string | null;
|
|
185
466
|
open?: string | null;
|
|
186
467
|
};
|
|
468
|
+
chat?: {
|
|
469
|
+
to?: string | null;
|
|
470
|
+
};
|
|
187
471
|
toast?: string | null;
|
|
188
472
|
local?: {
|
|
189
473
|
dismissed?: string[];
|
|
@@ -210,6 +494,8 @@ type AppHandle = {
|
|
|
210
494
|
}): void;
|
|
211
495
|
setNamespace(namespace: string): void;
|
|
212
496
|
setSound(on: boolean): void;
|
|
497
|
+
/** Change the `scale` the devices are drawn at. */
|
|
498
|
+
setScale(scale: number): void;
|
|
213
499
|
/** Stop streams and timers, remove listeners and empty the host. */
|
|
214
500
|
destroy(): void;
|
|
215
501
|
};
|
|
@@ -218,215 +504,23 @@ type PushSkin = "auto" | "ios" | "android";
|
|
|
218
504
|
type Tapback = "heart" | "like" | "dislike" | "laugh" | "emphasize" | "question";
|
|
219
505
|
declare function createApp(root: HTMLElement, options?: AppOptions): AppHandle;
|
|
220
506
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
declare const STYLES: string;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Every `data-testid` the harness UI renders, and selector helpers for browser tests.
|
|
228
|
-
*
|
|
229
|
-
* Elements that show one notification also carry its fields as attributes, so a test can narrow by
|
|
230
|
-
* what it knows instead of by position:
|
|
231
|
-
*
|
|
232
|
-
* data-notification-id data-channel data-service data-source data-to data-from
|
|
233
|
-
* data-status data-created-at data-unread ("true" | "false")
|
|
234
|
-
*
|
|
235
|
-
* The UI root (`TEST_IDS.app`) reports its state the same way: `data-ready` ("true" once the first
|
|
236
|
-
* read finished), `data-view`, `data-namespace`, `data-count`, `data-version`, `data-connected`,
|
|
237
|
-
* `data-sound` and `data-motion`.
|
|
238
|
-
*
|
|
239
|
-
* This module has no dependencies, so Playwright, Cypress or WebdriverIO specs can import it.
|
|
240
|
-
*/
|
|
241
|
-
declare const TEST_IDS: {
|
|
242
|
-
/** The UI root. */
|
|
243
|
-
readonly app: "notifications-app";
|
|
244
|
-
readonly topbar: "topbar";
|
|
245
|
-
/** `<select>` of namespaces. */
|
|
246
|
-
readonly namespace: "namespace";
|
|
247
|
-
/** Filter `<input>` (recipient, sender, text). */
|
|
248
|
-
readonly search: "search";
|
|
249
|
-
/** View tabs; `aria-pressed="true"` on the active one. */
|
|
250
|
-
readonly viewDevices: "view-devices";
|
|
251
|
-
readonly viewTimeline: "view-timeline";
|
|
252
|
-
/** "Follow new" checkbox. */
|
|
253
|
-
readonly follow: "follow";
|
|
254
|
-
/** Sound on/off button; `aria-pressed`. */
|
|
255
|
-
readonly sound: "sound-toggle";
|
|
256
|
-
/** Live stream indicator; `data-state="live" | "reconnecting"`. */
|
|
257
|
-
readonly connection: "connection";
|
|
258
|
-
/** One pill per emulator; `data-name`, `data-service`, `data-ok`, `data-count`. */
|
|
259
|
-
readonly source: "source";
|
|
260
|
-
/** Discovery or emulator errors, or the "no emulators" hint; `data-kind="error" | "empty"`. */
|
|
261
|
-
readonly notice: "notice";
|
|
262
|
-
/** Bottom-left message after an action, e.g. "Conversation archived." */
|
|
263
|
-
readonly toast: "toast";
|
|
264
|
-
readonly toastUndo: "toast-undo";
|
|
265
|
-
/** The phone; `data-screen="threads" | "conversation"`, `data-recipient`, `data-thread`. */
|
|
266
|
-
readonly smsDevice: "sms-device";
|
|
267
|
-
/** Phone number `<select>`; option values are E.164 numbers. */
|
|
268
|
-
readonly smsRecipient: "sms-recipient";
|
|
269
|
-
/** Unread SMS badge next to the column title (absent when 0). */
|
|
270
|
-
readonly smsUnreadCount: "sms-unread-count";
|
|
271
|
-
/** One conversation in the list; `data-from` (the sender address), `data-unread`, `data-pinned`, `data-muted`. */
|
|
272
|
-
readonly smsThread: "sms-thread";
|
|
273
|
-
readonly smsThreadName: "sms-thread-name";
|
|
274
|
-
readonly smsThreadPreview: "sms-thread-preview";
|
|
275
|
-
readonly smsThreadTime: "sms-thread-time";
|
|
276
|
-
readonly smsThreadUnread: "sms-thread-unread";
|
|
277
|
-
/** Swipe actions behind a thread (also reachable with the keyboard: focus the thread, press Delete). */
|
|
278
|
-
readonly smsThreadDelete: "sms-thread-delete";
|
|
279
|
-
readonly smsThreadMute: "sms-thread-mute";
|
|
280
|
-
readonly smsThreadPin: "sms-thread-pin";
|
|
281
|
-
readonly smsThreadToggleUnread: "sms-thread-toggle-unread";
|
|
282
|
-
/** Shown when the phone has no messages. */
|
|
283
|
-
readonly smsEmpty: "sms-empty";
|
|
284
|
-
/** An open conversation; `data-from`. */
|
|
285
|
-
readonly smsConversation: "sms-conversation";
|
|
286
|
-
readonly smsConversationTitle: "sms-conversation-title";
|
|
287
|
-
readonly smsBack: "sms-back";
|
|
288
|
-
/** One message; carries the notification attributes plus `data-code` when it holds a one-time code. */
|
|
289
|
-
readonly smsBubble: "sms-bubble";
|
|
290
|
-
readonly smsBubbleMedia: "sms-bubble-media";
|
|
291
|
-
/** The time revealed by swiping the conversation left. */
|
|
292
|
-
readonly smsBubbleTime: "sms-bubble-time";
|
|
293
|
-
/** A reaction added with the long-press menu; `data-tapback`. */
|
|
294
|
-
readonly smsTapback: "sms-tapback";
|
|
295
|
-
/** Centered date stamp between messages. */
|
|
296
|
-
readonly smsTimestamp: "sms-timestamp";
|
|
297
|
-
/** One-time code suggestion above the keyboard; `data-code`. */
|
|
298
|
-
readonly smsCode: "sms-code";
|
|
299
|
-
/** Long-press menu on a bubble. */
|
|
300
|
-
readonly smsMenu: "sms-menu";
|
|
301
|
-
readonly smsMenuCopy: "sms-menu-copy";
|
|
302
|
-
/** One tapback in the menu; `data-tapback="heart" | "like" | "dislike" | "laugh" | "emphasize" | "question"`. */
|
|
303
|
-
readonly smsMenuTapback: "sms-menu-tapback";
|
|
304
|
-
/** The phone; `data-skin="ios" | "android"`, `data-recipient`, `data-platform`. */
|
|
305
|
-
readonly pushDevice: "push-device";
|
|
306
|
-
/** Device token `<select>`. */
|
|
307
|
-
readonly pushRecipient: "push-recipient";
|
|
308
|
-
/** Skin buttons; `data-value`, `aria-pressed`. */
|
|
309
|
-
readonly pushSkin: "push-skin";
|
|
310
|
-
readonly pushUnreadCount: "push-unread-count";
|
|
311
|
-
/** One notification; notification attributes plus `data-expanded`, `data-platform`, `data-app`, `data-stacked`. */
|
|
312
|
-
readonly pushNotification: "push-notification";
|
|
313
|
-
readonly pushNotificationApp: "push-notification-app";
|
|
314
|
-
readonly pushNotificationTitle: "push-notification-title";
|
|
315
|
-
readonly pushNotificationBody: "push-notification-body";
|
|
316
|
-
readonly pushNotificationTime: "push-notification-time";
|
|
317
|
-
readonly pushNotificationImage: "push-notification-image";
|
|
318
|
-
/** The `data` payload, shown when expanded. */
|
|
319
|
-
readonly pushNotificationData: "push-notification-data";
|
|
320
|
-
/** Service, status, badge and sound, shown when expanded. */
|
|
321
|
-
readonly pushNotificationMeta: "push-notification-meta";
|
|
322
|
-
/** iOS: a group of notifications from one app; `data-app`, `data-count`, `data-open`. */
|
|
323
|
-
readonly pushGroup: "push-group";
|
|
324
|
-
/** iOS: "N more notifications" under a collapsed group (click to open it); `data-count`. */
|
|
325
|
-
readonly pushGroupMore: "push-group-more";
|
|
326
|
-
/** iOS: "Show less" on an open group. */
|
|
327
|
-
readonly pushGroupCollapse: "push-group-collapse";
|
|
328
|
-
/** iOS: swipe-left actions. */
|
|
329
|
-
readonly pushClear: "push-clear";
|
|
330
|
-
readonly pushOptions: "push-options";
|
|
331
|
-
/** iOS long-press preview; Android long-press settings. */
|
|
332
|
-
readonly pushPreview: "push-preview";
|
|
333
|
-
readonly pushSettings: "push-settings";
|
|
334
|
-
/** Android "Clear all". */
|
|
335
|
-
readonly pushClearAll: "push-clear-all";
|
|
336
|
-
readonly pushEmpty: "push-empty";
|
|
337
|
-
/** The browser window; `data-screen="inbox" | "message"`, `data-recipient`. */
|
|
338
|
-
readonly emailDevice: "email-device";
|
|
339
|
-
/** Mailbox `<select>`; option values are lower-case addresses. */
|
|
340
|
-
readonly emailRecipient: "email-recipient";
|
|
341
|
-
readonly emailUnreadCount: "email-unread-count";
|
|
342
|
-
/** One inbox row; notification attributes plus `data-starred`. */
|
|
343
|
-
readonly emailRow: "email-row";
|
|
344
|
-
readonly emailRowFrom: "email-row-from";
|
|
345
|
-
readonly emailRowSubject: "email-row-subject";
|
|
346
|
-
readonly emailRowSnippet: "email-row-snippet";
|
|
347
|
-
readonly emailRowDate: "email-row-date";
|
|
348
|
-
readonly emailRowService: "email-row-service";
|
|
349
|
-
readonly emailRowAttachment: "email-row-attachment";
|
|
350
|
-
readonly emailRowStar: "email-row-star";
|
|
351
|
-
/** Hover actions on a row. */
|
|
352
|
-
readonly emailRowArchive: "email-row-archive";
|
|
353
|
-
readonly emailRowDelete: "email-row-delete";
|
|
354
|
-
readonly emailRowToggleRead: "email-row-toggle-read";
|
|
355
|
-
readonly emailRefresh: "email-refresh";
|
|
356
|
-
readonly emailEmpty: "email-empty";
|
|
357
|
-
/** The open message; notification attributes. */
|
|
358
|
-
readonly emailOpen: "email-open";
|
|
359
|
-
readonly emailBack: "email-back";
|
|
360
|
-
readonly emailArchive: "email-archive";
|
|
361
|
-
readonly emailDelete: "email-delete";
|
|
362
|
-
readonly emailMarkUnread: "email-mark-unread";
|
|
363
|
-
readonly emailSubject: "email-subject";
|
|
364
|
-
readonly emailFromName: "email-from-name";
|
|
365
|
-
readonly emailFromAddress: "email-from-address";
|
|
366
|
-
/** "to me, …" line; click to toggle the details. */
|
|
367
|
-
readonly emailTo: "email-to";
|
|
368
|
-
readonly emailDate: "email-date";
|
|
369
|
-
readonly emailDetails: "email-details";
|
|
370
|
-
/** One row of the details; `data-field="from" | "to" | "cc" | "bcc" | "reply-to" | "date" | "subject" | "mailed-by" | "message-id"`. */
|
|
371
|
-
readonly emailDetail: "email-detail";
|
|
372
|
-
/** The HTML body `<iframe>` (same origin: use `frameLocator`). */
|
|
373
|
-
readonly emailBody: "email-body";
|
|
374
|
-
/** The plain-text body when there is no HTML. */
|
|
375
|
-
readonly emailText: "email-text";
|
|
376
|
-
readonly emailAttachments: "email-attachments";
|
|
377
|
-
/** One attachment; `data-filename`, `data-content-type`, `data-size`. */
|
|
378
|
-
readonly emailAttachment: "email-attachment";
|
|
379
|
-
readonly timeline: "timeline";
|
|
380
|
-
/** One row; notification attributes. Click it to inspect. */
|
|
381
|
-
readonly timelineRow: "timeline-row";
|
|
382
|
-
readonly timelineEmpty: "timeline-empty";
|
|
383
|
-
/** The JSON inspector; notification attributes. Opened by clicking a timeline row or double-clicking any notification. */
|
|
384
|
-
readonly inspector: "inspector";
|
|
385
|
-
readonly inspectorTitle: "inspector-title";
|
|
386
|
-
readonly inspectorClose: "inspector-close";
|
|
387
|
-
readonly inspectorShowOnDevice: "inspector-show-on-device";
|
|
388
|
-
/** One normalized field; `data-field`. */
|
|
389
|
-
readonly inspectorField: "inspector-field";
|
|
390
|
-
/** The full record, normalized fields plus `raw`, as JSON text. */
|
|
391
|
-
readonly inspectorJson: "inspector-json";
|
|
507
|
+
type WaitOptions = {
|
|
508
|
+
timeoutMs?: number;
|
|
509
|
+
count?: number;
|
|
392
510
|
};
|
|
393
|
-
type
|
|
394
|
-
/**
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
from?: string;
|
|
405
|
-
id?: string;
|
|
406
|
-
}) => string;
|
|
407
|
-
/** A conversation in the Messages list. */
|
|
408
|
-
smsThread: (from: string) => string;
|
|
409
|
-
/** A push notification card, optionally by id. */
|
|
410
|
-
pushNotification: (id?: string) => string;
|
|
411
|
-
/** An inbox row, optionally by id. */
|
|
412
|
-
emailRow: (id?: string) => string;
|
|
413
|
-
/** A timeline row, optionally by id. */
|
|
414
|
-
timelineRow: (id?: string) => string;
|
|
511
|
+
type NotificationHarness = {
|
|
512
|
+
/** The harness UI and JSON API as a Fetch handler. */
|
|
513
|
+
fetch(request: Request): Promise<Response>;
|
|
514
|
+
/** Read every emulator now. Resolves after a read that started after this call. */
|
|
515
|
+
sync(namespace?: string): Promise<void>;
|
|
516
|
+
/** Notifications matching `filter`, oldest first, after a fresh sync. */
|
|
517
|
+
list(filter?: NotificationFilter): Promise<Notification[]>;
|
|
518
|
+
/** Resolve once at least `count` (default 1) notifications match; reject after `timeoutMs`. */
|
|
519
|
+
waitFor(filter: NotificationFilter, options?: WaitOptions): Promise<Notification[]>;
|
|
520
|
+
sources(): SourceStatus[];
|
|
521
|
+
close(): void;
|
|
415
522
|
};
|
|
416
523
|
|
|
417
|
-
/**
|
|
418
|
-
* The harness UI as a component, for an app that wants its notifications on a tab or panel of its
|
|
419
|
-
* own page: in the browser, against an in-process harness, with no server and no network.
|
|
420
|
-
*
|
|
421
|
-
* const harness = createNotificationHarness({ services: { twilio, resend, fcm } })
|
|
422
|
-
* const ui = mountNotifications(panel, { harness })
|
|
423
|
-
* await ui.ready
|
|
424
|
-
* ui.destroy()
|
|
425
|
-
*
|
|
426
|
-
* Every rule of the stylesheet is scoped to the UI root (`.mb-notifications`), so it can sit next
|
|
427
|
-
* to the host app's own styles.
|
|
428
|
-
*/
|
|
429
|
-
|
|
430
524
|
type MountOptions = Omit<AppOptions, "fetch"> & {
|
|
431
525
|
/** An in-process harness (anything with a Fetch handler). Omit it to read `baseUrl` over HTTP. */
|
|
432
526
|
harness?: Pick<NotificationHarness, "fetch">;
|
|
@@ -441,5 +535,65 @@ type MountOptions = Omit<AppOptions, "fetch"> & {
|
|
|
441
535
|
*/
|
|
442
536
|
declare const mountNotifications: (host: HTMLElement, options?: MountOptions) => AppHandle;
|
|
443
537
|
|
|
444
|
-
|
|
445
|
-
|
|
538
|
+
/** Returns nothing, a dispose function, or a promise of either. */
|
|
539
|
+
type Mount = (panel: HTMLElement) => unknown;
|
|
540
|
+
type DashboardTab = {
|
|
541
|
+
/** Unique; also the `?tab=` value. `emulators` and `notifications` are taken. */
|
|
542
|
+
id: string;
|
|
543
|
+
label: string;
|
|
544
|
+
/** Draw the tab into `panel`, the first time it is shown. May return a dispose function. */
|
|
545
|
+
mount: Mount;
|
|
546
|
+
};
|
|
547
|
+
type DashboardOptions = {
|
|
548
|
+
/** Shown at the start of the tab bar. Omit it for a bar of tabs only. */
|
|
549
|
+
title?: string;
|
|
550
|
+
/** The embedder's own tabs, shown first. */
|
|
551
|
+
tabs?: DashboardTab[];
|
|
552
|
+
/** The emulator admin dashboard. `mount` may be async (for example, to load a script first). */
|
|
553
|
+
emulators?: {
|
|
554
|
+
label?: string;
|
|
555
|
+
mount: Mount;
|
|
556
|
+
};
|
|
557
|
+
/** The notifications UI: what `mountNotifications` takes, plus a tab label. */
|
|
558
|
+
notifications?: MountOptions & {
|
|
559
|
+
label?: string;
|
|
560
|
+
};
|
|
561
|
+
/** The tab to open. `?tab=` wins over it when `syncUrl` is set. Default: the first tab. */
|
|
562
|
+
initialTab?: string;
|
|
563
|
+
/** Read `?tab=` from the page URL and keep it current. Default false. */
|
|
564
|
+
syncUrl?: boolean;
|
|
565
|
+
onTabChange?: (id: string) => void;
|
|
566
|
+
/** Tab bar colors. `auto` follows the viewer's color scheme. Default `dark`, like the notifications UI. */
|
|
567
|
+
theme?: "dark" | "light" | "auto";
|
|
568
|
+
/** Add the stylesheets to the host's document or shadow root. Default true. */
|
|
569
|
+
injectStyles?: boolean;
|
|
570
|
+
};
|
|
571
|
+
type DashboardHandle = {
|
|
572
|
+
/** Open a tab by id. Unknown ids are ignored. */
|
|
573
|
+
show(id: string): void;
|
|
574
|
+
/** The id of the open tab. */
|
|
575
|
+
active(): string;
|
|
576
|
+
/** Tab ids, in bar order. */
|
|
577
|
+
tabs(): string[];
|
|
578
|
+
/** An empty element at the end of the tab bar, for a status or a link. */
|
|
579
|
+
aside: HTMLElement;
|
|
580
|
+
/** The notifications UI, when the dashboard has one. */
|
|
581
|
+
notifications?: AppHandle;
|
|
582
|
+
/** Dispose every mounted tab, remove listeners and empty the host. */
|
|
583
|
+
destroy(): void;
|
|
584
|
+
};
|
|
585
|
+
/**
|
|
586
|
+
* Mount the dashboard inside `host`, which it fills: give the host a height. Tabs are, in order,
|
|
587
|
+
* the embedder's `tabs`, Emulators, Notifications. A tab is drawn the first time it is shown and
|
|
588
|
+
* stays mounted afterwards, so switching away keeps its state. The Notifications tab counts what
|
|
589
|
+
* arrives while another tab is open.
|
|
590
|
+
*/
|
|
591
|
+
declare const mountDashboard: (host: HTMLElement, options: DashboardOptions) => DashboardHandle;
|
|
592
|
+
|
|
593
|
+
/** The class on the dashboard root. Every rule below is scoped to it. */
|
|
594
|
+
declare const DASHBOARD_ROOT_CLASS = "mb-dashboard";
|
|
595
|
+
/** The dashboard shell's stylesheet: the tab bar and its panels, nothing inside them. */
|
|
596
|
+
declare const DASHBOARD_STYLES: string;
|
|
597
|
+
|
|
598
|
+
export { DASHBOARD_ROOT_CLASS, DASHBOARD_STYLES, ROOT_CLASS, STYLES, TEST_IDS, createApp, mountDashboard, mountNotifications, selectors };
|
|
599
|
+
export type { AppHandle, AppOptions, DashboardHandle, DashboardOptions, DashboardTab, MotionPreference, MountOptions, PushSkin, TestId, View };
|