[Expressions] Fix failing functional test of event annotations fetch (#142386)

* Fix failing functional test of event annotations fetch
* Filter `isHidden` on expression level
This commit is contained in:
Michael Dokolin 2022-10-06 21:12:14 +02:00 committed by GitHub
parent 5a17c640fd
commit 2d34b6e789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 43 deletions

View file

@ -60,7 +60,7 @@ export function eventAnnotationGroup(): ExpressionFunctionDefinition<
fn: (input, args) => {
return {
type: 'event_annotation_group',
annotations: args.annotations,
annotations: args.annotations.filter((annotation) => !annotation.isHidden),
dataView: args.dataView,
};
},

View file

@ -19,44 +19,6 @@ describe('Event Annotation Service', () => {
expect(eventAnnotationService.toExpression([])).toEqual([]);
});
it('should skip hidden annotations', () => {
expect(
eventAnnotationService.toExpression([
{
id: 'myEvent',
type: 'manual',
key: {
type: 'point_in_time',
timestamp: '2022',
},
label: 'Hello',
isHidden: true,
},
{
id: 'myRangeEvent',
type: 'manual',
key: {
type: 'range',
timestamp: '2021',
endTimestamp: '2022',
},
label: 'Hello Range',
isHidden: true,
},
{
id: 'myEvent',
type: 'query',
timeField: '@timestamp',
key: {
type: 'point_in_time',
},
label: 'Hello Range',
isHidden: true,
filter: { type: 'kibana_query', query: '', language: 'kuery' },
},
])
).toEqual([]);
});
it('should process manual point annotations', () => {
expect(
eventAnnotationService.toExpression([
@ -79,6 +41,7 @@ describe('Event Annotation Service', () => {
function: 'manual_point_event_annotation',
arguments: {
id: ['myEvent'],
isHidden: [false],
time: ['2022'],
label: ['Hello'],
color: ['#f04e98'],
@ -115,6 +78,7 @@ describe('Event Annotation Service', () => {
function: 'manual_range_event_annotation',
arguments: {
id: ['myEvent'],
isHidden: [false],
time: ['2021'],
endTime: ['2022'],
label: ['Hello'],
@ -149,6 +113,7 @@ describe('Event Annotation Service', () => {
function: 'query_point_event_annotation',
arguments: {
id: ['myEvent'],
isHidden: [false],
timeField: ['@timestamp'],
label: ['Hello'],
color: ['#f04e98'],
@ -221,6 +186,7 @@ describe('Event Annotation Service', () => {
function: 'manual_point_event_annotation',
arguments: {
id: ['myEvent'],
isHidden: [false],
time: ['2022'],
label: ['Hello'],
color: ['#f04e98'],
@ -240,6 +206,7 @@ describe('Event Annotation Service', () => {
function: 'manual_range_event_annotation',
arguments: {
id: ['myRangeEvent'],
isHidden: [false],
time: ['2021'],
endTime: ['2022'],
label: ['Hello Range'],
@ -257,6 +224,7 @@ describe('Event Annotation Service', () => {
function: 'query_point_event_annotation',
arguments: {
id: ['myEvent'],
isHidden: [false],
timeField: ['@timestamp'],
label: ['Hello'],
color: ['#f04e98'],
@ -320,6 +288,7 @@ describe('Event Annotation Service', () => {
function: 'query_point_event_annotation',
arguments: {
id: ['myEvent'],
isHidden: [false],
timeField: ['@timestamp'],
label: ['Hello'],
color: ['#f04e98'],

View file

@ -25,9 +25,8 @@ export function hasIcon(icon: string | undefined): icon is string {
export function getEventAnnotationService(): EventAnnotationServiceType {
const annotationsToExpression = (annotations: EventAnnotationConfig[]) => {
const visibleAnnotations = annotations.filter(({ isHidden }) => !isHidden);
const [queryBasedAnnotations, manualBasedAnnotations] = partition(
visibleAnnotations,
annotations,
isQueryAnnotationConfig
);
@ -50,6 +49,7 @@ export function getEventAnnotationService(): EventAnnotationServiceType {
label: [label || defaultAnnotationLabel],
color: [color || defaultAnnotationRangeColor],
outside: [Boolean(outside)],
isHidden: [Boolean(annotation.isHidden)],
},
},
],
@ -71,6 +71,7 @@ export function getEventAnnotationService(): EventAnnotationServiceType {
lineStyle: [lineStyle || 'solid'],
icon: hasIcon(icon) ? [icon] : ['triangle'],
textVisibility: [textVisibility || false],
isHidden: [Boolean(annotation.isHidden)],
},
},
],
@ -112,6 +113,7 @@ export function getEventAnnotationService(): EventAnnotationServiceType {
filter: filter ? [queryToAst(filter)] : [],
extraFields: extraFields || [],
ignoreGlobalFilters: [Boolean(ignoreGlobalFilters)],
isHidden: [Boolean(annotation.isHidden)],
},
},
],

View file

@ -18,8 +18,7 @@ export default function ({
}: FtrProviderContext & { updateBaselines: boolean }) {
let expectExpression: ExpectExpression;
// Failing: See https://github.com/elastic/kibana/issues/140113
describe.skip('fetch event annotation tests', () => {
describe('fetch event annotation tests', () => {
before(() => {
expectExpression = expectExpressionProvider({ getService, updateBaselines });
});