From f9054a6e8fd4414cae2a63f5a6c33e702440c71a Mon Sep 17 00:00:00 2001 From: dinadi Date: Fri, 23 Aug 2024 12:55:17 +0300 Subject: [PATCH 1/2] added gherkin scenarios for create digital object --- .../create-digital-object.feature | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 staff-features/digital-objects/create-digital-object.feature diff --git a/staff-features/digital-objects/create-digital-object.feature b/staff-features/digital-objects/create-digital-object.feature new file mode 100644 index 00000000..3396e6fb --- /dev/null +++ b/staff-features/digital-objects/create-digital-object.feature @@ -0,0 +1,25 @@ +Feature: Digital Object Management - Create Digital Object Record + + Background: + Given I am signed in as a system administrator + And I am in the edit mode of an accession record + When I click on "Instances" in the left sidebar + And I click on "Add Digital Object" in the sub-record form + And I click on the dropdown toggle to the right of the input field + And I click on "Create" + + Scenario: Successfully create and link a digital object record + When I fill in the "Title" field + And I fill in the "Identifier" field + And I click on the "Create and Link" button + And I click on the "Save Accession" button + Then the digital object record is created + And the digital object is linked to the accession record + And "+1" is added next to "Instances" in the left sidebar + + Scenario: Fail to create a digital object record due to missing required information + When I click on the "Create and Link" button without filling in the required fields + Then the digital object record is not created + And an alert is shown with the following errors: + | Title - Property is required but was missing | + | Identifier - Property is required but was missing | \ No newline at end of file From e67e471b65746a1103628b4149fc9955539161f7 Mon Sep 17 00:00:00 2001 From: blacksmith-welder Date: Thu, 5 Sep 2024 17:34:13 +0300 Subject: [PATCH 2/2] Create digital object step definitions --- .../create-digital-object.feature | 25 ----------------- .../digital_object_create.feature | 16 +++++++++++ .../digital-objects/digital_object_create.rb | 28 +++++++++++++++++++ staff-features/shared/step_definitions.rb | 10 +++++++ staff-features/users/user_create.feature | 2 +- staff-features/users/user_create.rb | 6 ---- 6 files changed, 55 insertions(+), 32 deletions(-) delete mode 100644 staff-features/digital-objects/create-digital-object.feature create mode 100644 staff-features/digital-objects/digital_object_create.feature create mode 100644 staff-features/digital-objects/digital_object_create.rb diff --git a/staff-features/digital-objects/create-digital-object.feature b/staff-features/digital-objects/create-digital-object.feature deleted file mode 100644 index 3396e6fb..00000000 --- a/staff-features/digital-objects/create-digital-object.feature +++ /dev/null @@ -1,25 +0,0 @@ -Feature: Digital Object Management - Create Digital Object Record - - Background: - Given I am signed in as a system administrator - And I am in the edit mode of an accession record - When I click on "Instances" in the left sidebar - And I click on "Add Digital Object" in the sub-record form - And I click on the dropdown toggle to the right of the input field - And I click on "Create" - - Scenario: Successfully create and link a digital object record - When I fill in the "Title" field - And I fill in the "Identifier" field - And I click on the "Create and Link" button - And I click on the "Save Accession" button - Then the digital object record is created - And the digital object is linked to the accession record - And "+1" is added next to "Instances" in the left sidebar - - Scenario: Fail to create a digital object record due to missing required information - When I click on the "Create and Link" button without filling in the required fields - Then the digital object record is not created - And an alert is shown with the following errors: - | Title - Property is required but was missing | - | Identifier - Property is required but was missing | \ No newline at end of file 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