Skip to content

Commit

Permalink
[7.x] [ML] Fix functional tests for index based Data Visualizer (#86071
Browse files Browse the repository at this point in the history
…) (#86408)

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
qn895 and kibanamachine authored Dec 18, 2020
1 parent e86d30d commit 7fba080
Show file tree
Hide file tree
Showing 13 changed files with 388 additions and 461 deletions.
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

0 comments on commit 7fba080

Please sign in to comment.