DEV: Try fix bookmark flaky ()

I think the check for the bookmark icon is too optimistic,
so the DB might not be updated by the time we check. Using
try_until_success should fix this, we also don't have a
toast to check against via AJAX success, by design.
This commit is contained in:
Martin Brennan 2024-10-03 14:34:36 +10:00 committed by GitHub
parent ef00d6f633
commit 3108e3a6b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -33,8 +33,10 @@ describe "Bookmarking posts and topics", type: :system do
expect(bookmark_menu).to be_open
expect(page).to have_content(I18n.t("js.bookmarks.bookmarked_success"))
expect(topic_page).to have_post_bookmarked(post, with_reminder: false)
try_until_success(frequency: 0.5) do
expect(Bookmark.find_by(bookmarkable: post, user: current_user)).to be_truthy
end
end
it "updates the created bookmark with a selected reminder option from the bookmark menu" do
visit_topic_and_open_bookmark_menu(post)
@ -46,16 +48,20 @@ describe "Bookmarking posts and topics", type: :system do
expect(topic_page).to have_post_bookmarked(post, with_reminder: true)
expect(page).to have_no_css(".bookmark-menu-content.-expanded")
try_until_success(frequency: 0.5) do
expect(Bookmark.find_by(bookmarkable: post, user: current_user).reminder_at).not_to be_blank
end
end
it "can set a reminder from the bookmark modal using the custom bookmark menu option" do
visit_topic_and_open_bookmark_menu(post)
bookmark_menu.click_menu_option("custom")
bookmark_modal.select_preset_reminder(:tomorrow)
expect(topic_page).to have_post_bookmarked(post, with_reminder: true)
try_until_success(frequency: 0.5) do
expect(Bookmark.find_by(bookmarkable: post, user: current_user).reminder_at).not_to be_blank
end
end
it "allows choosing a different auto_delete_preference to the user preference and remembers it when reopening the modal" do
current_user.user_option.update!(