-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9996 from alphagov/attachments_ga4_index
Add GA4 index to attachment component renders
- Loading branch information
Showing
2 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,25 @@ class AttachmentsHelperTest < ActionView::TestCase | |
end | ||
end | ||
|
||
test "block_attachments renders with GA4 indexes on the nested details component" do | ||
alternative_format_contact_email = "[email protected]" | ||
file_attachment_with_all_assets = create(:file_attachment) | ||
attachments = [ | ||
file_attachment_with_all_assets, | ||
file_attachment_with_all_assets, | ||
file_attachment_with_all_assets, | ||
] | ||
|
||
rendered_attachments = block_attachments(attachments, alternative_format_contact_email) | ||
rendered_attachments.each.with_index do |rendered, index| | ||
assert_select_within_html(rendered, ".gem-c-details") do |details| | ||
ga4_event = JSON.parse(details.attribute("data-ga4-event")) | ||
assert_equal ga4_event["index_section"], index + 1 | ||
assert_equal ga4_event["index_section_count"], 3 | ||
end | ||
end | ||
end | ||
|
||
test "component params for HTML attachment" do | ||
attachment = create(:html_attachment) | ||
expect_params = { | ||
|