From d5a335a3628d83dbefa2459e595f3699a0dfc08a Mon Sep 17 00:00:00 2001 From: Derek Kniffin Date: Fri, 20 Sep 2024 13:41:24 -0400 Subject: [PATCH 1/2] Add failing test case for nested_select --- spec/features/inputs/nested_select_input_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/features/inputs/nested_select_input_spec.rb b/spec/features/inputs/nested_select_input_spec.rb index 1f18f5db..592b056d 100644 --- a/spec/features/inputs/nested_select_input_spec.rb +++ b/spec/features/inputs/nested_select_input_spec.rb @@ -67,7 +67,11 @@ it "shows filled select controls based on defined city_id", js: true do on_input_ctx("invoice_country") { expect_slimselect_selection("Chile") } - on_input_ctx("invoice_region") { expect_slimselect_selection("Metropolitana") } + on_input_ctx("invoice_region") do + expect_slimselect_selection("Metropolitana") + expect_slimselect_selection("Antofagasta") + expect_slimselect_selection("Cuyo") + end on_input_ctx("invoice_city") { expect_slimselect_selection("Santiago") } end From acf2c0c8c29ac2e02d9ea18a52efeaedf45c45bb Mon Sep 17 00:00:00 2001 From: Derek Kniffin Date: Fri, 20 Sep 2024 14:06:03 -0400 Subject: [PATCH 2/2] Be more specific with test case --- spec/features/inputs/nested_select_input_spec.rb | 4 ++-- spec/support/capybara_helpers.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/features/inputs/nested_select_input_spec.rb b/spec/features/inputs/nested_select_input_spec.rb index 592b056d..6259fa8e 100644 --- a/spec/features/inputs/nested_select_input_spec.rb +++ b/spec/features/inputs/nested_select_input_spec.rb @@ -69,8 +69,8 @@ on_input_ctx("invoice_country") { expect_slimselect_selection("Chile") } on_input_ctx("invoice_region") do expect_slimselect_selection("Metropolitana") - expect_slimselect_selection("Antofagasta") - expect_slimselect_selection("Cuyo") + expect_slimselect_option("Antofagasta") + expect_slimselect_option("Cuyo") end on_input_ctx("invoice_city") { expect_slimselect_selection("Santiago") } end diff --git a/spec/support/capybara_helpers.rb b/spec/support/capybara_helpers.rb index 7503e2f4..fdbe98b6 100644 --- a/spec/support/capybara_helpers.rb +++ b/spec/support/capybara_helpers.rb @@ -93,6 +93,10 @@ def expect_slimselect_empty_selection expect(page).to have_css(".ss-main", text: /Select Value/) end + def expect_slimselect_option(text) + expect(page).to have_css(".ss-option", text: /#{text}/) + end + def expect_slimselect_result_text_to_eq(result_number, text) expect(page).to have_css( "div.ss-option:nth-child(#{result_number})", text: /#{text}/