Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit bd83a84

Browse files
authored
Accession spawn Accession (#17)
1 parent 23c17e6 commit bd83a84

File tree

5 files changed

+77
-3
lines changed

5 files changed

+77
-3
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Feature: Accession Accession Spawn
2+
Background:
3+
Given an administrator user is logged in
4+
And an Accession has been created
5+
And the Accession is opened in edit mode
6+
Scenario: Accession Spawn Accession page is opened
7+
When the user clicks on 'Spawn'
8+
And the user clicks on 'Accession' in the spawn dropdown menu
9+
Then the New Accession page is displayed
10+
And the Accession has been spawned from Accession info message is displayed
11+
Scenario: Successfully spawn a new accession from an existing accession - not linked
12+
Given the user is on the New Accession page spawned from the original Accession
13+
When the user fills in 'Identifier'
14+
And the user clicks on 'Save'
15+
Then the Accession is created
16+
And the new Accession is not linked to the original Accession
17+
Scenario: Successfully spawn a new accession from an existing accession - linked
18+
Given the user is on the New Accession page spawned from the original Accession
19+
When the user fills in 'Identifier'
20+
And the user links to the original Accession in the 'Related Accessions' form
21+
And the user clicks on 'Save'
22+
Then the Accession is created
23+
And the new Accession is linked to the original Accession
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
# frozen_string_literal: true
22

3-
Given('the user is on the New Accession page') do
3+
Given 'the user is on the New Accession page' do
44
click_on 'Create'
55
click_on 'Accession'
66
end
77

8-
Then('the Accession is created') do
8+
Then 'the Accession is created' do
99
uri = find('#accession_form')[:'data-update-monitor-record-uri']
1010

1111
@accession_id = uri.split('/').pop
1212

1313
visit "#{STAFF_URL}/accessions/#{@accession_id}/edit"
1414

15-
expect(find('h2').text).to eq "#{@uuid} Accession"
1615
expect(find('#accession_id_0_').value).to eq @uuid
1716
end
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
Then 'the New Accession page is displayed' do
4+
expect(find('h2').text).to eq 'New Accession Accession'
5+
end
6+
7+
Given 'the user is on the New Accession page spawned from the original Accession' do
8+
visit "#{STAFF_URL}/accessions/new?accession_id=#{@accession_id}"
9+
end
10+
11+
Then 'the Accession has been spawned from Accession info message is displayed' do
12+
message = "This Accession has been spawned from Accession Accession Title #{@uuid}. This record is unsaved. You must click Save for the record to be created in the system"
13+
14+
expect(page).to have_text message
15+
end
16+
17+
Then 'the new Accession is not linked to the original Accession' do
18+
expect(page).not_to have_selector('#accession_related_accessions__0_')
19+
end
20+
21+
When 'the user links to the original Accession in the {string} form' do |form_title|
22+
section_title = find('h3', text: form_title)
23+
section = section_title.ancestor('section')
24+
expect(section[:id]).to_not eq nil
25+
26+
within section do
27+
click_on 'Add Related Accession'
28+
find('.related-accession-type').select '"Part of" Relationship'
29+
fill_in 'token-input-accession_related_accessions__0__ref_', with: @uuid
30+
dropdown_items = all('li.token-input-dropdown-item2')
31+
dropdown_items.first.click
32+
end
33+
end
34+
35+
Then 'the new Accession is linked to the original Accession' do
36+
section = find('#accession_related_accessions_')
37+
expect(section).to have_text @uuid
38+
end

staff_features/shared/step_definitions.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
end
2828
end
2929

30+
When 'the user clicks on {string} in the spawn dropdown menu' do |string|
31+
within '#spawn-dropdown' do
32+
click_on_string string
33+
end
34+
end
35+
3036
When 'the user clicks on {string} in the confirm popup' do |string|
3137
within '#confirmChangesModal' do
3238
click_on_string string
@@ -95,6 +101,14 @@
95101
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*deleted$/i)
96102
end
97103

104+
Then 'only the following info message is displayed' do |messages|
105+
expect(messages.raw.length).to eq 1
106+
107+
messages.raw.each do |message|
108+
expect(page).to have_text message[0]
109+
end
110+
end
111+
98112
Then 'the following error messages are displayed' do |messages|
99113
messages.raw.each do |message|
100114
expect(page).to have_text message[0]

0 commit comments

Comments
 (0)