feat(watcher): add BRI QRIS parsing and rules
Implement parsing for BRI QRIS transactions, including direct and forwarded message handling. Update rules to recognize QRIS success messages and adjust spending record mapping accordingly. Enhance tests to cover new functionality.
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
||||
} from "../src/lib/email.js";
|
||||
import { matchRule } from "../src/handlers/match-rule.js";
|
||||
import {
|
||||
briQrisDirectBody,
|
||||
briQrisForwardedBody,
|
||||
briTransferDirectBody,
|
||||
briTransferForwardedBody,
|
||||
grabBody,
|
||||
@@ -156,6 +158,32 @@ describe("matchRule", () => {
|
||||
assert.equal(result.pass.rule.kind, "bri.transfer.success");
|
||||
});
|
||||
|
||||
it("matches direct BRI QRIS", async () => {
|
||||
const result = await matchRule({
|
||||
messageId: "bri-qris-direct",
|
||||
log: silentLog,
|
||||
message: {
|
||||
from: "Bank BRI <BankBRI@bri.co.id>",
|
||||
subject: "Pembelian QRIS Berhasil",
|
||||
body: briQrisDirectBody,
|
||||
},
|
||||
});
|
||||
assert.equal(result.pass.rule.kind, "bri.qris.success");
|
||||
});
|
||||
|
||||
it("matches forwarded BRI QRIS via original header", async () => {
|
||||
const result = await matchRule({
|
||||
messageId: "1a09b9031c233407",
|
||||
log: silentLog,
|
||||
message: {
|
||||
from: "Nasyarobby Putra <nsrb@bu.edu>",
|
||||
subject: "Fwd: Pembelian QRIS Berhasil",
|
||||
body: briQrisForwardedBody,
|
||||
},
|
||||
});
|
||||
assert.equal(result.pass.rule.kind, "bri.qris.success");
|
||||
});
|
||||
|
||||
it("breaks on unknown from/subject", async () => {
|
||||
const result = await matchRule({
|
||||
messageId: "x",
|
||||
|
||||
Reference in New Issue
Block a user