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

Bookmark counter spec #3263

Merged
merged 3 commits into from
Oct 22, 2024
Merged

Conversation

mamrey
Copy link
Contributor

@mamrey mamrey commented Aug 8, 2024

A flaky test from #3215 was removed in #3245.

This PR fixes and replaces said spec, testing the ability to add/remove bookmarks without the bookmark navbar element present.

These changes also add an after hook to clean up modifications to CatalogController in the bookmark icon example

Ran the bookmark test suite 100 times, all green.

visit solr_document_path('2007020969')
expect(page).to have_no_css('#bookmarks_nav')
check 'Bookmark'

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a check here before navigating away from the page that shows it has been saved? Typically you can look for In Bookmarks in the page content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good call.

I have added that check, but it fails the rails 6 check. I built an internal test app using rails 6.1.7.8 and encountered the same failure. When inspecting the app, it looks like the BookmarkToggle event handler callback is fired twice in succession, so the checkbox checks and unchecks itself with one click. I haven't pinpointed the issue, but perhaps it's related to how the js assets are built/handled when using rails 6?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some additional context:

In the rails 6.1.7.8 test app, the browser receives both a blacklight.source.js and blacklight.debug.js file that appear the same. The clicked function is called in both these js files according to the debugger. This has the effect of the checkbox being clicked twice in succession, which reflects the failing test. While I am unfamiliar with the asset pipeline for rails 6 and BL, I will investigate turning off debug mode.

Copy link
Member

Choose a reason for hiding this comment

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

We can discuss pushing #3224 first at the next BL meeting. Then we don't have to worry about the odd things that webpack is doing.

sandbergja added a commit that referenced this pull request Oct 21, 2024
As @mamrey noted on #3263, this can lead to a user being unable to add bookmarks,
since the relevant eventlistener is added twice, so every time the user clicks to
add a bookmark, the toggle function is run twice, essentially doing nothing.

This bug (and fix) only affect Sprockets -- When using Importmap or Propshaft, this
branch of the view isn't even reached.
@sandbergja
Copy link
Contributor

@mamrey now that main no longer supports rails 6.1 (as of #3224), would you mind rebasing this PR? Thank you!

…element

- replaces previously removed flaky spec
- cleans up modifications to CatalogController after test
- clean up bookmarks before each example
Copy link
Contributor

@sandbergja sandbergja left a comment

Choose a reason for hiding this comment

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

Thanks, @mamrey !

@sandbergja sandbergja merged commit 50871a1 into projectblacklight:main Oct 22, 2024
13 checks passed
@mamrey
Copy link
Contributor Author

mamrey commented Oct 22, 2024

Thank you for further investigating the issue and moving things forward @sandbergja!

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.

3 participants