mediawiki-extensions-Echo/tests/browser/features/step_definitions/notifications_steps.rb

92 lines
3 KiB
Ruby
Raw Normal View History

def make_page_with_user(title, text, username)
client = on(APIPage).client
client.log_in(username, ENV['MEDIAWIKI_PASSWORD'])
client.create_page(title, text)
end
def clear_notifications(username)
client = on(APIPage).client
step 'the user "' + username + '" exists'
client.log_in(username, ENV['MEDIAWIKI_PASSWORD'])
client.action('echomarkread', token_type: 'edit', all: '1')
end
def make_page_with_user_b(title, text)
username = session_username_b
step 'the user "' + username + '" exists'
make_page_with_user(title, text, username)
end
def make_page_with_user_a(title, text)
make_page_with_user(title, text, session_username)
end
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'
Split alerts and messages in Echo Split the notifications into 'alert' and 'message' badget with two different flyouts. Also clean up styling and module behavior. ** Depends on ooui change Id4bbe14ba0bf6c for footers in popups. ** Depends on ooui change Ie93e4d6ed5637c for fixing a bug in inverted icons. ** MobileFrontend must also be updated to support the new modules in this patch I168f485d6e54cb4067 In this change: * Split notifcations into alert and messages and display those in two different badges. * Create two separate flyout/popups for each category with their notifications. * Create a view-model to control notification state and emit events for both the popup and the badge to intercept and react to. * Clean up module load and distribution: * Create an ext.echo.ui module for javascript-ui support and ooui widgets. * Create an ext.echo.nojs module that unifies all base classes that are needed for both nojs and js support, that the js version builds upon. * Create a separate ext.echo.logger module as a singleton that can be called to perform all logging. * Clean up style uses * Move the special page LESS file into nojs module so all styles load properly even in nojs mode. * Transfer some of the styling from JS to LESS for consistency. * Make the 'read more' button load already with the styles it needs to look like a button, since its behavior is similar in nojs and js vesions, but before its classes were applied only by the js, making it inconsistent and also making its appearance 'jump' from a link to a button. * Delete and clean up all old and unused files. * Moved 'Help.png' icon from modules/overlay to modules/icons for later use. Bug: T108190 Change-Id: I55f440ed9f64c46817f620328a6bb522d44c9ca9
2015-08-13 00:54:16 +00:00
break if on(ArticlePage).flyout_link_element.class_name =~ /mw-echo-unseen-notifications/
end
end
Given(/^another user has linked to a page I created from another page$/) do
title = 'Selenium Echo link test ' + @random_string
make_page_with_user_a(title, 'Selenium test page. Feel free to delete me.')
title2 = title + ' ' + @random_string
make_page_with_user_b(title2, 'I am linking to [[' + title + ']].')
end
Given(/^another user writes on my talk page$/) do
make_page_with_user_b(
'User talk:' + session_username,
"== Barnstar ==\nHello Selenium, here is a barnstar for all your testing! " +
@random_string + "~~~~\n")
end
Given(/^another user @s me on "(.*?)"$/) do |title|
username = session_username.sub('_', ' ')
text = '@' + username + ' Cho cho cho. ~~~~'
make_page_with_user_b(title, text)
end
Given(/^I reload the page (.*?) times or until a notification shows up$/) do |number_of_polls|
poll_for_new_notifications(number_of_polls)
end
Given(/^another user mentions me on the wiki$/) do
title = 'Selenium Echo mention test ' + @random_string
username = session_username.sub('_', ' ')
text = "== The walrus ==\n[[User:" + username + "]]: Cho cho cho. ~~~~\n"
make_page_with_user_b(title, text)
end
Given(/^I am logged in as a new user$/) do
@username = new_username
step 'I am logged in as the user "' + @username + '"'
end
Given(/^I am logged in as a new user with no notifications$/) do
@username = new_username
clear_notifications(@username)
step 'I am logged in as the user "' + @username + '"'
end
Given(/^I am logged in with no notifications$/) do
# Mark all messages as read
client = on(APIPage).client
username = session_username
step 'the user "' + username + '" exists'
client.log_in(username, ENV['MEDIAWIKI_PASSWORD'])
client.action('echomarkread', token_type: 'edit', all: '1')
step 'I am logged in my non-shared account'
step 'I have no new notifications'
end
Then(/^I have no new notifications$/) do
Split alerts and messages in Echo Split the notifications into 'alert' and 'message' badget with two different flyouts. Also clean up styling and module behavior. ** Depends on ooui change Id4bbe14ba0bf6c for footers in popups. ** Depends on ooui change Ie93e4d6ed5637c for fixing a bug in inverted icons. ** MobileFrontend must also be updated to support the new modules in this patch I168f485d6e54cb4067 In this change: * Split notifcations into alert and messages and display those in two different badges. * Create two separate flyout/popups for each category with their notifications. * Create a view-model to control notification state and emit events for both the popup and the badge to intercept and react to. * Clean up module load and distribution: * Create an ext.echo.ui module for javascript-ui support and ooui widgets. * Create an ext.echo.nojs module that unifies all base classes that are needed for both nojs and js support, that the js version builds upon. * Create a separate ext.echo.logger module as a singleton that can be called to perform all logging. * Clean up style uses * Move the special page LESS file into nojs module so all styles load properly even in nojs mode. * Transfer some of the styling from JS to LESS for consistency. * Make the 'read more' button load already with the styles it needs to look like a button, since its behavior is similar in nojs and js vesions, but before its classes were applied only by the js, making it inconsistent and also making its appearance 'jump' from a link to a button. * Delete and clean up all old and unused files. * Moved 'Help.png' icon from modules/overlay to modules/icons for later use. Bug: T108190 Change-Id: I55f440ed9f64c46817f620328a6bb522d44c9ca9
2015-08-13 00:54:16 +00:00
expect(on(ArticlePage).flyout_link_element.when_present.class_name).not_to match 'mw-echo-unseen-notifications'
end
Then(/^I have new notifications$/) do
Split alerts and messages in Echo Split the notifications into 'alert' and 'message' badget with two different flyouts. Also clean up styling and module behavior. ** Depends on ooui change Id4bbe14ba0bf6c for footers in popups. ** Depends on ooui change Ie93e4d6ed5637c for fixing a bug in inverted icons. ** MobileFrontend must also be updated to support the new modules in this patch I168f485d6e54cb4067 In this change: * Split notifcations into alert and messages and display those in two different badges. * Create two separate flyout/popups for each category with their notifications. * Create a view-model to control notification state and emit events for both the popup and the badge to intercept and react to. * Clean up module load and distribution: * Create an ext.echo.ui module for javascript-ui support and ooui widgets. * Create an ext.echo.nojs module that unifies all base classes that are needed for both nojs and js support, that the js version builds upon. * Create a separate ext.echo.logger module as a singleton that can be called to perform all logging. * Clean up style uses * Move the special page LESS file into nojs module so all styles load properly even in nojs mode. * Transfer some of the styling from JS to LESS for consistency. * Make the 'read more' button load already with the styles it needs to look like a button, since its behavior is similar in nojs and js vesions, but before its classes were applied only by the js, making it inconsistent and also making its appearance 'jump' from a link to a button. * Delete and clean up all old and unused files. * Moved 'Help.png' icon from modules/overlay to modules/icons for later use. Bug: T108190 Change-Id: I55f440ed9f64c46817f620328a6bb522d44c9ca9
2015-08-13 00:54:16 +00:00
expect(on(ArticlePage).flyout_link_element.when_present.class_name).to match 'mw-echo-unseen-notifications'
end