From 560b1ca93195ad8ca9241bb2971a1c739fbf326d Mon Sep 17 00:00:00 2001 From: Patrick Bolger Date: Sun, 25 Jun 2017 08:47:38 -0400 Subject: [PATCH] fixed remaining cuke tests --- Gemfile | 1 + Gemfile.lock | 6 ++++++ .../_reason_waiting.html.haml | 3 ++- .../admin-sets-custom-waiting-reason.feature | 14 +++++++------- features/step_definitions/basic_steps.rb | 4 ++++ 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index d53b89704..8383decb0 100644 --- a/Gemfile +++ b/Gemfile @@ -99,4 +99,5 @@ end group :test do gem 'poltergeist' + gem 'selenium-webdriver' end diff --git a/Gemfile.lock b/Gemfile.lock index 88d8765c3..32e50e931 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,6 +108,8 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) + childprocess (0.7.0) + ffi (~> 1.0, >= 1.0.11) chronic (0.10.2) city-state (0.0.13) rubyzip (~> 1.1) @@ -364,6 +366,9 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) + selenium-webdriver (3.4.3) + childprocess (~> 0.5) + rubyzip (~> 1.0) sexp_processor (4.8.0) shoulda-matchers (3.1.1) activesupport (>= 4.0.0) @@ -485,6 +490,7 @@ DEPENDENCIES rubyzip (>= 1.2.1) sanitize sass-rails (~> 5.0) + selenium-webdriver shoulda-matchers smarter_csv spring diff --git a/app/views/membership_applications/_reason_waiting.html.haml b/app/views/membership_applications/_reason_waiting.html.haml index d992bf583..2c14ee138 100644 --- a/app/views/membership_applications/_reason_waiting.html.haml +++ b/app/views/membership_applications/_reason_waiting.html.haml @@ -8,9 +8,10 @@ = label_tag :member_app_waiting_reasons, t('membership_applications.need_info.reason_title') - collection = AdminOnly::MemberAppWaitingReason.all.to_a - collection << AdminOnly::MemberAppWaitingReason.new(id: -1, "name_#{I18n.locale.to_s}": "#{@other_waiting_reason_text}") + - selected = ! @membership_application.custom_reason_text.blank? ? -1 : @membership_application.member_app_waiting_reasons_id = select_tag(:member_app_waiting_reasons, options_from_collection_for_select(collection, :id, reason_name_method, - @membership_application.member_app_waiting_reasons_id), + selected), { include_blank: t('membership_applications.need_info.select_a_reason'), class: 'reason-waiting-list' }) diff --git a/features/membership-application-status/admin-sets-custom-waiting-reason.feature b/features/membership-application-status/admin-sets-custom-waiting-reason.feature index 1b81e5231..a700fec9b 100644 --- a/features/membership-application-status/admin-sets-custom-waiting-reason.feature +++ b/features/membership-application-status/admin-sets-custom-waiting-reason.feature @@ -42,30 +42,29 @@ Feature: Admin sets or enters the reason they are waiting for info from a user And I am logged in as "admin@shf.com" - @javascript + @selenium Scenario: Admin selects 'need more documentation' as the reason SHF is waiting_for_applicant Given I am on "AnnaWaiting" application page When I set "member_app_waiting_reasons" to "need doc" And I am on the list applications page And I am on "AnnaWaiting" application page Then "member_app_waiting_reasons" should have "need doc" selected - And I should not see t("admin_only.member_app_waiting_reasons.other_custom_reason") - @javascript + @selenium Scenario: Admin selects 'waiting for payment' as the reason SHF is waiting_for_applicant Given I am on "AnnaWaiting" application page When I set "member_app_waiting_reasons" to "waiting for payment" And I am on the list applications page And I am on "AnnaWaiting" application page And "member_app_waiting_reasons" should have "waiting for payment" selected - And I should not see t("admin_only.member_app_waiting_reasons.other_custom_reason") - @javascript + @selenium Scenario: Admin selects 'other' and enters text as the reason SHF is waiting_for_applicant Given I am on "AnnaWaiting" application page When I set "member_app_waiting_reasons" to t("admin_only.member_app_waiting_reasons.other_custom_reason") And I fill in "custom_reason_text" with "This is my reason" + And I press enter in "custom_reason_text" And I am on the list applications page And I am on "AnnaWaiting" application page #And item t("admin_only.member_app_waiting_reasons.other_custom_reason") should be visible @@ -74,16 +73,16 @@ Feature: Admin sets or enters the reason they are waiting for info from a user And "member_app_waiting_reasons" should have t("admin_only.member_app_waiting_reasons.other_custom_reason") selected - @javascript + @selenium Scenario: Admin selects 'other' and fills in custom text but then changes reason to something else Given I am on "AnnaWaiting" application page When I set "member_app_waiting_reasons" to t("admin_only.member_app_waiting_reasons.other_custom_reason") And I fill in "custom_reason_text" with "This is my reason" + And I press enter in "custom_reason_text" And I set "member_app_waiting_reasons" to "waiting for payment" And I am on the list applications page And I am on "AnnaWaiting" application page And "member_app_waiting_reasons" should have "waiting for payment" selected - And I should not see t("admin_only.member_app_waiting_reasons.other_custom_reason") @javascript @@ -91,6 +90,7 @@ Feature: Admin sets or enters the reason they are waiting for info from a user Given I am on "AnnaWaiting" application page When I set "member_app_waiting_reasons" to t("admin_only.member_app_waiting_reasons.other_custom_reason") And I fill in "custom_reason_text" with "This is my reason" + And I press enter in "custom_reason_text" And I set "member_app_waiting_reasons" to "need doc" # change back so the custom reason field shows. it should be blank And I set "member_app_waiting_reasons" to t("admin_only.member_app_waiting_reasons.other_custom_reason") diff --git a/features/step_definitions/basic_steps.rb b/features/step_definitions/basic_steps.rb index 3eb13d1a7..30ddf127f 100644 --- a/features/step_definitions/basic_steps.rb +++ b/features/step_definitions/basic_steps.rb @@ -28,6 +28,10 @@ fill_in field, with: value end +And(/^I press enter in "([^"]*)"$/) do |field| + find_field(field).send_keys :enter +end + And(/^I fill in t\("([^"]*)"\) with "([^"]*)"$/) do |field, value| fill_in i18n_content(field), with: value end