fix data view runtime fields api service key (#125430)

This commit is contained in:
Matthew Kime 2022-02-11 15:00:12 -06:00 committed by GitHub
parent ddbb06032e
commit d06dc147ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 7 deletions

View file

@ -3,7 +3,7 @@
exports[`responseFormatter returns correct format 1`] = `
Object {
"body": Object {
"SERVICE_KEY": Object {
"data_view": Object {
"title": "dataView",
},
"fields": Array [
@ -18,12 +18,12 @@ Object {
exports[`responseFormatter returns correct format for legacy 1`] = `
Object {
"body": Object {
"SERVICE_KEY_LEGACY": Object {
"title": "dataView",
},
"field": Object {
"name": "field",
},
"index_pattern": Object {
"title": "dataView",
},
},
}
`;

View file

@ -7,7 +7,7 @@
*/
import { DataView, DataViewField } from 'src/plugins/data_views/common';
import { SERVICE_KEY_LEGACY, SERVICE_KEY_TYPE } from '../../constants';
import { SERVICE_KEY_LEGACY, SERVICE_KEY_TYPE, SERVICE_KEY } from '../../constants';
interface ResponseFormatterArgs {
serviceKey: SERVICE_KEY_TYPE;
@ -19,13 +19,13 @@ export const responseFormatter = ({ serviceKey, field, dataView }: ResponseForma
const response = {
body: {
fields: [field.toSpec()],
SERVICE_KEY: dataView.toSpec(),
[SERVICE_KEY]: dataView.toSpec(),
},
};
const legacyResponse = {
body: {
SERVICE_KEY_LEGACY: dataView.toSpec(),
[SERVICE_KEY_LEGACY]: dataView.toSpec(),
field: field.toSpec(),
},
};

View file

@ -47,6 +47,8 @@ export default function ({ getService }: FtrProviderContext) {
});
expect(response2.status).to.be(200);
expect(response2.body[config.serviceKey]).to.not.be.empty();
const field =
config.serviceKey === 'index_pattern' ? response2.body.field : response2.body.fields[0];
@ -82,6 +84,7 @@ export default function ({ getService }: FtrProviderContext) {
);
expect(response2.status).to.be(200);
expect(response2.body[config.serviceKey]).to.not.be.empty();
const field = response2.body[config.serviceKey].fields.runtimeBar;

View file

@ -60,6 +60,7 @@ export default function ({ getService }: FtrProviderContext) {
config.serviceKey === 'index_pattern' ? response2.body.field : response2.body.fields[0];
expect(response2.status).to.be(200);
expect(response2.body[config.serviceKey]).to.not.be.empty();
expect(typeof field).to.be('object');
expect(field.name).to.be('runtimeFoo');
expect(field.type).to.be('string');

View file

@ -63,6 +63,7 @@ export default function ({ getService }: FtrProviderContext) {
});
expect(response2.status).to.be(200);
expect(response2.body[config.serviceKey]).to.not.be.empty();
const response3 = await supertest.get(
`${config.path}/${response1.body[config.serviceKey].id}/runtime_field/runtimeFoo`
@ -122,6 +123,7 @@ export default function ({ getService }: FtrProviderContext) {
config.serviceKey === 'index_pattern' ? response2.body.field : response2.body.fields[0];
expect(response2.status).to.be(200);
expect(response2.body[config.serviceKey]).to.not.be.empty();
expect(typeof field.runtimeField).to.be('object');
});
});

View file

@ -70,6 +70,7 @@ export default function ({ getService }: FtrProviderContext) {
config.serviceKey === 'index_pattern' ? response3.body.field : response3.body.fields[0];
expect(response3.status).to.be(200);
expect(response3.body[config.serviceKey]).to.not.be.empty();
expect(field.type).to.be('string');
expect(field.runtimeField.type).to.be('keyword');
expect(field.runtimeField.script.source).to.be("doc['something_new'].value");