From c335147d625d78bcc25320cb0f783379a57b59d5 Mon Sep 17 00:00:00 2001 From: Dominik Klein Date: Wed, 29 Sep 2021 17:17:21 +0200 Subject: [PATCH] Maintenance: Port customer ticket create fields test to capybara. --- script/build/test_slice_tests.sh | 6 --- spec/system/ticket/create_spec.rb | 33 +++++++++++++ .../customer_ticket_create_fields_test.rb | 47 ------------------- 3 files changed, 33 insertions(+), 53 deletions(-) delete mode 100644 test/browser/customer_ticket_create_fields_test.rb diff --git a/script/build/test_slice_tests.sh b/script/build/test_slice_tests.sh index 8da4c701d..dd79296ab 100755 --- a/script/build/test_slice_tests.sh +++ b/script/build/test_slice_tests.sh @@ -46,7 +46,6 @@ if [ "$LEVEL" == '1' ]; then rm test/browser/agent_user_manage_test.rb rm test/browser/agent_user_profile_test.rb # test/browser/auth_test.rb - rm test/browser/customer_ticket_create_fields_test.rb rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/integration_test.rb @@ -105,7 +104,6 @@ elif [ "$LEVEL" == '2' ]; then rm test/browser/agent_user_manage_test.rb rm test/browser/agent_user_profile_test.rb rm test/browser/auth_test.rb - rm test/browser/customer_ticket_create_fields_test.rb rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/integration_test.rb @@ -164,7 +162,6 @@ elif [ "$LEVEL" == '3' ]; then rm test/browser/agent_user_manage_test.rb rm test/browser/agent_user_profile_test.rb rm test/browser/auth_test.rb - rm test/browser/customer_ticket_create_fields_test.rb rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/integration_test.rb @@ -223,7 +220,6 @@ elif [ "$LEVEL" == '4' ]; then rm test/browser/agent_user_manage_test.rb rm test/browser/agent_user_profile_test.rb rm test/browser/auth_test.rb - # test/browser/customer_ticket_create_fields_test.rb # test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/integration_test.rb @@ -281,7 +277,6 @@ elif [ "$LEVEL" == '5' ]; then # test/browser/agent_user_manage_test.rb # test/browser/agent_user_profile_test.rb rm test/browser/auth_test.rb - rm test/browser/customer_ticket_create_fields_test.rb rm test/browser/customer_ticket_create_test.rb rm test/browser/first_steps_test.rb rm test/browser/integration_test.rb @@ -342,7 +337,6 @@ elif [ "$LEVEL" == '6' ]; then rm test/browser/agent_user_manage_test.rb rm test/browser/agent_user_profile_test.rb rm test/browser/auth_test.rb - rm test/browser/customer_ticket_create_fields_test.rb rm test/browser/customer_ticket_create_test.rb # test/browser/first_steps_test.rb # test/browser/integration_test.rb diff --git a/spec/system/ticket/create_spec.rb b/spec/system/ticket/create_spec.rb index 05a11b108..debac63c2 100644 --- a/spec/system/ticket/create_spec.rb +++ b/spec/system/ticket/create_spec.rb @@ -500,6 +500,39 @@ RSpec.describe 'Ticket Create', type: :system do end end + context 'when agent and customer user login after another' do + let(:agent) { create(:agent, password: 'test') } + let(:customer) { create(:customer, password: 'test') } + + it 'customer user should not have agent object attributes', authenticated_as: :agent do + visit 'ticket/create' + + logout + + # Re-create agent session and fetch object attributes. + login( + username: agent.login, + password: 'test' + ) + visit 'ticket/create' + + # Re-remove local object attributes bound to the session + # there was an issue (#1856) where the old attribute values + # persisted and were stored as the original attributes. + logout + + # Create customer session and fetch object attributes. + login( + username: customer.login, + password: 'test' + ) + + visit 'customer_ticket_new' + + expect(page).to have_no_css('.newTicket input[name="customer_id"]') + end + end + describe 'It should be possible to show attributes which are configured shown false #3726', authenticated_as: :authenticate, db_strategy: :reset do let(:field_name) { SecureRandom.uuid } let(:field) do diff --git a/test/browser/customer_ticket_create_fields_test.rb b/test/browser/customer_ticket_create_fields_test.rb deleted file mode 100644 index c7ee90222..000000000 --- a/test/browser/customer_ticket_create_fields_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ - -require 'browser_test_helper' - -class CustomerTicketCreateFieldsTest < TestCase - def test_customer_ticket_create_fields - @browser = browser_instance - - # create agent session and fetch object attributes - login( - username: 'admin@example.com', - password: 'test', - url: browser_url, - ) - # remove local object attributes bound to the session - logout - - # re-create agent session and fetch object attributes - login( - username: 'admin@example.com', - password: 'test', - url: browser_url, - ) - # re-remove local object attributes bound to the session - # there was an issue (#1856) where the old attribute values - # persisted and were stored as the original attributes - logout - - # create customer session and fetch object attributes - login( - username: 'nicole.braun@zammad.org', - password: 'test', - url: browser_url, - ) - - # customer ticket create - click(css: 'a[href="#new"]', only_if_exists: true) - click(css: 'a[href="#customer_ticket_new"]') - sleep 2 - - # ensure that the object attributes of the agent session - # were removed properly and won't get displayed in the form - exists_not( - css: '.newTicket input[name="customer_id"]', - ) - end -end