Skip to content

Commit 37b151f

Browse files
Step definitions for form section fields
1 parent 21889db commit 37b151f

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

staff_features/accessions/accession_event_create.feature

+12-8
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,36 @@ Feature: Accession Event Create
55
And the Accession is opened in edit mode
66
Scenario: Accession Event create page
77
When the user clicks on 'Add Event'
8-
And the user clicks on 'Add Event' again
8+
And the user clicks on 'Add Event' in the dropdown menu
99
Then the New Event page is displayed with the Accession linked
1010
Scenario: Accession Event is created
1111
Given the New Event page is open for an Accession
12-
When the user fills in 'Begin' with '2020-01-01'
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
1314
And the user links an Agent
1415
And the user clicks on 'Save'
1516
Then the 'Event Created' message is displayed
16-
Scenario: Accession Event is not created due to missing all required fields
17+
Scenario: Accession Event is not created due to missing required fields
1718
Given the New Event page is open for an Accession
18-
When the user clicks on 'Save'
19+
When the user selects 'Single' from 'Type' in the 'Event Date/Time' form
20+
And the user clicks on 'Save'
1921
Then the following error messages are displayed
2022
| Expression - is required unless a begin or end date is given |
2123
| Begin - is required unless an expression or an end date is given |
2224
| Agents - Property is required but was missing |
2325
| Role - Property is required but was missing |
24-
Scenario: Accession Event is not created due to missing required fields - only 'Expression' is completed
26+
Scenario: Accession Event is not created due to missing required fields, with Event Date/Time Expression filled in
2527
Given the New Event page is open for an Accession
26-
When the user fills in 'Expression'
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
2730
And the user clicks on 'Save'
2831
Then the following error messages are displayed
2932
| Agents - Property is required but was missing |
3033
| Role - Property is required but was missing |
31-
Scenario: Accession Event is not created due to invalid date format
34+
Scenario: Accession Event is not created due to invalid date
3235
Given the New Event page is open for an Accession
33-
When the user fills in 'Begin' with '2024-13-15'
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
3438
And the user links an Agent
3539
And the user clicks on 'Save'
3640
Then the following error message is displayed

staff_features/shared/step_definitions.rb

+25-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
click_on_string string
2020
end
2121

22-
When 'the user clicks on {string} again' do |string|
23-
elements = all(:xpath, "//*[contains(text(), '#{string}')]")
24-
25-
elements[1].click
22+
When 'the user clicks on {string} in the dropdown menu' do |string|
23+
within '.dropdown-menu' do
24+
elements = all(:xpath, "//*[contains(text(), '#{string}')]")
25+
elements[1].click
26+
end
2627
end
2728

2829
When 'the user clicks on {string} in the confirm popup' do |string|
@@ -41,10 +42,30 @@
4142
fill_in label, with: value
4243
end
4344

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

59+
When 'the user selects {string} from {string} in the {string} form' do |option, label, form_title|
60+
section_title = find('h3', text: form_title)
61+
section = section_title.ancestor('section')
62+
expect(section[:id]).to_not eq nil
63+
64+
within section do
65+
select option, from: label
66+
end
67+
end
68+
4869
When 'the user checks {string}' do |label|
4970
check label
5071
end

0 commit comments

Comments
 (0)