Improved tests.

This commit is contained in:
Martin Edenhofer 2015-09-21 22:51:10 +02:00
parent e90ac1e336
commit e11a4f59f9
2 changed files with 86 additions and 7 deletions

View file

@ -3,7 +3,8 @@ require 'browser_test_helper'
class AgentTicketOverviewLevel1Test < TestCase class AgentTicketOverviewLevel1Test < TestCase
def test_i 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 browser1 = browser_instance
login( login(
@ -27,18 +28,34 @@ class AgentTicketOverviewLevel1Test < TestCase
overview_create( overview_create(
browser: browser1, browser: browser1,
data: { data: {
:name => name, :name => name1,
:role => 'Agent', :role => 'Agent',
:selector => {
'Priority' => '1 low',
},
:prio => 1000, :prio => 1000,
'order::direction' => 'down', 'order::direction' => 'down',
} }
) )
overview_create(
browser: browser1,
data: {
:name => name2,
:role => 'Agent',
:selector => {
'Priority' => '3 high',
},
:prio => 1001,
'order::direction' => 'down',
}
)
# create tickets # create tickets
ticket1 = ticket_create( ticket1 = ticket_create(
browser: browser1, browser: browser1,
data: { data: {
customer: 'nico*', customer: 'nico*',
priority: '1 low',
group: 'Users', group: 'Users',
title: 'overview #1', title: 'overview #1',
body: 'overview #1', body: 'overview #1',
@ -55,6 +72,7 @@ class AgentTicketOverviewLevel1Test < TestCase
browser: browser1, browser: browser1,
data: { data: {
customer: 'nico*', customer: 'nico*',
priority: '1 low',
group: 'Users', group: 'Users',
title: 'overview #2', title: 'overview #2',
body: 'overview #2', body: 'overview #2',
@ -65,6 +83,7 @@ class AgentTicketOverviewLevel1Test < TestCase
browser: browser1, browser: browser1,
data: { data: {
customer: 'nico*', customer: 'nico*',
priority: '1 low',
group: 'Users', group: 'Users',
title: 'overview #3', title: 'overview #3',
body: 'overview #3', body: 'overview #3',
@ -75,7 +94,7 @@ class AgentTicketOverviewLevel1Test < TestCase
ticket_open_by_overview( ticket_open_by_overview(
browser: browser2, browser: browser2,
number: ticket3[:number], number: ticket3[:number],
link: "#ticket/view/#{name}", link: "#ticket/view/#{name1}",
) )
# use overview navigation to got to #2 & #3 # use overview navigation to got to #2 & #3
@ -155,5 +174,34 @@ class AgentTicketOverviewLevel1Test < TestCase
css: '.active .ticketZoom-header .ticket-number', css: '.active .ticketZoom-header .ticket-number',
value: ticket2[: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
end end

View file

@ -923,6 +923,9 @@ wait untill text in selector disabppears
:data => { :data => {
:name => name, :name => name,
:role => 'Agent', :role => 'Agent',
:selector => {
'Priority': '1 low',
},
:prio => 1000, :prio => 1000,
'order::direction' => 'down', 'order::direction' => 'down',
} }
@ -945,22 +948,35 @@ wait untill text in selector disabppears
if data[:name] if data[:name]
element = instance.find_elements( { css: '.modal input[name=name]' } )[0] element = instance.find_elements( { css: '.modal input[name=name]' } )[0]
element.clear element.clear
element.send_keys( data[:name] ) element.send_keys(data[:name])
end end
if data[:role] if data[:role]
element = instance.find_elements( { css: '.modal select[name="role_id"]' } )[0] element = instance.find_elements( { css: '.modal select[name="role_id"]' } )[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by( :text, data[:role]) dropdown.select_by(:text, data[:role])
end 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] if data[:prio]
element = instance.find_elements( { css: '.modal input[name=prio]' } )[0] element = instance.find_elements( { css: '.modal input[name=prio]' } )[0]
element.clear element.clear
element.send_keys( data[:prio] ) element.send_keys(data[:prio])
end end
if data['order::direction'] if data['order::direction']
element = instance.find_elements( { css: '.modal select[name="order::direction"]' } )[0] element = instance.find_elements( { css: '.modal select[name="order::direction"]' } )[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by( :text, data['order::direction']) dropdown.select_by(:text, data['order::direction'])
end end
instance.find_elements( { css: '.modal button.js-submit' } )[0].click instance.find_elements( { css: '.modal button.js-submit' } )[0].click
@ -987,6 +1003,7 @@ wait untill text in selector disabppears
:data => { :data => {
:customer => 'nico', :customer => 'nico',
:group => 'Users', :group => 'Users',
:priority => '2 normal',
:title => 'overview #1', :title => 'overview #1',
:body => 'overview #1', :body => 'overview #1',
}, },
@ -1026,6 +1043,12 @@ wait untill text in selector disabppears
dropdown.select_by( :text, data[:group]) dropdown.select_by( :text, data[:group])
sleep 0.2 sleep 0.2
end 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] if data[:title]
element = instance.find_elements( { css: '.active .newTicket input[name="title"]' } )[0] element = instance.find_elements( { css: '.active .newTicket input[name="title"]' } )[0]
element.clear element.clear
@ -1116,6 +1139,7 @@ wait untill text in selector disabppears
:customer => 'some_customer@example.com', :customer => 'some_customer@example.com',
:body => 'some body', :body => 'some body',
:group => 'some group', :group => 'some group',
:priority => '1 low',
:state => 'closed', :state => 'closed',
}, },
:do_not_submit => true, :do_not_submit => true,
@ -1225,6 +1249,13 @@ wait untill text in selector disabppears
sleep 0.2 sleep 0.2
end 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] if data[:state]
element = instance.find_elements( { css: '.active .sidebar select[name="state_id"]' } )[0] element = instance.find_elements( { css: '.active .sidebar select[name="state_id"]' } )[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)