Sha256: 857ec6a6621b68d59e2c6f59af429799687758ed94092d5bc7544889cbd0a8c7

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true
def batch_edit_fields
  # skipping based_near because it's a select2 field, which is hard to test via capybara
  [
    "creator", "contributor", "description", "keyword", "publisher", "date_created",
    "subject", "language", "identifier", "related_url"
  ]
end

def fill_in_batch_edit_fields_and_verify!
  batch_edit_fields.each do |field_id|
    within "#form_#{field_id}" do
      batch_edit_expand(field_id)
      page.find("##{expected_element_text}_#{field_id}") # Ensuring that the element is on the page before we fill it
      fill_in "#{expected_element_text}_#{field_id}", with: "NEW #{field_id}"

      find("##{field_id}_save").click

      ajax_wait(15)
      # This was `expect(page).to have_content 'Changes Saved'`, however in debugging,
      # the `have_content` check was ignoring the `within` scoping and finding
      # "Changes Saved" for other field areas
      find('.status', text: 'Changes Saved')
    end
  end
end

def batch_edit_expand(field)
  find("#expand_link_#{field}").click
  yield if block_given?
end

def ajax_wait(s)
  Timeout.timeout(s) do
    loop until page.evaluate_script("jQuery.active").zero?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyrax-5.0.0 spec/support/features/batch_edit_actions.rb
hyrax-5.0.0.rc3 spec/support/features/batch_edit_actions.rb