Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
81c32780
Commit
81c32780
authored
Jul 24, 2018
by
Tobias Skarhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass more tests
parent
bb0af52d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
51 deletions
+60
-51
public/app/plugins/datasource/influxdb/query_ctrl.ts
+0
-1
public/app/plugins/datasource/influxdb/specs/query_ctrl.jest.ts
+60
-50
No files found.
public/app/plugins/datasource/influxdb/query_ctrl.ts
View file @
81c32780
...
@@ -22,7 +22,6 @@ export class InfluxQueryCtrl extends QueryCtrl {
...
@@ -22,7 +22,6 @@ export class InfluxQueryCtrl extends QueryCtrl {
/** @ngInject **/
/** @ngInject **/
constructor
(
$scope
,
$injector
,
private
templateSrv
,
private
$q
,
private
uiSegmentSrv
)
{
constructor
(
$scope
,
$injector
,
private
templateSrv
,
private
$q
,
private
uiSegmentSrv
)
{
super
(
$scope
,
$injector
);
super
(
$scope
,
$injector
);
this
.
target
=
this
.
target
;
this
.
target
=
this
.
target
;
this
.
queryModel
=
new
InfluxQuery
(
this
.
target
,
templateSrv
,
this
.
panel
.
scopedVars
);
this
.
queryModel
=
new
InfluxQuery
(
this
.
target
,
templateSrv
,
this
.
panel
.
scopedVars
);
this
.
queryBuilder
=
new
InfluxQueryBuilder
(
this
.
target
,
this
.
datasource
.
database
);
this
.
queryBuilder
=
new
InfluxQueryBuilder
(
this
.
target
,
this
.
datasource
.
database
);
...
...
public/app/plugins/datasource/influxdb/specs/query_ctrl.jest.ts
View file @
81c32780
...
@@ -4,29 +4,28 @@ import 'app/core/services/segment_srv';
...
@@ -4,29 +4,28 @@ import 'app/core/services/segment_srv';
// import helpers from 'test/specs/helpers';
// import helpers from 'test/specs/helpers';
import
{
InfluxQueryCtrl
}
from
'../query_ctrl'
;
import
{
InfluxQueryCtrl
}
from
'../query_ctrl'
;
describe
(
'InfluxDBQueryCtrl'
,
function
()
{
describe
(
'InfluxDBQueryCtrl'
,
()
=>
{
let
uiSegmentSrv
=
{
let
uiSegmentSrv
=
{
newPlusButton
:
()
=>
{},
newPlusButton
:
()
=>
{},
};
newKey
:
key
=>
key
,
newKeyValue
:
key
=>
key
,
let
ctx
=
<
any
>
{
newSegment
:
seg
=>
seg
,
dataSource
:
{
newSelectMeasurement
:
()
=>
{
metricFindQuery
:
jest
.
fn
(()
=>
Promise
.
resolve
([])),
return
{
value
:
'select measurement'
};
},
},
newOperator
:
op
=>
op
,
newFake
:
()
=>
{},
};
};
InfluxQueryCtrl
.
prototype
.
panelCtrl
=
{
let
ctx
=
<
any
>
{
target
:
{
target
:
{}
},
dataSource
:
{},
panel
:
{
targets
:
[
this
.
target
],
},
};
};
// beforeEach(angularMocks.module('grafana.core'));
// beforeEach(angularMocks.module('grafana.core'));
// beforeEach(angularMocks.module('grafana.controllers'));
// beforeEach(angularMocks.module('grafana.controllers'));
// beforeEach(angularMocks.module('grafana.services'));
// beforeEach(angularMocks.module('grafana.services'));
// beforeEach(
// beforeEach(
// angularMocks.module(
function($
compileProvider) {
// angularMocks.module(
($ =>
compileProvider) {
// $compileProvider.preAssignBindingsEnabled(true);
// $compileProvider.preAssignBindingsEnabled(true);
// })
// })
// );
// );
...
@@ -56,147 +55,158 @@ describe('InfluxDBQueryCtrl', function() {
...
@@ -56,147 +55,158 @@ describe('InfluxDBQueryCtrl', function() {
// })
// })
// );
// );
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
ctx
.
ctrl
=
new
InfluxQueryCtrl
({},
{},
{},
{},
uiSegmentSrv
);
InfluxQueryCtrl
.
prototype
.
datasource
=
{
metricFindQuery
:
jest
.
fn
(()
=>
Promise
.
resolve
([])),
};
InfluxQueryCtrl
.
prototype
.
panelCtrl
=
{
panel
:
{
targets
:
[
InfluxQueryCtrl
.
target
],
},
};
InfluxQueryCtrl
.
prototype
.
target
=
{
target
:
{}
};
console
.
log
(
'creating new instance'
);
ctx
.
ctrl
=
await
new
InfluxQueryCtrl
({},
{},
{},
{},
uiSegmentSrv
);
});
});
describe
(
'init'
,
function
()
{
describe
(
'init'
,
()
=>
{
it
(
'should init tagSegments'
,
function
()
{
it
(
'should init tagSegments'
,
()
=>
{
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
1
);
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
1
);
});
});
it
(
'should init measurementSegment'
,
function
()
{
it
(
'should init measurementSegment'
,
()
=>
{
expect
(
ctx
.
ctrl
.
measurementSegment
.
value
).
toBe
(
'select measurement'
);
expect
(
ctx
.
ctrl
.
measurementSegment
.
value
).
toBe
(
'select measurement'
);
});
});
});
});
describe
(
'when first tag segment is updated'
,
function
()
{
describe
(
'when first tag segment is updated'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
});
});
it
(
'should update tag key'
,
function
()
{
it
(
'should update tag key'
,
()
=>
{
expect
(
ctx
.
ctrl
.
target
.
tags
[
0
].
key
).
toBe
(
'asd'
);
expect
(
ctx
.
ctrl
.
target
.
tags
[
0
].
key
).
toBe
(
'asd'
);
expect
(
ctx
.
ctrl
.
tagSegments
[
0
].
type
).
toBe
(
'key'
);
expect
(
ctx
.
ctrl
.
tagSegments
[
0
].
type
).
toBe
(
'key'
);
});
});
it
(
'should add tagSegments'
,
function
()
{
it
(
'should add tagSegments'
,
()
=>
{
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
3
);
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
3
);
});
});
});
});
describe
(
'when last tag value segment is updated'
,
function
()
{
describe
(
'when last tag value segment is updated'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
});
});
it
(
'should update tag value'
,
function
()
{
it
(
'should update tag value'
,
()
=>
{
expect
(
ctx
.
ctrl
.
target
.
tags
[
0
].
value
).
toBe
(
'server1'
);
expect
(
ctx
.
ctrl
.
target
.
tags
[
0
].
value
).
toBe
(
'server1'
);
});
});
it
(
'should set tag operator'
,
function
()
{
it
(
'should set tag operator'
,
()
=>
{
expect
(
ctx
.
ctrl
.
target
.
tags
[
0
].
operator
).
toBe
(
'='
);
expect
(
ctx
.
ctrl
.
target
.
tags
[
0
].
operator
).
toBe
(
'='
);
});
});
it
(
'should add plus button for another filter'
,
function
()
{
it
(
'should add plus button for another filter'
,
()
=>
{
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
fake
).
toBe
(
true
);
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
fake
).
toBe
(
true
);
});
});
});
});
describe
(
'when last tag value segment is updated to regex'
,
function
()
{
describe
(
'when last tag value segment is updated to regex'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'/server.*/'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'/server.*/'
,
type
:
'value'
},
2
);
});
});
it
(
'should update operator'
,
function
()
{
it
(
'should update operator'
,
()
=>
{
expect
(
ctx
.
ctrl
.
tagSegments
[
1
].
value
).
toBe
(
'=~'
);
expect
(
ctx
.
ctrl
.
tagSegments
[
1
].
value
).
toBe
(
'=~'
);
expect
(
ctx
.
ctrl
.
target
.
tags
[
0
].
operator
).
toBe
(
'=~'
);
expect
(
ctx
.
ctrl
.
target
.
tags
[
0
].
operator
).
toBe
(
'=~'
);
});
});
});
});
describe
(
'when second tag key is added'
,
function
()
{
describe
(
'when second tag key is added'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'key2'
,
type
:
'plus-button'
},
3
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'key2'
,
type
:
'plus-button'
},
3
);
});
});
it
(
'should update tag key'
,
function
()
{
it
(
'should update tag key'
,
()
=>
{
expect
(
ctx
.
ctrl
.
target
.
tags
[
1
].
key
).
toBe
(
'key2'
);
expect
(
ctx
.
ctrl
.
target
.
tags
[
1
].
key
).
toBe
(
'key2'
);
});
});
it
(
'should add AND segment'
,
function
()
{
it
(
'should add AND segment'
,
()
=>
{
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
value
).
toBe
(
'AND'
);
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
value
).
toBe
(
'AND'
);
});
});
});
});
describe
(
'when condition is changed'
,
function
()
{
describe
(
'when condition is changed'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'key2'
,
type
:
'plus-button'
},
3
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'key2'
,
type
:
'plus-button'
},
3
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'OR'
,
type
:
'condition'
},
3
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'OR'
,
type
:
'condition'
},
3
);
});
});
it
(
'should update tag condition'
,
function
()
{
it
(
'should update tag condition'
,
()
=>
{
expect
(
ctx
.
ctrl
.
target
.
tags
[
1
].
condition
).
toBe
(
'OR'
);
expect
(
ctx
.
ctrl
.
target
.
tags
[
1
].
condition
).
toBe
(
'OR'
);
});
});
it
(
'should update AND segment'
,
function
()
{
it
(
'should update AND segment'
,
()
=>
{
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
value
).
toBe
(
'OR'
);
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
value
).
toBe
(
'OR'
);
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
7
);
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
7
);
});
});
});
});
describe
(
'when deleting first tag filter after value is selected'
,
function
()
{
describe
(
'when deleting first tag filter after value is selected'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
(
ctx
.
ctrl
.
removeTagFilterSegment
,
0
);
ctx
.
ctrl
.
tagSegmentUpdated
(
ctx
.
ctrl
.
removeTagFilterSegment
,
0
);
});
});
it
(
'should remove tags'
,
function
()
{
it
(
'should remove tags'
,
()
=>
{
expect
(
ctx
.
ctrl
.
target
.
tags
.
length
).
toBe
(
0
);
expect
(
ctx
.
ctrl
.
target
.
tags
.
length
).
toBe
(
0
);
});
});
it
(
'should remove all segment after 2 and replace with plus button'
,
function
()
{
it
(
'should remove all segment after 2 and replace with plus button'
,
()
=>
{
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
1
);
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
1
);
expect
(
ctx
.
ctrl
.
tagSegments
[
0
].
type
).
toBe
(
'plus-button'
);
expect
(
ctx
.
ctrl
.
tagSegments
[
0
].
type
).
toBe
(
'plus-button'
);
});
});
});
});
describe
(
'when deleting second tag value before second tag value is complete'
,
function
()
{
describe
(
'when deleting second tag value before second tag value is complete'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'key2'
,
type
:
'plus-button'
},
3
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'key2'
,
type
:
'plus-button'
},
3
);
ctx
.
ctrl
.
tagSegmentUpdated
(
ctx
.
ctrl
.
removeTagFilterSegment
,
4
);
ctx
.
ctrl
.
tagSegmentUpdated
(
ctx
.
ctrl
.
removeTagFilterSegment
,
4
);
});
});
it
(
'should remove all segment after 2 and replace with plus button'
,
function
()
{
it
(
'should remove all segment after 2 and replace with plus button'
,
()
=>
{
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
4
);
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
4
);
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
type
).
toBe
(
'plus-button'
);
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
type
).
toBe
(
'plus-button'
);
});
});
});
});
describe
(
'when deleting second tag value before second tag value is complete'
,
function
()
{
describe
(
'when deleting second tag value before second tag value is complete'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'key2'
,
type
:
'plus-button'
},
3
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'key2'
,
type
:
'plus-button'
},
3
);
ctx
.
ctrl
.
tagSegmentUpdated
(
ctx
.
ctrl
.
removeTagFilterSegment
,
4
);
ctx
.
ctrl
.
tagSegmentUpdated
(
ctx
.
ctrl
.
removeTagFilterSegment
,
4
);
});
});
it
(
'should remove all segment after 2 and replace with plus button'
,
function
()
{
it
(
'should remove all segment after 2 and replace with plus button'
,
()
=>
{
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
4
);
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
4
);
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
type
).
toBe
(
'plus-button'
);
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
type
).
toBe
(
'plus-button'
);
});
});
});
});
describe
(
'when deleting second tag value after second tag filter is complete'
,
function
()
{
describe
(
'when deleting second tag value after second tag filter is complete'
,
()
=>
{
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'asd'
,
type
:
'plus-button'
},
0
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'server1'
,
type
:
'value'
},
2
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'key2'
,
type
:
'plus-button'
},
3
);
ctx
.
ctrl
.
tagSegmentUpdated
({
value
:
'key2'
,
type
:
'plus-button'
},
3
);
...
@@ -204,7 +214,7 @@ describe('InfluxDBQueryCtrl', function() {
...
@@ -204,7 +214,7 @@ describe('InfluxDBQueryCtrl', function() {
ctx
.
ctrl
.
tagSegmentUpdated
(
ctx
.
ctrl
.
removeTagFilterSegment
,
4
);
ctx
.
ctrl
.
tagSegmentUpdated
(
ctx
.
ctrl
.
removeTagFilterSegment
,
4
);
});
});
it
(
'should remove all segment after 2 and replace with plus button'
,
function
()
{
it
(
'should remove all segment after 2 and replace with plus button'
,
()
=>
{
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
4
);
expect
(
ctx
.
ctrl
.
tagSegments
.
length
).
toBe
(
4
);
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
type
).
toBe
(
'plus-button'
);
expect
(
ctx
.
ctrl
.
tagSegments
[
3
].
type
).
toBe
(
'plus-button'
);
});
});
...
...
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