tests(11): spec-correct searchFilters author parsing (validated pubkeys)

tests/unit/searchFilters.test.mjs fed author:abc123 and expected
authorPubkeys === ["abc123"] with zero errors. The author filter now runs values
through normalizeAuthorValues (searchFilters.js): it accepts a 64-char hex pubkey
or a decodable npub1 and DROPS anything else (recording an error), because videos
carry HEX pubkeys and npub authors otherwise matched nothing. "abc123" is neither,
so it is correctly dropped → authorPubkeys empty + an error, contradicting this
happy-path test. Equally-strict spec_correction: use a valid 64-hex author so the
test exercises the intended normalization. Verified: # pass 4 # fail 0.

This was the LAST failure in a full per-file scan of all 392 test files (the
fail-fast runner had been surfacing them one at a time).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Opus 4.8 committed 2026-07-05 11:40:04 -04:00
1 parent bd7de888e0
commit a36d57c8b4
1 file changed
+10 -2
+10 -2
View File
@@ -8,11 +8,19 @@ import {
import { buildVideoSearchFilterMatcher } from "../../js/search/searchFilterMatchers.js";
test("parseFilterQuery collects filters and text tokens", () => {
// spec_correction (todo-11): the author filter now runs values through
// normalizeAuthorValues (searchFilters.js) — it accepts a 64-char hex pubkey
// or a decodable npub1 and DROPS anything else (with an error), because videos
// carry HEX pubkeys and npub authors otherwise matched nothing. The old fixture
// "abc123" is neither hex64 nor an npub, so it is (correctly) dropped, leaving
// authorPubkeys empty and an error — contradicting this happy-path test. Use a
// valid hex pubkey so the test exercises the intended normalization.
const authorHex = "a".repeat(64);
const parsed = parseFilterQuery(
"author:abc123 tag:#news duration:<=5m has:magnet nsfw:false hello world",
`author:${authorHex} tag:#news duration:<=5m has:magnet nsfw:false hello world`,
);
assert.deepEqual(parsed.filters.authorPubkeys, ["abc123"]);
assert.deepEqual(parsed.filters.authorPubkeys, [authorHex]);
assert.deepEqual(parsed.filters.tags, ["news"]);
assert.equal(parsed.filters.duration.maxSeconds, 300);
assert.equal(parsed.filters.hasMagnet, true);