Skip to content

Commit

Permalink
Fix all editor frame tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wylieconlon committed Mar 6, 2020
1 parent 9178b13 commit 0e22ae5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function LayerPanels(
type: 'UPDATE_VISUALIZATION_STATE',
visualizationId: activeVisualization.id,
newState,
clearStagedPreview: true,
clearStagedPreview: false,
});
},
[props.dispatch, activeVisualization]
Expand All @@ -109,7 +109,7 @@ function LayerPanels(
type: 'UPDATE_DATASOURCE_STATE',
updater: () => newState,
datasourceId,
clearStagedPreview: true,
clearStagedPreview: false,
});
},
[props.dispatch]
Expand Down Expand Up @@ -204,6 +204,9 @@ function LayerPanel(
const dragDropContext = useContext(DragContext);
const { framePublicAPI, layerId, activeVisualization, isOnlyLayer, onRemove } = props;
const datasourcePublicAPI = framePublicAPI.datasourceLayers[layerId];
if (!datasourcePublicAPI) {
return <></>;
}
const layerVisualizationConfigProps = {
layerId,
dragDropContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,14 +635,13 @@ describe('editor_frame', () => {

const updatedState = {};
const setVisualizationState = (mockVisualization.getLayerOptions as jest.Mock).mock
.calls[0][1].setState;
.calls[0][0].setState;
act(() => {
setVisualizationState(updatedState);
});

expect(mockVisualization.getLayerOptions).toHaveBeenCalledTimes(2);
expect(mockVisualization.getLayerOptions).toHaveBeenLastCalledWith(
// expect.any(Element),
expect.objectContaining({
state: updatedState,
})
Expand Down Expand Up @@ -722,7 +721,6 @@ describe('editor_frame', () => {

expect(mockVisualization.getLayerOptions).toHaveBeenCalledTimes(2);
expect(mockVisualization.getLayerOptions).toHaveBeenLastCalledWith(
// expect.any(Element),
expect.objectContaining({
frame: expect.objectContaining({
datasourceLayers: {
Expand All @@ -738,6 +736,7 @@ describe('editor_frame', () => {
it('should pass the datasource api for each layer to the visualization', async () => {
mockDatasource.getLayers.mockReturnValue(['first']);
mockDatasource2.getLayers.mockReturnValue(['second', 'third']);
mockVisualization.getLayerIds.mockReturnValue(['first', 'second', 'third']);

mount(
<EditorFrame
Expand Down Expand Up @@ -776,7 +775,8 @@ describe('editor_frame', () => {

expect(mockVisualization.getLayerOptions).toHaveBeenCalled();

const datasourceLayers = mockVisualization.initialize.mock.calls[0][0].datasourceLayers;
const datasourceLayers =
mockVisualization.getLayerOptions.mock.calls[0][0].frame.datasourceLayers;
expect(datasourceLayers.first).toBe(mockDatasource.publicAPIMock);
expect(datasourceLayers.second).toBe(mockDatasource2.publicAPIMock);
expect(datasourceLayers.third).toBe(mockDatasource2.publicAPIMock);
Expand Down Expand Up @@ -1039,7 +1039,6 @@ describe('editor_frame', () => {
expect(mockVisualization2.getSuggestions).toHaveBeenCalled();
expect(mockVisualization2.initialize).toHaveBeenCalledWith(expect.anything(), initialState);
expect(mockVisualization2.getLayerOptions).toHaveBeenCalledWith(
// expect.any(Element),
expect.objectContaining({ state: { initial: true } })
);
});
Expand All @@ -1057,7 +1056,6 @@ describe('editor_frame', () => {
})
);
expect(mockVisualization2.getLayerOptions).toHaveBeenCalledWith(
expect.any(Element),
expect.objectContaining({ state: { initial: true } })
);
});
Expand Down Expand Up @@ -1254,7 +1252,6 @@ describe('editor_frame', () => {

expect(mockVisualization.getLayerOptions).toHaveBeenCalledTimes(1);
expect(mockVisualization.getLayerOptions).toHaveBeenCalledWith(
// expect.any(Element),
expect.objectContaining({
state: suggestionVisState,
})
Expand Down Expand Up @@ -1319,7 +1316,6 @@ describe('editor_frame', () => {
});

expect(mockVisualization.getLayerOptions).toHaveBeenCalledWith(
// expect.any(Element),
expect.objectContaining({
state: suggestionVisState,
})
Expand Down Expand Up @@ -1393,7 +1389,6 @@ describe('editor_frame', () => {
});

expect(mockVisualization2.getLayerOptions).toHaveBeenCalledWith(
expect.any(Element),
expect.objectContaining({
state: suggestionVisState,
})
Expand Down Expand Up @@ -1489,7 +1484,6 @@ describe('editor_frame', () => {
});

expect(mockVisualization3.getLayerOptions).toHaveBeenCalledWith(
// expect.any(Element),
expect.objectContaining({
state: suggestionVisState,
})
Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/lens/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ export interface LensMultiTable {

export interface VisualizationLayerConfigProps<T = unknown> {
layerId: string;
// dragDropContext: DragContextState;
frame: FramePublicAPI;
state: T;
setState: (newState: T) => void;
Expand Down

0 comments on commit 0e22ae5

Please sign in to comment.