-
Notifications
You must be signed in to change notification settings - Fork 662
AO3-7214 AO3-7215 Bookmark Javascript Improvement #5499
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
base: master
Are you sure you want to change the base?
Conversation
Changed id to class so that every button that can do one feature behaves the same and changed the organisation of the jquery
Since the new tests have been moved to their new feature file to test javascript feature these are not needed
|
Appologies if having multiple ticket in one PR is bad etiquette. I decided to put both in the same PR, as they were extremely closely related, and would likely be waiting on each other if done separately. |
|
yeah, putting two tickets in one pr is fine when it's exact the same fix for both though the pr name should begin like this: "AO3-7214 AO3-7215" |
Changed the PR name accordingly |
sarken
left a comment
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.
Thanks for working on this! In addition to the question I left on the JavaScript file, I think you also need to changeid to class for the buttons in the bookmarkable_blurb, which is used for pages where we show multiple bookmarks under a single item, e.g., a tag's bookmark listing.
|
I pushed changes to the gemfile.lock by accident. Disregard the Gem Updates tag |
|
|
||
| bookmark_div.html("<%= escape_javascript(render "bookmarks/bookmark_form", :bookmarkable => @bookmarkable, :bookmark => @bookmark, :button_name => @button_name, :action => @action, :in_page => true, :dynamic => true) %>"); | ||
| bookmark_open.hide(); | ||
| if (!bookmark_div.children().length) { bookmark_div.html("<%= escape_javascript(render "bookmarks/bookmark_form", :bookmarkable => @bookmarkable, :bookmark => @bookmark, :button_name => @button_name, :action => @action, :in_page => true, :dynamic => true) %>"); } |
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.
I didn't check -- does this work with the new bookmarkable: @bookmarkable syntax? If so, it'd be nice to fix that while we're touching this line.
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.
What exactly is this new syntax?
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.
I think sarken is talking about the hashmap syntax? https://ruby-doc.org/core-3.1.0/Hash.html#class-Hash-label-Hash+Data+Syntax
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.
Right. It should be possible to use the JSON-style syntax from the example in my previous comment (bookmarkable: @bookmarkable) instead of the current hash rocket syntax (:bookmarkable => @bookmarkable).
| Given a canonical fandom "The Bookmarks" | ||
| And the work "Bookmark: The Beginnings" by "bookmarker" with fandom "The Bookmarks" | ||
| And the work "Bookmark: The Sequel" by "bookmarker" with fandom "The Bookmarks" | ||
| And all indexing jobs have been run | ||
| And the dashboard counts have expired | ||
| And I am logged in as "bookmarker" |
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.
I think we could simplify this considerably by just logging in and creating a bookmark: we don't need a canonical fandom unless we're testing a tag bookmark page, and we don't need to update any dashboard counts because we're not testing any dashboard pages.
We only need to run the indexing jobs if we're accessing pages that rely on Elasticsearch, but we have a workaround that lets us avoid constantly having to use all indexing jobs have been run. If you check out paths.rb, you'll see a lot of this:
otwarchive/features/support/paths.rb
Lines 128 to 130 in b23fe62
| when /^(.*?)(?:'s)? bookmarks page$/i | |
| step %{all indexing jobs have been run} | |
| user_bookmarks_path(user_id: $1) |
That way, instead of running indexing and following a link on the page, we can just say When I go to username's bookmarks page. (Not every page that relies on Elasticsearch is included in paths.rb, but you're always welcome to add any you need. It makes it easier for the next person who needs to test that page.)
However, I'm not sure we need any Background here at all. The second scenario seems to be broken in production and fixed in this branch with just one bookmark, so the bookmarks created in the background steps are unnecessary.
| @@ -0,0 +1,41 @@ | |||
| @bookmarks | |||
| Feature: Edit bookmarks with javascript enabled | |||
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.
Since there were a lot of places id needed to become class, and some of them were hard to track down, I think we need to be a bit more thorough with these tests. They should cover all of those locations, not just a few.
3a2d58f has some tests to get started. I think the only thing that isn't covered there are the Save buttons in the bookmark and bookmarkable blurbs. Can you try adding tests for those? There might also be some tweaks you can make to the code in my commit, e.g., standardizing some variable names, removing some comments, moving the Then step definitions into the Then section of the file. (You'll also need to change "Boorkmark" to "Bookmark" once you fix the locale file -- I wanted to make sure the tests would pass, so I used the version with the typo.)
That said, I'm going to leave a couple comments on the tests you have here just to provide some information that might be helpful in the future.
| And I bookmark the work "Bookmark: The Beginnings" | ||
| And I bookmark the work "Bookmark: The Sequel" | ||
| And all indexing jobs have been run | ||
| When I follow "Bookmarks" |
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.
When I go to the bookmarks page would be better here, since it includes some cache expiration we wouldn't get by just following the link:
otwarchive/features/support/paths.rb
Lines 30 to 34 in b23fe62
| when /^the bookmarks page$/i | |
| # This cached page only expires by time, not by any user action; | |
| # just clear it every time. | |
| Rails.cache.delete "bookmarks/index/latest/v2_true" | |
| bookmarks_path |
| edit_bookmark_path(current_user_bookmark), | ||
| id: "bookmark_form_trigger_for_#{bookmarkable.id}", | ||
| remote: true %> | ||
| <%= link_to t(".saved"), edit_bookmark_path(current_user_bookmark), data: { path: edit_bookmark_path(current_user_bookmark) }, class: "bookmark_form_trigger_for_#{bookmarkable.id}", remote: true %> |
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.
I think the multiline format was a little easier to read, if you could keep that here. (Reviewdog might have some opinions about the indenting, though. It usually takes me a few tries to figure out exactly what it wants.)
|
Gonna put this to draft while I add the rest of the test coverage. |
|
Some of the steps in the test are very inconsistent. I'm unsure what could be the cause. Is cucumber not the best friend with javascript? They overall seem very flaky. What could be explaining this? |
|
I shall put this as ready for review as I do not understand why the step fails in the test. |
Issue
https://otwarchive.atlassian.net/browse/AO3-7214
https://otwarchive.atlassian.net/browse/AO3-7215
Purpose
This adresses both tickets 7214 and 7215 by making all buttons that could edit a bookmark disappear when the form is open, by allowing a closed form to be reopened (7215) and by fixing the opening and closing of multiple forms at the same time.
7214 was fixed by removing the variables and jquerying the appropriate component each time the form is closed or reopened.
7215 was fixed by changing the href of the opening buttons as part of the closing event, as well as changing the id to a class so every element is affected at the same time.
Credit
Danaël / Rever ( they / he )
Jira account goes by Danaël Villeneuve