Refactor ULS tests to reduce duplication and repetition

Change-Id: I96f1594f1b4d1960da9a8bc21e2a5c4727497b10
This commit is contained in:
Niklas Laxström
2013-08-28 14:07:14 +03:00
parent f14161a0cd
commit 3bd4bb4f03
8 changed files with 146 additions and 216 deletions

View File

@@ -1,21 +1,26 @@
@reset-preferences-after @login @en.wikipedia.beta.wmflabs.org @commons.wikimedia.beta.wmflabs.org @reset-preferences-after @login @en.wikipedia.beta.wmflabs.org @commons.wikimedia.beta.wmflabs.org
Feature: Font selection Feature: Font selection
In order to have better using experience, In order to have better using experience,
As a reader and writer, As a reader and writer,
I want to change or disable the fonts for interface and content. I want to change or disable the fonts for interface and content.
In addition the user is provided live preview feature: changes are applied In addition the user is provided live preview feature: changes are applied
immediately when selection is made. Changes can either be applied or discared immediately when selection is made. Changes can either be applied or discared
for easy testing. for easy testing.
Background: Background:
Given I am logged in Given I am logged in
And I set "German" as the interface language And I set "German" as the interface language
And the content language is "English" And the content language is "English"
And I inspect current fonts And I inspect current fonts
Scenario: Discarding live preview of content font 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 content font
When I open "Fonts" panel of language settings When I open "Fonts" panel of language settings
And I select "OpenDyslexic" font for the content language for the live preview And I select "OpenDyslexic" font for the content language for the live preview
And I close the panel to discard the changes And I close the panel to discard the changes
@@ -23,7 +28,7 @@ Scenario: Discarding live preview of content font
# System is the default value for English and German # System is the default value for English and German
And the selected content font must be "system" And the selected content font must be "system"
Scenario: Discarding live preview of interface font Scenario: Discarding live preview of interface font
When I open "Fonts" panel of language settings When I open "Fonts" panel of language settings
And I select "OpenDyslexic" font for the interface language for the live preview And I select "OpenDyslexic" font for the interface language for the live preview
And I close the panel to discard the changes And I close the panel to discard the changes
@@ -31,7 +36,7 @@ Scenario: Discarding live preview of interface font
# System is the default value for English and German # System is the default value for English and German
And the selected interface font must be "system" And the selected interface font must be "system"
Scenario: Applying the live preview of interface font Scenario: Applying the live preview of interface font
When I open "Fonts" panel of language settings When I open "Fonts" panel of language settings
And I select "OpenDyslexic" font for the interface language for the live preview And I select "OpenDyslexic" font for the interface language for the live preview
And I apply the changes And I apply the changes

View File

@@ -2,6 +2,9 @@ Given(/^I am at random page$/) do
visit RandomPage visit RandomPage
end end
Given(/^I am logged out$/) do
end
Given(/^I am logged in$/) do Given(/^I am logged in$/) do
visit(LoginPage).login_with(@mediawiki_username, @mediawiki_password) visit(LoginPage).login_with(@mediawiki_username, @mediawiki_password)
end end
@@ -33,3 +36,13 @@ After('@reset-preferences-after') do |scenario|
visit(ResetPreferencesPage) visit(ResetPreferencesPage)
on(ResetPreferencesPage).submit_element.click on(ResetPreferencesPage).submit_element.click
end 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

View File

@@ -92,6 +92,18 @@ Then(/^the (.*) font must be changed to the "(.*?)" font$/) do |type, font|
end end
end end
Then(/^the selected font displayed as the interface font must be the same as before the intermediate selection$/) do Then(/^I can disable input methods$/) do
pending # express the regexp above with the code you wish you had 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 end

View File

