Skip to content

Commit 7a9c5ce

Browse files
committed
Include preview in tests
1 parent bbddc89 commit 7a9c5ce

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

x-pack/legacy/plugins/lens/public/editor_frame_service/editor_frame/layer_actions.test.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,21 @@ function createTestArgs(initialLayerIds: string[]) {
2828
appendLayer: (layerIds: unknown, layerId: string) => [...(layerIds as string[]), layerId],
2929
};
3030

31+
const datasourceStates = {
32+
ds1: {
33+
isLoading: false,
34+
state: initialLayerIds.slice(0, 1),
35+
},
36+
ds2: {
37+
isLoading: false,
38+
state: initialLayerIds.slice(1),
39+
},
40+
};
41+
3142
return {
3243
state: {
3344
activeDatasourceId: 'ds1',
34-
datasourceStates: {
35-
ds1: {
36-
isLoading: false,
37-
state: initialLayerIds.slice(0, 1),
38-
},
39-
ds2: {
40-
isLoading: false,
41-
state: initialLayerIds.slice(1),
42-
},
43-
},
45+
datasourceStates,
4446
title: 'foo',
4547
visualization: {
4648
activeId: 'vis1',
@@ -53,6 +55,13 @@ function createTestArgs(initialLayerIds: string[]) {
5355
ds2: testDatasource('ds2'),
5456
},
5557
trackUiEvent,
58+
stagedPreview: {
59+
visualization: {
60+
activeId: 'vis1',
61+
state: initialLayerIds,
62+
},
63+
datasourceStates,
64+
},
5665
};
5766
}
5867

@@ -90,6 +99,7 @@ describe('removeLayer', () => {
9099
expect(newState.visualization.state).toEqual(['layer2']);
91100
expect(newState.datasourceStates.ds1.state).toEqual([]);
92101
expect(newState.datasourceStates.ds2.state).toEqual(['layer2']);
102+
expect(newState.stagedPreview).not.toBeDefined();
93103
expect(trackUiEvent).toHaveBeenCalledWith('layer_removed');
94104
});
95105
});
@@ -111,6 +121,7 @@ describe('appendLayer', () => {
111121
expect(newState.visualization.state).toEqual(['layer1', 'layer2', 'foo']);
112122
expect(newState.datasourceStates.ds1.state).toEqual(['layer1', 'foo']);
113123
expect(newState.datasourceStates.ds2.state).toEqual(['layer2']);
124+
expect(newState.stagedPreview).not.toBeDefined();
114125
expect(trackUiEvent).toHaveBeenCalledWith('layer_added');
115126
});
116127
});

x-pack/legacy/plugins/lens/public/editor_frame_service/editor_frame/layer_actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,6 @@ export function appendLayer({
8585
...state.visualization,
8686
state: activeVisualization.appendLayer(state.visualization.state, layerId),
8787
},
88+
stagedPreview: undefined,
8889
};
8990
}

0 commit comments

Comments
 (0)