Skip to content

Conversation

@ReverM
Copy link
Contributor

@ReverM ReverM commented Dec 10, 2025

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

ReverM and others added 8 commits December 4, 2025 10:37
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
@ReverM
Copy link
Contributor Author

ReverM commented Dec 10, 2025

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.

@slavalamp
Copy link
Contributor

slavalamp commented Dec 10, 2025

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"

@ReverM ReverM changed the title AO3 7214 + 7215 Bookmark Javascript Improvement AO3-7214 AO3-7215 Bookmark Javascript Improvement Dec 10, 2025
@ReverM
Copy link
Contributor Author

ReverM commented Dec 10, 2025

though the pr name should begin like this: "AO3-7214 AO3-7215"

Changed the PR name accordingly

Copy link
Collaborator

@sarken sarken left a 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.

@ReverM
Copy link
Contributor Author

ReverM commented Jan 8, 2026

I pushed changes to the gemfile.lock by accident. Disregard the Gem Updates tag

@ReverM ReverM requested a review from sarken January 8, 2026 21:08

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) %>"); }
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

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

Copy link
Collaborator

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).

Comment on lines 8 to 13
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"
Copy link
Collaborator

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:

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
Copy link
Collaborator

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"
Copy link
Collaborator

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:

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 %>
Copy link
Collaborator

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.)

@ReverM
Copy link
Contributor Author

ReverM commented Jan 14, 2026

Gonna put this to draft while I add the rest of the test coverage.

@ReverM
Copy link
Contributor Author

ReverM commented Jan 15, 2026

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?

@ReverM ReverM marked this pull request as ready for review January 15, 2026 21:12
@ReverM
Copy link
Contributor Author

ReverM commented Jan 15, 2026

I shall put this as ready for review as I do not understand why the step fails in the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants