Commit c8b4a002 authored by Sarah Groff Hennigh-Palermo's avatar Sarah Groff Hennigh-Palermo

Merge branch '294032-remove-ref-path-from-url' into 'master'

Remove ref_path from coverage CSV path

See merge request gitlab-org/gitlab!53063
parents 281e1405 22d876f7
......@@ -11,6 +11,7 @@ import {
} from '@gitlab/ui';
import { __, s__ } from '~/locale';
import { pikadayToString } from '~/lib/utils/datetime_utility';
import { mergeUrlParams } from '~/lib/utils/url_utility';
import SelectProjectsDropdown from './select_projects_dropdown.vue';
export default {
......@@ -53,17 +54,19 @@ export default {
today.setDate(today.getDate() - this.selectedDateRange.value);
const startDate = pikadayToString(today);
const queryParams = new URLSearchParams({
const queryParams = {
start_date: startDate,
end_date: endDate,
});
};
// not including a project_ids param is the same as selecting all the projects
if (!this.allProjectsSelected) {
this.selectedProjectIds.forEach((id) => queryParams.append('project_ids[]', id));
if (!this.allProjectsSelected && this.selectedProjectIds.length) {
queryParams.project_ids = this.selectedProjectIds;
}
return `${this.groupAnalyticsCoverageReportsPath}&${queryParams.toString()}`;
return mergeUrlParams(queryParams, this.groupAnalyticsCoverageReportsPath, {
spreadArrays: true,
});
},
downloadCSVModalButton() {
return {
......
......@@ -4,5 +4,5 @@
%h3
= _("Repositories Analytics")
#js-group-repository-analytics{ data: { group_analytics_coverage_reports_path: group_analytics_coverage_reports_path(@group, format: :csv, ref_path: ""),
#js-group-repository-analytics{ data: { group_analytics_coverage_reports_path: group_analytics_coverage_reports_path(@group, format: :csv),
group_full_path: @group.full_path } }
......@@ -24,7 +24,7 @@ describe('Download test coverage component', () => {
const findAlert = () => wrapper.find(GlAlert);
const injectedProperties = {
groupAnalyticsCoverageReportsPath: '/coverage.csv?ref_path=refs/heads/master',
groupAnalyticsCoverageReportsPath: '/coverage.csv',
};
const createComponent = () => {
......@@ -75,7 +75,7 @@ describe('Download test coverage component', () => {
describe('when selecting a project', () => {
// Due to the fake_date helper, we can always expect today's date to be 2020-07-06
// and the default date 30 days ago to be 2020-06-06
const groupAnalyticsCoverageReportsPathWithDates = `${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-06-06&end_date=2020-07-06`;
const groupAnalyticsCoverageReportsPathWithDates = `${injectedProperties.groupAnalyticsCoverageReportsPath}?start_date=2020-06-06&end_date=2020-07-06`;
describe('with all projects selected', () => {
it('renders primary action as a link with no project_ids param', () => {
......@@ -92,7 +92,7 @@ describe('Download test coverage component', () => {
describe('with two or more projects selected without selecting all projects', () => {
it('renders primary action as a link with two project IDs as parameters', () => {
wrapper.setData({ allProjectsSelected: false, selectedProjectIds: [1, 2] });
const projectIdsQueryParam = `project_ids%5B%5D=1&project_ids%5B%5D=2`;
const projectIdsQueryParam = `project_ids[]=1&project_ids[]=2`;
const expectedPath = `${groupAnalyticsCoverageReportsPathWithDates}&${projectIdsQueryParam}`;
return wrapper.vm.$nextTick().then(() => {
......@@ -104,7 +104,7 @@ describe('Download test coverage component', () => {
describe('with one project selected', () => {
it('renders primary action as a link with one project ID as a parameter', () => {
wrapper.setData({ allProjectsSelected: false, selectedProjectIds: [1] });
const projectIdsQueryParam = `project_ids%5B%5D=1`;
const projectIdsQueryParam = `project_ids[]=1`;
const expectedPath = `${groupAnalyticsCoverageReportsPathWithDates}&${projectIdsQueryParam}`;
return wrapper.vm.$nextTick().then(() => {
......@@ -137,11 +137,11 @@ describe('Download test coverage component', () => {
describe('when selecting a date range', () => {
it.each`
date | expected
${7} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-06-29&end_date=2020-07-06`}
${14} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-06-22&end_date=2020-07-06`}
${30} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-06-06&end_date=2020-07-06`}
${60} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-05-07&end_date=2020-07-06`}
${90} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-04-07&end_date=2020-07-06`}
${7} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}?start_date=2020-06-29&end_date=2020-07-06`}
${14} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}?start_date=2020-06-22&end_date=2020-07-06`}
${30} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}?start_date=2020-06-06&end_date=2020-07-06`}
${60} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}?start_date=2020-05-07&end_date=2020-07-06`}
${90} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}?start_date=2020-04-07&end_date=2020-07-06`}
`(
'updates CSV path to have the start date be $date days before today',
({ date, expected }) => {
......
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