@@ -18,13 +18,13 @@ end
Given(/^I navigate to the anonymous Language Settings panel$/) do Given(/^I navigate to the anonymous Language Settings panel$/) do
step 'I am on a page with interlanguage links' step 'I am on a page with interlanguage links'
step 'I click the cog icon by Languages in the sidebar' 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 end
Given(/^I navigate to the Language Settings panel$/) do Given(/^I navigate to the Language Settings panel$/) do
step 'I am on a page with interlanguage links' step 'I am on a page with interlanguage links'
step 'I click the cog icon by Languages in the sidebar' 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 end
When(/^I click Apply Settings$/) do When(/^I click Apply Settings$/) do
@@ -35,18 +35,6 @@ When(/^I click Cancel$/) do
on(InterlanguagePage).cancel_element.click on(InterlanguagePage).cancel_element.click
end 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 When(/^I click on the link to select Malayalam$/) do
on(RandomPage).malayalam_link on(RandomPage).malayalam_link
end end
@@ -63,26 +51,10 @@ When(/^I click X$/) do
on(InterlanguagePage).x_element.click on(InterlanguagePage).x_element.click
end 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| When(/^in the language filter I type (.+)$/) do |language_abbreviation|
on(RandomPage).language_filter=language_abbreviation on(RandomPage).language_filter=language_abbreviation
end 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 Then(/^I can navigate back to Input Settings$/) do
on(InterlanguagePage) do |page| on(InterlanguagePage) do |page|
page.back_to_input page.back_to_input
@@ -102,9 +74,9 @@ When(/^I choose a different language for writing$/) do
end end
Then(/^I do not see the Language Settings panel$/) do Then(/^I do not see the Language Settings panel$/) do
on(InterlanguagePage) do |page| on(ULSPage) do |page|
page.language_button_element.should_not be_visible page.panel_language_element.should_not be_visible
page.fonts_button_element.should_not be_visible page.panel_fonts_element.should_not be_visible
page.default_language_button_element.should_not be_visible page.default_language_button_element.should_not be_visible
page.other_language_button_element.should_not be_visible page.other_language_button_element.should_not be_visible
end end
@@ -118,17 +90,17 @@ Then(/^I see Language Search$/) do
on(InterlanguagePage).language_search_element.should be_visible on(InterlanguagePage).language_search_element.should be_visible
end end
Then(/^I see the anonymous Language Settings panel$/) do Then(/^I see the logged out language settings panel$/) do
on(NoInterlanguagePage) do |page| on(ULSPage) do |page|
page.language_button_element.when_present.should be_visible page.panel_language_element.should be_visible
page.fonts_button_element.should be_visible page.panel_fonts_element.should be_visible
end end
end end
Then(/^I see the Language Settings panel$/) do Then(/^I see the logged in language settings panel$/) do
on(NoInterlanguagePage) do |page| on(ULSPage) do |page|
page.language_button_element.when_present.should be_visible page.panel_language_element.should be_visible
page.fonts_button_element.should be_visible page.panel_fonts_element.should be_visible
page.default_language_button_element.should be_visible page.default_language_button_element.should be_visible
page.other_language_button_element.should be_visible page.other_language_button_element.should be_visible
end end
@@ -141,9 +113,9 @@ Then(/^I see Worldwide$/) do
end end
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 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 end
Then(/^the cog icon brings up Language Settings again$/) do 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' step 'I see the Language Settings panel'
end 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 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 on(InterlanguagePage).how_to_use_ml_transliteration_element.should be_visible
end end

View File

@@ -9,22 +9,13 @@ module InterlanguagePageModule
a(:back_to_input, text: 'Back to input settings') a(:back_to_input, text: 'Back to input settings')
button(:cancel, class: 'button uls-display-settings-cancel') button(:cancel, class: 'button uls-display-settings-cancel')
span(:cog, class: 'uls-settings-trigger') 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(:ellipsis_button, class: 'uls-more-languages button')
button(:enable_input, class: 'active green button uls-input-toggle-button')
a(:english_link, text: 'English') 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') 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') text_field(:language_search, id: 'languagefilter')
button(:non_default_language, class: 'button uls-language-button', index: 1) button(:non_default_language, class: 'button uls-language-button', index: 1)
button(:other_language_button, class: 'button uls-language-button')
a(:talk, text: 'Discussion') a(:talk, text: 'Discussion')
select_list(:ui_font_selectbox, id: 'ui-font-selector')
span(:x, id: 'languagesettings-close') 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') a(:how_to_use_ml_transliteration, href: 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Extension:UniversalLanguageSelector/Input_methods/ml-transliteration')
end end

