Skip to content

A platform for community discussion. Free, open, simple.

DEV: Improve stability of post-event and chat-integration channel specs (#39658)

Jarek Radoszaf1090fa6f35
diff --git a/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/post_event.rb b/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/post_event.rb
index 7cb22c6b304..efa464b3b21 100644
--- a/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/post_event.rb
+++ b/plugins/discourse-calendar/spec/system/page_objects/discourse_calendar/post_event.rb
@@ -7,22 +7,20 @@ module PageObjects
TRIGGER_MENU_SELECTOR = ".discourse-post-event-more-menu-trigger"
def open_more_menu
- # post-event component re-renders on a post re-cook and message_bus
- # events, so we need to retry on stale refs (hence `synchronize`)
- page.document.synchronize { find("#{TRIGGER_MENU_SELECTOR}:not(.--saving)").click }
-
- has_css?(".discourse-post-event-more-menu-content")
+ try_until_success do
+ locator("#{TRIGGER_MENU_SELECTOR}:not(.--saving)").click
+ yield if block_given?
+ end
self
end
def going
- page.document.synchronize { find(".going-button").click }
+ locator(".going-button").click
self
end
def open_bulk_invite_modal
- open_more_menu
- find(".dropdown-menu__item.bulk-invite").click
+ open_more_menu { locator(".dropdown-menu__item.bulk-invite").click }
self
end
@@ -47,7 +45,7 @@ module PageObjects
end
def click_description_toggle
- find(".event-description__toggle").click
+ locator(".event-description__toggle").click
self
end
@@ -61,9 +59,8 @@ module PageObjects
def close
has_css?(".discourse-post-event .status-and-creators .status:not(.closed)")
- open_more_menu
- find(".close-event").click
- find("#dialog-holder .btn-primary").click
+ open_more_menu { locator(".close-event").click }
+ locator("#dialog-holder .btn-primary").click
has_css?(".discourse-post-event .status-and-creators .status.closed")
has_no_css?("#{TRIGGER_MENU_SELECTOR}.--saving")
self
@@ -71,23 +68,20 @@ module PageObjects
def open
has_css?(".discourse-post-event .status-and-creators .status.closed")
- open_more_menu
- find(".open-event").click
- find("#dialog-holder .btn-primary").click
+ open_more_menu { locator(".open-event").click }
+ locator("#dialog-holder .btn-primary").click
has_css?(".discourse-post-event .status-and-creators .status:not(.closed)")
has_no_css?("#{TRIGGER_MENU_SELECTOR}.--saving")
self
end
def add_to_calendar
- open_more_menu
- find(".add-to-calendar .btn").click
+ open_more_menu { locator(".add-to-calendar .btn").click }
self
end
def edit
- open_more_menu
- find(".edit-event").click
+ open_more_menu { locator(".edit-event").click }
end
end
end
diff --git a/plugins/discourse-calendar/spec/system/post_event_spec.rb b/plugins/discourse-calendar/spec/system/post_event_spec.rb
index 7dbc72afe99..786732a2c71 100644
--- a/plugins/discourse-calendar/spec/system/post_event_spec.rb
+++ b/plugins/discourse-calendar/spec/system/post_event_spec.rb
@@ -96,22 +96,28 @@ describe "Post event" do
visit(post.topic.url)
# First click: join the event; since max is 1, it reaches capacity and shows Full
- post_event_page.going
- expect(page).to have_css(
- ".going-button",
- text: I18n.t("js.discourse_post_event.models.event.full"),
- )
+ try_until_success do
+ post_event_page.going
+
+ expect(page).to have_css(
+ ".going-button",
+ text: I18n.t("js.discourse_post_event.models.event.full"),
+ )
+ end
# Second click: leave the event; label should no longer be Full
- post_event_page.going
- expect(page).to have_no_css(
- ".going-button",
- text: I18n.t("js.discourse_post_event.models.event.full"),
- )
- expect(page).to have_css(
- ".going-button",
- text: I18n.t("js.discourse_post_event.models.invitee.status.going"),
- )
+ try_until_success do
+ post_event_page.going
+
+ expect(page).to have_css(
+ ".going-button",
+ text: I18n.t("js.discourse_post_event.models.invitee.status.going"),
+ )
+ expect(page).to have_no_css(
+ ".going-button",
+ text: I18n.t("js.discourse_post_event.models.event.full"),
+ )
+ end
end
end
@@ -188,8 +194,11 @@ describe "Post event" do
post_event_page.close
post_event_page.open
- post_event_page.going.open_more_menu
- find(".show-all-participants").click
+
+ try_until_success { post_event_page.going }.open_more_menu do
+ locator(".show-all-participants").click
+ end
+
find(".d-modal input.filter").fill_in(with: user.username)
find(".d-modal .add-invitee").click
diff --git a/plugins/discourse-chat-integration/spec/system/create_channel_spec.rb b/plugins/discourse-chat-integration/spec/system/create_channel_spec.rb
index 82139fe7e04..a351d9b2423 100644
--- a/plugins/discourse-chat-integration/spec/system/create_channel_spec.rb
+++ b/plugins/discourse-chat-integration/spec/system/create_channel_spec.rb
@@ -21,9 +21,10 @@ RSpec.describe "Create channel" do
it "creates and displays a new channel" do
visit("/admin/plugins/discourse-chat-integration/providers/discord")
+ expect(page).to have_css("#site-logo")
expect(page).to have_no_css(".channel-details")
- find("#create-channel").click if page.has_css?("#create-channel", wait: 0)
+ find("#create-channel").click
expect(page).to have_css(".inline-channel-form")