Skip to content

Commit

Permalink
Update resource basic information step definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksmith-welder committed Aug 28, 2024
1 parent 44a88b9 commit e3a6c90
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 48 deletions.
48 changes: 48 additions & 0 deletions helpers/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# frozen_string_literal: true

def search(uuid)
visit STAFF_URL

fill_in 'global-search-box', with: uuid
find('#global-search-button').click
end

def login_admin
visit STAFF_URL

fill_in 'username', with: 'admin'
fill_in 'password', with: 'admin'

click_on 'Sign In'

expect(page).to have_content 'Welcome to ArchivesSpace'
expect(page).to have_content 'Your friendly archives management tool.'
element = find('.global-header .user-container')
expect(element.text.strip).to eq 'admin'
end

def create_resource(uuid)
fill_in 'resource_title_', with: "Resource #{uuid}"
fill_in 'resource_id_0_', with: "Resource #{uuid}"
select 'Class', from: 'resource_level_'
element = find('#resource_lang_materials__0__language_and_script__language_')
element.send_keys('AU')
element.send_keys(:tab)

select 'Single', from: 'resource_dates__0__date_type_'
fill_in 'resource_dates__0__begin_', with: '2024'

fill_in 'resource_extents__0__number_', with: '10'
select 'Cassettes', from: 'resource_extents__0__extent_type_'

element = find('#resource_finding_aid_language_')
element.send_keys('ENG')
element.send_keys(:tab)

element = find('#resource_finding_aid_script_')
element.send_keys('Latin')
element.send_keys(:tab)

find('button', text: 'Save Resource', match: :first).click

expect(page).to have_text "Resource Resource #{uuid} created"
end

def expect_record_to_be_in_search_results(search_term)
fill_in 'global-search-box', with: search_term
find('#global-search-button').click
Expand Down
25 changes: 0 additions & 25 deletions staff-features/resources/add-additional-info.feature

This file was deleted.

23 changes: 23 additions & 0 deletions staff-features/resources/update-basic-information.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Feature: Update Resource Basic Information
Background:
Given I am logged in as an admin user
Given a resource has been created
Scenario: Successfully update resource basic information
Given I am on the resource edit page
When I select "Records" from "Resource Type"
When I check Publish?
When I check Restrictions Apply?
When I fill in Repository Processing Note with "Repository Processing Note"
When I click on "Save Resource"
Then the resource is successfully updated
Then Resource Type has value Records
Then Publish? is checked
Then Restrictions Apply? is checked
Then Repository Processing Note has value "Repository Processing Note"
Scenario: Revert changes
Given I am on the resource edit page
When I change the resource Title
When I change the resource Identifier
When I click on "Revert Changes"
Then the resource Title does not change
Then the resource Identifier does not change
69 changes: 69 additions & 0 deletions staff-features/resources/update-basic-information.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# frozen_string_literal: true

Given 'a resource has been created' do
@uuid = SecureRandom.uuid

visit "#{STAFF_URL}/resources/new"

create_resource(@uuid)
end

Given 'I am on the resource edit page' do
search(@uuid)

click_on 'Edit'
end

When 'I check Publish?' do
find('#resource_publish_').check
end

When 'I check Restrictions Apply?' do
find('#resource_restrictions_').check
end

When 'I fill in Repository Processing Note with {string}' do |value|
fill_in 'Repository Processing Note', with: value
end

When 'I change the resource Title' do
uuid = SecureRandom.uuid

fill_in 'resource_title_', with: "Resource title chagned"
end

When 'I change the resource Identifier' do
fill_in 'resource_id_0_', with: "Resource identifier chagned"
end

Then 'the resource is successfully updated' do
element = find('.alert.alert-success.with-hide-alert')
expect(element.text).to eq "Resource Resource #{@uuid} updated"
end

Then 'Resource Type has value Records' do
# search(@uuid)
# click_on 'Edit'
element = find('#resource_resource_type_')
expect(element.value).to eq 'records'
end

Then 'Publish? is checked' do
expect(find('#resource_publish_').check.checked?).to eq true
end

Then 'Restrictions Apply? is checked' do
expect(find('#resource_restrictions_').check.checked?).to eq true
end

Then 'Repository Processing Note has value {string}' do |value|
expect(find('#resource_repository_processing_note_').value).to eq value
end

Then('the resource Title does not change') do
expect(find('#resource_title_').value).to eq "Resource #{@uuid}"
end

Then('the resource Identifier does not change') do
expect(find('#resource_id_0_').value).to eq "Resource #{@uuid}"
end
33 changes: 10 additions & 23 deletions staff-features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
# frozen_string_literal: true

Given 'the user is logged in as admin' do
visit STAFF_URL

fill_in 'username', with: 'admin'
fill_in 'password', with: 'admin'

click_on 'Sign In'

expect(page).to have_content 'Welcome to ArchivesSpace'
expect(page).to have_content 'Your friendly archives management tool.'
element = find('.global-header .user-container')
expect(element.text.strip).to eq 'admin'
login_admin
end

Given 'I am logged in as an admin user' do
visit "#{STAFF_URL}/logout"
visit STAFF_URL

fill_in 'username', with: 'admin'
fill_in 'password', with: 'admin'

click_on 'Sign In'

expect(page).to have_content 'Welcome to ArchivesSpace'
expect(page).to have_content 'Your friendly archives management tool.'
element = find('.global-header .user-container')
expect(element.text.strip).to eq 'admin'
login_admin
end

Given 'I am signed in as a view-only user' do
Expand Down Expand Up @@ -73,6 +52,14 @@
elements.first.click
end

When 'I fill in {string} with {string}' do |label, value|
fill_in label, with: value
end

When 'I select {string} from {string}' do |option, label|
select option, from: label
end

Then 'the message {string} is displayed' do |string|
expect(page).to have_text string
end

0 comments on commit e3a6c90

Please sign in to comment.