Skip to content

Commit

Permalink
[Lens] adding some functional tests (elastic#77863) (elastic#77932)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra authored Sep 18, 2020
1 parent ebc6705 commit 7fe28c5
Show file tree
Hide file tree
Showing 13 changed files with 213 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const QueryInput = ({

return (
<QueryStringInput
dataTestSubj="indexPattern-filters-queryStringInput"
size="s"
isInvalid={isInvalid}
bubbleSubmitEvent={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import {
} from '@elastic/eui';

export const NewBucketButton = ({ label, onClick }: { label: string; onClick: () => void }) => (
<EuiButtonEmpty size="xs" iconType="plusInCircle" onClick={onClick}>
<EuiButtonEmpty
data-test-subj="lns-newBucket-add"
size="xs"
iconType="plusInCircle"
onClick={onClick}
>
{label}
</EuiButtonEmpty>
);
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/pie_visualization/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export function PieToolbar(props: VisualizationToolbarProps<PieVisualizationStat
})}
type="values"
groupPosition="left"
buttonDataTestSubj="lnsLabelsButton"
>
<EuiFormRow
label={i18n.translate('xpack.lens.pieChart.labelPositionLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const LegendSettingsPopover: React.FunctionComponent<LegendSettingsPopove
})}
type="legend"
groupPosition="right"
buttonDataTestSubj="lnsLegendButton"
>
<EuiFormRow
display="columnCompressed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type ToolbarButtonProps = PropsOf<typeof EuiButton> & {
* Adjusts the borders for groupings
*/
groupPosition?: 'none' | 'left' | 'center' | 'right';
dataTestSubj?: string;
};

export const ToolbarButton: React.FunctionComponent<ToolbarButtonProps> = ({
Expand All @@ -42,6 +43,7 @@ export const ToolbarButton: React.FunctionComponent<ToolbarButtonProps> = ({
size = 'm',
hasArrow = true,
groupPosition = 'none',
dataTestSubj = '',
...rest
}) => {
const classes = classNames(
Expand All @@ -52,6 +54,7 @@ export const ToolbarButton: React.FunctionComponent<ToolbarButtonProps> = ({
);
return (
<EuiButton
data-test-subj={dataTestSubj}
className={classes}
iconSide="right"
iconType={hasArrow ? 'arrowDown' : ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface ToolbarPopoverProps {
* Button group position
*/
groupPosition?: ToolbarButtonProps['groupPosition'];
buttonDataTestSubj?: string;
}

export const ToolbarPopover: React.FunctionComponent<ToolbarPopoverProps> = ({
Expand All @@ -39,6 +40,7 @@ export const ToolbarPopover: React.FunctionComponent<ToolbarPopoverProps> = ({
type,
isDisabled = false,
groupPosition,
buttonDataTestSubj,
}) => {
const [open, setOpen] = useState(false);

Expand All @@ -60,6 +62,7 @@ export const ToolbarPopover: React.FunctionComponent<ToolbarPopoverProps> = ({
hasArrow={false}
isDisabled={isDisabled}
groupPosition={groupPosition}
dataTestSubj={buttonDataTestSubj}
>
<EuiIcon type={iconType} />
</ToolbarButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ export interface AxisSettingsPopoverProps {
const popoverConfig = (
axis: AxesSettingsConfigKeys,
isHorizontal: boolean
): { icon: IconType; groupPosition: ToolbarButtonProps['groupPosition']; popoverTitle: string } => {
): {
icon: IconType;
groupPosition: ToolbarButtonProps['groupPosition'];
popoverTitle: string;
buttonDataTestSubj: string;
} => {
switch (axis) {
case 'yLeft':
return {
Expand All @@ -86,6 +91,7 @@ const popoverConfig = (
: i18n.translate('xpack.lens.xyChart.leftAxisLabel', {
defaultMessage: 'Left axis',
}),
buttonDataTestSubj: 'lnsLeftAxisButton',
};
case 'yRight':
return {
Expand All @@ -98,6 +104,7 @@ const popoverConfig = (
: i18n.translate('xpack.lens.xyChart.rightAxisLabel', {
defaultMessage: 'Right axis',
}),
buttonDataTestSubj: 'lnsRightAxisButton',
};
case 'x':
default:
Expand All @@ -111,6 +118,8 @@ const popoverConfig = (
: i18n.translate('xpack.lens.xyChart.bottomAxisLabel', {
defaultMessage: 'Bottom axis',
}),

buttonDataTestSubj: 'lnsBottomAxisButton',
};
}
};
Expand Down Expand Up @@ -143,6 +152,7 @@ export const AxisSettingsPopover: React.FunctionComponent<AxisSettingsPopoverPro
type={config.icon}
groupPosition={config.groupPosition}
isDisabled={isDisabled}
buttonDataTestSubj={config.buttonDataTestSubj}
>
<EuiFlexGroup gutterSize="s" justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export function XyToolbar(props: VisualizationToolbarProps<State>) {
isDisabled={!hasNonBarSeries}
type="values"
groupPosition="left"
buttonDataTestSubj="lnsMissingValuesButton"
>
<EuiFormRow
display="columnCompressed"
Expand All @@ -216,6 +217,7 @@ export function XyToolbar(props: VisualizationToolbarProps<State>) {
})}
>
<EuiSuperSelect
data-test-subj="lnsMissingValuesSelect"
compressed
options={fittingFunctionDefinitions.map(({ id, title, description }) => {
return {
Expand Down Expand Up @@ -488,6 +490,7 @@ const ColorPicker = ({

const colorPicker = (
<EuiColorPicker
data-test-subj="indexPattern-dimension-colorPicker"
compressed
isClearable
onChange={handleColor}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@ export default function ({ getPageObjects, getService }) {
operation: 'date_histogram',
field: '@timestamp',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
operation: 'avg',
field: 'bytes',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension',
operation: 'terms',
field: 'ip',
});
await PageObjects.lens.closeDimensionEditor();
await PageObjects.lens.save(title, saveAsNew, redirectToOrigin);
}

Expand Down
20 changes: 19 additions & 1 deletion x-pack/test/functional/apps/lens/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await find.clickByButtonText('lnsXYvis');
await dashboardAddPanel.closeAddPanel();
await PageObjects.lens.goToTimeRange();
await clickInChart(5, 5); // hardcoded position of bar
await clickInChart(5, 5); // hardcoded position of bar, depends heavy on data and charts implementation

await retry.try(async () => {
await testSubjects.click('applyFiltersPopoverButton');
Expand All @@ -68,5 +68,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const hasIpFilter = await filterBar.hasFilter('ip', '97.220.3.248');
expect(hasIpFilter).to.be(true);
});
it('should be able to add filters by clicking in pie chart', async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.clickNewDashboard();
await dashboardAddPanel.clickOpenAddPanel();
await dashboardAddPanel.filterEmbeddableNames('lnsPieVis');
await find.clickByButtonText('lnsPieVis');
await dashboardAddPanel.closeAddPanel();

await PageObjects.lens.goToTimeRange();
await clickInChart(5, 5); // hardcoded position of the slice, depends heavy on data and charts implementation

await PageObjects.lens.assertExactText(
'[data-test-subj="embeddablePanelHeading-lnsPieVis"]',
'lnsPieVis'
);
const hasGeoDestFilter = await filterBar.hasFilter('geo.dest', 'LS');
expect(hasGeoDestFilter).to.be(true);
});
});
}
3 changes: 3 additions & 0 deletions x-pack/test/functional/apps/lens/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
operation: 'date_histogram',
field: '@timestamp',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
operation: 'sum',
field: 'bytes',
});
await PageObjects.lens.closeDimensionEditor();

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension',
operation: 'terms',
field: 'geo.src',
});
await PageObjects.lens.closeDimensionEditor();
expect(await find.allByCssSelector('.echLegendItem')).to.have.length(2);

await PageObjects.lens.save('Afancilenstest');
Expand Down
Loading

0 comments on commit 7fe28c5

Please sign in to comment.