-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
bugfix: core: Fix cases where message was not focused on narrowing with anchor. #967
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.
@zee-bit Thanks for fixing the issue - all our stream narrowing from links should work after this - though I'm looking forward to seeing tests :)
We don't need to refer to the issue in the comment, and I'd only include a comment if you can't express the logic clearly. Given None
has particular meaning here, I'd suggest using it explicitly.
314cf7a
to
3bd2378
Compare
3bd2378
to
f41aa9f
Compare
f41aa9f
to
ab4ee77
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.
@zee-bit Thanks for working on the tests 👍
As per the comment, let's keep the bugfix commit itself as small as possible for clarity. You've extended the test and also altered some other test lines in the same commit, without touching on why. Feel free to add a refactor commit before or after with a rationale for that and we can explore those or improve these tests - these tests are by no means fixed or optimal I'm sure.
Regarding extending the test state space, we definitely could benefit from this in the longer term. There is likely a case where we don't jump to the message remaining due to having pre-existing messages but not the one in question - but this is a more general bug! (can you see it?)
tests/core/test_core.py
Outdated
['topic', msg_box.topic_name]] | ||
controller.model.narrow = [] | ||
@pytest.mark.parametrize('initial_narrow, final_narrow, anchor', [ | ||
([], [['stream', 'BOO'], ['topic', 'RDS']], None), |
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.
Do we lose anything by having the final narrow be the same each time, given we're testing narrowing to a topic? That would make this a lot less verbose, so make it clearer to understand all the cases.
Do we gain from exploring the initial_narrow state space for this change too, except within a topic?
It's clearer if with a bugfix you add/modify the tests minimally such that it breaks, then fix it.
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.
To clarify, my intention behind keeping the final narrow same was that, the index_topic
fixture from conftest
contains just one topic and one message, so having multiple final narrows would need some serious refactoring.
No, we don't gain anything from exploring initial_narrow state space, it was just to assure that narrowing works for all possible combinations of initial narrow.
I'll have to explore more on how I can improve the tests with minimal change. Also, breaking the tests seems very unlikely since the index contains just one message and it would focus on that even if we provide an anchor or don't.
ab4ee77
to
858a231
Compare
858a231
to
68fe859
Compare
68fe859
to
ad7f863
Compare
ad7f863
to
7687d1f
Compare
7687d1f
to
9f587b3
Compare
There's a prep PR for this that might simplify the multiple-message index generation in |
9f587b3
to
18cd7fb
Compare
18cd7fb
to
0579843
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.
tests/core/test_core.py
Outdated
if len(initial_narrow) == 2 and initial_narrow[0][0] == "stream": | ||
controller.model.stream_id = 205 |
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.
It would be nice to simplify this and avoid the conditional, but I'm not sure if we can?
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.
We can perhaps have a initial_stream_id
in parameterize?
That would be None
when narrow is []
?
9b237b3
to
c37cb26
Compare
This commit adds an extra stream message fixture to a new index fixture so that it could be utilized in tests that demands having at least two messages in a particular topic.
This commit modifies the test_narrow_to_topic() function to leverage the index_multiple_topic_msg fixture and test narrowing to a topic that contains multiple messages. We add testing for cases when anchor is provided to the _narrow_to function to enable us to broaden our scope of testing and open our eyes to bugs that may have been unnoticed with the previous test. We also add asserts to check if the final focus after narrowing is on the message we were expecting it to be in to ensure our code is robust. Tests amended.
This is bugfix that allow focusing on messages from the same narrow if a contextual message-id (anchor) is provided to the _narrow_to function. Earlier, if the user was within the same topic narrow then narrowing to a quoted message from MsgLinkButton did not select the message, since the _narrow_to() function didn't took anchor into account in this case. Tests amended. Fixes zulip#954.
This bugfix allows messages to be focused when narrowing to the "all_messages" narrow from other narrows. The primary bug was if the message from which we press 'a' was not present in model.index['all_msg_ids'], then we were not fetching that from the server. The reason we were not fetching those messages was we only checked if the final narrow is not empty, which in this case will never be, and not if it contains the message we are focusing to. This made the focus to move elsewhere in the "all_messages" narrow. Related discussion: #zulip-terminal > Contextual narrowing bug. Tests added.
c37cb26
to
39cafda
Compare
@zee-bit I adjusted some commit text, added test cases for the the anchor being another value in the narrow, and moved the expected value into the parametrize block in the last commit (like in the earlier one) - merging now 🎉 |
This bugfix fixes selecting messages if a contextual msg-id (anchor) is provided to the
_narrow_to()
function for some edge cases. Earlier, if the user was within the same narrow then narrowing to a quoted message fromMsgLinkButton
did not select that message. Also, sometimes pressinga
on a particular message did not focus on it when narrowed to theall_messages
narrow.Tests added.
Fixes #954.