mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Fix/lens serialize (#218082)
This commit is contained in:
parent
3c1f04dbb4
commit
1017c22245
2 changed files with 53 additions and 2 deletions
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
import { of } from 'rxjs';
|
||||
import { UiSettingsCommon } from '@kbn/data-views-plugin/common';
|
||||
import { getEsqlFn } from './esql';
|
||||
import { ExecutionContext } from '@kbn/expressions-plugin/common';
|
||||
import { ESQLSearchResponse } from '@kbn/es-types';
|
||||
import { IKibanaSearchResponse } from '@kbn/search-types';
|
||||
|
||||
describe('getEsqlFn', () => {
|
||||
it('should always return a fully serializable table', async () => {
|
||||
const mockSearch = jest.fn().mockReturnValue(
|
||||
of({
|
||||
rawResponse: {
|
||||
values: [['value1']],
|
||||
columns: [{ name: 'column1', type: 'string' }],
|
||||
},
|
||||
} as IKibanaSearchResponse<ESQLSearchResponse>)
|
||||
);
|
||||
|
||||
const esqlFn = getEsqlFn({
|
||||
getStartDependencies: async () => ({
|
||||
search: mockSearch,
|
||||
uiSettings: {} as UiSettingsCommon,
|
||||
}),
|
||||
});
|
||||
|
||||
const input = null; // Mock input
|
||||
const args = {
|
||||
query: 'SELECT * FROM index',
|
||||
};
|
||||
|
||||
const context = {
|
||||
abortSignal: new AbortController().signal,
|
||||
inspectorAdapters: {},
|
||||
getKibanaRequest: jest.fn(),
|
||||
} as unknown as ExecutionContext;
|
||||
|
||||
const result = await esqlFn.fn(input, args, context).toPromise();
|
||||
|
||||
expect(result?.type).toEqual('datatable');
|
||||
expect(() => JSON.stringify(result)).not.toThrow();
|
||||
});
|
||||
});
|
|
@ -345,8 +345,8 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => {
|
|||
|
||||
const appliedTimeRange = input?.timeRange
|
||||
? {
|
||||
from: DateMath.parse(input.timeRange.from),
|
||||
to: DateMath.parse(input.timeRange.to, { roundUp: true }),
|
||||
from: DateMath.parse(input.timeRange.from)?.toISOString(),
|
||||
to: DateMath.parse(input.timeRange.to, { roundUp: true })?.toISOString(),
|
||||
}
|
||||
: undefined;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue