From a36d57c8b4e034bfafdfcf5f42f0d45ce6fbbbbe Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sun, 5 Jul 2026 11:40:04 -0400 Subject: [PATCH] tests(11): spec-correct searchFilters author parsing (validated pubkeys) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/unit/searchFilters.test.mjs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/unit/searchFilters.test.mjs b/tests/unit/searchFilters.test.mjs index 44227691..916d2da4 100644 --- a/tests/unit/searchFilters.test.mjs +++ b/tests/unit/searchFilters.test.mjs @@ -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);