From 52372f585743634bfee90473de5eb6a915fe9fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Laxstr=C3=B6m?= Date: Mon, 28 Oct 2013 12:41:06 +0200 Subject: [PATCH] Refactoring ime tests Scenarios: * Input method menu * Input method indicator is shown * Unsupported input language (pending) Added IMEPage Change-Id: I1f68d177bd05baca6ae8da97364b81a4d851b8b6 --- tests/browser/features/ime.feature | 3 +++ .../features/step_definitions/ime_steps.rb | 24 +++++++------------ .../features/support/pages/ime_page.rb | 9 +++++++ .../features/support/pages/random_page.rb | 5 ---- 4 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 tests/browser/features/support/pages/ime_page.rb diff --git a/tests/browser/features/ime.feature b/tests/browser/features/ime.feature index 9d6e2f26..d8541567 100644 --- a/tests/browser/features/ime.feature +++ b/tests/browser/features/ime.feature @@ -5,6 +5,7 @@ activated by the input method indicator. User can type with selected input method in different input fields and temporarily activate and deactivate the input method. + @commons.wikimedia.beta.wmflabs.org Scenario: Input method indicator is shown The input method indicator is shown when input field gets a focus. @@ -13,6 +14,7 @@ input method. When I click on an input box Then I should see the input method indicator + @commons.wikimedia.beta.wmflabs.org Scenario: Input method menu Input method menu is shown when user clicks the input method indicator. @@ -24,6 +26,7 @@ input method. And I should see a list of available input methods And I should see a list of suggested languages + @commons.wikimedia.beta.wmflabs.org Scenario: Unsupported input language User visits a wiki with content language that does not have have an input diff --git a/tests/browser/features/step_definitions/ime_steps.rb b/tests/browser/features/step_definitions/ime_steps.rb index 384487f0..10cc7928 100644 --- a/tests/browser/features/step_definitions/ime_steps.rb +++ b/tests/browser/features/step_definitions/ime_steps.rb @@ -7,40 +7,34 @@ Given(/^I am on a wiki in Kotava language$/) do 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 + on(IMEPage).search_input_element.click end When(/^I click on the input method indicator$/) do - on(RandomPage).input_method_element.when_present.click + on(IMEPage).input_method_element.when_present.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 + step 'I click on an input box' + pending('Bug in ULS with unsupported languages like avk') do + on(IMEPage).input_method_element.when_present.click end end Then(/^I should see the input method indicator$/) do - on(RandomPage).input_method_element.when_present.should be_visible + on(IMEPage).input_method_element.when_present.should be_visible end Then(/^I should see input methods for (.+)/) do |language| - on(RandomPage).input_method_ime_list_title.should == language + on(IMEPage).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 + on(IMEPage).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 + on(IMEPage).input_method_language_list_element.should be_visible end When(/^I choose (.+?) as the input language$/) do |language| diff --git a/tests/browser/features/support/pages/ime_page.rb b/tests/browser/features/support/pages/ime_page.rb new file mode 100644 index 00000000..be34e23f --- /dev/null +++ b/tests/browser/features/support/pages/ime_page.rb @@ -0,0 +1,9 @@ +class IMEPage + include PageObject + + div(:input_method, class: 'imeselector imeselector-toggle') + h3(:input_method_ime_list_title, class: 'ime-list-title') + ul(:input_method_language_list, class: 'ime-language-list') + div(:input_method_selector_menu, class: 'imeselector-menu') + text_field(:search_input, id: 'searchInput') +end diff --git a/tests/browser/features/support/pages/random_page.rb b/tests/browser/features/support/pages/random_page.rb index 38de1384..edc81811 100644 --- a/tests/browser/features/support/pages/random_page.rb +++ b/tests/browser/features/support/pages/random_page.rb @@ -8,11 +8,7 @@ class RandomPage a(:create_a_book, text: 'Create a book') a(:download_as_pdf, text: 'Download as PDF') a(:download_the_file, text: 'Download the file') - div(:input_method, class: 'imeselector imeselector-toggle') a(:input_method_enabled, class: 'ime-name imeselector-toggle') - h3(:input_method_ime_list_title, class: 'ime-list-title') - ul(:input_method_language_list, class: 'ime-language-list') - div(:input_method_selector_menu, class: 'imeselector-menu') text_field(:language_filter, id: 'languagefilter') li(:main_page, id: 'n-mainpage-description') a(:malayalam_link, title: 'Malayalam') @@ -21,6 +17,5 @@ class RandomPage a(:printable_version, text: 'Printable version') li(:uls_malayalam_inscript2_item, data_ime_inputmethod: 'ml-inscript2') button(:search_button, id: 'searchButton') - text_field(:search_input, id: 'searchInput') a(:uls_trigger, class: 'uls-trigger') end