Zfilipin has uploaded a new change for review. https://gerrit.wikimedia.org/r/86845
Change subject: Updated the repository to the latest version of shared test files ...................................................................... Updated the repository to the latest version of shared test files Bug: 53579 Change-Id: I6767477414ff3c659bb6bec3b89b0fd566225c8d --- D tests/browser/.gitignore M tests/browser/features/step_definitions/common_steps.rb M tests/browser/features/support/env.rb M tests/browser/tags.txt 4 files changed, 19 insertions(+), 44 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TwnMainPage refs/changes/45/86845/1 diff --git a/tests/browser/.gitignore b/tests/browser/.gitignore deleted file mode 100644 index 9fc7a0c..0000000 --- a/tests/browser/.gitignore +++ /dev/null @@ -1 +0,0 @@ -config/secret.yml diff --git a/tests/browser/features/step_definitions/common_steps.rb b/tests/browser/features/step_definitions/common_steps.rb index fa8ed56..6632e3a 100644 --- a/tests/browser/features/step_definitions/common_steps.rb +++ b/tests/browser/features/step_definitions/common_steps.rb @@ -2,7 +2,7 @@ end Given(/^I am logged in$/) do - visit(LoginPage).login_with(@mediawiki_username, @mediawiki_password) + visit(LoginPage).login_with(@mediawiki_username, ENV['MEDIAWIKI_PASSWORD']) # Assert that login worked loggedin = !@browser.execute_script( "return mw.user.isAnon();" ) loggedin.should be_true diff --git a/tests/browser/features/support/env.rb b/tests/browser/features/support/env.rb index 75f62b5..d56c8c4 100644 --- a/tests/browser/features/support/env.rb +++ b/tests/browser/features/support/env.rb @@ -7,16 +7,16 @@ World(PageObject::PageFactory) -def browser(environment, test_name, saucelabs_username, saucelabs_key, language) - if environment == :cloudbees - sauce_browser(test_name, saucelabs_username, saucelabs_key, language) +def browser(environment, test_name, language) + if environment == :saucelabs + sauce_browser(test_name, language) else local_browser(language) end end def environment - if ENV['ENVIRONMENT'] == 'cloudbees' - :cloudbees + if ENV['BROWSER_LABEL'] and ENV['SAUCE_ONDEMAND_USERNAME'] and ENV['SAUCE_ONDEMAND_ACCESS_KEY'] + :saucelabs else :local end @@ -42,10 +42,10 @@ Watir::Browser.new browser_label, :profile => profile end end -def sauce_api(json, saucelabs_username, saucelabs_key) - %x{curl -H 'Content-Type:text/json' -s -X PUT -d '#{json}' http://#{saucelabs_username}:#{saucelabs_key}@saucelabs.com/rest/v1/#{saucelabs_username}/jobs/#{$session_id}} +def sauce_api(json) + %x{curl -H 'Content-Type:text/json' -s -X PUT -d '#{json}' http://#{ENV['SAUCE_ONDEMAND_USERNAME']}:#{ENV['SAUCE_ONDEMAND_ACCESS_KEY']}@saucelabs.com/rest/v1/#{ENV['SAUCE_ONDEMAND_USERNAME']}/jobs/#{$session_id}} end -def sauce_browser(test_name, saucelabs_username, saucelabs_key, language) +def sauce_browser(test_name, language) config = YAML.load_file('config/config.yml') browser_label = config[ENV['BROWSER_LABEL']] @@ -69,7 +69,7 @@ browser = Watir::Browser.new( :remote, http_client: Selenium::WebDriver::Remote::Http::Persistent.new, - url: "http://#{saucelabs_username}:#{saucelabs_key}@ondemand.saucelabs.com:80/wd/hub", + url: "http://#{ENV['SAUCE_ONDEMAND_USERNAME']}:#{ENV['SAUCE_ONDEMAND_ACCESS_KEY']}@ondemand.saucelabs.com:80/wd/hub", desired_capabilities: caps) browser.wd.file_detector = lambda do |args| @@ -80,13 +80,7 @@ browser end -def secret_yml_location - secret_yml_locations = ['/private/wmf/', 'config/'] - secret_yml_locations.each do |secret_yml_location| - return secret_yml_location if File.exists?("#{secret_yml_location}secret.yml") - end - nil -end + def test_name(scenario) if scenario.respond_to? :feature "#{scenario.feature.name}: #{scenario.name}" @@ -98,41 +92,27 @@ config = YAML.load_file('config/config.yml') mediawiki_username = config['mediawiki_username'] -unless secret_yml_location == nil - secret = YAML.load_file("#{secret_yml_location}secret.yml") - mediawiki_password = secret['mediawiki_password'] -end - -if ENV['ENVIRONMENT'] == 'cloudbees' - saucelabs_username = secret['saucelabs_username'] - saucelabs_key = secret['saucelabs_key'] +Before('@login') do + puts "MEDIAWIKI_PASSWORD environment variable is not defined! Please export a value for that variable before proceeding." unless ENV['MEDIAWIKI_PASSWORD'] end Before('@language') do |scenario| @language = true - @saucelabs_username = saucelabs_username - @saucelabs_key = saucelabs_key @scenario = scenario -end -Before('@login') do - puts "secret.yml file at /private/wmf/ or config/ is required for tests tagged @login" if secret_yml_location == nil end Before do |scenario| @config = config - @does_not_exist_page_name = Random.new.rand.to_s + @random_string = Random.new.rand.to_s @mediawiki_username = mediawiki_username - @mediawiki_password = mediawiki_password - unless @language - @browser = browser(environment, test_name(scenario), saucelabs_username, saucelabs_key, 'default') - $session_id = @browser.driver.instance_variable_get(:@bridge).session_id - end + @browser = browser(environment, test_name(scenario), 'default') + $session_id = @browser.driver.instance_variable_get(:@bridge).session_id end After do |scenario| - if environment == :cloudbees - sauce_api(%Q{{"passed": #{scenario.passed?}}}, saucelabs_username, saucelabs_key) - sauce_api(%Q{{"public": true}}, saucelabs_username, saucelabs_key) + if environment == :saucelabs + sauce_api(%Q{{"passed": #{scenario.passed?}}}) + sauce_api(%Q{{"public": true}}) end @browser.close unless ENV['KEEP_BROWSER_OPEN'] == 'true' end diff --git a/tests/browser/tags.txt b/tests/browser/tags.txt index 503951b..df7d065 100644 --- a/tests/browser/tags.txt +++ b/tests/browser/tags.txt @@ -1,9 +1,5 @@ This file contains the descriptions of the tags we use. -@language - This tests needs support from Accept-Language header setting from the - webdriver. - @login This test logs in. You can filter these tests out if you don't have an account available. -- To view, visit https://gerrit.wikimedia.org/r/86845 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6767477414ff3c659bb6bec3b89b0fd566225c8d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TwnMainPage Gerrit-Branch: master Gerrit-Owner: Zfilipin <zfili...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits