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

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

View File

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

View File

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