View File

@@ -5,10 +5,20 @@ class ULSPage
page_url URL.url('?setlang=<%=params[:setlang]%>') page_url URL.url('?setlang=<%=params[:setlang]%>')
div(:panel_display, id: 'display-settings-block') 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_fonts, id: 'uls-display-settings-fonts-tab')
button(:panel_language, id: 'uls-display-settings-language-tab') button(:panel_language, id: 'uls-display-settings-language-tab')
span(:panel_button_close, id: 'languagesettings-close') span(:panel_button_close, id: 'languagesettings-close')
button(:panel_button_display_apply, id: 'uls-displaysettings-apply') 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 end

View File

@@ -1,74 +1,73 @@
@en.wikipedia.beta.wmflabs.org @ie6-bug @ie7-bug @en.wikipedia.beta.wmflabs.org @ie6-bug @ie7-bug
Feature: ULS cog behaviour on the side-bar for logged in users Feature: ULS cog in the sidebar allows access to language settings
Scenario: Page without interlanguage links has cog icon and language selector @login @uls-in-sidebar-only
Given I am on a page without interlanguage links Scenario Outline: Opening language settings from sidebar
Given I am <user status>
And I am on <page type>
When I click the cog icon by Languages in the sidebar When I click the cog icon by Languages in the sidebar
Then I see the anonymous Language Settings panel Then I see the <user status> language settings panel
Scenario: Page with interlanguage links has cog icon and language selector Examples:
Given I am on a page with interlanguage links | 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 <user status>
And I am on a page without interlanguage links
When I click the cog icon by Languages in the sidebar When I click the cog icon by Languages in the sidebar
Then I see the anonymous Language Settings panel And <close method>
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
Then I do not see the Language Settings panel 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 <user status> language settings panel
Scenario: Language Settings closes and opens with Apply Settings buttons Examples:
Given I navigate to the anonymous Language Settings panel | user status | close method |
When I click Apply Settings | logged in | I click X |
Then I do not see the Language Settings panel | logged out | I click Cancel |
And the cog icon brings up anonymous Language Settings again # 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 @login
Given I navigate to the anonymous Language Settings panel Scenario Outline: Input settings display
When I click Cancel Givan I am <user status>
Then I do not see the Language Settings panel And I am on a page without interlanguage links
And the cog icon brings up anonymous Language Settings again When I open "Input" panel of language settings
Scenario: Input settings display
Given I navigate to the anonymous Language Settings panel
When I click Input
Then I can enable input methods Then I can enable input methods
And I can disable 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 Scenario: How to use link appears in the Input settings panel
Given I navigate to the anonymous Language Settings panel Given I am at random page
When I click Input When I open "Input" panel of language settings
And I click Enable input
And I click the button with the ellipsis And I click the button with the ellipsis
And in the language filter I type ml And in the language filter I type ml
And I click on the link to select Malayalam And I click on the link to select Malayalam
Then I should see the How to use link near the Malayalam transliteration item Then I should see the How to use link near the Malayalam transliteration item
Scenario: Fonts default settings and display Scenario: More languages (input language selection)
Given I navigate to the anonymous Language Settings panel Given I am at random page
When I click Fonts When I open "Input" panel of language settings
Then a font selectbox appears And I click the button with the ellipsis
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
Then I see Worldwide Then I see Worldwide
And I see Language Search And I see Language Search
And I can navigate back to Input Settings 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

View File

@@ -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