From 224f2e8391ef02c07e21fe2f3355cbaf314dfffe Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 31 Dec 2015 02:04:45 +0100 Subject: [PATCH] Added auto wizard login support for browser tests. --- .gitlab-ci.yml | 2 ++ contrib/auto_wizard_test.json | 28 +++++++++++++++++++++++ test/browser_test_helper.rb | 12 ++++++++++ test/integration/facebook_browser_test.rb | 1 + test/integration/twitter_browser_test.rb | 1 + 5 files changed, 44 insertions(+) create mode 100644 contrib/auto_wizard_test.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d002d59c3..5477fae5b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -197,6 +197,7 @@ job_integration_twitter_ff: - export WS_PORT=3042 - export BROWSER_URL=http://$IP:$BROWSER_PORT - RAILS_ENV=test rake db:create + - cp contrib/auto_wizard_test.json auto_wizard.json - script/bootstrap.sh - rake assets:precompile - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT @@ -213,6 +214,7 @@ job_integration_facebook_ff: - export WS_PORT=3052 - export BROWSER_URL=http://$IP:$BROWSER_PORT - RAILS_ENV=test rake db:create + - cp contrib/auto_wizard_test.json auto_wizard.json - script/bootstrap.sh - rake assets:precompile - script/build/test_startup.sh $RAILS_ENV $BROWSER_PORT $WS_PORT diff --git a/contrib/auto_wizard_test.json b/contrib/auto_wizard_test.json new file mode 100644 index 000000000..b0f384d89 --- /dev/null +++ b/contrib/auto_wizard_test.json @@ -0,0 +1,28 @@ +{ + "Users": [ + { + "login": "master@example.com", + "firstname": "Test Master", + "lastname": "Agent", + "email": "master@example.com", + "password": "test" + }, + { + "login": "agent1@example.com", + "firstname": "Agent 1", + "lastname": "Test", + "email": "agent1@example.com", + "password": "test" + } + ], + "Settings": [ + { + "name": "developer_mode", + "value": true + }, + { + "name": "product_name", + "value": "Zammad Test System" + } + ] +} diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 82c4c41fc..862d3d9d4 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -124,6 +124,7 @@ class TestCase < Test::Unit::TestCase password: 'somepassword', url: 'some url', # optional remember_me: true, # optional + auto_wizard: false, # optional, in case of auto wizard, skip login ) =end @@ -139,6 +140,17 @@ class TestCase < Test::Unit::TestCase element = instance.find_elements({ css: '#login input[name="username"]' })[0] if !element + + if params[:auto_wizard] + sleep 10 + login = instance.find_elements({ css: '.user-menu .user a' })[0].attribute('title') + if login != params[:username] + screenshot(browser: instance, comment: 'auto wizard login failed') + fail 'auto wizard login failed' + end + assert(true, 'auto wizard login ok') + return + end screenshot(browser: instance, comment: 'login_failed') fail 'No login box found' end diff --git a/test/integration/facebook_browser_test.rb b/test/integration/facebook_browser_test.rb index e8e275e4f..88ca8145b 100644 --- a/test/integration/facebook_browser_test.rb +++ b/test/integration/facebook_browser_test.rb @@ -27,6 +27,7 @@ class FacebookBrowserTest < TestCase username: 'master@example.com', password: 'test', url: browser_url, + auto_wizard: true, ) tasks_close_all() diff --git a/test/integration/twitter_browser_test.rb b/test/integration/twitter_browser_test.rb index a36d72852..b7e529be1 100644 --- a/test/integration/twitter_browser_test.rb +++ b/test/integration/twitter_browser_test.rb @@ -29,6 +29,7 @@ class TwitterBrowserTest < TestCase username: 'master@example.com', password: 'test', url: browser_url, + auto_wizard: true, ) tasks_close_all()