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
866a0673
Commit
866a0673
authored
May 19, 2020
by
Himanshu Kapoor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate prometheus_metrics specs to Jest
Migrate spec/javascripts/prometheus_metrics specs from Karma to Jest.
parent
dfaf03f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
50 deletions
+49
-50
spec/frontend/prometheus_metrics/custom_metrics_spec.js
spec/frontend/prometheus_metrics/custom_metrics_spec.js
+1
-1
spec/frontend/prometheus_metrics/mock_data.js
spec/frontend/prometheus_metrics/mock_data.js
+42
-2
spec/frontend/prometheus_metrics/prometheus_metrics_spec.js
spec/frontend/prometheus_metrics/prometheus_metrics_spec.js
+6
-6
spec/javascripts/prometheus_metrics/mock_data.js
spec/javascripts/prometheus_metrics/mock_data.js
+0
-41
No files found.
spec/frontend/prometheus_metrics/custom_metrics_spec.js
View file @
866a0673
...
...
@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter';
import
CustomMetrics
from
'
~/prometheus_metrics/custom_metrics
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
PANEL_STATE
from
'
~/prometheus_metrics/constants
'
;
import
metrics
from
'
./mock_data
'
;
import
{
metrics1
as
metrics
}
from
'
./mock_data
'
;
describe
(
'
PrometheusMetrics
'
,
()
=>
{
const
FIXTURE
=
'
services/prometheus/prometheus_service.html
'
;
...
...
spec/frontend/prometheus_metrics/mock_data.js
View file @
866a0673
const
metrics
=
[
export
const
metrics1
=
[
{
edit_path
:
'
/root/prometheus-test/prometheus/metrics/3/edit
'
,
id
:
3
,
...
...
@@ -19,4 +19,44 @@ const metrics = [
},
];
export
default
metrics
;
export
const
metrics2
=
[
{
group
:
'
Kubernetes
'
,
priority
:
1
,
active_metrics
:
4
,
metrics_missing_requirements
:
0
,
},
{
group
:
'
HAProxy
'
,
priority
:
2
,
active_metrics
:
3
,
metrics_missing_requirements
:
0
,
},
{
group
:
'
Apache
'
,
priority
:
3
,
active_metrics
:
5
,
metrics_missing_requirements
:
0
,
},
];
export
const
missingVarMetrics
=
[
{
group
:
'
Kubernetes
'
,
priority
:
1
,
active_metrics
:
4
,
metrics_missing_requirements
:
0
,
},
{
group
:
'
HAProxy
'
,
priority
:
2
,
active_metrics
:
3
,
metrics_missing_requirements
:
1
,
},
{
group
:
'
Apache
'
,
priority
:
3
,
active_metrics
:
5
,
metrics_missing_requirements
:
3
,
},
];
spec/
javascripts
/prometheus_metrics/prometheus_metrics_spec.js
→
spec/
frontend
/prometheus_metrics/prometheus_metrics_spec.js
View file @
866a0673
...
...
@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter';
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
PrometheusMetrics
from
'
~/prometheus_metrics/prometheus_metrics
'
;
import
PANEL_STATE
from
'
~/prometheus_metrics/constants
'
;
import
{
metrics
,
missingVarMetrics
}
from
'
./mock_data
'
;
import
{
metrics
2
as
metrics
,
missingVarMetrics
}
from
'
./mock_data
'
;
describe
(
'
PrometheusMetrics
'
,
()
=>
{
const
FIXTURE
=
'
services/prometheus/prometheus_service.html
'
;
...
...
@@ -126,7 +126,7 @@ describe('PrometheusMetrics', () => {
}
beforeEach
(()
=>
{
spyOn
(
axios
,
'
get
'
).
and
.
callThrough
(
);
jest
.
spyOn
(
axios
,
'
get
'
);
prometheusMetrics
=
new
PrometheusMetrics
(
'
.js-prometheus-metrics-monitoring
'
);
...
...
@@ -145,7 +145,7 @@ describe('PrometheusMetrics', () => {
expect
(
prometheusMetrics
.
$monitoredMetricsLoading
.
hasClass
(
'
hidden
'
)).
toBeFalsy
();
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
prometheusMetrics
.
activeMetricsEndpoint
);
set
Timeout
(()
=>
{
set
Immediate
(()
=>
{
expect
(
prometheusMetrics
.
$monitoredMetricsLoading
.
hasClass
(
'
hidden
'
)).
toBeTruthy
();
done
();
});
...
...
@@ -156,7 +156,7 @@ describe('PrometheusMetrics', () => {
prometheusMetrics
.
loadActiveMetrics
();
set
Timeout
(()
=>
{
set
Immediate
(()
=>
{
expect
(
prometheusMetrics
.
$monitoredMetricsLoading
.
hasClass
(
'
hidden
'
)).
toBeTruthy
();
expect
(
prometheusMetrics
.
$monitoredMetricsEmpty
.
hasClass
(
'
hidden
'
)).
toBeFalsy
();
done
();
...
...
@@ -164,12 +164,12 @@ describe('PrometheusMetrics', () => {
});
it
(
'
should populate metrics list once response is loaded
'
,
done
=>
{
spyOn
(
prometheusMetrics
,
'
populateActiveMetrics
'
);
jest
.
spyOn
(
prometheusMetrics
,
'
populateActiveMetrics
'
).
mockImplementation
(
);
mockSuccess
();
prometheusMetrics
.
loadActiveMetrics
();
set
Timeout
(()
=>
{
set
Immediate
(()
=>
{
expect
(
prometheusMetrics
.
populateActiveMetrics
).
toHaveBeenCalledWith
(
metrics
);
done
();
});
...
...
spec/javascripts/prometheus_metrics/mock_data.js
deleted
100644 → 0
View file @
dfaf03f3
export
const
metrics
=
[
{
group
:
'
Kubernetes
'
,
priority
:
1
,
active_metrics
:
4
,
metrics_missing_requirements
:
0
,
},
{
group
:
'
HAProxy
'
,
priority
:
2
,
active_metrics
:
3
,
metrics_missing_requirements
:
0
,
},
{
group
:
'
Apache
'
,
priority
:
3
,
active_metrics
:
5
,
metrics_missing_requirements
:
0
,
},
];
export
const
missingVarMetrics
=
[
{
group
:
'
Kubernetes
'
,
priority
:
1
,
active_metrics
:
4
,
metrics_missing_requirements
:
0
,
},
{
group
:
'
HAProxy
'
,
priority
:
2
,
active_metrics
:
3
,
metrics_missing_requirements
:
1
,
},
{
group
:
'
Apache
'
,
priority
:
3
,
active_metrics
:
5
,
metrics_missing_requirements
:
3
,
},
];
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