mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-24 07:34:11 +00:00
Hygiene: Tidy up "core" acceptance tests
Changes: * Rename the somewhat awkwardly named "popups_core" Cucumber feature and its accompanying step definitions to "previews". * Remove as many references to Popups and HoverCards as possible. * Use language consistent with the QUnit unit and integration tests and documentation, e.g. the user dwells on a link. * Remove settings-related step definitions from the previews step definitions. Change-Id: Ibc0d07e8394aeb640f9efaabfe10be5317bf4b8c
This commit is contained in:
parent
68f04d62ec
commit
4db0043ee7
|
@ -1,17 +0,0 @@
|
|||
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant
|
||||
Feature: Popups core
|
||||
Background:
|
||||
Given the hover cards test page is installed
|
||||
And I am logged in
|
||||
And HoverCards is enabled as a beta feature
|
||||
And I am on the "Popups test page" page
|
||||
And the Hovercards JavaScript module has loaded
|
||||
|
||||
Scenario: Hover card is visible on mouse over
|
||||
And I hover over the first valid link
|
||||
Then I should see a hover card
|
||||
|
||||
Scenario: Hover card is not visible on mouse out
|
||||
And I hover over the first valid link
|
||||
And I hover over the page header
|
||||
Then I should not see a hover card
|
17
tests/browser/features/previews.feature
Normal file
17
tests/browser/features/previews.feature
Normal file
|
@ -0,0 +1,17 @@
|
|||
@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant
|
||||
Feature: Previews
|
||||
Background:
|
||||
Given the test page has been created
|
||||
And I am logged in
|
||||
And I have enabled the beta feature
|
||||
And I am on the "Popups test page" page
|
||||
And the RL module has loaded
|
||||
|
||||
Scenario: Dwelling on a valid link shows a preview
|
||||
When I dwell on the first valid link
|
||||
Then I should see a preview
|
||||
|
||||
Scenario: Abandoning the link hides the preview
|
||||
When I dwell on the first valid link
|
||||
And I abandon the link
|
||||
Then I should not see a preview
|
|
@ -3,14 +3,14 @@ class SpecialPreferencesPage
|
|||
page_url 'Special:Preferences'
|
||||
|
||||
a(:beta_features_tab, css: '#preftab-betafeatures')
|
||||
text_field(:hovercards_checkbox, css: '[name=wppopups]')
|
||||
text_field(:page_previews_checkbox, css: '[name=wppopups]')
|
||||
button(:submit_button, css: '#prefcontrol')
|
||||
div(:notification, css: ".mw-notification")
|
||||
|
||||
def enable_hovercards
|
||||
def enable_page_previews
|
||||
beta_features_tab_element.when_present.click
|
||||
return unless hovercards_checkbox_element.attribute('checked').nil?
|
||||
hovercards_checkbox_element.click
|
||||
return unless page_previews_checkbox_element.attribute('checked').nil?
|
||||
page_previews_checkbox_element.click
|
||||
submit_button_element.when_present.click
|
||||
|
||||
# Note well that Element#wait_until_present is more semantic but is
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Given(/^the hover cards test page is installed$/) do
|
||||
Given(/^the test page has been created$/) do
|
||||
api.create_page 'Popups test page', File.read('samples/links.wikitext')
|
||||
end
|
||||
|
||||
|
@ -6,14 +6,14 @@ Given(/^I am on the "(.*?)" page$/) do |page|
|
|||
visit(ArticlePage, using_params: { article_name: page })
|
||||
end
|
||||
|
||||
Then(/^HoverCards is enabled as a beta feature$/) do
|
||||
visit(SpecialPreferencesPage).enable_hovercards
|
||||
Given(/^I have enabled the beta feature$/) do
|
||||
visit(SpecialPreferencesPage).enable_page_previews
|
||||
end
|
||||
|
||||
Given(/^the Hovercards JavaScript module has loaded$/) do
|
||||
Given(/^the RL module has loaded$/) do
|
||||
on(ArticlePage) do |page|
|
||||
page.wait_until do
|
||||
browser.execute_script("return mw.loader.getState('ext.popups.desktop') === 'ready'")
|
||||
browser.execute_script("return mw.loader.getState('ext.popups') === 'ready'")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
When(/^I hover over the page header$/) do
|
||||
on(ArticlePage).page_header_element.hover
|
||||
end
|
||||
|
||||
When(/^I hover over the first valid link$/) do
|
||||
on(ArticlePage).first_valid_link_element.hover
|
||||
end
|
||||
|
||||
When(/^I see a hover card$/) do
|
||||
on(ArticlePage).hovercard_element.when_present
|
||||
end
|
||||
|
||||
When(/^I open the popups settings dialog of the first valid link$/) do
|
||||
step("I hover over the first valid link")
|
||||
on(ArticlePage).settings_icon_element.when_present.click
|
||||
end
|
||||
|
||||
When(/^I dismiss the popups settings dialog of the first valid link$/) do
|
||||
on(ArticlePage).cancel_settings_button_element.when_present.click
|
||||
end
|
||||
|
||||
When(/^I disable previews in the popups settings$/) do
|
||||
on(ArticlePage) do |page|
|
||||
page.settings_icon_element.when_present.click
|
||||
page.disable_previews_radio_element.when_present.click
|
||||
page.save_settings_button_element.when_present.click
|
||||
page.settings_help_ok_button_element.when_present.click
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
|
||||
When(/^I enable previews in the popups settings$/) do
|
||||
step("I see the enable previews link in the footer")
|
||||
on(ArticlePage) do |page|
|
||||
page.last_link_in_the_footer_element.when_present.click
|
||||
page.enable_previews_radio_element.when_present.click
|
||||
page.save_settings_button_element.when_present.click
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
|
||||
When(/^I see the enable previews link in the footer$/) do
|
||||
on(ArticlePage) do |page|
|
||||
page.wait_until do
|
||||
page.last_link_in_the_footer_element.when_present.text.include? 'Enable previews'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
When(/^I do not see the enable previews link in the footer$/) do
|
||||
!on(ArticlePage).last_link_in_the_footer_element.when_present.text.include? 'Enable previews'
|
||||
end
|
||||
|
||||
Then(/^I should see a hover card$/) do
|
||||
expect(on(ArticlePage).hovercard_element.when_present(5)).to be_visible
|
||||
end
|
||||
|
||||
Then(/^I should not see a hover card$/) do
|
||||
# Requesting a hovercard hits API so wait time before asserting it did not show
|
||||
sleep 5
|
||||
expect(on(ArticlePage).hovercard_element).not_to be_visible
|
||||
end
|
||||
|
||||
Then(/^I should see the enable previews link in the footer$/) do
|
||||
on(ArticlePage) do |page|
|
||||
page.wait_until do
|
||||
page.last_link_in_the_footer_element.when_present.text.include? 'Enable previews'
|
||||
end
|
||||
expect(page.last_link_in_the_footer_element.when_present.text).to match 'Enable previews'
|
||||
end
|
||||
end
|
||||
|
||||
Then(/^I should not see the enable previews link in the footer$/) do
|
||||
expect(on(ArticlePage).last_link_in_the_footer_element.when_present.text).not_to match 'Enable previews'
|
||||
end
|
||||
|
20
tests/browser/features/support/step_definitions/previews.rb
Normal file
20
tests/browser/features/support/step_definitions/previews.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
When(/^I dwell on the first valid link$/) do
|
||||
on(ArticlePage).first_valid_link_element.hover
|
||||
end
|
||||
|
||||
When(/^I abandon the link$/) do
|
||||
on(ArticlePage).page_header_element.hover
|
||||
end
|
||||
|
||||
Then(/^I should see a preview$/) do
|
||||
expect(on(ArticlePage).hovercard_element.when_present(5)).to be_visible
|
||||
end
|
||||
|
||||
Then(/^I should not see a preview$/) do
|
||||
|
||||
# Requesting a preview hits the API so wait some time before asserting it did
|
||||
# not show.
|
||||
sleep 5
|
||||
|
||||
expect(on(ArticlePage).hovercard_element).not_to be_visible
|
||||
end
|
Loading…
Reference in a new issue