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

Commit 81822ef

Browse files
kdimopulublacksmith-welder
authored andcommitted
Accession Event create step definitions
1 parent 1df445e commit 81822ef

File tree

5 files changed

+135
-32
lines changed

5 files changed

+135
-32
lines changed

helpers/helpers.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@ def ensure_test_user_exists
107107
visit STAFF_URL
108108
end
109109

110+
def ensure_test_agent_exists
111+
visit STAFF_URL
112+
113+
fill_in 'global-search-box', with: 'test_agent'
114+
find('#global-search-button').click
115+
116+
begin
117+
find 'tr', text: 'test_agent'
118+
rescue Capybara::ElementNotFound
119+
visit "#{STAFF_URL}/agents/agent_person/new"
120+
check 'Publish'
121+
fill_in 'Primary Part of Name', with: 'test_agent'
122+
click_on 'Save'
123+
end
124+
end
125+
110126
def find_user_table_row_in_manage_user_access_page(username)
111127
loop do
112128
begin

staff_features/accessions/accession_add_events.feature

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Feature: Accession Event Create
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 Event create page
7+
When the user clicks on 'Add Event'
8+
And the user clicks on 'Add Event' in the dropdown menu
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 selects 'Single' from 'Type' in the 'Event Date/Time' form
13+
And the user fills in 'Begin' with '2020-01-01' in the 'Event Date/Time' form
14+
And the user links an Agent
15+
And the user clicks on 'Save'
16+
Then the 'Event Created' message is displayed
17+
Scenario: Accession Event is not created due to missing required fields
18+
Given the New Event page is open for an Accession
19+
When the user selects 'Single' from 'Type' in the 'Event Date/Time' form
20+
And the user clicks on 'Save'
21+
Then the following error messages are displayed
22+
| Expression - is required unless a begin or end date is given |
23+
| Begin - is required unless an expression or an end date is given |
24+
| Agents - Property is required but was missing |
25+
| Role - Property is required but was missing |
26+
Scenario: Accession Event is not created due to missing required fields, with Event Date/Time Expression filled in
27+
Given the New Event page is open for an Accession
28+
When the user selects 'Single' from 'Type' in the 'Event Date/Time' form
29+
And the user fills in 'Expression' with 'Date Expression' in the 'Event Date/Time' form
30+
And the user clicks on 'Save'
31+
Then the following error messages are displayed
32+
| Agents - Property is required but was missing |
33+
| Role - Property is required but was missing |
34+
Scenario: Accession Event is not created due to invalid date
35+
Given the New Event page is open for an Accession
36+
When the user selects 'Single' from 'Type' in the 'Event Date/Time' form
37+
And the user fills in 'Begin' with '2020-22-22' in the 'Event Date/Time' form
38+
And the user links an Agent
39+
And the user clicks on 'Save'
40+
Then only the following error message is displayed
41+
| Begin - Not a valid date |
Lines changed: 42 additions & 0 deletions
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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
ensure_test_repository_exists
1111
ensure_test_user_exists
12+
ensure_test_agent_exists
1213
end
1314

1415
Given 'an archivist user is logged in' do
@@ -19,6 +20,13 @@
1920
click_on_string string
2021
end
2122

23+
When 'the user clicks on {string} in the dropdown menu' do |string|
24+
within '.dropdown-menu' do |dropdown_menu|
25+
elements = dropdown_menu.all(:xpath, "//*[contains(text(), '#{string}')]")
26+
elements[1].click
27+
end
28+
end
29+
2230
When 'the user clicks on {string} in the confirm popup' do |string|
2331
within '#confirmChangesModal' do
2432
click_on_string string
@@ -39,10 +47,30 @@
3947
fill_in label, with: value
4048
end
4149

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

64+
When 'the user selects {string} from {string} in the {string} form' do |option, label, form_title|
65+
section_title = find('h3', text: form_title)
66+
section = section_title.ancestor('section')
67+
expect(section[:id]).to_not eq nil
68+
69+
within section do
70+
select option, from: label
71+
end
72+
end
73+
4674
When 'the user checks {string}' do |label|
4775
check label
4876
end
@@ -93,6 +121,14 @@
93121
expect(page).to have_field(label, checked: true)
94122
end
95123

124+
Then 'only the following error message is displayed' do |messages|
125+
expect(messages.raw.length).to eq 1
126+
127+
messages.raw.each do |message|
128+
expect(page).to have_text message[0]
129+
end
130+
end
131+
96132
Then 'the {string} section is displayed' do |section_heading|
97133
expect(all('section > h3').map(&:text)).to include(section_heading)
98134
end

0 commit comments

Comments
 (0)