2014-11-07 21:28:03 +00:00
|
|
|
def make_page_with_user(title, text, username)
|
2014-08-05 00:41:33 +00:00
|
|
|
client = on(APIPage).client
|
2014-11-10 21:21:10 +00:00
|
|
|
client.log_in(username, ENV['MEDIAWIKI_PASSWORD'])
|
2014-08-05 00:41:33 +00:00
|
|
|
client.create_page(title, text)
|
|
|
|
end
|
|
|
|
|
2014-11-07 21:28:03 +00:00
|
|
|
def clear_notifications(username)
|
2014-08-08 17:10:01 +00:00
|
|
|
client = on(APIPage).client
|
|
|
|
step 'the user "' + username + '" exists'
|
2014-11-10 21:21:10 +00:00
|
|
|
client.log_in(username, ENV['MEDIAWIKI_PASSWORD'])
|
2014-11-07 21:28:03 +00:00
|
|
|
client.action('echomarkread', token_type: 'edit', all: '1')
|
2014-08-08 17:10:01 +00:00
|
|
|
end
|
|
|
|
|
2014-11-07 21:28:03 +00:00
|
|
|
def make_page_with_user_b(title, text)
|
|
|
|
username = get_session_username_b
|
2014-08-05 00:41:33 +00:00
|
|
|
step 'the user "' + username + '" exists'
|
2014-11-07 21:28:03 +00:00
|
|
|
make_page_with_user(title, text, username)
|
2014-08-05 00:41:33 +00:00
|
|
|
end
|
|
|
|
|
2014-11-07 21:28:03 +00:00
|
|
|
def make_page_with_user_a(title, text)
|
|
|
|
make_page_with_user(title, text, get_session_username)
|
2014-08-05 00:41:33 +00:00
|
|
|
end
|
|
|
|
|
2014-09-24 21:34:42 +00:00
|
|
|
def poll_for_new_notifications(number_of_polls)
|
|
|
|
number_of_polls.to_i.times do
|
|
|
|
step 'I am on the "Selenium Echo flyout test page" page'
|
|
|
|
break if on(ArticlePage).flyout_link_element.class_name =~ /mw-echo-unread-notifications/
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-08-19 22:34:47 +00:00
|
|
|
Given(/^another user has linked to a page I created from another page$/) do
|
|
|
|
title = 'Selenium Echo link test ' + @random_string
|
2014-11-10 21:21:10 +00:00
|
|
|
make_page_with_user_a(title, 'Selenium test page. Feel free to delete me.')
|
2014-08-19 22:34:47 +00:00
|
|
|
title2 = title + ' ' + @random_string
|
2014-11-10 21:21:10 +00:00
|
|
|
make_page_with_user_b(title2, 'I am linking to [[' + title + ']].')
|
2014-08-19 22:34:47 +00:00
|
|
|
end
|
|
|
|
|
2014-08-05 00:41:33 +00:00
|
|
|
Given(/^another user writes on my talk page$/) do
|
2015-02-20 16:43:04 +00:00
|
|
|
make_page_with_user_b(
|
|
|
|
'User talk:' + get_session_username,
|
|
|
|
"== Barnstar ==\nHello Selenium, here is a barnstar for all your testing! " +
|
|
|
|
@random_string + "~~~~\n")
|
2014-08-05 00:41:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Given(/^another user @s me on "(.*?)"$/) do |title|
|
2014-11-07 21:28:03 +00:00
|
|
|
username = get_session_username.sub('_', ' ')
|
2014-11-10 21:21:10 +00:00
|
|
|
text = '@' + username + ' Cho cho cho. ~~~~'
|
2014-08-05 00:41:33 +00:00
|
|
|
make_page_with_user_b(title, text)
|
|
|
|
end
|
|
|
|
|
2014-09-24 21:34:42 +00:00
|
|
|
Given(/^I reload the page (.*?) times or until a notification shows up$/) do |number_of_polls|
|
|
|
|
poll_for_new_notifications(number_of_polls)
|
2014-08-05 00:41:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Given(/^another user mentions me on the wiki$/) do
|
|
|
|
title = 'Selenium Echo mention test ' + @random_string
|
2014-11-07 21:28:03 +00:00
|
|
|
username = get_session_username.sub('_', ' ')
|
2014-08-05 00:41:33 +00:00
|
|
|
text = "== The walrus ==\n[[User:" + username + "]]: Cho cho cho. ~~~~\n"
|
|
|
|
make_page_with_user_b(title, text)
|
|
|
|
end
|
|
|
|
|
2014-09-08 07:03:32 +00:00
|
|
|
Given(/^I am logged in as a new user$/) do
|
2014-11-07 21:28:03 +00:00
|
|
|
@username = get_new_username
|
2014-09-08 07:03:32 +00:00
|
|
|
step 'I am logged in as the user "' + @username + '"'
|
|
|
|
end
|
|
|
|
|
2014-08-08 17:10:01 +00:00
|
|
|
Given(/^I am logged in as a new user with no notifications$/) do
|
2014-11-07 21:28:03 +00:00
|
|
|
@username = get_new_username
|
|
|
|
clear_notifications(@username)
|
2014-08-08 17:10:01 +00:00
|
|
|
step 'I am logged in as the user "' + @username + '"'
|
|
|
|
end
|
|
|
|
|
2014-08-05 00:41:33 +00:00
|
|
|
Given(/^I am logged in with no notifications$/) do
|
2014-08-13 23:11:38 +00:00
|
|
|
# Mark all messages as read
|
|
|
|
client = on(APIPage).client
|
2014-11-07 21:28:03 +00:00
|
|
|
username = get_session_username
|
2014-08-13 23:11:38 +00:00
|
|
|
step 'the user "' + username + '" exists'
|
2014-11-10 21:21:10 +00:00
|
|
|
client.log_in(username, ENV['MEDIAWIKI_PASSWORD'])
|
2014-11-07 21:28:03 +00:00
|
|
|
client.action('echomarkread', token_type: 'edit', all: '1')
|
2014-08-13 23:11:38 +00:00
|
|
|
|
2014-08-05 00:41:33 +00:00
|
|
|
step 'I am logged in my non-shared account'
|
2014-08-19 22:34:47 +00:00
|
|
|
step 'I have no new notifications'
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^I have no new notifications$/) do
|
2015-02-20 16:43:04 +00:00
|
|
|
expect(on(ArticlePage).flyout_link_element.when_present.class_name).not_to
|
|
|
|
match 'mw-echo-unread-notifications'
|
2014-08-05 00:41:33 +00:00
|
|
|
end
|
|
|
|
|
2014-08-05 00:20:59 +00:00
|
|
|
Then(/^I have new notifications$/) do
|
2015-02-20 16:43:04 +00:00
|
|
|
expect(on(ArticlePage).flyout_link_element.when_present.class_name).to
|
|
|
|
match 'mw-echo-unread-notifications'
|
2014-08-05 00:20:59 +00:00
|
|
|
end
|