-
Notifications
You must be signed in to change notification settings - Fork 309
autocomplete: Add and test MentionAutocompleteQuery #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autocomplete: Add and test MentionAutocompleteQuery #86
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Small comments.
test/example_data.dart
Outdated
// The use of JSON here is convenient in order to delegate parts of the data | ||
// to helper functions. The main downside is that it loses static typing | ||
// of the properties as we're constructing the data. That's probably OK | ||
// because (a) this is only for tests; (b) the types do get checked | ||
// dynamically in the constructor, so any ill-typing won't propagate further. | ||
return User.fromJson({ | ||
'user_id': userId ?? 123, // TODO generate example IDs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this isn't actually using such a helper function, better to leave it as a direct call to the generative constructor User
.
Looking at zulip-mobile's example data, we do have such a helper function there but it's only for abstracting between User and CrossRealmBot. Since we've successfully avoided introducing that distinction here in zulip-flutter, it's likely we'll never need such a helper function.
(For streamMessage
, by contrast, we're going to want to abstract between stream messages and DMs, much like we do in zulip-mobile.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, I see I copied from streamMessage
too hastily. 🙂
test/example_data.dart
Outdated
@@ -71,6 +71,30 @@ StreamMessage streamMessage( | |||
}); | |||
} | |||
|
|||
User user({int? userId, String? fullName}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's order these similarly to api/model/model.dart
, or when that doesn't suggest a workable ordering then like zulip-mobile's exampleData.js
.
That means users come next to accounts; streams and subscriptions will be after those; then messages.
test/example_data.dart
Outdated
return User.fromJson({ | ||
'user_id': userId ?? 123, // TODO generate example IDs | ||
'email': '[email protected]', | ||
'full_name': fullName ?? 'Full Name', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit more realistic, in making the name a name for the user rather than a self-reference:
'full_name': fullName ?? 'Full Name', | |
'full_name': fullName ?? 'A User', |
But I think better yet: default to a newly-generated random name. That will help avoid confusion when debugging a failing test, if there are several users involved who had automatic names.
(Random names can be out of scope for this PR, though — just bundle them into the same TODO as generating IDs. Same for emails.)
lib/model/autocomplete.dart
Outdated
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doCheck('Full Full', eg.user(fullName: 'Full Name'), false); | ||
doCheck('Name Name', eg.user(fullName: 'Full Name'), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also test that "full full" does match "Full Full Name" and "Full Name Full".
doCheck('Full', eg.user(fullName: 'Full Name'), true); | ||
doCheck('Name', eg.user(fullName: 'Full Name'), true); | ||
doCheck('Full Name', eg.user(fullName: 'Fully Named'), true); | ||
doCheck('Full Four', eg.user(fullName: 'Full Name Four Words'), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also test that "F Full" and "Four F" don't match this name, while "Full F" and "F Four" do.
expected ? check(result).isTrue() : check(result).isFalse(); | ||
} | ||
|
||
doCheck('', eg.user(fullName: 'Full Name'), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also include tests with empty fullName
— one where query is also empty, one where nonempty.
That isn't a super likely case, but it wouldn't be hard to have a bug where the search crashed on it.
4712aa7
to
511959d
Compare
Thanks for the review! Revision pushed (with the commits from #84 refreshed with my current revision of that). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit; otherwise lgtm once #84 is ready.
test/example_data.dart
Outdated
} | ||
|
||
final Uri realmUrl = Uri.parse('https://chat.example/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: user data after realm-wide / server-wide data
511959d
to
fa4434c
Compare
Thanks for the review! Revision pushed. |
fa4434c
to
8895ce8
Compare
(Rebased atop |
This is atop my current revision of #84. It excludes much of the work we did in the office together, which I still have in a draft branch (and which I have an open question about: czo)—but this seems like a self-contained piece of logic that we'll need, and that we'll want to get right.
Related: #49