Skip to content
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

views: Support 'j/k', 'J/K' and 'G/end' for navigation in popups. #524

Closed
wants to merge 4 commits into from

Conversation

preetmishra
Copy link
Member

@preetmishra preetmishra commented Mar 5, 2020

This PR is a follow-up to #518. This will generalize navigation and make the user interface consistent.
@neiljp

@zulipbot zulipbot added the size: L [Automatic label added by zulipbot] label Mar 5, 2020
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@preetmishra I can see the approach you have here working, but there's quite a bit of duplication; have you considered an inheritance approach to this?

@preetmishra
Copy link
Member Author

@neiljp Thanks for the review. I agree that there's duplication but there are two seperate views (Stream and Message). One possibility I can think of is making a base test class for popups, would that be fine?

@neiljp
Copy link
Collaborator

neiljp commented Mar 6, 2020

@preetmishra Right, it would seem straightforward to do that, maybe an InfoView? (based on the current class names)

I would keep this code around, but this other approach may be simpler.

@preetmishra
Copy link
Member Author

Yes, that seems plausible. I'll start working on it.

@preetmishra
Copy link
Member Author

@neiljp I have added an InfoView which encapsulates the basic tests for any popup and leveraged it to simplify TestStream/MsgInfoView tests.

I have also added another commit to refactor TestHelpMenu to leverage InfoView.

@neiljp
Copy link
Collaborator

neiljp commented Mar 6, 2020

@preetmishra Sorry if I wasn't clear; I was meaning refactoring the code to use another class with the common features, not the tests :)

@preetmishra
Copy link
Member Author

@neiljp Thanks. I have added InfoView with the common method and inherited it in the other Stream/MsgInfoView.

The second commit is a suggested refactor of HelpView to leverage InfoView class.

@neiljp neiljp added the PR needs review PR requires feedback to proceed label Mar 9, 2020
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@preetmishra Note that the refactor commit is not quite what I would expect - it makes the help menu still work, with new code, but not within just that one commit, since the new code is in another commit.

A structure that might be clearer, if in two commits, would be to extract the functionality into the base class from the existing class (the refactor), and then use the newly-available base class in the other cases (the feature). Try comparing the two different sequences of commits and let me know what you think.

@neiljp neiljp removed the PR needs review PR requires feedback to proceed label Mar 19, 2020
@zulipbot zulipbot added size: XL [Automatic label added by zulipbot] and removed size: L [Automatic label added by zulipbot] labels Mar 20, 2020
@preetmishra
Copy link
Member Author

@neiljp Thanks for the review. The sequence you suggested is indeed much cleaner than what I had proposed previously. I have pushed the new changes.

Also, I renamed InfoView to PopUpView as it seemed more consistent with HelpView and Stream/MsgInfoView (InfoView seemed only limited to infoviews).

Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@preetmishra This is really close, but since we're introducing the PopUpView (better name 👍), let's get it as good as we can first time.

My other comment re fixtures is something we could address in this PR, but also is fine elsewhere.

@preetmishra
Copy link
Member Author

preetmishra commented Mar 21, 2020

@neiljp I have added another refactor commit to introduce a fixture which will help in reducing code duplication. I think it is apt to introduce it here before the 'new' feature since they are going to use it in keypress_navigation tests. However, the commit heading already got too long with 'tests', 'areas' and 'refactor' that I had to settle with a short heading that is not as descriptive.

For the rest of the two commits, I have made the changes that were suggested. I have also renamed help_menu_content to log in HelpView to make it consistent with Msg/StreamInfoView.

Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@preetmishra This is looking great, the fixture makes the (test) code smaller 👍

Except for the name issues and perhaps a test for the new class, I would say this is ready!

@preetmishra
Copy link
Member Author

@neiljp Thanks. I have added a test for PopUpView's init method as its keypress is being tested in the derived classes anyway. I have also renamed the variables as per your suggestions.

@neiljp
Copy link
Collaborator

neiljp commented Mar 22, 2020

I understand the keypress is being tested in the derived classes, but the derived classes may change behavior later; I'm not sure this is much overhead or a challenge? :)

@preetmishra preetmishra force-pushed the fix-nav branch 2 times, most recently from 6c997cc to 9ded416 Compare March 23, 2020 14:32
@preetmishra
Copy link
Member Author

@neiljp My bad, I didn't consider the fact that the derived classes may change the behavior later. Thanks. I have added the tests for different keypress options as well.

Other than that, I have added another refactor commit to change super_view to super_keypress
in HelpView's test as the latter better defines what the variable holds.

Also, the commit order that GitHub is showing isn't what I had locally. The order that I pushed was 4 -> 3 -> 2 -> 1.

Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@preetmishra I know you've been working on this quite a lot for something small, but we're uncovering lots of things and new test code 👍

Inline feedback is all test-related, except for a note about including a change in behavior for the enhanced navigation commit (the original feature!).

I appreciate the initiative and it does clarify the tests in my view, but I think we should keep the size parameters in the test function body for now. We can perhaps do a sweep of this after some discussion, as this is a format used in many places in the tests, so would be good to change uniformly.

@preetmishra
Copy link
Member Author

@neiljp Thanks. I'll revert the size variable back in the tests. I also did this in #539 as per your suggestion to use default parameter as a compromise for size variable, I'll make these changes there as well.

@preetmishra
Copy link
Member Author

@neiljp Thanks. I have made the amendments in the test as per your suggestions. I also rewrote the commit message to include the Walker usage change. It is ready for review.

Updated the variable name from `super_view` to `super_keypress` in View and
HelpView as it better conveys what the variable holds.
Added a fixture, navigation_key_expected_key_pair, in `conftest.py`
to generate test cases for keypress tests related to navigation. This
helps in reducing code duplication through the sharing of the common
fixture among different navigation tests.

Tests amended for navigation keypresses in View and HelpView to
leverage the fixture.
Added PopUpView, a base class for popups, that extracts the common
keypress method and inherited it in HelpView.

This class can be leveraged to introduce the keypress method and
reduce potential code duplication in other popup views.

Test added for PopUpView.
Extended support for navigation through the other specified keys in
infoviews using PopUpView base class.

Note that unlike the previous implementation, the ListWalker object
is constructed in PopUpView (the base class) instead of the derived
class.

Tests added for navigation keypresses in MessageInfoView and
StreamInfoView.
@neiljp
Copy link
Collaborator

neiljp commented Mar 26, 2020

@preetmishra Thanks for this! I just merged it after some very minor tweaks 🎉

There were no code changes, I just moved one import from one commit to another, as you'd introduced an import in an earlier commit than it was required.

@neiljp neiljp closed this Mar 26, 2020
@preetmishra
Copy link
Member Author

Thanks so much! 🎉

@preetmishra preetmishra deleted the fix-nav branch March 26, 2020 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants