Skip to content
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 @@ -337,7 +337,8 @@ export class DiscoverApp {
async selectTextBaseLang() {
if (await this.page.testSubj.isEnabled('select-text-based-language-btn')) {
await this.page.testSubj.click('select-text-based-language-btn');
await this.waitForDocTableRendered();
await this.waitUntilSearchingHasFinished();
await this.codeEditor.waitCodeEditorReady('ESQLEditor');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { dataViewMock } from '@kbn/discover-utils/src/__mocks__';
import { DataSourceCategory } from '../../../../profiles';
import type { DefaultAppStateExtension, DefaultAppStateExtensionParams } from '../../../../types';
import { getDefaultAppState } from './get_default_app_state';

const createGetDefaultAppState = (prevAppState: DefaultAppStateExtension) =>
getDefaultAppState(() => prevAppState, {
context: {
category: DataSourceCategory.Metrics,
},
});

describe('getDefaultAppState', () => {
it('preserves the previous app state while applying the metrics defaults', () => {
const params: DefaultAppStateExtensionParams = { dataView: dataViewMock };
const prevAppState: DefaultAppStateExtension = {
breakdownField: 'host.name',
columns: [{ name: 'host.name' }],
rowHeight: 3,
};

const appState = createGetDefaultAppState(prevAppState)(params);

expect(appState).toEqual({
...prevAppState,
hideChart: false,
hideTable: true,
});
});

it('overrides previous chart visibility state with metrics defaults', () => {
const params: DefaultAppStateExtensionParams = { dataView: dataViewMock };
const prevAppState: DefaultAppStateExtension = {
hideChart: true,
hideTable: false,
};

const appState = createGetDefaultAppState(prevAppState)(params);

expect(appState).toEqual({
hideChart: false,
hideTable: true,
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { MetricsExperienceDataSourceProfileProvider } from '../profile';

export const getDefaultAppState: NonNullable<
MetricsExperienceDataSourceProfileProvider['profile']['getDefaultAppState']
> = (prev) => (params) => ({
...prev(params),
hideChart: false,
hideTable: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { METRICS_EXPERIENCE_PRODUCT_FEATURE_ID } from '../../../../../common/con
import type { DataSourceProfileProvider } from '../../../profiles';
import { DataSourceCategory, SolutionType } from '../../../profiles';
import { createChartSection } from './accessor/chart_section';
import { getDefaultAppState } from './accessor/get_default_app_state';

export type MetricsExperienceDataSourceProfileProvider = DataSourceProfileProvider<{}>;

Expand All @@ -26,6 +27,7 @@ export const createMetricsDataSourceProfileProvider =
restrictedToProductFeature: METRICS_EXPERIENCE_PRODUCT_FEATURE_ID,
profile: {
getChartSectionConfiguration: createChartSection(),
getDefaultAppState,
},
resolve: async ({ query, rootContext }) => {
if (!isQuerySupported(query) || !isSolutionValid(rootContext.solutionType)) {
Expand Down
Loading