mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 09:38:39 +00:00
test: dedupe bluebubbles normalize fixtures
This commit is contained in:
@@ -1,18 +1,24 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { normalizeWebhookMessage, normalizeWebhookReaction } from "./monitor-normalize.js";
|
import { normalizeWebhookMessage, normalizeWebhookReaction } from "./monitor-normalize.js";
|
||||||
|
|
||||||
|
function createFallbackDmPayload(overrides: Record<string, unknown> = {}) {
|
||||||
|
return {
|
||||||
|
guid: "msg-1",
|
||||||
|
isGroup: false,
|
||||||
|
isFromMe: false,
|
||||||
|
handle: null,
|
||||||
|
chatGuid: "iMessage;-;+15551234567",
|
||||||
|
...overrides,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
describe("normalizeWebhookMessage", () => {
|
describe("normalizeWebhookMessage", () => {
|
||||||
it("falls back to DM chatGuid handle when sender handle is missing", () => {
|
it("falls back to DM chatGuid handle when sender handle is missing", () => {
|
||||||
const result = normalizeWebhookMessage({
|
const result = normalizeWebhookMessage({
|
||||||
type: "new-message",
|
type: "new-message",
|
||||||
data: {
|
data: createFallbackDmPayload({
|
||||||
guid: "msg-1",
|
|
||||||
text: "hello",
|
text: "hello",
|
||||||
isGroup: false,
|
}),
|
||||||
isFromMe: false,
|
|
||||||
handle: null,
|
|
||||||
chatGuid: "iMessage;-;+15551234567",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result).not.toBeNull();
|
expect(result).not.toBeNull();
|
||||||
@@ -78,15 +84,11 @@ describe("normalizeWebhookReaction", () => {
|
|||||||
it("falls back to DM chatGuid handle when reaction sender handle is missing", () => {
|
it("falls back to DM chatGuid handle when reaction sender handle is missing", () => {
|
||||||
const result = normalizeWebhookReaction({
|
const result = normalizeWebhookReaction({
|
||||||
type: "updated-message",
|
type: "updated-message",
|
||||||
data: {
|
data: createFallbackDmPayload({
|
||||||
guid: "msg-2",
|
guid: "msg-2",
|
||||||
associatedMessageGuid: "p:0/msg-1",
|
associatedMessageGuid: "p:0/msg-1",
|
||||||
associatedMessageType: 2000,
|
associatedMessageType: 2000,
|
||||||
isGroup: false,
|
}),
|
||||||
isFromMe: false,
|
|
||||||
handle: null,
|
|
||||||
chatGuid: "iMessage;-;+15551234567",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result).not.toBeNull();
|
expect(result).not.toBeNull();
|
||||||
|
|||||||
Reference in New Issue
Block a user