diff --git a/tests/browser/features/popups_settings.feature b/tests/browser/features/popups_settings.feature new file mode 100644 index 000000000..fef7512bd --- /dev/null +++ b/tests/browser/features/popups_settings.feature @@ -0,0 +1,48 @@ +@chrome @en.m.wikipedia.beta.wmflabs.org @firefox @test2.m.wikipedia.org @vagrant @integration +Feature: Popups settings + 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: "Enable previews" footer link correctly appears + And I do not see the enable previews link in the footer + And I hover over the first valid link + And I see a hover card + And I disable previews in the popups settings + Then I should see the enable previews link in the footer + + Scenario: Disabling previews in the popup settings correctly disables popups + And I do not see the enable previews link in the footer + And I hover over the first valid link + And I see a hover card + And I disable previews in the popups settings + And I hover over the first valid link + Then I should not see a hover card + + Scenario: "Enable previews" footer link correctly disappears + And I do not see the enable previews link in the footer + And I hover over the first valid link + And I see a hover card + And I disable previews in the popups settings + And I enable previews in the popups settings + Then I should not see the enable previews link in the footer + + Scenario: Popups can be enabled via the "Enable previews" footer link + And I do not see the enable previews link in the footer + And I hover over the first valid link + And I see a hover card + And I disable previews in the popups settings + And I enable previews in the popups settings + And I hover over the first valid link + Then I should see a hover card + + Scenario: Dismissing settings dialog does not change popups settings + And I hover over the first valid link + And I see a hover card + And I open the popups settings dialog of the first valid link + And I dismiss the popups settings dialog of the first valid link + And I hover over the first valid link + Then I should see a hover card diff --git a/tests/browser/features/support/pages/article_page.rb b/tests/browser/features/support/pages/article_page.rb index c27d6c8c6..afef6f727 100644 --- a/tests/browser/features/support/pages/article_page.rb +++ b/tests/browser/features/support/pages/article_page.rb @@ -8,4 +8,11 @@ class ArticlePage div(:page_header, css: '#mw-head') a(:first_valid_link, css: 'ul a', index: 0) div(:hovercard, css: '.mwe-popups') + a(:settings_icon, css: '.mwe-popups-settings-icon') + radio(:enable_previews_radio, id: 'mwe-popups-settings-simple') + radio(:disable_previews_radio, id: 'mwe-popups-settings-disable_previews') + button(:cancel_settings_button, css: '#mwe-popups-settings-form button', index: 0) + button(:save_settings_button, css: '#mwe-popups-settings-form button', index: 1) + button(:settings_help_ok_button, css: '#mwe-popups-settings-help button', index: 0) + a(:last_link_in_the_footer, css: '#footer-places a', index: -1) end diff --git a/tests/browser/features/support/step_definitions/popups_core.rb b/tests/browser/features/support/step_definitions/popups_core.rb index d1374c10d..63db25973 100644 --- a/tests/browser/features/support/step_definitions/popups_core.rb +++ b/tests/browser/features/support/step_definitions/popups_core.rb @@ -6,6 +6,49 @@ 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 + 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 + 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 @@ -15,3 +58,17 @@ Then(/^I should not see a hover card$/) do 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 +