Skip to content

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

DEV: Improve post_event_spec flake situation again (#39791)

Jarek Radosz5738be243e29
diff --git a/plugins/discourse-calendar/spec/system/post_event_spec.rb b/plugins/discourse-calendar/spec/system/post_event_spec.rb
index 786732a2c71..65103f51b2b 100644
--- a/plugins/discourse-calendar/spec/system/post_event_spec.rb
+++ b/plugins/discourse-calendar/spec/system/post_event_spec.rb
@@ -89,35 +89,21 @@ describe "Post event" do
context "with max attendees" do
it "updates the going button label from Full after toggling" do
- title = "My test meetup event"
+ going = I18n.t("js.discourse_post_event.models.invitee.status.going")
+ full = I18n.t("js.discourse_post_event.models.event.full")
raw = "[event status='public' start='2222-02-22 14:22' max-attendees='1']\n[/event]"
- post = PostCreator.create(admin, title:, raw:)
+ post = PostCreator.create(admin, title: "My test meetup event", raw:)
visit(post.topic.url)
- # First click: join the event; since max is 1, it reaches capacity and shows 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
+ # Wait for the component to settle before clicking
+ expect(page).to have_css(".going-button", text: going)
+ post_event_page.going
+ expect(page).to have_css(".going-button", text: full)
- # Second click: leave the event; label should no longer be Full
- 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
+ post_event_page.going
+ expect(page).to have_css(".going-button", text: going)
+ expect(page).to have_no_css(".going-button", text: full)
end
end