From ed48d92a165e570db191785a80922d3cd2909b44 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 24 May 2016 09:47:53 +0200 Subject: [PATCH] Improved object manager browser tests. --- app/models/channel.rb | 1 + test/browser/admin_object_manager_test.rb | 32 +++++++- test/browser_test_helper.rb | 90 ++++++++++++++++++++++- 3 files changed, 117 insertions(+), 6 deletions(-) diff --git a/app/models/channel.rb b/app/models/channel.rb index 945643fdf..1d9874926 100644 --- a/app/models/channel.rb +++ b/app/models/channel.rb @@ -209,6 +209,7 @@ send via account # ignore notifications in developer mode if notification == true && Setting.get('developer_mode') == true logger.notice "Do not send notification #{mail_params.inspect} because of enabled developer_mode" + return end adapter = options[:adapter] diff --git a/test/browser/admin_object_manager_test.rb b/test/browser/admin_object_manager_test.rb index 51d27841b..914761f69 100644 --- a/test/browser/admin_object_manager_test.rb +++ b/test/browser/admin_object_manager_test.rb @@ -2,8 +2,7 @@ require 'browser_test_helper' class AdminObjectManagerTest < TestCase - def test_basic - name = "some overview #{rand(99_999_999)}" + def test_basic_a @browser = browser_instance login( @@ -114,11 +113,38 @@ class AdminObjectManagerTest < TestCase click(css: '.modal button.js-submit') # create new ticket + ticket = ticket_create( + data: { + customer: 'nico', + group: 'Users', + priority: '2 normal', + state: 'open', + title: 'ticket attribute test #1', + body: 'ticket attribute test #1', + }, + #custom_data_select: { + # key1: 'some value', + #}, + custom_data_input: { + browser_test1: 'some value öäüß', + }, + disable_group_check: true, + ) # update ticket + ticket_update( + data: {}, + #custom_data_select: { + # key1: 'some value', + #}, + custom_data_input: { + browser_test1: 'some value ABC', + }, + ) # discard new attribute - + click(css: 'a[href="#manage"]') + click(css: 'a[href="#system/object_manager"]') watch_for( css: '#content table', value: 'browser_test1', diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index c037cf41b..76d778f87 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -1620,6 +1620,25 @@ wait untill text in selector disabppears title: 'overview #1', } + ticket = ticket_create( + browser: browser1, + data: { + customer: 'nico', + group: 'Users', # optional / '-NONE-' # if group selection should not be shown + priority: '2 normal', + state: 'open', + title: 'overview #1', + body: 'overview #1', + }, + custom_data_select: { + key1: 'some value', + }, + custom_data_input: { + key1: 'some value', + }, + disable_group_check: true, + ) + =end def ticket_create(params) @@ -1668,8 +1687,10 @@ wait untill text in selector disabppears else # check count of agents, should be only 1 / - selection on init screen - count = instance.find_elements(css: '.active .newTicket select[name="owner_id"] option').count - assert_equal(1, count, 'check if owner selection is empty per default') + if !params[:disable_group_check] + count = instance.find_elements(css: '.active .newTicket select[name="owner_id"] option').count + assert_equal(1, count, 'check if owner selection is empty per default') + end select( browser: instance, css: '.active .newTicket select[name="group_id"]', @@ -1735,6 +1756,28 @@ wait untill text in selector disabppears sleep 0.4 end + if params[:custom_data_select] + params[:custom_data_select].each {|local_key, local_value| + select( + browser: instance, + css: ".active .newTicket select[name=\"#{local_key}\"]", + value: local_value, + mute_log: true, + ) + } + end + if params[:custom_data_input] + params[:custom_data_input].each {|local_key, local_value| + set( + browser: instance, + css: ".active .newTicket input[name=\"#{local_key}\"]", + value: local_value, + clear: true, + mute_log: true, + ) + } + end + if data[:attachment] file_upload( browser: instance, @@ -1798,6 +1841,25 @@ wait untill text in selector disabppears do_not_submit: true, ) + ticket_update( + browser: browser1, + data: { + title: '', + customer: 'some_customer@example.com', + body: 'some body', + group: 'some group', # optional + priority: '1 low', + state: 'closed', + }, + custom_data_select: { + key1: 'some value', + }, + custom_data_input: { + key1: 'some value', + }, + do_not_submit: true, + ) + =end def ticket_update(params) @@ -1933,7 +1995,29 @@ wait untill text in selector disabppears ) end - if data[:state] || data[:group] || data[:body] + if params[:custom_data_select] + params[:custom_data_select].each {|local_key, local_value| + select( + browser: instance, + css: ".active .sidebar select[name=\"#{local_key}\"]", + value: local_value, + mute_log: true, + ) + } + end + if params[:custom_data_input] + params[:custom_data_input].each {|local_key, local_value| + set( + browser: instance, + css: ".active .sidebar input[name=\"#{local_key}\"]", + value: local_value, + clear: true, + mute_log: true, + ) + } + end + + if data[:state] || data[:group] || data[:body] || !params[:custom_data_select].empty? || !params[:custom_data_input].empty? found = nil (1..10).each {