[Infra Monitoring UI] fix query suggestions, add and comment in tests (#137908) (#138006)

* fix query suggestions, add and comment in tests

* test commenting out failing test

* comment out the tooltip test for now

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 73702ee857)

Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2022-08-03 12:58:00 -04:00 committed by GitHub
parent a953c139a4
commit 90136903b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 13 deletions

View file

@ -14,7 +14,8 @@
"alerting",
"triggersActionsUi",
"observability",
"ruleRegistry"
"ruleRegistry",
"unifiedSearch"
],
"optionalPlugins": ["ml", "home", "embeddable", "osquery"],
"server": true,

View file

@ -76,7 +76,7 @@ export class AutocompleteField extends React.Component<
data-test-subj="infraSearchField"
/>
{areSuggestionsVisible && !isLoadingSuggestions && suggestions.length > 0 ? (
<SuggestionsPanel>
<SuggestionsPanel data-test-subj="infraSuggestionsPanel">
{suggestions.map((suggestion, suggestionIndex) => (
<SuggestionItem
key={suggestion.text}

View file

@ -13,13 +13,12 @@ import {
KibanaServices,
} from '@kbn/kibana-react-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import { QuerySuggestion, UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import { QuerySuggestion } from '@kbn/unified-search-plugin/public';
import { RendererFunction } from '../utils/typed_react';
import { InfraClientStartDeps } from '../types';
interface WithKueryAutocompletionLifecycleProps {
kibana: KibanaReactContextValue<
{ unifiedSearch: UnifiedSearchPublicPluginStart } & KibanaServices
>;
kibana: KibanaReactContextValue<InfraClientStartDeps & KibanaServices>;
children: RendererFunction<{
isLoadingSuggestions: boolean;
loadSuggestions: (expression: string, cursorPosition: number, maxSuggestions?: number) => void;
@ -66,7 +65,7 @@ class WithKueryAutocompletionComponent extends React.Component<
const { indexPattern } = this.props;
const language = 'kuery';
const hasQuerySuggestions =
this.props.kibana.services.unifiedSearch?.autocomplete.hasQuerySuggestions(language);
this.props.kibana.services.unifiedSearch.autocomplete.hasQuerySuggestions(language);
if (!hasQuerySuggestions) {
return;

View file

@ -6,6 +6,7 @@
*/
import type { CoreSetup, CoreStart, Plugin as PluginClass } from '@kbn/core/public';
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import type { IHttpFetchError } from '@kbn/core-http-browser';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
@ -62,6 +63,7 @@ export interface InfraClientSetupDeps {
export interface InfraClientStartDeps {
data: DataPublicPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
dataViews: DataViewsPublicPluginStart;
observability: ObservabilityPublicStart;
spaces: SpacesPluginStart;

View file

@ -17,8 +17,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const retry = getService('retry');
const pageObjects = getPageObjects(['common', 'infraHome', 'infraSavedViews']);
// Failing: See https://github.com/elastic/kibana/issues/106650
describe.skip('Home page', function () {
describe('Home page', function () {
this.tags('includeFirefox');
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/empty_kibana');
@ -51,11 +50,17 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.infraHome.goToTime(DATE_WITHOUT_DATA);
await pageObjects.infraHome.getNoMetricsDataPrompt();
});
it('renders the waffle map and tooltips for dates with data', async () => {
await pageObjects.infraHome.goToTime(DATE_WITH_DATA);
await pageObjects.infraHome.getWaffleMap();
await pageObjects.infraHome.getWaffleMapTooltips();
// await pageObjects.infraHome.getWaffleMapTooltips(); see https://github.com/elastic/kibana/issues/137903
});
it('shows query suggestions', async () => {
await pageObjects.infraHome.goToTime(DATE_WITH_DATA);
await pageObjects.infraHome.clickQueryBar();
await pageObjects.infraHome.inputQueryData();
await pageObjects.infraHome.ensureSuggestionsPanelVisible();
await pageObjects.infraHome.clearSearchTerm();
});
it('sort nodes by descending value', async () => {
@ -169,8 +174,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.infraHome.ensurePopoverClosed();
});
});
describe('Saved Views', () => {
// Failing: See https://github.com/elastic/kibana/issues/106650
describe.skip('Saved Views', () => {
before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'));
after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'));
it('should have save and load controls', async () => {

View file

@ -354,5 +354,18 @@ export function InfraHomePageProvider({ getService, getPageObjects }: FtrProvide
async clickGuidedSetupButton() {
await testSubjects.click('guidedSetupButton');
},
async clickQueryBar() {
await testSubjects.click('infraSearchField');
},
async inputQueryData() {
const queryBar = await testSubjects.find('infraSearchField');
await queryBar.type('h');
},
async ensureSuggestionsPanelVisible() {
await testSubjects.find('infraSuggestionsPanel');
},
};
}