Commit bcd124ae authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'nicolasdular/migrate-to-snowplow-helper' into 'master'

Migrate track panel specs to snowplow helper

See merge request gitlab-org/gitlab!41879
parents b6808c9a 9bae04ea
......@@ -8,20 +8,19 @@ RSpec.describe Gitlab::Metrics::Dashboard::Stages::TrackPanelType do
let(:project) { build_stubbed(:project) }
let(:environment) { build_stubbed(:environment, project: project) }
describe '#transform!' do
describe '#transform!', :snowplow do
subject { described_class.new(project, dashboard, environment: environment) }
let(:dashboard) { load_sample_dashboard.deep_symbolize_keys }
it 'creates tracking event' do
stub_application_setting(snowplow_enabled: true, snowplow_collector_hostname: 'localhost')
allow(Gitlab::Tracking).to receive(:event).and_call_original
subject.transform!
expect(Gitlab::Tracking).to have_received(:event)
.with('MetricsDashboard::Chart', 'chart_rendered', { label: 'area-chart' })
.at_least(:once)
expect_snowplow_event(
category: 'MetricsDashboard::Chart',
action: 'chart_rendered',
label: 'area-chart'
)
end
end
end
......@@ -33,7 +33,7 @@ module SnowplowHelpers
# end
def expect_snowplow_event(category:, action:, **kwargs)
expect(Gitlab::Tracking).to have_received(:event)
.with(category, action, **kwargs)
.with(category, action, **kwargs).at_least(:once)
end
# Asserts that no call to `Gitlab::Tracking#event` was made.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment