diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx
index 8801be4d8ff01..dd1241af14f5a 100644
--- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx
+++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx
@@ -258,7 +258,7 @@ describe('LayerPanel', () => {
it('should not update the visualization if the datasource is incomplete', () => {
(generateId as jest.Mock).mockReturnValue(`newid`);
const updateAll = jest.fn();
- const updateDatasource = jest.fn();
+ const updateDatasourceAsync = jest.fn();
mockVisualization.getConfiguration.mockReturnValue({
groups: [
@@ -276,7 +276,7 @@ describe('LayerPanel', () => {
const component = mountWithIntl(
);
@@ -295,15 +295,88 @@ describe('LayerPanel', () => {
mockDatasource.renderDimensionEditor.mock.calls.length - 1
][1].setState;
+ act(() => {
+ stateFn(
+ {
+ indexPatternId: '1',
+ columns: {},
+ columnOrder: [],
+ incompleteColumns: { newId: { operationType: 'count' } },
+ },
+ { isDimensionComplete: false }
+ );
+ });
+ expect(updateAll).not.toHaveBeenCalled();
+ expect(updateDatasourceAsync).toHaveBeenCalled();
+
act(() => {
stateFn({
indexPatternId: '1',
columns: {},
columnOrder: [],
- incompleteColumns: { newId: { operationType: 'count' } },
});
});
- expect(updateAll).not.toHaveBeenCalled();
+ expect(updateAll).toHaveBeenCalled();
+ });
+
+ it('should remove the dimension when the datasource marks it as removed', () => {
+ const updateAll = jest.fn();
+ const updateDatasource = jest.fn();
+
+ mockVisualization.getConfiguration.mockReturnValue({
+ groups: [
+ {
+ groupLabel: 'A',
+ groupId: 'a',
+ accessors: [{ columnId: 'y' }],
+ filterOperations: () => true,
+ supportsMoreColumns: true,
+ dataTestSubj: 'lnsGroup',
+ },
+ ],
+ });
+
+ const component = mountWithIntl(
+
+ );
+
+ act(() => {
+ component.find('[data-test-subj="lnsLayerPanel-dimensionLink"]').first().simulate('click');
+ });
+ component.update();
+
+ expect(mockDatasource.renderDimensionEditor).toHaveBeenCalledWith(
+ expect.any(Element),
+ expect.objectContaining({ columnId: 'y' })
+ );
+ const stateFn =
+ mockDatasource.renderDimensionEditor.mock.calls[
+ mockDatasource.renderDimensionEditor.mock.calls.length - 1
+ ][1].setState;
act(() => {
stateFn(
@@ -311,11 +384,19 @@ describe('LayerPanel', () => {
indexPatternId: '1',
columns: {},
columnOrder: [],
+ incompleteColumns: { y: { operationType: 'average' } },
},
- { shouldReplaceDimension: true }
+ {
+ isDimensionComplete: false,
+ }
);
});
expect(updateAll).toHaveBeenCalled();
+ expect(mockVisualization.removeDimension).toHaveBeenCalledWith(
+ expect.objectContaining({
+ columnId: 'y',
+ })
+ );
});
it('should keep the DimensionContainer open when configuring a new dimension', () => {
@@ -334,6 +415,7 @@ describe('LayerPanel', () => {
accessors: [],
filterOperations: () => true,
supportsMoreColumns: true,
+ enableDimensionEditor: true,
dataTestSubj: 'lnsGroup',
},
],
@@ -348,6 +430,7 @@ describe('LayerPanel', () => {
accessors: [{ columnId: 'newid' }],
filterOperations: () => true,
supportsMoreColumns: false,
+ enableDimensionEditor: true,
dataTestSubj: 'lnsGroup',
},
],
@@ -360,6 +443,20 @@ describe('LayerPanel', () => {
component.update();
expect(component.find('EuiFlyoutHeader').exists()).toBe(true);
+
+ const lastArgs =
+ mockDatasource.renderDimensionEditor.mock.calls[
+ mockDatasource.renderDimensionEditor.mock.calls.length - 1
+ ][1];
+
+ // Simulate what is called by the dimension editor
+ act(() => {
+ lastArgs.setState(lastArgs.state, {
+ isDimensionComplete: true,
+ });
+ });
+
+ expect(mockVisualization.renderDimensionEditor).toHaveBeenCalled();
});
it('should close the DimensionContainer when the active visualization changes', () => {
diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx
index 136c6a00c5b50..3a299de0fca6a 100644
--- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx
+++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx
@@ -423,10 +423,11 @@ export function LayerPanel(
isFullscreen={isFullscreen}
groupLabel={activeGroup?.groupLabel || ''}
handleClose={() => {
- if (layerDatasource.canCloseDimensionEditor) {
- if (!layerDatasource.canCloseDimensionEditor(layerDatasourceState)) {
- return false;
- }
+ if (
+ layerDatasource.canCloseDimensionEditor &&
+ !layerDatasource.canCloseDimensionEditor(layerDatasourceState)
+ ) {
+ return false;
}
if (layerDatasource.updateStateOnCloseDimension) {
const newState = layerDatasource.updateStateOnCloseDimension({
@@ -461,36 +462,37 @@ export function LayerPanel(
isFullscreen,
setState: (
newState: unknown,
- {
- shouldReplaceDimension,
- shouldRemoveDimension,
- }: {
- shouldReplaceDimension?: boolean;
- shouldRemoveDimension?: boolean;
- } = {}
+ { isDimensionComplete = true }: { isDimensionComplete?: boolean } = {}
) => {
- if (shouldReplaceDimension || shouldRemoveDimension) {
+ if (allAccessors.includes(activeId)) {
+ if (isDimensionComplete) {
+ props.updateDatasourceAsync(datasourceId, newState);
+ } else {
+ // The datasource can indicate that the previously-valid column is no longer
+ // complete, which clears the visualization. This keeps the flyout open and reuses
+ // the previous columnId
+ props.updateAll(
+ datasourceId,
+ newState,
+ activeVisualization.removeDimension({
+ layerId,
+ columnId: activeId,
+ prevState: props.visualizationState,
+ })
+ );
+ }
+ } else if (isDimensionComplete) {
props.updateAll(
datasourceId,
newState,
- shouldRemoveDimension
- ? activeVisualization.removeDimension({
- layerId,
- columnId: activeId,
- prevState: props.visualizationState,
- })
- : activeVisualization.setDimension({
- layerId,
- groupId: activeGroup.groupId,
- columnId: activeId,
- prevState: props.visualizationState,
- })
+ activeVisualization.setDimension({
+ layerId,
+ groupId: activeGroup.groupId,
+ columnId: activeId,
+ prevState: props.visualizationState,
+ })
);
- if (shouldRemoveDimension) {
- setActiveDimension(initialActiveDimensionState);
- } else {
- setActiveDimension({ ...activeDimension, isNew: false });
- }
+ setActiveDimension({ ...activeDimension, isNew: false });
} else {
props.updateDatasourceAsync(datasourceId, newState);
}
diff --git a/x-pack/plugins/lens/public/editor_frame_service/mocks.tsx b/x-pack/plugins/lens/public/editor_frame_service/mocks.tsx
index 38669d72474df..1762e7ff20fab 100644
--- a/x-pack/plugins/lens/public/editor_frame_service/mocks.tsx
+++ b/x-pack/plugins/lens/public/editor_frame_service/mocks.tsx
@@ -57,6 +57,7 @@ export function createMockVisualization(): jest.Mocked {
setDimension: jest.fn(),
removeDimension: jest.fn(),
getErrorMessages: jest.fn((_state) => undefined),
+ renderDimensionEditor: jest.fn(),
};
}
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx
index eec5c5345f8d8..1dda857c2c329 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx
@@ -112,21 +112,21 @@ export function DimensionEditor(props: DimensionEditorProps) {
const setStateWrapper = (
setter: IndexPatternLayer | ((prevLayer: IndexPatternLayer) => IndexPatternLayer)
) => {
+ const prevOperationType =
+ operationDefinitionMap[state.layers[layerId].columns[columnId]?.operationType]?.input;
+
const hypotheticalLayer = typeof setter === 'function' ? setter(state.layers[layerId]) : setter;
const hasIncompleteColumns = Boolean(hypotheticalLayer.incompleteColumns?.[columnId]);
- const prevOperationType =
- operationDefinitionMap[hypotheticalLayer.columns[columnId]?.operationType]?.input;
setState(
(prevState) => {
const layer = typeof setter === 'function' ? setter(prevState.layers[layerId]) : setter;
return mergeLayer({ state: prevState, layerId, newLayer: layer });
},
{
- shouldReplaceDimension: Boolean(hypotheticalLayer.columns[columnId]),
- // clear the dimension if there's an incomplete column pending && previous operation was a fullReference operation
- shouldRemoveDimension: Boolean(
- hasIncompleteColumns && prevOperationType === 'fullReference'
- ),
+ isDimensionComplete:
+ prevOperationType === 'fullReference'
+ ? hasIncompleteColumns
+ : Boolean(hypotheticalLayer.columns[columnId]),
}
);
};
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx
index 348c8a8e22344..72a084ce290d0 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx
@@ -502,10 +502,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
comboBox.prop('onChange')!([option]);
});
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](defaultProps.state)).toEqual({
...initialState,
layers: {
@@ -537,10 +534,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
comboBox.prop('onChange')!([option]);
});
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](defaultProps.state)).toEqual({
...state,
layers: {
@@ -571,10 +565,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
wrapper.find('button[data-test-subj="lns-indexPatternDimension-min"]').simulate('click');
});
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](state)).toEqual({
...state,
layers: {
@@ -645,10 +636,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
wrapper.find('button[data-test-subj="lns-indexPatternDimension-min"]').simulate('click');
});
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](state)).toEqual({
...state,
layers: {
@@ -683,10 +671,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
wrapper.find('button[data-test-subj="lns-indexPatternDimension-min"]').simulate('click');
});
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](state)).toEqual({
...state,
layers: {
@@ -752,10 +737,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
.simulate('click');
});
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](state)).toEqual({
...state,
layers: {
@@ -881,7 +863,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
expect(setState.mock.calls[0]).toEqual([
expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: false },
+ { isDimensionComplete: false },
]);
expect(setState.mock.calls[0][0](state)).toEqual({
...state,
@@ -948,10 +930,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
.simulate('click');
// Now check that the dimension gets cleaned up on state update
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: false },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](state)).toEqual({
...state,
layers: {
@@ -1044,10 +1023,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
});
expect(setState.mock.calls.length).toEqual(2);
- expect(setState.mock.calls[1]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[1]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[1][0](state)).toEqual({
...state,
layers: {
@@ -1145,10 +1121,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
.find('[data-test-subj="indexPattern-time-scaling-enable"]')
.hostNodes()
.simulate('click');
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](props.state)).toEqual({
...props.state,
layers: {
@@ -1177,10 +1150,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
wrapper
.find('button[data-test-subj="lns-indexPatternDimension-count incompatible"]')
.simulate('click');
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](props.state)).toEqual({
...props.state,
layers: {
@@ -1207,10 +1177,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
});
wrapper = mount();
wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click');
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](props.state)).toEqual({
...props.state,
layers: {
@@ -1241,10 +1208,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
.prop('onChange')!(({
target: { value: 'h' },
} as unknown) as ChangeEvent);
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](props.state)).toEqual({
...props.state,
layers: {
@@ -1271,10 +1235,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
.prop('onChange')!(({
target: { value: 'h' },
} as unknown) as ChangeEvent);
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](props.state)).toEqual({
...props.state,
layers: {
@@ -1302,10 +1263,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
{} as any
);
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](props.state)).toEqual({
...props.state,
layers: {
@@ -1595,10 +1553,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
.find('[data-test-subj="indexPattern-filter-by-enable"]')
.hostNodes()
.simulate('click');
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](props.state)).toEqual({
...props.state,
layers: {
@@ -1629,10 +1584,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
wrapper
.find('button[data-test-subj="lns-indexPatternDimension-count incompatible"]')
.simulate('click');
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](props.state)).toEqual({
...props.state,
layers: {
@@ -1658,10 +1610,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
language: 'kuery',
query: 'c: d',
});
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](props.state)).toEqual({
...props.state,
layers: {
@@ -1690,10 +1639,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
{} as any
);
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](props.state)).toEqual({
...props.state,
layers: {
@@ -1745,10 +1691,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click');
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: false },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: false }]);
expect(setState.mock.calls[0][0](defaultProps.state)).toEqual({
...state,
layers: {
@@ -1812,10 +1755,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click');
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](initialState)).toEqual({
...initialState,
layers: {
@@ -1840,10 +1780,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click');
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](state)).toEqual({
...state,
layers: {
@@ -1977,10 +1914,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
comboBox.prop('onChange')!([option]);
});
- expect(setState.mock.calls[0]).toEqual([
- expect.any(Function),
- { shouldRemoveDimension: false, shouldReplaceDimension: true },
- ]);
+ expect(setState.mock.calls[0]).toEqual([expect.any(Function), { isDimensionComplete: true }]);
expect(setState.mock.calls[0][0](defaultProps.state)).toEqual({
...state,
layers: {
diff --git a/x-pack/plugins/lens/public/types.ts b/x-pack/plugins/lens/public/types.ts
index 1c20e306b2e8a..b421d57dae6e1 100644
--- a/x-pack/plugins/lens/public/types.ts
+++ b/x-pack/plugins/lens/public/types.ts
@@ -306,8 +306,7 @@ export type DatasourceDimensionEditorProps = DatasourceDimensionPro
setState: (
newState: Parameters>[0],
publishToVisualization?: {
- shouldReplaceDimension?: boolean;
- shouldRemoveDimension?: boolean;
+ isDimensionComplete?: boolean;
}
) => void;
core: Pick;
diff --git a/x-pack/test/functional/apps/lens/smokescreen.ts b/x-pack/test/functional/apps/lens/smokescreen.ts
index 4c8d642e7feb9..418f39682f8b4 100644
--- a/x-pack/test/functional/apps/lens/smokescreen.ts
+++ b/x-pack/test/functional/apps/lens/smokescreen.ts
@@ -588,6 +588,57 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
);
});
+ it('should not leave an incomplete column in the visualization config with field-based operation', async () => {
+ await PageObjects.visualize.navigateToNewVisualization();
+ await PageObjects.visualize.clickVisType('lens');
+ await PageObjects.lens.goToTimeRange();
+
+ await PageObjects.lens.configureDimension({
+ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
+ operation: 'minimum',
+ });
+
+ expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql(
+ undefined
+ );
+ });
+
+ it('should not leave an incomplete column in the visualization config with reference-based operations', async () => {
+ await PageObjects.visualize.navigateToNewVisualization();
+ await PageObjects.visualize.clickVisType('lens');
+ await PageObjects.lens.goToTimeRange();
+
+ await PageObjects.lens.configureDimension({
+ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
+ operation: 'date_histogram',
+ field: '@timestamp',
+ });
+ await PageObjects.lens.configureDimension({
+ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
+ operation: 'moving_average',
+ field: 'Records',
+ });
+
+ expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql(
+ 'Moving average of Count of records'
+ );
+
+ await PageObjects.lens.configureDimension({
+ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger',
+ operation: 'median',
+ isPreviousIncompatible: true,
+ keepOpen: true,
+ });
+
+ expect(await PageObjects.lens.isDimensionEditorOpen()).to.eql(true);
+
+ await PageObjects.lens.closeDimensionEditor();
+
+ expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql(
+ undefined
+ );
+ });
+
it('should transition from unique count to last value', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
diff --git a/x-pack/test/functional/page_objects/lens_page.ts b/x-pack/test/functional/page_objects/lens_page.ts
index 60891caeccfb0..ac522f0c2b26d 100644
--- a/x-pack/test/functional/page_objects/lens_page.ts
+++ b/x-pack/test/functional/page_objects/lens_page.ts
@@ -389,6 +389,18 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
});
},
+ async isDimensionEditorOpen() {
+ return await testSubjects.exists('lns-indexPattern-dimensionContainerBack');
+ },
+
+ // closes the dimension editor flyout
+ async closeDimensionEditor() {
+ await retry.try(async () => {
+ await testSubjects.click('lns-indexPattern-dimensionContainerBack');
+ await testSubjects.missingOrFail('lns-indexPattern-dimensionContainerBack');
+ });
+ },
+
async enableTimeShift() {
await testSubjects.click('indexPattern-advanced-popover');
await retry.try(async () => {
@@ -408,14 +420,6 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
await testSubjects.click('errorFixAction');
},
- // closes the dimension editor flyout
- async closeDimensionEditor() {
- await retry.try(async () => {
- await testSubjects.click('lns-indexPattern-dimensionContainerBack');
- await testSubjects.missingOrFail('lns-indexPattern-dimensionContainerBack');
- });
- },
-
async isTopLevelAggregation() {
return await testSubjects.isEuiSwitchChecked('indexPattern-nesting-switch');
},