Init version of object manager browser tests.
This commit is contained in:
parent
37317f2a42
commit
3cc4a8f3a3
9 changed files with 283 additions and 30 deletions
|
@ -38,7 +38,7 @@ class App.ControllerForm extends App.Controller
|
||||||
@form
|
@form
|
||||||
|
|
||||||
showAlert: (message) =>
|
showAlert: (message) =>
|
||||||
@form.find('.alert').removeClass('hide').html(App.i18n.translateContent(message))
|
@form.find('.alert').first().removeClass('hide').html(App.i18n.translateInline(message))
|
||||||
|
|
||||||
hideAlert: =>
|
hideAlert: =>
|
||||||
@form.find('.alert').addClass('hide').html()
|
@form.find('.alert').addClass('hide').html()
|
||||||
|
|
|
@ -54,7 +54,7 @@ class App.UiElement.object_manager_attribute extends App.UiElement.ApplicationUi
|
||||||
required: false
|
required: false
|
||||||
Agent:
|
Agent:
|
||||||
create_bottom:
|
create_bottom:
|
||||||
show: true
|
shown: true
|
||||||
required: false
|
required: false
|
||||||
edit:
|
edit:
|
||||||
shown: true
|
shown: true
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<div class="page-content">
|
<div class="page-content">
|
||||||
<% if !_.isEmpty(@itemsToChange): %>
|
<% if !_.isEmpty(@itemsToChange): %>
|
||||||
<div class="box box--message">
|
<div class="box box--message">
|
||||||
<h2>Database Update required</h2>
|
<h2><%- @T('Database Update required') %></h2>
|
||||||
<p>
|
<p>
|
||||||
<%- @T('Changes were made that require a database update.') %>
|
<%- @T('Changes were made that require a database update.') %>
|
||||||
<%- @T('This might take some time where the system can\'t be used.') %>
|
<%- @T('This might take some time where the system can\'t be used.') %>
|
||||||
|
@ -24,9 +24,9 @@
|
||||||
<% for item in @itemsToChange: %>
|
<% for item in @itemsToChange: %>
|
||||||
<li>
|
<li>
|
||||||
<% if item.to_create is true: %>
|
<% if item.to_create is true: %>
|
||||||
<%- @T('Create') %> <%= item.object %>.<%= item.name %> (<%= item.data_type %>)
|
<%- @T('Create') %>: <%= item.object %>.<%= item.name %> (<%= item.data_type %>)
|
||||||
<% else if item.to_delete is true: %>
|
<% else if item.to_delete is true: %>
|
||||||
<%- @T('Delete') %> <%= item.object %>.<%= item.name %> (<%= item.data_type %>)
|
<%- @T('Delete') %>: <%= item.object %>.<%= item.name %> (<%= item.data_type %>)
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<%= screen %>
|
<%= screen %>
|
||||||
<td class="settings-list-row-control">
|
<td class="settings-list-row-control">
|
||||||
<% for key, defaultValue of options: %>
|
<% for key, defaultValue of options: %>
|
||||||
<%= @T(key) %>: <input name="{boolean}screens::<%= screen %>::<%= role %>::<%= key %>" type="checkbox" <% if (@init && defaultValue is true) || (@params && @params.screens && @params.screens[screen] && @params.screens[screen][role] && @params.screens[screen][role][key] is true) : %>checked<% end %> value="true">
|
<%- @T(key) %>: <input name="{boolean}screens::<%= screen %>::<%= role %>::<%= key %>" type="checkbox" <% if (@init && defaultValue is true) || (@params && @params.screens && @params.screens[screen] && @params.screens[screen][role] && @params.screens[screen][role][key] is true) : %>checked<% end %> value="true">
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -27,6 +27,18 @@ class ObjectManagerAttributesController < ApplicationController
|
||||||
def create
|
def create
|
||||||
return if deny_if_not_role(Z_ROLENAME_ADMIN)
|
return if deny_if_not_role(Z_ROLENAME_ADMIN)
|
||||||
check_params
|
check_params
|
||||||
|
|
||||||
|
# check if attribute already exists
|
||||||
|
exists = ObjectManager::Attribute.get(
|
||||||
|
object: params[:object],
|
||||||
|
name: params[:name],
|
||||||
|
)
|
||||||
|
if exists
|
||||||
|
render json: model_match_error('already exists'), status: :unprocessable_entity
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
object_manager_attribute = ObjectManager::Attribute.add(
|
object_manager_attribute = ObjectManager::Attribute.add(
|
||||||
object: params[:object],
|
object: params[:object],
|
||||||
name: params[:name],
|
name: params[:name],
|
||||||
|
@ -39,12 +51,18 @@ class ObjectManagerAttributesController < ApplicationController
|
||||||
editable: true,
|
editable: true,
|
||||||
)
|
)
|
||||||
render json: object_manager_attribute.attributes_with_associations, status: :created
|
render json: object_manager_attribute.attributes_with_associations, status: :created
|
||||||
|
rescue => e
|
||||||
|
logger.error e.message
|
||||||
|
logger.error e.backtrace.inspect
|
||||||
|
render json: model_match_error(e.message), status: :unprocessable_entity
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /object_manager_attributes/1
|
# PUT /object_manager_attributes/1
|
||||||
def update
|
def update
|
||||||
return if deny_if_not_role(Z_ROLENAME_ADMIN)
|
return if deny_if_not_role(Z_ROLENAME_ADMIN)
|
||||||
check_params
|
check_params
|
||||||
|
begin
|
||||||
object_manager_attribute = ObjectManager::Attribute.add(
|
object_manager_attribute = ObjectManager::Attribute.add(
|
||||||
object: params[:object],
|
object: params[:object],
|
||||||
name: params[:name],
|
name: params[:name],
|
||||||
|
@ -57,6 +75,11 @@ class ObjectManagerAttributesController < ApplicationController
|
||||||
editable: true,
|
editable: true,
|
||||||
)
|
)
|
||||||
render json: object_manager_attribute.attributes_with_associations, status: :ok
|
render json: object_manager_attribute.attributes_with_associations, status: :ok
|
||||||
|
rescue => e
|
||||||
|
logger.error e.message
|
||||||
|
logger.error e.backtrace.inspect
|
||||||
|
render json: model_match_error(e.message), status: :unprocessable_entity
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DELETE /object_manager_attributes/1
|
# DELETE /object_manager_attributes/1
|
||||||
|
|
|
@ -490,10 +490,15 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_name
|
def check_name
|
||||||
if name
|
return if !name
|
||||||
return true if name !~ /_(id|ids)$/i && name !~ /^id$/i && name !~ /\s/
|
if name =~ /_(id|ids)$/i || name =~ /^id$/i
|
||||||
|
raise 'Name can\'t get used, *_id and *_ids are not allowed'
|
||||||
|
elsif name =~ /\s/
|
||||||
|
raise 'Spaces in name are not allowed'
|
||||||
|
elsif name !~ /^[a-z0-9_]+$/
|
||||||
|
raise 'Only letters from a-z, numbers from 0-9, and _ are allowed'
|
||||||
end
|
end
|
||||||
raise "Name can't get used, *_id and *_ids are not allowed"
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_editable
|
def check_editable
|
||||||
|
|
|
@ -10,6 +10,7 @@ if [ "$LEVEL" == '1' ]; then
|
||||||
# test/browser/aac_basic_richtext_test.rb
|
# test/browser/aac_basic_richtext_test.rb
|
||||||
# test/browser/abb_one_group_test.rb
|
# test/browser/abb_one_group_test.rb
|
||||||
rm test/browser/admin_channel_email_test.rb
|
rm test/browser/admin_channel_email_test.rb
|
||||||
|
rm test/browser/admin_object_manager_test.rb
|
||||||
rm test/browser/admin_overview_test.rb
|
rm test/browser/admin_overview_test.rb
|
||||||
# test/browser/agent_navigation_and_title_test.rb
|
# test/browser/agent_navigation_and_title_test.rb
|
||||||
rm test/browser/agent_ticket_actions_level0_test.rb
|
rm test/browser/agent_ticket_actions_level0_test.rb
|
||||||
|
@ -51,6 +52,7 @@ elif [ "$LEVEL" == '2' ]; then
|
||||||
rm test/browser/aac_basic_richtext_test.rb
|
rm test/browser/aac_basic_richtext_test.rb
|
||||||
# test/browser/abb_one_group_test.rb
|
# test/browser/abb_one_group_test.rb
|
||||||
rm test/browser/admin_channel_email_test.rb
|
rm test/browser/admin_channel_email_test.rb
|
||||||
|
rm test/browser/admin_object_manager_test.rb
|
||||||
rm test/browser/admin_overview_test.rb
|
rm test/browser/admin_overview_test.rb
|
||||||
rm test/browser/agent_navigation_and_title_test.rb
|
rm test/browser/agent_navigation_and_title_test.rb
|
||||||
rm test/browser/agent_organization_profile_test.rb
|
rm test/browser/agent_organization_profile_test.rb
|
||||||
|
@ -93,6 +95,7 @@ elif [ "$LEVEL" == '3' ]; then
|
||||||
rm test/browser/aac_basic_richtext_test.rb
|
rm test/browser/aac_basic_richtext_test.rb
|
||||||
# test/browser/abb_one_group_test.rb
|
# test/browser/abb_one_group_test.rb
|
||||||
rm test/browser/admin_channel_email_test.rb
|
rm test/browser/admin_channel_email_test.rb
|
||||||
|
rm test/browser/admin_object_manager_test.rb
|
||||||
rm test/browser/admin_overview_test.rb
|
rm test/browser/admin_overview_test.rb
|
||||||
rm test/browser/agent_navigation_and_title_test.rb
|
rm test/browser/agent_navigation_and_title_test.rb
|
||||||
rm test/browser/agent_organization_profile_test.rb
|
rm test/browser/agent_organization_profile_test.rb
|
||||||
|
@ -135,6 +138,7 @@ elif [ "$LEVEL" == '4' ]; then
|
||||||
rm test/browser/aac_basic_richtext_test.rb
|
rm test/browser/aac_basic_richtext_test.rb
|
||||||
# test/browser/abb_one_group_test.rb
|
# test/browser/abb_one_group_test.rb
|
||||||
rm test/browser/admin_channel_email_test.rb
|
rm test/browser/admin_channel_email_test.rb
|
||||||
|
rm test/browser/admin_object_manager_test.rb
|
||||||
rm test/browser/admin_overview_test.rb
|
rm test/browser/admin_overview_test.rb
|
||||||
rm test/browser/agent_navigation_and_title_test.rb
|
rm test/browser/agent_navigation_and_title_test.rb
|
||||||
rm test/browser/agent_organization_profile_test.rb
|
rm test/browser/agent_organization_profile_test.rb
|
||||||
|
@ -177,6 +181,7 @@ elif [ "$LEVEL" == '5' ]; then
|
||||||
rm test/browser/aac_basic_richtext_test.rb
|
rm test/browser/aac_basic_richtext_test.rb
|
||||||
# test/browser/abb_one_group_test.rb
|
# test/browser/abb_one_group_test.rb
|
||||||
# test/browser/admin_channel_email_test.rb
|
# test/browser/admin_channel_email_test.rb
|
||||||
|
# test/browser/admin_object_manager_test.rb
|
||||||
# test/browser/admin_overview_test.rb
|
# test/browser/admin_overview_test.rb
|
||||||
rm test/browser/agent_navigation_and_title_test.rb
|
rm test/browser/agent_navigation_and_title_test.rb
|
||||||
# test/browser/agent_organization_profile_test.rb
|
# test/browser/agent_organization_profile_test.rb
|
||||||
|
|
157
test/browser/admin_object_manager_test.rb
Normal file
157
test/browser/admin_object_manager_test.rb
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
require 'browser_test_helper'
|
||||||
|
|
||||||
|
class AdminObjectManagerTest < TestCase
|
||||||
|
def test_basic
|
||||||
|
name = "some overview #{rand(99_999_999)}"
|
||||||
|
|
||||||
|
@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="#system/object_manager"]')
|
||||||
|
|
||||||
|
click(css: '#content .js-new')
|
||||||
|
|
||||||
|
modal_ready()
|
||||||
|
|
||||||
|
# already existing
|
||||||
|
set(
|
||||||
|
css: '.modal input[name="name"]',
|
||||||
|
value: 'customer_id',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
css: '.modal input[name="display"]',
|
||||||
|
value: 'Customer Should Not Creatable',
|
||||||
|
)
|
||||||
|
click(css: '.modal button.js-submit')
|
||||||
|
sleep 4
|
||||||
|
watch_for(
|
||||||
|
css: '.modal',
|
||||||
|
value: '(already exists)',
|
||||||
|
)
|
||||||
|
|
||||||
|
# invalid name
|
||||||
|
set(
|
||||||
|
css: '.modal input[name="name"]',
|
||||||
|
value: 'some_other_id',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
css: '.modal input[name="display"]',
|
||||||
|
value: 'Should Not Creatable',
|
||||||
|
)
|
||||||
|
click(css: '.modal button.js-submit')
|
||||||
|
sleep 4
|
||||||
|
watch_for(
|
||||||
|
css: '.modal',
|
||||||
|
value: '(are not allowed)',
|
||||||
|
)
|
||||||
|
|
||||||
|
# invalid name
|
||||||
|
set(
|
||||||
|
css: '.modal input[name="name"]',
|
||||||
|
value: 'some_other_ids',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
css: '.modal input[name="display"]',
|
||||||
|
value: 'Should Not Creatable',
|
||||||
|
)
|
||||||
|
click(css: '.modal button.js-submit')
|
||||||
|
sleep 4
|
||||||
|
watch_for(
|
||||||
|
css: '.modal',
|
||||||
|
value: '(are not allowed)',
|
||||||
|
)
|
||||||
|
|
||||||
|
# invalid name
|
||||||
|
set(
|
||||||
|
css: '.modal input[name="name"]',
|
||||||
|
value: 'some spaces',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
css: '.modal input[name="display"]',
|
||||||
|
value: 'Should Not Creatable',
|
||||||
|
)
|
||||||
|
click(css: '.modal button.js-submit')
|
||||||
|
sleep 4
|
||||||
|
watch_for(
|
||||||
|
css: '.modal',
|
||||||
|
value: '(are not allowed)',
|
||||||
|
)
|
||||||
|
click(css: '.modal .js-close')
|
||||||
|
modal_ready()
|
||||||
|
|
||||||
|
# valid name
|
||||||
|
click(css: '#content .js-new')
|
||||||
|
modal_ready()
|
||||||
|
set(
|
||||||
|
css: '.modal input[name="name"]',
|
||||||
|
value: 'browser_test1',
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
css: '.modal input[name="display"]',
|
||||||
|
value: 'Browser Test 1',
|
||||||
|
)
|
||||||
|
click(css: '.modal button.js-submit')
|
||||||
|
watch_for(
|
||||||
|
css: '#content table',
|
||||||
|
value: 'browser_test1',
|
||||||
|
)
|
||||||
|
watch_for(
|
||||||
|
css: '#content',
|
||||||
|
value: 'Database Update required',
|
||||||
|
)
|
||||||
|
click(css: '#content .tab-pane.active div.js-execute')
|
||||||
|
watch_for(
|
||||||
|
css: '.modal',
|
||||||
|
value: 'New Version',
|
||||||
|
)
|
||||||
|
click(css: '.modal button.js-submit')
|
||||||
|
|
||||||
|
# create new ticket
|
||||||
|
|
||||||
|
# update ticket
|
||||||
|
|
||||||
|
# discard new attribute
|
||||||
|
|
||||||
|
watch_for(
|
||||||
|
css: '#content table',
|
||||||
|
value: 'browser_test1',
|
||||||
|
)
|
||||||
|
match_not(
|
||||||
|
css: '#content',
|
||||||
|
value: 'Database Update required',
|
||||||
|
)
|
||||||
|
click(css: '#content .tab-pane.active table tbody tr:last-child .js-delete')
|
||||||
|
sleep 4
|
||||||
|
watch_for(
|
||||||
|
css: '#content',
|
||||||
|
value: 'Database Update required',
|
||||||
|
)
|
||||||
|
watch_for(
|
||||||
|
css: '#content table',
|
||||||
|
value: 'browser_test1',
|
||||||
|
)
|
||||||
|
click(css: '#content .tab-pane.active div.js-execute')
|
||||||
|
watch_for(
|
||||||
|
css: '.modal',
|
||||||
|
value: 'New Version',
|
||||||
|
)
|
||||||
|
click(css: '.modal button.js-submit')
|
||||||
|
sleep 5
|
||||||
|
match_not(
|
||||||
|
css: '#content',
|
||||||
|
value: 'Database Update required',
|
||||||
|
)
|
||||||
|
match_not(
|
||||||
|
css: '#content table',
|
||||||
|
value: 'browser_test1',
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -305,6 +305,69 @@ class ObjectManagerTest < ActiveSupport::TestCase
|
||||||
}
|
}
|
||||||
assert_equal(false, ObjectManager::Attribute.pending_migration?)
|
assert_equal(false, ObjectManager::Attribute.pending_migration?)
|
||||||
|
|
||||||
|
assert_raises(RuntimeError) {
|
||||||
|
attribute13 = ObjectManager::Attribute.add(
|
||||||
|
object: 'Ticket',
|
||||||
|
name: 'test13|',
|
||||||
|
display: 'Test 13',
|
||||||
|
data_type: 'date',
|
||||||
|
data_option: {
|
||||||
|
future: true,
|
||||||
|
past: false,
|
||||||
|
diff: 24,
|
||||||
|
null: true,
|
||||||
|
},
|
||||||
|
active: true,
|
||||||
|
screens: {},
|
||||||
|
position: 20,
|
||||||
|
created_by_id: 1,
|
||||||
|
updated_by_id: 1,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
assert_equal(false, ObjectManager::Attribute.pending_migration?)
|
||||||
|
|
||||||
|
assert_raises(RuntimeError) {
|
||||||
|
attribute14 = ObjectManager::Attribute.add(
|
||||||
|
object: 'Ticket',
|
||||||
|
name: 'test14!',
|
||||||
|
display: 'Test 14',
|
||||||
|
data_type: 'date',
|
||||||
|
data_option: {
|
||||||
|
future: true,
|
||||||
|
past: false,
|
||||||
|
diff: 24,
|
||||||
|
null: true,
|
||||||
|
},
|
||||||
|
active: true,
|
||||||
|
screens: {},
|
||||||
|
position: 20,
|
||||||
|
created_by_id: 1,
|
||||||
|
updated_by_id: 1,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
assert_equal(false, ObjectManager::Attribute.pending_migration?)
|
||||||
|
|
||||||
|
assert_raises(RuntimeError) {
|
||||||
|
attribute15 = ObjectManager::Attribute.add(
|
||||||
|
object: 'Ticket',
|
||||||
|
name: 'test15ä',
|
||||||
|
display: 'Test 15',
|
||||||
|
data_type: 'date',
|
||||||
|
data_option: {
|
||||||
|
future: true,
|
||||||
|
past: false,
|
||||||
|
diff: 24,
|
||||||
|
null: true,
|
||||||
|
},
|
||||||
|
active: true,
|
||||||
|
screens: {},
|
||||||
|
position: 20,
|
||||||
|
created_by_id: 1,
|
||||||
|
updated_by_id: 1,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
assert_equal(false, ObjectManager::Attribute.pending_migration?)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'b object manager attribute' do
|
test 'b object manager attribute' do
|
||||||
|
|
Loading…
Reference in a new issue