Fixes #1591 Drag&Drop groups empty
This commit is contained in:
parent
c3ad7e307b
commit
498980b52c
6 changed files with 140 additions and 2 deletions
|
@ -90,6 +90,7 @@ class Index extends App.ControllerSubContent
|
|||
item = App.User.find(id)
|
||||
|
||||
rerender = =>
|
||||
App.Group.fetch()
|
||||
@renderResult(user_ids)
|
||||
|
||||
new App.ControllerGenericEdit(
|
||||
|
|
|
@ -817,8 +817,6 @@ returns
|
|||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def cache_delete
|
||||
super
|
||||
|
||||
|
@ -831,6 +829,8 @@ returns
|
|||
Cache.delete(key)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_name
|
||||
if firstname.present?
|
||||
firstname.strip!
|
||||
|
|
|
@ -10,4 +10,16 @@ class UserGroup < ApplicationModel
|
|||
def self.ref_key
|
||||
:user_id
|
||||
end
|
||||
|
||||
def cache_update
|
||||
group.cache_update(nil)
|
||||
user.cache_update(nil)
|
||||
super
|
||||
end
|
||||
|
||||
def cache_delete
|
||||
group.cache_update(nil)
|
||||
user.cache_update(nil)
|
||||
super
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,7 @@ if [ "$LEVEL" == '1' ]; then
|
|||
rm test/browser/abb_one_group_test.rb
|
||||
rm test/browser/admin_channel_email_test.rb
|
||||
rm test/browser/admin_calendar_sla_test.rb
|
||||
rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
rm test/browser/admin_object_manager_test.rb
|
||||
rm test/browser/admin_object_manager_tree_select_test.rb
|
||||
rm test/browser/admin_overview_test.rb
|
||||
|
@ -86,6 +87,7 @@ elif [ "$LEVEL" == '2' ]; then
|
|||
# test/browser/abb_one_group_test.rb
|
||||
rm test/browser/admin_channel_email_test.rb
|
||||
rm test/browser/admin_calendar_sla_test.rb
|
||||
rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
rm test/browser/admin_object_manager_test.rb
|
||||
rm test/browser/admin_object_manager_tree_select_test.rb
|
||||
rm test/browser/admin_overview_test.rb
|
||||
|
@ -156,6 +158,7 @@ elif [ "$LEVEL" == '3' ]; then
|
|||
# test/browser/abb_one_group_test.rb
|
||||
rm test/browser/admin_channel_email_test.rb
|
||||
rm test/browser/admin_calendar_sla_test.rb
|
||||
rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
rm test/browser/admin_object_manager_test.rb
|
||||
rm test/browser/admin_object_manager_tree_select_test.rb
|
||||
rm test/browser/admin_overview_test.rb
|
||||
|
@ -226,6 +229,7 @@ elif [ "$LEVEL" == '4' ]; then
|
|||
# test/browser/abb_one_group_test.rb
|
||||
rm test/browser/admin_channel_email_test.rb
|
||||
rm test/browser/admin_calendar_sla_test.rb
|
||||
rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
rm test/browser/admin_object_manager_test.rb
|
||||
rm test/browser/admin_object_manager_tree_select_test.rb
|
||||
rm test/browser/admin_overview_test.rb
|
||||
|
@ -295,6 +299,7 @@ elif [ "$LEVEL" == '5' ]; then
|
|||
# test/browser/abb_one_group_test.rb
|
||||
# test/browser/admin_channel_email_test.rb
|
||||
# test/browser/admin_calendar_sla_test.rb
|
||||
# rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
# test/browser/admin_object_manager_test.rb
|
||||
# test/browser/admin_object_manager_tree_select_test.rb
|
||||
# test/browser/admin_overview_test.rb
|
||||
|
@ -367,6 +372,7 @@ elif [ "$LEVEL" == '6' ]; then
|
|||
rm test/browser/abb_one_group_test.rb
|
||||
rm test/browser/admin_channel_email_test.rb
|
||||
rm test/browser/admin_calendar_sla_test.rb
|
||||
rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
rm test/browser/admin_object_manager_test.rb
|
||||
rm test/browser/admin_object_manager_tree_select_test.rb
|
||||
rm test/browser/admin_overview_test.rb
|
||||
|
|
89
test/browser/admin_drag_drop_to_new_group_test.rb
Normal file
89
test/browser/admin_drag_drop_to_new_group_test.rb
Normal file
|
@ -0,0 +1,89 @@
|
|||
require 'browser_test_helper'
|
||||
|
||||
class AdminDragDropToNewGroupTest < TestCase
|
||||
def test_new_group
|
||||
new_group_name = "d_n_d_group#{rand(99_999_999)}"
|
||||
@browser = browser_instance
|
||||
login(
|
||||
username: 'master@example.com',
|
||||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all()
|
||||
|
||||
click(css: '.user-menu a[title=Admin')
|
||||
click(css: '.content.active a[href="#manage/groups"]')
|
||||
click(css: '.content.active a[data-type="new"]')
|
||||
|
||||
modal_ready
|
||||
|
||||
element = @browser.find_element(css: '.modal input[name=name]')
|
||||
element.clear
|
||||
element.send_keys(new_group_name)
|
||||
click(css: '.modal button.js-submit')
|
||||
|
||||
sleep(1)
|
||||
|
||||
click(css: '.content.active a[href="#manage/users"]')
|
||||
|
||||
user_css = '.user-list .js-tableBody tr td'
|
||||
watch_for(css: user_css)
|
||||
click(css: user_css)
|
||||
|
||||
modal_ready
|
||||
|
||||
scroll_script = "var el = document.getElementsByClassName('modal')[0];"
|
||||
scroll_script += 'el.scrollTo(0, el.scrollHeight);'
|
||||
|
||||
@browser.execute_script scroll_script
|
||||
|
||||
group = @browser.find_elements(css: '.modal .settings-list tbody tr').find do |el|
|
||||
el.find_element(css: 'td').text == new_group_name
|
||||
end
|
||||
|
||||
assert_not_nil(group)
|
||||
|
||||
checkbox = group.find_element(css: 'input[value=full]')
|
||||
|
||||
@browser
|
||||
.action
|
||||
.move_to(checkbox, 0, 10)
|
||||
.click
|
||||
.perform
|
||||
|
||||
click(css: '.modal button.js-submit')
|
||||
|
||||
sleep(1)
|
||||
|
||||
click(css: '.menu-item[href="#ticket/view"]')
|
||||
click(css: '.overview-header .tabsHolder a.tab[href="#ticket/view/all_unassigned"]')
|
||||
|
||||
element = @browser.find_element(css: '.js-tableBody .item')
|
||||
|
||||
@browser
|
||||
.action
|
||||
.click_and_hold(element)
|
||||
.move_by(100, 100)
|
||||
.perform
|
||||
|
||||
sleep(1)
|
||||
|
||||
@browser
|
||||
.action
|
||||
.move_to(@browser.find_element(css: '.js-batch-assign-circle'))
|
||||
.perform
|
||||
|
||||
sleep(1)
|
||||
|
||||
group_containers = @browser.find_elements(css: '.batch-overlay-assign-entry[data-action=group_assign]')
|
||||
|
||||
new_group_container = group_containers.find do |g|
|
||||
g.find_element(css: '.batch-overlay-assign-entry-name').text.downcase == new_group_name
|
||||
end
|
||||
|
||||
assert_not_nil new_group_container
|
||||
|
||||
group_description = new_group_container.find_element(css: '.batch-overlay-assign-entry-detail').text
|
||||
assert_equal('1 PEOPLE', group_description)
|
||||
end
|
||||
end
|
|
@ -1270,4 +1270,34 @@ class UserTest < ActiveSupport::TestCase
|
|||
assert_equal(0, RecentView.where(created_by_id: agent1_id).count)
|
||||
end
|
||||
|
||||
test 'adding group drops cache' do
|
||||
agent1 = User.create!(
|
||||
login: "agent-cleanup_check-1#{name}@example.com",
|
||||
firstname: 'vaild_agent_group_permission-1',
|
||||
lastname: "Agent#{name}",
|
||||
email: "agent-cleanup_check-1#{name}@example.com",
|
||||
password: 'agentpw',
|
||||
active: true,
|
||||
roles: Role.where(name: 'Agent'),
|
||||
groups: Group.all,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
|
||||
group1 = Group.create_or_update(
|
||||
name: "GroupWithoutPermission-#{rand(9_999_999_999)}",
|
||||
active: true,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
|
||||
differences = %w[
|
||||
group1.attributes_with_association_ids['user_ids'].count
|
||||
agent1.attributes_with_association_ids['group_ids'].keys.count
|
||||
]
|
||||
|
||||
assert_difference differences, 1 do
|
||||
agent1.groups << group1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue