From e11a4f59f9770473576fd91ebeb9ba1b3393ae26 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 21 Sep 2015 22:51:10 +0200 Subject: [PATCH] Improved tests. --- .../agent_ticket_overview_level1_test.rb | 54 +++++++++++++++++-- test/browser_test_helper.rb | 39 ++++++++++++-- 2 files changed, 86 insertions(+), 7 deletions(-) diff --git a/test/browser/agent_ticket_overview_level1_test.rb b/test/browser/agent_ticket_overview_level1_test.rb index b927746d7..e645018bd 100644 --- a/test/browser/agent_ticket_overview_level1_test.rb +++ b/test/browser/agent_ticket_overview_level1_test.rb @@ -3,7 +3,8 @@ require 'browser_test_helper' class AgentTicketOverviewLevel1Test < TestCase def test_i - name = 'name_' + rand(999_999).to_s + name1 = 'name_low_' + rand(999_999).to_s + name2 = 'name_high_' + rand(999_999).to_s browser1 = browser_instance login( @@ -27,18 +28,34 @@ class AgentTicketOverviewLevel1Test < TestCase overview_create( browser: browser1, data: { - :name => name, + :name => name1, :role => 'Agent', + :selector => { + 'Priority' => '1 low', + }, :prio => 1000, 'order::direction' => 'down', } ) + overview_create( + browser: browser1, + data: { + :name => name2, + :role => 'Agent', + :selector => { + 'Priority' => '3 high', + }, + :prio => 1001, + 'order::direction' => 'down', + } + ) # create tickets ticket1 = ticket_create( browser: browser1, data: { customer: 'nico*', + priority: '1 low', group: 'Users', title: 'overview #1', body: 'overview #1', @@ -55,6 +72,7 @@ class AgentTicketOverviewLevel1Test < TestCase browser: browser1, data: { customer: 'nico*', + priority: '1 low', group: 'Users', title: 'overview #2', body: 'overview #2', @@ -65,6 +83,7 @@ class AgentTicketOverviewLevel1Test < TestCase browser: browser1, data: { customer: 'nico*', + priority: '1 low', group: 'Users', title: 'overview #3', body: 'overview #3', @@ -75,7 +94,7 @@ class AgentTicketOverviewLevel1Test < TestCase ticket_open_by_overview( browser: browser2, number: ticket3[:number], - link: "#ticket/view/#{name}", + link: "#ticket/view/#{name1}", ) # use overview navigation to got to #2 & #3 @@ -155,5 +174,34 @@ class AgentTicketOverviewLevel1Test < TestCase css: '.active .ticketZoom-header .ticket-number', value: ticket2[:number], ) + click( + browser: browser2, + css: '.active .ticketZoom .ticketZoom-controls .overview-navigator .next', + ) + match( + browser: browser2, + css: '.active .ticketZoom-header .ticket-number', + value: ticket1[:number], + ) + sleep 2 # needed to selenium cache issues + ticket_update( + browser: browser2, + data: { + priority: '3 high', + } + ) + sleep 8 + + match( + browser: browser2, + css: '.active .ticketZoom .ticketZoom-controls .overview-navigator .pagination-counter .pagination-item-current', + value: '1', + ) + match( + browser: browser2, + css: '.active .ticketZoom-header .ticket-number', + value: ticket1[:number], + ) + end end diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index eceb4b76c..f5b4da8ea 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -923,6 +923,9 @@ wait untill text in selector disabppears :data => { :name => name, :role => 'Agent', + :selector => { + 'Priority': '1 low', + }, :prio => 1000, 'order::direction' => 'down', } @@ -945,22 +948,35 @@ wait untill text in selector disabppears if data[:name] element = instance.find_elements( { css: '.modal input[name=name]' } )[0] element.clear - element.send_keys( data[:name] ) + element.send_keys(data[:name]) end if data[:role] element = instance.find_elements( { css: '.modal select[name="role_id"]' } )[0] dropdown = Selenium::WebDriver::Support::Select.new(element) - dropdown.select_by( :text, data[:role]) + dropdown.select_by(:text, data[:role]) end + + if data[:selector] + data[:selector].each {|key, value| + element = instance.find_elements( { css: '.modal .ticket_selector .js-attributeSelector select' } )[0] + dropdown = Selenium::WebDriver::Support::Select.new(element) + dropdown.select_by(:text, key) + element = instance.find_elements( { css: '.modal .ticket_selector .js-value select' } )[0] + dropdown = Selenium::WebDriver::Support::Select.new(element) + dropdown.deselect_all + dropdown.select_by(:text, value) + } + end + if data[:prio] element = instance.find_elements( { css: '.modal input[name=prio]' } )[0] element.clear - element.send_keys( data[:prio] ) + element.send_keys(data[:prio]) end if data['order::direction'] element = instance.find_elements( { css: '.modal select[name="order::direction"]' } )[0] dropdown = Selenium::WebDriver::Support::Select.new(element) - dropdown.select_by( :text, data['order::direction']) + dropdown.select_by(:text, data['order::direction']) end instance.find_elements( { css: '.modal button.js-submit' } )[0].click @@ -987,6 +1003,7 @@ wait untill text in selector disabppears :data => { :customer => 'nico', :group => 'Users', + :priority => '2 normal', :title => 'overview #1', :body => 'overview #1', }, @@ -1026,6 +1043,12 @@ wait untill text in selector disabppears dropdown.select_by( :text, data[:group]) sleep 0.2 end + if data[:priority] + element = instance.find_elements( { css: '.active .newTicket select[name="priority_id"]' } )[0] + dropdown = Selenium::WebDriver::Support::Select.new(element) + dropdown.select_by( :text, data[:priority]) + sleep 0.2 + end if data[:title] element = instance.find_elements( { css: '.active .newTicket input[name="title"]' } )[0] element.clear @@ -1116,6 +1139,7 @@ wait untill text in selector disabppears :customer => 'some_customer@example.com', :body => 'some body', :group => 'some group', + :priority => '1 low', :state => 'closed', }, :do_not_submit => true, @@ -1225,6 +1249,13 @@ wait untill text in selector disabppears sleep 0.2 end + if data[:priority] + element = instance.find_elements( { css: '.active .sidebar select[name="priority_id"]' } )[0] + dropdown = Selenium::WebDriver::Support::Select.new(element) + dropdown.select_by( :text, data[:priority]) + sleep 0.2 + end + if data[:state] element = instance.find_elements( { css: '.active .sidebar select[name="state_id"]' } )[0] dropdown = Selenium::WebDriver::Support::Select.new(element)