Skip to content

Commit 1a622d5

Browse files
Subject edit
1 parent 2336064 commit 1a622d5

File tree

3 files changed

+81
-16
lines changed

3 files changed

+81
-16
lines changed

staff_features/shared/step_definitions.rb

+21-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080

8181
When 'the user clicks on {string} in the dropdown menu' do |string|
8282
dropdown_menu = all('.dropdown-menu').first
83-
8483
dropdown_menus = all('.dropdown-menu')
8584

8685
within dropdown_menus.first do |dropdown_menu|
@@ -247,10 +246,12 @@
247246
When 'the user changes the {string} field to {string}' do |field, value|
248247
element = find_field(field, match: :first)
249248

250-
if element.tag_name == 'select'
251-
element.select value
249+
field = find_field(field, match: :first)
250+
251+
if field.tag_name == 'select'
252+
field.select value.strip
252253
else
253-
element.fill_in with: value
254+
field.fill_in with: value
254255
end
255256
end
256257

@@ -272,6 +273,12 @@
272273
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*updated$/i)
273274
end
274275

276+
Then('the {string} saved message is displayed') do |string|
277+
wait_for_ajax if current_url.include? 'resources'
278+
279+
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*saved$/i)
280+
end
281+
275282
Then('the {string} deleted message is displayed') do |string|
276283
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*deleted$/i)
277284
end
@@ -384,3 +391,13 @@
384391

385392
click_on 'Save'
386393
end
394+
395+
When 'the user clears {string} in the {string} form' do |label, form_title|
396+
section_title = find('h3', text: form_title)
397+
section = section_title.ancestor('section')
398+
expect(section[:id]).to_not eq nil
399+
400+
within section do
401+
select '', from: label
402+
end
403+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# frozen_string_literal: true
2+
3+
Given 'the Subject appears in the search results list' do
4+
visit "#{STAFF_URL}/subjects"
5+
6+
fill_in 'filter-text', with: "subject_term_#{@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+
@subject_id = URI.decode_www_form_component(element[:href]).split('/').pop
19+
end
20+
end
21+
22+
Then 'the Subject is opened in the edit mode' do
23+
uri = current_url.split('/')
24+
25+
action = uri.pop
26+
subject_id = uri.pop
27+
28+
expect(action).to eq 'edit'
29+
expect(subject_id).to eq @subject_id
30+
end
31+
32+
Given 'the Subject is opened in the view mode' do
33+
visit "#{STAFF_URL}/subjects/#{@subject_id}"
34+
end
35+
36+
Given 'the Subject is opened in edit mode' do
37+
visit "#{STAFF_URL}/subjects/#{@subject_id}/edit"
38+
end
39+
40+
Given 'the Subject has one Metadata Rights Declarations' do
41+
click_on 'Add Metadata Rights Declaration'
42+
43+
select 'This record is made available under an Universal 1.0 Public Domain Dedication Creative Commons license.', from: 'License'
44+
45+
click_on 'Save'
46+
47+
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Subject Saved'
48+
end
49+
50+
Then 'the Subject does not have Metadata Rights Declarations' do
51+
elements = all('#subject_metadata_rights_declarations_ li')
52+
53+
expect(elements.length).to eq 0
54+
end

staff_features/subjects/subject_edit.feature

+6-12
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@ Feature: Subject Edit
1414
Given the Subject is opened in edit mode
1515
When the user changes the '<Field>' field to '<NewValue>'
1616
And the user clicks on 'Save'
17-
Then the 'Subject' updated message is displayed
17+
Then the 'Subject' saved message is displayed
1818
Then the field '<Field>' has value '<NewValue>'
1919
Examples:
20-
| Field | NewValue |
21-
| Authority ID | Test Authority ID |
22-
| Scope Note | Test Scope Note |
23-
Scenario: Subject is not updated after changes are reverted
20+
| Field | NewValue |
21+
| Scope Note | Test Scope Note |
22+
Scenario: Subject is not updated
2423
Given the Subject is opened in edit mode
25-
When the user changes the 'Term' field
26-
And the user clicks on 'Revert Changes'
27-
Then the Subject Term field has the original value
28-
Scenario: Delete required sub-record of a Subject fails
29-
Given the Subject is opened in edit mode
30-
When the user selects 'empty Source' from 'Source' in the 'Besic Information' form
24+
When the user clears 'Source' in the 'Basic Information' form
3125
And the user clicks on 'Save'
3226
Then the following error messages are displayed
3327
| Source - Property is required but was missing |
@@ -37,5 +31,5 @@ Feature: Subject Edit
3731
When the user clicks on remove icon in the 'Metadata Rights Declarations' form
3832
And the user clicks on 'Confirm Removal'
3933
And the user clicks on 'Save'
40-
Then the 'Subject' updated message is displayed
34+
Then the 'Subject' saved message is displayed
4135
And the Subject does not have Metadata Rights Declarations

0 commit comments

Comments
 (0)