trabajo-afectivo/test/browser/admin_permissions_granular_vs_full_test.rb

59 lines
1.6 KiB
Ruby
Raw Normal View History

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',
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
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