Skip to content

Commit

Permalink
[ML] Adds functional tests for the index data visualizer card contents (
Browse files Browse the repository at this point in the history
#83174)

* [ML] Adds functional tests for the index data visualizer card contents

* [ML] Fix translations

* [ML] Fix type errors in permissions tests

* [ML] Address comments from review
  • Loading branch information
peteharverson authored Nov 13, 2020
1 parent 4dd25fa commit dde2d11
Show file tree
Hide file tree
Showing 18 changed files with 365 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const DateContent: FC<FieldDataCardProps> = ({ config }) => {
return (
<div className="mlFieldDataCard__stats">
<div>
<EuiText size="xs" color="subdued">
<EuiText size="xs" color="subdued" data-test-subj="mlFieldDataCardDocCount">
<EuiIcon type="document" />
&nbsp;
<FormattedMessage
Expand All @@ -41,7 +41,7 @@ export const DateContent: FC<FieldDataCardProps> = ({ config }) => {

<EuiSpacer size="m" />

<div>
<div data-test-subj="mlFieldDataCardEarliest">
<FormattedMessage
id="xpack.ml.fieldDataCard.cardDate.earliestDescription"
defaultMessage="earliest {earliestFormatted}"
Expand All @@ -53,7 +53,7 @@ export const DateContent: FC<FieldDataCardProps> = ({ config }) => {

<EuiSpacer size="s" />

<div>
<div data-test-subj="mlFieldDataCardLatest">
<FormattedMessage
id="xpack.ml.fieldDataCard.cardDate.latestDescription"
defaultMessage="latest {latestFormatted}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const KeywordContent: FC<FieldDataCardProps> = ({ config }) => {
return (
<div className="mlFieldDataCard__stats">
<div>
<EuiText size="xs" color="subdued">
<EuiText size="xs" color="subdued" data-test-subj="mlFieldDataCardDocCount">
<EuiIcon type="document" />
&nbsp;
<FormattedMessage
Expand All @@ -41,7 +41,7 @@ export const KeywordContent: FC<FieldDataCardProps> = ({ config }) => {
<EuiSpacer size="xs" />

<div>
<EuiText size="xs" color="subdued">
<EuiText size="xs" color="subdued" data-test-subj="mlFieldDataCardCardinality">
<EuiIcon type="database" />
&nbsp;
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ import {
} from '../metric_distribution_chart';
import { TopValues } from '../top_values';

enum DETAILS_MODE {
DISTRIBUTION = 'distribution',
TOP_VALUES = 'top_values',
}
const DETAILS_MODE = {
DISTRIBUTION: 'distribution',
TOP_VALUES: 'top_values',
} as const;

type DetailsModeType = typeof DETAILS_MODE[keyof typeof DETAILS_MODE];

const METRIC_DISTRIBUTION_CHART_WIDTH = 325;
const METRIC_DISTRIBUTION_CHART_HEIGHT = 210;
Expand Down Expand Up @@ -76,7 +78,7 @@ export const NumberContent: FC<FieldDataCardProps> = ({ config }) => {
return (
<div className="mlFieldDataCard__stats">
<div>
<EuiText size="xs" color="subdued">
<EuiText size="xs" color="subdued" data-test-subj="mlFieldDataCardDocCount">
<EuiIcon type="document" />
&nbsp;
<FormattedMessage
Expand All @@ -91,7 +93,7 @@ export const NumberContent: FC<FieldDataCardProps> = ({ config }) => {
</div>
<EuiSpacer size="xs" />
<div>
<EuiText size="xs" color="subdued">
<EuiText size="xs" color="subdued" data-test-subj="mlFieldDataCardCardinality">
<EuiIcon type="database" />
&nbsp;
<FormattedMessage
Expand Down Expand Up @@ -131,28 +133,28 @@ export const NumberContent: FC<FieldDataCardProps> = ({ config }) => {
</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexGroup gutterSize="xs" justifyContent="center">
<EuiFlexItem grow={1} className="eui-textTruncate">
<EuiFlexItem grow={1} className="eui-textTruncate" data-test-subj="mlFieldDataCardMin">
<DisplayValue value={kibanaFieldFormat(min, fieldFormat)} />
</EuiFlexItem>
<EuiFlexItem grow={1} className="eui-textTruncate">
<EuiFlexItem grow={1} className="eui-textTruncate" data-test-subj="mlFieldDataCardMedian">
<DisplayValue value={kibanaFieldFormat(median, fieldFormat)} />
</EuiFlexItem>
<EuiFlexItem grow={1} className="eui-textTruncate">
<EuiFlexItem grow={1} className="eui-textTruncate" data-test-subj="mlFieldDataCardMax">
<DisplayValue value={kibanaFieldFormat(max, fieldFormat)} />
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="s" />
<EuiButtonGroup
options={detailsOptions}
idSelected={detailsMode}
onChange={(optionId) => setDetailsMode(optionId as DETAILS_MODE)}
onChange={(optionId) => setDetailsMode(optionId as DetailsModeType)}
legend={i18n.translate(
'xpack.ml.fieldDataCard.cardNumber.selectMetricDetailsDisplayAriaLabel',
{
defaultMessage: 'Select display option for metric details',
}
)}
data-test-subj="mlFieldDataCardNumberDetailsSelect"
data-test-subj="mlFieldDataCardDetailsSelect"
isFullWidth={true}
buttonSize="compressed"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const DocumentCountChart: FC<Props> = ({
const EVENT_RATE_COLOR = themeName.euiColorVis2;

return (
<div style={{ width, height }}>
<div style={{ width, height }} data-test-subj="mlFieldDataCardDocumentCountChart">
<Chart>
<Settings
xDomain={xDomain}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const ExamplesList: FC<Props> = ({ examples }) => {
});

return (
<div>
<div data-test-subj="mlFieldDataCardExamplesList">
<EuiTitle size="xxxs" className="mlFieldDataCard__valuesTitle">
<span>
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const FieldDataCard: FC<FieldDataCardProps> = ({ config }) => {
hasShadow={false}
>
<FieldTitleBar card={config} />
<div className="mlFieldDataCard__content">
<div className="mlFieldDataCard__content" data-test-subj="mlFieldDataCardContent">
{loading === true ? <LoadingIndicator /> : getCardContent()}
</div>
</EuiPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const MetricDistributionChart: FC<Props> = ({ width, height, chartData, f
};

return (
<div style={{ width, height }}>
<div style={{ width, height }} data-test-subj="mlFieldDataCardMetricDistributionChart">
<Chart>
<Settings
theme={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor }) => {
const progressBarMax = isTopValuesSampled === true ? topValuesSampleSize : count;

return (
<Fragment>
<div data-test-subj="mlFieldDataCardTopValues">
{topValues.map((value: any) => (
<EuiFlexGroup gutterSize="xs" alignItems="center" key={value.key}>
<EuiFlexItem grow={false} style={{ width: 100 }} className="eui-textTruncate">
Expand All @@ -55,7 +55,7 @@ export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor }) => {
</EuiText>
</EuiToolTip>
</EuiFlexItem>
<EuiFlexItem>
<EuiFlexItem data-test-subj="mlFieldDataCardTopValueBar">
<EuiProgress value={value.doc_count} max={progressBarMax} color={barColor} size="m" />
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ width: 70 }} className="eui-textTruncate">
Expand All @@ -79,6 +79,6 @@ export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor }) => {
</EuiText>
</Fragment>
)}
</Fragment>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ const searchSizeOptions = [1000, 5000, 10000, 100000, -1].map((v) => {
value: String(v),
inputDisplay:
v > 0 ? (
<FormattedMessage
id="xpack.ml.datavisualizer.searchPanel.sampleSizeOptionLabel"
defaultMessage="Sample size (per shard): {wrappedValue}"
values={{ wrappedValue: <b>{v}</b> }}
/>
<span data-test-subj={`mlDataVisualizerShardSizeOption ${v}`}>
<FormattedMessage
id="xpack.ml.datavisualizer.searchPanel.sampleSizeOptionLabel"
defaultMessage="Sample size (per shard): {wrappedValue}"
values={{ wrappedValue: <b>{v}</b> }}
/>
</span>
) : (
<FormattedMessage
id="xpack.ml.datavisualizer.searchPanel.allOptionLabel"
defaultMessage="Search all"
/>
<span data-test-subj={`mlDataVisualizerShardSizeOption all`}>
<FormattedMessage
id="xpack.ml.datavisualizer.searchPanel.allOptionLabel"
defaultMessage="Search all"
/>
</span>
),
};
});
Expand Down Expand Up @@ -174,10 +178,18 @@ export const SearchPanel: FC<Props> = ({
<EuiFlexItem grow={false}>
<EuiText size="s">
<FormattedMessage
id="xpack.ml.datavisualizer.searchPanel.documentsPerShardLabel"
defaultMessage="Total documents: {wrappedTotalCount}"
id="xpack.ml.datavisualizer.searchPanel.totalDocCountLabel"
defaultMessage="Total documents: {strongTotalCount}"
values={{
wrappedTotalCount: <b data-test-subj="mlDataVisualizerTotalDocCount">{totalCount}</b>,
strongTotalCount: (
<strong data-test-subj="mlDataVisualizerTotalDocCount">
<FormattedMessage
id="xpack.ml.datavisualizer.searchPanel.totalDocCountNumber"
defaultMessage="{totalCount, plural, one {#} other {#}}"
values={{ totalCount }}
/>
</strong>
),
}}
/>
</EuiText>
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -12270,7 +12270,6 @@
"xpack.ml.datavisualizer.page.fieldsPanelTitle": "フィールド",
"xpack.ml.datavisualizer.page.metricsPanelTitle": "メトリック",
"xpack.ml.datavisualizer.searchPanel.allOptionLabel": "すべて検索",
"xpack.ml.datavisualizer.searchPanel.documentsPerShardLabel": "合計ドキュメント数: {wrappedTotalCount}",
"xpack.ml.datavisualizer.searchPanel.invalidKuerySyntaxErrorMessageQueryBar": "無効なクエリ",
"xpack.ml.datavisualizer.searchPanel.queryBarPlaceholder": "小さいサンプルサイズを選択することで、クエリの実行時間を短縮しクラスターへの負荷を軽減できます。",
"xpack.ml.datavisualizer.searchPanel.queryBarPlaceholderText": "検索… (例: status:200 AND extension:\"PHP\")",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -12284,7 +12284,6 @@
"xpack.ml.datavisualizer.page.fieldsPanelTitle": "字段",
"xpack.ml.datavisualizer.page.metricsPanelTitle": "指标",
"xpack.ml.datavisualizer.searchPanel.allOptionLabel": "搜索全部",
"xpack.ml.datavisualizer.searchPanel.documentsPerShardLabel": "文档总数:{wrappedTotalCount}",
"xpack.ml.datavisualizer.searchPanel.invalidKuerySyntaxErrorMessageQueryBar": "无效查询",
"xpack.ml.datavisualizer.searchPanel.queryBarPlaceholder": "选择较小的样例大小将减少查询运行时间和集群上的负载。",
"xpack.ml.datavisualizer.searchPanel.queryBarPlaceholderText": "搜索……(例如,status:200 AND extension:\"PHP\")",
Expand Down
Loading

0 comments on commit dde2d11

Please sign in to comment.