forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
173 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import expect from 'expect.js'; | ||
import ngMock from 'ng_mock'; | ||
import AggTypesIndexProvider from 'ui/agg_types/index'; | ||
|
||
describe('Terms Agg', function () { | ||
describe('order agg editor UI', function () { | ||
|
||
let $rootScope; | ||
|
||
function init({ responseValueAggs = [] }) { | ||
ngMock.module('kibana'); | ||
ngMock.inject(function (Private, $controller, _$rootScope_) { | ||
const terms = Private(AggTypesIndexProvider).byName.terms; | ||
const orderAggController = terms.params.byName.orderAgg.controller; | ||
|
||
$rootScope = _$rootScope_; | ||
$rootScope.agg = { | ||
id: 'test', | ||
params: {}, | ||
type: terms, | ||
vis: { | ||
aggs: [] | ||
} | ||
}; | ||
$rootScope.responseValueAggs = responseValueAggs; | ||
$controller(orderAggController, { $scope: $rootScope }); | ||
$rootScope.$digest(); | ||
}); | ||
} | ||
|
||
it('defaults to the first metric agg', function () { | ||
init({ | ||
responseValueAggs: [ | ||
{ | ||
id: 'agg1', | ||
type: { | ||
name: 'count' | ||
} | ||
}, | ||
{ | ||
id: 'agg2', | ||
type: { | ||
name: 'count' | ||
} | ||
} | ||
] | ||
}); | ||
expect($rootScope.agg.params.orderBy).to.be('agg1'); | ||
}); | ||
|
||
it('defaults to the first metric agg that is compatible with the terms bucket', function () { | ||
init({ | ||
responseValueAggs: [ | ||
{ | ||
id: 'agg1', | ||
type: { | ||
name: 'top_hits' | ||
} | ||
}, | ||
{ | ||
id: 'agg2', | ||
type: { | ||
name: 'percentiles' | ||
} | ||
}, | ||
{ | ||
id: 'agg3', | ||
type: { | ||
name: 'median' | ||
} | ||
}, | ||
{ | ||
id: 'agg4', | ||
type: { | ||
name: 'std_dev' | ||
} | ||
}, | ||
{ | ||
id: 'agg5', | ||
type: { | ||
name: 'count' | ||
} | ||
} | ||
] | ||
}); | ||
expect($rootScope.agg.params.orderBy).to.be('agg5'); | ||
}); | ||
|
||
it('defaults to the custom metric if no agg is compatible', function () { | ||
init({ | ||
responseValueAggs: [ | ||
{ | ||
id: 'agg1', | ||
type: { | ||
name: 'top_hits' | ||
} | ||
} | ||
] | ||
}); | ||
expect($rootScope.agg.params.orderBy).to.be('custom'); | ||
}); | ||
|
||
it('selects "custom metric" if there are no metric aggs', function () { | ||
init({}); | ||
expect($rootScope.agg.params.orderBy).to.be('custom'); | ||
}); | ||
|
||
it('is emptied if the selected metric becomes incompatible', function () { | ||
init({ | ||
responseValueAggs: [ | ||
{ | ||
id: 'agg1', | ||
type: { | ||
name: 'count' | ||
} | ||
} | ||
] | ||
}); | ||
expect($rootScope.agg.params.orderBy).to.be('agg1'); | ||
$rootScope.responseValueAggs = [ | ||
{ | ||
id: 'agg1', | ||
type: { | ||
name: 'top_hits' | ||
} | ||
} | ||
]; | ||
$rootScope.$digest(); | ||
expect($rootScope.agg.params.orderBy).to.be(null); | ||
}); | ||
|
||
it('is emptied if the selected metric is removed', function () { | ||
init({ | ||
responseValueAggs: [ | ||
{ | ||
id: 'agg1', | ||
type: { | ||
name: 'count' | ||
} | ||
} | ||
] | ||
}); | ||
expect($rootScope.agg.params.orderBy).to.be('agg1'); | ||
$rootScope.responseValueAggs = []; | ||
$rootScope.$digest(); | ||
expect($rootScope.agg.params.orderBy).to.be(null); | ||
}); | ||
|
||
it('adds "custom metric" option'); | ||
it('lists all metric agg responses'); | ||
it('lists individual values of a multi-value metric'); | ||
it('displays a metric editor if "custom metric" is selected'); | ||
it('saves the "custom metric" to state and refreshes from it'); | ||
it('invalidates the form if the metric agg form is not complete'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters