Commit 044170c7 authored by Brandon Labuschagne's avatar Brandon Labuschagne

Merge branch 'nfriend-add-lead-time-frontend-fixture' into 'master'

Add DORA 4 lead time API frontend fixtures

See merge request gitlab-org/gitlab!58708
parents ec369247 f76fbea9
...@@ -9,16 +9,21 @@ RSpec.describe 'DORA Metrics (JavaScript fixtures)' do ...@@ -9,16 +9,21 @@ RSpec.describe 'DORA Metrics (JavaScript fixtures)' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:reporter) { create(:user).tap { |u| project.add_reporter(u) } } let_it_be(:reporter) { create(:user).tap { |u| project.add_reporter(u) } }
let_it_be(:environment) { create(:environment, project: project, name: 'production') } let_it_be(:environment) { create(:environment, project: project, name: 'production') }
let_it_be(:seconds_in_1_day) { 60 * 60 * 24 }
before_all do before_all do
[ [
{ date: '2015-06-01', value: 1 }, { date: '2015-06-01', deployment_frequency: 1, lead_time_for_changes_in_seconds: nil },
{ date: '2015-06-25', value: 1 }, { date: '2015-06-25', deployment_frequency: 1, lead_time_for_changes_in_seconds: nil },
{ date: '2015-06-30', value: 3 }, { date: '2015-06-30', deployment_frequency: 3, lead_time_for_changes_in_seconds: seconds_in_1_day },
{ date: '2015-07-01', value: 1 }, { date: '2015-07-01', deployment_frequency: 1, lead_time_for_changes_in_seconds: seconds_in_1_day * 5 },
{ date: '2015-07-03', value: 1 } { date: '2015-07-03', deployment_frequency: 1, lead_time_for_changes_in_seconds: seconds_in_1_day * 7 }
].each do |data_point| ].each do |data_point|
create(:dora_daily_metrics, deployment_frequency: data_point[:value], environment: environment, date: data_point[:date]) create(:dora_daily_metrics,
deployment_frequency: data_point[:deployment_frequency],
lead_time_for_changes_in_seconds: data_point[:lead_time_for_changes_in_seconds],
environment: environment,
date: data_point[:date])
end end
end end
...@@ -32,38 +37,45 @@ RSpec.describe 'DORA Metrics (JavaScript fixtures)' do ...@@ -32,38 +37,45 @@ RSpec.describe 'DORA Metrics (JavaScript fixtures)' do
end end
describe API::Dora::Metrics, type: :request do describe API::Dora::Metrics, type: :request do
let(:shared_params) do
{
end_date: Date.tomorrow.beginning_of_day,
interval: 'daily'
}
end
before(:all) do before(:all) do
clean_frontend_fixtures('api/dora/metrics') clean_frontend_fixtures('api/dora/metrics')
end end
describe 'deployment frequency' do def make_request(additional_query_params:)
let(:shared_params) do params = shared_params.merge(additional_query_params)
{ get api("/projects/#{project.id}/dora/metrics?#{params.to_query}", reporter)
metric: 'deployment_frequency', end
end_date: Date.tomorrow.beginning_of_day,
interval: 'daily'
}
end
def make_request(additional_query_params:)
params = shared_params.merge(additional_query_params)
get api("/projects/#{project.id}/dora/metrics?#{params.to_query}", reporter)
end
it 'api/dora/metrics/daily_deployment_frequencies_for_last_week.json' do shared_examples 'dora metric fixtures' do |metric_name|
make_request(additional_query_params: { start_date: 1.week.ago }) it "api/dora/metrics/daily_#{metric_name}_for_last_week.json" do
make_request(additional_query_params: { metric: metric_name, start_date: 1.week.ago })
expect(response).to be_successful expect(response).to be_successful
end end
it 'api/dora/metrics/daily_deployment_frequencies_for_last_month.json' do it "api/dora/metrics/daily_#{metric_name}_for_last_month.json" do
make_request(additional_query_params: { start_date: 1.month.ago }) make_request(additional_query_params: { metric: metric_name, start_date: 1.month.ago })
expect(response).to be_successful expect(response).to be_successful
end end
it 'api/dora/metrics/daily_deployment_frequencies_for_last_90_days.json' do it "api/dora/metrics/daily_#{metric_name}_for_last_90_days.json" do
make_request(additional_query_params: { start_date: 90.days.ago }) make_request(additional_query_params: { metric: metric_name, start_date: 90.days.ago })
expect(response).to be_successful expect(response).to be_successful
end end
end end
describe 'deployment frequency' do
it_behaves_like 'dora metric fixtures', 'deployment_frequency'
end
describe 'lead time' do
it_behaves_like 'dora metric fixtures', 'lead_time_for_changes'
end
end end
end end
...@@ -11,13 +11,13 @@ import CiCdAnalyticsCharts from '~/projects/pipelines/charts/components/ci_cd_an ...@@ -11,13 +11,13 @@ import CiCdAnalyticsCharts from '~/projects/pipelines/charts/components/ci_cd_an
jest.mock('~/flash'); jest.mock('~/flash');
const lastWeekData = getJSONFixture( const lastWeekData = getJSONFixture(
'api/dora/metrics/daily_deployment_frequencies_for_last_week.json', 'api/dora/metrics/daily_deployment_frequency_for_last_week.json',
); );
const lastMonthData = getJSONFixture( const lastMonthData = getJSONFixture(
'api/dora/metrics/daily_deployment_frequencies_for_last_month.json', 'api/dora/metrics/daily_deployment_frequency_for_last_month.json',
); );
const last90DaysData = getJSONFixture( const last90DaysData = getJSONFixture(
'api/dora/metrics/daily_deployment_frequencies_for_last_90_days.json', 'api/dora/metrics/daily_deployment_frequency_for_last_90_days.json',
); );
describe('ee_component/projects/pipelines/charts/components/deployment_frequency_charts.vue', () => { describe('ee_component/projects/pipelines/charts/components/deployment_frequency_charts.vue', () => {
......
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