2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2016-04-04 13:54:37 +00:00
|
|
|
require 'browser_test_helper'
|
|
|
|
|
2016-09-05 13:18:22 +00:00
|
|
|
class AgentTicketOnlineNotificationTest < TestCase
|
2016-04-04 13:54:37 +00:00
|
|
|
|
|
|
|
def test_online_notifications
|
|
|
|
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
|
|
|
username: 'master@example.com',
|
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
tasks_close_all()
|
|
|
|
|
|
|
|
# create new ticket
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_create(
|
2016-04-04 13:54:37 +00:00
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'online notification #1',
|
|
|
|
body: 'online notification #1',
|
2016-04-04 13:54:37 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
browser2 = browser_instance
|
|
|
|
login(
|
2018-12-19 17:31:51 +00:00
|
|
|
browser: browser2,
|
2016-04-04 13:54:37 +00:00
|
|
|
username: 'agent1@example.com',
|
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
tasks_close_all(browser: browser2)
|
|
|
|
|
|
|
|
click(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-toggleNotifications',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-mark',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# remove all notificatons
|
|
|
|
online_notitifcation_close_all(
|
|
|
|
browser: browser2,
|
|
|
|
)
|
|
|
|
|
|
|
|
exists_not(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-noNotifications.hide',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-noNotifications',
|
|
|
|
value: 'No unread Notifications',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
exists(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-mark.hide',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match_not(
|
2018-12-19 17:31:51 +00:00
|
|
|
browser: browser2,
|
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '\d',
|
2016-04-04 13:54:37 +00:00
|
|
|
no_quote: true,
|
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_create(
|
2016-04-04 13:54:37 +00:00
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'online notification #2',
|
|
|
|
body: 'online notification #2',
|
2016-04-04 13:54:37 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-item',
|
|
|
|
value: 'online notification #2',
|
2016-04-04 13:54:37 +00:00
|
|
|
timeout: 10,
|
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '1',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
exists_not(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-mark.hide',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_create(
|
2016-04-04 13:54:37 +00:00
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'online notification #3',
|
|
|
|
body: 'online notification #3',
|
2016-04-04 13:54:37 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-item',
|
|
|
|
value: 'online notification #3',
|
2016-04-04 13:54:37 +00:00
|
|
|
timeout: 6,
|
|
|
|
)
|
2018-12-14 17:41:46 +00:00
|
|
|
|
|
|
|
# flanky
|
2016-04-04 13:54:37 +00:00
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '2',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
|
|
|
|
count = items.count
|
|
|
|
assert_equal(2, count)
|
|
|
|
|
|
|
|
items[1].click
|
|
|
|
|
|
|
|
click(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-toggleNotifications',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '1',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
|
|
|
|
assert_equal(2, items.count)
|
|
|
|
|
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
|
|
|
|
assert_equal(1, items.count)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_create(
|
2016-04-04 13:54:37 +00:00
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'online notification #4',
|
|
|
|
body: 'online notification #4',
|
2016-04-04 13:54:37 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '2',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
|
|
|
|
assert_equal(3, items.count)
|
|
|
|
|
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
|
|
|
|
assert_equal(1, items.count)
|
|
|
|
|
|
|
|
click(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-mark',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
sleep 3
|
|
|
|
|
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
|
|
|
|
assert_equal(3, items.count)
|
|
|
|
|
2018-12-14 17:41:46 +00:00
|
|
|
# flanky
|
2016-04-04 13:54:37 +00:00
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
|
|
|
|
assert_equal(3, items.count)
|
|
|
|
|
|
|
|
match_not(
|
2018-12-19 17:31:51 +00:00
|
|
|
browser: browser2,
|
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '\d',
|
2016-04-04 13:54:37 +00:00
|
|
|
no_quote: true,
|
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_create(
|
2016-04-04 13:54:37 +00:00
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'online notification #5',
|
|
|
|
body: 'online notification #5',
|
2016-04-04 13:54:37 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '1',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
|
|
|
|
assert_equal(4, items.count)
|
|
|
|
|
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
|
|
|
|
assert_equal(3, items.count)
|
|
|
|
|
2020-11-12 11:42:44 +00:00
|
|
|
# NOTE: title update will generate extra notification - so we will have 5
|
2016-04-04 13:54:37 +00:00
|
|
|
ticket_update(
|
|
|
|
data: {
|
|
|
|
title: 'online notification #5/5',
|
|
|
|
state: 'closed',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-item',
|
|
|
|
value: 'online notification #5/5',
|
2016-04-04 13:54:37 +00:00
|
|
|
timeout: 20,
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-item.is-inactive',
|
|
|
|
value: 'online notification #5/5',
|
2016-04-04 13:54:37 +00:00
|
|
|
timeout: 20,
|
|
|
|
)
|
|
|
|
|
|
|
|
match_not(
|
2018-12-19 17:31:51 +00:00
|
|
|
browser: browser2,
|
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '\d',
|
2016-04-04 13:54:37 +00:00
|
|
|
no_quote: true,
|
|
|
|
)
|
|
|
|
|
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
|
|
|
|
assert_equal(6, items.count)
|
|
|
|
|
|
|
|
items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
|
|
|
|
assert_equal(6, items.count)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_online_notifications_render
|
|
|
|
@browser = browser_instance
|
|
|
|
login(
|
|
|
|
username: 'master@example.com',
|
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
tasks_close_all()
|
|
|
|
|
|
|
|
browser2 = browser_instance
|
|
|
|
login(
|
2018-12-19 17:31:51 +00:00
|
|
|
browser: browser2,
|
2016-04-04 13:54:37 +00:00
|
|
|
username: 'agent1@example.com',
|
|
|
|
password: 'test',
|
2018-12-19 17:31:51 +00:00
|
|
|
url: browser_url,
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
tasks_close_all(browser: browser2)
|
|
|
|
click(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-toggleNotifications',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
online_notitifcation_close_all(browser: browser2)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_create(
|
2016-04-04 13:54:37 +00:00
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'online notification render #1',
|
|
|
|
body: 'online notification render #1',
|
2016-04-04 13:54:37 +00:00
|
|
|
},
|
|
|
|
)
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_create(
|
2016-04-04 13:54:37 +00:00
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'online notification render #2',
|
|
|
|
body: 'online notification render #2',
|
2016-04-04 13:54:37 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '2',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
execute(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
js: '$(".js-notificationsContainer .js-items .js-item:nth-child(1) .activity-text").text("render test 2")',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
execute(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
js: '$(".js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text").text("render test 1")',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .js-item:nth-child(1) .activity-text',
|
|
|
|
value: 'render test 2',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text',
|
|
|
|
value: 'render test 1',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_create(
|
2016-04-04 13:54:37 +00:00
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2018-12-19 17:31:51 +00:00
|
|
|
group: 'Users',
|
|
|
|
title: 'online notification render #3',
|
|
|
|
body: 'online notification render #3',
|
2016-04-04 13:54:37 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '3',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .js-item:nth-child(1) .activity-text',
|
|
|
|
value: 'online notification render #3',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text',
|
|
|
|
value: 'render test 2',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .js-item:nth-child(3) .activity-text',
|
|
|
|
value: 'render test 1',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
ticket_update(
|
|
|
|
data: {
|
|
|
|
state: 'closed',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
watch_for(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsCounter',
|
|
|
|
value: '2',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .is-inactive.js-item:nth-child(1) .activity-text',
|
|
|
|
value: 'online notification render #3',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .is-inactive.js-item:nth-child(2) .activity-text',
|
|
|
|
value: 'online notification render #3',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .js-item:nth-child(3) .activity-text',
|
|
|
|
value: 'render test 2',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .js-item:nth-child(4) .activity-text',
|
|
|
|
value: 'render test 1',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
execute(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
js: '$(".js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text").text("render test 3")',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
close_online_notitifcation(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
data: {
|
2016-04-04 13:54:37 +00:00
|
|
|
position: 3,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .is-inactive.js-item:nth-child(1) .activity-text',
|
|
|
|
value: 'online notification render #3',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text',
|
|
|
|
value: 'render test 3',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
match(
|
|
|
|
browser: browser2,
|
2018-12-19 17:31:51 +00:00
|
|
|
css: '.js-notificationsContainer .js-items .js-item:nth-child(3) .activity-text',
|
|
|
|
value: 'render test 1',
|
2016-04-04 13:54:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|