From 6ff974e6ec9801174bbe7d38320b3e87bcddf20e Mon Sep 17 00:00:00 2001 From: Billy Zhou Date: Thu, 29 Nov 2018 00:12:24 +0800 Subject: [PATCH] Fix #2344 - Missing translation for quote header timestamp --- .../article_action/email_reply.coffee | 6 +- ...agent_ticket_email_reply_keep_body_test.rb | 72 +++++++++++++++++++ test/browser_test_helper.rb | 49 +++++++++++++ 3 files changed, 126 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee index 700fa08ce..b2f777bea 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee @@ -180,7 +180,11 @@ class EmailReply extends App.Controller day: 'numeric' year: 'numeric' } - new Date(date_string).toLocaleTimeString('en-US', options) + locale = App.i18n.get() || 'en-US' + try + new Date(date_string).toLocaleTimeString(locale, options) + catch e + new Date(date_string).toLocaleTimeString('en-US', options) @emailForward: (ticket, article, ui) -> diff --git a/test/browser/agent_ticket_email_reply_keep_body_test.rb b/test/browser/agent_ticket_email_reply_keep_body_test.rb index 3ea521b87..ad06a411c 100644 --- a/test/browser/agent_ticket_email_reply_keep_body_test.rb +++ b/test/browser/agent_ticket_email_reply_keep_body_test.rb @@ -129,4 +129,76 @@ class AgentTicketEmailReplyKeepBodyTest < TestCase assert match[1] assert Time.zone.parse(match[1]) end + + # Regression test for issue #2344 - Missing translation for Full-Quote-Text "on xy wrote" + def test_full_quote_german_locale + @browser = instance = browser_instance + login( + username: 'master@example.com', + password: 'test', + url: browser_url, + ) + tasks_close_all() + + ticket_open_by_title( + title: 'Welcome to Zammad', + ) + watch_for( + css: '.content.active .js-settingContainer .js-setting .dropdown-icon', + ) + + # enable email full quote in the ticket zoom config page + scroll_to( + position: 'botton', + css: '.content.active .js-settingContainer .js-setting .dropdown-icon', + ) + click(css: '.content.active .js-settingContainer .js-setting .dropdown-icon') + modal_ready() + select( + css: '.modal #ui_ticket_zoom_article_email_full_quote select[name="ui_ticket_zoom_article_email_full_quote"]', + value: 'yes' + ) + click( + css: '.modal #ui_ticket_zoom_article_email_full_quote .btn[type="submit"]', + ) + modal_close() + modal_disappear() + + exists(css: '.content.active .ticket-article [data-type="emailReply"]') + + # switch user profile language to German + switch_language( + data: { + language: 'Deutsch' + }, + ) + + ticket_open_by_title( + title: 'Welcome to Zammad', + ) + + scroll_to( + position: 'botton', + css: '.content.active .ticket-article [data-type="emailReply"]', + ) + click(css: '.content.active .ticket-article [data-type="emailReply"]') + + full_text = @browser.find_element(css: '.content.active .article-new .articleNewEdit-body').text + + match = full_text.match(/\nAm (.*?), schrieb Nicole Braun:/) + assert match + + datestamp = match[1] + assert datestamp + assert Time.zone.parse(datestamp) + day_of_week = datestamp.split(',').first + assert %w[Montag Dienstag Mittwoch Donnerstag Freitag Samstag Sonntag].include? day_of_week + + # switch user profile language to English again for other tests + switch_language( + data: { + language: 'English (United States)' + }, + ) + end end diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 2003fca28..5a697c1d4 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -4440,6 +4440,55 @@ wait untill text in selector disabppears scope.find_element(css: "input[value=#{value}]").property('checked') end +=begin + + Switch the current logged in user's profile language to a new language + + switch_language( + browser: browser2, + data: { + language: 'Deutsch' + }, + ) + + IMPORTANT REMINDER! At the end of tests, the caller must manually set the language back to English again: + + switch_language( + browser: browser2, + data: { + language: 'English (United States)' + }, + ) + + Failure to switch back to English will cause large amounts of subsequent tests to fail due to the UI language differences. + +=end + + def switch_language(params = {}) + switch_window_focus(params) + log('switch_language', params) + + instance = params[:browser] || @browser + data = params[:data] + + click(browser: instance, css: '#navigation .user-menu .js-avatar') + + click(browser: instance, css: '#navigation .user-menu a[href="#profile"]') + + select( + browser: instance, + css: '.content.active .searchableSelect-shadow', + value: data[:language], + ) + + click(browser: instance, css: '.content.active .btn--primary') + + watch_for( + browser: instance, + css: '#notify', + ) + end + =begin Retrieve a hash of all the avaiable Zammad settings and their current values.