2014-09-22 22:00:35 +00:00
|
|
|
def get_new_username
|
|
|
|
"EchoUserNew#{@random_string}"
|
2014-08-13 23:11:38 +00:00
|
|
|
end
|
|
|
|
|
2014-09-22 22:00:35 +00:00
|
|
|
def get_session_username
|
|
|
|
"#{ENV["MEDIAWIKI_USER"]}_#{@browser.name}"
|
2014-08-08 17:10:01 +00:00
|
|
|
end
|
|
|
|
|
2014-09-22 22:00:35 +00:00
|
|
|
def get_session_username_b
|
|
|
|
"EchoUser"
|
2014-08-04 23:07:37 +00:00
|
|
|
end
|
|
|
|
|
2014-09-22 22:00:35 +00:00
|
|
|
Given(/^I am logged in as the user "(.*?)"$/) do |username|
|
2014-11-07 21:28:03 +00:00
|
|
|
step 'the user "' + username + '" exists'
|
2014-09-22 22:00:35 +00:00
|
|
|
visit(LoginPage).login_with(username, ENV["MEDIAWIKI_PASSWORD"])
|
2014-08-04 23:07:37 +00:00
|
|
|
end
|
|
|
|
|
2014-09-22 22:00:35 +00:00
|
|
|
# Note Echo redefines this so that the user is unique to the current browser
|
|
|
|
Given(/^I am logged in my non-shared account$/) do
|
2014-11-07 21:28:03 +00:00
|
|
|
username = get_session_username
|
2014-09-22 22:00:35 +00:00
|
|
|
step 'I am logged in as the user "' + username + '"'
|
2014-08-04 23:07:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Given(/^I am on the "(.+)" page$/) do |title|
|
|
|
|
on(APIPage).create title, "Test is used by Selenium web driver"
|
2014-11-07 21:28:03 +00:00
|
|
|
visit(ArticlePage, using_params: { article_name: title })
|
2014-08-04 23:07:37 +00:00
|
|
|
end
|
2014-08-05 00:20:59 +00:00
|
|
|
|
2014-09-22 22:00:35 +00:00
|
|
|
Given(/^I am using user agent "(.+)"$/) do |user_agent|
|
|
|
|
@user_agent = user_agent
|
2014-11-07 21:28:03 +00:00
|
|
|
@browser = browser(test_name(@scenario), user_agent: user_agent)
|
2014-09-22 22:00:35 +00:00
|
|
|
$session_id = @browser.driver.instance_variable_get(:@bridge).session_id
|
|
|
|
end
|
|
|
|
|
|
|
|
Given(/^my user rights get changed$/) do
|
2014-11-07 21:28:03 +00:00
|
|
|
@username = get_new_username
|
2014-09-22 22:00:35 +00:00
|
|
|
client = on(APIPage).client
|
|
|
|
client.log_in(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"])
|
|
|
|
resp = client.query(action: "query", list: "users", ususers: @username, ustoken: 'userrights')
|
2014-11-07 21:28:03 +00:00
|
|
|
data = resp.data
|
2014-09-22 22:00:35 +00:00
|
|
|
@token = data["users"][0]["userrightstoken"]
|
|
|
|
client.action('userrights', token_type: false, token: @token, add: "bot", user: @username)
|
|
|
|
end
|
|
|
|
|
2014-08-05 00:41:33 +00:00
|
|
|
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"])
|
2014-08-08 17:10:01 +00:00
|
|
|
puts "Successfully created user " + username
|
2014-08-05 00:41:33 +00:00
|
|
|
rescue MediawikiApi::ApiError
|
2014-08-08 17:10:01 +00:00
|
|
|
puts 'Assuming in step that user ' + username + ' already exists since was unable to create.'
|
2014-08-05 00:41:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-22 22:00:35 +00:00
|
|
|
Then(/^I am on the Special Notifications page$/) do
|
|
|
|
expect(@browser.url).to match "Special:Notifications"
|
2014-08-05 00:41:33 +00:00
|
|
|
end
|
|
|
|
|
2014-09-22 22:00:35 +00:00
|
|
|
Then(/^I see the first heading on the page says Notifications$/) do
|
|
|
|
expect(on(ArticlePage).first_heading_span).to match "Notifications"
|
2014-08-05 00:20:59 +00:00
|
|
|
end
|