Sbisson has uploaded a new change for review. https://gerrit.wikimedia.org/r/252711
Change subject: Browser Tests: fix ...................................................................... Browser Tests: fix * extract notifications to components/notifications.rb * wait for the flyout to be loaded before counting the unred notifications * remove popup.feature because it is redudant with notifications.feature and too low-level for acceptance testing Change-Id: If0b0286e8e98e379ae1d6d91db8084adda93b3f6 --- D tests/browser/features/popup.feature M tests/browser/features/step_definition/badge_steps.rb M tests/browser/features/step_definition/notifications_steps.rb M tests/browser/features/step_definition/popup_steps.rb A tests/browser/features/support/components/notifications.rb M tests/browser/features/support/pages/article_page.rb 6 files changed, 34 insertions(+), 58 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/11/252711/1 diff --git a/tests/browser/features/popup.feature b/tests/browser/features/popup.feature deleted file mode 100644 index 12615b1..0000000 --- a/tests/browser/features/popup.feature +++ /dev/null @@ -1,10 +0,0 @@ -@firefox [email protected] -Feature: Basic features for no-js functionality - - Background: - Given I am logged in - - Scenario: Clicking alerts badge loads the alert popup - When I click the alert badge - Then I see the alert popup diff --git a/tests/browser/features/step_definition/badge_steps.rb b/tests/browser/features/step_definition/badge_steps.rb index 8cb7cfe..73bf8c3 100644 --- a/tests/browser/features/step_definition/badge_steps.rb +++ b/tests/browser/features/step_definition/badge_steps.rb @@ -2,9 +2,9 @@ # Work in both nojs and js version Given(/^I click the alert badge$/) do - on(ArticlePage).notifications_badge_alert + on(ArticlePage).alerts.badge end Given(/^I click the message badge$/) do - on(ArticlePage).notifications_badge_message + on(ArticlePage).messages.badge end diff --git a/tests/browser/features/step_definition/notifications_steps.rb b/tests/browser/features/step_definition/notifications_steps.rb index 4c5721c..e8d1a6b 100644 --- a/tests/browser/features/step_definition/notifications_steps.rb +++ b/tests/browser/features/step_definition/notifications_steps.rb @@ -13,9 +13,9 @@ ']] in this page to test Echo notifications. ~~~~' as_user(:b) do api.create_page( - @data_manager.get('Echo_test_page'), - message - ) + @data_manager.get('Echo_test_page'), + message + ) end end @@ -31,7 +31,7 @@ Given(/^the alert badge is showing unseen notifications$/) do on(ArticlePage) do |page| page.refresh_until do - page.notifications_badge_alert_unseen_element.visible? + page.alerts.badge_unseen_element.visible? end end end @@ -39,7 +39,7 @@ Given(/^the message badge is showing unseen notifications$/) do on(ArticlePage) do |page| page.refresh_until do - page.notifications_badge_message_unseen_element.visible? + page.messages.badge_unseen_element.visible? end end end @@ -47,7 +47,7 @@ Given(/^the alert badge value is "(.+)"$/) do |num| on(ArticlePage) do |page| page.refresh_until do - page.notifications_badge_alert_element.text == num + page.alerts.badge_element.text == num end end end @@ -55,14 +55,14 @@ Given(/^the message badge value is "(.+)"$/) do |num| on(ArticlePage) do |page| page.refresh_until do - page.notifications_badge_message_element.text == num + 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.popup_title(page.popup_message_element) - expect(page.num_unread_message_notifications).to eq(num.to_i) + page.messages.when_loaded + expect(page.messages.num_unread_notifications).to eq(num.to_i) end end diff --git a/tests/browser/features/step_definition/popup_steps.rb b/tests/browser/features/step_definition/popup_steps.rb index 720e323..e6c8f0f 100644 --- a/tests/browser/features/step_definition/popup_steps.rb +++ b/tests/browser/features/step_definition/popup_steps.rb @@ -1,11 +1,11 @@ Given(/^I see the alert popup$/) do on(ArticlePage) do |page| - expect(page.popup_title(page.popup_alert_element).text).to match('Alerts') + expect(page.alerts.title_element.when_present.text).to match('Alerts') end end Given(/^I see the message popup$/) do on(ArticlePage) do |page| - expect(page.popup_title(page.popup_message_element).text).to match('Messages') + expect(page.messages.title_element.when_present.text).to match('Messages') end end diff --git a/tests/browser/features/support/components/notifications.rb b/tests/browser/features/support/components/notifications.rb new file mode 100644 index 0000000..1f91440 --- /dev/null +++ b/tests/browser/features/support/components/notifications.rb @@ -0,0 +1,19 @@ +class Notifications + include PageObject + + link(:badge) + link(:badge_unseen, css: '.mw-echo-unseen-notifications') + link(:mark_all_as_read, css: '.mw-echo-ui-notificationsWidget-markAllReadButton > a') + div(:popup, css: '.mw-echo-ui-notificationBadgeButtonPopupWidget-popup') + span(:title, css: '.oo-ui-popupWidget-head > .oo-ui-labelElement-label') + div(:notifications_container, css: '.mw-echo-ui-notificationsWidget') + + def when_loaded + title_element.when_present + notifications_container_element.when_present + end + + def num_unread_notifications + div_elements(css: '.mw-echo-ui-notificationOptionWidget-unread').size + end +end \ No newline at end of file diff --git a/tests/browser/features/support/pages/article_page.rb b/tests/browser/features/support/pages/article_page.rb index 216cc62..4126fd7 100644 --- a/tests/browser/features/support/pages/article_page.rb +++ b/tests/browser/features/support/pages/article_page.rb @@ -1,39 +1,6 @@ -# Page Object describing Headings, Flyouts, and Overlay in Echo class ArticlePage include PageObject - h1(:first_heading, id: 'firstHeading') - - li(:notifications_alert, css: '#pt-notifications-alert') - li(:notifications_message, css: '#pt-notifications-message') - link(:notifications_badge_alert, css: '#pt-notifications-alert a') - link(:notifications_badge_message, css: '#pt-notifications-message a') - div(:popup_alert, - css: '#pt-notifications-alert .mw-echo-ui-notificationBadgeButtonPopupWidget-popup') - div(:popup_message, - css: '#pt-notifications-message .mw-echo-ui-notificationBadgeButtonPopupWidget-popup') - - link(:notifications_badge_alert_unseen, - css: '#pt-notifications-alert a.mw-echo-unseen-notifications') - link(:notifications_badge_message_unseen, - css: '#pt-notifications-message a.mw-echo-unseen-notifications') - - # Popup elements - button(:mark_all_read_button, css: '.mw-echo-ui-notificationsWidget-markAllReadButton') - def popup_title(popupElement) - popupElement.when_present.span_element( - css: '.oo-ui-popupWidget-head > .oo-ui-labelElement-label') - end - - # Notification elements - a(:notification_option, css: '.mw-echo-ui-notificationOptionWidget') - a(:notification_option_unread, css: '.mw-echo-ui-notificationOptionWidget-unread') - a(:notification_option_markRead, css: '.mw-echo-ui-notificationOptionWidget-markAsReadButton') - def num_unread_message_notifications - # Count the number of elements that are unseen notification divs - # Taken from http://stackoverflow.com/questions/6433084/how-to-get-the-number-of-elements-having-same-attribute-in-html-in-watir - browser.elements( - css: '.mw-echo-ui-notificationOptionWidget-unread.mw-echo-ui-notificationOptionWidget-message' - ).size - end + page_section(:alerts, Notifications, css: '#pt-notifications-alert') + page_section(:messages, Notifications, css: '#pt-notifications-message') end -- To view, visit https://gerrit.wikimedia.org/r/252711 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If0b0286e8e98e379ae1d6d91db8084adda93b3f6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Sbisson <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
