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
a5d03379
Commit
a5d03379
authored
Mar 30, 2020
by
Andrei Stoicescu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for chart color matching
parent
d0cb43e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
12 deletions
+40
-12
spec/frontend/monitoring/components/charts/time_series_spec.js
...frontend/monitoring/components/charts/time_series_spec.js
+40
-12
No files found.
spec/frontend/monitoring/components/charts/time_series_spec.js
View file @
a5d03379
import
{
shallowM
ount
}
from
'
@vue/test-utils
'
;
import
{
m
ount
}
from
'
@vue/test-utils
'
;
import
{
setTestTimeout
}
from
'
helpers/timeout
'
;
import
{
GlLink
}
from
'
@gitlab/ui
'
;
import
{
GlAreaChart
,
GlLineChart
,
GlChartSeriesLabel
}
from
'
@gitlab/ui/dist/charts
'
;
import
{
GlAreaChart
,
GlLineChart
,
GlChartSeriesLabel
,
GlChartLegend
,
}
from
'
@gitlab/ui/dist/charts
'
;
import
{
cloneDeep
}
from
'
lodash
'
;
import
{
shallowWrapperContainsSlotText
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
createStore
}
from
'
~/monitoring/stores
'
;
...
...
@@ -41,13 +46,16 @@ describe('Time series component', () => {
let
store
;
const
makeTimeSeriesChart
=
(
graphData
,
type
)
=>
shallowM
ount
(
TimeSeries
,
{
m
ount
(
TimeSeries
,
{
propsData
:
{
graphData
:
{
...
graphData
,
type
},
deploymentData
:
store
.
state
.
monitoringDashboard
.
deploymentData
,
projectPath
:
`
${
mockHost
}${
mockProjectDir
}
`
,
},
store
,
stubs
:
{
GlPopover
:
true
,
},
});
describe
(
'
With a single time series
'
,
()
=>
{
...
...
@@ -552,19 +560,39 @@ describe('Time series component', () => {
timeSeriesChart
.
destroy
();
});
describe
(
'
computed
'
,
()
=>
{
let
chartData
;
describe
(
'
Color match
'
,
()
=>
{
let
lineColors
;
beforeEach
(()
=>
{
({
chartData
}
=
timeSeriesChart
.
vm
);
lineColors
=
timeSeriesChart
.
find
(
GlAreaChart
)
.
vm
.
series
.
map
(
item
=>
item
.
lineStyle
.
color
);
});
it
(
'
should contain different colors for contiguous time series
'
,
()
=>
{
lineColors
.
forEach
((
color
,
index
)
=>
{
expect
(
color
).
not
.
toBe
(
lineColors
[
index
+
1
]);
});
});
it
(
'
should contain different colors for each time series
'
,
()
=>
{
expect
(
chartData
[
0
].
lineStyle
.
color
).
toBe
(
'
#1f78d1
'
);
expect
(
chartData
[
1
].
lineStyle
.
color
).
toBe
(
'
#1aaa55
'
);
expect
(
chartData
[
2
].
lineStyle
.
color
).
toBe
(
'
#fc9403
'
);
expect
(
chartData
[
3
].
lineStyle
.
color
).
toBe
(
'
#6d49cb
'
);
expect
(
chartData
[
4
].
lineStyle
.
color
).
toBe
(
'
#1f78d1
'
);
it
(
'
should match series color with tooltip label color
'
,
()
=>
{
const
labels
=
timeSeriesChart
.
findAll
(
GlChartSeriesLabel
);
lineColors
.
forEach
((
color
,
index
)
=>
{
const
labelColor
=
labels
.
at
(
index
).
props
(
'
color
'
);
expect
(
color
).
toBe
(
labelColor
);
});
});
it
(
'
should match series color with legend color
'
,
()
=>
{
const
legendColors
=
timeSeriesChart
.
find
(
GlChartLegend
)
.
props
(
'
seriesInfo
'
)
.
map
(
item
=>
item
.
color
);
lineColors
.
forEach
((
color
,
index
)
=>
{
expect
(
color
).
toBe
(
legendColors
[
index
]);
});
});
});
});
...
...
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