Skip to content

Commit

Permalink
fix some CI steps
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Sep 15, 2022
1 parent a78a867 commit be509cb
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ const InContextMenuActions = (
actions: LayerButtonsAction[];
}
) => {
const dataTestSubject = 'lnsLayerSplitButton';
const [isPopoverOpen, setPopover] = useState(false);
const splitButtonPopoverId = useGeneratedHtmlId({
prefix: 'splitButtonPopover',
prefix: dataTestSubject,
});

const onButtonClick = useCallback(() => {
Expand All @@ -57,7 +58,7 @@ const InContextMenuActions = (
const items = props.actions.map((i) => (
<EuiContextMenuItem
icon={<EuiIcon type={i.icon} title={i.displayName} color={i.color} />}
data-test-subj="lnsLayerClone"
data-test-subj={i['data-test-subj']}
aria-label={i.displayName}
title={i.displayName}
onClick={() => {
Expand All @@ -83,6 +84,7 @@ const InContextMenuActions = (
defaultMessage: `Layer actions`,
})}
onClick={onButtonClick}
data-test-subj={dataTestSubject}
/>
}
ownFocus={true}
Expand Down Expand Up @@ -124,13 +126,19 @@ export const LayerButtons = (props: LayerButtonsProps) => {
if (compatibleActions.length > 1) {
return <InContextMenuActions {...props} actions={compatibleActions} />;
} else {
const { displayName, execute, icon, color } = compatibleActions[0];
const {
displayName,
execute,
icon,
color,
'data-test-subj': dataTestSubj,
} = compatibleActions[0];
return (
<EuiButtonIcon
size="xs"
iconType={icon}
color={color}
data-test-subj="lnsLayerRemove"
data-test-subj={dataTestSubj}
aria-label={displayName}
title={displayName}
onClick={execute}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
IUiSettingsClient,
SavedObjectsClientContract,
HttpSetup,
CoreSetup,
CoreStart,
} from '@kbn/core/public';
import { IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
import { generateId } from '../../id_generator';
Expand Down Expand Up @@ -240,7 +240,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
},
},
} as unknown as DataPublicPluginStart,
core: {} as CoreSetup,
core: {} as CoreStart,
dimensionGroups: [],
groupId: 'a',
isFullscreen: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks';
describe('Fields Accordion', () => {
let defaultProps: FieldsAccordionProps;
let indexPattern: IndexPattern;
let core: ReturnType<typeof coreMock['createSetup']>;
let core: ReturnType<typeof coreMock['createStart']>;
let fieldProps: FieldItemSharedProps;

beforeEach(() => {
Expand All @@ -42,7 +42,7 @@ describe('Fields Accordion', () => {
},
],
} as IndexPattern;
core = coreMock.createSetup();
core = coreMock.createStart();
core.http.post.mockClear();

fieldProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export function getIndexPatternDatasource({
},

cloneLayer(state: IndexPatternPrivateState, layerId: string, newLayerId: string) {
console.log('data source: clone layer');
// @todo: wip
return {
...state,
layers: {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/mocks/datasource_mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function createMockDatasource(id: string): DatasourceMock {
toExpression: jest.fn((_frame, _state, _indexPatterns) => null),
insertLayer: jest.fn((_state, _newLayerId) => ({})),
removeLayer: jest.fn((_state, _layerId) => {}),
cloneLayer: jest.fn((_state, _layerId, _newLayerId) => {}),
removeColumn: jest.fn((props) => {}),
getLayers: jest.fn((_state) => []),
uniqueLabels: jest.fn((_state) => ({})),
Expand Down
21 changes: 5 additions & 16 deletions x-pack/plugins/lens/public/state_management/lens_slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,18 @@ export const makeLensReducer = (storeDeps: LensStoreDeps) => {
};
}
) => {
// @todo: wip

if (!state.activeDatasourceId || !state.visualization.activeId) {
return state;
}

const activeVisualization = visualizationMap[state.visualization.activeId];
const activeDatasource = datasourceMap[state.activeDatasourceId];
// reuse the active datasource dataView id for the new layer
const currentDataViewsId = activeDatasource.getCurrentIndexPatternId(
state.datasourceStates[state.activeDatasourceId!].state
);
// const currentDataViewsId = activeDatasource.getCurrentIndexPatternId(
// state.datasourceStates[state.activeDatasourceId!].state
// );

const layerType = getLayerType(activeVisualization, state.visualization.state, layerId);

Expand All @@ -320,8 +322,6 @@ export const makeLensReducer = (storeDeps: LensStoreDeps) => {
}
);

console.log(state.datasourceStates);

const { activeDatasourceState, activeVisualizationState } = addInitialValueIfAvailable({
datasourceState: state.datasourceStates[state.activeDatasourceId].state,
visualizationState: state.visualization.state,
Expand All @@ -332,17 +332,6 @@ export const makeLensReducer = (storeDeps: LensStoreDeps) => {
layerType,
});

console.log({
activeDatasourceState,
activeVisualizationState,
activeVisualization,
currentDataViewsId,
visualizationId,
layerId,
state,
newLayerId,
});

state.visualization.state = activeVisualizationState;
state.datasourceStates[state.activeDatasourceId].state = activeDatasourceState;
state.stagedPreview = undefined;
Expand Down
3 changes: 3 additions & 0 deletions x-pack/test/functional/page_objects/lens_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,9 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
/** resets visualization/layer or removes a layer */
async removeLayer(index: number = 0) {
await retry.try(async () => {
if (await testSubjects.exists('lnsLayerSplitButton')) {
await testSubjects.click('lnsLayerSplitButton');
}
await testSubjects.click(`lnsLayerRemove--${index}`);
if (await testSubjects.exists('lnsLayerRemoveModal')) {
await testSubjects.exists('lnsLayerRemoveConfirmButton');
Expand Down

0 comments on commit be509cb

Please sign in to comment.