diff --git a/staff_features/resources/resource_generate_bulk_spreadsheet.feature b/staff_features/resources/resource_generate_bulk_spreadsheet.feature new file mode 100644 index 0000000..0655669 --- /dev/null +++ b/staff_features/resources/resource_generate_bulk_spreadsheet.feature @@ -0,0 +1,14 @@ +Feature: Resource generate bulk spreadsheet + Background: + Given an administrator user is logged in + And a Resource has been created + And the Resource is opened in edit mode + Scenario: Resource Bulk archival object updater page is displayed + When the user clicks on 'More' + And the user clicks on 'Generate Bulk Archival Object Spreadsheet' + Then the Generate Bulk Archival Object Spreadsheet page is displayed + Scenario: Resource Bulk Archival Object Spreadsheet is downloaded + Given the user is on the Generate Bulk Archival Object Spreadsheet page + When the user selects the Archival Object + And the user clicks on 'Download Spreadsheet' + Then the Bulk Update Resource spreadsheet is downloaded diff --git a/staff_features/resources/step_definitions/resource_generate_bulk_spreadsheet.rb b/staff_features/resources/step_definitions/resource_generate_bulk_spreadsheet.rb new file mode 100644 index 0000000..61c5fef --- /dev/null +++ b/staff_features/resources/step_definitions/resource_generate_bulk_spreadsheet.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +Given 'the user is on the Generate Bulk Archival Object Spreadsheet page' do + click_on 'More' + click_on 'Generate Bulk Archival Object Spreadsheet' +end + +Then 'the Generate Bulk Archival Object Spreadsheet page is displayed' do + expect(current_url).to include 'bulk_archival_object_updater/download?resource=' + expect(current_url).to include @resource_id +end + +Then 'the user selects the Archival Object' do + input_fields = all('#bulk_archival_object_updater_table input') + + expect(input_fields.length).to eq 2 + input_fields[1].click +end + +Then 'the Bulk Update Resource spreadsheet is downloaded' do + files = Dir.glob(File.join(Dir.tmpdir, '*.xlsx')) + + downloaded_file = nil + files.each do |file| + downloaded_file = file if file.include?("bulk_update.resource_#{@resource_id}") + end + + expect(downloaded_file).to_not eq nil +end