Skip to content

Commit ea6734b

Browse files
authored
Subject edit (#77)
1 parent 3fed532 commit ea6734b

File tree

3 files changed

+110
-7
lines changed

3 files changed

+110
-7
lines changed

staff_features/shared/step_definitions.rb

+21-7
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,9 @@
7979
end
8080

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

86-
within dropdown_menus.first do |dropdown_menu|
84+
within dropdown_menus.first do
8785
elements = dropdown_menu.all(:xpath, ".//*[contains(text(), '#{string}')]")
8886

8987
elements.each do |element|
@@ -245,12 +243,12 @@
245243
end
246244

247245
When 'the user changes the {string} field to {string}' do |field, value|
248-
element = find_field(field, match: :first)
246+
field = find_field(field, match: :first)
249247

250-
if element.tag_name == 'select'
251-
element.select value
248+
if field.tag_name == 'select'
249+
field.select value.strip
252250
else
253-
element.fill_in with: value
251+
field.fill_in with: value
254252
end
255253
end
256254

@@ -272,6 +270,12 @@
272270
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*updated$/i)
273271
end
274272

273+
Then('the {string} saved message is displayed') do |string|
274+
wait_for_ajax if current_url.include? 'resources'
275+
276+
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*saved$/i)
277+
end
278+
275279
Then('the {string} deleted message is displayed') do |string|
276280
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*deleted$/i)
277281
end
@@ -384,3 +388,13 @@
384388

385389
click_on 'Save'
386390
end
391+
392+
When 'the user clears {string} in the {string} form' do |label, form_title|
393+
section_title = find('h3', text: form_title)
394+
section = section_title.ancestor('section')
395+
expect(section[:id]).to_not eq nil
396+
397+
within section do
398+
select '', from: label
399+
end
400+
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Feature: Subject Edit
2+
Background:
3+
Given an administrator user is logged in
4+
And a Subject has been created
5+
Scenario: Subject is opened in the edit mode from the browse menu
6+
Given the Subject appears in the search results list
7+
When the user clicks on 'Edit'
8+
Then the Subject is opened in the edit mode
9+
Scenario: Subject is opened in the edit mode from the view mode
10+
Given the Subject is opened in the view mode
11+
When the user clicks on 'Edit'
12+
Then the Subject is opened in the edit mode
13+
Scenario Outline: Subject is successfully updated
14+
Given the Subject is opened in edit mode
15+
When the user changes the '<Field>' field to '<NewValue>'
16+
And the user clicks on 'Save'
17+
Then the 'Subject' saved message is displayed
18+
Then the field '<Field>' has value '<NewValue>'
19+
Examples:
20+
| Field | NewValue |
21+
| Scope Note | Test Scope Note |
22+
Scenario: Subject is not updated
23+
Given the Subject is opened in edit mode
24+
When the user clears 'Source' in the 'Basic Information' form
25+
And the user clicks on 'Save'
26+
Then the following error messages are displayed
27+
| Source - Property is required but was missing |
28+
Scenario: Delete sub-record of a Subject
29+
Given the Subject is opened in edit mode
30+
And the Subject has one Metadata Rights Declarations
31+
When the user clicks on remove icon in the 'Metadata Rights Declarations' form
32+
And the user clicks on 'Confirm Removal'
33+
And the user clicks on 'Save'
34+
Then the 'Subject' saved message is displayed
35+
And the Subject does not have Metadata Rights Declarations

0 commit comments

Comments
 (0)