Skip to content

Commit

Permalink
Fix test: turn some no-ops into real expectations
Browse files Browse the repository at this point in the history
That's why tests should be red before turning them green.
  • Loading branch information
cbliard committed Aug 22, 2024
1 parent c063cbc commit 217be2e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/support/edit_fields/progress_edit_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def display_selector
# If they are the same, it means the modal field is in focus.
# @return [Boolean] true if the modal field is in focus, false otherwise.
def expect_modal_field_in_focus
expect(focused?).to be(true)
end

def focused?
input_element == page.evaluate_script("document.activeElement")
end

Expand All @@ -140,6 +144,10 @@ def expect_modal_field_in_focus
# If they are the same, it means the cursor is at the end of the input.
# @return [Boolean] true if the cursor is at the end of the input, false otherwise.
def expect_cursor_at_end_of_input
expect(cursor_at_end_of_input?).to be(true)
end

def cursor_at_end_of_input?
input_element.evaluate_script("this.selectionStart == this.value.length;")
end

Expand Down

0 comments on commit 217be2e

Please sign in to comment.