From 192d27f8b4edb196c94386c4818c18897b16bf82 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Tue, 29 Jan 2019 10:51:10 +0100 Subject: [PATCH 1/2] Tentative fix for flaky specs These specs are failing often on circleCI builds. The added expectation ensures that the click toggled the table header HTML. This has the double benefit to ensure HTML is consistent and leaves more time to successfully verify the flaky expectation: `expect(text_match_1).to appear_before text_match_2` --- backend/spec/features/admin/users_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/spec/features/admin/users_spec.rb b/backend/spec/features/admin/users_spec.rb index 9c58c9e67c3..f8b8604c5af 100644 --- a/backend/spec/features/admin/users_spec.rb +++ b/backend/spec/features/admin/users_spec.rb @@ -59,6 +59,7 @@ it "can sort asc" do within_table(table_id) do + expect(page).to have_selector '.sort_link.asc' expect(page).to have_text text_match_1 expect(page).to have_text text_match_2 expect(text_match_1).to appear_before text_match_2 @@ -70,6 +71,7 @@ # Ransack adds a ▲ to the sort link. With exact match Capybara is not able to find that link click_link sort_link, exact: false + expect(page).to have_selector '.sort_link.desc' expect(page).to have_text text_match_1 expect(page).to have_text text_match_2 expect(text_match_2).to appear_before text_match_1 From 25e680f3593b38b5d35a4c6bb2cf5e02b651fad2 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Thu, 7 Feb 2019 16:58:43 +0100 Subject: [PATCH 2/2] Split `within_table` block to achieve green spec The `within_table` must be splitted in order to get green specs. This is seems be caused by rack_test not being able to detect updates inside the selected HTML block after a page reload. Re-selecting the HTML block with a second `within_table` does the job. --- backend/spec/features/admin/users_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/spec/features/admin/users_spec.rb b/backend/spec/features/admin/users_spec.rb index f8b8604c5af..0fc32c5de04 100644 --- a/backend/spec/features/admin/users_spec.rb +++ b/backend/spec/features/admin/users_spec.rb @@ -70,7 +70,9 @@ within_table(table_id) do # Ransack adds a ▲ to the sort link. With exact match Capybara is not able to find that link click_link sort_link, exact: false + end + within_table(table_id) do expect(page).to have_selector '.sort_link.desc' expect(page).to have_text text_match_1 expect(page).to have_text text_match_2