diff --git a/staff-features/digital-objects/digital_object_create.feature b/staff-features/digital-objects/digital_object_create.feature new file mode 100644 index 00000000..fd9bc952 --- /dev/null +++ b/staff-features/digital-objects/digital_object_create.feature @@ -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 diff --git a/staff-features/digital-objects/digital_object_create.rb b/staff-features/digital-objects/digital_object_create.rb new file mode 100644 index 00000000..385a97a1 --- /dev/null +++ b/staff-features/digital-objects/digital_object_create.rb @@ -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 diff --git a/staff-features/shared/step_definitions.rb b/staff-features/shared/step_definitions.rb index 89ef843c..ff9ab670 100644 --- a/staff-features/shared/step_definitions.rb +++ b/staff-features/shared/step_definitions.rb @@ -100,6 +100,10 @@ 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 @@ -107,3 +111,9 @@ 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 diff --git a/staff-features/users/user_create.feature b/staff-features/users/user_create.feature index 120259b5..47459d5c 100644 --- a/staff-features/users/user_create.feature +++ b/staff-features/users/user_create.feature @@ -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 | diff --git a/staff-features/users/user_create.rb b/staff-features/users/user_create.rb index abe2fbae..19422da4 100644 --- a/staff-features/users/user_create.rb +++ b/staff-features/users/user_create.rb @@ -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