Skip to content

Commit e75e3a7

Browse files
Accession Event create step definitions
1 parent 17cd9bd commit e75e3a7

File tree

4 files changed

+89
-26
lines changed

4 files changed

+89
-26
lines changed

helpers/helpers.rb

+16
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ def ensure_test_repository_exists
9191
# Continue
9292
end
9393

94+
def ensure_test_agent_exists
95+
visit STAFF_URL
96+
97+
fill_in 'global-search-box', with: 'test_agent'
98+
find('#global-search-button').click
99+
100+
begin
101+
find 'tr', text: 'test_agent'
102+
rescue Capybara::ElementNotFound
103+
visit "#{STAFF_URL}/agents/agent_person/new"
104+
check 'Publish'
105+
fill_in 'Primary Part of Name', with: 'test_agent'
106+
click_on 'Save'
107+
end
108+
end
109+
94110
def find_user_table_row_in_manage_user_access_page(username)
95111
loop do
96112
begin
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,37 @@
1-
Feature: Add Event to an Accession
1+
Feature: Accession Event Create
22
Background:
33
Given an administrator user is logged in
44
And an Accession has been created
55
And the Accession is opened in edit mode
6-
Scenario: Accession is opened to Add Event mode
6+
Scenario: Accession Event create page
77
When the user clicks on 'Add Event'
8-
And the user selects 'Accession' from the drop down menu
9-
And the user clicks on 'Add Event' button
10-
Then the Accession is opened in the Add Event mode
11-
Scenario: Event type accession is successfully added
12-
Given the Accession is opened in add event mode
13-
When the user fills in 'Begin'
14-
And the user fills in 'Agents'
15-
And the user fills in 'Role'
8+
And the user clicks on 'Add Event' again
9+
Then the New Event page is displayed with the Accession linked
10+
Scenario: Accession Event is created
11+
Given the New Event page is open for an Accession
12+
When the user fills in 'Begin' with '2020-01-01'
13+
And the user links an Agent
1614
And the user clicks on 'Save'
17-
Then the 'Event' Created message is displayed
18-
Scenario: Event type accession is not added
19-
Given the Accession is opened in Add Event mode
20-
When the user fills in 'Begin'
21-
And the user fills in 'Agents'
22-
And the user fills in 'Role'
23-
And the user clicks on 'Cancel'
24-
Then the Event is not created
25-
Scenario: Add Event fails due to missing all required fields
26-
Given the Accession is opened in Add Event mode
15+
Then the 'Event Created' message is displayed
16+
Scenario: Accession Event is not created due to missing all required fields
17+
Given the New Event page is open for an Accession
2718
When the user clicks on 'Save'
2819
Then the following error messages are displayed
2920
| Expression - is required unless a begin or end date is given |
3021
| Begin - is required unless an expression or an end date is given |
3122
| Agents - Property is required but was missing |
3223
| Role - Property is required but was missing |
33-
Scenario: Add Event fails due to missing required fields - only 'Expression' is completed
34-
Given the Accession is opened in Add Event mode
24+
Scenario: Accession Event is not created due to missing required fields - only 'Expression' is completed
25+
Given the New Event page is open for an Accession
3526
When the user fills in 'Expression'
3627
And the user clicks on 'Save'
3728
Then the following error messages are displayed
3829
| Agents - Property is required but was missing |
3930
| Role - Property is required but was missing |
40-
Scenario: Add Event fails due to invalid date format
41-
Given the Accession is opened in Add Event mode
31+
Scenario: Accession Event is not created due to invalid date format
32+
Given the New Event page is open for an Accession
4233
When the user fills in 'Begin' with '2024-13-15'
43-
And the user fills in 'Agents'
44-
And the user fills in 'Role'
34+
And the user links an Agent
4535
And the user clicks on 'Save'
4636
Then the following error message is displayed
4737
| Begin - Not a valid date |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
Given 'the New Event page is open for an Accession' do
25+
click_on 'Add Event'
26+
27+
within '#form_add_event' do
28+
click_on 'Add Event'
29+
end
30+
end
31+
32+
When 'the user links an Agent' do
33+
select 'Authorizer', from: 'event_linked_agents__0__role_'
34+
fill_in 'token-input-event_linked_agents__0__ref_', with: 'test_agent'
35+
dropdown_items = all('li.token-input-dropdown-item2')
36+
dropdown_items.first.click
37+
end
38+
39+
Then 'the New Event page is displayed with the Accession linked' do
40+
expect(find('h2').text).to eq 'New Event Event'
41+
expect(find('#event_linked_records__0__ref__combobox')).to have_text @uuid
42+
end

staff_features/shared/step_definitions.rb

+15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
login_admin
99

1010
ensure_test_repository_exists
11+
ensure_test_agent_exists
1112
end
1213

1314
Given 'an archivist user is logged in' do
@@ -18,6 +19,12 @@
1819
click_on_string string
1920
end
2021

22+
When 'the user clicks on {string} again' do |string|
23+
elements = all(:xpath, "//*[contains(text(), '#{string}')]")
24+
25+
elements[1].click
26+
end
27+
2128
When 'the user clicks on {string} in the confirm popup' do |string|
2229
within '#confirmChangesModal' do
2330
click_on_string string
@@ -71,3 +78,11 @@
7178
Then 'the {string} is checked' do |label|
7279
expect(page).to have_field(label, checked: true)
7380
end
81+
82+
Then 'the following error message is displayed' do |messages|
83+
expect(messages.raw.length).to eq 1
84+
85+
messages.raw.each do |message|
86+
expect(page).to have_text message[0]
87+
end
88+
end

0 commit comments

Comments
 (0)