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 ...@@ -8,20 +8,19 @@ RSpec.describe Gitlab::Metrics::Dashboard::Stages::TrackPanelType do
let(:project) { build_stubbed(:project) } let(:project) { build_stubbed(:project) }
let(:environment) { build_stubbed(:environment, project: project) } let(:environment) { build_stubbed(:environment, project: project) }
describe '#transform!' do describe '#transform!', :snowplow do
subject { described_class.new(project, dashboard, environment: environment) } subject { described_class.new(project, dashboard, environment: environment) }
let(:dashboard) { load_sample_dashboard.deep_symbolize_keys } let(:dashboard) { load_sample_dashboard.deep_symbolize_keys }
it 'creates tracking event' do 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! subject.transform!
expect(Gitlab::Tracking).to have_received(:event) expect_snowplow_event(
.with('MetricsDashboard::Chart', 'chart_rendered', { label: 'area-chart' }) category: 'MetricsDashboard::Chart',
.at_least(:once) action: 'chart_rendered',
label: 'area-chart'
)
end end
end end
end end
...@@ -33,7 +33,7 @@ module SnowplowHelpers ...@@ -33,7 +33,7 @@ module SnowplowHelpers
# end # end
def expect_snowplow_event(category:, action:, **kwargs) def expect_snowplow_event(category:, action:, **kwargs)
expect(Gitlab::Tracking).to have_received(:event) expect(Gitlab::Tracking).to have_received(:event)
.with(category, action, **kwargs) .with(category, action, **kwargs).at_least(:once)
end end
# Asserts that no call to `Gitlab::Tracking#event` was made. # 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