From 0cca8c2cc1c0404ed95c71567d0cc8a75d961354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 6 Jun 2019 13:58:46 +0200 Subject: [PATCH] Check the comment is present after commenting We've got a bug which causes the admin description not to appear immediately after commenting, due to the `admin_layout` variable being false when we add a comment using an AJAX request. So the test reloaded the page to check the admin description was there. However, sometimes reloading the page is faster than the AJAX request, and so the comment is not there yet. By checking the results of the AJAX request before reloading the page, the test passes. A proper solution would be to display the admin description or name right after the comment is added. --- spec/features/comments/budget_investments_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/features/comments/budget_investments_spec.rb b/spec/features/comments/budget_investments_spec.rb index 5aeb77f7f..b171d5b88 100644 --- a/spec/features/comments/budget_investments_spec.rb +++ b/spec/features/comments/budget_investments_spec.rb @@ -412,6 +412,10 @@ describe "Commenting Budget::Investments" do check "comment-as-administrator-budget_investment_#{investment.id}" click_button "Publish comment" + within "#comments" do + expect(page).to have_content "I am your Admin!" + end + visit admin_budget_budget_investment_path(investment.budget, investment) within "#comments" do