-
Notifications
You must be signed in to change notification settings - Fork 310
autocomplete: Exclude deactivated users from @-mention autocomplete popup #582
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: Exclude deactivated users from @-mention autocomplete popup #582
Conversation
Better than before, but still needs some improvements.
As stated in the Zulip Commit Discipline page, the tests for a change should be in the same commit. Also, instead of closing a PR and then opening a new one just for the sake of some changes, there is an easy way of doing it explained in this page. |
8de38cd
to
3a98165
Compare
@sm-sayedi You're right although the tests in the second commit do not test the same change that the first one introduces. they depend on some of the changes. Regarding the rebase.. I learned it hard way! Thanks for you helpful guidance |
3a98165
to
0d6a28d
Compare
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 @Khader-1 for the contribution, and @sm-sayedi for the initial reviews! Comments below on this version.
13dc818
to
261bfef
Compare
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.
This has gone through many iterations! hopefully each iteration is a step in the right direction.
I think it is ready to be reviewed now
fbaf56a
to
6dfd58e
Compare
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 @Khader-1! This is quite close to merge.
A few small comments below. The one other area that needs a bit of revision before we merge this is the formatting of the commit messages.
- For the formatting around the "[nfc]" marker, see examples at https://github.com/zulip/zulip-mobile/blob/main/docs/glossary.md#nfc .
- For the "fixes" line, see https://github.com/zulip/zulip-mobile/blob/main/docs/style.md#fixes-format .
- See Zulip's Git style guide: https://zulip.readthedocs.io/en/latest/contributing/commit-discipline.html#formatting-guidelines
on line-wrapping for the prose in the body of your commit message. - The commit summary can go slightly longer than 70 columns when there's a lot to express, but this one is 95 columns and longer than it needs to be:
autocomplete test[nfc]: Use a test group to handle MentionAutocompleteQuery.testUser test cases
- Saying just
testUser
instead ofMentionAutocompleteQuery.testUser
is the main part of a fix. - You can also make the wording more concise; summary lines can be in a terse "headlinese" style. To see examples, try
git log --oneline --author Greg
orgit log --oneline --author cbobbe
.
- Saying just
To see example commit messages in general, here's a slightly broader version of that last pair of commands:
$ git log --stat --author '(greg|cbobbe)@zulip' -P
test/model/autocomplete_test.dart
Outdated
}); | ||
|
||
test('user is always excluded when not active regardless of other criteria', () { | ||
doCheck('Full Name', eg.user(fullName: 'Full Name', isActive: false), 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.
Just to make this test case fully self-contained, let's give it a second line that looks exactly the same except the user is active, and does match.
That line will be identical to one of the lines in the existing test case, so in a sense it's redundant. But it makes a useful baseline for the reader to compare this other check to. It means that the reader can look at this test case and be confident that it really is testing what it's meant to test — that there isn't some accident where the user stopped matching because something changed about the name matching, or whatever — without having to look around at other tests, or to look back at the implementation that's being tested.
6dfd58e
to
854a18c
Compare
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.
This is not tagged as [nfc]
because it does actually add functionality or at least it tests it's existence. Besides the new test case is mentioned as a part of the issue.
Sounds good, yeah. (I assume you're referring to the second commit in the series: because that's the one that was marked NFC in the previous revision, and isn't in this one.) |
The test case 'whitespace around info string' includes a line that ends with a white space, while this is important for the test case it can cause two issues: * It could accidentally get reformatted by code editor * It is not explicit for developers reading the code This commit is making the trailing white space be more explicit.
While autocomplete does not include deactivated users, there still is a possibility that same-name users with one or more deactivated gets mentioned, which will make the mentioned user ambiguous without the id, this is explained in zulip#451. This adds a test case that asserts same-name users are disambiguated while composing the message regardless of them being active. Fixes part of zulip#451
As we start adding more features 'MentionAutocompleteQuery.testUser' would get confusing, This commit factors out _testName helper which is then used inside testUser.
'testUser' is a filter function that is expected to get complicated as we add features. For example it will be responsible for filtering users based on email, name, stream activity, etc. More on this: zulip#236 so it is useful to have the test cases for 'testUser' grouped.
Deactivated users can not be mentioned, so this commit ensures that deactivated users are excluded from the list that gets rendered in autocomplete popup. Fixes: zulip#451
Thanks @Khader-1 for the revision! This all looks good except two small nits in commit messages. I'll fix those up and merge.
The summary line should be in sentence case after the prefix: so "Factor out …".
The "fixes" line should have a colon: https://github.com/zulip/zulip-mobile/blob/main/docs/style.md#fixes-format |
854a18c
to
81feda5
Compare
Logic Implemented
autocomplete: Exclude deactivated users from @-mention autocomplete popup
Deactivated users can not be mentioned, so this ensures that deactivated users are excluded from the list that gets rendered in autocomplete popup.
compose test: Check ID still included if same-name users deactivated
While autocomplete does not include deactivated users, there still is a possibility that same-name users with one or more of them deactivated gets mentioned, which will make the mentioned user ambiguous without the id, this is explained in #451.
Fixes #451