mediawiki-extensions-Echo/tests/browser/features/step_definition/notifications_steps.rb
Stephane Bisson 10c4ed6f49 Browser Tests: fix
* extract notifications to components/notifications.rb
* wait for the flyout to be loaded before counting
  the unread notifications
* remove popup.feature because it is redudant with
  notifications.feature and too low-level
  for acceptance testing

Change-Id: If0b0286e8e98e379ae1d6d91db8084adda93b3f6
2015-11-12 15:17:07 -08:00

69 lines
1.6 KiB
Ruby

Given(/^all my notifications are read$/) do
clear_unread_notifications(@username)
end
Given(/^I refresh the page$/) do
on(ArticlePage) do |page|
page.refresh
end
end
Given(/^another user mentions me$/) do
message = '===Mention test===\nI am mentioning [[User:' + user(nil) +
']] in this page to test Echo notifications. ~~~~'
as_user(:b) do
api.create_page(
@data_manager.get('Echo_test_page'),
message
)
end
end
Given(/^another user writes on my talk page$/) do
talk_page = "User_talk:#{user}"
message = '===Talk page test===\n' +
'I am writing a message in your user page to test Echo notifications. ~~~~'
as_user(:b) do
api.create_page(talk_page, message)
end
end
Given(/^the alert badge is showing unseen notifications$/) do
on(ArticlePage) do |page|
page.refresh_until do
page.alerts.badge_unseen_element.visible?
end
end
end
Given(/^the message badge is showing unseen notifications$/) do
on(ArticlePage) do |page|
page.refresh_until do
page.messages.badge_unseen_element.visible?
end
end
end
Given(/^the alert badge value is "(.+)"$/) do |num|
on(ArticlePage) do |page|
page.refresh_until do
page.alerts.badge_element.text == num
end
end
end
Given(/^the message badge value is "(.+)"$/) do |num|
on(ArticlePage) do |page|
page.refresh_until do
page.messages.badge_element.text == num
end
end
end
Given(/^there are "(.+)" unread notifications in the message popup$/) do |num|
on(ArticlePage) do |page|
page.messages.when_loaded
expect(page.messages.num_unread_notifications).to eq(num.to_i)
end
end