@remit/mailbox-service 0.0.111 → 0.0.112
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 +21 -6
- package/src/body-part-mapper.ts +51 -1
- package/src/body-sync-queue.test.ts +39 -99
- package/src/body-sync-terminal.test.ts +115 -277
- package/src/body-sync-terminal.ts +10 -12
- package/src/body-sync.test.ts +925 -0
- package/src/body-sync.ts +156 -235
- package/src/classification-backfill.test.ts +197 -527
- package/src/classify-message.test.ts +11 -74
- package/src/external-move.test.ts +102 -209
- package/src/external-move.ts +13 -0
- package/src/filter-operations.test.ts +319 -0
- package/src/filter-operations.ts +377 -0
- package/src/filter-update.test.ts +313 -0
- package/src/filters/filter-config.test.ts +55 -197
- package/src/filters/filter-config.ts +4 -39
- package/src/filters/match.test.ts +1 -38
- package/src/filters/match.ts +3 -52
- package/src/filters/pipeline.test.ts +158 -289
- package/src/filters/pipeline.ts +56 -170
- package/src/flag-push-terminal.ts +9 -11
- package/src/flag-push.test.ts +76 -372
- package/src/flag-queue.test.ts +197 -0
- package/src/folder-operations.test.ts +273 -0
- package/src/folder-operations.ts +217 -0
- package/src/forwarded-message.test.ts +122 -0
- package/src/imapflow-connect-retry.test.ts +76 -113
- package/src/imapflow-connection.test.ts +34 -0
- package/src/imapflow-connection.ts +5 -4
- package/src/index.ts +59 -12
- package/src/list-id-backfill.test.ts +133 -499
- package/src/mailbox-cursor.test.ts +81 -189
- package/src/mailbox-delete-intent.test.ts +78 -205
- package/src/mailbox-intent.ts +5 -3
- package/src/mailbox-management.test.ts +107 -220
- package/src/mailbox-management.ts +1 -2
- package/src/mailbox-presence.test.ts +36 -34
- package/src/mailbox-queue.ts +2 -20
- package/src/mailbox-rename-intent.test.ts +156 -325
- package/src/mailbox-rename-subtree.test.ts +205 -582
- package/src/mailbox-sync.test.ts +182 -744
- package/src/message-move.test.ts +726 -0
- package/src/message-move.ts +227 -57
- package/src/message-read.ts +87 -0
- package/src/message-save-retry.test.ts +90 -0
- package/src/message-sync-flags.test.ts +10 -1
- package/src/message-sync.test.ts +762 -0
- package/src/message-sync.ts +409 -239
- package/src/mime-walker.ts +16 -15
- package/src/organize-job.ts +93 -0
- package/src/outbox-attachment.test.ts +97 -209
- package/src/outbox-failed-recovery.test.ts +198 -269
- package/src/outbox-queue.test.ts +24 -0
- package/src/outbox-queue.ts +25 -8
- package/src/ownership.ts +140 -0
- package/src/placement-move-terminal.ts +9 -12
- package/src/placement-move.ts +33 -6
- package/src/placement-settled.ts +28 -4
- package/src/placement.test.ts +404 -0
- package/src/quarantine.test.ts +90 -148
- package/src/quarantine.ts +3 -2
- package/src/refusal.ts +29 -0
- package/src/restore-source-placement.ts +0 -4
- package/src/spam-report.test.ts +238 -710
- package/src/sync-warning.test.ts +213 -0
- package/src/sync-warning.ts +56 -0
- package/src/test-helpers/fake-imap.ts +690 -0
- package/src/test-helpers/test-queue.ts +56 -0
- package/src/test-helpers/test-store.ts +299 -0
- package/src/thread-root.test.ts +29 -0
- package/src/thread-root.ts +51 -0
- package/src/types/mailparser-augment.d.ts +8 -0
- package/src/adversarial-mime.e2e.test.ts +0 -307
- package/src/body-sync-auto-read-writeonce.test.ts +0 -219
- package/src/body-sync-calendar-suggestion.test.ts +0 -433
- package/src/body-sync-category-denormalize.test.ts +0 -352
- package/src/body-sync-category-override.test.ts +0 -501
- package/src/body-sync-category-writeonce.test.ts +0 -234
- package/src/body-sync-filter.test.ts +0 -237
- package/src/body-sync-message-gone.test.ts +0 -139
- package/src/body-sync-placement-flags.test.ts +0 -347
- package/src/body-sync-placement-writeonce.test.ts +0 -337
- package/src/body-sync-quarantine.test.ts +0 -276
- package/src/body-sync-resync.test.ts +0 -605
- package/src/body-sync-unclassifiable-once.test.ts +0 -260
- package/src/body-sync-unsubscribed-auto-read.test.ts +0 -176
- package/src/filters/anchor-drift.ts +0 -55
- package/src/filters/message-embedder.test.ts +0 -39
- package/src/filters/message-embedder.ts +0 -33
- package/src/flag-push-terminal.test.ts +0 -209
- package/src/flag-queue-stars.test.ts +0 -171
- package/src/imapflow-connection.e2e.test.ts +0 -335
- package/src/imapflow-connection.integ.test.ts +0 -316
- package/src/message-delete-junk-reconcile.test.ts +0 -117
- package/src/message-delete-no-trash.test.ts +0 -245
- package/src/message-delete-unsettled-placement.test.ts +0 -396
- package/src/message-move-copy.test.ts +0 -562
- package/src/message-move-empty-trash.test.ts +0 -326
- package/src/message-move-same-mailbox.test.ts +0 -139
- package/src/message-move-unsettled-placement.test.ts +0 -378
- package/src/message-sync-address-spoof.test.ts +0 -293
- package/src/message-sync-category.test.ts +0 -142
- package/src/message-sync-changedsince.test.ts +0 -840
- package/src/message-sync-junk-harvest.test.ts +0 -244
- package/src/message-sync-quarantine.test.ts +0 -416
- package/src/message-sync-repoint.test.ts +0 -419
- package/src/outbox-queue-settled-row.test.ts +0 -140
- package/src/pass-through-unit-of-work.ts +0 -17
- package/src/placement-move-terminal.test.ts +0 -300
- package/src/placement-move-unsettled.test.ts +0 -275
- package/src/placement-transition-race.test.ts +0 -482
- package/src/stale-message-reconcile.test.ts +0 -82
- package/src/stale-message-reconcile.ts +0 -55
- package/src/test-helpers/isolated-mailbox.ts +0 -44
- package/src/test-helpers/mailfuzz-connection.ts +0 -27
- package/test/fixtures/mime-adversarial-e2e/01-octet-stream-pdf.eml +0 -21
- package/test/fixtures/mime-adversarial-e2e/02-nested-related-cid-image.eml +0 -31
- package/test/fixtures/mime-adversarial-e2e/03-calendar-invite.eml +0 -33
- package/test/fixtures/mime-adversarial-e2e/04-forwarded-rfc822-with-attachments.eml +0 -42
- package/test/fixtures/mime-adversarial-e2e/05-tnef-winmail.eml +0 -25
- package/test/fixtures/mime-adversarial-e2e/06-8bit-non-ascii.eml +0 -15
- package/test/fixtures/mime-adversarial-e2e/07-quoted-printable-soft-breaks.eml +0 -17
- package/test/fixtures/mime-adversarial-e2e/08-alternative-empty-text.eml +0 -18
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import type {
|
|
4
|
-
IMessageRepository,
|
|
5
|
-
IThreadMessageRepository,
|
|
6
|
-
} from "@remit/data-ports";
|
|
7
|
-
import type { FlagPushLogger } from "./flag-push.js";
|
|
8
|
-
import {
|
|
9
|
-
type ResolveExhaustedFlagPushDeps,
|
|
10
|
-
resolveExhaustedFlagPushFailure,
|
|
11
|
-
} from "./flag-push-terminal.js";
|
|
12
|
-
import type { IImapConnection } from "./types.js";
|
|
13
|
-
|
|
14
|
-
interface LogEntry {
|
|
15
|
-
obj: Record<string, unknown>;
|
|
16
|
-
msg: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const buildLogger = (): {
|
|
20
|
-
log: FlagPushLogger;
|
|
21
|
-
infos: LogEntry[];
|
|
22
|
-
errors: LogEntry[];
|
|
23
|
-
} => {
|
|
24
|
-
const infos: LogEntry[] = [];
|
|
25
|
-
const errors: LogEntry[] = [];
|
|
26
|
-
return {
|
|
27
|
-
log: {
|
|
28
|
-
info: (obj, msg) => infos.push({ obj, msg }),
|
|
29
|
-
error: (obj, msg) => errors.push({ obj, msg }),
|
|
30
|
-
},
|
|
31
|
-
infos,
|
|
32
|
-
errors,
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const buildConnection = (
|
|
37
|
-
present: Set<number>,
|
|
38
|
-
fetchDrops: Set<number> = new Set(),
|
|
39
|
-
): IImapConnection =>
|
|
40
|
-
({
|
|
41
|
-
openBox: async () => ({}) as never,
|
|
42
|
-
fetchMessages: async (uids: number[]) =>
|
|
43
|
-
uids
|
|
44
|
-
.filter((uid) => present.has(uid) && !fetchDrops.has(uid))
|
|
45
|
-
.map((uid) => ({ uid }) as unknown as never),
|
|
46
|
-
search: async (criteria: unknown[]) => {
|
|
47
|
-
const [, value] = (criteria as Array<[string, string]>)[0];
|
|
48
|
-
const uid = Number(value);
|
|
49
|
-
return present.has(uid) ? [uid] : [];
|
|
50
|
-
},
|
|
51
|
-
}) as unknown as IImapConnection;
|
|
52
|
-
|
|
53
|
-
describe("resolveExhaustedFlagPushFailure — the two terminal outcomes (mirrors #1289/#1270 for flag pushes)", () => {
|
|
54
|
-
it("RECONCILED (expected): the message is gone from its mailbox — marker dropped, stale row reconciled, no alarm", async () => {
|
|
55
|
-
const deletedMessages: string[] = [];
|
|
56
|
-
const deletedThreadMessages: Array<{
|
|
57
|
-
accountConfigId: string;
|
|
58
|
-
threadMessageId: string;
|
|
59
|
-
}> = [];
|
|
60
|
-
const markerDeletes: Array<{ messageId: string; flagName: string }> = [];
|
|
61
|
-
const { log, infos, errors } = buildLogger();
|
|
62
|
-
|
|
63
|
-
const deps: ResolveExhaustedFlagPushDeps = {
|
|
64
|
-
markerService: {
|
|
65
|
-
delete: async (messageId: string, flagName: string) => {
|
|
66
|
-
markerDeletes.push({ messageId, flagName });
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
messageService: {
|
|
70
|
-
delete: async (id: string) => {
|
|
71
|
-
deletedMessages.push(id);
|
|
72
|
-
},
|
|
73
|
-
} as unknown as Pick<IMessageRepository, "delete">,
|
|
74
|
-
threadMessageService: {
|
|
75
|
-
findAllByMessageId: async (
|
|
76
|
-
accountConfigId: string,
|
|
77
|
-
messageId: string,
|
|
78
|
-
) => [{ accountConfigId, threadMessageId: `tm-${messageId}` }],
|
|
79
|
-
deleteMany: async (
|
|
80
|
-
keys: Array<{ accountConfigId: string; threadMessageId: string }>,
|
|
81
|
-
) => {
|
|
82
|
-
deletedThreadMessages.push(...keys);
|
|
83
|
-
},
|
|
84
|
-
} as unknown as Pick<
|
|
85
|
-
IThreadMessageRepository,
|
|
86
|
-
"findAllByMessageId" | "deleteMany"
|
|
87
|
-
>,
|
|
88
|
-
log,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const result = await resolveExhaustedFlagPushFailure(deps, {
|
|
92
|
-
accountId: "acc-1",
|
|
93
|
-
accountConfigId: "cfg-1",
|
|
94
|
-
messageId: "msg-gone",
|
|
95
|
-
flagName: "\\Seen",
|
|
96
|
-
uid: 101,
|
|
97
|
-
mailboxPath: "INBOX",
|
|
98
|
-
getConnection: async () => buildConnection(new Set()),
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
assert.equal(result.outcome, "reconciled");
|
|
102
|
-
assert.deepEqual(markerDeletes, [
|
|
103
|
-
{ messageId: "msg-gone", flagName: "\\Seen" },
|
|
104
|
-
]);
|
|
105
|
-
assert.deepEqual(deletedMessages, ["msg-gone"]);
|
|
106
|
-
assert.equal(deletedThreadMessages.length, 1);
|
|
107
|
-
|
|
108
|
-
assert.equal(errors.length, 0, "reconciled outcome must not log an alert");
|
|
109
|
-
const metricLog = infos.find(
|
|
110
|
-
(entry) => entry.obj.metric === "flag_push_stale_row_reconciled",
|
|
111
|
-
);
|
|
112
|
-
assert.ok(metricLog, "expected a routine reconciliation metric log");
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("a dropped FETCH row is not absence: the message is still in the mailbox — marker and local rows survive", async () => {
|
|
116
|
-
const markerDeletes: Array<{ messageId: string; flagName: string }> = [];
|
|
117
|
-
const { log, errors } = buildLogger();
|
|
118
|
-
|
|
119
|
-
const deps: ResolveExhaustedFlagPushDeps = {
|
|
120
|
-
markerService: {
|
|
121
|
-
delete: async (messageId: string, flagName: string) => {
|
|
122
|
-
markerDeletes.push({ messageId, flagName });
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
messageService: {
|
|
126
|
-
delete: async () => {
|
|
127
|
-
throw new Error("must not be called — the message still exists");
|
|
128
|
-
},
|
|
129
|
-
} as unknown as Pick<IMessageRepository, "delete">,
|
|
130
|
-
threadMessageService: {
|
|
131
|
-
findAllByMessageId: async () => {
|
|
132
|
-
throw new Error("must not be called — the message still exists");
|
|
133
|
-
},
|
|
134
|
-
deleteMany: async () => {
|
|
135
|
-
throw new Error("must not be called — the message still exists");
|
|
136
|
-
},
|
|
137
|
-
} as unknown as Pick<
|
|
138
|
-
IThreadMessageRepository,
|
|
139
|
-
"findAllByMessageId" | "deleteMany"
|
|
140
|
-
>,
|
|
141
|
-
log,
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const result = await resolveExhaustedFlagPushFailure(deps, {
|
|
145
|
-
accountId: "acc-1",
|
|
146
|
-
accountConfigId: "cfg-1",
|
|
147
|
-
messageId: "msg-live",
|
|
148
|
-
flagName: "\\Seen",
|
|
149
|
-
uid: 303,
|
|
150
|
-
mailboxPath: "INBOX",
|
|
151
|
-
getConnection: async () =>
|
|
152
|
-
buildConnection(new Set([303]), new Set([303])),
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
assert.equal(result.outcome, "broken");
|
|
156
|
-
assert.deepEqual(markerDeletes, []);
|
|
157
|
-
assert.ok(errors.some((e) => e.obj.alert === "flag_push_failed"));
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it("BROKEN (should never happen): the message still exists — marker left in place, alert logged", async () => {
|
|
161
|
-
const markerDeletes: Array<{ messageId: string; flagName: string }> = [];
|
|
162
|
-
const { log, errors } = buildLogger();
|
|
163
|
-
|
|
164
|
-
const deps: ResolveExhaustedFlagPushDeps = {
|
|
165
|
-
markerService: {
|
|
166
|
-
delete: async (messageId: string, flagName: string) => {
|
|
167
|
-
markerDeletes.push({ messageId, flagName });
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
messageService: {
|
|
171
|
-
delete: async () => {
|
|
172
|
-
throw new Error("must not be called — message still exists");
|
|
173
|
-
},
|
|
174
|
-
} as unknown as Pick<IMessageRepository, "delete">,
|
|
175
|
-
threadMessageService: {
|
|
176
|
-
findAllByMessageId: async () => {
|
|
177
|
-
throw new Error("must not be called — message still exists");
|
|
178
|
-
},
|
|
179
|
-
deleteMany: async () => {
|
|
180
|
-
throw new Error("must not be called — message still exists");
|
|
181
|
-
},
|
|
182
|
-
} as unknown as Pick<
|
|
183
|
-
IThreadMessageRepository,
|
|
184
|
-
"findAllByMessageId" | "deleteMany"
|
|
185
|
-
>,
|
|
186
|
-
log,
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
const result = await resolveExhaustedFlagPushFailure(deps, {
|
|
190
|
-
accountId: "acc-1",
|
|
191
|
-
accountConfigId: "cfg-1",
|
|
192
|
-
messageId: "msg-still-here",
|
|
193
|
-
flagName: "\\Flagged",
|
|
194
|
-
uid: 202,
|
|
195
|
-
mailboxPath: "INBOX",
|
|
196
|
-
getConnection: async () => buildConnection(new Set([202])),
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
assert.equal(result.outcome, "broken");
|
|
200
|
-
assert.deepEqual(
|
|
201
|
-
markerDeletes,
|
|
202
|
-
[],
|
|
203
|
-
"marker must be left in place — resync never reverts a pending flag while it is",
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
const alerted = errors.find((e) => e.obj.alert === "flag_push_failed");
|
|
207
|
-
assert.ok(alerted, "expected an alertable flag_push_failed log");
|
|
208
|
-
});
|
|
209
|
-
});
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { describe, test } from "node:test";
|
|
3
|
-
import type {
|
|
4
|
-
IMessageFlagRepository,
|
|
5
|
-
IMessageRepository,
|
|
6
|
-
IThreadMessageRepository,
|
|
7
|
-
MessageItem,
|
|
8
|
-
ThreadMessageItem,
|
|
9
|
-
UpdateThreadMessageInput,
|
|
10
|
-
} from "@remit/data-ports";
|
|
11
|
-
import { MessageSystemFlag } from "@remit/domain-enums";
|
|
12
|
-
import type { FlagPushService } from "./flag-push.js";
|
|
13
|
-
import { FlagQueueService } from "./flag-queue.js";
|
|
14
|
-
|
|
15
|
-
// #44: `hasStars` is the boolean of record and `star` its presentation colour.
|
|
16
|
-
// The UI's star toggle sends only `isStarred`, so a star that left `star` at
|
|
17
|
-
// the `none` sentinel disagreed with `hasStars` and every read site that
|
|
18
|
-
// consulted the colour rejected the row. The colour now follows the boolean.
|
|
19
|
-
|
|
20
|
-
const ACCOUNT_CONFIG_ID = "cfg-1";
|
|
21
|
-
const ACCOUNT_ID = "acct-1";
|
|
22
|
-
const MESSAGE_ID = "msg-1";
|
|
23
|
-
const MAILBOX_ID = "mbx-1";
|
|
24
|
-
const THREAD_MESSAGE_ID = "tm-1";
|
|
25
|
-
|
|
26
|
-
const threadMessage = {
|
|
27
|
-
threadMessageId: THREAD_MESSAGE_ID,
|
|
28
|
-
accountConfigId: ACCOUNT_CONFIG_ID,
|
|
29
|
-
mailboxId: MAILBOX_ID,
|
|
30
|
-
sentDate: 1,
|
|
31
|
-
isRead: false,
|
|
32
|
-
isDeleted: false,
|
|
33
|
-
hasStars: false,
|
|
34
|
-
hasAttachment: false,
|
|
35
|
-
} as unknown as ThreadMessageItem;
|
|
36
|
-
|
|
37
|
-
const buildService = ({
|
|
38
|
-
alreadyFlagged = false,
|
|
39
|
-
}: {
|
|
40
|
-
alreadyFlagged?: boolean;
|
|
41
|
-
} = {}): {
|
|
42
|
-
service: FlagQueueService;
|
|
43
|
-
updates: UpdateThreadMessageInput[];
|
|
44
|
-
flips: Array<{ flagName: string; operation: string }>;
|
|
45
|
-
} => {
|
|
46
|
-
const updates: UpdateThreadMessageInput[] = [];
|
|
47
|
-
const flips: Array<{ flagName: string; operation: string }> = [];
|
|
48
|
-
|
|
49
|
-
const messageService = {
|
|
50
|
-
get: async () => ({ mailboxId: MAILBOX_ID }) as unknown as MessageItem,
|
|
51
|
-
} as unknown as IMessageRepository;
|
|
52
|
-
|
|
53
|
-
const messageFlagService = {
|
|
54
|
-
hasFlag: async (_messageId: string, flagName: string) =>
|
|
55
|
-
flagName === MessageSystemFlag.Flagged ? alreadyFlagged : false,
|
|
56
|
-
addFlag: async () => {},
|
|
57
|
-
removeFlag: async () => {},
|
|
58
|
-
} as unknown as IMessageFlagRepository;
|
|
59
|
-
|
|
60
|
-
const threadMessageService = {
|
|
61
|
-
findAllByMessageId: async () => [threadMessage],
|
|
62
|
-
update: async (
|
|
63
|
-
_accountConfigId: string,
|
|
64
|
-
_threadMessageId: string,
|
|
65
|
-
input: UpdateThreadMessageInput,
|
|
66
|
-
) => {
|
|
67
|
-
updates.push(input);
|
|
68
|
-
return threadMessage;
|
|
69
|
-
},
|
|
70
|
-
} as unknown as IThreadMessageRepository;
|
|
71
|
-
|
|
72
|
-
const flagPushService = {
|
|
73
|
-
flip: async (event: { flagName: string; operation: string }) => {
|
|
74
|
-
flips.push({ flagName: event.flagName, operation: event.operation });
|
|
75
|
-
},
|
|
76
|
-
} as unknown as FlagPushService;
|
|
77
|
-
|
|
78
|
-
const service = new FlagQueueService({
|
|
79
|
-
messageFlagService,
|
|
80
|
-
messageService,
|
|
81
|
-
threadMessageService,
|
|
82
|
-
flagPushService,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
return { service, updates, flips };
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
describe("updateFlags keeps hasStars and the star colour in step", () => {
|
|
89
|
-
test("starring without a colour sets both the boolean and a visible colour", async () => {
|
|
90
|
-
const { service, updates } = buildService();
|
|
91
|
-
|
|
92
|
-
await service.updateFlags(ACCOUNT_CONFIG_ID, MESSAGE_ID, ACCOUNT_ID, {
|
|
93
|
-
isStarred: true,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
assert.deepEqual(updates, [{ hasStars: true, star: "yellow" }]);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test("unstarring clears the colour back to the none sentinel", async () => {
|
|
100
|
-
const { service, updates } = buildService({ alreadyFlagged: true });
|
|
101
|
-
|
|
102
|
-
await service.updateFlags(ACCOUNT_CONFIG_ID, MESSAGE_ID, ACCOUNT_ID, {
|
|
103
|
-
isStarred: false,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
assert.deepEqual(updates, [{ hasStars: false, star: "none" }]);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test("an explicit colour wins over the default", async () => {
|
|
110
|
-
const { service, updates } = buildService();
|
|
111
|
-
|
|
112
|
-
await service.updateFlags(ACCOUNT_CONFIG_ID, MESSAGE_ID, ACCOUNT_ID, {
|
|
113
|
-
isStarred: true,
|
|
114
|
-
starColor: "red",
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
assert.deepEqual(updates, [{ hasStars: true, star: "red" }]);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// A colour-only request is legal on the wire. Before, it wrote the colour
|
|
121
|
-
// and left `hasStars` alone, so a coloured-but-unstarred row rendered
|
|
122
|
-
// unstarred, stayed out of Starred, and never pushed \Flagged.
|
|
123
|
-
test("a colour alone stars the message and pushes the flag", async () => {
|
|
124
|
-
const { service, updates, flips } = buildService();
|
|
125
|
-
|
|
126
|
-
await service.updateFlags(ACCOUNT_CONFIG_ID, MESSAGE_ID, ACCOUNT_ID, {
|
|
127
|
-
starColor: "blue",
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
assert.deepEqual(updates, [{ hasStars: true, star: "blue" }]);
|
|
131
|
-
assert.deepEqual(flips, [
|
|
132
|
-
{ flagName: MessageSystemFlag.Flagged, operation: "add" },
|
|
133
|
-
]);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test("the none colour unstars the message", async () => {
|
|
137
|
-
const { service, updates, flips } = buildService({ alreadyFlagged: true });
|
|
138
|
-
|
|
139
|
-
await service.updateFlags(ACCOUNT_CONFIG_ID, MESSAGE_ID, ACCOUNT_ID, {
|
|
140
|
-
starColor: "none",
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
assert.deepEqual(updates, [{ hasStars: false, star: "none" }]);
|
|
144
|
-
assert.deepEqual(flips, [
|
|
145
|
-
{ flagName: MessageSystemFlag.Flagged, operation: "remove" },
|
|
146
|
-
]);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test("isStarred decides the boolean when both fields are sent", async () => {
|
|
150
|
-
const { service, updates } = buildService();
|
|
151
|
-
|
|
152
|
-
await service.updateFlags(ACCOUNT_CONFIG_ID, MESSAGE_ID, ACCOUNT_ID, {
|
|
153
|
-
isStarred: true,
|
|
154
|
-
starColor: "none",
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
assert.deepEqual(updates, [{ hasStars: true, star: "none" }]);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
test("starring pushes the Flagged keyword", async () => {
|
|
161
|
-
const { service, flips } = buildService();
|
|
162
|
-
|
|
163
|
-
await service.updateFlags(ACCOUNT_CONFIG_ID, MESSAGE_ID, ACCOUNT_ID, {
|
|
164
|
-
isStarred: true,
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
assert.deepEqual(flips, [
|
|
168
|
-
{ flagName: MessageSystemFlag.Flagged, operation: "add" },
|
|
169
|
-
]);
|
|
170
|
-
});
|
|
171
|
-
});
|