Skip to content

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

DEV: Fix flaky system test (#34531)

Alan Guo Xiang Tan61a7816007c7
diff --git a/spec/system/composer/drafts_spec.rb b/spec/system/composer/drafts_spec.rb
index 8cfe5c37215..81c040eca27 100644
--- a/spec/system/composer/drafts_spec.rb
+++ b/spec/system/composer/drafts_spec.rb
@@ -21,7 +21,7 @@ describe "Composer - Drafts", type: :system do
composer.close
expect(toasts).to have_success(I18n.t("js.composer.draft_saved"))
- expect(Draft.where(user: current_user).count).to eq(1)
+ try_until_success { expect(Draft.where(user: current_user).count).to eq(1) }
end
context "when only a title and category is specified" do
@@ -37,7 +37,8 @@ describe "Composer - Drafts", type: :system do
composer.close
expect(toasts).to have_success(I18n.t("js.composer.draft_saved"))
- expect(Draft.where(user: current_user).count).to eq(1)
+
+ try_until_success { expect(Draft.where(user: current_user).count).to eq(1) }
end
end
end
@@ -94,7 +95,7 @@ describe "Composer - Drafts", type: :system do
expect(discard_draft_modal).to be_closed
expect(composer).to be_closed
- expect(Draft.where(user: current_user).count).to eq(1)
+ try_until_success { expect(Draft.where(user: current_user).count).to eq(1) }
end
end
end