Maintenance: Ported admin_permissions_granular_vs_full_test.rb to Capybara.
This commit is contained in:
parent
22cd8f3376
commit
1de9c8d803
4 changed files with 27 additions and 78 deletions
|
@ -887,10 +887,6 @@ Metrics/PerceivedComplexity:
|
|||
- 'test/browser_test_helper.rb'
|
||||
- 'test/integration/slack_test.rb'
|
||||
|
||||
Rails/AssertNot:
|
||||
Exclude:
|
||||
- 'test/browser/admin_permissions_granular_vs_full_test.rb'
|
||||
|
||||
Rails/CreateTableWithTimestamps:
|
||||
Exclude:
|
||||
- 'db/migrate/20120101000001_create_base.rb'
|
||||
|
|
|
@ -13,7 +13,6 @@ if [ "$LEVEL" == '1' ]; then
|
|||
rm test/browser/abb_one_group_test.rb
|
||||
rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
rm test/browser/admin_overview_test.rb
|
||||
rm test/browser/admin_permissions_granular_vs_full_test.rb
|
||||
rm test/browser/admin_role_test.rb
|
||||
# test/browser/agent_navigation_and_title_test.rb
|
||||
# test/browser/agent_organization_profile_test.rb
|
||||
|
@ -68,7 +67,6 @@ elif [ "$LEVEL" == '2' ]; then
|
|||
# test/browser/abb_one_group_test.rb
|
||||
rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
rm test/browser/admin_overview_test.rb
|
||||
rm test/browser/admin_permissions_granular_vs_full_test.rb
|
||||
#rm test/browser/admin_role_test.rb
|
||||
rm test/browser/agent_navigation_and_title_test.rb
|
||||
rm test/browser/agent_organization_profile_test.rb
|
||||
|
@ -123,7 +121,6 @@ elif [ "$LEVEL" == '3' ]; then
|
|||
# test/browser/abb_one_group_test.rb
|
||||
rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
rm test/browser/admin_overview_test.rb
|
||||
rm test/browser/admin_permissions_granular_vs_full_test.rb
|
||||
rm test/browser/admin_role_test.rb
|
||||
rm test/browser/agent_navigation_and_title_test.rb
|
||||
rm test/browser/agent_organization_profile_test.rb
|
||||
|
@ -178,7 +175,6 @@ elif [ "$LEVEL" == '4' ]; then
|
|||
# test/browser/abb_one_group_test.rb
|
||||
rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
rm test/browser/admin_overview_test.rb
|
||||
rm test/browser/admin_permissions_granular_vs_full_test.rb
|
||||
rm test/browser/admin_role_test.rb
|
||||
rm test/browser/agent_navigation_and_title_test.rb
|
||||
rm test/browser/agent_organization_profile_test.rb
|
||||
|
@ -232,7 +228,6 @@ elif [ "$LEVEL" == '5' ]; then
|
|||
# test/browser/abb_one_group_test.rb
|
||||
# rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
# test/browser/admin_overview_test.rb
|
||||
# rm test/browser/admin_permissions_granular_vs_full_test.rb
|
||||
rm test/browser/admin_role_test.rb
|
||||
rm test/browser/agent_navigation_and_title_test.rb
|
||||
rm test/browser/agent_organization_profile_test.rb
|
||||
|
@ -289,7 +284,6 @@ elif [ "$LEVEL" == '6' ]; then
|
|||
rm test/browser/abb_one_group_test.rb
|
||||
rm test/browser/admin_drag_drop_to_new_group_test.rb
|
||||
rm test/browser/admin_overview_test.rb
|
||||
rm test/browser/admin_permissions_granular_vs_full_test.rb
|
||||
rm test/browser/admin_role_test.rb
|
||||
rm test/browser/agent_navigation_and_title_test.rb
|
||||
rm test/browser/agent_organization_profile_test.rb
|
||||
|
|
|
@ -111,6 +111,33 @@ RSpec.describe 'Manage > Users', type: :system do
|
|||
end
|
||||
end
|
||||
|
||||
context 'updating a user' do
|
||||
before do
|
||||
create(:admin)
|
||||
end
|
||||
|
||||
it 'handles permission checkboxes correctly' do
|
||||
visit '#manage/users'
|
||||
|
||||
within(:active_content) do
|
||||
click 'table.user-list tbody tr:first-child'
|
||||
end
|
||||
in_modal disappears: false do
|
||||
scroll_into_view 'table.settings-list'
|
||||
within 'table.settings-list tbody tr:first-child' do
|
||||
click 'input[value="full"]', visible: :all
|
||||
expect(find('input[value="full"]', visible: :all).checked?).to be true
|
||||
click 'input[value="read"]', visible: :all
|
||||
expect(find('input[value="full"]', visible: :all).checked?).to be false
|
||||
expect(find('input[value="read"]', visible: :all).checked?).to be true
|
||||
click 'input[value="full"]', visible: :all
|
||||
expect(find('input[value="full"]', visible: :all).checked?).to be true
|
||||
expect(find('input[value="read"]', visible: :all).checked?).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'check user edit permissions', authenticated_as: -> { user } do
|
||||
|
||||
shared_examples 'user permission' do |allow|
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
require 'browser_test_helper'
|
||||
|
||||
class AdminPermissionsGranularVsFullTest < TestCase
|
||||
def test_permissions_selecting
|
||||
new_group_name = "permissions_test_group#{SecureRandom.uuid}"
|
||||
@browser = browser_instance
|
||||
login(
|
||||
username: 'admin@example.com',
|
||||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all
|
||||
|
||||
click(css: 'a[href="#manage"]')
|
||||
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')
|
||||
modal_disappear
|
||||
|
||||
click(css: '.content.active a[href="#manage/users"]')
|
||||
|
||||
user_css = '.user-list .js-tableBody tr td'
|
||||
watch_for(css: user_css)
|
||||
@browser.find_elements(css: '.content.active .user-list td:first-child').each do |entry|
|
||||
next if entry.text.strip != 'admin@example.com'
|
||||
|
||||
entry.click
|
||||
break
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
if !group
|
||||
screenshot(comment: 'group_not_found')
|
||||
raise "Can't find group #{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
|
Loading…
Reference in a new issue