Skip to content

Commit

Permalink
Subject edit
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Jan 21, 2025
1 parent 79fa1d6 commit 5ba2a8f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 13 deletions.
24 changes: 23 additions & 1 deletion staff_features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@
end
end

When 'the user clears {string} in the {string} form' do |label, form_title|
section_title = find('h3', text: form_title)
section = section_title.ancestor('section')
expect(section[:id]).to_not eq nil

within section do
select '', from: label
end
end

When 'the user checks {string}' do |label|
check label, match: :first
end
Expand All @@ -234,7 +244,13 @@
end

When 'the user changes the {string} field to {string}' do |field, value|
fill_in field, with: value, match: :first
field = find_field(field, match: :first)

if field.tag_name == 'select'
field.select value.strip
else
field.fill_in with: value
end
end

When 'the user changes the {string} field' do |field|
Expand All @@ -255,6 +271,12 @@
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*updated$/i)
end

Then('the {string} saved message is displayed') do |string|
wait_for_ajax if current_url.include? 'resources'

expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*saved$/i)
end

Then('the {string} deleted message is displayed') do |string|
expect(find('.alert.alert-success.with-hide-alert').text).to match(/^#{string}.*deleted$/i)
end
Expand Down
54 changes: 54 additions & 0 deletions staff_features/subjects/step_definitions/subject_edit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

Given 'the Subject appears in the search results list' do
visit "#{STAFF_URL}/subjects"

fill_in 'filter-text', with: "subject_term_#{@uuid}"

within '.search-filter' do
find('button').click
end

search_result_rows = all('#tabledSearchResults tbody tr')
expect(search_result_rows.length).to eq 1

within search_result_rows[0] do
element = find('a', text: 'Edit')

@subject_id = URI.decode_www_form_component(element[:href]).split('/').pop
end
end

Then 'the Subject is opened in the edit mode' do
uri = current_url.split('/')

action = uri.pop
subject_id = uri.pop

expect(action).to eq 'edit'
expect(subject_id).to eq @subject_id
end

Given 'the Subject is opened in the view mode' do
visit "#{STAFF_URL}/subjects/#{@subject_id}"
end

Given 'the Subject is opened in edit mode' do
visit "#{STAFF_URL}/subjects/#{@subject_id}/edit"
end

Given 'the Subject has one Metadata Rights Declarations' do
click_on 'Add Metadata Rights Declaration'

select 'This record is made available under an Universal 1.0 Public Domain Dedication Creative Commons license.', from: 'License'

click_on 'Save'

expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Subject Saved'
end

Then 'the Subject does not have Metadata Rights Declarations' do
elements = all('#subject_metadata_rights_declarations_ li')

expect(elements.length).to eq 0
end
18 changes: 6 additions & 12 deletions staff_features/subjects/subject_edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,14 @@ Feature: Subject Edit
Given the Subject is opened in edit mode
When the user changes the '<Field>' field to '<NewValue>'
And the user clicks on 'Save'
Then the 'Subject' updated message is displayed
Then the 'Subject' saved message is displayed
Then the field '<Field>' has value '<NewValue>'
Examples:
| Field | NewValue |
| Authority ID | Test Authority ID |
| Scope Note | Test Scope Note |
Scenario: Subject is not updated after changes are reverted
| Field | NewValue |
| Scope Note | Test Scope Note |
Scenario: Subject is not updated
Given the Subject is opened in edit mode
When the user changes the 'Term' field
And the user clicks on 'Revert Changes'
Then the Subject Term field has the original value
Scenario: Delete required sub-record of a Subject fails
Given the Subject is opened in edit mode
When the user selects 'empty Source' from 'Source' in the 'Besic Information' form
When the user clears 'Source' in the 'Basic Information' form
And the user clicks on 'Save'
Then the following error messages are displayed
| Source - Property is required but was missing |
Expand All @@ -37,5 +31,5 @@ Feature: Subject Edit
When the user clicks on remove icon in the 'Metadata Rights Declarations' form
And the user clicks on 'Confirm Removal'
And the user clicks on 'Save'
Then the 'Subject' updated message is displayed
Then the 'Subject' saved message is displayed
And the Subject does not have Metadata Rights Declarations

0 comments on commit 5ba2a8f

Please sign in to comment.