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

Accept comments argument in showSelectedPost #11606

Merged
merged 2 commits into from
Feb 27, 2017

Conversation

nb
Copy link
Member

@nb nb commented Feb 27, 2017

Fixes #10951 – when clicking the Comments link on a card in the reader it doesn’t take us to the comments section of a post.

Implementation details are in the commit message.

A couple of design notes:

  • Tracking passing callbacks and other arguments (the click handler and the comments argument) through several layers was not fun. As a reader it would’ve been easier if it was clearer where those values were coming from.
  • I had to mock a lot of stuff to test the function. I don’t mind testing with some side effects, but calling page this deep the call chain was unexpected for me. It would’ve felt a lot more natural if page calls were limited to actions/controllers, or at least to components, not library functions.

Currently when clicking on a comment link in a stream we are passing a
`comments` attribute to `showSelectedPost` (via an object), however we
aren’t destructuring it and are doing nothing with it.

This commit adds `comments` to the arguments destructuring in
`showSelectedPost` and then passes the argument down to `showFullPost`,
which already supports and is smart enough to add `#comments` to the
URL.

As a result, now clicking on a the comments link in any card takes us to
the comments section of the post, not the title.

There are some limited tests, too.

Fixes #10951.
@matticbot
Copy link
Contributor

@nb nb requested review from blowery and samouri February 27, 2017 12:19
@matticbot matticbot added the [Size] M Medium sized issue label Feb 27, 2017
@nb nb added [Feature] Reader The reader site on Calypso. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 27, 2017

it( 'redirects if passed a post key', () => {
showSelectedPost( { postKey: { feedId: 1, postId: 5 } } );
expect( pageSpy ).to.have.been.calledOnce;
Copy link
Contributor

Choose a reason for hiding this comment

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

may be good to verify that the url does not have "#comments" here

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. I wanted to hear your thoughts on refactoring this a bit before adding a lot more tests. This suite is missing many other branches of the code.

@samouri
Copy link
Contributor

samouri commented Feb 27, 2017

Thank you @nb for addressing this!

Code looks great. I love the tests :)
I'll test it out functionality now

@samouri
Copy link
Contributor

samouri commented Feb 27, 2017

On your design notes:
You are definitely right about the pain of tracking those callbacks + the too-deep page calls so I'll create a follow-up PR to clean up the points you mentioned

@samouri
Copy link
Contributor

samouri commented Feb 27, 2017

Functionality is still broken for cards in the SearchStream. I'll plop in a commit with a fix

@samouri samouri added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 27, 2017
@matticbot matticbot added the [Size] M Medium sized issue label Feb 27, 2017
@samouri samouri added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Author Reply labels Feb 27, 2017
Copy link
Contributor

@blowery blowery left a comment

Choose a reason for hiding this comment

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

LGTM

@blowery blowery merged commit cd64141 into master Feb 27, 2017
@blowery blowery deleted the fix/comment-link-on-streams branch February 27, 2017 15:46
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 27, 2017
@nb
Copy link
Member Author

nb commented Feb 27, 2017

@blowery wouldn’t it have been better if we had squashed the commits in this case? The search stream change doesn’t seem logically separate from the first one.

@blowery
Copy link
Contributor

blowery commented Feb 27, 2017

@nb I tend to avoid squashing when there are multiple authors

@blowery
Copy link
Contributor

blowery commented Feb 27, 2017

helps to preserve blame info down the road

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Reader The reader site on Calypso. [Size] M Medium sized issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants