From b2ff00cc74a9a00aa3e4853ba8c23e5566d492de Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Mon, 17 Jul 2023 15:34:11 +1000 Subject: [PATCH] DEV: Fix bookmark system spec flaky (#22630) 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 --- spec/system/bookmarks_spec.rb | 1 + spec/system/page_objects/pages/topic.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/spec/system/bookmarks_spec.rb b/spec/system/bookmarks_spec.rb index a16eb786b1d..732b130c9d1 100644 --- a/spec/system/bookmarks_spec.rb +++ b/spec/system/bookmarks_spec.rb @@ -108,6 +108,7 @@ describe "Bookmarking posts and topics", type: :system do expect(dialog).to have_content(I18n.t("js.bookmarks.confirm_clear")) dialog.click_yes expect(dialog).to be_closed + expect(topic_page).to have_no_bookmarks expect(Bookmark.where(user: current_user).count).to eq(0) end end diff --git a/spec/system/page_objects/pages/topic.rb b/spec/system/page_objects/pages/topic.rb index 15b7e23c926..b791f537922 100644 --- a/spec/system/page_objects/pages/topic.rb +++ b/spec/system/page_objects/pages/topic.rb @@ -88,6 +88,10 @@ module PageObjects has_css?("#{topic_footer_button_id("bookmark")}.bookmarked", text: "Edit Bookmark") end + def has_no_bookmarks? + has_no_css?("#{topic_footer_button_id("bookmark")}.bookmarked") + end + def find_topic_footer_button(button) find(topic_footer_button_id(button)) end