Added support for admin form preview also for admins if feature is disabled.
This commit is contained in:
parent
0c4bf9f5ca
commit
57a7e25cf1
4 changed files with 130 additions and 39 deletions
|
@ -48,6 +48,7 @@ class App.ChannelForm extends App.ControllerSubContent
|
||||||
@$('.js-modal-params').html(paramString)
|
@$('.js-modal-params').html(paramString)
|
||||||
|
|
||||||
# rebuild preview
|
# rebuild preview
|
||||||
|
params.test = true
|
||||||
if params.modal
|
if params.modal
|
||||||
@$('.js-formInline').addClass('hide')
|
@$('.js-formInline').addClass('hide')
|
||||||
@$('.js-formBtn').removeClass('hide')
|
@$('.js-formBtn').removeClass('hide')
|
||||||
|
|
|
@ -16,6 +16,10 @@ class FormController < ApplicationController
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if params[:test] && current_user && current_user.permissions?('admin.channel_formular')
|
||||||
|
config[:enabled] = true
|
||||||
|
end
|
||||||
|
|
||||||
render json: config, status: :ok
|
render json: config, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -115,6 +119,7 @@ class FormController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def enabled?
|
def enabled?
|
||||||
|
return true if params[:test] && current_user && current_user.permissions?('admin.channel_formular')
|
||||||
return true if Setting.get('form_ticket_create')
|
return true if Setting.get('form_ticket_create')
|
||||||
response_access_deny
|
response_access_deny
|
||||||
false
|
false
|
||||||
|
|
|
@ -105,7 +105,8 @@ $(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin.prototype.init = function () {
|
Plugin.prototype.init = function () {
|
||||||
var _this = this
|
var _this = this,
|
||||||
|
params = {}
|
||||||
|
|
||||||
_this.log('debug', 'init', this._src)
|
_this.log('debug', 'init', this._src)
|
||||||
|
|
||||||
|
@ -117,8 +118,12 @@ $(function() {
|
||||||
_this.log('debug', 'endpoint_submit: ' + _this.endpoint_submit)
|
_this.log('debug', 'endpoint_submit: ' + _this.endpoint_submit)
|
||||||
|
|
||||||
// load config
|
// load config
|
||||||
|
if (this.options.test) {
|
||||||
|
params.test = true
|
||||||
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: _this.endpoint_config,
|
url: _this.endpoint_config,
|
||||||
|
data: params
|
||||||
}).done(function(data) {
|
}).done(function(data) {
|
||||||
_this.log('debug', 'config:', data)
|
_this.log('debug', 'config:', data)
|
||||||
_this._config = data
|
_this._config = data
|
||||||
|
@ -216,6 +221,10 @@ $(function() {
|
||||||
if (!params.title) {
|
if (!params.title) {
|
||||||
params.title = this.options.messageTitle
|
params.title = this.options.messageTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.options.test) {
|
||||||
|
params.test = true
|
||||||
|
}
|
||||||
_this.log('debug', 'params', params)
|
_this.log('debug', 'params', params)
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,82 @@ class FormTest < TestCase
|
||||||
type: 'off',
|
type: 'off',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# admin preview test
|
||||||
|
sleep 1
|
||||||
|
click(
|
||||||
|
browser: agent,
|
||||||
|
css: '.content.active .js-formBtn',
|
||||||
|
)
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
set(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal [name="name"]',
|
||||||
|
value: 'some sender',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal [name="body"]',
|
||||||
|
value: '',
|
||||||
|
)
|
||||||
|
click(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
|
)
|
||||||
|
exists(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal .has-error [name="body"]',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal [name="body"]',
|
||||||
|
value: 'new body',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal [name="email"]',
|
||||||
|
value: 'somebody@notexistinginanydomainspacealsonothere.nowhere',
|
||||||
|
)
|
||||||
|
click(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
|
)
|
||||||
|
exists(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal .has-error [name="email"]',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal [name="email"]',
|
||||||
|
value: 'notexistinginanydomainspacealsonothere@znuny.com',
|
||||||
|
)
|
||||||
|
click(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
|
)
|
||||||
|
exists(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal .has-error [name="email"]',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal [name="email"]',
|
||||||
|
value: 'discard@znuny.com',
|
||||||
|
)
|
||||||
|
click(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
|
)
|
||||||
|
watch_for(
|
||||||
|
browser: agent,
|
||||||
|
css: 'body div.zammad-form-modal',
|
||||||
|
value: 'Thank you for your inquiry',
|
||||||
|
)
|
||||||
|
# click on backgroud (not on thank you dialog)
|
||||||
|
element = agent.find_elements({ css: 'body div.zammad-form-modal' })[0]
|
||||||
|
agent.action.move_to(element, 200, 200).perform
|
||||||
|
agent.action.click.perform
|
||||||
|
|
||||||
customer = browser_instance
|
customer = browser_instance
|
||||||
location(
|
location(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
|
@ -59,7 +135,7 @@ class FormTest < TestCase
|
||||||
|
|
||||||
exists_not(
|
exists_not(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal',
|
css: 'body div.zammad-form-modal',
|
||||||
)
|
)
|
||||||
|
|
||||||
# modal dialog
|
# modal dialog
|
||||||
|
@ -69,28 +145,28 @@ class FormTest < TestCase
|
||||||
)
|
)
|
||||||
exists(
|
exists(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal',
|
css: 'body div.zammad-form-modal',
|
||||||
)
|
)
|
||||||
|
|
||||||
# fill form valid data - but too fast
|
# fill form valid data - but too fast
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="name"]',
|
css: 'body div.zammad-form-modal [name="name"]',
|
||||||
value: 'some name',
|
value: 'some name',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="email"]',
|
css: 'body div.zammad-form-modal [name="email"]',
|
||||||
value: 'discard@znuny.com',
|
value: 'discard@znuny.com',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="body"]',
|
css: 'body div.zammad-form-modal [name="body"]',
|
||||||
value: "some text\nnew line",
|
value: "some text\nnew line",
|
||||||
)
|
)
|
||||||
click(
|
click(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal button[type="submit"]',
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
)
|
)
|
||||||
|
|
||||||
# check warning
|
# check warning
|
||||||
|
@ -101,54 +177,54 @@ class FormTest < TestCase
|
||||||
# fill form invalid data - within correct time
|
# fill form invalid data - within correct time
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="name"]',
|
css: 'body div.zammad-form-modal [name="name"]',
|
||||||
value: 'some name',
|
value: 'some name',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="email"]',
|
css: 'body div.zammad-form-modal [name="email"]',
|
||||||
value: 'invalid_email',
|
value: 'invalid_email',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="body"]',
|
css: 'body div.zammad-form-modal [name="body"]',
|
||||||
value: "some text\nnew line",
|
value: "some text\nnew line",
|
||||||
)
|
)
|
||||||
click(
|
click(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal button[type="submit"]',
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
)
|
)
|
||||||
sleep 10
|
sleep 10
|
||||||
exists(
|
exists(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal',
|
css: 'body div.zammad-form-modal',
|
||||||
)
|
)
|
||||||
|
|
||||||
# fill form valid data
|
# fill form valid data
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="email"]',
|
css: 'body div.zammad-form-modal [name="email"]',
|
||||||
value: 'discard@znuny.com',
|
value: 'discard@znuny.com',
|
||||||
)
|
)
|
||||||
click(
|
click(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal button[type="submit"]',
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
)
|
)
|
||||||
watch_for(
|
watch_for(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal',
|
css: 'body div.zammad-form-modal',
|
||||||
value: 'Thank you for your inquiry',
|
value: 'Thank you for your inquiry',
|
||||||
)
|
)
|
||||||
|
|
||||||
# click on backgroud (not on thank you dialog)
|
# click on backgroud (not on thank you dialog)
|
||||||
element = customer.find_elements({ css: 'body div.modal' })[0]
|
element = customer.find_elements({ css: 'body div.zammad-form-modal' })[0]
|
||||||
customer.action.move_to(element, 200, 200).perform
|
customer.action.move_to(element, 200, 200).perform
|
||||||
customer.action.click.perform
|
customer.action.click.perform
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
exists_not(
|
exists_not(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal',
|
css: 'body div.zammad-form-modal',
|
||||||
)
|
)
|
||||||
|
|
||||||
# fill form invalid data - within correct time
|
# fill form invalid data - within correct time
|
||||||
|
@ -159,100 +235,100 @@ class FormTest < TestCase
|
||||||
sleep 10
|
sleep 10
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="name"]',
|
css: 'body div.zammad-form-modal [name="name"]',
|
||||||
value: '',
|
value: '',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="email"]',
|
css: 'body div.zammad-form-modal [name="email"]',
|
||||||
value: 'discard@znuny.com',
|
value: 'discard@znuny.com',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="body"]',
|
css: 'body div.zammad-form-modal [name="body"]',
|
||||||
value: "some text\nnew line",
|
value: "some text\nnew line",
|
||||||
)
|
)
|
||||||
click(
|
click(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal button[type="submit"]',
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
)
|
)
|
||||||
exists(
|
exists(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal .has-error [name="name"]',
|
css: 'body div.zammad-form-modal .has-error [name="name"]',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="name"]',
|
css: 'body div.zammad-form-modal [name="name"]',
|
||||||
value: 'some sender',
|
value: 'some sender',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="body"]',
|
css: 'body div.zammad-form-modal [name="body"]',
|
||||||
value: '',
|
value: '',
|
||||||
)
|
)
|
||||||
click(
|
click(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal button[type="submit"]',
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
)
|
)
|
||||||
exists(
|
exists(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal .has-error [name="body"]',
|
css: 'body div.zammad-form-modal .has-error [name="body"]',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="body"]',
|
css: 'body div.zammad-form-modal [name="body"]',
|
||||||
value: 'new body',
|
value: 'new body',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="email"]',
|
css: 'body div.zammad-form-modal [name="email"]',
|
||||||
value: 'somebody@notexistinginanydomainspacealsonothere.nowhere',
|
value: 'somebody@notexistinginanydomainspacealsonothere.nowhere',
|
||||||
)
|
)
|
||||||
click(
|
click(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal button[type="submit"]',
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
)
|
)
|
||||||
exists(
|
exists(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal .has-error [name="email"]',
|
css: 'body div.zammad-form-modal .has-error [name="email"]',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="email"]',
|
css: 'body div.zammad-form-modal [name="email"]',
|
||||||
value: 'notexistinginanydomainspacealsonothere@znuny.com',
|
value: 'notexistinginanydomainspacealsonothere@znuny.com',
|
||||||
)
|
)
|
||||||
click(
|
click(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal button[type="submit"]',
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
)
|
)
|
||||||
exists(
|
exists(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal .has-error [name="email"]',
|
css: 'body div.zammad-form-modal .has-error [name="email"]',
|
||||||
)
|
)
|
||||||
set(
|
set(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal [name="email"]',
|
css: 'body div.zammad-form-modal [name="email"]',
|
||||||
value: 'discard@znuny.com',
|
value: 'discard@znuny.com',
|
||||||
)
|
)
|
||||||
click(
|
click(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal button[type="submit"]',
|
css: 'body div.zammad-form-modal button[type="submit"]',
|
||||||
)
|
)
|
||||||
watch_for(
|
watch_for(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal',
|
css: 'body div.zammad-form-modal',
|
||||||
value: 'Thank you for your inquiry',
|
value: 'Thank you for your inquiry',
|
||||||
)
|
)
|
||||||
|
|
||||||
# click on backgroud (not on thank you dialog)
|
# click on backgroud (not on thank you dialog)
|
||||||
element = customer.find_elements({ css: 'body div.modal' })[0]
|
element = customer.find_elements({ css: 'body div.zammad-form-modal' })[0]
|
||||||
customer.action.move_to(element, 200, 200).perform
|
customer.action.move_to(element, 200, 200).perform
|
||||||
customer.action.click.perform
|
customer.action.click.perform
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
exists_not(
|
exists_not(
|
||||||
browser: customer,
|
browser: customer,
|
||||||
css: 'body div.modal',
|
css: 'body div.zammad-form-modal',
|
||||||
)
|
)
|
||||||
|
|
||||||
# inline form
|
# inline form
|
||||||
|
|
Loading…
Reference in a new issue