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] Adds functional tests for the index data visualizer card contents #83174

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 6 additions & 7 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,12 @@
"data.search.unableToGetSavedQueryToastTitle": "保存したクエリ {savedQueryId} を読み込めません",
"data.search.upgradeLicense": "クエリがタイムアウトしました。無料のベーシックティアではクエリがタイムアウトすることはありません。",
"data.search.upgradeLicenseActionText": "今すぐアップグレード",
"data.search.functions.kibana_context.filters.help": "Kibana ジェネリックフィルターを指定します",
"data.search.functions.kibana_context.help": "Kibana グローバルコンテキストを更新します",
"data.search.functions.kibana_context.q.help": "自由形式の Kibana テキストクエリを指定します",
"data.search.functions.kibana_context.savedSearchId.help": "クエリとフィルターに使用する保存検索ID を指定します。",
"data.search.functions.kibana_context.timeRange.help": "Kibana 時間範囲フィルターを指定します",
"data.search.functions.kibana.help": "Kibana グローバルコンテキストを取得します",
"devTools.badge.readOnly.text": "読み込み専用",
"devTools.badge.readOnly.tooltip": "を保存できませんでした",
"devTools.devToolsTitle": "開発ツール",
Expand Down Expand Up @@ -1662,12 +1668,6 @@
"expressions.functions.font.invalidFontWeightErrorMessage": "無効なフォント太さ:'{weight}'",
"expressions.functions.font.invalidTextAlignmentErrorMessage": "無効なテキストアラインメント:'{align}'",
"expressions.functions.fontHelpText": "フォントスタイルを作成します。",
"data.search.functions.kibana_context.filters.help": "Kibana ジェネリックフィルターを指定します",
"data.search.functions.kibana_context.help": "Kibana グローバルコンテキストを更新します",
"data.search.functions.kibana_context.q.help": "自由形式の Kibana テキストクエリを指定します",
"data.search.functions.kibana_context.savedSearchId.help": "クエリとフィルターに使用する保存検索ID を指定します。",
"data.search.functions.kibana_context.timeRange.help": "Kibana 時間範囲フィルターを指定します",
"data.search.functions.kibana.help": "Kibana グローバルコンテキストを取得します",
"expressions.functions.theme.args.defaultHelpText": "テーマ情報がない場合のデフォルト値。",
"expressions.functions.theme.args.variableHelpText": "読み取るテーマ変数名。",
"expressions.functions.themeHelpText": "テーマ設定を読み取ります。",
Expand Down Expand Up @@ -12273,7 +12273,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
13 changes: 6 additions & 7 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,12 @@
"data.search.unableToGetSavedQueryToastTitle": "无法加载已保存查询 {savedQueryId}",
"data.search.upgradeLicense": "您的查询已超时。使用我们免费的基础级许可,您的查询永不会超时。",
"data.search.upgradeLicenseActionText": "立即升级",
"data.search.functions.kibana_context.filters.help": "指定 Kibana 常规筛选",
"data.search.functions.kibana_context.help": "更新 kibana 全局上下文",
"data.search.functions.kibana_context.q.help": "指定 Kibana 自由格式文本查询",
"data.search.functions.kibana_context.savedSearchId.help": "指定要用于查询和筛选的已保存搜索 ID",
"data.search.functions.kibana_context.timeRange.help": "指定 Kibana 时间范围筛选",
"data.search.functions.kibana.help": "获取 kibana 全局上下文",
"devTools.badge.readOnly.text": "只读",
"devTools.badge.readOnly.tooltip": "无法保存",
"devTools.devToolsTitle": "开发工具",
Expand Down Expand Up @@ -1663,12 +1669,6 @@
"expressions.functions.font.invalidFontWeightErrorMessage": "无效的字体粗细:“{weight}”",
"expressions.functions.font.invalidTextAlignmentErrorMessage": "无效的文本对齐方式:“{align}”",
"expressions.functions.fontHelpText": "创建字体样式。",
"data.search.functions.kibana_context.filters.help": "指定 Kibana 常规筛选",
"data.search.functions.kibana_context.help": "更新 kibana 全局上下文",
"data.search.functions.kibana_context.q.help": "指定 Kibana 自由格式文本查询",
"data.search.functions.kibana_context.savedSearchId.help": "指定要用于查询和筛选的已保存搜索 ID",
"data.search.functions.kibana_context.timeRange.help": "指定 Kibana 时间范围筛选",
"data.search.functions.kibana.help": "获取 kibana 全局上下文",
"expressions.functions.theme.args.defaultHelpText": "主题信息不可用时的默认值。",
"expressions.functions.theme.args.variableHelpText": "要读取的主题变量的名称。",
"expressions.functions.themeHelpText": "读取主题设置。",
Expand Down Expand Up @@ -12287,7 +12287,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