Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Mar 14, 2022
1 parent cf4cb83 commit 2f8ce6f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ describe('lens_merge_tables', () => {
});
});

it('should store the current tables in the tables inspector', () => {
const adapters: DefaultInspectorAdapters = {
it('should reset the current tables in the tables inspector', () => {
const adapters = {
tables: new TablesAdapter(),
requests: {} as never,
expression: {} as never,
};
} as DefaultInspectorAdapters;

const resetSpy = jest.spyOn(adapters.tables, 'reset');

mergeTables.fn(null, { layerIds: ['first', 'second'], tables: [sampleTable1, sampleTable2] }, {
inspectorAdapters: adapters,
} as ExecutionContext<DefaultInspectorAdapters, ExpressionValueSearchContext>);
expect(adapters.tables!.tables.first).toBe(sampleTable1);
expect(adapters.tables!.tables.second).toBe(sampleTable2);
expect(resetSpy).toHaveBeenCalled();
});

it('should pass the date range along', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
getUnknownVisualizationTypeError,
} from '../../error_helper';
import { getMissingIndexPattern, validateDatasourceAndVisualization } from '../state_helpers';
import type { DefaultInspectorAdapters } from '../../../../../../../src/plugins/expressions/common';
import {
onActiveDataChange,
useLensDispatch,
Expand Down Expand Up @@ -496,19 +497,20 @@ export const VisualizationWrapper = ({
const dispatchLens = useLensDispatch();

const onData$ = useCallback(
(data) => {
if (data?.value?.data) {
let tables: Record<string, Datatable> = {};
switch (data.value.data.type) {
case 'datatable':
const [layerId] = Object.keys(datasourceLayers);
tables[layerId] = { ...data.value.data };
break;
case 'lens_multitable':
tables = { ...data.value.data.tables };
break;
}
dispatchLens(onActiveDataChange(tables));
(data: unknown, adapters?: Partial<DefaultInspectorAdapters>) => {
if (adapters && adapters.tables) {
const [defaultLayerId] = Object.keys(datasourceLayers);

dispatchLens(
onActiveDataChange(
Object.entries(adapters.tables?.tables).reduce<Record<string, Datatable>>(
(acc, [key, value]) => ({
[key === 'default' ? defaultLayerId : key]: value,
}),
{}
)
)
);
}
},
[datasourceLayers, dispatchLens]
Expand Down

0 comments on commit 2f8ce6f

Please sign in to comment.