mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Discover] Unskip Discover-Lens functional test suite (#200687)
Catching an invalid state of properties propagated to the UnifiedHistogram which is using the Lens embeddable in Discover, that causes a rendering error when e.g. ad hoc data views are being edited. Therefore the skipped testview can be unskipped.
This commit is contained in:
parent
0cafc7be9e
commit
e082cd1dfa
2 changed files with 35 additions and 6 deletions
|
@ -10,12 +10,12 @@
|
|||
import { useEuiTheme } from '@elastic/eui';
|
||||
import { css } from '@emotion/react';
|
||||
import React, { useState } from 'react';
|
||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||
import type { DataView, DataViewSpec } from '@kbn/data-views-plugin/public';
|
||||
import type { DefaultInspectorAdapters, Datatable } from '@kbn/expressions-plugin/common';
|
||||
import type { IKibanaSearchResponse } from '@kbn/search-types';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
import type { TimeRange } from '@kbn/es-query';
|
||||
import type {
|
||||
import {
|
||||
EmbeddableComponentProps,
|
||||
LensEmbeddableInput,
|
||||
LensEmbeddableOutput,
|
||||
|
@ -59,6 +59,32 @@ export interface HistogramProps {
|
|||
withDefaultActions: EmbeddableComponentProps['withDefaultActions'];
|
||||
}
|
||||
|
||||
/**
|
||||
* To prevent flakiness in the chart, we need to ensure that the data view config is valid.
|
||||
* This requires that there are not multiple different data view ids in the given configuration.
|
||||
* @param dataView
|
||||
* @param visContext
|
||||
* @param adHocDataViews
|
||||
*/
|
||||
const checkValidDataViewConfig = (
|
||||
dataView: DataView,
|
||||
visContext: UnifiedHistogramVisContext,
|
||||
adHocDataViews: { [key: string]: DataViewSpec } | undefined
|
||||
) => {
|
||||
if (!dataView.id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!dataView.isPersisted() && !adHocDataViews?.[dataView.id]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dataView.id !== visContext.requestData.dataViewId) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const computeTotalHits = (
|
||||
hasLensSuggestions: boolean,
|
||||
adapterTables:
|
||||
|
@ -204,6 +230,10 @@ export function Histogram({
|
|||
}
|
||||
`;
|
||||
|
||||
if (!checkValidDataViewConfig(dataView, visContext, lensProps.attributes.state.adHocDataViews)) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
|
|
|
@ -110,8 +110,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
return seriesType;
|
||||
}
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/184600
|
||||
describe.skip('discover lens vis', function () {
|
||||
describe('discover lens vis', function () {
|
||||
before(async () => {
|
||||
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']);
|
||||
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
|
||||
|
@ -655,8 +654,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await discover.waitUntilSearchingHasFinished();
|
||||
await testSubjects.missingOrFail('unsavedChangesBadge');
|
||||
|
||||
await discover.chooseLensSuggestion('pie');
|
||||
expect(await getCurrentVisTitle()).to.be('Pie');
|
||||
await discover.chooseLensSuggestion('waffle');
|
||||
expect(await getCurrentVisTitle()).to.be('Waffle');
|
||||
await testSubjects.existOrFail('partitionVisChart');
|
||||
expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue