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

Commit 0750a44

Browse files
kdimopulublacksmith-welder
authored andcommitted
Accession spawn step definitions
1 parent ce78a04 commit 0750a44

File tree

5 files changed

+113
-43
lines changed

5 files changed

+113
-43
lines changed
Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
Feature: Spawning a new accession record from an existing accession record
1+
Feature: Accession Accession Spawn
22
Background:
33
Given an administrator user is logged in
4-
And an Accession has been created
5-
And the Accession is opened in edit mode
4+
And an Accession has been created
5+
And the Accession is opened in edit mode
66
Scenario: Accession Spawn Accession page is opened
7-
When the user clicks on 'Spawn'
8-
And the user clicks on 'Accession' in the dropdown menu
9-
Then the New Accession page is opened
10-
And the 'This Accession has been spawned from Accession . This record is unsaved. You must click Save for the record to be created in the system.' message is displayed
11-
Scenario: Successfully spawn a new accession record from an existing accession record - non linked
12-
Given the user is on the New Accession page spawned from the original accession
13-
When the user fills in 'Identifier' with a unique identifier
14-
And the user does not add any links to the original accession in the 'Related Accessions' form
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 only the following info message is displayed
11+
|This Accession has been spawned from Accession . This record is unsaved. You must click Save for the record to be created in the system.|
12+
Scenario: Successfully spawn a new accession from an existing accession - not linked
13+
Given the user is on the New Accession page spawned from the original Accession
14+
When the user fills in 'Identifier'
1515
And the user clicks on 'Save'
1616
Then the Accession is created
17-
And the new accession record is not linked to the original accession
18-
Scenario: Successfully spawn a new accession record from an existing accession record - linked
19-
Given the user is on the New Accession page spawned from the original accession
20-
When the user fills in 'Identifier' with a unique identifier
21-
And the user adds links to the original accession in the 'Related Accessions' form
17+
And the new Accession is not linked to the original Accession
18+
Scenario: Successfully spawn a new accession from an existing accession - linked
19+
Given the user is on the New Accession page spawned from the original Accession
20+
When the user fills in 'Identifier'
21+
And the user links to the original Accession in the 'Related Accessions' form
2222
And the user clicks on 'Save'
2323
Then the Accession is created
24-
And the new accession record is linked to the original accession in the 'Related Accessions' field
25-
Scenario: Accession Spawn is not created due to missing required fields
26-
Given the user is on the New Accession page spawned from the original accession
27-
When the user clicks on 'Save'
28-
Then the following error message is displayed
29-
| Identifier - Property is required but was missing |
24+
And the new Accession is linked to the original Accession

staff_features/accessions/step_definitions/accession_edit.rb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,6 @@
4040
click_on 'View'
4141
end
4242

43-
Given 'the Accession is opened in edit mode' do
44-
visit "#{STAFF_URL}/accessions"
45-
46-
fill_in 'filter-text', with: @uuid
47-
48-
within '.search-filter' do
49-
find('button').click
50-
end
51-
52-
search_result_rows = all('#tabledSearchResults tbody tr')
53-
expect(search_result_rows.length).to eq 1
54-
55-
within search_result_rows[0] do
56-
element = find('a', text: 'Edit')
57-
58-
@accession_id = URI.decode_www_form_component(element[:href]).split('/').pop
59-
end
60-
61-
click_on 'Edit'
62-
end
63-
6443
Then 'the Accession is updated with the new {string} as {string}' do |field, value|
6544
fill_in field, with: value
6645
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
Given 'the Accession is opened in edit mode' do
4+
visit "#{STAFF_URL}/accessions"
5+
6+
fill_in 'filter-text', with: @uuid
7+
8+
within '.search-filter' do
9+
find('button').click
10+
end
11+
12+
search_result_rows = all('#tabledSearchResults tbody tr')
13+
expect(search_result_rows.length).to eq 1
14+
15+
within search_result_rows[0] do
16+
element = find('a', text: 'Edit')
17+
18+
@accession_id = URI.decode_www_form_component(element[:href]).split('/').pop
19+
end
20+
21+
click_on 'Edit'
22+
end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 new Accession is not linked to the original Accession' do
12+
expect(page).not_to have_selector('#accession_related_accessions__0_')
13+
end
14+
15+
When 'the user links to the original Accession in the {string} form' do |form_title|
16+
section_title = find('h3', text: form_title)
17+
section = section_title.ancestor('section')
18+
expect(section[:id]).to_not eq nil
19+
20+
within section do
21+
click_on 'Add Related Accession'
22+
find('.related-accession-type').select '"Part of" Relationship'
23+
fill_in 'token-input-accession_related_accessions__0__ref_', with: @uuid
24+
dropdown_items = all('li.token-input-dropdown-item2')
25+
dropdown_items.first.click
26+
end
27+
end
28+
29+
Then 'the new Accession is linked to the original Accession' do
30+
section = find('#accession_related_accessions_')
31+
expect(section).to have_text @uuid
32+
end

staff_features/shared/step_definitions.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
click_on_string string
2020
end
2121

22+
When 'the user clicks on {string} in the spawn dropdown menu' do |string|
23+
within '#spawn-dropdown' do
24+
click_on_string string
25+
end
26+
end
27+
2228
When 'the user clicks on {string} in the confirm popup' do |string|
2329
within '#confirmChangesModal' do
2430
click_on_string string
@@ -39,10 +45,30 @@
3945
fill_in label, with: value
4046
end
4147

48+
When 'the user fills in {string} with {string} in the {string} form' do |label, value, form_title|
49+
section_title = find('h3', text: form_title)
50+
section = section_title.ancestor('section')
51+
expect(section[:id]).to_not eq nil
52+
53+
within section do
54+
fill_in label, with: value
55+
end
56+
end
57+
4258
When 'the user selects {string} from {string}' do |option, label|
4359
select option, from: label
4460
end
4561

62+
When 'the user selects {string} from {string} in the {string} form' do |option, label, form_title|
63+
section_title = find('h3', text: form_title)
64+
section = section_title.ancestor('section')
65+
expect(section[:id]).to_not eq nil
66+
67+
within section do
68+
select option, from: label
69+
end
70+
end
71+
4672
When 'the user checks {string}' do |label|
4773
check label
4874
end
@@ -67,6 +93,14 @@
6793
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*deleted$/i)
6894
end
6995

96+
Then 'only the following info message is displayed' do |messages|
97+
expect(messages.raw.length).to eq 1
98+
99+
messages.raw.each do |message|
100+
expect(page).to have_text message[0]
101+
end
102+
end
103+
70104
Then 'the following error messages are displayed' do |messages|
71105
messages.raw.each do |message|
72106
expect(page).to have_text message[0]
@@ -93,6 +127,14 @@
93127
expect(page).to have_field(label, checked: true)
94128
end
95129

130+
Then 'only the following error message is displayed' do |messages|
131+
expect(messages.raw.length).to eq 1
132+
133+
messages.raw.each do |message|
134+
expect(page).to have_text message[0]
135+
end
136+
end
137+
96138
Then 'the {string} section is displayed' do |section_heading|
97139
expect(all('section > h3').map(&:text)).to include(section_heading)
98140
end

0 commit comments

Comments
 (0)