diff --git a/staff_features/container_profiles/container_profile_edit.feature b/staff_features/container_profiles/container_profile_edit.feature index 176e45a..9c5cd26 100644 --- a/staff_features/container_profiles/container_profile_edit.feature +++ b/staff_features/container_profiles/container_profile_edit.feature @@ -4,21 +4,22 @@ Feature: Container Profile Edit And a Container Profile has been created Scenario: Container Profile is opened in the edit mode from the browse menu Given the Container Profile appears in the search results list - When the user clicks on 'Edit' - Then the Container Profile is opened in the edit mode + When the user clicks on 'Edit' + Then the Container Profile is opened in the edit mode Scenario: Container Profile is opened in the edit mode from the view mode Given the Container Profile is opened in the view mode - When the user clicks on 'Edit' - Then the Container Profile is opened in the edit mode + When the user clicks on 'Edit' + Then the Container Profile is opened in the edit mode Scenario Outline: Container Profile is successfully updated - Given the Container Profile is opened in edit mode - When the user changes the '' field to '' + Given the Container Profile is opened in the view mode + When the user clicks on 'Edit' + And the user changes the '' field to '' And the user clicks on 'Save' + And the user clicks on 'Edit' Then the field '' has value '' Examples: - | Field | NewValue | - | Name | Updated Test Container Profile | - | Width | 10 | + | Field | NewValue | + | Width | 10 | Scenario: Container Profile is not updated after changes are reverted Given the Container Profile is opened in edit mode When the user changes the 'Name' field @@ -30,4 +31,4 @@ Feature: Container Profile Edit And the user clicks on 'Save' Then the following error message is displayed | Name - Property is required but was missing | - And the Container Profile Name field has the original value \ No newline at end of file + And the Container Profile Name field has the original value diff --git a/staff_features/container_profiles/step_definitions/container_profile_edit.rb b/staff_features/container_profiles/step_definitions/container_profile_edit.rb new file mode 100644 index 0000000..cd52b8d --- /dev/null +++ b/staff_features/container_profiles/step_definitions/container_profile_edit.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +Given 'a Container Profile has been created' do + visit "#{STAFF_URL}/container_profiles/new" + + fill_in 'container_profile_name_', with: "Container Profile #{@uuid}" + fill_in 'container_profile_depth_', with: '1.1' + fill_in 'container_profile_height_', with: '2.2' + fill_in 'container_profile_width_', with: '3.3' + + click_on 'Save' + expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Container Profile Created' + + @container_profile_id = current_url.split('/').pop +end + +Given 'the Container Profile appears in the search results list' do + visit "#{STAFF_URL}/container_profiles" + + fill_in 'filter-text', with: @uuid + + within '.search-filter' do + find('button').click + end + + search_result_rows = all('#tabledSearchResults tbody tr') + expect(search_result_rows.length).to eq 1 +end + +Then 'the Container Profile is opened in the edit mode' do + url_parts = current_url.split('/') + action = url_parts.pop + container_profile_id = url_parts.pop + + expect(action).to eq 'edit' + expect(container_profile_id).to eq @container_profile_id +end + +Given 'the Container Profile is opened in the view mode' do + visit "#{STAFF_URL}/container_profiles/#{@container_profile_id}" +end + +Given 'the Container Profile is opened in edit mode' do + visit "#{STAFF_URL}/container_profiles/#{@container_profile_id}/edit" +end + +Then 'the Container Profile Name field has the original value' do + visit "#{STAFF_URL}/container_profiles/#{@container_profile_id}/edit" + + expect(page).to have_field('Name', with: "Container Profile #{@uuid}") +end