mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-03 20:06:59 +00:00
0d23ba8bbe
Some browser tests were broken by 945fccf009
.
The badge element is now technically rendered offscreen, with only the
:before and :after pseudoelements being onscreen. Because of this, Selenium
thinks that the badges are invisible, and this breaks various things in
totally unexpected ways.
* article_page.rb: Store references to the parent <li> elements of badges.
This might not be necessary but I don't know how to access them otherwise.
* badge_steps.rb: When clicking the badges, click the parent <li> element
rather than the not-really-invisible <a>. Effectively, the <a> gets
clicked anyway, since they overlap.
* no_javascript.feature/no_javascript.rb: Wait for page load before
checking that we're on the right page. The wait is no longer
implicit, since Selenium thinks we're clicking the <li> rather than
<a> (links are special-cased).
* notification_steps.rb:
* Check whether the badges exist on the page, rather than whether they
are visible.
* Use a weird hack to read badge text. Apparently you can't read the text
of elements that Selenium thinks are invisible.
http://stackoverflow.com/questions/20888592/gettext-method-of-selenium-chrome-driver-sometimes-returns-an-empty-string
Bug: T161941
Change-Id: Ic6bcd1088249109e49a47cc9007e6ee002d3d8ba
77 lines
1.9 KiB
Ruby
77 lines
1.9 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.exists?
|
|
end
|
|
end
|
|
end
|
|
|
|
Given(/^the notice badge is showing unseen notifications$/) do
|
|
on(ArticlePage) do |page|
|
|
page.refresh_until do
|
|
page.notices.badge_unseen_element.exists?
|
|
end
|
|
end
|
|
end
|
|
|
|
Given(/^the alert badge value is "(.+)"$/) do |num|
|
|
on(ArticlePage) do |page|
|
|
page.refresh_until do
|
|
# `.text` doesn't work for invisible elements, and Selenium thinks the badge is invisible
|
|
page.alerts.badge_element.attribute('innerText') == num
|
|
end
|
|
end
|
|
end
|
|
|
|
Given(/^the notice badge value is "(.+)"$/) do |num|
|
|
on(ArticlePage) do |page|
|
|
page.refresh_until do
|
|
page.notices.badge_element.attribute('innerText') == num
|
|
end
|
|
end
|
|
end
|
|
|
|
Given(/^there are "(.+)" unread notifications in the notice popup$/) do |num|
|
|
on(ArticlePage) do |page|
|
|
page.notices.when_loaded
|
|
expect(page.notices.num_unread_notifications).to eq(num.to_i)
|
|
end
|
|
end
|
|
|
|
Given(/^there are "(.+)" unread notifications in the alert popup$/) do |num|
|
|
on(ArticlePage) do |page|
|
|
page.alerts.when_loaded
|
|
expect(page.alerts.num_unread_notifications).to eq(num.to_i)
|
|
end
|
|
end
|