Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent export #93

Merged
merged 2 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions staff_features/agents/agent_export.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Feature: Agent Export
Background:
Given an administrator user is logged in
And an Agent has been created
And the Agent is opened in edit mode
Scenario: Agent Download EAC-CPF
When the user clicks on 'Download EAC-CPF'
Then an EAC-CPF XML file is downloaded
Scenario: Agent Download MARCXML AUTHORITY
When the user clicks on 'Download MARCXML Authority'
Then a MARC XML file is downloaded
38 changes: 38 additions & 0 deletions staff_features/agents/step_definitions/agent_export.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

Then 'an EAC-CPF XML file is downloaded' do
files = Dir.glob(File.join(Dir.tmpdir, '*.xml'))

first_part_of_uuid = @uuid.split('-').pop

downloaded_file = nil
files.each do |file|
downloaded_file = file if file.include?('__eac.xml') &&
file.include?(first_part_of_uuid)
end

expect(downloaded_file).to_not eq nil

load_file = File.read(downloaded_file)
expect(load_file).to include '<eac-cpf'
expect(load_file).to include '<entityType>person</entityType>'
expect(load_file).to include "<part localType=\"surname\">Agent #{@uuid}</part>"
end

Then 'a MARC XML file is downloaded' do
files = Dir.glob(File.join(Dir.tmpdir, '*.xml'))

first_part_of_uuid = @uuid.split('-').pop

downloaded_file = nil
files.each do |file|
downloaded_file = file if file.include?('__marc.xml') &&
file.include?(first_part_of_uuid)
end

expect(downloaded_file).to_not eq nil

load_file = File.read(downloaded_file)
expect(load_file).to include '<collection'
expect(load_file).to include "<subfield code=\"a\">Agent #{@uuid}</subfield>"
end
Loading