mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-09 14:22:53 +00:00
Fix comment event matching for uppercase addresses
This commit is contained in:
1 parent
71df75a8d1
commit
c882139e90
2 files changed
+69
-10
No files matched your search
@@ -6,8 +6,11 @@ import {
|
||||
publishComment,
|
||||
listVideoComments,
|
||||
subscribeVideoComments,
|
||||
__testExports,
|
||||
} from "../../js/nostr/commentEvents.js";
|
||||
|
||||
const { normalizeCommentTarget, isVideoCommentEvent } = __testExports;
|
||||
|
||||
function createMockClient({
|
||||
actorPubkey = "actor-pubkey",
|
||||
relays = ["wss://primary"],
|
||||
@@ -281,6 +284,39 @@ test("listVideoComments matches comments even when tag casing and whitespace dif
|
||||
"isVideoCommentEvent should treat tag casing and whitespace as insignificant",
|
||||
);
|
||||
});
|
||||
|
||||
test("listVideoComments matches uppercase definition addresses without lowering", async () => {
|
||||
const uppercasePointer = "30078:AUTHOR:Clip42";
|
||||
const matchingEvent = {
|
||||
id: "uppercase-comment",
|
||||
kind: COMMENT_EVENT_KIND,
|
||||
created_at: 1700000400,
|
||||
tags: [
|
||||
["A", uppercasePointer],
|
||||
["e", "video-1"],
|
||||
],
|
||||
};
|
||||
|
||||
const { client, pool } = createMockClient();
|
||||
pool.list = async () => [[matchingEvent]];
|
||||
|
||||
const descriptorInput = {
|
||||
videoEventId: "video-1",
|
||||
videoDefinitionAddress: uppercasePointer,
|
||||
};
|
||||
|
||||
const events = await listVideoComments(client, descriptorInput);
|
||||
assert.equal(events.length, 1, "uppercase pointer should still match");
|
||||
assert.equal(events[0].id, "uppercase-comment", "matched event should be returned");
|
||||
|
||||
const normalizedDescriptor = normalizeCommentTarget(descriptorInput);
|
||||
assert.ok(normalizedDescriptor, "normalizeCommentTarget should produce a descriptor");
|
||||
assert.equal(
|
||||
isVideoCommentEvent(matchingEvent, normalizedDescriptor),
|
||||
true,
|
||||
"isVideoCommentEvent should respect descriptor casing for definition pointers",
|
||||
);
|
||||
});
|
||||
test("listVideoComments matches comments even when tag casing and whitespace differ", async () => {
|
||||
const mismatchedEvent = {
|
||||
id: "case-comment",
|
||||
|
||||
Reference in new issue
Block a user