Skip to content

Commit

Permalink
reafctors panel/section specs that were giving false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbowen committed Oct 2, 2024
1 parent 2e706f0 commit f492f76
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 10 additions & 8 deletions spec/components/filter_panel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 10 additions & 8 deletions spec/components/filter_section_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f492f76

Please sign in to comment.