Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix locale enforcement on GA4 webchat available link #3110

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading