From 3bd4bb4f03001cde21f079f1c16b9cd43c237ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Laxstr=C3=B6m?= Date: Wed, 28 Aug 2013 14:07:14 +0300 Subject: [PATCH] Refactor ULS tests to reduce duplication and repetition Change-Id: I96f1594f1b4d1960da9a8bc21e2a5c4727497b10 --- tests/browser/features/font_selection.feature | 65 ++++++----- .../features/step_definitions/common_steps.rb | 13 +++ .../features/step_definitions/panel_steps.rb | 16 ++- .../uls_cog_sidebar_user_steps.rb | 62 +++------- .../support/modules/interlanguage_module.rb | 11 +- .../features/support/pages/panel_page.rb | 18 ++- .../uls_cog_sidebar_anon_user.feature | 109 +++++++++--------- .../uls_cog_sidebar_logged_user.feature | 68 ----------- 8 files changed, 146 insertions(+), 216 deletions(-) delete mode 100644 tests/browser/features/uls_cog_sidebar_logged_user.feature diff --git a/tests/browser/features/font_selection.feature b/tests/browser/features/font_selection.feature index 8e3b122c..621b6b96 100644 --- a/tests/browser/features/font_selection.feature +++ b/tests/browser/features/font_selection.feature @@ -1,38 +1,43 @@ @reset-preferences-after @login @en.wikipedia.beta.wmflabs.org @commons.wikimedia.beta.wmflabs.org Feature: Font selection -In order to have better using experience, -As a reader and writer, -I want to change or disable the fonts for interface and content. + In order to have better using experience, + As a reader and writer, + I want to change or disable the fonts for interface and content. -In addition the user is provided live preview feature: changes are applied -immediately when selection is made. Changes can either be applied or discared -for easy testing. + In addition the user is provided live preview feature: changes are applied + immediately when selection is made. Changes can either be applied or discared + for easy testing. -Background: - Given I am logged in - And I set "German" as the interface language - And the content language is "English" - And I inspect current fonts + Background: + Given I am logged in + And I set "German" as the interface language + And the content language is "English" + And I inspect current fonts -Scenario: Discarding live preview of content font - When I open "Fonts" panel of language settings - And I select "OpenDyslexic" font for the content language for the live preview - And I close the panel to discard the changes - Then the active content font must be the same as font prior to the preview - # System is the default value for English and German - And the selected content font must be "system" + Scenario: Font selector appears + When I open "Fonts" panel of language settings + Then a font selector for interface language appears + Then a font selector for content language appears -Scenario: Discarding live preview of interface font - When I open "Fonts" panel of language settings - And I select "OpenDyslexic" font for the interface language for the live preview - And I close the panel to discard the changes - Then the active interface font must be the same as font prior to the preview - # System is the default value for English and German - And the selected interface font must be "system" + Scenario: Discarding live preview of content font + When I open "Fonts" panel of language settings + And I select "OpenDyslexic" font for the content language for the live preview + And I close the panel to discard the changes + Then the active content font must be the same as font prior to the preview + # System is the default value for English and German + And the selected content font must be "system" -Scenario: Applying the live preview of interface font - When I open "Fonts" panel of language settings - And I select "OpenDyslexic" font for the interface language for the live preview - And I apply the changes - Then the interface font must be changed to the "OpenDyslexic" font + Scenario: Discarding live preview of interface font + When I open "Fonts" panel of language settings + And I select "OpenDyslexic" font for the interface language for the live preview + And I close the panel to discard the changes + Then the active interface font must be the same as font prior to the preview + # System is the default value for English and German + And the selected interface font must be "system" + + Scenario: Applying the live preview of interface font + When I open "Fonts" panel of language settings + And I select "OpenDyslexic" font for the interface language for the live preview + And I apply the changes + Then the interface font must be changed to the "OpenDyslexic" font diff --git a/tests/browser/features/step_definitions/common_steps.rb b/tests/browser/features/step_definitions/common_steps.rb index 5d9fe214..84083b71 100644 --- a/tests/browser/features/step_definitions/common_steps.rb +++ b/tests/browser/features/step_definitions/common_steps.rb @@ -2,6 +2,9 @@ Given(/^I am at random page$/) do visit RandomPage end +Given(/^I am logged out$/) do +end + Given(/^I am logged in$/) do visit(LoginPage).login_with(@mediawiki_username, @mediawiki_password) end @@ -33,3 +36,13 @@ After('@reset-preferences-after') do |scenario| visit(ResetPreferencesPage) on(ResetPreferencesPage).submit_element.click end + +Before('@uls-in-sidebar-only') do |scenario| + if !defined?($uls_position) + visit(ULSPage) + $uls_position = @browser.execute_script( "return mw.config.get( 'wgULSPosition' )" ); + end + if $uls_position != 'interlanguage' + scenario.skip_invoke! + end +end diff --git a/tests/browser/features/step_definitions/panel_steps.rb b/tests/browser/features/step_definitions/panel_steps.rb index e12371ff..bbfbdbea 100644 --- a/tests/browser/features/step_definitions/panel_steps.rb +++ b/tests/browser/features/step_definitions/panel_steps.rb @@ -92,6 +92,18 @@ Then(/^the (.*) font must be changed to the "(.*?)" font$/) do |type, font| end end -Then(/^the selected font displayed as the interface font must be the same as before the intermediate selection$/) do - pending # express the regexp above with the code you wish you had +Then(/^I can disable input methods$/) do + on(ULSPage).panel_disable_input_methods_element.click +end + +Then(/^I can enable input methods$/) do + on(ULSPage).panel_enable_input_methods_element.click +end + +Then(/^a font selector for interface language appears$/) do + on(ULSPage).panel_interface_font_selector_element.should be_visible +end + +Then(/^a font selector for content language appears$/) do + on(ULSPage).panel_content_font_selector_element.should be_visible end diff --git a/tests/browser/features/step_definitions/uls_cog_sidebar_user_steps.rb b/tests/browser/features/step_definitions/uls_cog_sidebar_user_steps.rb index 2ebe1bb1..0fe97b32 100644 --- a/tests/browser/features/step_definitions/uls_cog_sidebar_user_steps.rb +++ b/tests/browser/features/step_definitions/uls_cog_sidebar_user_steps.rb @@ -18,13 +18,13 @@ end Given(/^I navigate to the anonymous Language Settings panel$/) do step 'I am on a page with interlanguage links' step 'I click the cog icon by Languages in the sidebar' - step 'I see the anonymous Language Settings panel' + step 'I see the logged out language settings panel' end Given(/^I navigate to the Language Settings panel$/) do step 'I am on a page with interlanguage links' step 'I click the cog icon by Languages in the sidebar' - step 'I see the Language Settings panel' + step 'I see the logged in language settings panel' end When(/^I click Apply Settings$/) do @@ -35,18 +35,6 @@ When(/^I click Cancel$/) do on(InterlanguagePage).cancel_element.click end -Then(/^I click Enable input$/) do - on(InterlanguagePage).enable_input_element.when_visible.click -end - -When(/^I click Fonts$/) do - on(InterlanguagePage).fonts_settings -end - -When(/^I click Input$/) do - on(InterlanguagePage).input_settings_element.click -end - When(/^I click on the link to select Malayalam$/) do on(RandomPage).malayalam_link end @@ -63,26 +51,10 @@ When(/^I click X$/) do on(InterlanguagePage).x_element.click end -When(/^I navigate to the talk page$/) do - on(InterlanguagePage).talk_element.click -end - When(/^in the language filter I type (.+)$/) do |language_abbreviation| on(RandomPage).language_filter=language_abbreviation end -Then(/^a font selectbox appears$/) do - on(InterlanguagePage).content_font_selectbox_element.should be_visible -end - -Then(/^I can disable input methods$/) do - on(InterlanguagePage).disable_input_methods_element.when_visible.should be_visible -end - -Then(/^I can enable input methods$/) do - on(InterlanguagePage).enable_input_element.when_visible.should be_visible -end - Then(/^I can navigate back to Input Settings$/) do on(InterlanguagePage) do |page| page.back_to_input @@ -102,9 +74,9 @@ When(/^I choose a different language for writing$/) do end Then(/^I do not see the Language Settings panel$/) do - on(InterlanguagePage) do |page| - page.language_button_element.should_not be_visible - page.fonts_button_element.should_not be_visible + on(ULSPage) do |page| + page.panel_language_element.should_not be_visible + page.panel_fonts_element.should_not be_visible page.default_language_button_element.should_not be_visible page.other_language_button_element.should_not be_visible end @@ -118,17 +90,17 @@ Then(/^I see Language Search$/) do on(InterlanguagePage).language_search_element.should be_visible end -Then(/^I see the anonymous Language Settings panel$/) do - on(NoInterlanguagePage) do |page| - page.language_button_element.when_present.should be_visible - page.fonts_button_element.should be_visible +Then(/^I see the logged out language settings panel$/) do + on(ULSPage) do |page| + page.panel_language_element.should be_visible + page.panel_fonts_element.should be_visible end end -Then(/^I see the Language Settings panel$/) do - on(NoInterlanguagePage) do |page| - page.language_button_element.when_present.should be_visible - page.fonts_button_element.should be_visible +Then(/^I see the logged in language settings panel$/) do + on(ULSPage) do |page| + page.panel_language_element.should be_visible + page.panel_fonts_element.should be_visible page.default_language_button_element.should be_visible page.other_language_button_element.should be_visible end @@ -141,9 +113,9 @@ Then(/^I see Worldwide$/) do end end -Then(/^the cog icon brings up anonymous Language Settings again$/) do +Then(/^I click the cog icon to open language settings again$/) do step 'I click the cog icon by Languages in the sidebar' - step 'I see the anonymous Language Settings panel' + step 'I see the logged out language settings panel' end Then(/^the cog icon brings up Language Settings again$/) do @@ -151,10 +123,6 @@ Then(/^the cog icon brings up Language Settings again$/) do step 'I see the Language Settings panel' end -Then(/^a font selectbox appears for content$/) do - on(InterlanguagePage).content_font_selectbox_element.should be_visible -end - Then(/^I should see the How to use link near the Malayalam transliteration item$/) do on(InterlanguagePage).how_to_use_ml_transliteration_element.should be_visible end diff --git a/tests/browser/features/support/modules/interlanguage_module.rb b/tests/browser/features/support/modules/interlanguage_module.rb index 59993323..cd9dc4e1 100644 --- a/tests/browser/features/support/modules/interlanguage_module.rb +++ b/tests/browser/features/support/modules/interlanguage_module.rb @@ -9,22 +9,13 @@ module InterlanguagePageModule a(:back_to_input, text: 'Back to input settings') button(:cancel, class: 'button uls-display-settings-cancel') span(:cog, class: 'uls-settings-trigger') - select_list(:content_font_selectbox, id: 'content-font-selector') - button(:default_language_button, class: 'button uls-language-button down') - button(:disable_input_methods, class: 'active green button uls-input-toggle-button') button(:ellipsis_button, class: 'uls-more-languages button') - button(:enable_input, class: 'active green button uls-input-toggle-button') a(:english_link, text: 'English') - button(:fonts_button, id: 'uls-display-settings-fonts-tab') - button(:fonts_settings, id: 'uls-display-settings-fonts-tab') div(:input_settings, id: 'input-settings-block') - button(:language_button, id: 'uls-display-settings-language-tab') - div(:language_list, class: 'row uls-language-list lcd') + div(:language_list, class: 'row uls-language-list lcd') text_field(:language_search, id: 'languagefilter') button(:non_default_language, class: 'button uls-language-button', index: 1) - button(:other_language_button, class: 'button uls-language-button') a(:talk, text: 'Discussion') - select_list(:ui_font_selectbox, id: 'ui-font-selector') span(:x, id: 'languagesettings-close') a(:how_to_use_ml_transliteration, href: 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Extension:UniversalLanguageSelector/Input_methods/ml-transliteration') end diff --git a/tests/browser/features/support/pages/panel_page.rb b/tests/browser/features/support/pages/panel_page.rb index 9aff40af..a251fab2 100644 --- a/tests/browser/features/support/pages/panel_page.rb +++ b/tests/browser/features/support/pages/panel_page.rb @@ -1,14 +1,24 @@ class ULSPage - include PageObject + include PageObject - include URL - page_url URL.url('?setlang=<%=params[:setlang]%>') + include URL + page_url URL.url('?setlang=<%=params[:setlang]%>') div(:panel_display, id: 'display-settings-block') - div(:panel_input, id: 'display-settings-block') + div(:panel_input, id: 'input-settings-block') button(:panel_fonts, id: 'uls-display-settings-fonts-tab') button(:panel_language, id: 'uls-display-settings-language-tab') span(:panel_button_close, id: 'languagesettings-close') button(:panel_button_display_apply, id: 'uls-displaysettings-apply') + + button(:panel_disable_input_methods, class: 'uls-input-toggle-button') + button(:panel_enable_input_methods, class: 'uls-input-toggle-button') + + select_list(:panel_content_font_selector, id: 'content-font-selector') + select_list(:panel_interface_font_selector, id: 'ui-font-selector') + + # TODO: Rename to match convention + button(:other_language_button, class: 'button uls-language-button') + button(:default_language_button, class: 'button uls-language-button down') end diff --git a/tests/browser/features/uls_cog_sidebar_anon_user.feature b/tests/browser/features/uls_cog_sidebar_anon_user.feature index aac0011e..d157e9f5 100644 --- a/tests/browser/features/uls_cog_sidebar_anon_user.feature +++ b/tests/browser/features/uls_cog_sidebar_anon_user.feature @@ -1,74 +1,73 @@ -@en.wikipedia.beta.wmflabs.org @ie6-bug @ie7-bug -Feature: ULS cog behaviour on the side-bar for logged in users +@en.wikipedia.beta.wmflabs.org @ie6-bug @ie7-bug +Feature: ULS cog in the sidebar allows access to language settings - Scenario: Page without interlanguage links has cog icon and language selector - Given I am on a page without interlanguage links + @login @uls-in-sidebar-only + Scenario Outline: Opening language settings from sidebar + Given I am + And I am on When I click the cog icon by Languages in the sidebar - Then I see the anonymous Language Settings panel + Then I see the language settings panel - Scenario: Page with interlanguage links has cog icon and language selector - Given I am on a page with interlanguage links + Examples: + | user status | page type | + | logged out | a page without interlanguage links | + | logged in | a page with interlanguage links | + | logged out | a talk page without interlanguage links | + | logged out | a talk page with interlanguage links | + + @login @uls-in-sidebar-only + Scenario Outline: Closing language settings without saving + Given I am + And I am on a page without interlanguage links When I click the cog icon by Languages in the sidebar - Then I see the anonymous Language Settings panel - - Scenario: Page without interlanguage links has cog icon and language selector on Talk page - Given I am on a talk page without interlanguage links - When I click the cog icon by Languages in the sidebar - Then I see the anonymous Language Settings panel - - Scenario: Page with interlanguage links has cog icon and language selector on Talk page - Given I am on a talk page with interlanguage links - When I click the cog icon by Languages in the sidebar - Then I see the anonymous Language Settings panel - - Scenario: Language Settings closes and opens with X button - Given I navigate to the anonymous Language Settings panel - When I click X + And Then I do not see the Language Settings panel - And the cog icon brings up anonymous Language Settings again + And I click the cog icon by Languages in the sidebar + And I see the language settings panel - Scenario: Language Settings closes and opens with Apply Settings buttons - Given I navigate to the anonymous Language Settings panel - When I click Apply Settings - Then I do not see the Language Settings panel - And the cog icon brings up anonymous Language Settings again + Examples: + | user status | close method | + | logged in | I click X | + | logged out | I click Cancel | + # It is weird that this works, since the button is disabled until changes + # have been made + | logged out | I click Apply Settings | - Scenario: Language Settings closes and opens with Cancel buttons - Given I navigate to the anonymous Language Settings panel - When I click Cancel - Then I do not see the Language Settings panel - And the cog icon brings up anonymous Language Settings again - - Scenario: Input settings display - Given I navigate to the anonymous Language Settings panel - When I click Input + @login + Scenario Outline: Input settings display + Givan I am + And I am on a page without interlanguage links + When I open "Input" panel of language settings Then I can enable input methods And I can disable input methods + Examples: + | user status | + | logged out | + | logged in | + Scenario: How to use link appears in the Input settings panel - Given I navigate to the anonymous Language Settings panel - When I click Input - And I click Enable input + Given I am at random page + When I open "Input" panel of language settings And I click the button with the ellipsis And in the language filter I type ml And I click on the link to select Malayalam Then I should see the How to use link near the Malayalam transliteration item - Scenario: Fonts default settings and display - Given I navigate to the anonymous Language Settings panel - When I click Fonts - Then a font selectbox appears - - Scenario: Fonts not default settings and display - Given I navigate to the anonymous Language Settings panel - When I click Fonts - Then a font selectbox appears for content - - Scenario: More languages - Given I navigate to the anonymous Language Settings panel - And I click Input - And I click Enable input - When I click the button with the ellipsis + Scenario: More languages (input language selection) + Given I am at random page + When I open "Input" panel of language settings + And I click the button with the ellipsis Then I see Worldwide And I see Language Search And I can navigate back to Input Settings + + @login + Scenario: More languages (interface language selection) + Given I am logged in + When I open "Language" panel of language settings + And I click the button with the ellipsis + Then I see Common Languages + And I see Worldwide + And I see Language Search + And I can navigate back to Language Settings diff --git a/tests/browser/features/uls_cog_sidebar_logged_user.feature b/tests/browser/features/uls_cog_sidebar_logged_user.feature deleted file mode 100644 index 9ce7ed46..00000000 --- a/tests/browser/features/uls_cog_sidebar_logged_user.feature +++ /dev/null @@ -1,68 +0,0 @@ -@en.wikipedia.beta.wmflabs.org @login @ie6-bug @ie7-bug -Feature: ULS cog behaviour on the side-bar for logged in users - - Background: - Given I am logged in - - Scenario: Page without interlanguage links has cog icon and language selector - Given I am on a page without interlanguage links - When I click the cog icon by Languages in the sidebar - Then I see the Language Settings panel - - Scenario: Page with interlanguage links has cog icon and language selector - Given I am on a page with interlanguage links - When I click the cog icon by Languages in the sidebar - Then I see the Language Settings panel - - Scenario: Page without interlanguage links has cog icon and language selector on Talk page - Given I am on a talk page without interlanguage links - When I click the cog icon by Languages in the sidebar - Then I see the Language Settings panel - - Scenario: Page with interlanguage links has cog icon and language selector on Talk page - Given I am on a talk page with interlanguage links - When I click the cog icon by Languages in the sidebar - Then I see the Language Settings panel - - Scenario: Language Settings closes and opens with X button - Given I navigate to the Language Settings panel - When I click X - Then I do not see the Language Settings panel - And the cog icon brings up Language Settings again - - Scenario: Language Settings closes and opens with Apply Settings buttons - Given I navigate to the Language Settings panel - When I click Apply Settings - Then I do not see the Language Settings panel - And the cog icon brings up Language Settings again - - Scenario: Language Settings closes and opens with Cancel buttons - Given I navigate to the Language Settings panel - When I click Cancel - Then I do not see the Language Settings panel - And the cog icon brings up Language Settings again - - Scenario: Input settings display - Given I navigate to the Language Settings panel - When I click Input - Then I can enable input methods - And I can disable input methods - - Scenario: Fonts default settings and display - Given I navigate to the Language Settings panel - When I click Fonts - Then a font selectbox appears - - Scenario: Fonts not default settings and display - Given I navigate to the Language Settings panel - When I choose a different language for writing - And I click Fonts - Then a font selectbox appears for content - - Scenario: More languages - Given I navigate to the Language Settings panel - When I click the button with the ellipsis - Then I see Common Languages - And I see Worldwide - And I see Language Search - And I can navigate back to Language Settings