123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- # encoding: utf-8
- require 'browser_test_helper'
- class AgentTicketOnlineNotificationTest < TestCase
- def test_online_notifications
- @browser = browser_instance
- login(
- username: 'master@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all()
- # create new ticket
- ticket1 = ticket_create(
- data: {
- customer: 'nico',
- group: 'Users',
- title: 'online notification #1',
- body: 'online notification #1',
- },
- )
- browser2 = browser_instance
- login(
- browser: browser2,
- username: 'agent1@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all(browser: browser2)
- click(
- browser: browser2,
- css: '.js-toggleNotifications',
- )
- click(
- browser: browser2,
- css: '.js-mark',
- )
- sleep 2
- # remove all notificatons
- online_notitifcation_close_all(
- browser: browser2,
- )
- exists_not(
- browser: browser2,
- css: '.js-noNotifications.hide',
- )
- match(
- browser: browser2,
- css: '.js-noNotifications',
- value: 'No unread Notifications',
- )
- exists(
- browser: browser2,
- css: '.js-mark.hide',
- )
- match_not(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '\d',
- no_quote: true,
- )
- ticket2 = ticket_create(
- data: {
- customer: 'nico',
- group: 'Users',
- title: 'online notification #2',
- body: 'online notification #2',
- },
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsContainer .js-item',
- value: 'online notification #2',
- timeout: 10,
- )
- match(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '1',
- )
- exists_not(
- browser: browser2,
- css: '.js-mark.hide',
- )
- ticket3 = ticket_create(
- data: {
- customer: 'nico',
- group: 'Users',
- title: 'online notification #3',
- body: 'online notification #3',
- },
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsContainer .js-item',
- value: 'online notification #3',
- timeout: 6,
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '2',
- )
- items = browser2.find_elements(css: '.js-notificationsContainer .js-item')
- count = items.count
- assert_equal(2, count)
- items[1].click
- click(
- browser: browser2,
- css: '.js-toggleNotifications',
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '1',
- )
- 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)
- ticket4 = ticket_create(
- data: {
- customer: 'nico',
- group: 'Users',
- title: 'online notification #4',
- body: 'online notification #4',
- },
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '2',
- )
- 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,
- css: '.js-mark',
- )
- sleep 3
- 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(3, items.count)
- match_not(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '\d',
- no_quote: true,
- )
- ticket5 = ticket_create(
- data: {
- customer: 'nico',
- group: 'Users',
- title: 'online notification #5',
- body: 'online notification #5',
- },
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '1',
- )
- 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)
- # Note: title update will generate extra notification - so we will have 5
- ticket_update(
- data: {
- title: 'online notification #5/5',
- state: 'closed',
- },
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsContainer .js-item',
- value: 'online notification #5/5',
- timeout: 20,
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsContainer .js-item.is-inactive',
- value: 'online notification #5/5',
- timeout: 20,
- )
- match_not(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '\d',
- 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',
- url: browser_url,
- )
- tasks_close_all()
- browser2 = browser_instance
- login(
- browser: browser2,
- username: 'agent1@example.com',
- password: 'test',
- url: browser_url,
- )
- tasks_close_all(browser: browser2)
- click(
- browser: browser2,
- css: '.js-toggleNotifications',
- )
- online_notitifcation_close_all(browser: browser2)
- ticket1 = ticket_create(
- data: {
- customer: 'nico',
- group: 'Users',
- title: 'online notification render #1',
- body: 'online notification render #1',
- },
- )
- ticket2 = ticket_create(
- data: {
- customer: 'nico',
- group: 'Users',
- title: 'online notification render #2',
- body: 'online notification render #2',
- },
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '2',
- )
- execute(
- browser: browser2,
- js: '$(".js-notificationsContainer .js-items .js-item:nth-child(1) .activity-text").text("render test 2")',
- )
- execute(
- browser: browser2,
- js: '$(".js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text").text("render test 1")',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .js-item:nth-child(1) .activity-text',
- value: 'render test 2',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text',
- value: 'render test 1',
- )
- ticket3 = ticket_create(
- data: {
- customer: 'nico',
- group: 'Users',
- title: 'online notification render #3',
- body: 'online notification render #3',
- },
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '3',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .js-item:nth-child(1) .activity-text',
- value: 'online notification render #3',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text',
- value: 'render test 2',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .js-item:nth-child(3) .activity-text',
- value: 'render test 1',
- )
- ticket_update(
- data: {
- state: 'closed',
- },
- )
- watch_for(
- browser: browser2,
- css: '.js-notificationsCounter',
- value: '2',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .is-inactive.js-item:nth-child(1) .activity-text',
- value: 'online notification render #3',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .is-inactive.js-item:nth-child(2) .activity-text',
- value: 'online notification render #3',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .js-item:nth-child(3) .activity-text',
- value: 'render test 2',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .js-item:nth-child(4) .activity-text',
- value: 'render test 1',
- )
- execute(
- browser: browser2,
- js: '$(".js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text").text("render test 3")',
- )
- close_online_notitifcation(
- browser: browser2,
- data: {
- position: 3,
- },
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .is-inactive.js-item:nth-child(1) .activity-text',
- value: 'online notification render #3',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text',
- value: 'render test 3',
- )
- match(
- browser: browser2,
- css: '.js-notificationsContainer .js-items .js-item:nth-child(3) .activity-text',
- value: 'render test 1',
- )
- end
- end
|