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