Improved speed of tests.
This commit is contained in:
parent
3a82045f96
commit
43ff43f5cf
8 changed files with 994 additions and 750 deletions
|
@ -3,201 +3,72 @@ require 'browser_test_helper'
|
|||
|
||||
class AAbUnitTest < TestCase
|
||||
def test_core
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url + '/tests-core',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 8,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
@browser = browser_instance
|
||||
location( :url => browser_url + '/tests-core' )
|
||||
sleep 10
|
||||
match(
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
)
|
||||
end
|
||||
def test_ui
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url + '/tests-ui',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 8,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
end
|
||||
def test_model
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url + '/tests-model',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 8,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
end
|
||||
def test_model_ui
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url + '/tests-model-ui',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 8,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
@browser = browser_instance
|
||||
location( :url => browser_url + '/tests-ui' )
|
||||
sleep 8
|
||||
match(
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
)
|
||||
location( :url => browser_url + '/tests-model' )
|
||||
sleep 8
|
||||
match(
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
)
|
||||
location( :url => browser_url + '/tests-model-ui' )
|
||||
sleep 8
|
||||
match(
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
)
|
||||
end
|
||||
def test_form
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url + '/tests-form',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 8,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
end
|
||||
def test_form_extended
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url + '/tests-form-extended',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 8,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
@browser = browser_instance
|
||||
location( :url => browser_url + '/tests-form' )
|
||||
sleep 8
|
||||
match(
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
)
|
||||
location( :url => browser_url + '/tests-form-extended' )
|
||||
sleep 8
|
||||
match(
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
)
|
||||
end
|
||||
def test_form_validation
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url + '/tests-form-validation',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 8,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
@browser = browser_instance
|
||||
location( :url => browser_url + '/tests-form-validation' )
|
||||
sleep 4
|
||||
match(
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
)
|
||||
end
|
||||
def test_table
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url + '/tests-table',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 8,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
end
|
||||
def test_html_utils
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url + '/tests-html-utils',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 8,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
@browser = browser_instance
|
||||
location( :url => browser_url + '/tests-table' )
|
||||
sleep 4
|
||||
match(
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
)
|
||||
location( :url => browser_url + '/tests-html-utils' )
|
||||
sleep 4
|
||||
match(
|
||||
:css => '.result .failed',
|
||||
:value => '0',
|
||||
)
|
||||
end
|
||||
end
|
|
@ -3,94 +3,48 @@ require 'browser_test_helper'
|
|||
|
||||
class AACBasicRichtextTest < TestCase
|
||||
def test_preferences
|
||||
tests = [
|
||||
{
|
||||
:name => 'richtext single line',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'click',
|
||||
:css => 'a[href="#current_user"]',
|
||||
},
|
||||
{
|
||||
:execute => 'click',
|
||||
:css => 'a[href="#layout_ref"]',
|
||||
},
|
||||
{
|
||||
:execute => 'click',
|
||||
:css => 'a[href="#layout_ref/richtext"]',
|
||||
},
|
||||
{
|
||||
:execute => 'set',
|
||||
:css => '#content .text-1',
|
||||
:value => 'some test for browser ',
|
||||
:slow => true,
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 4,
|
||||
},
|
||||
{
|
||||
:execute => 'sendkey',
|
||||
:value => :enter,
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 1,
|
||||
},
|
||||
{
|
||||
:execute => 'sendkey',
|
||||
:value => 'and some other for browser',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 2,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '#content .text-1',
|
||||
:value => 'some test for browser and some other for browser',
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
:name => 'richtext multi line',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'set',
|
||||
:css => '#content .text-3',
|
||||
:value => 'some test for browser ',
|
||||
:slow => true,
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 4,
|
||||
},
|
||||
{
|
||||
:execute => 'sendkey',
|
||||
:value => :enter,
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 1,
|
||||
},
|
||||
{
|
||||
:execute => 'sendkey',
|
||||
:value => 'and some other for browser',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 2,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '#content .text-3',
|
||||
:value => "some test for browser\nand some other for browser",
|
||||
:match_result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_signle_test_with_login(tests, { :username => 'master@example.com' })
|
||||
@browser = browser_instance
|
||||
login(
|
||||
:username => 'master@example.com',
|
||||
:password => 'test',
|
||||
:url => browser_url,
|
||||
)
|
||||
|
||||
click( :css => 'a[href="#current_user"]' )
|
||||
click( :css => 'a[href="#layout_ref"]' )
|
||||
click( :css => 'a[href="#layout_ref/richtext"]' )
|
||||
click( :css => 'a[href="#current_user"]' )
|
||||
|
||||
# richtext single line
|
||||
set(
|
||||
:css => '#content .text-1',
|
||||
:value => 'some test for browser ',
|
||||
:slow => true,
|
||||
)
|
||||
sleep 1
|
||||
sendkey( :value => :enter )
|
||||
sendkey( :value => 'and some other for browser' )
|
||||
sleep 1
|
||||
|
||||
match(
|
||||
:css => '#content .text-1',
|
||||
:value => 'some test for browser and some other for browser',
|
||||
)
|
||||
|
||||
# richtext multi line
|
||||
set(
|
||||
:css => '#content .text-3',
|
||||
:value => 'some test for browser ',
|
||||
:slow => true,
|
||||
)
|
||||
sleep 1
|
||||
sendkey( :value => :enter )
|
||||
sendkey( :value => 'and some other for browser' )
|
||||
sleep 1
|
||||
|
||||
match(
|
||||
:css => '#content .text-3',
|
||||
:value => "some test for browser\nand some other for browser",
|
||||
)
|
||||
end
|
||||
end
|
|
@ -3,72 +3,47 @@ require 'browser_test_helper'
|
|||
|
||||
class AgentTicketOverviewLevel0Test < TestCase
|
||||
def test_I
|
||||
tests = [
|
||||
{
|
||||
:name => 'verify overview count',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'close_all_tasks',
|
||||
},
|
||||
@browser = browser_instance
|
||||
login(
|
||||
:username => 'master@example.com',
|
||||
:password => 'test',
|
||||
:url => browser_url,
|
||||
)
|
||||
tasks_close_all()
|
||||
|
||||
# remember it ticket count in overview
|
||||
{
|
||||
:execute => 'overview_count_remember',
|
||||
},
|
||||
# remember current overview count
|
||||
overview_counter_before = overview_counter()
|
||||
|
||||
# create new open ticket
|
||||
{
|
||||
:execute => 'create_ticket',
|
||||
:group => 'Users',
|
||||
:subject => 'some subject 123äöü',
|
||||
:body => 'some body 123äöü - with closed tab',
|
||||
},
|
||||
# create new ticket
|
||||
ticket1 = ticket_create(
|
||||
:data => {
|
||||
:customer => 'nico*',
|
||||
:group => 'Users',
|
||||
:title => 'overview count test #1',
|
||||
:body => 'overview count test #1',
|
||||
}
|
||||
)
|
||||
sleep 8
|
||||
|
||||
# remember ticket for later
|
||||
{
|
||||
:execute => 'match',
|
||||
:css => '.active .page-header .ticket-number',
|
||||
:value => '^(.*)$',
|
||||
:no_quote => true,
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 5,
|
||||
},
|
||||
# get new overview count
|
||||
overview_counter_new = overview_counter()
|
||||
assert_equal( overview_counter_before['#ticket/view/all_unassigned'] + 1, overview_counter_new['#ticket/view/all_unassigned'] )
|
||||
|
||||
# check new ticket count of open tickets in overview
|
||||
{
|
||||
:execute => 'overview_count_verify',
|
||||
:data => {
|
||||
'#ticket/view/all_unassigned' => 1,
|
||||
},
|
||||
},
|
||||
# open ticket by search
|
||||
ticket_open_by_search(
|
||||
:number => ticket1[:number],
|
||||
)
|
||||
|
||||
# close ticket
|
||||
{
|
||||
:execute => 'search_ticket',
|
||||
:number => '###stack###',
|
||||
},
|
||||
{
|
||||
:execute => 'update_ticket',
|
||||
:state => 'closed',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 5,
|
||||
},
|
||||
# close ticket
|
||||
ticket_update(
|
||||
:data => {
|
||||
:state => 'closed',
|
||||
}
|
||||
)
|
||||
sleep 8
|
||||
|
||||
# verify new open tickets in overview
|
||||
{
|
||||
:execute => 'overview_count_verify',
|
||||
:data => {
|
||||
'#ticket/view/all_unassigned' => 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_signle_test_with_login(tests, { :username => 'master@example.com' })
|
||||
# get current overview count
|
||||
overview_counter_after = overview_counter()
|
||||
assert_equal( overview_counter_before['#ticket/view/all_unassigned'], overview_counter_after['#ticket/view/all_unassigned'] )
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,83 +5,79 @@ class AgentTicketOverviewLevel1Test < TestCase
|
|||
def test_I
|
||||
name = 'name-' + rand(999999).to_s
|
||||
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance1 => browser_instance,
|
||||
:instance2 => browser_instance,
|
||||
:instance1_username => 'master@example.com',
|
||||
:instance1_password => 'test',
|
||||
:instance2_username => 'agent1@example.com',
|
||||
:instance2_password => 'test',
|
||||
:url => browser_url,
|
||||
:action => [
|
||||
{
|
||||
:where => :instance1,
|
||||
:execute => 'close_all_tasks',
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'close_all_tasks',
|
||||
},
|
||||
browser1 = browser_instance
|
||||
login(
|
||||
:browser => browser1,
|
||||
:username => 'master@example.com',
|
||||
:password => 'test',
|
||||
:url => browser_url,
|
||||
)
|
||||
tasks_close_all( :browser => browser1 )
|
||||
|
||||
# create new overview
|
||||
{
|
||||
:where => :instance1,
|
||||
:execute => 'create_overview',
|
||||
:name => name,
|
||||
:link => name,
|
||||
:role => 'Agent',
|
||||
:prio => 1000,
|
||||
'order::direction' => 'down',
|
||||
},
|
||||
browser2 = browser_instance
|
||||
login(
|
||||
:browser => browser2,
|
||||
:username => 'agent1@example.com',
|
||||
:password => 'test',
|
||||
:url => browser_url,
|
||||
)
|
||||
tasks_close_all( :browser => browser2 )
|
||||
|
||||
# create tickets
|
||||
{
|
||||
:where => :instance1,
|
||||
:execute => 'create_ticket',
|
||||
:group => 'Users',
|
||||
:subject => 'overview #1',
|
||||
:body => 'overview #1',
|
||||
},
|
||||
# create new overview
|
||||
overview = overview_create(
|
||||
:browser => browser1,
|
||||
:data => {
|
||||
:name => name,
|
||||
:link => name,
|
||||
:role => 'Agent',
|
||||
:prio => 1000,
|
||||
'order::direction' => 'down',
|
||||
}
|
||||
)
|
||||
sleep 1
|
||||
|
||||
# remember ticket for later
|
||||
{
|
||||
:where => :instance1,
|
||||
:execute => 'match',
|
||||
:css => '.active .page-header .ticket-number',
|
||||
:value => '^(.*)$',
|
||||
:no_quote => true,
|
||||
:match_result => true,
|
||||
},
|
||||
{
|
||||
:where => :instance1,
|
||||
:execute => 'create_ticket',
|
||||
:group => 'Users',
|
||||
:subject => 'overview #2',
|
||||
:body => 'overview #2',
|
||||
},
|
||||
{
|
||||
:where => :instance1,
|
||||
:execute => 'create_ticket',
|
||||
:group => 'Users',
|
||||
:subject => 'overview #3',
|
||||
:body => 'overview #3',
|
||||
},
|
||||
# create tickets
|
||||
ticket1 = ticket_create(
|
||||
:browser => browser1,
|
||||
:data => {
|
||||
:customer => 'nico*',
|
||||
:group => 'Users',
|
||||
:title => 'overview #1',
|
||||
:body => 'overview #1',
|
||||
}
|
||||
)
|
||||
sleep 1
|
||||
|
||||
# click on first ticket on overview
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'overview_ticket',
|
||||
:number => '###stack###',
|
||||
:link => name,
|
||||
},
|
||||
ticket2 = ticket_create(
|
||||
:browser => browser1,
|
||||
:data => {
|
||||
:customer => 'nico*',
|
||||
:group => 'Users',
|
||||
:title => 'overview #2',
|
||||
:body => 'overview #2',
|
||||
}
|
||||
)
|
||||
sleep 1
|
||||
|
||||
ticket3 = ticket_create(
|
||||
:browser => browser1,
|
||||
:data => {
|
||||
:customer => 'nico*',
|
||||
:group => 'Users',
|
||||
:title => 'overview #3',
|
||||
:body => 'overview #3',
|
||||
}
|
||||
)
|
||||
|
||||
# click on #1 on overview
|
||||
ticket_open_by_overview(
|
||||
:browser => browser2,
|
||||
:number => ticket1[:number],
|
||||
:link => '#ticket/view/' + name,
|
||||
)
|
||||
|
||||
# use overview navigation to got to #2 & #3
|
||||
|
||||
# use overview navigation to got to #2 & #3
|
||||
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_double_test(tests)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,118 +0,0 @@
|
|||
# encoding: utf-8
|
||||
require 'browser_test_helper'
|
||||
|
||||
class AuthCustomerTest < TestCase
|
||||
def test_authentication
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url,
|
||||
:action => [
|
||||
{
|
||||
:execute => 'check',
|
||||
:css => '#login',
|
||||
:result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'check',
|
||||
:css => '#login button',
|
||||
:result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'click',
|
||||
:css => '#login button',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 5,
|
||||
},
|
||||
{
|
||||
:execute => 'check',
|
||||
:css => '#login',
|
||||
:result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
:name => 'login',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'login',
|
||||
:username => 'nicole.braun@zammad.org',
|
||||
:password => 'test',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 5,
|
||||
},
|
||||
{
|
||||
:execute => 'reload',
|
||||
},
|
||||
{
|
||||
:execute => 'watch_for',
|
||||
:area => 'body',
|
||||
:value => 'Overviews',
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:element => :cookie,
|
||||
:value => 'expires=>nil',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
end
|
||||
|
||||
def test_authentication_new_browser_without_permanent_cookie_no_session_should_be
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url,
|
||||
:action => [
|
||||
{
|
||||
:execute => 'check',
|
||||
:css => '#login',
|
||||
:result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'check',
|
||||
:css => '#login button',
|
||||
:result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
end
|
||||
|
||||
def test_new_browser_with_permanent_cookie_login
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url,
|
||||
:action => [
|
||||
{
|
||||
:execute => 'login',
|
||||
:username => 'nicole.braun@zammad.org',
|
||||
:password => 'test',
|
||||
:remember_me => true,
|
||||
},
|
||||
{
|
||||
:execute => 'match',
|
||||
:element => :cookie,
|
||||
:value => 'expires=>.+?\d{4}.+?,',
|
||||
},
|
||||
{
|
||||
:execute => 'logout',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,50 +0,0 @@
|
|||
# encoding: utf-8
|
||||
require 'browser_test_helper'
|
||||
|
||||
class AuthMasterTest < TestCase
|
||||
def test_authentication
|
||||
tests = [
|
||||
{
|
||||
:name => 'start',
|
||||
:instance => browser_instance,
|
||||
:url => browser_url,
|
||||
:action => [
|
||||
{
|
||||
:execute => 'check',
|
||||
:css => '#login',
|
||||
:result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'check',
|
||||
:css => '#login button',
|
||||
:result => true,
|
||||
},
|
||||
{
|
||||
:execute => 'click',
|
||||
:css => '#login button',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 5,
|
||||
},
|
||||
{
|
||||
:execute => 'check',
|
||||
:css => '#login',
|
||||
:result => true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
:name => 'login',
|
||||
:action => [
|
||||
{
|
||||
:execute => 'login',
|
||||
:username => 'master@example.com',
|
||||
:password => 'test1234äöüß',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
browser_single_test(tests)
|
||||
end
|
||||
end
|
85
test/browser/auth_test.rb
Normal file
85
test/browser/auth_test.rb
Normal file
|
@ -0,0 +1,85 @@
|
|||
# encoding: utf-8
|
||||
require 'browser_test_helper'
|
||||
|
||||
class AuthTest < TestCase
|
||||
def test_authentication
|
||||
@browser = browser_instance
|
||||
location( :url => browser_url )
|
||||
match(
|
||||
:css => '#login',
|
||||
:value => 'username',
|
||||
)
|
||||
click( :css => '#login button' )
|
||||
|
||||
sleep 4
|
||||
match(
|
||||
:css => '#login',
|
||||
:value => 'username',
|
||||
)
|
||||
|
||||
# login with username/password
|
||||
login(
|
||||
:username => 'nicole.braun@zammad.org',
|
||||
:password => 'test',
|
||||
)
|
||||
|
||||
# reload page
|
||||
reload()
|
||||
|
||||
# check if cookie is temporarily
|
||||
watch_for(
|
||||
:css => 'body',
|
||||
:value => 'Overviews',
|
||||
)
|
||||
|
||||
# verify session cookie
|
||||
cookie(
|
||||
:name => '^_zammad.+?',
|
||||
:value => '.+?',
|
||||
:expires => '',
|
||||
)
|
||||
end
|
||||
|
||||
def test_authentication_new_browser_without_permanent_cookie_no_session_should_be
|
||||
@browser = browser_instance
|
||||
location( :url => browser_url )
|
||||
match(
|
||||
:css => '#login',
|
||||
:value => 'username',
|
||||
)
|
||||
end
|
||||
|
||||
def test_new_browser_with_permanent_cookie_login
|
||||
@browser = browser_instance
|
||||
location( :url => browser_url )
|
||||
|
||||
# login with username/password
|
||||
login(
|
||||
:username => 'nicole.braun@zammad.org',
|
||||
:password => 'test',
|
||||
:remember_me => true,
|
||||
)
|
||||
|
||||
# check if cookie is temporarily
|
||||
watch_for(
|
||||
:css => 'body',
|
||||
:value => 'Overviews',
|
||||
)
|
||||
|
||||
# verify session cookie
|
||||
cookie(
|
||||
:name => '^_zammad.+?',
|
||||
:value => '.+?',
|
||||
:expires => '\d{4}-\d{1,2}-\d{1,2}.+?',
|
||||
)
|
||||
|
||||
logout()
|
||||
|
||||
# verify session cookie
|
||||
cookie(
|
||||
:name => '^_zammad.+?',
|
||||
:should_not_exist => true,
|
||||
)
|
||||
end
|
||||
|
||||
end
|
|
@ -71,6 +71,707 @@ class TestCase < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
username = login(
|
||||
:browser => browser1,
|
||||
:username => 'someuser',
|
||||
:password => 'somepassword',
|
||||
:url => 'some url', # optional
|
||||
:remember_me => true, # optional
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def login(params)
|
||||
instance = params[:browser] || @browser
|
||||
|
||||
if params[:url]
|
||||
instance.get( params[:url] )
|
||||
end
|
||||
|
||||
element = instance.find_elements( { :css => '#login input[name="username"]' } )[0]
|
||||
if !element
|
||||
raise "No login box found"
|
||||
end
|
||||
element.clear
|
||||
element.send_keys( params[:username] )
|
||||
|
||||
element = instance.find_elements( { :css => '#login input[name="password"]' } )[0]
|
||||
element.clear
|
||||
element.send_keys( params[:password] )
|
||||
|
||||
if params[:remember_me]
|
||||
instance.find_elements( { :css => '#login [name="remember_me"]' } )[0].click
|
||||
end
|
||||
instance.find_elements( { :css => '#login button' } )[0].click
|
||||
|
||||
sleep 4
|
||||
login = instance.find_elements( { :css => '.user-menu .user a' } )[0].attribute('title')
|
||||
if login != params[:username]
|
||||
raise "login failed"
|
||||
end
|
||||
assert( true, "login ok" )
|
||||
login
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
logout(
|
||||
:browser => browser1
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def logout(params = {})
|
||||
instance = params[:browser] || @browser
|
||||
|
||||
instance.find_elements( { :css => 'a[href="#current_user"]' } )[0].click
|
||||
sleep 0.1
|
||||
instance.find_elements( { :css => 'a[href="#logout"]' } )[0].click
|
||||
(1..6).each {|loop|
|
||||
login = instance.find_elements( { :css => '#login' } )[0]
|
||||
if login
|
||||
assert( true, "logout ok" )
|
||||
return
|
||||
end
|
||||
}
|
||||
raise "no login box found, seems logout was not successfully!"
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
location(
|
||||
:browser => browser1,
|
||||
:url => 'http://someurl',
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def location(params)
|
||||
instance = params[:browser] || @browser
|
||||
instance.get( params[:url] )
|
||||
end
|
||||
|
||||
|
||||
=begin
|
||||
|
||||
reload(
|
||||
:browser => browser1,
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def reload(params = {})
|
||||
instance = params[:browser] || @browser
|
||||
instance.navigate.refresh
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
click(
|
||||
:browser => browser1,
|
||||
:css => '.some_class',
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def click(params)
|
||||
instance = params[:browser] || @browser
|
||||
instance.find_elements( { :css => params[:css] } )[0].click
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
exists(
|
||||
:browser => browser1,
|
||||
:css => '.some_class',
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def exists(params)
|
||||
instance = params[:browser] || @browser
|
||||
if instance.find_elements( { :css => params[:css] } )[0]
|
||||
return true
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
set(
|
||||
:browser => browser1,
|
||||
:css => '.some_class',
|
||||
:value => true,
|
||||
:slow => false,
|
||||
:clear => true, # todo
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def set(params)
|
||||
instance = params[:browser] || @browser
|
||||
|
||||
element = instance.find_elements( { :css => params[:css] } )[0]
|
||||
element.clear
|
||||
|
||||
if !params[:slow]
|
||||
element.send_keys( params[:value] )
|
||||
else
|
||||
element.send_keys( '' )
|
||||
keys = params[:value].to_s.split('')
|
||||
keys.each {|key|
|
||||
instance.action.send_keys(key).perform
|
||||
}
|
||||
end
|
||||
sleep 0.1
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
sendkey(
|
||||
:browser => browser1,
|
||||
:value => :enter,
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def sendkey(params)
|
||||
instance = params[:browser] || @browser
|
||||
if params[:value].class == Array
|
||||
params[:value].each {|key|
|
||||
instance.action.send_keys(key).perform
|
||||
}
|
||||
return
|
||||
end
|
||||
instance.action.send_keys(params[:value]).perform
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
match(
|
||||
:browser => browser1,
|
||||
:css => '#content .text-1',
|
||||
:value => 'some test for browser and some other for browser',
|
||||
:attribute => 'some_attribute', # match on attribute
|
||||
:should_not_match => true,
|
||||
:no_quote => false, # use regex
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def match(params)
|
||||
instance = params[:browser] || @browser
|
||||
element = instance.find_elements( { :css => params[:css] } )[0]
|
||||
|
||||
if params[:css] =~ /select/
|
||||
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
||||
success = false
|
||||
if dropdown.selected_options
|
||||
dropdown.selected_options.each {|option|
|
||||
if option.text == params[:value]
|
||||
success = true
|
||||
end
|
||||
}
|
||||
end
|
||||
if params[:should_not_match]
|
||||
if success
|
||||
raise "should not match '#{params[:value]}' in select list, but is matching"
|
||||
end
|
||||
return true
|
||||
else
|
||||
if !success
|
||||
raise "not matching '#{params[:value]}' in select list"
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
# match pn attribute
|
||||
if params[:attribute]
|
||||
text = element.attribute( params[:attribute] )
|
||||
elsif params[:css] =~ /(input|textarea)/i
|
||||
text = element.attribute('value')
|
||||
else
|
||||
text = element.text
|
||||
end
|
||||
match = false
|
||||
if params[:no_quote]
|
||||
#puts "aaaa #{text}/#{params[:value]}"
|
||||
if text =~ /#{params[:value]}/i
|
||||
match = $1 || true
|
||||
end
|
||||
else
|
||||
if text =~ /#{Regexp.quote(params[:value])}/i
|
||||
match = true
|
||||
end
|
||||
end
|
||||
if match
|
||||
if params[:should_not_match]
|
||||
raise "matching '#{params[:value]}' in content '#{text}' but should not!"
|
||||
end
|
||||
else
|
||||
if !params[:should_not_match]
|
||||
raise "not matching '#{params[:value]}' in content '#{text}' but should!"
|
||||
end
|
||||
end
|
||||
return match
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
cookie(
|
||||
:browser => browser1,
|
||||
:name => '^_zammad.+?',
|
||||
:value => '.+?',
|
||||
:expires => nil,
|
||||
)
|
||||
|
||||
cookie(
|
||||
:browser => browser1,
|
||||
:name => '^_zammad.+?',
|
||||
:should_not_exist => true,
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def cookie(params)
|
||||
instance = params[:browser] || @browser
|
||||
|
||||
if !browser_support_cookies
|
||||
assert( true, "'#{params[:value]}' ups browser is not supporting reading cookies, go ahead")
|
||||
return true
|
||||
end
|
||||
|
||||
cookies = instance.manage.all_cookies
|
||||
cookies.each {|cookie|
|
||||
#puts "CCC #{cookie.inspect}"
|
||||
# :name=>"_zammad_session_c25832f4de2", :value=>"adc31cd21615cb0a7ab269184ec8b76f", :path=>"/", :domain=>"localhost", :expires=>nil, :secure=>false}
|
||||
if cookie[:name] =~ /#{params[:name]}/i
|
||||
if params.has_key?( :value ) && cookie[:value].to_s =~ /#{params[:value]}/i
|
||||
assert( true, "matching value '#{params[:value]}' in cookie '#{cookie.to_s}'" )
|
||||
else
|
||||
raise "not matching value '#{params[:value]}' in cookie '#{cookie.to_s}'"
|
||||
end
|
||||
if params.has_key?( :expires ) && cookie[:expires].to_s =~ /#{params[:expires]}/i
|
||||
assert( true, "matching expires '#{params[:expires].inspect}' in cookie '#{cookie.to_s}'" )
|
||||
else
|
||||
raise "not matching expires '#{params[:expires]}' in cookie '#{cookie.to_s}'"
|
||||
end
|
||||
|
||||
if params[:should_not_exist]
|
||||
raise "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies.to_s}'"
|
||||
end
|
||||
return
|
||||
end
|
||||
}
|
||||
if params[:should_not_exist]
|
||||
assert( true, "cookie with name '#{params[:name]}' is not existing" )
|
||||
return
|
||||
end
|
||||
raise "not matching name '#{params[:name]}' in cookie '#{cookies.to_s}'"
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
watch_for(
|
||||
:browser => browser1,
|
||||
:css => true,
|
||||
:value => 'some text',
|
||||
:timeout => '16', # in sec, default 16
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def watch_for(params = {})
|
||||
instance = params[:browser] || @browser
|
||||
|
||||
timeout = 16
|
||||
if params[:timeout]
|
||||
timeout = params[:timeout]
|
||||
end
|
||||
loops = (timeout).to_i
|
||||
text = ''
|
||||
(1..loops).each { |loop|
|
||||
element = instance.find_elements( { :css => params[:css] } )[0]
|
||||
if element #&& element.displayed?
|
||||
begin
|
||||
text = element.text
|
||||
if text =~ /#{params[:value]}/i
|
||||
assert( true, "'#{params[:value]}' found in '#{text}'" )
|
||||
return true
|
||||
end
|
||||
rescue
|
||||
# just try again
|
||||
end
|
||||
end
|
||||
sleep 1
|
||||
}
|
||||
raise "'#{params[:value]}' found in '#{text}'"
|
||||
end
|
||||
|
||||
|
||||
=begin
|
||||
|
||||
tasks_close_all(
|
||||
:browser => browser1,
|
||||
:discard_changes => true,
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def tasks_close_all(params = {})
|
||||
instance = params[:browser] || @browser
|
||||
|
||||
for i in 1..100
|
||||
sleep 1
|
||||
if instance.find_elements( { :css => '.navigation .tasks .task:first-child' } )[0]
|
||||
instance.mouse.move_to( instance.find_elements( { :css => '.navigation .tasks .task:first-child' } )[0] )
|
||||
sleep 0.2
|
||||
|
||||
click_element = instance.find_elements( { :css => '.navigation .tasks .task:first-child .js-close' } )[0]
|
||||
if click_element
|
||||
sleep 0.1
|
||||
click_element.click
|
||||
|
||||
# accept task close warning
|
||||
if params[:discard_changes]
|
||||
sleep 1
|
||||
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
||||
end
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
assert( true, "all tasks closed" )
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
username = overview_create(
|
||||
:browser => browser1,
|
||||
:data => {
|
||||
:name => name,
|
||||
:link => name,
|
||||
:role => 'Agent',
|
||||
:prio => 1000,
|
||||
'order::direction' => 'down',
|
||||
}
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def overview_create(params)
|
||||
instance = params[:browser] || @browser
|
||||
data = params[:data]
|
||||
|
||||
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
||||
instance.find_elements( { :css => 'a[href="#manage/overviews"]' } )[0].click
|
||||
instance.find_elements( { :css => '#content a[data-type="new"]' } )[0].click
|
||||
sleep 2
|
||||
|
||||
if data[:name]
|
||||
element = instance.find_elements( { :css => '.modal input[name=name]' } )[0]
|
||||
element.clear
|
||||
element.send_keys( data[:name] )
|
||||
end
|
||||
if data[:link]
|
||||
element = instance.find_elements( { :css => '.modal input[name=link]' } )[0]
|
||||
element.clear
|
||||
element.send_keys( data[:link] )
|
||||
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])
|
||||
end
|
||||
if data[:prio]
|
||||
element = instance.find_elements( { :css => '.modal input[name=prio]' } )[0]
|
||||
element.clear
|
||||
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'])
|
||||
end
|
||||
|
||||
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
||||
(1..12).each {|loop|
|
||||
element = instance.find_elements( { :css => 'body' } )[0]
|
||||
text = element.text
|
||||
if text =~ /#{Regexp.quote(data[:name])}/
|
||||
assert( true, "overview created" )
|
||||
overview = {
|
||||
:name => name,
|
||||
}
|
||||
return overview
|
||||
end
|
||||
sleep 1
|
||||
}
|
||||
raise "overview creation failed"
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
ticket = ticket_create(
|
||||
:browser => browser1,
|
||||
:data => {
|
||||
:customer => 'nico',
|
||||
:group => 'Users',
|
||||
:subject => 'overview #1',
|
||||
:body => 'overview #1',
|
||||
},
|
||||
:do_not_submit => true,
|
||||
)
|
||||
|
||||
returns (in case of submitted)
|
||||
{
|
||||
:id => 123,
|
||||
:number => '100001',
|
||||
}
|
||||
|
||||
=end
|
||||
|
||||
def ticket_create(params)
|
||||
instance = params[:browser] || @browser
|
||||
data = params[:data]
|
||||
|
||||
instance.find_elements( { :css => 'a[href="#new"]' } )[0].click
|
||||
instance.find_elements( { :css => 'a[href="#ticket/create"]' } )[0].click
|
||||
element = instance.find_elements( { :css => '.active .newTicket' } )[0]
|
||||
if !element
|
||||
raise "no ticket create screen found!"
|
||||
end
|
||||
sleep 1
|
||||
|
||||
# check count of agents, should be only 1 / - selection on init screen
|
||||
count = instance.find_elements( { :css => '.active .newTicket select[name="owner_id"] option' } ).count
|
||||
assert_equal( 1, count, 'check if owner selection is empty per default' )
|
||||
|
||||
if data[:group]
|
||||
element = instance.find_elements( { :css => '.active .newTicket select[name="group_id"]' } )[0]
|
||||
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
||||
dropdown.select_by( :text, data[:group])
|
||||
sleep 0.2
|
||||
end
|
||||
if data[:title]
|
||||
element = instance.find_elements( { :css => '.active .newTicket input[name="title"]' } )[0]
|
||||
element.clear
|
||||
element.send_keys( data[:title] )
|
||||
sleep 0.2
|
||||
end
|
||||
if data[:body]
|
||||
#instance.execute_script( '$(".active .newTicket div[data-name=body]").focus()' )
|
||||
sleep 0.5
|
||||
element = instance.find_elements( { :css => '.active .newTicket div[data-name=body]' } )[0]
|
||||
element.clear
|
||||
element.send_keys( data[:body] )
|
||||
end
|
||||
if data[:customer]
|
||||
element = instance.find_elements( { :css => '.active .newTicket input[name="customer_id_completion"]' } )[0]
|
||||
element.click
|
||||
element.clear
|
||||
element.send_keys( data[:customer] )
|
||||
sleep 4
|
||||
element.send_keys( :arrow_down )
|
||||
sleep 0.1
|
||||
instance.find_elements( { :css => '.active .newTicket .recipientList-entry.js-user.is-active' } )[0].click
|
||||
sleep 0.3
|
||||
end
|
||||
if params[:do_not_submit]
|
||||
assert( true, "ticket created without submit" )
|
||||
return
|
||||
end
|
||||
sleep 0.8
|
||||
#instance.execute_script( '$(".content.active .newTicket form").submit();' )
|
||||
instance.find_elements( { :css => '.active .newTicket button.submit' } )[0].click
|
||||
sleep 1
|
||||
(1..16).each {|loop|
|
||||
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
|
||||
assert( true, "ticket created" )
|
||||
sleep 1
|
||||
id = instance.current_url
|
||||
id.gsub!(//, )
|
||||
id.gsub!(/^.+?\/(\d+)$/, "\\1")
|
||||
|
||||
number = instance.find_elements( { :css => '.active .page-header .ticket-number' } )[0].text
|
||||
ticket = {
|
||||
:id => id,
|
||||
:number => number,
|
||||
}
|
||||
return ticket
|
||||
end
|
||||
sleep 0.5
|
||||
}
|
||||
raise "ticket creation failed, can't get zoom url"
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
ticket_update(
|
||||
:browser => browser1,
|
||||
:data => {
|
||||
:group => 'some group',
|
||||
:state => 'closed',
|
||||
},
|
||||
:do_not_submit => true,
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def ticket_update(params)
|
||||
instance = params[:browser] || @browser
|
||||
data = params[:data]
|
||||
|
||||
if data[:group]
|
||||
element = instance.find_elements( { :css => '.active .sidebar select[name="group_id"]' } )[0]
|
||||
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
||||
dropdown.select_by( :text, data[:group])
|
||||
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)
|
||||
dropdown.select_by( :text, data[:state])
|
||||
sleep 0.2
|
||||
end
|
||||
|
||||
found = nil
|
||||
(1..5).each {|loop|
|
||||
if !found
|
||||
text = instance.find_elements( { :css => '.content.active .js-reset' } )[0].text
|
||||
if text =~ /(Discard your unsaved changes.|Verwerfen der)/
|
||||
found = true
|
||||
end
|
||||
sleep 1
|
||||
end
|
||||
}
|
||||
if !found
|
||||
raise "no discard message found"
|
||||
end
|
||||
|
||||
if params[:do_not_submit]
|
||||
assert( true, "(#{test[:name]}) ticket updated without submit" )
|
||||
return true
|
||||
end
|
||||
|
||||
instance.find_elements( { :css => '.content.active button.js-submit' } )[0].click
|
||||
|
||||
(1..10).each {|loop|
|
||||
text = instance.find_elements( { :css => '.content.active .js-reset' } )[0].text
|
||||
if !text || text.empty?
|
||||
return true
|
||||
end
|
||||
sleep 1
|
||||
}
|
||||
raise "unable to update ticket"
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
ticket_open_by_overview(
|
||||
:browser => browser2,
|
||||
:number => ticket1[:number],
|
||||
:link => '#ticket/view/' + name,
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def ticket_open_by_overview(params)
|
||||
instance = params[:browser] || @browser
|
||||
|
||||
instance.find_elements( { :css => '#navigation li.overviews a' } )[0].click
|
||||
sleep 1
|
||||
instance.find_elements( { :css => ".content.active .sidebar a[href=\"#{params[:link]}\"]" } )[0].click
|
||||
sleep 1
|
||||
element = instance.find_elements( { :partial_link_text => params[:number] } )[0].click
|
||||
sleep 1
|
||||
number = instance.find_elements( { :css => '.active .page-header .ticket-number' } )[0].text
|
||||
if number !~ /#{params[:number]}/
|
||||
raise "unable to search/find ticket #{params[:number]}!"
|
||||
end
|
||||
assert( true, "ticket #{params[:number]} found" )
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
ticket_open_by_search(
|
||||
:browser => browser2,
|
||||
:number => ticket1[:number],
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def ticket_open_by_search(params)
|
||||
instance = params[:browser] || @browser
|
||||
|
||||
# search by number
|
||||
element = instance.find_elements( { :css => '#global-search' } )[0]
|
||||
element.click
|
||||
element.clear
|
||||
element.send_keys( params[:number] )
|
||||
sleep 3
|
||||
|
||||
# empty search box by x
|
||||
instance.find_elements( { :css => '.search .empty-search' } )[0].click
|
||||
sleep 0.5
|
||||
text = instance.find_elements( { :css => '#global-search' } )[0].attribute('value')
|
||||
if !text
|
||||
raise "#global-search is not empty!"
|
||||
end
|
||||
|
||||
# search by number again
|
||||
element = instance.find_elements( { :css => '#global-search' } )[0]
|
||||
element.click
|
||||
element.clear
|
||||
element.send_keys( params[:number] )
|
||||
sleep 1
|
||||
|
||||
# open ticket
|
||||
element = instance.find_element( { :partial_link_text => params[:number] } ).click
|
||||
number = instance.find_elements( { :css => '.active .page-header .ticket-number' } )[0].text
|
||||
if number !~ /#{params[:number]}/
|
||||
raise "unable to search/find ticket #{params[:number]}!"
|
||||
end
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
overview_count = overview_counter(
|
||||
:browser => browser2,
|
||||
)
|
||||
|
||||
returns
|
||||
{
|
||||
'#ticket/view/all_unassigned' => 42,
|
||||
}
|
||||
|
||||
=end
|
||||
|
||||
def overview_counter(params = {})
|
||||
instance = params[:browser] || @browser
|
||||
|
||||
instance.find_elements( { :css => '#navigation li.overviews a' } )[0].click
|
||||
sleep 2
|
||||
overviews = {}
|
||||
instance.find_elements( { :css => '.content.active .sidebar a[href]' } ).each {|element|
|
||||
url = element.attribute('href')
|
||||
url.gsub!(/(http|https):\/\/.+?\/(.+?)$/, "\\2")
|
||||
overviews[url] = 0
|
||||
#puts url.inspect
|
||||
#puts element.inspect
|
||||
}
|
||||
overviews.each {|url, value|
|
||||
count = instance.find_elements( { :css => ".content.active .sidebar a[href=\"#{url}\"] .badge" } )[0].text
|
||||
overviews[url] = count.to_i
|
||||
}
|
||||
overviews
|
||||
end
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
def browser_login(data)
|
||||
all_tests = [
|
||||
|
@ -204,20 +905,6 @@ class TestCase < Test::Unit::TestCase
|
|||
assert( false, "(#{test[:name]}) not matching '#{action[:value]}' in title '#{title}'" )
|
||||
end
|
||||
return
|
||||
elsif action[:element] == :cookie
|
||||
if !browser_support_cookies
|
||||
assert( true, "(#{test[:name]}) '#{action[:value]}' ups browser is not supporting reading cookies")
|
||||
return
|
||||
end
|
||||
cookies = instance.manage.all_cookies
|
||||
cookies.each {|cookie|
|
||||
if cookie.to_s =~ /#{action[:value]}/i
|
||||
assert( true, "(#{test[:name]}) matching '#{action[:value]}' in cookie '#{cookie.to_s}'" )
|
||||
return
|
||||
end
|
||||
}
|
||||
assert( false, "(#{test[:name]}) not matching '#{action[:value]}' in cookie '#{cookies.to_s}'" )
|
||||
return
|
||||
elsif action[:element] == :alert
|
||||
element = instance.switch_to.alert
|
||||
elsif action[:execute] == 'login'
|
||||
|
@ -338,54 +1025,6 @@ class TestCase < Test::Unit::TestCase
|
|||
assert( true, "(#{test[:name]}) user creation failed" )
|
||||
return
|
||||
|
||||
# overview remember
|
||||
elsif action[:execute] == 'overview_count_remember'
|
||||
instance.find_elements( { :css => '#navigation li.overviews a' } )[0].click
|
||||
sleep 2
|
||||
overviews = {}
|
||||
instance.find_elements( { :css => '.content.active .sidebar a[href]' } ).each {|element|
|
||||
url = element.attribute('href')
|
||||
url.gsub!(/(http|https):\/\/.+?\/(.+?)$/, "\\2")
|
||||
overviews[url] = 0
|
||||
#puts url.inspect
|
||||
#puts element.inspect
|
||||
}
|
||||
overviews.each {|url, value|
|
||||
count = instance.find_elements( { :css => ".content.active .sidebar a[href=\"#{url}\"] .badge" } )[0].text
|
||||
overviews[url] = count
|
||||
}
|
||||
@overview_count_remember = overviews
|
||||
assert( !overviews.empty?, "(#{test[:name]}) overview_count_remember" )
|
||||
return
|
||||
|
||||
# overview verify
|
||||
elsif action[:execute] == 'overview_count_verify'
|
||||
instance.find_elements( { :css => '#navigation li.overviews a' } )[0].click
|
||||
sleep 2
|
||||
overviews = {}
|
||||
instance.find_elements( { :css => '.content.active .sidebar a[href]' } ).each {|element|
|
||||
url = element.attribute('href')
|
||||
url.gsub!(/(http|https):\/\/.+?\/(.+?)$/, "\\2")
|
||||
overviews[url] = 0
|
||||
}
|
||||
overviews.each {|url, value|
|
||||
count = instance.find_elements( { :css => ".content.active .sidebar a[href=\"#{url}\"] .badge" } )[0].text
|
||||
overviews[url] = count
|
||||
}
|
||||
#puts "ov #{overviews.inspect}"
|
||||
#puts "@ov #{@overview_count_remember.inspect}"
|
||||
#puts "data #{action[:data].inspect}"
|
||||
action[:data].each {|url,count|
|
||||
if @overview_count_remember.has_key?(url)
|
||||
count_is = overviews[url].to_i
|
||||
count_should = @overview_count_remember[url].to_i + count.to_i
|
||||
assert_equal( count_should, count_is, "(#{test[:name]}) expected count of url #{url} is different overview_count_remember" )
|
||||
else
|
||||
assert( false, "(#{test[:name]}) no url #{url} exists in overview_count_remember" )
|
||||
end
|
||||
}
|
||||
return
|
||||
|
||||
# create signature
|
||||
elsif action[:execute] == 'create_signature'
|
||||
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
||||
|
@ -413,46 +1052,6 @@ class TestCase < Test::Unit::TestCase
|
|||
assert( true, "(#{test[:name]}) signature creation failed" )
|
||||
return
|
||||
|
||||
# create overview
|
||||
elsif action[:execute] == 'create_overview'
|
||||
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
||||
instance.find_elements( { :css => 'a[href="#manage/overviews"]' } )[0].click
|
||||
instance.find_elements( { :css => '#content a[data-type="new"]' } )[0].click
|
||||
sleep 2
|
||||
element = instance.find_elements( { :css => '.modal input[name=name]' } )[0]
|
||||
element.clear
|
||||
element.send_keys( action[:name] )
|
||||
element = instance.find_elements( { :css => '.modal input[name=link]' } )[0]
|
||||
element.clear
|
||||
element.send_keys( action[:link] )
|
||||
|
||||
element = instance.find_elements( { :css => '.modal select[name="role_id"]' } )[0]
|
||||
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
||||
dropdown.select_by( :text, action[:role])
|
||||
sleep 0.2
|
||||
|
||||
element = instance.find_elements( { :css => '.modal input[name=prio]' } )[0]
|
||||
element.clear
|
||||
element.send_keys( action[:prio] )
|
||||
|
||||
element = instance.find_elements( { :css => '.modal select[name="order::direction"]' } )[0]
|
||||
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
||||
dropdown.select_by( :text, action['order::direction'])
|
||||
sleep 0.2
|
||||
|
||||
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
||||
(1..12).each {|loop|
|
||||
element = instance.find_elements( { :css => 'body' } )[0]
|
||||
text = element.text
|
||||
if text =~ /#{Regexp.quote(action[:name])}/
|
||||
assert( true, "(#{test[:name]}) overview created" )
|
||||
return
|
||||
end
|
||||
sleep 1
|
||||
}
|
||||
assert( true, "(#{test[:name]}) overview creation failed" )
|
||||
return
|
||||
|
||||
# create group
|
||||
elsif action[:execute] == 'create_group'
|
||||
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
||||
|
@ -620,56 +1219,6 @@ class TestCase < Test::Unit::TestCase
|
|||
assert( false, "(#{test[:name]}) ticket creation failed, can't get zoom url" )
|
||||
return
|
||||
|
||||
# udpate ticket
|
||||
elsif action[:execute] == 'update_ticket'
|
||||
|
||||
if action[:group]
|
||||
element = instance.find_elements( { :css => '.active .sidebar select[name="group_id"]' } )[0]
|
||||
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
||||
dropdown.select_by( :text, action[:group])
|
||||
sleep 0.2
|
||||
end
|
||||
|
||||
if action[:state]
|
||||
element = instance.find_elements( { :css => '.active .sidebar select[name="state_id"]' } )[0]
|
||||
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
||||
dropdown.select_by( :text, action[:state])
|
||||
sleep 0.2
|
||||
end
|
||||
|
||||
found = nil
|
||||
(1..5).each {|loop|
|
||||
if !found
|
||||
text = instance.find_elements( { :css => '.content.active .js-reset' } )[0].text
|
||||
if text =~ /(Discard your unsaved changes.|Verwerfen der)/
|
||||
assert( true, "(#{test[:name]}) discard message found" )
|
||||
found = true
|
||||
end
|
||||
sleep 1
|
||||
end
|
||||
}
|
||||
if !found
|
||||
assert( false, "(#{test[:name]}) no discard message found" )
|
||||
end
|
||||
|
||||
if action[:do_not_submit]
|
||||
assert( true, "(#{test[:name]}) ticket updated without submit" )
|
||||
return
|
||||
end
|
||||
|
||||
instance.find_elements( { :css => '.content.active button.js-submit' } )[0].click
|
||||
|
||||
(1..10).each {|loop|
|
||||
text = instance.find_elements( { :css => '.content.active .js-reset' } )[0].text
|
||||
if !text || text.empty?
|
||||
assert( true, "(#{test[:name]}) ticket updated" )
|
||||
return
|
||||
end
|
||||
sleep 1
|
||||
}
|
||||
assert( false, "(#{test[:name]}) unable to update ticket" )
|
||||
return
|
||||
|
||||
# search user
|
||||
elsif action[:execute] == 'search_user'
|
||||
element = instance.find_elements( { :css => '#global-search' } )[0]
|
||||
|
@ -753,24 +1302,6 @@ class TestCase < Test::Unit::TestCase
|
|||
assert( true, "(#{test[:name]}) ticket #{action[:number]} found" )
|
||||
return
|
||||
|
||||
# overview ticket
|
||||
elsif action[:execute] == 'overview_ticket'
|
||||
instance.find_elements( { :css => '#navigation li.overviews a' } )[0].click
|
||||
sleep 1
|
||||
instance.find_elements( { :css => ".content.active .sidebar a[href=##{action[:link]}]" } ).click
|
||||
sleep 1
|
||||
|
||||
action[:number].gsub! '###stack###', @stack
|
||||
|
||||
element = instance.find_element( { :partial_link_text => action[:number] } ).click
|
||||
number = instance.find_elements( { :css => '.active .page-header .ticket-number' } )[0].text
|
||||
if number !~ /#{action[:number]}/
|
||||
assert( false, "(#{test[:name]}) unable to search/find ticket #{action[:number]}!" )
|
||||
return
|
||||
end
|
||||
assert( true, "(#{test[:name]}) ticket #{action[:number]} found" )
|
||||
return
|
||||
|
||||
# close all tasks
|
||||
elsif action[:execute] == 'close_all_tasks'
|
||||
for i in 1..100
|
||||
|
|
Loading…
Reference in a new issue