Skip to content

Commit

Permalink
Fix locale enforcement on GA4 webchat available link
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGDS committed Feb 23, 2024
1 parent b13db9e commit cfa3509
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/shared/_webchat.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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") %>
</a>.
</span>
Expand Down
7 changes: 7 additions & 0 deletions test/integration/contact_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<p>Some HTML</p>\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

0 comments on commit cfa3509

Please sign in to comment.