From f92bc9693f6dbdc5147531a4a492142dbd7abd56 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Wed, 2 Oct 2024 12:22:21 +0100 Subject: [PATCH] fixes flaky JS test --- .../early_career_payments_claim_spec.rb | 2 +- spec/support/feature_helpers.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/features/early_career_payments/early_career_payments_claim_spec.rb b/spec/features/early_career_payments/early_career_payments_claim_spec.rb index 98e559659c..7a55f6626c 100644 --- a/spec/features/early_career_payments/early_career_payments_claim_spec.rb +++ b/spec/features/early_career_payments/early_career_payments_claim_spec.rb @@ -997,7 +997,7 @@ skip_tid # - Which school do you teach at - choose_school school + choose_school_js school # - NQT in Academic Year after ITT choose "Yes" diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 212fc67389..0c8b88cad6 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -40,6 +40,22 @@ def choose_school(school) click_button "Continue" end + def choose_school_js(school) + expect(page).to have_text(/Which (additional )?school/) # there can be variations of the full text depending on which journey/page + + fill_in :school_search, with: school.name.sub("The ", "").split(" ").first + + within("#school_search__listbox") do + sleep(1) # seems to aid in success, as if click happens before event is bound + find("li", text: school.name).click + end + + click_button "Continue" + + choose school.name + click_button "Continue" + end + def choose_still_teaching(teaching_at = "Yes, at Penistone Grammar School") choose teaching_at click_on "Continue"