-
-
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
views: Support 'j/k', 'J/K' and 'G/end' for navigation in popups. #524
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.
@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?
@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? |
@preetmishra Right, it would seem straightforward to do that, maybe an I would keep this code around, but this other approach may be simpler. |
Yes, that seems plausible. I'll start working on it. |
@neiljp I have added an I have also added another commit to refactor |
@preetmishra Sorry if I wasn't clear; I was meaning refactoring the code to use another class with the common features, not the tests :) |
@neiljp Thanks. I have added The second commit is a suggested refactor of |
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.
@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 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 |
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.
@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.
@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 For the rest of the two commits, I have made the changes that were suggested. I have also renamed |
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.
@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!
@neiljp Thanks. I have added a test for |
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? :) |
6c997cc
to
9ded416
Compare
@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 Also, the commit order that GitHub is showing isn't what I had locally. The order that I pushed was 4 -> 3 -> 2 -> 1. |
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.
@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.
@neiljp Thanks. I have made the amendments in the test as per your suggestions. I also rewrote the commit message to include the |
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.
@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. |
Thanks so much! 🎉 |
This PR is a follow-up to #518. This will generalize navigation and make the user interface consistent.
@neiljp