Files
mediawiki-extensions-Univer…/tests/browser/features/step_definitions/ime_steps.rb
Zeljko Filipin fb56c5f12c Fixed "Unsupported input language" scenario
Tested on my machine, it now works on both Firefox and Chrome. 

Change-Id: I8c810b355ed1407307b57699f8427f487ab1a08a
2013-09-25 16:13:11 +00:00

91 lines
2.6 KiB
Ruby

# encoding: utf-8
Given(/^I am on a wiki in Kotava language$/) do
visit(RandomPage)
# Fake a Kotava Wiki
@browser.execute_script( "mw.config.set( 'wgContentLanguage', 'avk' )" )
end
When(/^I click on an input box$/) do
on(RandomPage) do |page|
page.search_input_element.click
# For some reason click alone doesn't seem to trigger the ime indicator
# when running tests
page.search_input_element.send_keys ' '
end
end
When(/^I click on the input method indicator$/) do
on(RandomPage).input_method_element.click
end
When(/^I open the input method menu$/) do
on(RandomPage) do |page|
page.search_input_element.fire_event "onfocus"
page.search_input_element.click
page.input_method_element.when_present.click
end
end
Then(/^I should see the input method indicator$/) do
on(RandomPage).input_method_element.should be_visible
end
Then(/^I should see input methods for (.+)/) do |language|
on(RandomPage).input_method_ime_list_title.should == language
end
Then(/^I should see a list of available input methods$/) do
on(RandomPage).input_method_selector_menu_element.should be_visible
end
Then(/^I should see a list of suggested languages$/) do
on(RandomPage).input_method_language_list_element.should be_visible
end
When(/^I choose (.+?) as the input language$/) do |language|
on(RandomPage) do |page|
page.more_languages
page.language_filter = language
# firefox only works with :return
# phantomjs only works with :enter
# This seems to work on both
page.language_filter_element.send_keys "\n"
end
end
When(/^I click on the Malayalam InScript 2 menu item$/) do
on(RandomPage).uls_malayalam_inscript2_item_element.click
end
When(/^I press Control\-M$/) do
on(RandomPage).search_input_element.send_keys [:control, 'm']
end
When(/^I go to another random page$/) do
visit(RandomPage)
end
Then(/^in it there must be an element with Malayalam text$/) do
# 'input_method_enabled' alone only returns []
on(RandomPage).input_method_enabled_element.text.should == 'ഇൻസ്ക്രിപ്റ്റ് 2'
end
When(/^I visit page in Vector skin$/) do
visit(ULSPage, :using_params => {:extra => "useskin=vector"})
end
When(/^I visit page in Monobook skin$/) do
visit(ULSPage, :using_params => {:extra => "useskin=monobook"})
end
Then(/^I should see the input method menu is not offscreen$/) do
@browser.execute_script( "
var $selectorMenu = $( '.imeselector-menu' ),
menuLeft = $selectorMenu.offset().left,
menuRight = menuLeft + $selectorMenu.width();
return ( menuLeft >= 0 && menuRight <= $( window ).width() );
" ).should == true
end