Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e0156b14
Commit
e0156b14
authored
Aug 24, 2020
by
Miguel Rincon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use bar generated data instead of hardcoded data
Mock bar chart's data with generated data instead of hardcoded data
parent
e8c7d7ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
7 deletions
+27
-7
spec/frontend/monitoring/components/charts/bar_spec.js
spec/frontend/monitoring/components/charts/bar_spec.js
+7
-4
spec/frontend/monitoring/components/dashboard_panel_spec.js
spec/frontend/monitoring/components/dashboard_panel_spec.js
+7
-3
spec/frontend/monitoring/graph_data.js
spec/frontend/monitoring/graph_data.js
+13
-0
No files found.
spec/frontend/monitoring/components/charts/bar_spec.js
View file @
e0156b14
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlBarChart
}
from
'
@gitlab/ui/dist/charts
'
;
import
Bar
from
'
~/monitoring/components/charts/bar.vue
'
;
import
{
bar
MockData
}
from
'
../../mock
_data
'
;
import
{
bar
GraphData
}
from
'
../../graph
_data
'
;
jest
.
mock
(
'
~/lib/utils/icon_utils
'
,
()
=>
({
getSvgIconPathContent
:
jest
.
fn
().
mockResolvedValue
(
'
mockSvgPathContent
'
),
...
...
@@ -10,11 +10,14 @@ jest.mock('~/lib/utils/icon_utils', () => ({
describe
(
'
Bar component
'
,
()
=>
{
let
barChart
;
let
store
;
let
graphData
;
beforeEach
(()
=>
{
graphData
=
barGraphData
();
barChart
=
shallowMount
(
Bar
,
{
propsData
:
{
graphData
:
barMockData
,
graphData
,
},
store
,
});
...
...
@@ -31,7 +34,7 @@ describe('Bar component', () => {
beforeEach
(()
=>
{
glbarChart
=
barChart
.
find
(
GlBarChart
);
chartData
=
barChart
.
vm
.
chartData
[
barMock
Data
.
metrics
[
0
].
label
];
chartData
=
barChart
.
vm
.
chartData
[
graph
Data
.
metrics
[
0
].
label
];
});
it
(
'
is a Vue instance
'
,
()
=>
{
...
...
@@ -39,7 +42,7 @@ describe('Bar component', () => {
});
it
(
'
should display a label on the x axis
'
,
()
=>
{
expect
(
glbarChart
.
vm
.
xAxisTitle
).
toBe
(
barMock
Data
.
xLabel
);
expect
(
glbarChart
.
props
(
'
xAxisTitle
'
)).
toBe
(
graph
Data
.
xLabel
);
});
it
(
'
should return chartData as array of arrays
'
,
()
=>
{
...
...
spec/frontend/monitoring/components/dashboard_panel_spec.js
View file @
e0156b14
...
...
@@ -15,10 +15,14 @@ import {
mockNamespace
,
mockNamespacedData
,
mockTimeRange
,
barMockData
,
}
from
'
../mock_data
'
;
import
{
dashboardProps
,
graphData
,
graphDataEmpty
}
from
'
../fixture_data
'
;
import
{
anomalyGraphData
,
singleStatGraphData
,
heatmapGraphData
}
from
'
../graph_data
'
;
import
{
anomalyGraphData
,
singleStatGraphData
,
heatmapGraphData
,
barGraphData
,
}
from
'
../graph_data
'
;
import
{
panelTypes
}
from
'
~/monitoring/constants
'
;
...
...
@@ -240,7 +244,7 @@ describe('Dashboard Panel', () => {
${
dataWithType
(
panelTypes
.
COLUMN
)}
|
${
MonitorColumnChart
}
|
${
false
}
${
dataWithType
(
panelTypes
.
STACKED_COLUMN
)}
|
${
MonitorStackedColumnChart
}
|
${
false
}
${
heatmapGraphData
()}
|
${
MonitorHeatmapChart
}
|
${
false
}
${
bar
MockData
}
|
${
MonitorBarChart
}
|
${
false
}
${
bar
GraphData
()}
|
${
MonitorBarChart
}
|
${
false
}
`
(
'
when $data.type data is provided
'
,
({
data
,
component
,
hasCtxMenu
})
=>
{
const
attrs
=
{
attr1
:
'
attr1Value
'
,
attr2
:
'
attr2Value
'
};
...
...
spec/frontend/monitoring/graph_data.js
View file @
e0156b14
...
...
@@ -259,3 +259,16 @@ export const stackedColumnGraphData = (panelOptions = {}, dataOptions = {}) => {
type
:
panelTypes
.
STACKED_COLUMN
,
};
};
/**
* Generates bar mock graph data according to options
*
* @param {Object} panelOptions - Panel options as in YML.
* @param {Object} dataOptions
*/
export
const
barGraphData
=
(
panelOptions
=
{},
dataOptions
=
{})
=>
{
return
{
...
timeSeriesGraphData
(
panelOptions
,
dataOptions
),
type
:
panelTypes
.
BAR
,
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment