Skip to content

Commit edecd76

Browse files
committed
Fix locale enforcement on GA4 webchat available link
1 parent cbf3997 commit edecd76

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/views/shared/_webchat.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
rel="external"
2727
class="js-webchat-open-button"
2828
data-module="ga4-link-tracker"
29-
data-ga4-link="<%= { event_name: "navigation", type: "webchat", text: t("shared.webchat.speak_to_adviser", lang: :en) }.to_json %>">
29+
data-ga4-link="<%= { event_name: "navigation", type: "webchat", text: t("shared.webchat.speak_to_adviser", locale: :en) }.to_json %>">
3030
<%= t("shared.webchat.speak_to_adviser") %>
3131
</a>.
3232
</span>

test/integration/contact_test.rb

+7
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,11 @@ class ContactTest < ActionDispatch::IntegrationTest
8888
assert_selector ".js-webchat-advisers-available a[data-module=ga4-link-tracker]"
8989
assert_selector ".js-webchat-advisers-available a[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"webchat\",\"text\":\"Speak to an adviser now\"}']"
9090
end
91+
92+
test "has English text for GA4 on the webchat available link, even if the link is in another language" do
93+
setup_and_visit_content_item("contact", { locale: "cy", base_path: "/government/organisations/hm-passport-office/contact/hm-passport-office-webchat", details: { "more_info_webchat": "<p>Some HTML</p>\n" } })
94+
assert_selector ".js-webchat-advisers-available a[data-module=ga4-link-tracker]"
95+
assert_selector ".js-webchat-advisers-available a[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"webchat\",\"text\":\"Speak to an adviser now\"}']"
96+
assert_selector ".js-webchat-advisers-available a", text: "Siaradwch â chynghorydd nawr"
97+
end
9198
end

0 commit comments

Comments
 (0)