[Event annotations] add types to integration tests (#164103)

This commit is contained in:
Drew Tate 2023-08-17 08:17:25 -06:00 committed by GitHub
parent 3d60f22a92
commit 276cf86858
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 39 deletions

2
.github/CODEOWNERS vendored
View file

@ -829,7 +829,7 @@ packages/kbn-yarn-lock-validator @elastic/kibana-operations
/x-pack/test/api_integration/apis/lens/ @elastic/kibana-visualizations
/test/functional/apps/visualize/ @elastic/kibana-visualizations
/x-pack/test/functional/apps/graph @elastic/kibana-visualizations
/test/api_integraion/apis/event_annotations @elastic/kibana-visualizations
/test/api_integration/apis/event_annotations @elastic/kibana-visualizations
# Global Experience

View file

@ -26,5 +26,11 @@ export type { EventAnnotationGroupArgs } from './event_annotation_group';
export type { FetchEventAnnotationsArgs } from './fetch_event_annotations/types';
export type { EventAnnotationArgs, EventAnnotationOutput } from './types';
export type { EventAnnotationGroupSavedObjectAttributes } from './content_management';
export type {
EventAnnotationGroupSavedObjectAttributes,
EventAnnotationGroupCreateIn,
EventAnnotationGroupUpdateIn,
EventAnnotationGroupSearchIn,
} from './content_management';
export { CONTENT_ID } from './content_management';
export { ANNOTATIONS_LISTING_VIEW_ID } from './constants';

View file

@ -7,18 +7,23 @@
*/
import expect from '@kbn/expect';
import type {
EventAnnotationGroupSavedObjectAttributes,
EventAnnotationGroupCreateIn,
EventAnnotationGroupUpdateIn,
EventAnnotationGroupSearchIn,
} from '@kbn/event-annotation-plugin/common';
import { CONTENT_ID } from '@kbn/event-annotation-plugin/common';
import { FtrProviderContext } from '../../ftr_provider_context';
const CONTENT_ENDPOINT = '/api/content_management/rpc';
const CONTENT_TYPE_ID = 'event-annotation-group';
const API_VERSION = 1;
const EXISTING_ID_1 = 'fcebef20-3ba4-11ee-85d3-3dd00bdd66ef'; // from loaded archive
const EXISTING_ID_2 = '0d1aa670-3baf-11ee-a4a7-c11cb33a9549'; // from loaded archive
const DEFAULT_EVENT_ANNOTATION_GROUP = {
const DEFAULT_EVENT_ANNOTATION_GROUP: EventAnnotationGroupSavedObjectAttributes = {
title: 'a group',
description: '',
ignoreGlobalFilters: true,
@ -66,20 +71,22 @@ export default function ({ getService }: FtrProviderContext) {
// TODO test tag searching, ordering, pagination, etc
it(`should retrieve existing groups`, async () => {
const payload: EventAnnotationGroupSearchIn = {
contentTypeId: CONTENT_ID,
query: {
limit: 1000,
tags: {
included: [],
excluded: [],
},
},
version: API_VERSION,
};
const resp = await supertest
.post(`${CONTENT_ENDPOINT}/search`)
.set('kbn-xsrf', 'kibana')
.send({
contentTypeId: CONTENT_TYPE_ID,
query: {
limit: 1000,
tags: {
included: [],
excluded: [],
},
},
version: API_VERSION,
})
.send(payload)
.expect(200);
const results = resp.body.result.result.hits;
@ -90,18 +97,20 @@ export default function ({ getService }: FtrProviderContext) {
describe('create', () => {
it(`should require dataViewSpec to be specified`, async () => {
const createWithDataViewSpec = (dataViewSpec: any) =>
supertest
const createWithDataViewSpec = (dataViewSpec: any) => {
const payload: EventAnnotationGroupCreateIn = {
contentTypeId: CONTENT_ID,
data: { ...DEFAULT_EVENT_ANNOTATION_GROUP, dataViewSpec },
options: {
references: DEFAULT_REFERENCES,
},
version: API_VERSION,
};
return supertest
.post(`${CONTENT_ENDPOINT}/create`)
.set('kbn-xsrf', 'kibana')
.send({
contentTypeId: CONTENT_TYPE_ID,
data: { ...DEFAULT_EVENT_ANNOTATION_GROUP, dataViewSpec },
options: {
references: DEFAULT_REFERENCES,
},
version: API_VERSION,
});
.send(payload);
};
const errorResp = await createWithDataViewSpec(undefined).expect(400);
@ -119,20 +128,22 @@ export default function ({ getService }: FtrProviderContext) {
describe('update', () => {
it(`should require dataViewSpec to be specified`, async () => {
const updateWithDataViewSpec = (dataViewSpec: any) =>
supertest
const updateWithDataViewSpec = (dataViewSpec: any) => {
const payload: EventAnnotationGroupUpdateIn = {
contentTypeId: CONTENT_ID,
data: { ...DEFAULT_EVENT_ANNOTATION_GROUP, dataViewSpec },
id: EXISTING_ID_1,
options: {
references: DEFAULT_REFERENCES,
},
version: API_VERSION,
};
return supertest
.post(`${CONTENT_ENDPOINT}/update`)
.set('kbn-xsrf', 'kibana')
.send({
contentTypeId: CONTENT_TYPE_ID,
data: { ...DEFAULT_EVENT_ANNOTATION_GROUP, dataViewSpec },
id: EXISTING_ID_1,
options: {
references: DEFAULT_REFERENCES,
},
version: API_VERSION,
});
.send(payload);
};
const errorResp = await updateWithDataViewSpec(undefined).expect(400);
expect(errorResp.body.message).to.be(

View file

@ -67,6 +67,7 @@
"@kbn/enterprise-search-plugin",
"@kbn/core-saved-objects-server",
"@kbn/discover-plugin",
"@kbn/core-http-common"
"@kbn/core-http-common",
"@kbn/event-annotation-plugin"
]
}