DEV: Fix bookmark system spec flaky ()

1) Bookmarking posts and topics topic level bookmarks clears all topic bookmarks from the topic bookmark button if more than one post is bookmarked
     Failure/Error: expect(Bookmark.where(user: current_user).count).to eq(0)

       expected: 0
            got: 2
This commit is contained in:
Martin Brennan 2023-07-17 15:34:11 +10:00 committed by GitHub
parent 37fd05af4e
commit b2ff00cc74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions
spec/system
bookmarks_spec.rb
page_objects/pages

@ -108,6 +108,7 @@ describe "Bookmarking posts and topics", type: :system do
expect(dialog).to have_content(I18n.t("js.bookmarks.confirm_clear")) expect(dialog).to have_content(I18n.t("js.bookmarks.confirm_clear"))
dialog.click_yes dialog.click_yes
expect(dialog).to be_closed expect(dialog).to be_closed
expect(topic_page).to have_no_bookmarks
expect(Bookmark.where(user: current_user).count).to eq(0) expect(Bookmark.where(user: current_user).count).to eq(0)
end end
end end

@ -88,6 +88,10 @@ module PageObjects
has_css?("#{topic_footer_button_id("bookmark")}.bookmarked", text: "Edit Bookmark") has_css?("#{topic_footer_button_id("bookmark")}.bookmarked", text: "Edit Bookmark")
end end
def has_no_bookmarks?
has_no_css?("#{topic_footer_button_id("bookmark")}.bookmarked")
end
def find_topic_footer_button(button) def find_topic_footer_button(button)
find(topic_footer_button_id(button)) find(topic_footer_button_id(button))
end end