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

work doesn't get selected when "Want to Read" button is pressed #8529

Merged

Conversation

Billa05
Copy link
Contributor

@Billa05 Billa05 commented Nov 15, 2023

Closes #6881

It fixes the bug that was causing to select the work when pressed on the Want to Read button.

also, I have added a test case for toggelSelected method

Testing

  1. setup locally and login as admin
  2. go to search result and press want to read button

Screenshot

example.mp4

Stakeholders

@scottbarnes

@Billa05 Billa05 changed the title work doesnt get selected when want to read button is pressed work doesn't get selected when "Want to Read" button is pressed Nov 15, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 17, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (308a35d) 16.51% compared to head (023667a) 17.61%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8529      +/-   ##
==========================================
+ Coverage   16.51%   17.61%   +1.09%     
==========================================
  Files          85       85              
  Lines        4456     4456              
  Branches      782      782              
==========================================
+ Hits          736      785      +49     
+ Misses       3227     3187      -40     
+ Partials      493      484       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@scottbarnes
Copy link
Collaborator

scottbarnes commented Nov 17, 2023

Thanks for this, @Billa05! The feature works like it should, which is definitely a win. :)

The set up for the tests in this case turned out to be more involved than I thought, and you were 90% of the way there.

One thing to remember with tests is you want to make sure that the test doesn't always pass. In this case, even without the change to toggleSelected(), the test still passed, so I tweaked it and pushed the changes to this branch, with one test that simulates clicking on the dropper / 'want to read', and another that simulates clicking elsewhere.

I'm still not 100% sold on the test set up myself, so if you have any suggestions, please let me know. Also, if you want to make further changes, please pull from your remote branch first on your Open Library fork, so you can integrate these changes into your own local branch.

Once you're happy with everything, I will go ahead and merge this.

@mheiman
Copy link
Collaborator

mheiman commented Nov 17, 2023

@scottbarnes — I have a PR in review with Drini that refactors this file in some significant ways (e.g. toggleSelected is called something else and has new parameters). If you could hold off on merging this for a few days until that one lands, it would avoid some confusion.

@scottbarnes
Copy link
Collaborator

@scottbarnes — I have a PR in review with Drini that refactors this file in some significant ways (e.g. toggleSelected is called something else and has new parameters). If you could hold off on merging this for a few days until that one lands, it would avoid some confusion.

Will do! Thanks for the heads up.

@Billa05
Copy link
Contributor Author

Billa05 commented Nov 20, 2023

Thanks for this, @Billa05! The feature works like it should, which is definitely a win. :)

The set up for the tests in this case turned out to be more involved than I thought, and you were 90% of the way there.

One thing to remember with tests is you want to make sure that the test doesn't always pass. In this case, even without the change to toggleSelected(), the test still passed, so I tweaked it and pushed the changes to this branch, with one test that simulates clicking on the dropper / 'want to read', and another that simulates clicking elsewhere.

I'm still not 100% sold on the test set up myself, so if you have any suggestions, please let me know. Also, if you want to make further changes, please pull from your remote branch first on your Open Library fork, so you can integrate these changes into your own local branch.

Once you're happy with everything, I will go ahead and merge this.

Sorry for the delayed response I was travelling. @scottbarnes thank you for the feedback this was my first time writing a test case in js. I appreciate your insights on the test setup, and I understand the importance of ensuring test reliability. Your adjustments make sense, as it checks individually for clicking on ctaDiv and listItem elements. will make the needful changes once @mheiman pr gets reviewed.

@jimchamp jimchamp added the State: Blocked Work has stopped, waiting for something (Info, Dependent fix, etc. See comments). [managed] label Nov 20, 2023
@jimchamp jimchamp assigned scottbarnes and unassigned mheiman Nov 20, 2023
@jimchamp
Copy link
Collaborator

Merging is blocked until #8441 is merged.

Comment on lines 88 to 89
$(clickEvent.target).closest('.searchResultItemCTA').length > 0 ||
($(clickEvent.target).closest('a').is('a') &&
Copy link
Collaborator

@cdrini cdrini Nov 21, 2023

Choose a reason for hiding this comment

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

We can make this a little tighter :) This will also handle any other <button> elements.

