From df2c17bfd2387f97012744c6f8ec594832471933 Mon Sep 17 00:00:00 2001 From: Vikas S Yaligar Date: Fri, 17 Jul 2015 02:37:03 -0500 Subject: [PATCH] [BrowserTest] Load i18n messages from MediaWiki to browser tests * translate method can be called to translate a particular string to a specific language. Bug: T90577 Change-Id: I7852ee0b0009e70bd9decef0dd317055d91a06a6 --- .../tests/browser/features/language_screenshot.feature | 4 ++++ .../step_definitions/language_screenshot_steps.rb | 4 ++++ .../browser/features/support/pages/visual_editor_page.rb | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/ve-mw/tests/browser/features/language_screenshot.feature b/modules/ve-mw/tests/browser/features/language_screenshot.feature index 988b0eadfb..37ae38dde0 100644 --- a/modules/ve-mw/tests/browser/features/language_screenshot.feature +++ b/modules/ve-mw/tests/browser/features/language_screenshot.feature @@ -177,3 +177,7 @@ Feature: Language Screenshot Given I go to the "Reference VisualEditor Screenshot" page with source content "VisualEditor is a MediaWiki extension" When I click on References list in Insert menu Then I should see References list dialog box + + Scenario: Load i18n messages from MediaWiki to browser tests + Given I am on the Main page + Then I should see save button diff --git a/modules/ve-mw/tests/browser/features/step_definitions/language_screenshot_steps.rb b/modules/ve-mw/tests/browser/features/step_definitions/language_screenshot_steps.rb index 3cd2ce9766..4c96956c76 100644 --- a/modules/ve-mw/tests/browser/features/step_definitions/language_screenshot_steps.rb +++ b/modules/ve-mw/tests/browser/features/step_definitions/language_screenshot_steps.rb @@ -529,3 +529,7 @@ When(/^I go to language screenshot page$/) do step 'I am on the Language Screenshot page' browser.goto "#{browser.url}&setlang=#{lookup(:language_screenshot_code)}" end + +Then(/^I should see save button$/) do + on(VisualEditorPage).save_page_element.when_present.should be_visible +end diff --git a/modules/ve-mw/tests/browser/features/support/pages/visual_editor_page.rb b/modules/ve-mw/tests/browser/features/support/pages/visual_editor_page.rb index cb25266330..4ad65d56e6 100644 --- a/modules/ve-mw/tests/browser/features/support/pages/visual_editor_page.rb +++ b/modules/ve-mw/tests/browser/features/support/pages/visual_editor_page.rb @@ -4,6 +4,12 @@ class VisualEditorPage page_url 'User:<%= env.user %>/<%= env.browser_name %>?vehidebetadialog=true&veaction=edit' + def self.translate(string) + file = File.read "../../i18n/#{ENV['LANGUAGE_SCREENSHOT_CODE']}.json" + json = JSON.parse(file) + json[string] + end + div(:add_a_template_title, class: 'oo-ui-processDialog-location', text: /Add a template/) text_field(:add_category, css: 'div.ve-ui-mwCategoryInputWidget > input') span(:add_template, text: 'Add template') @@ -150,7 +156,7 @@ class VisualEditorPage div(:top_editing_tabs, id: 'p-views') li(:ve_edit_tab, id: 'ca-ve-edit') li(:edit_source_tab, id: 'ca-edit') - a(:save_page, css: '.oo-ui-flaggedElement-progressive > a:nth-child(1)') + a(:save_page, text: translate('visualeditor-savedialog-label-save')) div(:save_enabled, css: 'div.ve-init-mw-desktopArticleTarget-toolbar .oo-ui-toolbar-actions > div.oo-ui-flaggedElement-progressive.oo-ui-widget-enabled') div(:search_page_link, class: 'oo-ui-optionWidget-selected') a(:second_reference, text: '[1]', index: 2)