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

[Discover] Unskip Discover-Lens functional test suite #200687

Merged
merged 6 commits into from
Nov 20, 2024
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
34 changes: 32 additions & 2 deletions src/plugins/unified_histogram/public/chart/histogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -204,6 +230,10 @@ export function Histogram({
}
`;

if (!checkValidDataViewConfig(dataView, visContext, lensProps.attributes.state.adHocDataViews)) {
return <></>;
Copy link
Member Author

@kertal kertal Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jughosta do we have an alternative here? we need to prevent the rendering for the flaky case, should we render something, given we move forward with this PR (it woulld need to be investigated or refactored later on, since the given state causing the flakiness ideally should not happen)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have an alternative right now. What I've tried was causing other test failures and extra fetches. So let's go with your solution.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so we should open an issue to remove this code, given we resolve the root cause, which might be a bigger refactoring

}

return (
<>
<div
Expand Down
7 changes: 3 additions & 4 deletions test/functional/apps/discover/group3/_lens_vis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');

Expand Down