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 3c72a189ef..23a0ee789b 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 @@ -6,7 +6,12 @@ class VisualEditorPage def self.translate(string) language = ENV['LANGUAGE_SCREENSHOT_CODE'] - file_name = (File.exist?("../../i18n/#{language}.json")) ? "../../i18n/#{language}.json" : '../../i18n/en.json' + + file_name = File.expand_path("../../../i18n/#{language}.json", __dir__) + unless File.exist?(file_name) + file_name = File.expand_path('../../../i18n/en.json', __dir__) + end + json = JSON.parse(File.read(file_name)) json[string] || '' end diff --git a/modules/ve-mw/tests/browser/features/support/visual_editor_helper.rb b/modules/ve-mw/tests/browser/features/support/visual_editor_helper.rb index 115bac3864..f0fdb2bb86 100644 --- a/modules/ve-mw/tests/browser/features/support/visual_editor_helper.rb +++ b/modules/ve-mw/tests/browser/features/support/visual_editor_helper.rb @@ -10,6 +10,10 @@ module VisualEditorHelper def i18n_file language = lookup(:language_screenshot_code) - (File.exist?("i18n/#{language}.json")) ? "i18n/#{language}.json" : 'i18n/en.json' + file_name = File.expand_path("../../i18n/#{language}.json", __dir__) + unless File.exist?(file_name) + file_name = File.expand_path('../../i18n/en.json', __dir__) + end + file_name end end