Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1507 from psu-stewardship/i#1466.1
Browse files Browse the repository at this point in the history
Combining Form render and form use tests together to save testing time
  • Loading branch information
carolyncole authored Jan 14, 2019
2 parents 536c786 + cfc302c commit b6a1440
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions spec/features/batch_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@
it 'edits a field and displays the changes', js: true do
expect(page).to have_content 'Changes will be applied to the following'

# check the form has the correct values
@original_value = Capybara.ignore_hidden_elements
Capybara.ignore_hidden_elements = false
within('textarea#batch_edit_item_description') do
expect(page).to have_content('descriptiondescription')
end
expect(page).to have_css "input#batch_edit_item_contributor[value*='contributorcontributor']"
expect(page).to have_css "input#batch_edit_item_keyword[value*='tagtag']"
expect(page).to have_css "input#batch_edit_item_based_near[value*='based_nearbased_near']"
expect(page).to have_css "input#batch_edit_item_language[value*='languagelanguage']"
expect(find_field(id: 'batch_edit_item[creators][0][given_name]').value).to eq('First')
expect(find_field(id: 'batch_edit_item[creators][0][sur_name]').value).to eq('Creator')
expect(find_field(id: 'batch_edit_item[creators][0][display_name]').value).to eq('First Creator')
expect(find_field(id: 'batch_edit_item[creators][1][given_name]').value).to eq('Second')
expect(find_field(id: 'batch_edit_item[creators][1][sur_name]').value).to eq('Creator')
expect(find_field(id: 'batch_edit_item[creators][1][display_name]').value).to eq('Second Creator')
expect(page).to have_css "input#batch_edit_item_publisher[value*='publisherpublisher']"
expect(page).to have_css "input#batch_edit_item_subject[value*='subjectsubject']"
expect(page).to have_css "input#batch_edit_item_related_url[value*='http://example.org/TheRelatedURLLink/']"
expect(page).to have_no_checked_field('Private')
expect(page).to have_content(I18n.t('scholarsphere.batch_edit.permissions_warning'))
Capybara.ignore_hidden_elements = @original_value

# Update standard fields
batch_edit_fields.each do |field|
fill_in_batch_edit_field(field, with: "Updated batch #{field}")
Expand Down Expand Up @@ -81,30 +104,6 @@
expect(work2.creators.map(&:agent).map(&:sur_name)).to contain_exactly('Creator', 'Creator')
expect(work2.creators.map(&:agent).map(&:given_name)).to contain_exactly('Another', 'Second')
end

it "displays the field's existing value" do
@original_value = Capybara.ignore_hidden_elements
Capybara.ignore_hidden_elements = false
within('textarea#batch_edit_item_description') do
expect(page).to have_content('descriptiondescription')
end
expect(page).to have_css "input#batch_edit_item_contributor[value*='contributorcontributor']"
expect(page).to have_css "input#batch_edit_item_keyword[value*='tagtag']"
expect(page).to have_css "input#batch_edit_item_based_near[value*='based_nearbased_near']"
expect(page).to have_css "input#batch_edit_item_language[value*='languagelanguage']"
expect(find_field(id: 'batch_edit_item[creators][0][given_name]').value).to eq('First')
expect(find_field(id: 'batch_edit_item[creators][0][sur_name]').value).to eq('Creator')
expect(find_field(id: 'batch_edit_item[creators][0][display_name]').value).to eq('First Creator')
expect(find_field(id: 'batch_edit_item[creators][1][given_name]').value).to eq('Second')
expect(find_field(id: 'batch_edit_item[creators][1][sur_name]').value).to eq('Creator')
expect(find_field(id: 'batch_edit_item[creators][1][display_name]').value).to eq('Second Creator')
expect(page).to have_css "input#batch_edit_item_publisher[value*='publisherpublisher']"
expect(page).to have_css "input#batch_edit_item_subject[value*='subjectsubject']"
expect(page).to have_css "input#batch_edit_item_related_url[value*='http://example.org/TheRelatedURLLink/']"
expect(page).to have_no_checked_field('Private')
expect(page).to have_content(I18n.t('scholarsphere.batch_edit.permissions_warning'))
Capybara.ignore_hidden_elements = @original_value
end
end

context 'when selecting multiple works for deletion', js: true do
Expand Down

0 comments on commit b6a1440

Please sign in to comment.