mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
remove all the old, no longer used filter_bar tests
This commit is contained in:
parent
a2913d680c
commit
3e821580c3
5 changed files with 0 additions and 471 deletions
|
@ -1,81 +0,0 @@
|
|||
define(function (require) {
|
||||
return ['add', function () {
|
||||
var _ = require('lodash');
|
||||
var sinon = require('test_utils/auto_release_sinon');
|
||||
var filterActions, $rootScope, Promise, mapFilter, indexPattern, getIndexPatternStub;
|
||||
|
||||
beforeEach(module('kibana'));
|
||||
|
||||
beforeEach(function () {
|
||||
getIndexPatternStub = sinon.stub();
|
||||
module('kibana/courier', function ($provide) {
|
||||
$provide.service('courier', function () {
|
||||
var courier = { indexPatterns: { get: getIndexPatternStub } };
|
||||
return courier;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
inject(function (_$rootScope_, _Promise_, Private) {
|
||||
Promise = _Promise_;
|
||||
$rootScope = _$rootScope_;
|
||||
|
||||
mapFilter = Private(require('components/filter_bar/lib/mapFilter'));
|
||||
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
|
||||
filterActions = Private(require('components/filter_bar/lib/filterActions'));
|
||||
|
||||
getIndexPatternStub.returns(Promise.resolve(indexPattern));
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
var filters = [
|
||||
{ meta: { index: 'logstash-*' }, query: { match: { '@tags': { query: 'foo' } } } },
|
||||
{ meta: { index: 'logstash-*' }, query: { match: { '@tags': { query: 'bar' } } } },
|
||||
{ meta: { index: 'logstash-*' }, exists: { field: '@timestamp' } },
|
||||
{ meta: { index: 'logstash-*', disabled: true }, missing: { field: 'host' } },
|
||||
];
|
||||
|
||||
Promise.map(filters, mapFilter)
|
||||
.then(function (filters) {
|
||||
$rootScope = { filters: filters };
|
||||
});
|
||||
$rootScope.$digest();
|
||||
});
|
||||
|
||||
describe('addFilters', function () {
|
||||
var fn;
|
||||
var newFilters;
|
||||
|
||||
beforeEach(function () {
|
||||
fn = filterActions($rootScope).addFilters;
|
||||
newFilters = [
|
||||
{ meta: { index: 'logstash-*', apply: true }, query: { match: { 'extension': { query: 'baz' } } } },
|
||||
{ meta: { index: 'logstash-*', apply: false }, query: { match: { 'extension': { query: 'buz' } } } },
|
||||
{ meta: { index: 'logstash-*', disabled: true, apply: true }, missing: { field: 'geo.src' } },
|
||||
];
|
||||
});
|
||||
|
||||
it('should add filter object', function () {
|
||||
expect($rootScope.filters.length).to.be(4);
|
||||
var filter = newFilters[0];
|
||||
fn(filter);
|
||||
expect($rootScope.filters.length).to.be(5);
|
||||
expect($rootScope.filters[4]).to.eql(newFilters[0]);
|
||||
});
|
||||
|
||||
it('should ignore the apply param', function () {
|
||||
expect($rootScope.filters.length).to.be(4);
|
||||
newFilters.forEach(function (filter) {
|
||||
fn(filter);
|
||||
});
|
||||
expect($rootScope.filters.length).to.be(7);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}];
|
||||
});
|
||||
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
define(function (require) {
|
||||
return ['invert', function () {
|
||||
var _ = require('lodash');
|
||||
var sinon = require('test_utils/auto_release_sinon');
|
||||
var filterActions, $rootScope, Promise, mapFilter, indexPattern, getIndexPatternStub;
|
||||
|
||||
beforeEach(module('kibana'));
|
||||
|
||||
beforeEach(function () {
|
||||
getIndexPatternStub = sinon.stub();
|
||||
module('kibana/courier', function ($provide) {
|
||||
$provide.service('courier', function () {
|
||||
var courier = { indexPatterns: { get: getIndexPatternStub } };
|
||||
return courier;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
inject(function (_$rootScope_, _Promise_, Private) {
|
||||
Promise = _Promise_;
|
||||
$rootScope = _$rootScope_;
|
||||
|
||||
mapFilter = Private(require('components/filter_bar/lib/mapFilter'));
|
||||
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
|
||||
filterActions = Private(require('components/filter_bar/lib/filterActions'));
|
||||
|
||||
getIndexPatternStub.returns(Promise.resolve(indexPattern));
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
var filters = [
|
||||
{ meta: { index: 'logstash-*' }, query: { match: { 'extension': { query: 'jpg' } } } },
|
||||
{ meta: { index: 'logstash-*', negate: true }, query: { match: { 'extension': { query: 'png' } } } },
|
||||
{ meta: { index: 'logstash-*' }, query: { match: { '_type': { query: 'apache' } } } },
|
||||
{ meta: { index: 'logstash-*' }, query: { match: { '_type': { query: 'nginx' } } } },
|
||||
{ meta: { index: 'logstash-*' }, exists: { field: '@timestamp' } },
|
||||
];
|
||||
|
||||
Promise.map(filters, mapFilter)
|
||||
.then(function (filters) {
|
||||
$rootScope = { filters: filters };
|
||||
});
|
||||
$rootScope.$digest();
|
||||
});
|
||||
|
||||
describe('invertFilter', function () {
|
||||
var fn;
|
||||
|
||||
beforeEach(function () {
|
||||
fn = filterActions($rootScope).invertFilter;
|
||||
});
|
||||
|
||||
it('should negate filter', function () {
|
||||
var filter = $rootScope.filters[0];
|
||||
expect(filter.meta).to.have.property('negate', false);
|
||||
filter = fn(filter);
|
||||
expect(filter.meta).to.have.property('negate', true);
|
||||
});
|
||||
|
||||
it('should de-negate filter', function () {
|
||||
var filter = $rootScope.filters[1];
|
||||
expect(filter.meta).to.have.property('negate', true);
|
||||
filter = fn(filter);
|
||||
expect(filter.meta).to.have.property('negate', false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('invertAll', function () {
|
||||
var fn;
|
||||
|
||||
beforeEach(function () {
|
||||
fn = filterActions($rootScope).invertAll;
|
||||
});
|
||||
|
||||
var pickNegated = function (filter) {
|
||||
return filter.meta.negate;
|
||||
};
|
||||
|
||||
it('should toggle all the filters', function () {
|
||||
expect(_.filter($rootScope.filters, pickNegated)).to.have.length(1);
|
||||
fn();
|
||||
expect(_.filter($rootScope.filters, pickNegated)).to.have.length(4);
|
||||
});
|
||||
});
|
||||
}];
|
||||
});
|
|
@ -1,139 +0,0 @@
|
|||
define(function (require) {
|
||||
return ['pin', function () {
|
||||
var _ = require('lodash');
|
||||
var sinon = require('test_utils/auto_release_sinon');
|
||||
var filterActions, $rootScope, Promise, mapFilter, indexPattern, getIndexPatternStub;
|
||||
|
||||
beforeEach(module('kibana'));
|
||||
|
||||
beforeEach(function () {
|
||||
getIndexPatternStub = sinon.stub();
|
||||
module('kibana/courier', function ($provide) {
|
||||
$provide.service('courier', function () {
|
||||
var courier = { indexPatterns: { get: getIndexPatternStub } };
|
||||
return courier;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
inject(function (_$rootScope_, _Promise_, Private) {
|
||||
Promise = _Promise_;
|
||||
$rootScope = _$rootScope_;
|
||||
|
||||
mapFilter = Private(require('components/filter_bar/lib/mapFilter'));
|
||||
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
|
||||
filterActions = Private(require('components/filter_bar/lib/filterActions'));
|
||||
|
||||
getIndexPatternStub.returns(Promise.resolve(indexPattern));
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
var filters = [
|
||||
{ meta: { index: 'logstash-*', pinned: true }, query: { match: { 'extension': { query: 'jpg' } } } },
|
||||
{ meta: { index: 'logstash-*' }, query: { match: { '_type': { query: 'nginx' } } } },
|
||||
{ meta: { index: 'logstash-*' }, exists: { field: '@timestamp' } },
|
||||
];
|
||||
|
||||
Promise.map(filters, mapFilter)
|
||||
.then(function (filters) {
|
||||
$rootScope.filters = filters;
|
||||
});
|
||||
$rootScope.$digest();
|
||||
});
|
||||
|
||||
describe('pinFilter', function () {
|
||||
var fn;
|
||||
|
||||
beforeEach(function () {
|
||||
fn = filterActions($rootScope).pinFilter;
|
||||
});
|
||||
|
||||
it('should set pinned state from false to true and append', function () {
|
||||
var filter = $rootScope.filters[1];
|
||||
var filterCount = $rootScope.filters.length;
|
||||
|
||||
expect(filter.meta.pinned).to.be(false);
|
||||
filter = fn(filter);
|
||||
expect(filter.meta.pinned).to.be(true);
|
||||
// should also duplicate filter as pinned
|
||||
expect($rootScope.filters.length).to.be(filterCount + 1);
|
||||
});
|
||||
|
||||
it('should set pinned state from true to false and de-dupe', function () {
|
||||
var filter = $rootScope.filters[0];
|
||||
var filterCount = $rootScope.filters.length;
|
||||
var dupeFilter = _.cloneDeep(filter);
|
||||
dupeFilter.meta.pinned = false;
|
||||
|
||||
$rootScope.filters.push(dupeFilter);
|
||||
expect($rootScope.filters.length).to.be(filterCount + 1);
|
||||
|
||||
expect(filter.meta.pinned).to.be(true);
|
||||
filter = fn(filter);
|
||||
expect(filter.meta.pinned).to.be(false);
|
||||
// check that the 2 now-unpinned filters are de-duped
|
||||
expect($rootScope.filters.length).to.be(filterCount);
|
||||
});
|
||||
|
||||
it('should force pin filter to true', function () {
|
||||
var filter = $rootScope.filters[0];
|
||||
|
||||
expect(filter.meta.pinned).to.be(true);
|
||||
filter = fn(filter, true);
|
||||
expect(filter.meta.pinned).to.be(true);
|
||||
|
||||
filter = $rootScope.filters[1];
|
||||
|
||||
expect(filter.meta.pinned).to.be(false);
|
||||
filter = fn(filter, true);
|
||||
expect(filter.meta.pinned).to.be(true);
|
||||
});
|
||||
|
||||
it('should force pin filter to false', function () {
|
||||
var filter = $rootScope.filters[0];
|
||||
|
||||
expect(filter.meta.pinned).to.be(true);
|
||||
filter = fn(filter, false);
|
||||
expect(filter.meta.pinned).to.be(false);
|
||||
|
||||
filter = $rootScope.filters[1];
|
||||
|
||||
expect(filter.meta.pinned).to.be(false);
|
||||
filter = fn(filter, false);
|
||||
expect(filter.meta.pinned).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('pinAll', function () {
|
||||
var fn;
|
||||
|
||||
beforeEach(function () {
|
||||
fn = filterActions($rootScope).pinAll;
|
||||
});
|
||||
|
||||
it('should pin all filters to global state', function () {
|
||||
var filterCount = $rootScope.filters.length;
|
||||
var unfilteredCount = _.filter($rootScope.filters, { meta: { pinned: false }}).length;
|
||||
fn(true);
|
||||
var pinned = _.filter($rootScope.filters, { meta: { pinned: true }});
|
||||
// all existing filters were pinned
|
||||
expect(pinned.length).to.be(filterCount);
|
||||
// all previously unpinned filters were duplicated
|
||||
expect($rootScope.filters.length).to.be(filterCount + unfilteredCount);
|
||||
});
|
||||
|
||||
it('should unpin all filters from global state', function () {
|
||||
var filterCount = $rootScope.filters.length;
|
||||
fn(false);
|
||||
var unpinned = _.filter($rootScope.filters, { meta: { pinned: false }});
|
||||
// all filters were unpinned, no duplicates remain
|
||||
expect(unpinned.length).to.be(filterCount);
|
||||
});
|
||||
});
|
||||
|
||||
}];
|
||||
});
|
||||
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
define(function (require) {
|
||||
return ['remove', function () {
|
||||
var _ = require('lodash');
|
||||
var sinon = require('test_utils/auto_release_sinon');
|
||||
var filterActions, mapFilter, $rootScope, Promise, getIndexPatternStub, indexPattern;
|
||||
|
||||
beforeEach(module('kibana'));
|
||||
|
||||
beforeEach(function () {
|
||||
getIndexPatternStub = sinon.stub();
|
||||
module('kibana/courier', function ($provide) {
|
||||
$provide.service('courier', function () {
|
||||
var courier = { indexPatterns: { get: getIndexPatternStub } };
|
||||
return courier;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(inject(function (_Promise_, _$rootScope_, Private) {
|
||||
Promise = _Promise_;
|
||||
$rootScope = _$rootScope_;
|
||||
filterActions = Private(require('components/filter_bar/lib/filterActions'));
|
||||
mapFilter = Private(require('components/filter_bar/lib/mapFilter'));
|
||||
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
|
||||
|
||||
getIndexPatternStub.returns(Promise.resolve(indexPattern));
|
||||
})
|
||||
);
|
||||
|
||||
beforeEach(function () {
|
||||
var filters = [
|
||||
{ meta: { index: 'logstash-*' }, query: { match: { '@tags': { query: 'foo' } } } },
|
||||
{ meta: { index: 'logstash-*' }, query: { match: { '@tags': { query: 'bar' } } } },
|
||||
{ meta: { index: 'logstash-*' }, exists: { field: '@timestamp' } },
|
||||
{ meta: { index: 'logstash-*', disabled: true }, missing: { field: 'host' } },
|
||||
];
|
||||
|
||||
Promise.map(filters, mapFilter)
|
||||
.then(function (filters) {
|
||||
$rootScope.state = { filters: filters };
|
||||
});
|
||||
$rootScope.$digest();
|
||||
});
|
||||
|
||||
describe('removeFilter', function () {
|
||||
var fn;
|
||||
|
||||
beforeEach(function () {
|
||||
fn = filterActions($rootScope).removeFilter;
|
||||
});
|
||||
|
||||
it('should remove the filter from the state', function () {
|
||||
var filter = $rootScope.state.filters[2];
|
||||
fn(filter);
|
||||
expect($rootScope.state.filters).to.not.contain(filter);
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeAll', function () {
|
||||
var fn;
|
||||
|
||||
beforeEach(function () {
|
||||
fn = filterActions($rootScope).removeAll;
|
||||
});
|
||||
|
||||
it('should remove all the filters', function () {
|
||||
expect($rootScope.state.filters).to.have.length(4);
|
||||
fn();
|
||||
expect($rootScope.state.filters).to.have.length(0);
|
||||
});
|
||||
});
|
||||
}];
|
||||
});
|
|
@ -1,90 +0,0 @@
|
|||
define(function (require) {
|
||||
return ['toggle', function () {
|
||||
var _ = require('lodash');
|
||||
var sinon = require('test_utils/auto_release_sinon');
|
||||
var filterActions, mapFilter, $rootScope, Promise, getIndexPatternStub, indexPattern;
|
||||
|
||||
beforeEach(module('kibana'));
|
||||
|
||||
beforeEach(function () {
|
||||
getIndexPatternStub = sinon.stub();
|
||||
module('kibana/courier', function ($provide) {
|
||||
$provide.service('courier', function () {
|
||||
var courier = { indexPatterns: { get: getIndexPatternStub } };
|
||||
return courier;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(inject(function (_Promise_, _$rootScope_, Private) {
|
||||
Promise = _Promise_;
|
||||
$rootScope = _$rootScope_;
|
||||
filterActions = Private(require('components/filter_bar/lib/filterActions'));
|
||||
mapFilter = Private(require('components/filter_bar/lib/mapFilter'));
|
||||
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
|
||||
|
||||
getIndexPatternStub.returns(Promise.resolve(indexPattern));
|
||||
}));
|
||||
|
||||
beforeEach(function () {
|
||||
var filters = [
|
||||
{ meta: { index: 'logstash-*' }, query: { match: { '_type': { query: 'apache' } } } },
|
||||
{ meta: { index: 'logstash-*' }, query: { match: { '_type': { query: 'nginx' } } } },
|
||||
{ meta: { index: 'logstash-*' }, exists: { field: '@timestamp' } },
|
||||
{ meta: { index: 'logstash-*', disabled: true }, missing: { field: 'host' } },
|
||||
];
|
||||
|
||||
Promise.map(filters, mapFilter)
|
||||
.then(function (filters) {
|
||||
$rootScope.filters = filters;
|
||||
});
|
||||
$rootScope.$digest();
|
||||
});
|
||||
|
||||
describe('toggleFilter', function () {
|
||||
var fn;
|
||||
|
||||
beforeEach(function () {
|
||||
fn = filterActions($rootScope).toggleFilter;
|
||||
});
|
||||
|
||||
it('should toggle filters on and off', function () {
|
||||
var filter = fn($rootScope.filters[0]);
|
||||
expect(filter.meta).to.have.property('disabled', true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toggleAll', function () {
|
||||
var fn;
|
||||
|
||||
beforeEach(function () {
|
||||
fn = filterActions($rootScope).toggleAll;
|
||||
});
|
||||
|
||||
var pickDisabled = function (filter) {
|
||||
return filter.meta.disabled;
|
||||
};
|
||||
|
||||
it('should toggle all the filters', function () {
|
||||
expect(_.filter($rootScope.filters, pickDisabled)).to.have.length(1);
|
||||
fn();
|
||||
expect(_.filter($rootScope.filters, pickDisabled)).to.have.length(3);
|
||||
});
|
||||
|
||||
it('should disable all the filters', function () {
|
||||
expect(_.filter($rootScope.filters, pickDisabled)).to.have.length(1);
|
||||
fn(true);
|
||||
expect(_.filter($rootScope.filters, pickDisabled)).to.have.length(4);
|
||||
});
|
||||
|
||||
it('should enable all the filters', function () {
|
||||
expect(_.filter($rootScope.filters, pickDisabled)).to.have.length(1);
|
||||
fn(false);
|
||||
expect(_.filter($rootScope.filters, pickDisabled)).to.have.length(0);
|
||||
});
|
||||
});
|
||||
}];
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue