mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
fix(mobile): fold accents when matching mention names
`@jos` listed José María, `@jose` listed nobody and `@josé` listed them again: mobile only lowercased names. Name matching now follows section 3 of the shared mention rules, as buzz-app does (recommendation 6). Each code point is NFKD-normalized, its combining accents (the Combining Diacritical Marks blocks) are removed, it is lowercased and a final `ς` becomes `σ`, so `jose` matches `José`, `fiona` matches `fio` and `jose` matches `jose`, while `ø`, `ł`, `æ`, `ß`, `ı` and the marks of other scripts stay distinct. Words are runs of letters, marks and digits, so a hyphen or apostrophe separates them: `jane` finds `Mary-Jane` and `brien` finds `O'Brien`. The folding lives in `name_match.dart` and drives the chooser, Space selection, multi-word admission, the verified-name matches and the recipient pickers, so `@jose maria` lists José María with no accents typed. The vendored fixture moves from version 1 (95 cases) to version 4 of buzz-app's `mention-rules.fixtures.json` (125 cases), copied unchanged, and the conformance test runs every section, with a new `matching` group. No case is skipped. The rules the newer versions added are implemented too: an exact public key (64 hex in either case, or a complete lowercase or uppercase npub with an optional `nostr:` prefix) matches only its owner, even one with no name, and Space selects that owner; the viewer's own agent whose name continues the query with a new word leads (`Sol 6` for `sol`), and an exact person leads over it; agents from the viewer's other communities follow everyone here; an outside choice's longer name no longer blocks a member's exact name on Space, and a choice's own longer alias is not its own namesake. The search cache's exact-key exemption uses the same `typedPublicKey`. Refutation itself stays lowercase-only on purpose: it reasons about the relay's prefix search, which is out of scope here, so an accented query is a new search rather than a continuation. A refuted query still matches members on the device by folding: after `z` finds nobody, `@zoe` lists the member Zoë without a search. Tests: the compose bar search journey types `@jose maria` and sees José María, and `@zoe` after the `z` refutation sees Zoë; both and seven fixture cases fail when accent stripping is removed. `dart format`, `flutter analyze` and the full mobile `flutter test` suite pass. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
This commit is contained in:
@@ -1,6 +1,146 @@
|
||||
{
|
||||
"$comment": "Mention rules v1: semantic inputs, no signed events. Spec: README.md. Keys are lowercase 64-hex. Choice defaults: label = name, aliases = [name], agent/owned/managed = false. history maps key to recency (higher is more recent); presence maps key to online/away (missing is unknown). ranking.expected is the full ordered key list; space.expected is a key or null. Expected outputs are literal, not generated by the code under test.",
|
||||
"version": 1,
|
||||
"$comment": "Mention rules v4: semantic inputs, no signed events. Spec: README.md. Keys are lowercase 64-hex. Choice defaults: label = name, aliases = [name], agent/owned/managed = false. history maps key to recency (higher is more recent); presence maps key to online/away (missing is unknown). matching.expected is the tier (0 to 3) or null; ranking.expected is the full ordered key list; space.expected is a key or null. Expected outputs are literal, not generated by the code under test. A query may also be an exact public key (README Terms).",
|
||||
"version": 4,
|
||||
"matching": [
|
||||
{
|
||||
"name": "decomposed_name",
|
||||
"label": "Jose\u0301",
|
||||
"query": "josé",
|
||||
"expected": 0
|
||||
},
|
||||
{
|
||||
"name": "decomposed_query",
|
||||
"label": "José",
|
||||
"query": "jose\u0301",
|
||||
"expected": 0
|
||||
},
|
||||
{
|
||||
"name": "ligature",
|
||||
"label": "fiona",
|
||||
"query": "fio",
|
||||
"expected": 1
|
||||
},
|
||||
{
|
||||
"name": "full_width",
|
||||
"label": "jose",
|
||||
"query": "jose",
|
||||
"expected": 0
|
||||
},
|
||||
{
|
||||
"name": "dotted_capital_i",
|
||||
"label": "İpek",
|
||||
"query": "ipek",
|
||||
"expected": 0
|
||||
},
|
||||
{
|
||||
"name": "dotless_i_stays_distinct",
|
||||
"label": "Kılıç",
|
||||
"query": "kilic",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "greek_final_sigma",
|
||||
"label": "ΟΔΥΣΣΕΥΣ",
|
||||
"query": "οδυσσευς",
|
||||
"expected": 0
|
||||
},
|
||||
{
|
||||
"name": "accented_whole_word",
|
||||
"label": "Mary José",
|
||||
"query": "jose",
|
||||
"expected": 2
|
||||
},
|
||||
{
|
||||
"name": "accented_word_prefix",
|
||||
"label": "Ana Josefa",
|
||||
"query": "jose",
|
||||
"expected": 3
|
||||
},
|
||||
{
|
||||
"name": "hyphen_separates_words",
|
||||
"label": "Mary-Jane",
|
||||
"query": "jane",
|
||||
"expected": 2
|
||||
},
|
||||
{
|
||||
"name": "apostrophe_separates_words",
|
||||
"label": "Pat O'Brien",
|
||||
"query": "brien",
|
||||
"expected": 2
|
||||
},
|
||||
{
|
||||
"name": "next_line_separates_words",
|
||||
"label": "Anne\u0085Marie",
|
||||
"query": "marie",
|
||||
"expected": 2
|
||||
},
|
||||
{
|
||||
"name": "no_break_space_separates_words",
|
||||
"label": "Anne\u00a0Marie",
|
||||
"query": "marie",
|
||||
"expected": 2
|
||||
},
|
||||
{
|
||||
"name": "stroke_letter_does_not_fold",
|
||||
"label": "Łukasz",
|
||||
"query": "lukasz",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "slashed_o_does_not_fold",
|
||||
"label": "Øyvind",
|
||||
"query": "oyvind",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "ligature_letter_does_not_fold",
|
||||
"label": "Æsir",
|
||||
"query": "aesir",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "sharp_s_does_not_fold",
|
||||
"label": "Straße",
|
||||
"query": "strasse",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "devanagari_vowel_sign_kept",
|
||||
"label": "र\u093eम",
|
||||
"query": "रम",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "japanese_voicing_mark_kept",
|
||||
"label": "ジョン",
|
||||
"query": "ション",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "japanese_same_name",
|
||||
"label": "ジョン",
|
||||
"query": "ジョン",
|
||||
"expected": 0
|
||||
},
|
||||
{
|
||||
"name": "text_inside_a_word",
|
||||
"label": "Honey",
|
||||
"query": "oney",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "query_with_space_matches_only_at_start",
|
||||
"label": "Visible Legacy Bee",
|
||||
"query": "legacy bee",
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "trimmed_both_sides",
|
||||
"label": " Honey ",
|
||||
"query": " HONEY ",
|
||||
"expected": 0
|
||||
}
|
||||
],
|
||||
"ranking": [
|
||||
{
|
||||
"name": "match_tiers_within_members",
|
||||
@@ -119,6 +259,71 @@
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "accents_and_case_fold",
|
||||
"query": "jose",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Mary José",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "JOSÉ",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"name": "Joséphine",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
|
||||
"name": "Jo Se",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "accented_query_matches_plain_name",
|
||||
"query": "Zöe",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Zoe",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Zoey",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "final_sigma_folds",
|
||||
"query": "παρος",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "ΠΑΡΟΣ",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "public_keys_are_not_searchable",
|
||||
"query": "abcdef12",
|
||||
@@ -387,7 +592,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ownership_does_not_override_match_quality",
|
||||
"name": "owned_agent_starting_with_the_query_words_beats_another_agents_exact_name",
|
||||
"query": "Rizz",
|
||||
"choices": [
|
||||
{
|
||||
@@ -404,11 +609,217 @@
|
||||
"owned": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ownership_does_not_override_match_quality_inside_a_word",
|
||||
"query": "Rizz",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Rizz",
|
||||
"member": true,
|
||||
"agent": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Rizzo",
|
||||
"member": true,
|
||||
"agent": true,
|
||||
"owned": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "exact_person_before_owned_agent_starting_with_the_query",
|
||||
"query": "sol",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Sol 6",
|
||||
"member": true,
|
||||
"agent": true,
|
||||
"owned": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Sol",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"name": "Sol",
|
||||
"label": "Sol · cccc",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
|
||||
"name": "Sol",
|
||||
"label": "Wes’s Sol",
|
||||
"member": true,
|
||||
"agent": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "another_persons_agent_continuing_the_query_does_not_lead",
|
||||
"query": "sol",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Sol 6",
|
||||
"member": true,
|
||||
"agent": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Sol",
|
||||
"member": true,
|
||||
"agent": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "owned_agent_leads_for_a_multi_word_query_and_a_hyphen",
|
||||
"query": "sol 6",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Sol 6",
|
||||
"member": true,
|
||||
"agent": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Sol 6.1 High",
|
||||
"member": true,
|
||||
"agent": true,
|
||||
"owned": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "owned_agent_with_a_hyphenated_name_leads",
|
||||
"query": "sol",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Sol",
|
||||
"member": true,
|
||||
"agent": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Sol-6",
|
||||
"member": true,
|
||||
"agent": true,
|
||||
"owned": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "hidden_alias_does_not_lead",
|
||||
"query": "sol",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Helper",
|
||||
"aliases": ["Helper", "Sol 6"],
|
||||
"member": true,
|
||||
"agent": true,
|
||||
"owned": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Sol",
|
||||
"label": "Wes’s Sol",
|
||||
"member": true,
|
||||
"agent": true
|
||||
},
|
||||
{
|
||||
"pubkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"name": "Solveig",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "generated_owner_prefix_does_not_lead",
|
||||
"query": "tho",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Rizz",
|
||||
"label": "tho’s Rizz",
|
||||
"member": true,
|
||||
"agent": true,
|
||||
"owned": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Tho",
|
||||
"member": true,
|
||||
"agent": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "lead_does_not_override_membership",
|
||||
"query": "sol",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Sol 6",
|
||||
"member": false,
|
||||
"agent": true,
|
||||
"owned": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Sol",
|
||||
"member": true,
|
||||
"agent": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "visible_prefix_beats_owned_word_prefix",
|
||||
"query": "riz",
|
||||
@@ -670,6 +1081,139 @@
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "other_community_agents_follow_everyone_here",
|
||||
"query": "honey",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Honey",
|
||||
"member": false,
|
||||
"agent": true,
|
||||
"elsewhere": "oss.example.com"
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Honey Bee",
|
||||
"member": false,
|
||||
"agent": true
|
||||
},
|
||||
{
|
||||
"pubkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"name": "Honey Bear",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "exact_public_key_matches_only_its_owner",
|
||||
"query": "npub1424242424242424242424242424242424242424242424242424qamrcaj",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "npub1424242424242424242424242424242424242424242424242424qamrcaj",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "uppercase_nostr_npub_matches_its_owner",
|
||||
"query": "NOSTR:NPUB1424242424242424242424242424242424242424242424242424QAMRCAJ",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "npub1424242424242424242424242424242424242424242424242424qamrcaj",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "uppercase_hex_key_matches_its_owner",
|
||||
"query": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "exact_public_key_matches_an_unnamed_owner",
|
||||
"query": "npub1424242424242424242424242424242424242424242424242424qamrcaj",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "npub…rcaj",
|
||||
"aliases": [],
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": [
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "partial_npub_is_not_searchable",
|
||||
"query": "npub1424242",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": []
|
||||
}
|
||||
],
|
||||
"space": [
|
||||
@@ -863,6 +1407,221 @@
|
||||
}
|
||||
],
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "outside_longer_name_does_not_block_a_member",
|
||||
"query": "Jose",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Jose",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Jose-Luis",
|
||||
"member": false
|
||||
}
|
||||
],
|
||||
"expected": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "outside_longer_name_blocks_an_outside_name",
|
||||
"query": "Jose",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Jose",
|
||||
"member": false
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Jose-Luis",
|
||||
"member": false
|
||||
}
|
||||
],
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "exact_after_folding",
|
||||
"query": "jose",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "José",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Josefa",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "names_equal_after_folding_are_not_unique",
|
||||
"query": "jose",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "José",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Jose",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "folded_longer_name_blocks_space",
|
||||
"query": "jose",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Jose",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "José Luis",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "longer_name_after_tab_blocks",
|
||||
"query": "Jose",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Jose",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Jose\tLuis",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "longer_name_after_hyphen_blocks",
|
||||
"query": "Jose",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Jose",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Jose-Luis",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "accented_longer_name_blocks",
|
||||
"query": "jose",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "José",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "José Luis",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": null
|
||||
},
|
||||
{
|
||||
"name": "alias_of_same_identity_does_not_block",
|
||||
"query": "example",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Example",
|
||||
"aliases": ["Example Agent", "Example"],
|
||||
"member": false,
|
||||
"agent": true,
|
||||
"owned": true
|
||||
},
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "Member",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "exact_public_key_selects_its_owner_among_namesakes",
|
||||
"query": "npub1424242424242424242424242424242424242424242424242424qamrcaj",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "name_equal_to_a_key_does_not_select",
|
||||
"query": "npub1424242424242424242424242424242424242424242424242424qamrcaj",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"name": "npub1424242424242424242424242424242424242424242424242424qamrcaj",
|
||||
"member": true
|
||||
},
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "exact_public_key_selects_an_unnamed_owner",
|
||||
"query": "npub1424242424242424242424242424242424242424242424242424qamrcaj",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "npub…rcaj",
|
||||
"aliases": [],
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
},
|
||||
{
|
||||
"name": "partial_npub_does_not_select",
|
||||
"query": "npub1424242",
|
||||
"choices": [
|
||||
{
|
||||
"pubkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"name": "Honey",
|
||||
"member": true
|
||||
}
|
||||
],
|
||||
"expected": null
|
||||
}
|
||||
],
|
||||
"query": [
|
||||
@@ -999,6 +1758,24 @@
|
||||
"query": "Honey ",
|
||||
"names": ["Honey Bee"],
|
||||
"expected": true
|
||||
},
|
||||
{
|
||||
"name": "multi_word_prefix_after_folding",
|
||||
"query": "jose l",
|
||||
"names": ["José Luis"],
|
||||
"expected": true
|
||||
},
|
||||
{
|
||||
"name": "completed_folded_name_with_space_closes",
|
||||
"query": "jose ",
|
||||
"names": ["José"],
|
||||
"expected": false
|
||||
},
|
||||
{
|
||||
"name": "padded_known_name_with_space_closes",
|
||||
"query": "jose ",
|
||||
"names": ["José "],
|
||||
"expected": false
|
||||
}
|
||||
],
|
||||
"tags": {
|
||||
|
||||
@@ -3,10 +3,12 @@ import 'dart:io';
|
||||
|
||||
import 'package:buzz/shared/mentions/mention_rules.dart';
|
||||
import 'package:buzz/shared/mentions/mention_tags.dart';
|
||||
import 'package:buzz/shared/mentions/name_match.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
// Portable fixtures, copied unchanged from buzz-app
|
||||
// src/bundled/mentions/mention-rules.fixtures.json (mention rules v1).
|
||||
// src/bundled/mentions/mention-rules.fixtures.json (mention rules v4).
|
||||
// Every case runs; none is skipped.
|
||||
final Map<String, dynamic> _fixtures =
|
||||
jsonDecode(
|
||||
File(
|
||||
@@ -37,6 +39,7 @@ MentionChoice _choice(Map<String, dynamic> json) {
|
||||
agent: json['agent'] as bool? ?? false,
|
||||
owned: json['owned'] as bool? ?? false,
|
||||
managed: json['managed'] as bool? ?? false,
|
||||
elsewhere: json['elsewhere'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -46,13 +49,31 @@ List<MentionChoice> _choices(Map<String, dynamic> fixture) => [
|
||||
];
|
||||
|
||||
void main() {
|
||||
test('reads mention fixtures version 1', () {
|
||||
expect(_fixtures['version'], 1);
|
||||
for (final section in ['ranking', 'space', 'query', 'admission']) {
|
||||
test('reads mention fixtures version 4', () {
|
||||
expect(_fixtures['version'], 4);
|
||||
final sections = ['matching', 'ranking', 'space', 'query', 'admission'];
|
||||
for (final section in sections) {
|
||||
expect(_cases(section), isNotEmpty, reason: section);
|
||||
}
|
||||
expect(_tagCases('write'), isNotEmpty);
|
||||
expect(_tagCases('read'), isNotEmpty);
|
||||
// Every fixture section above has a group below that runs each case.
|
||||
expect(_fixtures.keys.where((key) => !key.startsWith(r'$')).toSet(), {
|
||||
...sections,
|
||||
'version',
|
||||
'tags',
|
||||
});
|
||||
});
|
||||
|
||||
group('matching fixtures', () {
|
||||
for (final fixture in _cases('matching')) {
|
||||
test(fixture['name'], () {
|
||||
expect(
|
||||
nameMatchTier(fixture['label'] as String, fixture['query'] as String),
|
||||
fixture['expected'],
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
group('tag writer fixtures', () {
|
||||
|
||||
Reference in New Issue
Block a user