2021-02-22 17:27:13 +05:30
|
|
|
import { GlColumnChart } from '@gitlab/ui/dist/charts';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createMockApollo from 'helpers/mock_apollo_helper';
|
2021-03-08 18:12:59 +05:30
|
|
|
import PipelineCharts from '~/projects/pipelines/charts/components/pipeline_charts.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import StatisticsList from '~/projects/pipelines/charts/components/statistics_list.vue';
|
|
|
|
import getPipelineCountByStatus from '~/projects/pipelines/charts/graphql/queries/get_pipeline_count_by_status.query.graphql';
|
|
|
|
import getProjectPipelineStatistics from '~/projects/pipelines/charts/graphql/queries/get_project_pipeline_statistics.query.graphql';
|
2021-06-08 01:23:25 +05:30
|
|
|
import CiCdAnalyticsCharts from '~/vue_shared/components/ci_cd_analytics/ci_cd_analytics_charts.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { mockPipelineCount, mockPipelineStatistics } from '../mock_data';
|
|
|
|
|
|
|
|
const projectPath = 'gitlab-org/gitlab';
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(VueApollo);
|
2021-02-22 17:27:13 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
describe('~/projects/pipelines/charts/components/pipeline_charts.vue', () => {
|
2021-02-22 17:27:13 +05:30
|
|
|
let wrapper;
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
function createMockApolloProvider() {
|
|
|
|
const requestHandlers = [
|
|
|
|
[getPipelineCountByStatus, jest.fn().mockResolvedValue(mockPipelineCount)],
|
|
|
|
[getProjectPipelineStatistics, jest.fn().mockResolvedValue(mockPipelineStatistics)],
|
|
|
|
];
|
|
|
|
|
|
|
|
return createMockApollo(requestHandlers);
|
|
|
|
}
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
beforeEach(() => {
|
2021-03-08 18:12:59 +05:30
|
|
|
wrapper = shallowMount(PipelineCharts, {
|
|
|
|
provide: {
|
2021-03-11 19:13:27 +05:30
|
|
|
projectPath,
|
2021-02-22 17:27:13 +05:30
|
|
|
},
|
2021-03-11 19:13:27 +05:30
|
|
|
localVue,
|
|
|
|
apolloProvider: createMockApolloProvider(),
|
2021-02-22 17:27:13 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('overall statistics', () => {
|
|
|
|
it('displays the statistics list', () => {
|
|
|
|
const list = wrapper.find(StatisticsList);
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(list.exists()).toBe(true);
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(list.props('counts')).toEqual({
|
|
|
|
total: 34,
|
|
|
|
success: 23,
|
|
|
|
failed: 1,
|
|
|
|
successRatio: (23 / (23 + 1)) * 100,
|
|
|
|
});
|
2021-02-22 17:27:13 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('displays the commit duration chart', () => {
|
|
|
|
const chart = wrapper.find(GlColumnChart);
|
|
|
|
|
|
|
|
expect(chart.exists()).toBeTruthy();
|
|
|
|
expect(chart.props('yAxisTitle')).toBe('Minutes');
|
|
|
|
expect(chart.props('xAxisTitle')).toBe('Commit');
|
|
|
|
expect(chart.props('bars')).toBe(wrapper.vm.timesChartTransformedData);
|
|
|
|
expect(chart.props('option')).toBe(wrapper.vm.$options.timesChartOptions);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('pipelines charts', () => {
|
2021-03-11 19:13:27 +05:30
|
|
|
it('displays the charts components', () => {
|
|
|
|
expect(wrapper.find(CiCdAnalyticsCharts).exists()).toBe(true);
|
2021-02-22 17:27:13 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('displays individual correctly', () => {
|
|
|
|
it('renders with the correct data', () => {
|
2021-03-11 19:13:27 +05:30
|
|
|
const charts = wrapper.find(CiCdAnalyticsCharts);
|
|
|
|
expect(charts.props()).toEqual({
|
|
|
|
charts: wrapper.vm.areaCharts,
|
|
|
|
chartOptions: wrapper.vm.$options.areaChartOptions,
|
|
|
|
});
|
2021-02-22 17:27:13 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|