mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-02 11:26:26 +00:00
b3df4d0814
* add @custom_browser tag so we don't create an extra browser instance * remove @chrome tag because this only works in Firefox * alphabetize within G/W/T buckets in commons_steps.rb * alphabetize flyout_steps.rb * bring env.rb up to date with the modern situation * make assertions about the URL and heading on the final destination page * update Ruby gems, especially mediawiki-selenium with a @custom_browser improvement ** use modern RSpec assert syntax *** we're going to have to update all the repos for this soon Change-Id: I6cb20126a662bd2a20e2b4bbebe91e8f3b04c7df
64 lines
2 KiB
Ruby
64 lines
2 KiB
Ruby
def get_new_username
|
|
"EchoUserNew#{@random_string}"
|
|
end
|
|
|
|
def get_session_username
|
|
"#{ENV["MEDIAWIKI_USER"]}_#{@browser.name}"
|
|
end
|
|
|
|
def get_session_username_b
|
|
"EchoUser"
|
|
end
|
|
|
|
Given(/^I am logged in as the user "(.*?)"$/) do |username|
|
|
step 'the user "' + username +'" exists'
|
|
visit(LoginPage).login_with(username, ENV["MEDIAWIKI_PASSWORD"])
|
|
end
|
|
|
|
# Note Echo redefines this so that the user is unique to the current browser
|
|
Given(/^I am logged in my non-shared account$/) do
|
|
username = get_session_username()
|
|
step 'I am logged in as the user "' + username + '"'
|
|
end
|
|
|
|
Given(/^I am on the "(.+)" page$/) do |title|
|
|
on(APIPage).create title, "Test is used by Selenium web driver"
|
|
visit(ArticlePage, :using_params => {:article_name => title})
|
|
end
|
|
|
|
Given(/^I am using user agent "(.+)"$/) do |user_agent|
|
|
@user_agent = user_agent
|
|
@browser = browser(test_name(@scenario), {user_agent: user_agent})
|
|
$session_id = @browser.driver.instance_variable_get(:@bridge).session_id
|
|
end
|
|
|
|
Given(/^my user rights get changed$/) do
|
|
@username = get_new_username()
|
|
client = on(APIPage).client
|
|
client.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"])
|
|
resp = client.query(action: "query", list: "users", ususers: @username, ustoken: 'userrights')
|
|
data = resp.data()
|
|
@token = data["users"][0]["userrightstoken"]
|
|
client.action('userrights', token_type: false, token: @token, add: "bot", user: @username)
|
|
end
|
|
|
|
Given(/^the user "(.*?)" exists$/) do |username|
|
|
on(APIPage).client.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"])
|
|
begin
|
|
on(APIPage).client.create_account(username, ENV["MEDIAWIKI_PASSWORD"])
|
|
puts "Successfully created user " + username
|
|
rescue MediawikiApi::ApiError
|
|
puts 'Assuming in step that user ' + username + ' already exists since was unable to create.'
|
|
end
|
|
end
|
|
|
|
Then(/^I am on the Special Notifications page$/) do
|
|
expect(@browser.url).to match "Special:Notifications"
|
|
end
|
|
|
|
Then(/^I see the first heading on the page says Notifications$/) do
|
|
expect(on(ArticlePage).first_heading_span).to match "Notifications"
|
|
end
|
|
|
|
|