Add shared hex normalization for comment flows

This commit is contained in:
thePR0M3TH3AN committed 2025-12-12 13:42:15 -05:00
1 parent af8a5828dd
commit 735d67313c
6 files changed
+102 -89

No files matched your search

+29
View File
@@ -387,6 +387,35 @@ test("CommentThreadService normalizes mixed-case event ids in thread state", asy
);
});
test("CommentThreadService normalizes mixed-case pubkeys during hydration", async () => {
const video = createBaseVideo();
const mixedPubkey = "PuBkEy-Upper";
const fetchVideoComments = async () => [
createComment({ id: "c-hydrate", pubkey: mixedPubkey, createdAt: 1700000200 }),
];
const hydrationRequests = [];
const service = new CommentThreadService({
nostrClient: { ensurePool: async () => {} },
fetchVideoComments,
subscribeVideoComments: () => () => {},
batchFetchProfiles: async (pubkeys) => {
hydrationRequests.push([...pubkeys]);
return [];
},
hydrationDebounceMs: 0,
});
await service.loadThread({ video });
assert.deepEqual(
hydrationRequests,
[[mixedPubkey.toLowerCase()]],
"hydration should request normalized pubkeys",
);
});
test(
"listVideoComments accepts builder events without parent ids and filters replies",
async () => {