Commit ca7aad60 authored by Nathan Friend's avatar Nathan Friend

Merge branch '215130-update-docs-for-code-coverage-report' into 'master'

Update docs for CSV report

See merge request gitlab-org/gitlab!42507
parents 6e0a7fdd 88554977
...@@ -16,7 +16,15 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -16,7 +16,15 @@ info: To determine the technical writer assigned to the Stage/Group associated w
CAUTION: **Warning:** CAUTION: **Warning:**
This feature might not be available to you. Check the **version history** note above for details. This feature might not be available to you. Check the **version history** note above for details.
To get a CSV of the code coverage data for all of the projects in your group, go to your group's **Analytics > CI/CD** page, and click **Download historic test coverage data (.csv)**. You can get a CSV of the code coverage data for all of the projects in your group. This report has a maximum of 1000 records. To get the report:
1. Go to your group's **Analytics > Repositories** page
1. Click **Download historic test coverage data (.csv)**,
1. In the popup, select the projects you want to include in the report.
1. Select the date range for the report from the preset options.
1. Click **Download test coverage data (.csv)**.
The projects dropdown shows up to 100 projects from your group. If the project you want to check is not in the dropdown list, you can select **All projects** to download the report for all projects in your group, including any projects that are not listed. There is a plan to improve this behavior in this [related issue](https://gitlab.com/gitlab-org/gitlab/-/issues/250684).
For each day that a coverage report was generated by a job in a project's pipeline, there will be a row in the CSV which includes: For each day that a coverage report was generated by a job in a project's pipeline, there will be a row in the CSV which includes:
......
...@@ -10,7 +10,6 @@ import { ...@@ -10,7 +10,6 @@ import {
} from '@gitlab/ui'; } from '@gitlab/ui';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import { pikadayToString } from '~/lib/utils/datetime_utility'; import { pikadayToString } from '~/lib/utils/datetime_utility';
import { getProjectIdQueryParams } from '../utils';
import getGroupProjects from '../graphql/queries/get_group_projects.query.graphql'; import getGroupProjects from '../graphql/queries/get_group_projects.query.graphql';
export default { export default {
...@@ -72,7 +71,18 @@ export default { ...@@ -72,7 +71,18 @@ export default {
const endDate = pikadayToString(today); const endDate = pikadayToString(today);
today.setDate(today.getDate() - this.selectedDateRange.value); today.setDate(today.getDate() - this.selectedDateRange.value);
const startDate = pikadayToString(today); const startDate = pikadayToString(today);
return `${this.groupAnalyticsCoverageReportsPath}&start_date=${startDate}&end_date=${endDate}&${this.selectedProjectIdsParam}`;
const queryParams = new URLSearchParams({
start_date: startDate,
end_date: endDate,
});
// not including a project_ids param is the same as selecting all the projects
if (!this.selectAllProjects) {
queryParams.set('project_ids', this.selectedProjectIdsParam);
}
return `${this.groupAnalyticsCoverageReportsPath}&${queryParams.toString()}`;
}, },
downloadCSVModalButton() { downloadCSVModalButton() {
return { return {
...@@ -96,10 +106,7 @@ export default { ...@@ -96,10 +106,7 @@ export default {
); );
}, },
selectedProjectIdsParam() { selectedProjectIdsParam() {
if (this.selectAllProjects) { return this.groupProjects.filter(project => project.isSelected).map(project => project.id);
return getProjectIdQueryParams(this.groupProjects);
}
return getProjectIdQueryParams(this.groupProjects.filter(project => project.isSelected));
}, },
}, },
methods: { methods: {
......
export const getProjectIdQueryParams = projects =>
`project_ids=${projects.map(project => project.id).join(',')}`;
---
title: Fix selecting all projects in group code coverage report
merge_request: 42507
author:
type: fixed
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import { GlDropdown, GlDropdownItem, GlModal } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlModal } from '@gitlab/ui';
import { useFakeDate } from 'helpers/fake_date'; import { useFakeDate } from 'helpers/fake_date';
import { getProjectIdQueryParams } from 'ee/analytics/repository_analytics/utils';
import GroupRepositoryAnalytics from 'ee/analytics/repository_analytics/components/group_repository_analytics.vue'; import GroupRepositoryAnalytics from 'ee/analytics/repository_analytics/components/group_repository_analytics.vue';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -76,9 +75,21 @@ describe('Group repository analytics app', () => { ...@@ -76,9 +75,21 @@ describe('Group repository analytics app', () => {
selectAllCodeCoverageProjects(); selectAllCodeCoverageProjects();
}); });
it('renders primary action as a link with all project IDs as parameters', () => { it('renders primary action as a link with no project_ids param', () => {
const projectIdParams = getProjectIdQueryParams(groupProjectsData); expect(findCodeCoverageDownloadButton().attributes('href')).toBe(
const expectedPath = `${groupAnalyticsCoverageReportsPathWithDates}&${projectIdParams}`; groupAnalyticsCoverageReportsPathWithDates,
);
});
});
describe('with two or more projects selected without selecting all projects', () => {
beforeEach(() => {
selectCodeCoverageProjectById(groupProjectsData[0].id);
selectCodeCoverageProjectById(groupProjectsData[1].id);
});
it('renders primary action as a link with two project IDs as parameters', () => {
const expectedPath = `${groupAnalyticsCoverageReportsPathWithDates}&project_ids=${groupProjectsData[0].id}%2C${groupProjectsData[1].id}`;
expect(findCodeCoverageDownloadButton().attributes('href')).toBe(expectedPath); expect(findCodeCoverageDownloadButton().attributes('href')).toBe(expectedPath);
}); });
...@@ -111,15 +122,13 @@ describe('Group repository analytics app', () => { ...@@ -111,15 +122,13 @@ describe('Group repository analytics app', () => {
}); });
describe('when selecting a date range', () => { describe('when selecting a date range', () => {
const projectIdParams = '&project_ids=1,2';
it.each` it.each`
date | expected date | expected
${7} | ${`${injectedProperties.groupAnalyticsCoverageReportsPath}&start_date=2020-06-29&end_date=2020-07-06${projectIdParams}`} ${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${projectIdParams}`} ${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${projectIdParams}`} ${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${projectIdParams}`} ${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${projectIdParams}`} ${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', 'updates CSV path to have the start date be $date days before today',
({ date, expected }) => { ({ date, expected }) => {
......
import { getProjectIdQueryParams } from 'ee/analytics/repository_analytics/utils';
describe('group repository analytics util functions', () => {
describe('getProjectIdQueryParams', () => {
it('returns query param string project ids', () => {
const projects = [{ id: 1 }, { id: 2 }];
const expectedString = 'project_ids=1,2';
expect(getProjectIdQueryParams(projects)).toBe(expectedString);
});
});
});
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