From f492f76febf3d96596b6ca11b856761898d68ab6 Mon Sep 17 00:00:00 2001 From: alexbowen Date: Wed, 2 Oct 2024 15:23:35 +0100 Subject: [PATCH] reafctors panel/section specs that were giving false positives --- spec/components/filter_panel_spec.rb | 18 ++++++++++-------- spec/components/filter_section_spec.rb | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/spec/components/filter_panel_spec.rb b/spec/components/filter_panel_spec.rb index e5cfe387b..91e02f980 100644 --- a/spec/components/filter_panel_spec.rb +++ b/spec/components/filter_panel_spec.rb @@ -78,20 +78,22 @@ def render_component(locals, &block) end it "renders ga4 tracking attributes to open/close button element" do + button_text = "Filter" + button_event_attributes = { - "ga4-expandable": "true", - "ga4-event": { - "event-name": "select_content", - "type": "finder", + event_name: "select_content", + type: "finder", + section: button_text, + text: button_text, + index: { + index_section: 0, + index_section_count: 4, }, } - button_text = "Filter" - render_component(button_text:, data: button_event_attributes.to_json) assert_select ".app-c-filter-panel button[data-ga4-expandable]", true - assert_select ".app-c-filter-panel button[data-ga4-event]", data: button_event_attributes.to_json - assert_select ".app-c-filter-panel button[data-ga4-event]", data: { section: button_text, text: button_text } + assert_select ".app-c-filter-panel button[data-ga4-event='#{button_event_attributes.to_json}']", true end end diff --git a/spec/components/filter_section_spec.rb b/spec/components/filter_section_spec.rb index bb5c5ad6b..a80dd6d75 100644 --- a/spec/components/filter_section_spec.rb +++ b/spec/components/filter_section_spec.rb @@ -58,20 +58,22 @@ def render_component(locals) end it "renders ga4 tracking attributes to open/close summary element" do + heading_text = "Filter" + button_event_attributes = { - "ga4-expandable": "true", - "ga4-event": { - "event-name": "select_content", - "type": "finder", + event_name: "select_content", + type: "finder", + section: heading_text, + text: heading_text, + index: { + index_section: 1, + index_section_count: 0, }, } - heading_text = "Filter" - render_component(heading_text:, data: button_event_attributes.to_json) assert_select ".app-c-filter-section summary[data-ga4-expandable]", true - assert_select ".app-c-filter-section summary[data-ga4-event]", data: button_event_attributes.to_json - assert_select ".app-c-filter-section summary[data-ga4-event]", data: { section: heading_text, text: heading_text } + assert_select ".app-c-filter-section summary[data-ga4-event='#{button_event_attributes.to_json}']", true end end