@remit/mailbox-service 0.0.75 → 0.0.76
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/filters/pipeline.test.ts +38 -2
package/package.json
CHANGED
|
@@ -44,11 +44,11 @@ const senderFilter = (destinationMailboxId: string): FilterItem =>
|
|
|
44
44
|
updatedAt: 1,
|
|
45
45
|
}) as unknown as FilterItem;
|
|
46
46
|
|
|
47
|
-
const buildPipeline = (
|
|
47
|
+
const buildPipeline = (...filters: FilterItem[]) => {
|
|
48
48
|
const state = { embedCalls: 0 };
|
|
49
49
|
const config: FilterConfig = {
|
|
50
50
|
filterService: {
|
|
51
|
-
listByAccountAndState: async () =>
|
|
51
|
+
listByAccountAndState: async () => filters,
|
|
52
52
|
refreshExpiry: async (f: FilterItem) => f,
|
|
53
53
|
} as unknown as IFilterRepository,
|
|
54
54
|
filterAnchorService: {
|
|
@@ -103,6 +103,42 @@ describe("FilterPipeline — anchorless From/Or filter at index time", () => {
|
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Arbitration survives exactly here: two standing filters colliding over the
|
|
108
|
+
* same message at the same trigger. A move is exclusive, so the pass resolves
|
|
109
|
+
* one destination — the more-recently-changed action wins (reader #497 leaves
|
|
110
|
+
* this untouched while removing arbitration from the user-initiated apply).
|
|
111
|
+
*/
|
|
112
|
+
describe("FilterPipeline — two standing filters colliding on one message", () => {
|
|
113
|
+
const rivalFilter = (): FilterItem =>
|
|
114
|
+
({
|
|
115
|
+
...senderFilter("mbx-projects"),
|
|
116
|
+
filterId: "flt-rival",
|
|
117
|
+
name: "github to projects",
|
|
118
|
+
actionChangedAt: 2,
|
|
119
|
+
}) as unknown as FilterItem;
|
|
120
|
+
|
|
121
|
+
it("resolves a single destination from the more-recently-changed action", async () => {
|
|
122
|
+
const older = {
|
|
123
|
+
...senderFilter("mbx-archive"),
|
|
124
|
+
actionChangedAt: 1,
|
|
125
|
+
} as unknown as FilterItem;
|
|
126
|
+
const { pipeline } = buildPipeline(older, rivalFilter());
|
|
127
|
+
const decision = await pipeline.evaluate("cfg-1", "m-3", {
|
|
128
|
+
from: "npm@github.com",
|
|
129
|
+
fromName: "npm",
|
|
130
|
+
subject: "A new version of left-pad is available",
|
|
131
|
+
text: "body",
|
|
132
|
+
listId: "",
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
assert.deepEqual(decision.move, {
|
|
136
|
+
destinationMailboxId: "mbx-projects",
|
|
137
|
+
filterId: "flt-rival",
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
106
142
|
describe("FilterPipeline — anchor lazy re-embed on model drift (reader #295)", () => {
|
|
107
143
|
const anchoredFilter = (): FilterItem =>
|
|
108
144
|
({
|