Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Fix functional tests for index based Data Visualizer #86071

Merged
merged 12 commits into from
Dec 17, 2020
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const MultiSelectPicker: FC<{

const button = (
<EuiFilterButton
data-test-subj={`${dataTestSubj}-button`}
iconType="arrowDown"
onClick={onButtonClick}
isSelected={isPopoverOpen}
Expand All @@ -98,32 +99,41 @@ export const MultiSelectPicker: FC<{
return (
<EuiFilterGroup data-test-subj={dataTestSubj}>
<EuiPopover
data-test-subj={`${dataTestSubj}-popover`}
id="popoverExampleMultiSelect"
button={button}
isOpen={isPopoverOpen}
closePopover={closePopover}
panelPaddingSize="none"
>
<EuiPopoverTitle paddingSize="s">
<EuiFieldSearch compressed onChange={(e) => setSearchTerm(e.target.value)} />
<EuiFieldSearch
compressed
onChange={(e) => setSearchTerm(e.target.value)}
data-test-subj={`${dataTestSubj}-searchInput`}
/>
</EuiPopoverTitle>
<div style={{ maxHeight: 250, overflow: 'auto' }}>
{Array.isArray(items) && items.length > 0 ? (
items.map((item, index) => (
<EuiFilterSelectItem
checked={
checkedOptions &&
checkedOptions.findIndex((fieldValue) => fieldValue === item.value) > -1
? 'on'
: undefined
}
key={index}
onClick={() => handleOnChange(index)}
style={{ flexDirection: 'row' }}
>
{item.name ?? item.value}
</EuiFilterSelectItem>
))
items.map((item, index) => {
const checked =
checkedOptions &&
checkedOptions.findIndex((fieldValue) => fieldValue === item.value) > -1;

return (
<EuiFilterSelectItem
checked={checked ? 'on' : undefined}
key={index}
onClick={() => handleOnChange(index)}
style={{ flexDirection: 'row' }}
data-test-subj={`${dataTestSubj}-option-${item.value}${
checked ? '-checked' : ''
}`}
>
{item.name ?? item.value}
</EuiFilterSelectItem>
);
})
) : (
<NoFilterItems />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const DocumentCountChart: FC<Props> = ({
const dateFormatter = niceTimeFormatter([timeRangeEarliest, timeRangeLatest]);

return (
<div style={{ width: width ?? '100%' }} data-test-subj="mlFieldDataCardDocumentCountChart">
<div style={{ width: width ?? '100%' }} data-test-subj="mlFieldDataDocumentCountChart">
<Chart
size={{
width: '100%',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const ExamplesList: FC<Props> = ({ examples }) => {
});

return (
<div data-test-subj="mlFieldDataCardExamplesList">
<div data-test-subj="mlFieldDataExamplesList">
<ExpandedRowFieldHeader>
<FormattedMessage
id="xpack.ml.fieldDataCard.examplesList.title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const MetricDistributionChart: FC<Props> = ({
};

return (
<div data-test-subj="mlFieldDataCardMetricDistributionChart">
<div data-test-subj="mlFieldDataMetricDistributionChart">
<Chart size={{ width, height }}>
<Settings
theme={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor, compressed
} = stats;
const progressBarMax = isTopValuesSampled === true ? topValuesSampleSize : count;
return (
<div data-test-subj="mlFieldDataCardTopValues">
<div data-test-subj="mlFieldDataTopValues">
{Array.isArray(topValues) &&
topValues.map((value: any) => (
<EuiFlexGroup gutterSize="xs" alignItems="center" key={value.key}>
Expand All @@ -64,7 +64,7 @@ export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor, compressed
</EuiText>
</EuiToolTip>
</EuiFlexItem>
<EuiFlexItem data-test-subj="mlFieldDataCardTopValueBar">
<EuiFlexItem data-test-subj="mlFieldDataTopValueBar">
<EuiProgress value={value.doc_count} max={progressBarMax} color={barColor} size="m" />
</EuiFlexItem>
<EuiFlexItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const NumberContentPreview: FC<FieldDataCardProps> = ({ config }) => {
const defaultChartData: MetricDistributionChartData[] = [];
const [distributionChartData, setDistributionChartData] = useState(defaultChartData);
const [legendText, setLegendText] = useState<{ min: number; max: number } | undefined>();
const dataTestSubj = fieldName;
const dataTestSubj = `mlDataGridChart-${fieldName}`;
useEffect(() => {
const chartData = buildChartDataFromStats(stats, METRIC_DISTRIBUTION_CHART_WIDTH);
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const DataVisualizerFieldExpandedRow = ({ item }: { item: FieldVisConfig
return (
<div
className="mlDataVisualizerFieldExpandedRow"
data-test-subj={`mlDataVisualizerFieldExpandedRow ${fieldName} ${type}`}
data-test-subj={`mlDataVisualizerFieldExpandedRow-${fieldName}`}
>
{loading === true ? <LoadingIndicator /> : getCardContent()}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const DataVisualizerDataGrid = ({
const direction = expandedRowItemIds.includes(item.fieldName) ? 'arrowUp' : 'arrowDown';
return (
<EuiButtonIcon
data-test-subj={`mlDataVisualizerToggleDetails ${item.fieldName} ${direction}`}
data-test-subj={`mlDataVisualizerDetailsToggle-${item.fieldName}-${direction}`}
onClick={() => toggleDetails(item)}
aria-label={
expandedRowItemIds.includes(item.fieldName)
Expand Down
Loading