Fixed issue #1669 - Ticket templates disappear after logout/login in same browser session.
This commit is contained in:
parent
59d20eb30a
commit
33f0082da6
6 changed files with 130 additions and 27 deletions
|
@ -1,9 +1,9 @@
|
|||
class App.WidgetTemplate extends App.Controller
|
||||
events:
|
||||
'click [data-type=template_save]': 'create'
|
||||
'click [data-type=template_select]': 'select'
|
||||
'click [data-type=template_delete]': 'delete'
|
||||
'click .templates-welcome .create': 'showManage'
|
||||
'click .templates-manage .js-save': 'create'
|
||||
'click .templates-manage .js-apply': 'select'
|
||||
'click .templates-manage .js-delete': 'delete'
|
||||
'click .templates-welcome .js-create': 'showManage'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
|
@ -15,12 +15,12 @@ class App.WidgetTemplate extends App.Controller
|
|||
|
||||
render: =>
|
||||
@configure_attributes = [
|
||||
{ name: 'template_id', display: '', tag: 'select', multiple: false, null: true, nulloption: true, relation: 'Template', default: @template_id },
|
||||
{ name: 'id', display: '', tag: 'select', multiple: false, null: true, nulloption: true, relation: 'Template', default: @id },
|
||||
]
|
||||
|
||||
template = {}
|
||||
if @template_id && App.Template.exists(@template_id)
|
||||
template = App.Template.find(@template_id)
|
||||
if @id && App.Template.exists(@id)
|
||||
template = App.Template.find(@id)
|
||||
|
||||
# insert data
|
||||
@html App.view('widget/template')(
|
||||
|
@ -57,11 +57,11 @@ class App.WidgetTemplate extends App.Controller
|
|||
params = @formParam(e.target)
|
||||
|
||||
# check if template is selected
|
||||
return if !params['template_id']
|
||||
return if !params['id']
|
||||
|
||||
template = App.Template.find(params['template_id'])
|
||||
template = App.Template.find(params['id'])
|
||||
if confirm('Sure?')
|
||||
@template_id = false
|
||||
@id = false
|
||||
template.destroy()
|
||||
|
||||
select: (e) =>
|
||||
|
@ -71,12 +71,12 @@ class App.WidgetTemplate extends App.Controller
|
|||
params = @formParam(e.target)
|
||||
|
||||
# check if template is selected
|
||||
return if !params['template_id']
|
||||
return if !params['id']
|
||||
|
||||
# remember template (to select it after rerender)
|
||||
@template_id = params['template_id']
|
||||
@id = params['id']
|
||||
|
||||
template = App.Template.find(params['template_id'])
|
||||
template = App.Template.find(params['id'])
|
||||
App.Event.trigger 'ticket_create_rerender', template.attributes()
|
||||
|
||||
create: (e) =>
|
||||
|
@ -85,7 +85,7 @@ class App.WidgetTemplate extends App.Controller
|
|||
# get params
|
||||
form = @formParam($(e.target).closest('.content').find('.ticket-create'))
|
||||
params = @formParam(e.target)
|
||||
name = params['template_name']
|
||||
name = params['name']
|
||||
return if !name
|
||||
|
||||
template = App.Template.findByAttribute('name', name)
|
||||
|
@ -93,7 +93,7 @@ class App.WidgetTemplate extends App.Controller
|
|||
template = new App.Template
|
||||
|
||||
template.load(
|
||||
name: params['template_name']
|
||||
name: params['name']
|
||||
options: form
|
||||
)
|
||||
|
||||
|
@ -107,7 +107,7 @@ class App.WidgetTemplate extends App.Controller
|
|||
ui = @
|
||||
template.save(
|
||||
done: ->
|
||||
ui.template_id = @id
|
||||
ui.id = @id
|
||||
|
||||
fail: =>
|
||||
@log 'error', 'save failed!'
|
||||
|
|
|
@ -406,10 +406,12 @@ set new attributes of model (remove already available attributes)
|
|||
clear = true
|
||||
if param.clear is true || param.clear is false
|
||||
clear = param.clear
|
||||
if !@initFetchActive
|
||||
if !@initFetchActives && @count() is 0
|
||||
@initFetchActive = true
|
||||
@one 'refresh', (collection) ->
|
||||
@one('refresh', (collection) =>
|
||||
@initFetchActive = false
|
||||
callback(collection)
|
||||
)
|
||||
@fetchFull(
|
||||
->
|
||||
clear: clear
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
<div id="form-template"></div>
|
||||
</div>
|
||||
<div class="horizontal">
|
||||
<button type="submit" class="btn btn--action" data-type="template_delete"><%- @T('Delete') %></button>
|
||||
<button type="submit" class="btn btn--action align-right" data-type="template_select"><%- @T('Apply') %></button>
|
||||
<button type="submit" class="btn btn--action js-delete"><%- @T('Delete') %></button>
|
||||
<button type="submit" class="btn btn--action align-right js-apply"><%- @T('Apply') %></button>
|
||||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label class="" for="template_name"><%- @T('Save as template') %></label>
|
||||
<input type="text" name="template_name" id="template_name" class="form-control" value="<%= @template.name %>"/>
|
||||
<input type="text" name="name" id="template_name" class="form-control js-name" value="<%= @template.name %>"/>
|
||||
</div>
|
||||
<div class="horizontal">
|
||||
<button type="submit" class="btn btn--action align-right" data-type="template_save"><%- @T('Save') %></button>
|
||||
<button type="submit" class="btn btn--action align-right js-save"><%- @T('Save') %></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -25,5 +25,5 @@
|
|||
<p><%- @T('No template created yet.') %></p>
|
||||
<p><%- @T('With templates you can pre-fill ticket attributes.') %></p>
|
||||
<p><%- @T('Choose attributes and then save them as a new template.') %></p>
|
||||
<p><a class="create u-clickable"><%- @T('Save new template') %></a></p>
|
||||
<p><a class="js-create u-clickable"><%- @T('Save new template') %></a></p>
|
||||
</div>
|
||||
|
|
|
@ -24,6 +24,7 @@ if [ "$LEVEL" == '1' ]; then
|
|||
rm test/browser/agent_ticket_attachment_test.rb
|
||||
rm test/browser/agent_ticket_auto_assignment_test.rb
|
||||
rm test/browser/agent_ticket_create_reset_customer_selection_test.rb
|
||||
rm test/browser/agent_ticket_create_template_test.rb
|
||||
rm test/browser/agent_ticket_email_reply_keep_body_test.rb
|
||||
rm test/browser/agent_ticket_email_signature_test.rb
|
||||
rm test/browser/agent_ticket_link_test.rb
|
||||
|
@ -88,6 +89,7 @@ elif [ "$LEVEL" == '2' ]; then
|
|||
rm test/browser/agent_ticket_attachment_test.rb
|
||||
rm test/browser/agent_ticket_auto_assignment_test.rb
|
||||
rm test/browser/agent_ticket_create_reset_customer_selection_test.rb
|
||||
rm test/browser/agent_ticket_create_template_test.rb
|
||||
rm test/browser/agent_ticket_email_reply_keep_body_test.rb
|
||||
rm test/browser/agent_ticket_email_signature_test.rb
|
||||
rm test/browser/agent_ticket_link_test.rb
|
||||
|
@ -152,6 +154,7 @@ elif [ "$LEVEL" == '3' ]; then
|
|||
# test/browser/agent_ticket_attachment_test.rb
|
||||
# test/browser/agent_ticket_auto_assignment_test.rb
|
||||
# test/browser/agent_ticket_create_reset_customer_selection_test.rb
|
||||
# test/browser/agent_ticket_create_template_test.rb
|
||||
# test/browser/agent_ticket_email_reply_keep_body_test.rb
|
||||
# test/browser/agent_ticket_email_signature_test.rb
|
||||
# test/browser/agent_ticket_link_test.rb
|
||||
|
@ -216,6 +219,7 @@ elif [ "$LEVEL" == '4' ]; then
|
|||
rm test/browser/agent_ticket_attachment_test.rb
|
||||
rm test/browser/agent_ticket_auto_assignment_test.rb
|
||||
rm test/browser/agent_ticket_create_reset_customer_selection_test.rb
|
||||
rm test/browser/agent_ticket_create_template_test.rb
|
||||
rm test/browser/agent_ticket_email_reply_keep_body_test.rb
|
||||
rm test/browser/agent_ticket_email_signature_test.rb
|
||||
rm test/browser/agent_ticket_link_test.rb
|
||||
|
@ -279,6 +283,7 @@ elif [ "$LEVEL" == '5' ]; then
|
|||
rm test/browser/agent_ticket_attachment_test.rb
|
||||
rm test/browser/agent_ticket_auto_assignment_test.rb
|
||||
rm test/browser/agent_ticket_create_reset_customer_selection_test.rb
|
||||
rm test/browser/agent_ticket_create_template_test.rb
|
||||
rm test/browser/agent_ticket_email_reply_keep_body_test.rb
|
||||
rm test/browser/agent_ticket_email_signature_test.rb
|
||||
rm test/browser/agent_ticket_link_test.rb
|
||||
|
@ -345,6 +350,7 @@ elif [ "$LEVEL" == '6' ]; then
|
|||
rm test/browser/agent_ticket_attachment_test.rb
|
||||
rm test/browser/agent_ticket_auto_assignment_test.rb
|
||||
rm test/browser/agent_ticket_create_reset_customer_selection_test.rb
|
||||
rm test/browser/agent_ticket_create_template_test.rb
|
||||
rm test/browser/agent_ticket_email_reply_keep_body_test.rb
|
||||
rm test/browser/agent_ticket_email_signature_test.rb
|
||||
rm test/browser/agent_ticket_link_test.rb
|
||||
|
|
97
test/browser/agent_ticket_create_template_test.rb
Normal file
97
test/browser/agent_ticket_create_template_test.rb
Normal file
|
@ -0,0 +1,97 @@
|
|||
|
||||
require 'browser_test_helper'
|
||||
|
||||
# Regression test for UI bugfix
|
||||
# https://github.com/zammad/zammad/issues/1669
|
||||
#
|
||||
# After creating a new ticket template, logging out, and logging back in,
|
||||
# ensure that the template selection menu still contains the new entry.
|
||||
class AgentTicketCreateTemplateTest < TestCase
|
||||
def test_ticket_template_creation
|
||||
@browser = browser_instance
|
||||
login(
|
||||
username: 'agent1@example.com',
|
||||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all()
|
||||
|
||||
click(
|
||||
css: 'a[href="#ticket/create"]'
|
||||
)
|
||||
watch_for(
|
||||
css: '.active .templates-welcome',
|
||||
displayed: true
|
||||
)
|
||||
|
||||
set(
|
||||
css: 'input[name="title"]',
|
||||
value: 'my first ticket'
|
||||
)
|
||||
click(
|
||||
css: '.active .templates-welcome .js-create'
|
||||
)
|
||||
watch_for(
|
||||
css: '.active .templates-manage',
|
||||
displayed: true,
|
||||
timeout: 3,
|
||||
)
|
||||
exists_not(
|
||||
css: '.active .templates-manage select[name="id"] > option:not([value=""])'
|
||||
)
|
||||
|
||||
# save new template
|
||||
set(
|
||||
css: '.active .templates-manage .js-name',
|
||||
value: 'test template'
|
||||
)
|
||||
click(
|
||||
css: '.active .templates-manage .js-save'
|
||||
)
|
||||
exists(
|
||||
css: '.active .templates-manage select[name="id"] > option:not([value=""])',
|
||||
displayed: true
|
||||
)
|
||||
|
||||
# check if relogin temlates are still available
|
||||
logout
|
||||
login(
|
||||
username: 'agent1@example.com',
|
||||
password: 'test',
|
||||
)
|
||||
|
||||
click(
|
||||
css: '.navigation > .tasks > a.task'
|
||||
)
|
||||
exists(
|
||||
css: '.active .templates-manage',
|
||||
displayed: true
|
||||
)
|
||||
exists(
|
||||
css: '.active .templates-manage select[name="id"] > option:not([value=""])',
|
||||
displayed: true
|
||||
)
|
||||
|
||||
# apply new tempalte
|
||||
tasks_close_all()
|
||||
click(
|
||||
css: 'a[href="#ticket/create"]'
|
||||
)
|
||||
watch_for(
|
||||
css: '.active .templates-manage',
|
||||
displayed: true,
|
||||
timeout: 3,
|
||||
)
|
||||
select(
|
||||
css: '.active .templates-manage select[name="id"]',
|
||||
value: 'test template',
|
||||
)
|
||||
click(
|
||||
css: '.active .templates-manage .js-apply'
|
||||
)
|
||||
exists(
|
||||
css: '.active .newTicket input[name="title"]',
|
||||
value: 'my first ticket'
|
||||
)
|
||||
end
|
||||
end
|
|
@ -46,9 +46,7 @@ class TestCase < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def browser_instance
|
||||
if !@browsers
|
||||
@browsers = {}
|
||||
end
|
||||
@browsers ||= {}
|
||||
if ENV['REMOTE_URL'].blank?
|
||||
local_browser = Selenium::WebDriver.for(browser.to_sym, profile: profile)
|
||||
@browsers[local_browser.hash] = local_browser
|
||||
|
@ -138,7 +136,7 @@ class TestCase < Test::Unit::TestCase
|
|||
browser: browser1,
|
||||
username: 'someuser',
|
||||
password: 'somepassword',
|
||||
url: 'some url', # optional
|
||||
url: 'some url', # optional, in case of aleady opened brower a reload is done because url is called again
|
||||
remember_me: true, # optional
|
||||
auto_wizard: false, # optional, in case of auto wizard, skip login
|
||||
success: false, #optional
|
||||
|
|
Loading…
Reference in a new issue