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
|
2021-09-20 10:47:05 +00:00
|
|
|
new_group_name = "permissions_test_group#{SecureRandom.uuid}"
|
2018-05-15 16:15:38 +00:00
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
2021-08-17 12:10:02 +00:00
|
|
|
username: 'admin@example.com',
|
2018-05-15 16:15:38 +00:00
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2018-05-15 16:15:38 +00:00
|
|
|
)
|
2021-07-16 13:29:38 +00:00
|
|
|
tasks_close_all
|
2018-05-15 16:15:38 +00:00
|
|
|
|
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|
|
2021-08-17 12:10:02 +00:00
|
|
|
next if entry.text.strip != 'admin@example.com'
|
2018-12-14 17:29:31 +00:00
|
|
|
|
|
|
|
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
|