[Lens][Unified Field list] Add functional tests to fields lists and summary popover (#143747)

* ♻️ Add testId handlers

*  Add functional tests

* 💄 Wrap unsupported messages with testId

* 🔧 Enable creation of dataViews without timefield

*  Extends tests for other dataview types + runtime fields

*  Add more checks on top values charts

* 👌 Integrated feedback

* 🐛 Fix testIds and added some logging
This commit is contained in:
Marco Liberati 2022-10-27 15:32:11 +02:00 committed by GitHub
parent 7bc63e07af
commit 2efad9d15a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 287 additions and 24 deletions

View file

@ -190,6 +190,9 @@ export const InnerFieldItem = function InnerFieldItem(props: FieldItemProps) {
initialFocus=".lnsFieldItem__fieldPanel"
className="lnsFieldItem__popoverAnchor"
data-test-subj="lnsFieldListPanelField"
panelProps={{
'data-test-subj': 'lnsFieldListPanelFieldContent',
}}
container={document.querySelector<HTMLElement>('.application') || undefined}
button={
<DragDrop
@ -331,26 +334,30 @@ function FieldItemPopoverContents(
field={dataViewField}
data-test-subj="lnsFieldListPanel"
overrideMissingContent={(params) => {
if (params?.noDataFound) {
if (params.reason === 'no-data') {
// TODO: should we replace this with a default message "Analysis is not available for this field?"
const isUsingSampling = core.uiSettings.get('lens:useFieldExistenceSampling');
return (
<>
<EuiText size="s">
{isUsingSampling
? i18n.translate('xpack.lens.indexPattern.fieldStatsSamplingNoData', {
defaultMessage:
'Lens is unable to create visualizations with this field because it does not contain data in the first 500 documents that match your filters. To create a visualization, drag and drop a different field.',
})
: i18n.translate('xpack.lens.indexPattern.fieldStatsNoData', {
defaultMessage:
'Lens is unable to create visualizations with this field because it does not contain data. To create a visualization, drag and drop a different field.',
})}
</EuiText>
</>
<EuiText size="s" data-test-subj="lnsFieldListPanel-missingFieldStats">
{isUsingSampling
? i18n.translate('xpack.lens.indexPattern.fieldStatsSamplingNoData', {
defaultMessage:
'Lens is unable to create visualizations with this field because it does not contain data in the first 500 documents that match your filters. To create a visualization, drag and drop a different field.',
})
: i18n.translate('xpack.lens.indexPattern.fieldStatsNoData', {
defaultMessage:
'Lens is unable to create visualizations with this field because it does not contain data. To create a visualization, drag and drop a different field.',
})}
</EuiText>
);
}
if (params.reason === 'unsupported') {
return (
<EuiText data-test-subj="lnsFieldListPanel-missingFieldStats">
{params.element}
</EuiText>
);
}
return params.element;
}}
/>

View file

@ -169,14 +169,18 @@ export const FieldsAccordion = memo(function InnerFieldsAccordion({
}
if (hasLoaded) {
return (
<EuiNotificationBadge size="m" color={isFiltered ? 'accent' : 'subdued'}>
<EuiNotificationBadge
size="m"
color={isFiltered ? 'accent' : 'subdued'}
data-test-subj={`${id}-count`}
>
{fieldsCount}
</EuiNotificationBadge>
);
}
return <EuiLoadingSpinner size="m" />;
}, [showExistenceFetchError, showExistenceFetchTimeout, hasLoaded, isFiltered, fieldsCount]);
}, [showExistenceFetchError, showExistenceFetchTimeout, hasLoaded, isFiltered, id, fieldsCount]);
return (
<EuiAccordion

View file

@ -49,14 +49,18 @@ export const FieldsAccordion = memo(function InnerFieldsAccordion({
const extraAction = useMemo(() => {
if (hasLoaded) {
return (
<EuiNotificationBadge size="m" color={isFiltered ? 'accent' : 'subdued'}>
<EuiNotificationBadge
size="m"
color={isFiltered ? 'accent' : 'subdued'}
data-test-subj={`${id}-count`}
>
{fields.length}
</EuiNotificationBadge>
);
}
return <EuiLoadingSpinner size="m" />;
}, [fields.length, hasLoaded, isFiltered]);
}, [fields.length, hasLoaded, id, isFiltered]);
return (
<>