Skip to content

Commit

Permalink
Fix failed integration tests for valkyrie.
Browse files Browse the repository at this point in the history
  • Loading branch information
lsitu committed Aug 21, 2023
1 parent 8dfb21e commit 6f3099a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/controllers/hyrax/batch_edits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def valkyrie_update_document(obj)
form = form_class.new(obj, current_ability, nil)
return unless form.validate(params[form_class.model_class.model_name.param_key])

cleanu_form_fields form
cleanup_form_fields form

result = transactions['change_set.update_work']
.with_step_args('work_resource.save_acl' => { permissions_params: form.input_params["permissions"] })
Expand Down Expand Up @@ -157,7 +157,7 @@ def redirect_to_return_controller

# Clean up form fields
# @param form Hyrax::Froms::ResourceBatchEditForm
def cleanu_form_fields(form)
def cleanup_form_fields(form)
form.lease = nil if form.lease && form.lease.fields['lease_expiration_date'].nil?
form.embargo = nil if form.embargo && form.embargo.fields['embargo_release_date'].nil?
form.fields.keys.each do |k|
Expand Down
12 changes: 8 additions & 4 deletions spec/features/batch_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
let(:permission_template) { create(:permission_template, source_id: admin_set.id) }
let!(:workflow) { create(:workflow, allows_access_grant: true, active: true, permission_template_id: permission_template.id) }

let!(:work1) { create(:public_work, admin_set_id: admin_set.id, user: current_user, ordered_members: [file_set]) }
let!(:work2) { create(:public_work, admin_set_id: admin_set.id, user: current_user) }
let!(:work1) { create(:public_work, creator: ["Creator"], admin_set_id: admin_set.id, user: current_user, ordered_members: [file_set]) }
let!(:work2) { create(:public_work, creator: ["Creator"], admin_set_id: admin_set.id, user: current_user) }
let!(:file_set) { create(:file_set) }

before do
Expand Down Expand Up @@ -77,10 +77,12 @@
batch_edit_expand('permissions_visibility')
find('#generic_work_visibility_authenticated').click
find('#permissions_visibility_save').click

ajax_wait(30)
# 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', wait: 5)
find('.status', text: 'Changes Saved')
end

within "#form_permissions" do
Expand All @@ -91,10 +93,12 @@
find('#collapse_permissions_sharing table', text: 'View/Download')
find('#collapse_permissions_sharing table', text: 'donor')
find('#permissions_sharing_save').click

ajax_wait(30)
# 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', wait: 5)
find('.status', text: 'Changes Saved')
end

# Visit work permissions and verify
Expand Down
10 changes: 9 additions & 1 deletion spec/support/features/batch_edit_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ def fill_in_batch_edit_fields_and_verify!
fill_in "generic_work_#{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', wait: 5)
find('.status', text: 'Changes Saved')
end
end
end
Expand All @@ -27,3 +29,9 @@ 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

0 comments on commit 6f3099a

Please sign in to comment.