admin_permissions_granular_vs_full_test.rb 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. require 'browser_test_helper'
  2. class AdminPermissionsGranularVsFullTest < TestCase
  3. def test_permissions_selecting
  4. new_group_name = "permissions_test_group#{rand(99_999_999)}"
  5. @browser = browser_instance
  6. login(
  7. username: 'master@example.com',
  8. password: 'test',
  9. url: browser_url,
  10. )
  11. tasks_close_all()
  12. click(css: 'a[href="#manage"]')
  13. click(css: '.content.active a[href="#manage/groups"]')
  14. click(css: '.content.active a[data-type="new"]')
  15. modal_ready
  16. element = @browser.find_element(css: '.modal input[name=name]')
  17. element.clear
  18. element.send_keys(new_group_name)
  19. click(css: '.modal button.js-submit')
  20. modal_disappear
  21. click(css: '.content.active a[href="#manage/users"]')
  22. user_css = '.user-list .js-tableBody tr td'
  23. watch_for(css: user_css)
  24. @browser.find_elements(css: '.content.active .user-list td:first-child').each do |entry|
  25. next if entry.text.strip != 'master@example.com'
  26. entry.click
  27. break
  28. end
  29. modal_ready
  30. scroll_script = "var el = document.getElementsByClassName('modal')[0];"
  31. scroll_script += 'el.scrollTo(0, el.scrollHeight);'
  32. @browser.execute_script scroll_script
  33. group = @browser.find_elements(css: '.modal .settings-list tbody tr').find do |el|
  34. el.find_element(css: 'td').text == new_group_name
  35. end
  36. if !group
  37. screenshot(comment: 'group_not_found')
  38. raise "Can't find group #{new_group_name}"
  39. end
  40. toggle_checkbox(group, 'full')
  41. sleep(1)
  42. assert(checkbox_is_selected(group, 'full'))
  43. toggle_checkbox(group, 'read')
  44. sleep(1)
  45. assert(!checkbox_is_selected(group, 'full'))
  46. assert(checkbox_is_selected(group, 'read'))
  47. toggle_checkbox(group, 'full')
  48. sleep(1)
  49. assert(checkbox_is_selected(group, 'full'))
  50. assert(!checkbox_is_selected(group, 'read'))
  51. end
  52. end