Fix autocomplete filter predicate not matching diacritic variants#3977
Fix autocomplete filter predicate not matching diacritic variants#3977
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughChanged the autocomplete filter predicate to be diacritic-insensitive (CONTAINS[cd]) so queries like "Joao" match accented variants (e.g., "João"). Added a test exercising diacritic matching and updated the changelog to document the fix. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c9433a1 to
d2056ed
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@Tests/StreamChatTests/Controllers/ChannelListController/ChannelListController_Tests.swift`:
- Around line 1270-1297: Extend the existing
test_filterPredicate_autocomplete_matchesDiacriticVariants test to also exercise
the collection-field branch by adding assertions that use the
.autocomplete(.memberName, text: ...) predicate (which uses ANY) and verify it
matches the same allMatchingCids; reuse the same channelsInDB setup and call try
assertFilterPredicate(.autocomplete(.memberName, text: "Joao"), channelsInDB:
channelsInDB, expectedResult: allMatchingCids) and similarly for "Jõao" to cover
both diacritic-insensitive paths.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
CHANGELOG.mdSources/StreamChat/Query/Filter+predicate.swiftTests/StreamChatTests/Controllers/ChannelListController/ChannelListController_Tests.swift
| func test_filterPredicate_autocomplete_matchesDiacriticVariants() throws { | ||
| let cidPlain = ChannelId.unique | ||
| let cidAccentA = ChannelId.unique | ||
| let cidTildeO = ChannelId.unique | ||
|
|
||
| let channelsInDB: [ChannelPayload] = [ | ||
| .dummy(channel: .dummy(cid: cidPlain, name: "Joao Silva")), | ||
| .dummy(channel: .dummy(cid: cidAccentA, name: "João Silva")), | ||
| .dummy(channel: .dummy(cid: cidTildeO, name: "Jõao Silva")), | ||
| .dummy(channel: .dummy(name: "Random")) | ||
| ] | ||
| let allMatchingCids = [cidPlain, cidAccentA, cidTildeO] | ||
|
|
||
| // Autocomplete uses CONTAINS[cd] (case and diacritic insensitive), | ||
| // so "Joao" matches "João", "Jõao", and "Joao". | ||
| try assertFilterPredicate( | ||
| .autocomplete(.name, text: "Joao"), | ||
| channelsInDB: channelsInDB, | ||
| expectedResult: allMatchingCids | ||
| ) | ||
|
|
||
| // "Jõao" also matches all variants thanks to diacritic insensitivity. | ||
| try assertFilterPredicate( | ||
| .autocomplete(.name, text: "Jõao"), | ||
| channelsInDB: channelsInDB, | ||
| expectedResult: allMatchingCids | ||
| ) | ||
| } |
There was a problem hiding this comment.
Add collection-field coverage for diacritic matching.
This test only exercises .name (non-collection). The reported bug also affects the memberName autocomplete path (collection + ANY). Add a memberName assertion to cover that predicate branch.
✅ Suggested test extension
@@
// "Jõao" also matches all variants thanks to diacritic insensitivity.
try assertFilterPredicate(
.autocomplete(.name, text: "Jõao"),
channelsInDB: channelsInDB,
expectedResult: allMatchingCids
)
+
+ let memberChannels: [ChannelPayload] = [
+ .dummy(channel: .dummy(cid: cidPlain, members: [.dummy(user: .dummy(userId: .unique, name: "Joao Silva"))])),
+ .dummy(channel: .dummy(cid: cidAccentA, members: [.dummy(user: .dummy(userId: .unique, name: "João Silva"))])),
+ .dummy(channel: .dummy(cid: cidTildeO, members: [.dummy(user: .dummy(userId: .unique, name: "Jõao Silva"))])),
+ .dummy(channel: .dummy(name: "Random"))
+ ]
+ try assertFilterPredicate(
+ .autocomplete(.memberName, text: "Joao"),
+ channelsInDB: memberChannels,
+ expectedResult: allMatchingCids
+ )As per coding guidelines: "Tests/**/*.swift: Add and extend tests in the matching module's Tests/ folder, covering core models, API surface, and UI behaviors using fakes/mocks from test helpers".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@Tests/StreamChatTests/Controllers/ChannelListController/ChannelListController_Tests.swift`
around lines 1270 - 1297, Extend the existing
test_filterPredicate_autocomplete_matchesDiacriticVariants test to also exercise
the collection-field branch by adding assertions that use the
.autocomplete(.memberName, text: ...) predicate (which uses ANY) and verify it
matches the same allMatchingCids; reuse the same channelsInDB setup and call try
assertFilterPredicate(.autocomplete(.memberName, text: "Joao"), channelsInDB:
channelsInDB, expectedResult: allMatchingCids) and similarly for "Jõao" to cover
both diacritic-insensitive paths.
# Conflicts: # CHANGELOG.md
Public Interface🚀 No changes affecting the public interface. |
SDK Size
|
|



🔗 Issue Links
Fixes: IOS-1443
🎯 Goal
Fix autocomplete filter predicate not matching diacritic variants
📝 Summary
API returned correct results, but some results got filtered out on the CoreData level
🛠 Implementation
🎨 Showcase
🧪 Manual Testing Notes
Changing default channel list query:
And then creating some groups with users who name contains "João" (I added some using channel explorer).
r2-d2 has one matching group currently which I used for testing.
☑️ Contributor Checklist
docs-contentrepoSummary by CodeRabbit
Bug Fixes
Tests
Documentation