@remit/mailbox-service 0.0.83 → 0.0.84
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
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, test } from "node:test";
|
|
3
|
+
import type { MessageItem } from "@remit/data-ports";
|
|
4
|
+
import { MessageStatus, MessageSyncStatus } from "@remit/domain-enums";
|
|
5
|
+
import { placementBindingOf } from "./placement-settled.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Pins `placementBindingOf` directly. It is the guard #1098/#1143 depend on and
|
|
9
|
+
* only end-to-end specs covered it, so a change made for the client's benefit
|
|
10
|
+
* could have moved it without anything going red.
|
|
11
|
+
*
|
|
12
|
+
* Note what these cases say about `syncStatus: failed`: it answers `abandoned`
|
|
13
|
+
* here for a row that may well be mid-retry. That is correct for a guard whose
|
|
14
|
+
* consequence is a temporary refusal, and it is exactly why no user-facing
|
|
15
|
+
* statement may be derived from that field alone.
|
|
16
|
+
*/
|
|
17
|
+
const row = (over: Partial<MessageItem>): MessageItem =>
|
|
18
|
+
({
|
|
19
|
+
messageId: "m-1",
|
|
20
|
+
mailboxId: "mbx-dest",
|
|
21
|
+
uid: 7,
|
|
22
|
+
status: MessageStatus.moving,
|
|
23
|
+
syncStatus: MessageSyncStatus.pending,
|
|
24
|
+
originalMailboxId: "mbx-src",
|
|
25
|
+
originalUid: 7,
|
|
26
|
+
...over,
|
|
27
|
+
}) as unknown as MessageItem;
|
|
28
|
+
|
|
29
|
+
describe("placementBindingOf", () => {
|
|
30
|
+
test("a settled row binds consistently", () => {
|
|
31
|
+
assert.equal(
|
|
32
|
+
placementBindingOf(row({ status: MessageStatus.active })),
|
|
33
|
+
"consistent",
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("a row whose uid still names the source is in flight", () => {
|
|
38
|
+
assert.equal(placementBindingOf(row({})), "in_flight");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("`failed` on a foreign-uid row is refused as abandoned", () => {
|
|
42
|
+
assert.equal(
|
|
43
|
+
placementBindingOf(row({ syncStatus: MessageSyncStatus.failed })),
|
|
44
|
+
"abandoned",
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("a moving row that was never moved binds consistently", () => {
|
|
49
|
+
assert.equal(
|
|
50
|
+
placementBindingOf(
|
|
51
|
+
row({ originalUid: undefined, originalMailboxId: undefined }),
|
|
52
|
+
),
|
|
53
|
+
"consistent",
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("a moving row whose uid has been repointed binds consistently", () => {
|
|
58
|
+
assert.equal(placementBindingOf(row({ uid: 42 })), "consistent");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("`failed` alone, with no foreign uid, is still consistent", () => {
|
|
62
|
+
assert.equal(
|
|
63
|
+
placementBindingOf(
|
|
64
|
+
row({
|
|
65
|
+
status: MessageStatus.active,
|
|
66
|
+
syncStatus: MessageSyncStatus.failed,
|
|
67
|
+
}),
|
|
68
|
+
),
|
|
69
|
+
"consistent",
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
});
|