2017-11-23 08:09:44 +00:00
|
|
|
|
2015-03-08 01:06:04 +00:00
|
|
|
require 'browser_test_helper'
|
|
|
|
|
2016-09-05 13:18:22 +00:00
|
|
|
class AgentTicketAttachmentTest < TestCase
|
2015-03-08 01:06:04 +00:00
|
|
|
def test_ticket
|
|
|
|
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
2015-04-27 13:42:53 +00:00
|
|
|
username: 'agent1@example.com',
|
|
|
|
password: 'test',
|
|
|
|
url: browser_url,
|
2015-03-08 01:06:04 +00:00
|
|
|
)
|
|
|
|
tasks_close_all()
|
|
|
|
|
|
|
|
#
|
|
|
|
# attachment checks - new ticket
|
|
|
|
#
|
|
|
|
|
|
|
|
# create new ticket with no attachment, attachment check should pop up
|
2015-04-05 20:55:44 +00:00
|
|
|
ticket_create(
|
2015-04-27 13:42:53 +00:00
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
|
|
|
group: 'Users',
|
|
|
|
title: 'test 6 - ticket 1',
|
|
|
|
body: 'test 6 - ticket 1 - with the word attachment, but not attachment atteched it should give an warning on submit',
|
2015-03-08 01:06:04 +00:00
|
|
|
},
|
2015-04-27 13:42:53 +00:00
|
|
|
do_not_submit: true,
|
2015-03-08 01:06:04 +00:00
|
|
|
)
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# submit form
|
2016-05-21 16:56:35 +00:00
|
|
|
click(css: '.content.active .js-submit')
|
2015-03-08 01:06:04 +00:00
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# check warning
|
|
|
|
alert = @browser.switch_to.alert
|
|
|
|
alert.dismiss()
|
|
|
|
#alert.accept()
|
|
|
|
#alert = alert.text
|
|
|
|
|
2018-03-28 05:33:41 +00:00
|
|
|
# since selenium webdriver with firefox is not able to upload files, skipp here
|
|
|
|
# https://github.com/w3c/webdriver/issues/1230
|
|
|
|
return if browser == 'firefox'
|
|
|
|
|
2015-03-08 01:06:04 +00:00
|
|
|
# add attachment, attachment check should quiet
|
2015-12-15 07:46:01 +00:00
|
|
|
file_upload(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .attachmentPlaceholder-inputHolder input',
|
2018-06-05 03:28:12 +00:00
|
|
|
files: [Rails.root.join('test', 'data', 'upload', 'upload1.txt'),
|
|
|
|
Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
|
2015-12-15 07:46:01 +00:00
|
|
|
)
|
2015-03-08 01:06:04 +00:00
|
|
|
|
2018-07-06 07:14:53 +00:00
|
|
|
# upload might take a while
|
|
|
|
watch_for(
|
|
|
|
css: '.content.active .newTicket .attachments',
|
|
|
|
value: 'upload1.txt',
|
|
|
|
)
|
|
|
|
watch_for(
|
|
|
|
css: '.content.active .newTicket .attachments',
|
|
|
|
value: 'upload2.jpg',
|
|
|
|
)
|
|
|
|
|
2015-03-08 01:06:04 +00:00
|
|
|
# submit form
|
2016-05-21 16:56:35 +00:00
|
|
|
click(css: '.content.active .js-submit')
|
2015-03-08 01:06:04 +00:00
|
|
|
sleep 5
|
|
|
|
|
2015-12-15 07:46:01 +00:00
|
|
|
# check if ticket is shown and attachment exists
|
2016-05-21 16:56:35 +00:00
|
|
|
location_check(url: '#ticket/zoom/')
|
2016-05-22 09:37:44 +00:00
|
|
|
sleep 2
|
2016-10-16 18:35:55 +00:00
|
|
|
ticket_number = @browser.find_elements({ css: '.content.active .ticketZoom-header .ticket-number' })[0].text
|
2015-12-15 07:46:01 +00:00
|
|
|
match(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .ticket-article-item:nth-child(1) .attachments',
|
2015-12-15 07:46:01 +00:00
|
|
|
value: 'upload2.jpg',
|
|
|
|
)
|
|
|
|
match(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .ticket-article-item:nth-child(1) .attachments',
|
2015-12-15 07:46:01 +00:00
|
|
|
value: 'upload1.txt',
|
|
|
|
)
|
2015-03-08 01:06:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# attachment checks - update ticket
|
|
|
|
#
|
|
|
|
|
|
|
|
# update ticket with no attachment, attachment check should pop up
|
|
|
|
ticket_update(
|
2015-04-27 13:42:53 +00:00
|
|
|
data: {
|
|
|
|
body: 'test 6 - ticket 1-1 - with the word attachment, but not attachment atteched it should give an warning on submit',
|
2015-03-08 01:06:04 +00:00
|
|
|
},
|
2015-04-27 13:42:53 +00:00
|
|
|
do_not_submit: true,
|
2015-03-08 01:06:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# submit form
|
2016-10-16 18:35:55 +00:00
|
|
|
click(css: '.content.active .js-submit')
|
2015-03-08 01:06:04 +00:00
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# check warning
|
|
|
|
alert = @browser.switch_to.alert
|
|
|
|
alert.dismiss()
|
|
|
|
|
|
|
|
# add attachment, attachment check should quiet
|
2015-12-15 07:46:01 +00:00
|
|
|
file_upload(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .attachmentPlaceholder-inputHolder input',
|
2018-06-05 03:28:12 +00:00
|
|
|
files: [Rails.root.join('test', 'data', 'upload', 'upload1.txt')],
|
2015-12-15 07:46:01 +00:00
|
|
|
)
|
2015-03-08 01:06:04 +00:00
|
|
|
|
2018-07-06 07:14:53 +00:00
|
|
|
# upload might take a while
|
|
|
|
watch_for(
|
|
|
|
css: '.content.active .article-add .attachments',
|
|
|
|
value: 'upload1.txt',
|
|
|
|
)
|
|
|
|
|
2015-03-08 01:06:04 +00:00
|
|
|
# submit form
|
2016-10-16 18:35:55 +00:00
|
|
|
click(css: '.content.active .js-submit')
|
2015-03-08 01:06:04 +00:00
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# no warning
|
|
|
|
#alert = @browser.switch_to.alert
|
|
|
|
|
|
|
|
# check if article exists
|
|
|
|
|
|
|
|
# discard changes should gone away
|
|
|
|
watch_for_disappear(
|
2015-04-27 13:42:53 +00:00
|
|
|
css: '.content.active .js-reset',
|
|
|
|
value: '(Discard your unsaved changes.|Verwerfen der)',
|
|
|
|
no_quote: true,
|
2015-03-08 01:06:04 +00:00
|
|
|
)
|
|
|
|
ticket_verify(
|
2015-04-27 13:42:53 +00:00
|
|
|
data: {
|
|
|
|
body: '',
|
2015-03-08 01:06:04 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
# check content and edit screen in instance 1
|
2018-03-28 05:33:41 +00:00
|
|
|
watch_for(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active div.ticket-article',
|
2015-04-27 13:42:53 +00:00
|
|
|
value: 'test 6 - ticket 1-1',
|
2015-03-08 01:06:04 +00:00
|
|
|
)
|
2015-12-15 07:46:01 +00:00
|
|
|
match_not(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .ticket-article-item:nth-child(3) .attachments',
|
2015-12-15 07:46:01 +00:00
|
|
|
value: 'upload2.jpg',
|
|
|
|
)
|
|
|
|
match(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .ticket-article-item:nth-child(3) .attachments',
|
2015-12-15 07:46:01 +00:00
|
|
|
value: 'upload1.txt',
|
|
|
|
)
|
2015-03-08 01:06:04 +00:00
|
|
|
|
2015-10-23 11:45:20 +00:00
|
|
|
# add attachment without body
|
2015-12-15 07:46:01 +00:00
|
|
|
file_upload(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .attachmentPlaceholder-inputHolder input',
|
2018-06-05 03:28:12 +00:00
|
|
|
files: [Rails.root.join('test', 'data', 'upload', 'upload1.txt'),
|
|
|
|
Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
|
2015-12-15 07:46:01 +00:00
|
|
|
)
|
2015-10-23 11:45:20 +00:00
|
|
|
|
2018-07-06 07:14:53 +00:00
|
|
|
# upload might take a while
|
|
|
|
watch_for(
|
|
|
|
css: '.content.active .article-add .attachments',
|
|
|
|
value: 'upload1.txt',
|
|
|
|
)
|
|
|
|
watch_for(
|
|
|
|
css: '.content.active .article-add .attachments',
|
|
|
|
value: 'upload2.jpg',
|
|
|
|
)
|
|
|
|
|
2015-10-23 11:45:20 +00:00
|
|
|
# submit form
|
2016-10-16 18:35:55 +00:00
|
|
|
click(css: '.content.active .js-submit')
|
2015-10-23 11:45:20 +00:00
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# check warning
|
2015-12-09 15:55:19 +00:00
|
|
|
match(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .modal',
|
2015-12-09 15:55:19 +00:00
|
|
|
value: 'missing',
|
|
|
|
)
|
2016-10-16 18:35:55 +00:00
|
|
|
click(css: '.content.active .modal .js-cancel')
|
2015-12-09 15:55:19 +00:00
|
|
|
sleep 2
|
2015-10-23 11:45:20 +00:00
|
|
|
|
|
|
|
ticket_update(
|
|
|
|
data: {
|
|
|
|
body: 'now submit should work',
|
|
|
|
},
|
|
|
|
do_not_submit: true,
|
|
|
|
)
|
|
|
|
|
|
|
|
# submit form
|
2016-10-16 18:35:55 +00:00
|
|
|
click(css: '.content.active .js-submit')
|
2015-10-23 11:45:20 +00:00
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# discard changes should gone away
|
|
|
|
watch_for_disappear(
|
|
|
|
css: '.content.active .js-reset',
|
|
|
|
value: '(Discard your unsaved changes.|Verwerfen der)',
|
|
|
|
no_quote: true,
|
|
|
|
)
|
|
|
|
ticket_verify(
|
|
|
|
data: {
|
|
|
|
body: '',
|
|
|
|
},
|
|
|
|
)
|
2015-12-15 07:46:01 +00:00
|
|
|
match(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .ticket-article-item:nth-child(4) .attachments',
|
2015-12-15 07:46:01 +00:00
|
|
|
value: 'upload2.jpg',
|
|
|
|
)
|
|
|
|
match(
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .ticket-article-item:nth-child(4) .attachments',
|
2015-12-15 07:46:01 +00:00
|
|
|
value: 'upload1.txt',
|
|
|
|
)
|
2015-03-08 01:06:04 +00:00
|
|
|
#
|
|
|
|
# ticket customer change checks
|
|
|
|
#
|
|
|
|
|
2015-04-05 20:55:44 +00:00
|
|
|
# use current session
|
|
|
|
browser1 = @browser
|
2015-03-08 01:06:04 +00:00
|
|
|
|
2015-04-05 20:55:44 +00:00
|
|
|
browser2 = browser_instance
|
|
|
|
login(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: browser2,
|
|
|
|
username: 'master@example.com',
|
|
|
|
password: 'test',
|
|
|
|
url: browser_url,
|
2015-04-05 20:55:44 +00:00
|
|
|
)
|
|
|
|
tasks_close_all(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: browser2,
|
2015-04-05 20:55:44 +00:00
|
|
|
)
|
2015-04-27 13:43:34 +00:00
|
|
|
random = 'ticket-actions-6-test-' + rand(999_999).to_s
|
2015-04-05 20:55:44 +00:00
|
|
|
user_email = random + '@example.com'
|
|
|
|
user_create(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: browser2,
|
|
|
|
data: {
|
|
|
|
firstname: 'Action6 Firstname' + random,
|
|
|
|
lastname: 'Action6 Lastname' + random,
|
|
|
|
email: user_email,
|
|
|
|
password: 'some-pass',
|
2015-04-05 20:55:44 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
# update customer, check if new customer is shown in side bar
|
|
|
|
ticket_open_by_search(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: browser2,
|
|
|
|
number: ticket_number,
|
2015-04-05 20:55:44 +00:00
|
|
|
)
|
|
|
|
ticket_update(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: browser2,
|
|
|
|
data: {
|
|
|
|
customer: user_email,
|
2015-04-05 20:55:44 +00:00
|
|
|
},
|
2015-04-27 13:42:53 +00:00
|
|
|
do_not_submit: true,
|
2015-04-05 20:55:44 +00:00
|
|
|
)
|
2015-03-08 01:06:04 +00:00
|
|
|
|
|
|
|
# check if customer has changed in second browser
|
2016-10-16 18:35:55 +00:00
|
|
|
click(browser: browser1, css: '.content.active .tabsSidebar-tab[data-tab="customer"]')
|
2015-04-05 20:55:44 +00:00
|
|
|
watch_for(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: browser1,
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .tabsSidebar',
|
2015-04-27 13:42:53 +00:00
|
|
|
value: user_email,
|
2015-04-05 20:55:44 +00:00
|
|
|
)
|
2015-03-08 01:06:04 +00:00
|
|
|
|
2015-04-05 20:55:44 +00:00
|
|
|
#
|
|
|
|
# modify customer
|
|
|
|
#
|
|
|
|
|
|
|
|
# modify customer
|
2016-10-16 18:35:55 +00:00
|
|
|
click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
|
|
|
|
click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
|
2015-04-05 20:55:44 +00:00
|
|
|
sleep 2
|
2016-05-21 16:56:35 +00:00
|
|
|
set(browser: browser1, css: '.modal [name="address"]', value: 'some new address')
|
|
|
|
click(browser: browser1, css: '.modal .js-submit')
|
2017-06-16 20:43:09 +00:00
|
|
|
modal_disappear(browser: browser1)
|
2015-04-05 20:55:44 +00:00
|
|
|
|
|
|
|
# verify is customer has chnaged other browser too
|
2016-10-16 18:35:55 +00:00
|
|
|
click(browser: browser2, css: '.content.active .tabsSidebar-tab[data-tab="customer"]')
|
2015-04-05 20:55:44 +00:00
|
|
|
watch_for(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: browser2,
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .sidebar[data-tab="customer"]',
|
2015-04-27 13:42:53 +00:00
|
|
|
value: 'some new address',
|
2015-04-05 20:55:44 +00:00
|
|
|
)
|
2015-03-08 01:06:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# ticket customer organization change checks
|
|
|
|
#
|
|
|
|
|
|
|
|
# change org of customer, check if org is shown in sidebar
|
2016-10-16 18:35:55 +00:00
|
|
|
click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
|
|
|
|
click(browser: browser1, css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
|
2015-04-05 20:55:44 +00:00
|
|
|
sleep 2
|
2016-05-21 16:56:35 +00:00
|
|
|
set(browser: browser1, css: '.modal .js-input', value: 'zammad')
|
|
|
|
click(browser: browser1, css: '.modal .js-input')
|
|
|
|
click(browser: browser1, css: '.modal .js-option')
|
2015-09-23 18:01:04 +00:00
|
|
|
|
2016-05-21 16:56:35 +00:00
|
|
|
click(browser: browser1, css: '.modal .js-submit')
|
2017-06-16 20:43:09 +00:00
|
|
|
modal_disappear(browser: browser1)
|
2015-03-08 01:06:04 +00:00
|
|
|
|
|
|
|
# check if org has changed in second browser
|
2015-04-05 20:55:44 +00:00
|
|
|
sleep 3
|
2016-10-16 18:35:55 +00:00
|
|
|
click(browser: browser2, css: '.content.active .tabsSidebar-tab[data-tab="organization"]')
|
2015-04-05 20:55:44 +00:00
|
|
|
watch_for(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: browser2,
|
2016-10-16 18:35:55 +00:00
|
|
|
css: '.content.active .sidebar[data-tab="organization"]',
|
2015-04-27 13:42:53 +00:00
|
|
|
value: 'Zammad Foundation',
|
2015-04-05 20:55:44 +00:00
|
|
|
)
|
2015-03-08 01:06:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# form change/reset checks
|
|
|
|
#
|
|
|
|
|
|
|
|
# some form reset checks
|
|
|
|
end
|
2018-07-10 14:07:11 +00:00
|
|
|
|
|
|
|
def test_upload_blocks_ticket_updates
|
|
|
|
# since selenium webdriver with firefox is not able to upload files, skip here
|
|
|
|
# https://github.com/w3c/webdriver/issues/1230
|
|
|
|
return if browser == 'firefox'
|
|
|
|
|
|
|
|
@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: 'Ticket 1',
|
|
|
|
body: 'some body',
|
|
|
|
},
|
|
|
|
do_not_submit: true,
|
|
|
|
)
|
|
|
|
|
|
|
|
# First test the attachment uploading for new tickets
|
|
|
|
file_upload(
|
|
|
|
css: '.content.active .attachmentPlaceholder-inputHolder input',
|
|
|
|
files: [Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
|
|
|
|
no_sleep: true,
|
|
|
|
)
|
2018-07-23 05:54:10 +00:00
|
|
|
exists(
|
|
|
|
css: '.content.active .js-submit:disabled',
|
2018-07-10 14:07:11 +00:00
|
|
|
)
|
|
|
|
watch_for_disappear(
|
2018-07-23 05:54:10 +00:00
|
|
|
css: '.content.active .js-submit:disabled',
|
2018-07-10 14:07:11 +00:00
|
|
|
)
|
2018-07-23 05:54:10 +00:00
|
|
|
exists(
|
|
|
|
css: '.content.active .js-submit',
|
2018-07-10 14:07:11 +00:00
|
|
|
)
|
|
|
|
click(
|
2018-07-23 05:54:10 +00:00
|
|
|
css: '.content.active .js-submit',
|
2018-07-10 14:07:11 +00:00
|
|
|
)
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# Next test the attachment uploading for new articles
|
|
|
|
ticket_update(
|
|
|
|
data: {
|
|
|
|
body: 'added attachment',
|
|
|
|
},
|
|
|
|
do_not_submit: true,
|
|
|
|
)
|
|
|
|
file_upload(
|
|
|
|
css: '.content.active .attachmentPlaceholder-inputHolder input',
|
|
|
|
files: [Rails.root.join('test', 'data', 'upload', 'upload2.jpg')],
|
|
|
|
no_sleep: true,
|
|
|
|
)
|
2018-07-23 05:54:10 +00:00
|
|
|
exists(
|
|
|
|
css: '.content.active .js-submit:disabled',
|
2018-07-10 14:07:11 +00:00
|
|
|
)
|
|
|
|
watch_for_disappear(
|
2018-07-23 05:54:10 +00:00
|
|
|
css: '.content.active .js-submit:disabled',
|
2018-07-10 14:07:11 +00:00
|
|
|
)
|
|
|
|
end
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|