From 2c50fcfa393f95ec2a8136af77bc90cc7355dbb3 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 10 Mar 2016 16:47:42 +0100 Subject: [PATCH] Improved imap folder support in admin interface. --- .../_application_controller_form.coffee | 2 +- .../app/controllers/_channel/email.coffee | 21 +++- .../channel/email_account_wizard.jst.eco | 13 +- script/build/test_slice_tests.sh | 2 + test/browser/admin_channel_email_test.rb | 112 ++++++++++++++++++ 5 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 test/browser/admin_channel_email_test.rb diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.coffee index 6b6660ddd..aeeb9de0a 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.coffee @@ -389,7 +389,7 @@ class App.ControllerForm extends App.Controller model: @model params: params screen: @screen - ) + ) # get all params of the form @params: (form) -> diff --git a/app/assets/javascripts/app/controllers/_channel/email.coffee b/app/assets/javascripts/app/controllers/_channel/email.coffee index 738865326..7cfec2175 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.coffee @@ -446,6 +446,7 @@ class App.ChannelEmailAccountWizard extends App.WizardModal 'change .js-outbound [name=adapter]': 'toggleOutboundAdapter' 'submit .js-outbound': 'probleOutbound' 'click .js-goToSlide': 'goToSlide' + 'click .js-expert': 'probeBasedOnIntro' 'click .js-close': 'hide' constructor: -> @@ -495,13 +496,12 @@ class App.ChannelEmailAccountWizard extends App.WizardModal # base configureAttributesBase = [ - { name: 'realname', display: 'Department Name', tag: 'input', type: 'text', limit: 160, null: false, placeholder: 'Organization Support', autocomplete: 'off' }, + { name: 'realname', display: 'Organization & Department Name', tag: 'input', type: 'text', limit: 160, null: false, placeholder: 'Organization Support', autocomplete: 'off' }, { name: 'email', display: 'Email', tag: 'input', type: 'email', limit: 120, null: false, placeholder: 'support@example.com', autocapitalize: false, autocomplete: 'off' }, { name: 'password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: false, autocapitalize: false, autocomplete: 'new-password', single: true }, { name: 'group_id', display: 'Destination Group', tag: 'select', null: false, relation: 'Group', nulloption: true }, - { name: 'folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false }, ] - new App.ControllerForm( + @formMeta = new App.ControllerForm( el: @$('.base-settings'), model: configure_attributes: configureAttributesBase @@ -587,6 +587,19 @@ class App.ChannelEmailAccountWizard extends App.WizardModal if @channel params.channel_id = @channel.id + if $(e.currentTarget).hasClass('js-expert') + + # validate form + errors = @formMeta.validate(params) + if errors + @formValidate(form: e.target, errors: errors) + return + + @showSlide('js-inbound') + @$('.js-inbound [name="options::user"]').val(params.email) + @$('.js-inbound [name="options::password"]').val(params.password) + return + @disable(e) @$('.js-probe .js-email').text(params.email) @showSlide('js-probe') @@ -777,7 +790,7 @@ class App.ChannelEmailAccountWizard extends App.WizardModal else if data.subject && @account @account.subject = data.subject - @verify( @account, count + 1 ) + @verify(@account, count + 1) fail: => @showSlide('js-intro') @showAlert('js-intro', 'Unable to verify sending and receiving. Please check your settings.') diff --git a/app/assets/javascripts/app/views/channel/email_account_wizard.jst.eco b/app/assets/javascripts/app/views/channel/email_account_wizard.jst.eco index df2bf5953..337a60207 100644 --- a/app/assets/javascripts/app/views/channel/email_account_wizard.jst.eco +++ b/app/assets/javascripts/app/views/channel/email_account_wizard.jst.eco @@ -18,8 +18,11 @@ @@ -121,7 +124,7 @@ <%- @T('Go Back') %> @@ -149,7 +152,7 @@ <%- @T('Go Back') %> diff --git a/script/build/test_slice_tests.sh b/script/build/test_slice_tests.sh index e28097008..39f34133d 100755 --- a/script/build/test_slice_tests.sh +++ b/script/build/test_slice_tests.sh @@ -5,6 +5,7 @@ if [ "$LEVEL" == '1' ]; then echo "slicing level 1" # no ticket action + rm test/browser/admin_channel_email_test.rb rm test/browser/agent_user_profile_test.rb rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_ticket_*.rb @@ -21,6 +22,7 @@ elif [ "$LEVEL" == '2' ]; then rm test/browser/aab_unit_test.rb rm test/browser/aac_basic_richtext_test.rb rm test/browser/aab_basic_urls_test.rb + rm test/browser/admin_channel_email_test.rb rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_user_*.rb rm test/browser/auth_test.rb diff --git a/test/browser/admin_channel_email_test.rb b/test/browser/admin_channel_email_test.rb new file mode 100644 index 000000000..2c6359efb --- /dev/null +++ b/test/browser/admin_channel_email_test.rb @@ -0,0 +1,112 @@ +# encoding: utf-8 +require 'browser_test_helper' + +class AdminChannelEmailTest < TestCase + def test_account_add + + if !ENV['MAILBOX_INIT'] + #raise "Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'" + puts "NOTICE: Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'" + return + end + mailbox_user = ENV['MAILBOX_INIT'].split(':')[0] + mailbox_password = ENV['MAILBOX_INIT'].split(':')[1] + + @browser = browser_instance + login( + username: 'master@example.com', + password: 'test', + url: browser_url, + ) + tasks_close_all() + + click(css: 'a[href="#manage"]') + click(css: 'a[href="#channels/email"]') + + click(css: '#content .js-channelNew') + + sleep 2 + + set( + css: '.modal input[name="realname"]', + value: 'My System', + ) + set( + css: '.modal input[name="email"]', + value: mailbox_user, + ) + set( + css: '.modal input[name="password"]', + value: mailbox_password, + ) + select( + css: '.modal select[name="group_id"]', + value: 'Users', + ) + click(css: '.modal button.js-submit') + sleep 4 + + watch_for( + css: '.modal', + value: 'already exists', + ) + + click(css: '.modal .js-close') + + # delete + click(css: '#content .js-channelDelete') + sleep 2 + click(css: '.modal .js-submit') + + # re-create + click(css: '#content .js-channelNew') + + sleep 2 + + set( + css: '.modal input[name="realname"]', + value: 'My System', + ) + set( + css: '.modal input[name="email"]', + value: mailbox_user, + ) + set( + css: '.modal input[name="password"]', + value: mailbox_password, + ) + select( + css: '.modal select[name="group_id"]', + value: 'Users', + ) + click(css: '.modal button.js-submit') + sleep 2 + + watch_for_disappear( + css: '.modal', + ) + sleep 2 + exists_not(css: '.modal') + + watch_for( + css: '#content', + value: mailbox_user, + ) + + # set invalid folder + click(css: '#content .js-editInbound') + sleep 2 + + set( + css: '.modal input[name="options::folder"]', + value: 'not_existing_folder', + ) + click(css: '.modal .js-inbound button.js-submit') + watch_for( + css: '.modal', + value: 'Mailbox doesn\'t exist', + ) + + end + +end