123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
- require 'browser_test_helper'
- class AgentProfilePermissionsTest < TestCase
- def test_agent_to_edit_customer_profile
- @browser = browser_instance
- login(
- username: 'agent1@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all
- user_open_by_search(value: 'Braun')
- verify_task(
- data: {
- title: 'Nicole Braun',
- }
- )
- watch_for(
- css: '.content.active .profile-window',
- value: 'note',
- )
- watch_for(
- css: '.content.active .profile-window',
- value: 'email',
- )
- set(
- css: '.content.active [data-name="note"]',
- value: 'some note 123',
- )
- empty_search
- # check and change note again in edit screen
- click(css: '.content.active .js-action .icon-arrow-down', fast: true)
- click(css: '.content.active .js-action [data-type="edit"]')
- modal_ready
- watch_for(
- css: '.content.active .modal',
- value: 'some note 123',
- )
- set(
- css: '.modal [name="lastname"]',
- value: 'B2',
- )
- set(
- css: '.modal [data-name="note"]',
- value: 'some note abc',
- )
- click(css: '.content.active .modal button.js-submit')
- modal_disappear
- watch_for(
- css: '.content.active .profile-window',
- value: 'some note abc',
- )
- verify_task(
- data: {
- title: 'Nicole B2',
- }
- )
- # change lastname back
- click(css: '.content.active .js-action .icon-arrow-down', fast: true)
- click(css: '.content.active .js-action [data-type="edit"]')
- modal_ready
- set(
- css: '.modal [name="lastname"]',
- value: 'Braun',
- )
- click(css: '.content.active .modal button.js-submit')
- modal_disappear
- verify_task(
- data: {
- title: 'Nicole Braun',
- }
- )
- end
- def test_agent_edit_admin_profile
- @browser = browser_instance
- login(
- username: 'agent1@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all
- user_open_by_search(value: 'Test Admin')
- verify_task(
- data: {
- title: 'Test Admin Agent',
- }
- )
- watch_for(
- css: '.content.active .profile-window',
- value: 'note',
- )
- watch_for(
- css: '.content.active .profile-window',
- value: 'email',
- )
- empty_search
- sleep 2
- click(css: '.content.active .js-action .icon-arrow-down', fast: true)
- exists_not(css: '.content.active .js-action [data-type="edit"]')
- end
- def test_agent_to_edit_admin_ticket_user_details
- @browser = browser_instance
- login(
- username: 'admin@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all
- ticket1 = ticket_create(
- data: {
- customer: 'admin',
- group: 'Users',
- title: 'test_user_access_permissions - ticket 1',
- body: 'test_user_access_permissions - ticket 1',
- },
- )
- tasks_close_all
- logout
- login(
- username: 'agent1@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all
- ticket_open_by_search(
- number: ticket1[:number],
- )
- watch_for(
- css: '.content.active .tabsSidebar-holder',
- value: ticket1[:title],
- )
- click(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
- click(css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
- exists_not(css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
- end
- def test_agent_to_edit_customer_ticket
- @browser = browser_instance
- login(
- username: 'agent1@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all
- ticket1 = ticket_create(
- data: {
- customer: 'nico',
- group: 'Users',
- title: 'test_user_access_permissions - ticket 2',
- body: 'test_user_access_permissions - ticket 2',
- },
- )
- ticket_open_by_search(
- number: ticket1[:number],
- )
- click(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
- click(css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
- click(css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
- modal_ready
- set(
- css: '.modal [name="lastname"]',
- value: 'B2',
- )
- set(
- css: '.modal [data-name="note"]',
- value: 'some note abc',
- )
- click(css: '.content.active .modal button.js-submit')
- modal_disappear
- watch_for(
- css: '.content.active .sidebar[data-tab="customer"] .sidebar-block [data-name="note"]',
- value: 'some note abc',
- )
- watch_for(
- css: '.content.active .sidebar[data-tab="customer"] .sidebar-block h3[title="Name"]',
- value: 'Nicole B2',
- )
- # change lastname back
- click(css: '.content.active .sidebar[data-tab="customer"] .js-actions')
- click(css: 'li[data-type="customer-edit"]')
- modal_ready
- set(
- css: '.modal [name="lastname"]',
- value: 'Braun',
- )
- set(
- css: '.modal [data-name="note"]',
- value: 'some note abc',
- )
- click(css: '.content.active .modal button.js-submit')
- modal_disappear
- watch_for(
- css: '.content.active .sidebar[data-tab="customer"] .sidebar-block [data-name="note"]',
- value: 'some note abc',
- )
- watch_for(
- css: '.content.active .sidebar[data-tab="customer"] .sidebar-block [title="Name"]',
- value: 'Nicole Braun',
- )
- end
- def test_agent_to_edit_customer_ticket_details
- @browser = browser_instance
- login(
- username: 'agent1@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all
- ticket1 = ticket_create(
- data: {
- customer: 'nico',
- group: 'Users',
- title: 'test_user_access_permissions - ticket 3',
- body: 'test_user_access_permissions - ticket 3',
- },
- )
- ticket_open_by_search(
- number: ticket1[:number],
- )
- exists(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
- exists(css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
- exists(css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
- # scroll to the Avatar at the top of the zoom view and click it
- # scrolling is needed because the browser might have scrolled down
- # caused by a undeliverable email (of the created ticket)
- zoom_top_avatar_selector = '.content.active .tabsSidebar-holder .js-avatar'
- scroll_to(
- position: 'botton',
- css: zoom_top_avatar_selector,
- )
- click(css: zoom_top_avatar_selector)
- # check and change note again in edit screen
- click(css: '.content.active .js-action .dropdown-toggle')
- click(css: '.content.active .js-action [data-type="edit"]')
- modal_ready
- set(
- css: '.modal [name="lastname"]',
- value: 'B2',
- )
- set(
- css: '.modal [data-name="note"]',
- value: 'some note abc',
- )
- click(css: '.content.active .modal button.js-submit')
- modal_disappear
- watch_for(
- css: '.content.active .profile-window',
- value: 'some note abc',
- )
- verify_task(
- data: {
- title: 'Nicole B2',
- }
- )
- # change lastname back
- click(css: '.content.active .js-action .dropdown-toggle')
- click(css: '.content.active .js-action [data-type="edit"]')
- modal_ready
- set(
- css: '.modal [name="lastname"]',
- value: 'Braun',
- )
- set(
- css: '.modal [data-name="note"]',
- value: 'note',
- )
- click(css: '.content.active .modal button.js-submit')
- modal_disappear
- verify_task(
- data: {
- title: 'Nicole Braun',
- }
- )
- end
- def test_agent_to_edit_admin_ticket_details
- @browser = browser_instance
- login(
- username: 'agent1@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all
- ticket1 = ticket_create(
- data: {
- customer: 'admin',
- group: 'Users',
- title: 'test_user_access_permissions - ticket 4',
- body: 'test_user_access_permissions - ticket 4',
- },
- )
- ticket_open_by_search(
- number: ticket1[:number],
- )
- exists(css: '.content.active .tabsSidebar .tabsSidebar-tab[data-tab="customer"]')
- exists(css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
- exists_not(css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
- begin
- retries ||= 0
- # scroll to the Avatar at the top of the zoom view and click it
- # scrolling is needed because the browser might have scrolled down
- # caused by a undeliverable email (of the created ticket)
- zoom_top_avatar_selector = '.content.active .tabsSidebar-holder .js-avatar'
- scroll_to(
- position: 'botton',
- css: zoom_top_avatar_selector,
- )
- click(css: zoom_top_avatar_selector)
- click(css: '.content.active .js-action .icon-arrow-down', fast: true)
- exists_not(css: '.content.active .js-action [data-type="edit"]')
- rescue Selenium::WebDriver::Error::UnknownError
- sleep retries
- retries += 1
- retry if retries < 3
- end
- end
- end
|