Skip to content

Commit

Permalink
Merge pull request #5 from archivesspace/gherkin-scenarios-for-digita…
Browse files Browse the repository at this point in the history
…l-object-management

Create digital objects
  • Loading branch information
blacksmith-welder authored Sep 5, 2024
2 parents 8ec0eb7 + e67e471 commit e1d425a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 7 deletions.
16 changes: 16 additions & 0 deletions staff-features/digital-objects/digital_object_create.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Feature: Create Digital Object
Background:
Given I am logged in as an admin user
Scenario: Digital object is successfully created
Given I am on the New Digital Object page
When I fill in Title with a unique id
And I fill in Identifier with a unique id
And I click on Save
Then a digital object is created
Scenario: Digital object fails to be created because required fields are missing
Given I am on the New Digital Object page
When I click on Save
Then the following error messages are displayed:
| Title - Property is required but was missing |
| Identifier - Property is required but was missing |
And a digital object is not created
28 changes: 28 additions & 0 deletions staff-features/digital-objects/digital_object_create.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

Given('I am on the New Digital Object page') do
@uuid = SecureRandom.uuid

visit "#{STAFF_URL}/digital_objects/new"
end

When('I fill in Title with a unique id') do
fill_in 'Title', with: "Digital Object Title #{@uuid}"
end

When('I fill in Identifier with a unique id') do
fill_in 'Identifier', with: @uuid
end

Then('a digital object is created') do
expect(find('h2').text).to eq "Digital Object Title #{@uuid} Digital Object"
expect(find('.alert.alert-success.with-hide-alert').text).to eq "Digital Object Digital Object Title #{@uuid} Created"

expect_record_to_be_in_search_results(@uuid)
end

Then ('a digital object is not created') do
expect(find('h2').text).to eq 'New Digital Object Digital Object'

expect_record_to_not_be_in_search_results(@uuid)
end
10 changes: 10 additions & 0 deletions staff-features/shared/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,20 @@
fill_in label, with: value
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

Then 'the following error messages are displayed:' do |messages|
messages.raw.each do |message|
expect(page).to have_text message[0]
end
end
2 changes: 1 addition & 1 deletion staff-features/users/user_create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Feature: User Management - Create User
Given I am on the Manage Users page
When I click on Create User
And I click on Create Account
Then the system should display the following error messages:
Then the following error messages are displayed:
| Username - can't be empty |
| Full name - Property is required but was missing |
| Password - can't be empty |
Expand Down
6 changes: 0 additions & 6 deletions staff-features/users/user_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,3 @@
And 'the new user should appear in the search results' do
expect_record_to_be_in_search_results(@uuid)
end

Then 'the system should display the following error messages:' do |messages|
messages.raw.each do |message|
expect(page).to have_text message[0]
end
end

0 comments on commit e1d425a

Please sign in to comment.