From 9da582cb918ad7a81c7ed4fef53a9a38259e1af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 23 Oct 2024 17:20:14 +0200 Subject: [PATCH] Wait for suggestions in multitenancy and document tests In commit f638e5017 we introduced some methods to avoid race conditions in tests that created debates, proposals or investments. However, since we don't have a way to effectively make sure we use these methods in new code, we forgot to do so when adding tests in commits c483c6036 and 84b88c0ec. So we're using them now. There's a chance that this is what was causing multitenancy tests to fail sometimes; if we don't wait for the request to get the suggestions to finish, the application might still be dealing with this request when we make another request to a different subdomain, or when the test has finished and the tenant has already been deleted. On my machine, the test "Creating content in one tenant doesn't affect other tenants" failed about 5% of the time without these changes, and I haven't been able to reproduce this failure after applying them. Having said that, it's possible that this is a coincidence and that this test will fail for a different reason in the future (like `login_as` not working properly with subdomains). --- spec/system/documents_spec.rb | 2 +- spec/system/multitenancy_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/system/documents_spec.rb b/spec/system/documents_spec.rb index d9815be69..524a559a8 100644 --- a/spec/system/documents_spec.rb +++ b/spec/system/documents_spec.rb @@ -6,7 +6,7 @@ describe "Documents" do login_as(create(:user)) visit new_proposal_path - fill_in "Proposal title", with: "debate" + fill_in_new_proposal_title with: "debate" fill_in "Proposal summary", with: "In summary, what we want is..." fill_in "Full name of the person submitting the proposal", with: "Isabel Garcia" documentable_attach_new_file(file_fixture("logo_with_metadata.pdf")) diff --git a/spec/system/multitenancy_spec.rb b/spec/system/multitenancy_spec.rb index bc92dc60e..85bad8941 100644 --- a/spec/system/multitenancy_spec.rb +++ b/spec/system/multitenancy_spec.rb @@ -45,7 +45,7 @@ describe "Multitenancy", :seed_tenants do with_subdomain("mars") do visit new_proposal_path - fill_in "Proposal title", with: "Use the unaccent extension in Mars" + fill_in_new_proposal_title with: "Use the unaccent extension in Mars" fill_in "Proposal summary", with: "tsvector for MarĂ­a the Martian" check "I agree to the Privacy Policy and the Terms and conditions of use" @@ -73,7 +73,7 @@ describe "Multitenancy", :seed_tenants do with_subdomain("mars") do visit new_debate_path - fill_in "Debate title", with: "Found any water here?" + fill_in_new_debate_title with: "Found any water here?" fill_in_ckeditor "Initial debate text", with: "Found any water here?" check "I agree to the Privacy Policy and the Terms and conditions of use"