@gitlab/ui 32.40.0 → 32.43.1
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/search_box_by_click/search_box_by_click.js +1 -0
- 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/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/regions/empty_state/empty_state.js +1 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/documentation/documented_stories.js +2 -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.spec.js +0 -4
- 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_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/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 +0 -4
- 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/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 +1 -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 -11
- 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 +9 -15
- package/src/components/charts/stacked_column/stacked_column.spec.js +2 -30
- package/src/components/regions/empty_state/empty_state.vue +8 -2
- 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 +26 -0
- package/src/scss/utility-mixins/sizing.scss +6 -0
- package/src/scss/utility-mixins/spacing.scss +4 -0
- package/src/scss/utility-mixins/z-index.scss +4 -0
- 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/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
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
## Usage
|
|
2
|
-
|
|
3
1
|
Using the tooltip component is recommended if you have HTML content.
|
|
4
2
|
It is also currently required if the tooltip content needs to change while it's visible
|
|
5
|
-
(see [this upstream issue]). In all other cases, please use the directive.
|
|
3
|
+
(see [this upstream issue][this upstream issue]). In all other cases, please use the directive.
|
|
6
4
|
|
|
7
5
|
[this upstream issue]: https://github.com/bootstrap-vue/bootstrap-vue/issues/2142
|
|
8
6
|
|
|
@@ -43,11 +41,11 @@ export default {
|
|
|
43
41
|
|
|
44
42
|
## Directive attributes
|
|
45
43
|
|
|
46
|
-
`v-gl-tooltip` directive uses the same attributes as [`v-b-tooltip`].
|
|
44
|
+
`v-gl-tooltip` directive uses the same attributes as [`v-b-tooltip`][`v-b-tooltip`].
|
|
47
45
|
|
|
48
46
|
## Under the hood
|
|
49
47
|
|
|
50
|
-
Tooltip uses [`<b-tooltip>`] and [`v-b-tooltip`] internally.
|
|
48
|
+
Tooltip uses [`<b-tooltip>`][`<b-tooltip>`] and [`v-b-tooltip`][`v-b-tooltip`] internally.
|
|
51
49
|
|
|
52
50
|
[`<b-tooltip>`]: https://bootstrap-vue.org/docs/components/tooltip
|
|
53
51
|
|
|
@@ -19,11 +19,6 @@ describe('GlTooltip', () => {
|
|
|
19
19
|
createWrapper();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
wrapper.destroy();
|
|
24
|
-
wrapper = null;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
22
|
it.each(tooltipActionEvents)('passes through the %s event to the bvTooltip instance', (event) => {
|
|
28
23
|
wrapper.vm.$emit(event);
|
|
29
24
|
|
|
@@ -1,34 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { documentedStoriesOf } from '../../../../documentation/documented_stories';
|
|
3
|
-
import { GlTooltipDirective } from '../../../../index';
|
|
1
|
+
import { GlTooltip, GlTooltipDirective } from '../../../../index';
|
|
4
2
|
import readme from './tooltip.md';
|
|
5
3
|
|
|
6
|
-
const directives = {
|
|
7
|
-
GlTooltip: GlTooltipDirective,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
4
|
function makeTooltip(modifier = '') {
|
|
11
|
-
return
|
|
12
|
-
directives
|
|
5
|
+
return {
|
|
6
|
+
directives: {
|
|
7
|
+
GlTooltip: GlTooltipDirective,
|
|
8
|
+
},
|
|
13
9
|
template: `
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
<div class="gl-display-flex gl-align-items-center gl-justify-content-center gl-p-7 gl-m-7">
|
|
11
|
+
<gl-button
|
|
12
|
+
v-gl-tooltip${modifier}
|
|
13
|
+
title="some tooltip text"
|
|
14
|
+
>
|
|
15
|
+
Tooltip
|
|
16
|
+
</gl-button>
|
|
17
|
+
</div>
|
|
18
|
+
`,
|
|
23
19
|
mounted() {
|
|
24
20
|
this.$nextTick(() => this.$el.querySelector('button').focus());
|
|
25
21
|
},
|
|
26
|
-
}
|
|
22
|
+
};
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
export const TopDefault = (args, argTypes) => ({
|
|
26
|
+
...makeTooltip(),
|
|
27
|
+
props: Object.keys(argTypes),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const Right = (args, argTypes) => ({
|
|
31
|
+
...makeTooltip('.right'),
|
|
32
|
+
props: Object.keys(argTypes),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const Bottom = (args, argTypes) => ({
|
|
36
|
+
...makeTooltip('.bottom'),
|
|
37
|
+
props: Object.keys(argTypes),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const Left = (args, argTypes) => ({
|
|
41
|
+
...makeTooltip('.left'),
|
|
42
|
+
props: Object.keys(argTypes),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// A default export contains higher-level info about the component and the stories' settings.
|
|
46
|
+
export default {
|
|
47
|
+
title: 'base/tooltip',
|
|
48
|
+
component: GlTooltip,
|
|
49
|
+
parameters: {
|
|
50
|
+
bootstrapComponent: 'b-tooltip',
|
|
51
|
+
knobs: { disable: true },
|
|
52
|
+
docs: {
|
|
53
|
+
description: {
|
|
54
|
+
component: readme,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -5,6 +5,7 @@ import ChartLegend from '../legend/legend.vue';
|
|
|
5
5
|
import AreaChart from './area.vue';
|
|
6
6
|
|
|
7
7
|
import { LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE } from '~/utils/charts/constants';
|
|
8
|
+
import { createMockChartInstance, ChartTooltipStub } from '~helpers/chart_stubs';
|
|
8
9
|
|
|
9
10
|
let mockChartInstance;
|
|
10
11
|
|
|
@@ -14,7 +15,6 @@ jest.mock('echarts', () => ({
|
|
|
14
15
|
|
|
15
16
|
describe('area component', () => {
|
|
16
17
|
let wrapper;
|
|
17
|
-
let option;
|
|
18
18
|
|
|
19
19
|
const findChart = () => wrapper.findComponent(Chart);
|
|
20
20
|
const findLegend = () => wrapper.findComponent(ChartLegend);
|
|
@@ -24,33 +24,17 @@ describe('area component', () => {
|
|
|
24
24
|
const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
|
|
25
25
|
|
|
26
26
|
const createShallowWrapper = (props = {}) => {
|
|
27
|
-
wrapper = shallowMount(AreaChart, {
|
|
27
|
+
wrapper = shallowMount(AreaChart, {
|
|
28
|
+
propsData: { option: { series: [] }, data: [], ...props },
|
|
29
|
+
stubs: {
|
|
30
|
+
'chart-tooltip': ChartTooltipStub,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
28
33
|
emitChartCreated();
|
|
29
34
|
};
|
|
30
35
|
|
|
31
36
|
beforeEach(() => {
|
|
32
|
-
|
|
33
|
-
series: [],
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
mockChartInstance = {
|
|
37
|
-
getDom: () => {
|
|
38
|
-
return {
|
|
39
|
-
addEventListener: jest.fn(),
|
|
40
|
-
removeEventListener: jest.fn(),
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
on: jest.fn(),
|
|
44
|
-
off: jest.fn(),
|
|
45
|
-
convertToPixel: jest.fn(),
|
|
46
|
-
getOption: () => {
|
|
47
|
-
return option;
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
afterEach(() => {
|
|
53
|
-
wrapper.destroy();
|
|
37
|
+
mockChartInstance = createMockChartInstance();
|
|
54
38
|
});
|
|
55
39
|
|
|
56
40
|
it('emits `created`, with the chart instance', async () => {
|
|
@@ -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"
|
|
@@ -2,16 +2,9 @@ import { shallowMount } from '@vue/test-utils';
|
|
|
2
2
|
import Chart from '../chart/chart.vue';
|
|
3
3
|
import BarChart from './bar.vue';
|
|
4
4
|
import TooltipDefaultFormat from '~/components/shared_components/charts/tooltip_default_format.vue';
|
|
5
|
+
import { createMockChartInstance } from '~helpers/chart_stubs';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
getDom: () => {
|
|
8
|
-
return {
|
|
9
|
-
addEventListener: jest.fn(),
|
|
10
|
-
removeEventListener: jest.fn(),
|
|
11
|
-
};
|
|
12
|
-
},
|
|
13
|
-
convertToPixel: jest.fn(),
|
|
14
|
-
};
|
|
7
|
+
let mockChartInstance;
|
|
15
8
|
|
|
16
9
|
jest.mock('echarts', () => ({
|
|
17
10
|
getInstanceByDom: () => mockChartInstance,
|
|
@@ -45,8 +38,8 @@ describe('Bar chart component', () => {
|
|
|
45
38
|
});
|
|
46
39
|
};
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
mockChartInstance = createMockChartInstance();
|
|
50
43
|
});
|
|
51
44
|
|
|
52
45
|
describe('when mounted', () => {
|
|
@@ -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
|
|