Skip to content

Commit

Permalink
Disable editing values on the progress display fields
Browse files Browse the repository at this point in the history
* Ensures interactions are solely via the modal.
  • Loading branch information
aaron-contreras committed Apr 5, 2024
1 parent 85d9fd6 commit 29c84b8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(click)="onInputClick($event)"
(focus)="showProgressModal()"
[value]="asHours"
[disabled]="inFlight"
[disabled]="opened || inFlight"
[id]="handler.htmlId"
/>

Expand Down
28 changes: 28 additions & 0 deletions spec/features/work_packages/progress_modal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions spec/support/edit_fields/progress_edit_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 29c84b8

Please sign in to comment.