kibana/test/unit/api/ingest_field_capabilities.js
Spencer 90434765c0 [functionalTestRunner] replace intern (#10910)
* [functional_test_runner] replace functional testing tools with custom/pluggable solution

* [functional_test_runner] Convert unit tests to commonjs format

* [functional_test_runner] Fix dashboard test in wrong mode

* [functional_test_runner] Add dashboardLandingPage test subject

* [functional_test_runner] Get Visualize page object

* [functional_test_runner] Fix outdated references

* [functional_test_runner] Fix more outdated refs

* [functional_test_runner] Remove duplicate tests

* [functional_test_runner] Improve test readability

* [functional_test_runner] 😞 So many duplicate methods

* [functional_test_runner] Move mgmt `before` outside toplevel describe

* [functional_test_runner] Settings page obj missing methods

* [functional_test_runner] Add improvements from @gammon

* [functional_test_runner] Fix return statements in async funcs

* [functional_test_runner] Move before() to correct scope

* [functional_test_runner] Add after() hooks to remove index patterns

* [functional_test_runner] Attempt to fix vertical bar chart tests

* [functional_test_runner] Clean up

* [functional_test_runner] Reinstate unit tests

* [functional_test_runner] Set default loglevel back to info

* [functional_test_runner] Replace `context`s with `describe`s

* [functional_test_runner] Better error handling

* [functional_test_runner] Add in new Tile Map tests

* Incorporate changes from master

* [functional_test_runner] validate that every test file has a single top-level suite

* Update contributing doc with link to full doc

* [docs] Spelling and grammar fixes

* docs: writing and running functional tests

* [docs] Move plugin doc to plugin area

* [docs] Housekeeping. Doc in wrong place

* [docs] Remove dup doc file

* [grunt] Only run mocha_setup when running tests, not every grunt task
2017-04-11 17:01:06 -05:00

84 lines
2.3 KiB
JavaScript

import expect from 'expect.js';
import { emptyKibana, client, supertest } from './lib';
describe('ingest field_capabilities API', () => {
before(() => emptyKibana.setup());
after(() => emptyKibana.teardown());
before(() => {
return client.create({
index: 'foo-1',
type: 'bar',
id: '1',
body: {
foo: 'bar'
}
})
.then(() => {
return client.create({
index: 'foo-2',
type: 'bar',
id: '2',
body: {
baz: 'bar'
}
});
})
.then(() => {
return client.indices.refresh({
index: ['foo-1', 'foo-2']
});
});
});
after(() => {
return emptyKibana.setup().then(() => {
return client.indices.delete({
index: 'foo*'
});
});
});
it('should return searchable/aggregatable flags for fields in the indices specified', () => {
return supertest.get('/kibana/foo-1/field_capabilities')
.expect(200)
.then((response) => {
const fields = response.body.fields;
expect(fields.foo).to.eql({ searchable: true, aggregatable: false });
expect(fields['foo.keyword']).to.eql({ searchable: true, aggregatable: true });
expect(fields).to.not.have.property('baz');
});
});
it('should accept wildcards in the index name', () => {
return supertest.get('/kibana/foo-*/field_capabilities')
.expect(200)
.then((response) => {
const fields = response.body.fields;
expect(fields.foo).to.eql({ searchable: true, aggregatable: false });
expect(fields.baz).to.eql({ searchable: true, aggregatable: false });
});
});
it('should accept comma delimited lists of indices', () => {
return supertest.get('/kibana/foo-1,foo-2/field_capabilities')
.expect(200)
.then((response) => {
const fields = response.body.fields;
expect(fields.foo).to.eql({ searchable: true, aggregatable: false });
expect(fields.baz).to.eql({ searchable: true, aggregatable: false });
});
});
it('should return 404 if a pattern matches no indices', () => {
return supertest.post('/kibana/doesnotexist-*/field_capabilities')
.expect(404);
});
it('should return 404 if a concrete index does not exist', () => {
return supertest.post('/kibana/concrete/field_capabilities')
.expect(404);
});
});