From edecd766cf9a4cb1953fed1a70cc6c6c538097e9 Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Fri, 23 Feb 2024 11:18:50 +0000 Subject: [PATCH] Fix locale enforcement on GA4 webchat available link --- app/views/shared/_webchat.html.erb | 2 +- test/integration/contact_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/views/shared/_webchat.html.erb b/app/views/shared/_webchat.html.erb index 4c86cfdfc..368cee9d1 100644 --- a/app/views/shared/_webchat.html.erb +++ b/app/views/shared/_webchat.html.erb @@ -26,7 +26,7 @@ rel="external" class="js-webchat-open-button" data-module="ga4-link-tracker" - data-ga4-link="<%= { event_name: "navigation", type: "webchat", text: t("shared.webchat.speak_to_adviser", lang: :en) }.to_json %>"> + data-ga4-link="<%= { event_name: "navigation", type: "webchat", text: t("shared.webchat.speak_to_adviser", locale: :en) }.to_json %>"> <%= t("shared.webchat.speak_to_adviser") %> . diff --git a/test/integration/contact_test.rb b/test/integration/contact_test.rb index 7ba14d7aa..58344b66e 100644 --- a/test/integration/contact_test.rb +++ b/test/integration/contact_test.rb @@ -88,4 +88,11 @@ class ContactTest < ActionDispatch::IntegrationTest assert_selector ".js-webchat-advisers-available a[data-module=ga4-link-tracker]" assert_selector ".js-webchat-advisers-available a[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"webchat\",\"text\":\"Speak to an adviser now\"}']" end + + test "has English text for GA4 on the webchat available link, even if the link is in another language" do + setup_and_visit_content_item("contact", { locale: "cy", base_path: "/government/organisations/hm-passport-office/contact/hm-passport-office-webchat", details: { "more_info_webchat": "
Some HTML
\n" } }) + assert_selector ".js-webchat-advisers-available a[data-module=ga4-link-tracker]" + assert_selector ".js-webchat-advisers-available a[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"webchat\",\"text\":\"Speak to an adviser now\"}']" + assert_selector ".js-webchat-advisers-available a", text: "Siaradwch รข chynghorydd nawr" + end end