Skip to content

Commit 20237f4

Browse files
Accession spawn step definitions
1 parent 31aa670 commit 20237f4

File tree

3 files changed

+110
-22
lines changed

3 files changed

+110
-22
lines changed
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 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' in the 'Basic Information' form
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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
23+
24+
Then 'the New Accession page is displayed' do
25+
expect(find('h2').text).to eq 'New Accession Accession'
26+
end
27+
28+
Given 'the user is on the New Accession page spawned from the original Accession' do
29+
visit "#{STAFF_URL}/accessions/new?accession_id=#{@accession_id}"
30+
end
31+
32+
Then 'the new Accession is not linked to the original Accession' do
33+
expect(page).not_to have_selector('#accession_related_accessions__0_')
34+
end
35+
36+
When 'the user links to the original Accession in the {string} form' do |form_title|
37+
section_title = find('h3', text: form_title)
38+
section = section_title.ancestor('section')
39+
expect(section[:id]).to_not eq nil
40+
41+
within section do
42+
click_on 'Add Related Accession'
43+
find('.related-accession-type').select '"Part of" Relationship'
44+
fill_in 'token-input-accession_related_accessions__0__ref_', with: @uuid
45+
dropdown_items = all('li.token-input-dropdown-item2')
46+
dropdown_items.first.click
47+
end
48+
end
49+
50+
Then 'the new Accession is linked to the original Accession' do
51+
section = find('#accession_related_accessions_')
52+
expect(section).to have_text @uuid
53+
end

staff_features/shared/step_definitions.rb

+40
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
click_on_string string
1919
end
2020

21+
When 'the user clicks on {string} in the spawn dropdown menu' do |string|
22+
within '#spawn-dropdown' do
23+
click_on_string string
24+
end
25+
end
26+
2127
When 'the user clicks on {string} in the confirm popup' do |string|
2228
within '#confirmChangesModal' do
2329
click_on_string string
@@ -34,10 +40,30 @@
3440
fill_in label, with: value
3541
end
3642

43+
When 'the user fills in {string} with {string} in the {string} form' do |label, value, form_title|
44+
section_title = find('h3', text: form_title)
45+
section = section_title.ancestor('section')
46+
expect(section[:id]).to_not eq nil
47+
48+
within section do
49+
fill_in label, with: value
50+
end
51+
end
52+
3753
When 'the user selects {string} from {string}' do |option, label|
3854
select option, from: label
3955
end
4056

57+
When 'the user selects {string} from {string} in the {string} form' do |option, label, form_title|
58+
section_title = find('h3', text: form_title)
59+
section = section_title.ancestor('section')
60+
expect(section[:id]).to_not eq nil
61+
62+
within section do
63+
select option, from: label
64+
end
65+
end
66+
4167
When 'the user checks {string}' do |label|
4268
check label
4369
end
@@ -54,6 +80,12 @@
5480
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*updated$/i)
5581
end
5682

83+
Then('the following info message is displayed') do |messages|
84+
messages.raw.each do |message|
85+
expect(page).to have_text message[0]
86+
end
87+
end
88+
5789
Then 'the following error messages are displayed' do |messages|
5890
messages.raw.each do |message|
5991
expect(page).to have_text message[0]
@@ -71,3 +103,11 @@
71103
Then 'the {string} is checked' do |label|
72104
expect(page).to have_field(label, checked: true)
73105
end
106+
107+
Then 'the following error message is displayed' do |messages|
108+
expect(messages.raw.length).to eq 1
109+
110+
messages.raw.each do |message|
111+
expect(page).to have_text message[0]
112+
end
113+
end

0 commit comments

Comments
 (0)