@gitlab/ui 32.38.0 → 32.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/components/base/carousel/carousel.documentation.js +1 -4
- package/dist/components/base/filtered_search/filtered_search.js +1 -1
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +5 -2
- package/dist/components/base/form/form_input_group/form_input_group.js +6 -1
- package/dist/components/base/markdown/markdown.documentation.js +2 -6
- package/dist/components/base/search_box_by_click/search_box_by_click.js +2 -1
- package/dist/components/base/search_box_by_type/search_box_by_type.js +1 -1
- package/dist/components/base/token_selector/token_selector.documentation.js +2 -106
- package/dist/components/base/token_selector/token_selector.js +85 -1
- package/dist/components/base/tooltip/tooltip.documentation.js +2 -6
- package/dist/components/charts/area/area.js +1 -1
- package/dist/components/charts/bar/bar.js +1 -1
- package/dist/components/charts/column/column.js +1 -1
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +1 -1
- package/dist/components/charts/line/line.js +1 -1
- package/dist/components/charts/sparkline/sparkline.js +1 -1
- package/dist/components/charts/stacked_column/stacked_column.js +1 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/documentation/documented_stories.js +4 -0
- package/package.json +13 -13
- package/src/components/base/accordion/accordion.spec.js +0 -4
- package/src/components/base/accordion/accordion_item.spec.js +0 -4
- package/src/components/base/alert/alert.spec.js +0 -4
- package/src/components/base/avatar_labeled/avatar_labeled.spec.js +0 -2
- package/src/components/base/avatars_inline/avatars_inline.spec.js +0 -2
- package/src/components/base/badge/badge.spec.js +0 -2
- package/src/components/base/broadcast_message/broadcast_message.spec.js +0 -4
- package/src/components/base/button/button.spec.js +0 -5
- package/src/components/base/card/card.spec.js +0 -5
- package/src/components/base/carousel/carousel.documentation.js +0 -2
- package/src/components/base/carousel/carousel.md +0 -2
- package/src/components/base/carousel/carousel.spec.js +0 -4
- package/src/components/base/carousel/carousel.stories.js +24 -11
- package/src/components/base/collapse/collapse.spec.js +0 -4
- package/src/components/base/datepicker/datepicker.spec.js +0 -4
- package/src/components/base/daterange_picker/daterange_picker.spec.js +0 -5
- package/src/components/base/drawer/drawer.spec.js +0 -4
- package/src/components/base/dropdown/dropdown.spec.js +0 -2
- package/src/components/base/dropdown/dropdown_item.spec.js +0 -2
- package/src/components/base/filtered_search/filtered_search.spec.js +0 -10
- package/src/components/base/filtered_search/filtered_search.vue +1 -0
- package/src/components/base/filtered_search/filtered_search_suggestion.spec.js +0 -5
- package/src/components/base/filtered_search/filtered_search_suggestion_list.spec.js +0 -5
- package/src/components/base/filtered_search/filtered_search_term.spec.js +0 -5
- package/src/components/base/filtered_search/filtered_search_token.spec.js +0 -5
- package/src/components/base/filtered_search/filtered_search_token_segment.vue +4 -1
- package/src/components/base/form/form_checkbox_tree/form_checkbox_tree.spec.js +0 -5
- package/src/components/base/form/form_combobox/form_combobox.spec.js +0 -4
- package/src/components/base/form/form_input/form_input.spec.js +0 -5
- package/src/components/base/form/form_input_group/form_input_group.spec.js +18 -5
- package/src/components/base/form/form_input_group/form_input_group.vue +6 -1
- package/src/components/base/form/form_radio/form_radio.spec.js +0 -4
- package/src/components/base/form/form_radio_group/form_radio_group.spec.js +0 -4
- package/src/components/base/form/form_select/form_select.spec.js +0 -5
- package/src/components/base/form/form_textarea/form_textarea.spec.js +0 -5
- package/src/components/base/icon/icon.spec.js +0 -2
- package/src/components/base/infinite_scroll/infinite_scroll.spec.js +0 -1
- package/src/components/base/keyset_pagination/keyset_pagination.spec.js +0 -5
- package/src/components/base/label/label.spec.js +0 -4
- package/src/components/base/link/link.spec.js +0 -5
- package/src/components/base/loading_icon/loading_icon.spec.js +0 -4
- package/src/components/base/markdown/markdown.documentation.js +0 -3
- package/src/components/base/markdown/markdown.md +0 -2
- package/src/components/base/markdown/markdown.stories.js +25 -24
- package/src/components/base/modal/modal.spec.js +0 -1
- package/src/components/base/nav/nav.spec.js +0 -4
- package/src/components/base/nav/nav_item.spec.js +0 -4
- package/src/components/base/nav/nav_item_dropdown.spec.js +0 -4
- package/src/components/base/paginated_list/paginated_list.spec.js +0 -6
- package/src/components/base/pagination/pagination.spec.js +0 -1
- package/src/components/base/path/path.spec.js +0 -5
- package/src/components/base/popover/popover.spec.js +0 -5
- package/src/components/base/search_box_by_click/search_box_by_click.spec.js +0 -4
- package/src/components/base/search_box_by_click/search_box_by_click.vue +2 -0
- package/src/components/base/search_box_by_type/search_box_by_type.spec.js +0 -5
- package/src/components/base/search_box_by_type/search_box_by_type.vue +1 -1
- package/src/components/base/segmented_control/segmented_control.spec.js +0 -4
- package/src/components/base/skeleton_loader/skeleton_loader.spec.js +0 -5
- package/src/components/base/sorting/sorting.spec.js +0 -4
- package/src/components/base/sorting/sorting_item.spec.js +0 -4
- package/src/components/base/tabs/tabs/scrollable_tabs.spec.js +0 -5
- package/src/components/base/toggle/toggle.spec.js +0 -4
- package/src/components/base/token/token.spec.js +0 -4
- package/src/components/base/token_selector/token_container.spec.js +0 -2
- package/src/components/base/token_selector/token_selector.documentation.js +0 -137
- package/src/components/base/token_selector/token_selector.md +0 -6
- package/src/components/base/token_selector/token_selector.spec.js +0 -5
- package/src/components/base/token_selector/token_selector.stories.js +96 -113
- package/src/components/base/token_selector/token_selector.vue +89 -1
- package/src/components/base/token_selector/token_selector_dropdown.spec.js +0 -5
- package/src/components/base/tooltip/tooltip.documentation.js +0 -3
- package/src/components/base/tooltip/tooltip.md +3 -5
- package/src/components/base/tooltip/tooltip.spec.js +0 -5
- package/src/components/base/tooltip/tooltip.stories.js +49 -25
- package/src/components/base/tooltip/tooltip.vue +1 -0
- package/src/components/charts/area/area.spec.js +8 -24
- package/src/components/charts/area/area.vue +9 -12
- package/src/components/charts/bar/bar.spec.js +4 -26
- package/src/components/charts/bar/bar.vue +3 -2
- package/src/components/charts/chart/chart.spec.js +0 -4
- package/src/components/charts/column/column.vue +3 -2
- package/src/components/charts/column/column_chart.spec.js +35 -19
- package/src/components/charts/discrete_scatter/discrete_scatter.stories.js +1 -0
- package/src/components/charts/discrete_scatter/discrete_scatter.vue +5 -8
- package/src/components/charts/gauge/gauge.spec.js +2 -24
- package/src/components/charts/heatmap/heatmap.spec.js +6 -23
- package/src/components/charts/legend/legend.spec.js +8 -14
- package/src/components/charts/line/line.spec.js +19 -30
- package/src/components/charts/line/line.vue +3 -2
- package/src/components/charts/single_stat/single_stat.spec.js +0 -4
- package/src/components/charts/sparkline/sparkline.spec.js +19 -31
- package/src/components/charts/sparkline/sparkline.vue +24 -12
- package/src/components/charts/stacked_column/stacked_column.spec.js +4 -22
- package/src/components/charts/stacked_column/stacked_column.vue +5 -8
- package/src/components/shared_components/clear_icon_button/clear_icon_button.spec.js +0 -4
- package/src/components/shared_components/close_button/close_button.spec.js +0 -4
- package/src/components/utilities/friendly_wrap/friendly_wrap.spec.js +0 -4
- package/src/components/utilities/intersection_observer/intersection_observer.spec.js +1 -1
- package/src/components/utilities/sprintf/sprintf.spec.js +0 -4
- package/src/components/utilities/truncate/truncate.spec.js +10 -15
- package/src/directives/hover_load/hover_load.spec.js +0 -1
- package/src/directives/outside/outside.spec.js +0 -4
- package/src/directives/resize_observer/resize_observer.spec.js +0 -4
- package/src/directives/safe_html/safe_html.spec.js +0 -4
- package/src/directives/safe_link/safe_link.spec.js +0 -5
- package/src/scss/utilities.scss +14 -0
- package/src/scss/utility-mixins/spacing.scss +4 -0
- package/src/scss/utility-mixins/z-index.scss +4 -0
- package/dist/components/base/carousel/examples/carousel.basic.example.js +0 -38
- package/dist/components/base/carousel/examples/index.js +0 -13
- package/dist/components/base/markdown/examples/index.js +0 -13
- package/dist/components/base/markdown/examples/markdown.basic.example.js +0 -38
- package/dist/components/base/token_selector/examples/index.js +0 -19
- package/dist/components/base/token_selector/examples/token_selector.user_defined_tokens.example.js +0 -48
- package/dist/components/base/token_selector/examples/token_selector.users.example.js +0 -202
- package/dist/components/base/tooltip/examples/index.js +0 -31
- package/dist/components/base/tooltip/examples/tooltip.directive_bottom.example.js +0 -38
- package/dist/components/base/tooltip/examples/tooltip.directive_default.example.js +0 -38
- package/dist/components/base/tooltip/examples/tooltip.directive_left.example.js +0 -38
- package/dist/components/base/tooltip/examples/tooltip.directive_right.example.js +0 -38
- package/src/components/base/carousel/examples/carousel.basic.example.vue +0 -26
- package/src/components/base/carousel/examples/index.js +0 -15
- package/src/components/base/markdown/examples/index.js +0 -15
- package/src/components/base/markdown/examples/markdown.basic.example.vue +0 -15
- package/src/components/base/token_selector/examples/index.js +0 -22
- package/src/components/base/token_selector/examples/token_selector.user_defined_tokens.example.vue +0 -17
- package/src/components/base/token_selector/examples/token_selector.users.example.vue +0 -212
- package/src/components/base/tooltip/examples/index.js +0 -36
- package/src/components/base/tooltip/examples/tooltip.directive_bottom.example.vue +0 -7
- package/src/components/base/tooltip/examples/tooltip.directive_default.example.vue +0 -5
- package/src/components/base/tooltip/examples/tooltip.directive_left.example.vue +0 -7
- package/src/components/base/tooltip/examples/tooltip.directive_right.example.vue +0 -7
|
@@ -345,8 +345,9 @@ export default {
|
|
|
345
345
|
:left="annotationsTooltipPosition.left"
|
|
346
346
|
placement="bottom"
|
|
347
347
|
>
|
|
348
|
-
|
|
349
|
-
|
|
348
|
+
<template #title>
|
|
349
|
+
<div>{{ annotationsTooltipTitle }}</div>
|
|
350
|
+
</template>
|
|
350
351
|
<div>{{ annotationsTooltipContent }}</div>
|
|
351
352
|
</chart-tooltip>
|
|
352
353
|
<chart-tooltip
|
|
@@ -359,19 +360,15 @@ export default {
|
|
|
359
360
|
:top="dataTooltipPosition.top"
|
|
360
361
|
:left="dataTooltipPosition.left"
|
|
361
362
|
>
|
|
362
|
-
<template
|
|
363
|
-
|
|
364
|
-
<
|
|
365
|
-
<slot name="tooltip-content"></slot>
|
|
366
|
-
</template>
|
|
367
|
-
<template v-else>
|
|
368
|
-
<!-- eslint-disable-next-line vue/no-deprecated-slot-attribute -->
|
|
369
|
-
<div slot="title">
|
|
363
|
+
<template #title>
|
|
364
|
+
<slot v-if="formatTooltipText" name="tooltip-title"></slot>
|
|
365
|
+
<template v-else>
|
|
370
366
|
{{ dataTooltipTitle }}
|
|
371
367
|
<template v-if="options.xAxis.name">({{ options.xAxis.name }})</template>
|
|
372
|
-
</
|
|
373
|
-
<tooltip-default-format :tooltip-content="dataTooltipContent" />
|
|
368
|
+
</template>
|
|
374
369
|
</template>
|
|
370
|
+
<slot v-if="formatTooltipText" name="tooltip-content"></slot>
|
|
371
|
+
<tooltip-default-format v-else :tooltip-content="dataTooltipContent" />
|
|
375
372
|
</chart-tooltip>
|
|
376
373
|
<chart-legend
|
|
377
374
|
v-if="compiledOptions"
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import Chart from '../chart/chart.vue';
|
|
3
3
|
import BarChart from './bar.vue';
|
|
4
|
-
import ChartTooltip from '~/components/charts/tooltip/tooltip.vue';
|
|
5
4
|
import TooltipDefaultFormat from '~/components/shared_components/charts/tooltip_default_format.vue';
|
|
5
|
+
import { createMockChartInstance } from '~helpers/chart_stubs';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
getDom: () => {
|
|
9
|
-
return {
|
|
10
|
-
addEventListener: jest.fn(),
|
|
11
|
-
removeEventListener: jest.fn(),
|
|
12
|
-
};
|
|
13
|
-
},
|
|
14
|
-
convertToPixel: jest.fn(),
|
|
15
|
-
};
|
|
7
|
+
let mockChartInstance;
|
|
16
8
|
|
|
17
9
|
jest.mock('echarts', () => ({
|
|
18
10
|
getInstanceByDom: () => mockChartInstance,
|
|
@@ -34,7 +26,6 @@ describe('Bar chart component', () => {
|
|
|
34
26
|
let wrapper;
|
|
35
27
|
|
|
36
28
|
const findChart = () => wrapper.findComponent(Chart);
|
|
37
|
-
const findChartTooltip = () => wrapper.findComponent(ChartTooltip);
|
|
38
29
|
const getOptions = () => findChart().props('options');
|
|
39
30
|
const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
|
|
40
31
|
|
|
@@ -47,8 +38,8 @@ describe('Bar chart component', () => {
|
|
|
47
38
|
});
|
|
48
39
|
};
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
mockChartInstance = createMockChartInstance();
|
|
52
43
|
});
|
|
53
44
|
|
|
54
45
|
describe('when mounted', () => {
|
|
@@ -123,19 +114,6 @@ describe('Bar chart component', () => {
|
|
|
123
114
|
);
|
|
124
115
|
});
|
|
125
116
|
});
|
|
126
|
-
|
|
127
|
-
it('render accurate tooltip title and content', () => {
|
|
128
|
-
const expectedTooltipTitle = `${labelParams.value} (${defaultChartProps.yAxisTitle})`;
|
|
129
|
-
|
|
130
|
-
getOptions().yAxis.axisPointer.label.formatter(labelParams);
|
|
131
|
-
return wrapper.vm.$nextTick(() => {
|
|
132
|
-
const tooltipTextContent = findChartTooltip().element.textContent;
|
|
133
|
-
|
|
134
|
-
expect(tooltipTextContent).toContain(expectedTooltipTitle);
|
|
135
|
-
expect(tooltipTextContent).toContain(defaultChartProps.xAxisTitle);
|
|
136
|
-
expect(tooltipTextContent).toContain(labelParams.seriesData[0].data[0]);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
117
|
});
|
|
140
118
|
});
|
|
141
119
|
});
|
|
@@ -238,8 +238,9 @@ export default {
|
|
|
238
238
|
:top="tooltipPosition.top"
|
|
239
239
|
:left="tooltipPosition.left"
|
|
240
240
|
>
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
<template #title>
|
|
242
|
+
<div>{{ tooltipTitle }} ({{ yAxisTitle }})</div>
|
|
243
|
+
</template>
|
|
243
244
|
<tooltip-default-format :tooltip-content="tooltipContent" />
|
|
244
245
|
</chart-tooltip>
|
|
245
246
|
</div>
|
|
@@ -25,10 +25,6 @@ describe('chart component', () => {
|
|
|
25
25
|
wrapper = shallowMount(...mountArgs);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
wrapper.destroy();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
28
|
it('initializes chart using $refs.chart', () => {
|
|
33
29
|
expect(echarts.init).toHaveBeenCalledWith(
|
|
34
30
|
wrapper.findComponent({ ref: 'chart' }).element,
|
|
@@ -207,8 +207,9 @@ export default {
|
|
|
207
207
|
:top="tooltipPosition.top"
|
|
208
208
|
:left="tooltipPosition.left"
|
|
209
209
|
>
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
<template #title>
|
|
211
|
+
<div>{{ tooltipTitle }} ({{ xAxisTitle }})</div>
|
|
212
|
+
</template>
|
|
212
213
|
<tooltip-default-format :tooltip-content="tooltipContent" />
|
|
213
214
|
</chart-tooltip>
|
|
214
215
|
</div>
|
|
@@ -6,6 +6,13 @@ import {
|
|
|
6
6
|
} from '../../../utils/charts/mock_data';
|
|
7
7
|
import Chart from '../chart/chart.vue';
|
|
8
8
|
import ColumnChart from './column.vue';
|
|
9
|
+
import { createMockChartInstance, ChartTooltipStub } from '~helpers/chart_stubs';
|
|
10
|
+
|
|
11
|
+
let mockChartInstance;
|
|
12
|
+
|
|
13
|
+
jest.mock('echarts', () => ({
|
|
14
|
+
getInstanceByDom: () => mockChartInstance,
|
|
15
|
+
}));
|
|
9
16
|
|
|
10
17
|
describe('column chart component', () => {
|
|
11
18
|
const defaultChartProps = {
|
|
@@ -16,40 +23,33 @@ describe('column chart component', () => {
|
|
|
16
23
|
};
|
|
17
24
|
let wrapper;
|
|
18
25
|
|
|
19
|
-
const TooltipStub = {
|
|
20
|
-
name: 'chart-tooltip',
|
|
21
|
-
template: '<div />',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
26
|
const chartItemClickedSpy = jest.fn();
|
|
25
27
|
const findChart = () => wrapper.findComponent(Chart);
|
|
28
|
+
const findTooltip = () => wrapper.findComponent(ChartTooltipStub);
|
|
29
|
+
const getChartOptions = () => findChart().props('options');
|
|
26
30
|
|
|
27
|
-
const factory = (props = defaultChartProps) => {
|
|
31
|
+
const factory = (props = defaultChartProps, slots) => {
|
|
28
32
|
wrapper = shallowMount(ColumnChart, {
|
|
29
33
|
propsData: { ...props },
|
|
30
34
|
stubs: {
|
|
31
|
-
chart:
|
|
32
|
-
'chart-tooltip': TooltipStub,
|
|
35
|
+
'chart-tooltip': ChartTooltipStub,
|
|
33
36
|
},
|
|
34
37
|
listeners: {
|
|
35
38
|
chartItemClicked: chartItemClickedSpy,
|
|
36
39
|
},
|
|
40
|
+
data() {
|
|
41
|
+
return {
|
|
42
|
+
chart: mockChartInstance,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
slots,
|
|
37
46
|
});
|
|
38
|
-
const chart = {
|
|
39
|
-
getDom: jest.fn(() => ({
|
|
40
|
-
addEventListener: jest.fn(),
|
|
41
|
-
removeEventListener: jest.fn(),
|
|
42
|
-
})),
|
|
43
|
-
};
|
|
44
|
-
wrapper.setData({ chart });
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
beforeEach(() => {
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
+
mockChartInstance = createMockChartInstance();
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
wrapper.destroy();
|
|
52
|
+
factory();
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
it('emits "created" when onCreated is called', () => {
|
|
@@ -104,4 +104,20 @@ describe('column chart component', () => {
|
|
|
104
104
|
expect(chart.props('options').yAxis[1].name).toEqual(secondaryDataTitle);
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
|
+
|
|
108
|
+
describe('tooltip', () => {
|
|
109
|
+
it('displays the generic tooltip content', async () => {
|
|
110
|
+
const params = {
|
|
111
|
+
seriesData: [{ seriesIndex: '0', seriesName: 'Full', value: ['Mary', 934] }],
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
getChartOptions().xAxis.axisPointer.label.formatter(params);
|
|
115
|
+
|
|
116
|
+
await wrapper.vm.$nextTick();
|
|
117
|
+
|
|
118
|
+
const expectedTooltipTitle = `${params.seriesData[0].value[0]} (${defaultChartProps.xAxisTitle})`;
|
|
119
|
+
|
|
120
|
+
expect(findTooltip().text()).toContain(expectedTooltipTitle);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
107
123
|
});
|
|
@@ -174,16 +174,13 @@ export default {
|
|
|
174
174
|
:top="tooltipPosition.top"
|
|
175
175
|
:left="tooltipPosition.left"
|
|
176
176
|
>
|
|
177
|
-
<template
|
|
178
|
-
|
|
179
|
-
<slot slot="title" name="tooltip-title"></slot>
|
|
180
|
-
<slot name="tooltip-content"></slot>
|
|
177
|
+
<template #title>
|
|
178
|
+
<slot name="tooltip-title">{{ tooltipTitle }} ({{ xAxisTitle }})</slot>
|
|
181
179
|
</template>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
<div slot="title">{{ tooltipTitle }} ({{ xAxisTitle }})</div>
|
|
180
|
+
|
|
181
|
+
<slot name="tooltip-content">
|
|
185
182
|
<tooltip-default-format :tooltip-content="tooltipContent" />
|
|
186
|
-
</
|
|
183
|
+
</slot>
|
|
187
184
|
</chart-tooltip>
|
|
188
185
|
</div>
|
|
189
186
|
</template>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
-
|
|
3
2
|
import { gaugeSafeHues, gaugeWarningHue } from '../../../utils/charts/theme';
|
|
4
3
|
import Chart from '../chart/chart.vue';
|
|
5
4
|
import GlGauge from './gauge.vue';
|
|
5
|
+
import { createMockChartInstance } from '~helpers/chart_stubs';
|
|
6
6
|
|
|
7
7
|
const placeholder = '--';
|
|
8
8
|
|
|
@@ -20,7 +20,6 @@ jest.mock('echarts', () => ({
|
|
|
20
20
|
|
|
21
21
|
describe('gauge component', () => {
|
|
22
22
|
let wrapper;
|
|
23
|
-
let options;
|
|
24
23
|
|
|
25
24
|
const findChart = () => wrapper.findComponent(Chart);
|
|
26
25
|
const findChartOptions = () => findChart().props('options');
|
|
@@ -38,28 +37,7 @@ describe('gauge component', () => {
|
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
beforeEach(() => {
|
|
41
|
-
|
|
42
|
-
series: [],
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
mockChartInstance = {
|
|
46
|
-
getDom: () => {
|
|
47
|
-
return {
|
|
48
|
-
addEventListener: jest.fn(),
|
|
49
|
-
removeEventListener: jest.fn(),
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
on: jest.fn(),
|
|
53
|
-
off: jest.fn(),
|
|
54
|
-
convertToPixel: jest.fn(),
|
|
55
|
-
getOption: () => {
|
|
56
|
-
return options;
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
afterEach(() => {
|
|
62
|
-
wrapper.destroy();
|
|
40
|
+
mockChartInstance = createMockChartInstance();
|
|
63
41
|
});
|
|
64
42
|
|
|
65
43
|
it('emits `created`, with the chart instance', () => {
|
|
@@ -4,6 +4,7 @@ import Chart from '../chart/chart.vue';
|
|
|
4
4
|
import ChartTooltip from '../tooltip/tooltip.vue';
|
|
5
5
|
import HeatMapChart from './heatmap.vue';
|
|
6
6
|
import { TOOLTIP_LEFT_OFFSET } from '~/utils/charts/constants';
|
|
7
|
+
import { createMockChartInstance } from '~helpers/chart_stubs';
|
|
7
8
|
|
|
8
9
|
let mockChartInstance;
|
|
9
10
|
|
|
@@ -13,7 +14,6 @@ jest.mock('echarts', () => ({
|
|
|
13
14
|
|
|
14
15
|
describe('heatmap component', () => {
|
|
15
16
|
let wrapper;
|
|
16
|
-
let options;
|
|
17
17
|
|
|
18
18
|
const findChart = () => wrapper.findComponent(Chart);
|
|
19
19
|
const findChartTooltip = () => wrapper.findComponent(ChartTooltip);
|
|
@@ -22,33 +22,16 @@ describe('heatmap component', () => {
|
|
|
22
22
|
const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
|
|
23
23
|
|
|
24
24
|
beforeEach(() => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
getDom: () => {
|
|
31
|
-
return {
|
|
32
|
-
addEventListener: jest.fn(),
|
|
33
|
-
removeEventListener: jest.fn(),
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
convertToPixel: jest.fn(),
|
|
37
|
-
getOption: () => {
|
|
38
|
-
return options;
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
wrapper = shallowMount(HeatMapChart, { propsData: { options, dataSeries: [] } });
|
|
25
|
+
mockChartInstance = createMockChartInstance();
|
|
26
|
+
|
|
27
|
+
wrapper = shallowMount(HeatMapChart, {
|
|
28
|
+
propsData: { options: { series: [] }, dataSeries: [] },
|
|
29
|
+
});
|
|
43
30
|
emitChartCreated();
|
|
44
31
|
|
|
45
32
|
return wrapper.vm.$nextTick();
|
|
46
33
|
});
|
|
47
34
|
|
|
48
|
-
afterEach(() => {
|
|
49
|
-
wrapper.destroy();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
35
|
it('emits `created`, with the chart instance', () => {
|
|
53
36
|
expect(wrapper.emitted('created').length).toBe(1);
|
|
54
37
|
expect(wrapper.emitted('created')[0][0]).toBe(mockChartInstance);
|
|
@@ -2,16 +2,13 @@ import { shallowMount } from '@vue/test-utils';
|
|
|
2
2
|
import Chart from '../chart/chart.vue';
|
|
3
3
|
import GlChartSeriesLabel from '../series_label/series_label.vue';
|
|
4
4
|
import Legend from './legend.vue';
|
|
5
|
+
import { createMockChartInstance } from '~helpers/chart_stubs';
|
|
6
|
+
|
|
7
|
+
let mockChartInstance;
|
|
5
8
|
|
|
6
9
|
jest.mock('echarts', () => ({
|
|
7
|
-
getInstanceByDom:
|
|
8
|
-
init:
|
|
9
|
-
dispatchAction: jest.fn(),
|
|
10
|
-
resize: jest.fn(),
|
|
11
|
-
setOption: jest.fn(),
|
|
12
|
-
on: jest.fn(),
|
|
13
|
-
off: jest.fn(),
|
|
14
|
-
})),
|
|
10
|
+
getInstanceByDom: () => mockChartInstance,
|
|
11
|
+
init: () => mockChartInstance,
|
|
15
12
|
registerTheme: jest.fn(),
|
|
16
13
|
}));
|
|
17
14
|
|
|
@@ -58,24 +55,21 @@ describe('chart legend component', () => {
|
|
|
58
55
|
legendWrapper = shallowMount(Legend, {
|
|
59
56
|
propsData: {
|
|
60
57
|
...propsData,
|
|
61
|
-
chart,
|
|
58
|
+
chart: mockChartInstance,
|
|
62
59
|
seriesInfo,
|
|
63
60
|
},
|
|
64
61
|
});
|
|
65
62
|
};
|
|
66
63
|
|
|
67
64
|
beforeEach(async () => {
|
|
65
|
+
mockChartInstance = createMockChartInstance();
|
|
66
|
+
|
|
68
67
|
chartWrapper = shallowMount(...chartArgs);
|
|
69
68
|
await chartWrapper.vm.$nextTick();
|
|
70
69
|
// Runs after mounting the chart so that it has an up to date reference
|
|
71
70
|
buildLegend();
|
|
72
71
|
});
|
|
73
72
|
|
|
74
|
-
afterEach(() => {
|
|
75
|
-
chartWrapper.destroy();
|
|
76
|
-
legendWrapper.destroy();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
73
|
it('renders the legend with no errors', () => {
|
|
80
74
|
expect(legendWrapper.exists()).toBe(true);
|
|
81
75
|
});
|
|
@@ -6,6 +6,8 @@ import LineChart from './line.vue';
|
|
|
6
6
|
|
|
7
7
|
import { LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE } from '~/utils/charts/constants';
|
|
8
8
|
|
|
9
|
+
import { createMockChartInstance, ChartTooltipStub } from '~helpers/chart_stubs';
|
|
10
|
+
|
|
9
11
|
let mockChartInstance;
|
|
10
12
|
|
|
11
13
|
jest.mock('echarts', () => ({
|
|
@@ -23,36 +25,16 @@ describe('line component', () => {
|
|
|
23
25
|
|
|
24
26
|
const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
|
|
25
27
|
|
|
26
|
-
const createShallowWrapper = (props = {}) => {
|
|
28
|
+
const createShallowWrapper = (props = {}, mountOptions = {}) => {
|
|
27
29
|
wrapper = shallowMount(LineChart, {
|
|
28
30
|
propsData: { option, data: [], ...props },
|
|
31
|
+
...mountOptions,
|
|
29
32
|
});
|
|
30
33
|
emitChartCreated();
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
beforeEach(() => {
|
|
34
|
-
|
|
35
|
-
series: [],
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
mockChartInstance = {
|
|
39
|
-
getDom: () => {
|
|
40
|
-
return {
|
|
41
|
-
addEventListener: jest.fn(),
|
|
42
|
-
removeEventListener: jest.fn(),
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
on: jest.fn(),
|
|
46
|
-
off: jest.fn(),
|
|
47
|
-
convertToPixel: jest.fn(),
|
|
48
|
-
getOption: () => {
|
|
49
|
-
return option;
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
afterEach(() => {
|
|
55
|
-
wrapper.destroy();
|
|
37
|
+
mockChartInstance = createMockChartInstance();
|
|
56
38
|
});
|
|
57
39
|
|
|
58
40
|
it('emits `created`, with the chart instance', async () => {
|
|
@@ -128,14 +110,21 @@ describe('line component', () => {
|
|
|
128
110
|
},
|
|
129
111
|
};
|
|
130
112
|
|
|
131
|
-
createShallowWrapper(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
113
|
+
createShallowWrapper(
|
|
114
|
+
{
|
|
115
|
+
annotations: [
|
|
116
|
+
{
|
|
117
|
+
min: '',
|
|
118
|
+
max: '',
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
stubs: {
|
|
124
|
+
'chart-tooltip': ChartTooltipStub,
|
|
136
125
|
},
|
|
137
|
-
|
|
138
|
-
|
|
126
|
+
}
|
|
127
|
+
);
|
|
139
128
|
|
|
140
129
|
wrapper.vm.onChartDataPointMouseOver(params);
|
|
141
130
|
|
|
@@ -339,8 +339,9 @@ export default {
|
|
|
339
339
|
:left="annotationsTooltipPosition.left"
|
|
340
340
|
placement="bottom"
|
|
341
341
|
>
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
<template #title>
|
|
343
|
+
<div>{{ annotationsTooltipTitle }}</div>
|
|
344
|
+
</template>
|
|
344
345
|
<div>{{ annotationsTooltipContent }}</div>
|
|
345
346
|
</chart-tooltip>
|
|
346
347
|
<chart-tooltip
|
|
@@ -26,10 +26,6 @@ describe('GlSingleStat', () => {
|
|
|
26
26
|
|
|
27
27
|
const findIemByTestId = (testId) => wrapper.find(`[data-testid="${testId}"]`);
|
|
28
28
|
|
|
29
|
-
afterEach(() => {
|
|
30
|
-
wrapper.destroy();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
29
|
describe('displays the correct default data', () => {
|
|
34
30
|
beforeEach(() => createWrapper());
|
|
35
31
|
|
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
|
2
2
|
import Chart from '../chart/chart.vue';
|
|
3
|
-
import ChartTooltip from '../tooltip/tooltip.vue';
|
|
4
3
|
import SparklineChart from './sparkline.vue';
|
|
5
4
|
import { waitForAnimationFrame } from '~/utils/test_utils';
|
|
5
|
+
import { createMockChartInstance, ChartTooltipStub } from '~helpers/chart_stubs';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const mockChartInstance = {
|
|
9
|
-
subscribedEvents: {},
|
|
10
|
-
getDom: () => {},
|
|
11
|
-
convertToPixel: () => [],
|
|
12
|
-
resize: mockResize,
|
|
13
|
-
};
|
|
7
|
+
let mockChartInstance;
|
|
14
8
|
|
|
15
|
-
// echarts need to be mocked to prevent prop-validation in chart-tooltips to fail
|
|
16
9
|
jest.mock('echarts', () => ({
|
|
17
10
|
getInstanceByDom: () => mockChartInstance,
|
|
18
11
|
}));
|
|
19
12
|
|
|
20
|
-
jest.mock('~/utils/charts/theme', () => ({
|
|
21
|
-
sparkline: {
|
|
22
|
-
variants: { foo: 'foo', bar: 'bar' },
|
|
23
|
-
defaultVariant: 'foo',
|
|
24
|
-
},
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
13
|
let triggerResize = () => {};
|
|
28
14
|
jest.mock('~/directives/resize_observer/resize_observer', () => ({
|
|
29
15
|
GlResizeObserverDirective: {
|
|
@@ -46,19 +32,23 @@ describe('sparkline chart component', () => {
|
|
|
46
32
|
variant: null,
|
|
47
33
|
},
|
|
48
34
|
scopedSlots: { latestSeriesEntry: jest.fn() },
|
|
35
|
+
stubs: {
|
|
36
|
+
'chart-tooltip': ChartTooltipStub,
|
|
37
|
+
},
|
|
49
38
|
};
|
|
50
39
|
|
|
51
40
|
wrapper = shallowMount(SparklineChart, componentOptions);
|
|
52
41
|
};
|
|
53
42
|
|
|
54
43
|
// helpers
|
|
44
|
+
const getByTestId = (id) => wrapper.find(`[data-testid="${id}"]`);
|
|
55
45
|
const getChart = () => wrapper.findComponent(Chart);
|
|
56
46
|
|
|
57
|
-
const getTooltip = () => wrapper.findComponent(
|
|
58
|
-
const getTooltipTitle = () =>
|
|
59
|
-
const getTooltipContent = () =>
|
|
47
|
+
const getTooltip = () => wrapper.findComponent(ChartTooltipStub);
|
|
48
|
+
const getTooltipTitle = () => getByTestId('tooltip-title');
|
|
49
|
+
const getTooltipContent = () => getByTestId('tooltip-content');
|
|
60
50
|
|
|
61
|
-
const getLastYValue = () =>
|
|
51
|
+
const getLastYValue = () => getByTestId('last-y-value');
|
|
62
52
|
|
|
63
53
|
const getChartOptions = () => getChart().props('options');
|
|
64
54
|
const getXAxisLabelFormatter = () => {
|
|
@@ -76,18 +66,18 @@ describe('sparkline chart component', () => {
|
|
|
76
66
|
const emitChartCreated = () => getChart().vm.$emit('created', mockChartInstance);
|
|
77
67
|
|
|
78
68
|
beforeEach(() => {
|
|
69
|
+
mockChartInstance = createMockChartInstance();
|
|
79
70
|
factory();
|
|
80
71
|
// needs to run after every mount, or the chart-instance is `null` and `beforeDestroy` throws
|
|
81
72
|
emitChartCreated();
|
|
82
73
|
});
|
|
83
74
|
|
|
84
75
|
afterEach(() => {
|
|
85
|
-
wrapper.destroy();
|
|
86
76
|
jest.clearAllMocks();
|
|
87
77
|
});
|
|
88
78
|
|
|
89
79
|
it('emits `chartCreated`, which passes on the chart instance', () => {
|
|
90
|
-
expect(wrapper.emitted('chartCreated')
|
|
80
|
+
expect(wrapper.emitted('chartCreated')).toHaveLength(1);
|
|
91
81
|
expect(wrapper.emitted('chartCreated')[0][0]).toBe(mockChartInstance);
|
|
92
82
|
});
|
|
93
83
|
|
|
@@ -153,7 +143,7 @@ describe('sparkline chart component', () => {
|
|
|
153
143
|
expect(getTooltip().attributes('show')).toBeFalsy();
|
|
154
144
|
});
|
|
155
145
|
|
|
156
|
-
it('adds the right content to the tooltip', () => {
|
|
146
|
+
it('adds the right content to the tooltip', async () => {
|
|
157
147
|
const xValue = 'foo';
|
|
158
148
|
const yValue = 'bar';
|
|
159
149
|
const mockData = { seriesData: [{ data: [xValue, yValue] }] };
|
|
@@ -163,10 +153,9 @@ describe('sparkline chart component', () => {
|
|
|
163
153
|
expect(getTooltipTitle().text()).toBe('');
|
|
164
154
|
expect(getTooltipContent().text()).toBe('');
|
|
165
155
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
156
|
+
await waitForAnimationFrame();
|
|
157
|
+
expect(getTooltipTitle().text()).toBe(xValue);
|
|
158
|
+
expect(getTooltipContent().text()).toBe(yValue);
|
|
170
159
|
});
|
|
171
160
|
|
|
172
161
|
it(`shows the last entry's y-value per default`, async () => {
|
|
@@ -182,13 +171,12 @@ describe('sparkline chart component', () => {
|
|
|
182
171
|
expect(getLastYValue().text()).toBe(latestEntryYValue);
|
|
183
172
|
});
|
|
184
173
|
|
|
185
|
-
it(`does not show the last entry's y-value if 'showLastYValue' is false`, () => {
|
|
174
|
+
it(`does not show the last entry's y-value if 'showLastYValue' is false`, async () => {
|
|
186
175
|
expect(getLastYValue().exists()).toBe(true);
|
|
187
176
|
|
|
188
177
|
wrapper.setProps({ showLastYValue: false });
|
|
189
178
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
});
|
|
179
|
+
await wrapper.vm.$nextTick();
|
|
180
|
+
expect(getLastYValue().exists()).toBe(false);
|
|
193
181
|
});
|
|
194
182
|
});
|