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 15, 2023
1 parent 4254426 commit 44ba338
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
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(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

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(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

# 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 44ba338

Please sign in to comment.