diff --git a/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.html b/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.html index 49c60a400101..8dc10c83c498 100644 --- a/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.html +++ b/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.html @@ -10,7 +10,7 @@ (click)="onInputClick($event)" (focus)="showProgressModal()" [value]="asHours" - [disabled]="inFlight" + [disabled]="opened || inFlight" [id]="handler.htmlId" /> diff --git a/spec/features/work_packages/progress_modal_spec.rb b/spec/features/work_packages/progress_modal_spec.rb index 7bd4d425be43..c323c8568388 100644 --- a/spec/features/work_packages/progress_modal_spec.rb +++ b/spec/features/work_packages/progress_modal_spec.rb @@ -122,6 +122,34 @@ def update_work_package_with(work_package, attributes) remaining_work_edit_field.expect_modal_field_value(work_package.remaining_hours) percent_complete_edit_field.expect_modal_field_value(work_package.done_ratio) end + + it "disables the field that triggered the modal" do + work_package_table.visit_query(progress_query) + work_package_table.expect_work_package_listed(work_package) + + work_edit_field = ProgressEditField.new(work_package_row, :estimatedTime) + + work_edit_field.activate! + + work_edit_field.expect_trigger_field_disabled + end + + it "allows clicking on a field other than the one that triggered the modal " \ + "and opens the modal with said field selected" do + work_package_table.visit_query(progress_query) + work_package_table.expect_work_package_listed(work_package) + + work_edit_field = ProgressEditField.new(work_package_row, :estimatedTime) + remaining_work_edit_field = ProgressEditField.new(work_package_row, :remainingTime) + + remaining_work_edit_field.activate! + remaining_work_edit_field.expect_modal_field_in_focus + remaining_work_edit_field.expect_trigger_field_disabled + + work_edit_field.reactivate! + work_edit_field.expect_modal_field_in_focus + work_edit_field.expect_trigger_field_disabled + end end describe "% Complete field" do diff --git a/spec/support/edit_fields/progress_edit_field.rb b/spec/support/edit_fields/progress_edit_field.rb index b311bfad27b3..171d0c4dbb04 100644 --- a/spec/support/edit_fields/progress_edit_field.rb +++ b/spec/support/edit_fields/progress_edit_field.rb @@ -45,12 +45,27 @@ def initialize(context, super @field_name = "work_package_#{FIELD_NAME_MAP.fetch(@property_name)}" + @trigger_selector = "input[id$=inline-edit--field-#{@property_name}]" end def update(value, save: true, expect_failure: false) super end + def reactivate!(expect_open: true) + retry_block(args: { tries: 2 }) do + SeleniumHubWaiter.wait unless using_cuprite? + scroll_to_and_click(display_element) + SeleniumHubWaiter.wait unless using_cuprite? + + if expect_open && !active? + raise "Expected field for attribute '#{property_name}' to be active." + end + + self + end + end + def active? page.has_selector?(MODAL_SELECTOR, wait: 1) end @@ -63,6 +78,12 @@ def input_element modal_element.find_field(field_name) end + def trigger_element + within @context do + page.find(@trigger_selector) + end + end + def save! submit_by_enter end @@ -106,6 +127,10 @@ def expect_cursor_at_end_of_input input_element.evaluate_script("this.selectionStart == this.value.length;") end + def expect_trigger_field_disabled + expect(trigger_element).to be_disabled + end + def expect_modal_field_disabled expect(page).to have_field(@field_name, disabled: true) end