Skip to content

Commit

Permalink
Fix failing tests with radio and checkbox inputs
Browse files Browse the repository at this point in the history
Version 5.1.0 of govuk-frontend contains refactoring to the CSS for radio buttons and checkboxes, this change resulted in tests throwing an `ElementClickInterceptedError`.

This was logged as a GitHub issue in govuk-frontend
 - alphagov/govuk-frontend#4762

This issue was fixed in version 5.2.0 - alphagov/govuk-frontend#4768
  • Loading branch information
MartinJJones authored and andysellick committed Jul 15, 2024
1 parent 943da97 commit baf6c55
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
26 changes: 13 additions & 13 deletions test/integration/engine/changing_answer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ class ChangingAnswerTest < EngineIntegrationTest
click_on "Continue"

within("#current-question") { assert_page_has_content "What...is your quest?" }
choose("To seek the Holy Grail", visible: false)
choose("To seek the Holy Grail", visible: false, allow_label_click: true)
click_on "Continue"

within("#current-question") { assert_page_has_content "Do you want to select any of these?" }
choose("Yes", visible: false)
choose("Yes", visible: false, allow_label_click: true)
click_on "Continue"

within("#current-question") { assert_page_has_content "What...is your favorite colour?" }
choose("Blue", visible: false)
choose("Blue", visible: false, allow_label_click: true)
click_on "Continue"

within("#result-info") { assert_page_has_content "Right, off you go." }
Expand All @@ -123,15 +123,15 @@ class ChangingAnswerTest < EngineIntegrationTest
assert_current_url "/bridge-of-death/y/Bors"

within("#current-question") { assert_page_has_content "What...is your quest?" }
choose("To seek the Holy Grail", visible: false)
choose("To seek the Holy Grail", visible: false, allow_label_click: true)
click_on "Continue"

within("#current-question") { assert_page_has_content "Do you want to select any of these?" }
choose("Yes", visible: false)
choose("Yes", visible: false, allow_label_click: true)
click_on "Continue"

within("#current-question") { assert_page_has_content "What...is your favorite colour?" }
choose("Blue", visible: false)
choose("Blue", visible: false, allow_label_click: true)
click_on "Continue"

within("#result-info") { assert_page_has_content "Right, off you go." }
Expand All @@ -143,15 +143,15 @@ class ChangingAnswerTest < EngineIntegrationTest
assert page.has_unchecked_field?("I dunno", visible: false)
end

choose("To rescue the princess", visible: false)
choose("To rescue the princess", visible: false, allow_label_click: true)
click_on "Continue"

assert_current_url "/bridge-of-death/y/Bors/to_rescue_the_princess"

choose("Yes", visible: false)
choose("Yes", visible: false, allow_label_click: true)
click_on "Continue"

choose("Blue", visible: false)
choose("Blue", visible: false, allow_label_click: true)
click_on "Continue"

within("#result-info") { assert_page_has_content "Right, off you go." }
Expand All @@ -163,7 +163,7 @@ class ChangingAnswerTest < EngineIntegrationTest
assert page.has_unchecked_field?("Red", visible: false)
end

choose("Red", visible: false)
choose("Red", visible: false, allow_label_click: true)
click_on "Continue"

assert_current_url "/bridge-of-death/y/Bors/to_rescue_the_princess/yes/red"
Expand All @@ -174,8 +174,8 @@ class ChangingAnswerTest < EngineIntegrationTest

visit "/checkbox-sample/y"

check("Peppers", visible: false)
check("Pepperoni", visible: false)
check("Peppers", visible: false, allow_label_click: true)
check("Pepperoni", visible: false, allow_label_click: true)
click_on "Continue"

assert_current_url "/checkbox-sample/y/pepperoni,peppers"
Expand All @@ -189,7 +189,7 @@ class ChangingAnswerTest < EngineIntegrationTest
assert page.has_checked_field?("Pepperoni", visible: false)
end

check("Ham", visible: false)
check("Ham", visible: false, allow_label_click: true)
click_on "Continue"

assert_current_url "/checkbox-sample/y/ham,pepperoni,peppers"
Expand Down
12 changes: 6 additions & 6 deletions test/integration/engine/checkbox_questions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class CheckboxQuestionsTest < EngineIntegrationTest
assert_equal ["Ham", "Peppers", "Ice Cream!!!", "Pepperoni"], options
end

check("Ham", visible: false)
check("Pepperoni", visible: false)
check("Ham", visible: false, allow_label_click: true)
check("Pepperoni", visible: false, allow_label_click: true)
click_on "Continue"

assert_current_url "/checkbox-sample/y/ham,pepperoni"
Expand Down Expand Up @@ -61,7 +61,7 @@ class CheckboxQuestionsTest < EngineIntegrationTest

assert_page_has_content "Are you sure you don't want any toppings?"

check("Definitely no toppings", visible: false)
check("Definitely no toppings", visible: false, allow_label_click: true)

click_on "Continue"

Expand Down Expand Up @@ -95,11 +95,11 @@ class CheckboxQuestionsTest < EngineIntegrationTest
should "toggle options when none option is present" do
visit "/checkbox-sample/y/none"

check("Definitely no toppings", visible: false)
check("Hmm I'm not sure, ask me again please", visible: false)
check("Definitely no toppings", visible: false, allow_label_click: true)
check("Hmm I'm not sure, ask me again please", visible: false, allow_label_click: true)
assert_not page.has_checked_field?("Definitely no toppings")

check("Definitely no toppings", visible: false)
check("Definitely no toppings", visible: false, allow_label_click: true)
assert_not page.has_checked_field?("Hmm I'm not sure, ask me again please")
click_on "Continue"

Expand Down
6 changes: 3 additions & 3 deletions test/integration/engine/radio_and_value_questions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class RadioAndValueQuestionsTest < EngineIntegrationTest
assert_equal ["To seek the Holy Grail", "To rescue the princess", "I dunno"], options
end

choose("To seek the Holy Grail", visible: false)
choose("To seek the Holy Grail", visible: false, allow_label_click: true)
click_on "Continue"

assert_current_url "/bridge-of-death/y/Lancelot/to_seek_the_holy_grail"
Expand Down Expand Up @@ -108,7 +108,7 @@ class RadioAndValueQuestionsTest < EngineIntegrationTest
assert_equal %w[Yes No], options
end

choose("Yes", visible: false)
choose("Yes", visible: false, allow_label_click: true)
click_on "Continue"

within "#current-question" do
Expand All @@ -124,7 +124,7 @@ class RadioAndValueQuestionsTest < EngineIntegrationTest
assert_equal ["Blue", "Blue... NO! YELLOOOOOOOOOOOOOOOOWWW!!!!", "Red"], options
end

choose("Blue", visible: false)
choose("Blue", visible: false, allow_label_click: true)
click_on "Continue"

assert_current_url "/bridge-of-death/y/Lancelot/to_seek_the_holy_grail/yes/blue"
Expand Down

0 comments on commit baf6c55

Please sign in to comment.