Files
mediawiki-extensions-Univer…/tests/browser/features/step_definitions/panel_steps.rb
Niklas Laxström d695b21381 Add new scenarios for font changes
There is currently some duplication between the various page objects
and other code. Those should be cleaned up incrementally.

Change-Id: I592829a00ca65bbecd5399b773c885c764c1cc06
2013-08-27 16:35:23 +03:00

98 lines
2.8 KiB
Ruby

Given(/^I set "(.*?)" as the interface language$/) do |language|
code = language_to_code(language)
visit(ULSPage, :using_params => {:setlang => "#{code}"})
# And check it took effect
actual = @browser.execute_script( "return jQuery( 'html' ).attr( 'lang' )" )
actual.should == code
end
Given(/^the content language is "(.*?)"$/) do |language|
code = language_to_code(language)
actual = @browser.execute_script( "return mw.config.get( 'wgContentLanguage' )" )
actual.should == code
end
Given(/^I inspect current fonts$/) do
@original_content_font = get_content_font()
@original_interface_font = get_interface_font()
end
When(/^I open "(.*?)" panel of language settings$/) do |panel|
# These can be of two different type of elements, which PageObjects do not like.
@browser.execute_script(
"jQuery( '.uls-trigger, .uls-settings-trigger' ).eq( 0 ).click()"
)
on(ULSPage) do |page|
case panel
when "Display"
page.panel_display_element.click
when "Language"
page.panel_display_element.click
page.panel_language_element.click
when "Fonts"
page.panel_display_element.click
page.panel_fonts_element.click
when "Input"
page.panel_input_element.click
else
pending
end
end
end
When(/^I select "(.*?)" font for the (.*?) language for the live preview$/) do |font,type|
if type == 'interface'
type = 'ui'
end
Selenium::WebDriver::Support::Select.new(
@browser.driver.find_element(:id, "#{type}-font-selector")
).select_by(:text, font)
end
When(/^I close the panel to discard the changes$/) do
on(ULSPage).panel_button_close_element.click
end
Then(/^the active (.*?) font must be the same as font prior to the preview$/) do |type|
case type
when "content"
get_content_font().should === @original_content_font
when "interface"
get_interface_font().should === @original_interface_font
else
pending
end
end
Then(/^the selected (.*?) font must be "(.*?)"$/) do |type, font|
if type == 'interface'
type = 'ui'
end
step 'I open "Fonts" panel of language settings'
Selenium::WebDriver::Support::Select.new(
@browser.driver.find_element(:id, "#{type}-font-selector")
).first_selected_option().attribute('value').should == font
end
When(/^I apply the changes$/) do
on(ULSPage).panel_button_display_apply_element.click
wait = Selenium::WebDriver::Wait.new(:timeout => 3)
panel = @browser.driver.find_element(:id => 'language-settings-dialog')
wait.until { !panel.displayed? }
end
Then(/^the (.*) font must be changed to the "(.*?)" font$/) do |type, font|
case type
when "content"
get_content_font().should match("^#{font}")
when "interface"
get_interface_font().should match("^#{font}")
else
pending
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
end