From c5ededb7914a09cd7991281a6569c022d0ac530b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 20 Jul 2022 16:17:28 +0200 Subject: [PATCH] Unset the assignee field using the x marker We no longer have an empty option in the user autocompleter, but a clear button --- spec/features/work_packages/edit_work_package_spec.rb | 4 +++- .../autocompleter/ng_select_autocomplete_helpers.rb | 6 ++++++ spec/support/edit_fields/edit_field.rb | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/spec/features/work_packages/edit_work_package_spec.rb b/spec/features/work_packages/edit_work_package_spec.rb index a896c2aab9..4b58bf9e74 100644 --- a/spec/features/work_packages/edit_work_package_spec.rb +++ b/spec/features/work_packages/edit_work_package_spec.rb @@ -168,7 +168,9 @@ describe 'edit work package', wp_page.expect_attributes assignee: manager.name wp_page.expect_activity_message("Assignee set to #{manager.name}") - wp_page.update_attributes assignee: '-' + field = wp_page.edit_field :assignee + field.unset_value + wp_page.expect_attributes assignee: '-' wp_page.visit! diff --git a/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb b/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb index 7b44d522d7..2ddccdaf09 100644 --- a/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb +++ b/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb @@ -56,6 +56,12 @@ module Components::Autocompleter from_element.find('.ng-input input') end + ## + # clear the ng select field + def ng_select_clear(from_element) + from_element.find('.ng-clear-wrapper', visible: :all).click + end + def select_autocomplete(element, query:, select_text: nil, results_selector: nil, wait_dropdown_open: true) target_dropdown = search_autocomplete(element, query:, diff --git a/spec/support/edit_fields/edit_field.rb b/spec/support/edit_fields/edit_field.rb index fd85c68433..af7d981d5e 100644 --- a/spec/support/edit_fields/edit_field.rb +++ b/spec/support/edit_fields/edit_field.rb @@ -164,14 +164,15 @@ class EditField ## # Set or select the given value. # For fields of type select, will check for an option with that value. - def unset_value(content, multi = false) + def unset_value(content = nil, multi = false) + activate! scroll_to_element(input_element) if field_type.end_with?('-autocompleter') if multi page.find('.ng-value-label', visible: :all, text: content).sibling('.ng-value-icon').click else - page.find('.ng-dropdown-panel .ng-option', visible: :all, text: '-').click + ng_select_clear(field_container) end else input_element.set('')