Commit f76fbea9 authored by Nathan Friend's avatar Nathan Friend

Add DORA 4 lead time API frontend fixture

This commit adds 3 new frontend fixtures that represent the return
values of the DORA 4 lead time API.
parent f69bcd39
......@@ -9,16 +9,21 @@ RSpec.describe 'DORA Metrics (JavaScript fixtures)' do
let_it_be(:project) { create(:project, :repository) }
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(:seconds_in_1_day) { 60 * 60 * 24 }
before_all do
[
{ date: '2015-06-01', value: 1 },
{ date: '2015-06-25', value: 1 },
{ date: '2015-06-30', value: 3 },
{ date: '2015-07-01', value: 1 },
{ date: '2015-07-03', value: 1 }
{ date: '2015-06-01', deployment_frequency: 1, lead_time_for_changes_in_seconds: nil },
{ date: '2015-06-25', deployment_frequency: 1, lead_time_for_changes_in_seconds: nil },
{ date: '2015-06-30', deployment_frequency: 3, lead_time_for_changes_in_seconds: seconds_in_1_day },
{ date: '2015-07-01', deployment_frequency: 1, lead_time_for_changes_in_seconds: seconds_in_1_day * 5 },
{ date: '2015-07-03', deployment_frequency: 1, lead_time_for_changes_in_seconds: seconds_in_1_day * 7 }
].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
......@@ -32,38 +37,45 @@ RSpec.describe 'DORA Metrics (JavaScript fixtures)' do
end
describe API::Dora::Metrics, type: :request do
let(:shared_params) do
{
end_date: Date.tomorrow.beginning_of_day,
interval: 'daily'
}
end
before(:all) do
clean_frontend_fixtures('api/dora/metrics')
end
describe 'deployment frequency' do
let(:shared_params) do
{
metric: 'deployment_frequency',
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
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
make_request(additional_query_params: { start_date: 1.week.ago })
shared_examples 'dora metric fixtures' do |metric_name|
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
end
it 'api/dora/metrics/daily_deployment_frequencies_for_last_month.json' do
make_request(additional_query_params: { start_date: 1.month.ago })
it "api/dora/metrics/daily_#{metric_name}_for_last_month.json" do
make_request(additional_query_params: { metric: metric_name, start_date: 1.month.ago })
expect(response).to be_successful
end
it 'api/dora/metrics/daily_deployment_frequencies_for_last_90_days.json' do
make_request(additional_query_params: { start_date: 90.days.ago })
it "api/dora/metrics/daily_#{metric_name}_for_last_90_days.json" do
make_request(additional_query_params: { metric: metric_name, start_date: 90.days.ago })
expect(response).to be_successful
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
......@@ -11,13 +11,13 @@ import CiCdAnalyticsCharts from '~/projects/pipelines/charts/components/ci_cd_an
jest.mock('~/flash');
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(
'api/dora/metrics/daily_deployment_frequencies_for_last_month.json',
'api/dora/metrics/daily_deployment_frequency_for_last_month.json',
);
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', () => {
......
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