-
Notifications
You must be signed in to change notification settings - Fork 309
autocomplete: Add and test MentionAutocompleteView #102
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3bb27e1
log: Use recently added `debugLog` instead of `debugPrint`
chrisbobbe 64107a4
test: Add selfUser, otherUser, and thirdUser to example data
gnprice 4dfac27
test: Add per-account `store` to example data
gnprice 572f592
test: Add test_store, for a PerAccountStore that's convenient for tes…
gnprice 381c802
deps: Add dev:fake_async
gnprice 5024fdd
autocomplete: Add `cache` param to MentionAutocompleteQuery.testUser
chrisbobbe d21886a
autocomplete: Add and test MentionAutocompleteView
chrisbobbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,19 @@ import 'package:zulip/api/model/initial_snapshot.dart'; | |
import 'package:zulip/api/model/model.dart'; | ||
import 'package:zulip/model/store.dart'; | ||
|
||
import 'api/fake_api.dart'; | ||
|
||
final Uri realmUrl = Uri.parse('https://chat.example/'); | ||
|
||
const String recentZulipVersion = '6.1'; | ||
const int recentZulipFeatureLevel = 164; | ||
|
||
User user({int? userId, String? fullName}) { | ||
User user({int? userId, String? email, String? fullName}) { | ||
return User( | ||
userId: userId ?? 123, // TODO generate example IDs | ||
deliveryEmailStaleDoNotUse: '[email protected]', | ||
email: '[email protected]', // TODO generate example emails | ||
fullName: fullName ?? 'A user',// TODO generate example names | ||
email: email ?? '[email protected]', // TODO generate example emails | ||
fullName: fullName ?? 'A user', // TODO generate example names | ||
dateJoined: '2023-04-28', | ||
isActive: true, | ||
isOwner: false, | ||
|
@@ -28,28 +30,32 @@ User user({int? userId, String? fullName}) { | |
); | ||
} | ||
|
||
final User selfUser = user(fullName: 'Self User', email: 'self@example', userId: 123); | ||
final Account selfAccount = Account( | ||
id: 1001, | ||
realmUrl: realmUrl, | ||
email: 'self@example', | ||
email: selfUser.email, | ||
apiKey: 'asdfqwer', | ||
userId: 123, | ||
userId: selfUser.userId, | ||
zulipFeatureLevel: recentZulipFeatureLevel, | ||
zulipVersion: recentZulipVersion, | ||
zulipMergeBase: recentZulipVersion, | ||
); | ||
|
||
final User otherUser = user(fullName: 'Other User', email: 'other@example', userId: 234); | ||
final Account otherAccount = Account( | ||
id: 1002, | ||
realmUrl: realmUrl, | ||
email: 'other@example', | ||
email: otherUser.email, | ||
apiKey: 'sdfgwert', | ||
userId: 234, | ||
userId: otherUser.userId, | ||
zulipFeatureLevel: recentZulipFeatureLevel, | ||
zulipVersion: recentZulipVersion, | ||
zulipMergeBase: recentZulipVersion, | ||
); | ||
|
||
final User thirdUser = user(fullName: 'Third User', email: 'third@example', userId: 345); | ||
|
||
final _messagePropertiesBase = { | ||
'is_me_message': false, | ||
'last_edit_timestamp': null, | ||
|
@@ -108,3 +114,11 @@ final InitialSnapshot initialSnapshot = InitialSnapshot( | |
realmNonActiveUsers: [], | ||
crossRealmBots: [], | ||
); | ||
|
||
PerAccountStore store() { | ||
return PerAccountStore.fromInitialSnapshot( | ||
account: selfAccount, | ||
connection: FakeApiConnection.fromAccount(selfAccount), | ||
initialSnapshot: initialSnapshot, | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'package:checks/checks.dart'; | ||
import 'package:zulip/model/autocomplete.dart'; | ||
|
||
extension UserMentionAutocompleteResultChecks on Subject<UserMentionAutocompleteResult> { | ||
Subject<int> get userId => has((r) => r.userId, 'userId'); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
(FWIW I'd be inclined to put this one inside the individual test file, down at the end after
main
, because it seems likely we'll only want it within the one file and because it'd be easy to move later if we want it in several files after all. But in a separate file is fine too.)