2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2018-05-15 16:15:38 +00:00
|
|
|
require 'browser_test_helper'
|
|
|
|
|
|
|
|
class AdminPermissionsGranularVsFullTest < TestCase
|
|
|
|
def test_permissions_selecting
|
|
|
|
new_group_name = "permissions_test_group#{rand(99_999_999)}"
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
|
|
|
username: 'master@example.com',
|
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2018-05-15 16:15:38 +00:00
|
|
|
)
|
|
|
|
tasks_close_all()
|
|
|
|
|
2018-12-14 17:29:31 +00:00
|
|
|
click(css: 'a[href="#manage"]')
|
2018-05-15 16:15:38 +00:00
|
|
|
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')
|
2018-12-14 17:29:31 +00:00
|
|
|
modal_disappear
|
2018-05-15 16:15:38 +00:00
|
|
|
|
|
|
|
click(css: '.content.active a[href="#manage/users"]')
|
|
|
|
|
|
|
|
user_css = '.user-list .js-tableBody tr td'
|
|
|
|
watch_for(css: user_css)
|
2018-12-14 17:29:31 +00:00
|
|
|
@browser.find_elements(css: '.content.active .user-list td:first-child').each do |entry|
|
|
|
|
next if entry.text.strip != 'master@example.com'
|
|
|
|
|
|
|
|
entry.click
|
|
|
|
break
|
|
|
|
end
|
2018-05-15 16:15:38 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-12-14 17:29:31 +00:00
|
|
|
if !group
|
|
|
|
screenshot(comment: 'group_not_found')
|
|
|
|
raise "Can't find group #{new_group_name}"
|
|
|
|
end
|
|
|
|
|
2018-05-15 16:15:38 +00:00
|
|
|
toggle_checkbox(group, 'full')
|
|
|
|
sleep(1)
|
|
|
|
assert(checkbox_is_selected(group, 'full'))
|
|
|
|
|
|
|
|
toggle_checkbox(group, 'read')
|
|
|
|
sleep(1)
|
|
|
|
assert(!checkbox_is_selected(group, 'full'))
|
|
|
|
assert(checkbox_is_selected(group, 'read'))
|
|
|
|
|
|
|
|
toggle_checkbox(group, 'full')
|
|
|
|
sleep(1)
|
|
|
|
assert(checkbox_is_selected(group, 'full'))
|
|
|
|
assert(!checkbox_is_selected(group, 'read'))
|
|
|
|
end
|
|
|
|
end
|