Suggested change
$(clickEvent.target).closest('.searchResultItemCTA').length > 0 ||
($(clickEvent.target).closest('a').is('a') &&
($(clickEvent.target).closest('a, button').length > 0 &&

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks good to me. tested and it is working properly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the read and want to read buttons are not button elements. but still, this solves the issue. @scottbarnes could you look into this?

@cdrini cdrini removed the State: Blocked Work has stopped, waiting for something (Info, Dependent fix, etc. See comments). [managed] label Nov 24, 2023
@cdrini
Copy link
Collaborator

cdrini commented Nov 24, 2023

No longer blocked! This will need a rebase though

@Billa05
Copy link
Contributor Author

Billa05 commented Nov 26, 2023

@scottbarnes is there any need to change the test case? I think the test case for ctaDiv has to be removed. if required I can try to add a test case for the button, if it makes sense.

@Billa05
Copy link
Contributor Author

Billa05 commented Nov 29, 2023

I have modified the testcase file. @scottbarnes could you please review it.

@scottbarnes
Copy link
Collaborator

I have modified the testcase file. @scottbarnes could you please review it.

Hi, @Billa05. Thanks for updating this. Can you rebase it against the latest master branch and push the updated commits to this PR?

Please see Making Updates to Your Pull Request if you run into issues rebasing.

@Billa05
Copy link
Contributor Author

Billa05 commented Nov 30, 2023

I have modified the testcase file. @scottbarnes could you please review it.

Hi, @Billa05. Thanks for updating this. Can you rebase it against the latest master branch and push the updated commits to this PR?

Please see Making Updates to Your Pull Request if you run into issues rebasing.

this is the first time I have done rebasing. is this right? and should I remove all the commented code from the test case?

@scottbarnes
Copy link
Collaborator

Alas, @Billa05, the rebasing has gone slightly awry. You'll want to remove (drop) the commits that aren't related to your PR: https://github.com/internetarchive/openlibrary/pull/8529/commits.

Using the following should get you started:

git fetch upstream master
git rebase -i upstream/master

I have done this exact same thing during some of my first rebases. :) If you get stuck let me know and I can give further direction, though it won't be until tomorrow evening Pacific time at the earliest, most likely.

I happened to have all your commits, at least of perhaps 12 hours or so ago, handy, so this may help:

pick 6d05cdd3e resolve the bug and added a test case
pick 1c09cff50 [pre-commit.ci] auto fixes from pre-commit.com hooks
pick 9ed1e8cba SelectionManager: toggleSelected shouldn't activate with dropper clicks
pick 9d3fd49a6 also handle any other <button> elements
pick 4372bf2d9 renaming
pick aa6c8de2c changing funtion name in testcase
pick 7ce03e9f1 modified testcases

@Billa05
Copy link
Contributor Author

Billa05 commented Nov 30, 2023

Alas, @Billa05, the rebasing has gone slightly awry. You'll want to remove (drop) the commits that aren't related to your PR: https://github.com/internetarchive/openlibrary/pull/8529/commits.

Using the following should get you started:

git fetch upstream master
git rebase -i upstream/master

I have done this exact same thing during some of my first rebases. :) If you get stuck let me know and I can give further direction, though it won't be until tomorrow evening Pacific time at the earliest, most likely.

I happened to have all your commits, at least of perhaps 12 hours or so ago, handy, so this may help:

pick 6d05cdd3e resolve the bug and added a test case
pick 1c09cff50 [pre-commit.ci] auto fixes from pre-commit.com hooks
pick 9ed1e8cba SelectionManager: toggleSelected shouldn't activate with dropper clicks
pick 9d3fd49a6 also handle any other <button> elements
pick 4372bf2d9 renaming
pick aa6c8de2c changing funtion name in testcase
pick 7ce03e9f1 modified testcases

firstly this shows up:
Screenshot 2023-11-30 221854
then if i ctrl+z it shows this:
Screenshot 2023-11-30 221132
now if I am dropping all the others the issue is this ( pick 6d05cdd resolve the bug and added a test case) is getting drop with
(pick 2b93e92 modified testcases)

I tired to undo the rebasing but got nothing other than frustration 😩

according to the commit messages I was resolving the conflicts, I accepted the changes from the respective commits instead of the current code. it that the right way? at last i was left with this:
Screenshot 2023-11-30 223107

should I push this?
I was thinking couldn't I have just merged the master branch to the feature branch to update it, is it necessary to have the commits in line?

@Billa05
Copy link
Contributor Author

Billa05 commented Dec 1, 2023

hey, @scottbarnes could you please look into this?

@scottbarnes
Copy link
Collaborator

@Billa05, I think that the last screenshot, with the following, looks correct:

pick 9d3fd49a6 also handle any other <button> elements
pick 4372bf2d9 renaming
pick aa6c8de2c changing funtion name in testcase
pick 7ce03e9f1 modified testcases

Assuming you resolved all the conflicts, the fix works, and the tests work, then yeah, push it and I can take a look.

In answer to your question about the commented out code, yes, please go ahead and remove it, and as for whether the tests need to change, I can look more closely at that once the rebase is done and the code pushed here.

With respect to why not merge master into your feature branch, it does fundamentally do the same thing in terms of resolving conflicts, but in doing so it adds other code, unrelated to your branch, into your branch. That's fine so long as none of that code later changes, however, it often does change, and it makes it harder to review.

@Billa05
Copy link
Contributor Author

Billa05 commented Dec 1, 2023

@scottbarnes thank you for the explanation. I have pushed the commits but it doesn't seem to fix it.
the previous rebase caused this issue, right? So cant I undo it in some way

@scottbarnes
Copy link
Collaborator

@Billa05, I was able to rebase the branch with this latest code. I can simply push it here, but if you'd like we could also do a screenshare for a few minutes and I can show you what I've done.

Let me know if you'd like to do a screenshare, or if I should just push the rebased branch. :)

@Billa05
Copy link
Contributor Author

Billa05 commented Dec 1, 2023

@Billa05, I was able to rebase the branch with this latest code. I can simply push it here, but if you'd like we could also do a screenshare for a few minutes and I can show you what I've done.

Let me know if you'd like to do a screenshare, or if I should just push the rebased branch. :)

@scottbarnes, I would love to do that. I want to clear the mess I have created 😅

@scottbarnes
Copy link
Collaborator

@Billa05, I'll send you a message on Slack to coordinate.

@Billa05
Copy link
Contributor Author

Billa05 commented Dec 1, 2023

@Billa05, I'll send you a message on Slack to coordinate.

sure, I am waiting

@scottbarnes scottbarnes force-pushed the 6881/fix/work-doesnt-get-selected branch from 8e7e503 to e093fe0 Compare December 2, 2023 06:40
@Billa05
Copy link
Contributor Author

Billa05 commented Dec 3, 2023

@scottbarnes could you please review the test case

Copy link
Collaborator

@scottbarnes scottbarnes left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks, @Billa05!

@scottbarnes scottbarnes merged commit 9e7f5ba into internetarchive:master Dec 3, 2023
3 checks passed
@Billa05
Copy link
Contributor Author

Billa05 commented Dec 3, 2023

Looks good to me. Thanks, @Billa05!

Thank you, @scottbarnes, for all your help throughout the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Work gets selected in merge UI when you press "Want to read" near it
6 participants