diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/index.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/consts.ts similarity index 84% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/index.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/consts.ts index 43465810bd33..84e03d9ab1e7 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/index.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/consts.ts @@ -7,4 +7,4 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export { createLogsDataSourceProfileProviders } from './create_profile_providers'; +export const OBSERVABILITY_ROOT_PROFILE_ID = 'observability-root-profile'; diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/accessors/get_doc_viewer.tsx b/src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/accessors/get_doc_viewer.tsx similarity index 100% rename from src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/accessors/get_doc_viewer.tsx rename to src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/accessors/get_doc_viewer.tsx diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/accessors/index.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/accessors/index.ts similarity index 100% rename from src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/accessors/index.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/accessors/index.ts diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/index.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/index.ts similarity index 86% rename from src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/index.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/index.ts index 2c9eb04083f4..f710dce3c998 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/index.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/index.ts @@ -7,4 +7,4 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export { createLogDocumentProfileProvider } from './profile'; +export { createObservabilityLogDocumentProfileProvider } from './profile'; diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/profile.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/profile.test.ts similarity index 69% rename from src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/profile.test.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/profile.test.ts index 394ccdf71da1..196eec475583 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/profile.test.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/profile.test.ts @@ -12,19 +12,28 @@ import { DocViewsRegistry } from '@kbn/unified-doc-viewer'; import { DataSourceCategory, DataSourceContext, + DocumentProfileProviderParams, DocumentType, RootContext, SolutionType, } from '../../../profiles'; import { createContextAwarenessMocks } from '../../../__mocks__'; -import { createLogDocumentProfileProvider } from './profile'; +import { createObservabilityLogDocumentProfileProvider } from './profile'; +import { ContextWithProfileId } from '../../../profile_service'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../consts'; const mockServices = createContextAwarenessMocks().profileProviderServices; describe('logDocumentProfileProvider', () => { - const logDocumentProfileProvider = createLogDocumentProfileProvider(mockServices); - const ROOT_CONTEXT: RootContext = { solutionType: SolutionType.Default }; - const DATA_SOURCE_CONTEXT: DataSourceContext = { category: DataSourceCategory.Logs }; + const logDocumentProfileProvider = createObservabilityLogDocumentProfileProvider(mockServices); + const ROOT_CONTEXT: ContextWithProfileId = { + profileId: OBSERVABILITY_ROOT_PROFILE_ID, + solutionType: SolutionType.Observability, + }; + const DATA_SOURCE_CONTEXT: ContextWithProfileId = { + profileId: 'data-source-profile', + category: DataSourceCategory.Logs, + }; const RESOLUTION_MATCH = { isMatch: true, context: { @@ -99,6 +108,42 @@ describe('logDocumentProfileProvider', () => { ).toEqual(RESOLUTION_MISMATCH); }); + it('does not match records when solution type is not Observability', () => { + const params: Omit = { + dataSourceContext: DATA_SOURCE_CONTEXT, + record: buildMockRecord('another-index', { + 'data_stream.type': ['logs'], + }), + }; + expect( + logDocumentProfileProvider.resolve({ + ...params, + rootContext: ROOT_CONTEXT, + }) + ).toEqual(RESOLUTION_MATCH); + expect( + logDocumentProfileProvider.resolve({ + ...params, + rootContext: { profileId: 'other-data-source-profile', solutionType: SolutionType.Default }, + }) + ).toEqual(RESOLUTION_MISMATCH); + expect( + logDocumentProfileProvider.resolve({ + ...params, + rootContext: { profileId: 'other-data-source-profile', solutionType: SolutionType.Search }, + }) + ).toEqual(RESOLUTION_MISMATCH); + expect( + logDocumentProfileProvider.resolve({ + ...params, + rootContext: { + profileId: 'other-data-source-profile', + solutionType: SolutionType.Security, + }, + }) + ).toEqual(RESOLUTION_MISMATCH); + }); + describe('getDocViewer', () => { it('adds a log overview doc view to the registry', () => { const getDocViewer = logDocumentProfileProvider.profile.getDocViewer!( diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/profile.tsx b/src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/profile.tsx similarity index 85% rename from src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/profile.tsx rename to src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/profile.tsx index 5ff4857b5bf7..e92bbb9a5960 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/log_document_profile/profile.tsx +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/log_document_profile/profile.tsx @@ -11,15 +11,20 @@ import { DataTableRecord } from '@kbn/discover-utils'; import { DocumentProfileProvider, DocumentType } from '../../../profiles'; import { ProfileProviderServices } from '../../profile_provider_services'; import { getDocViewer } from './accessors'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../consts'; -export const createLogDocumentProfileProvider = ( +export const createObservabilityLogDocumentProfileProvider = ( services: ProfileProviderServices ): DocumentProfileProvider => ({ - profileId: 'log-document-profile', + profileId: 'observability-log-document-profile', profile: { getDocViewer, }, - resolve: ({ record }) => { + resolve: ({ record, rootContext }) => { + if (rootContext.profileId !== OBSERVABILITY_ROOT_PROFILE_ID) { + return { isMatch: false }; + } + const isLogRecord = getIsLogRecord(record, services.logsContextService.isLogsIndexPattern); if (!isLogRecord) { diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_cell_renderers.tsx b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/accessors/get_cell_renderers.tsx similarity index 100% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_cell_renderers.tsx rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/accessors/get_cell_renderers.tsx diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_default_app_state.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/accessors/get_default_app_state.ts similarity index 100% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_default_app_state.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/accessors/get_default_app_state.ts diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_row_additional_leading_controls.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/accessors/get_row_additional_leading_controls.ts similarity index 100% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_row_additional_leading_controls.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/accessors/get_row_additional_leading_controls.ts diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_row_indicator_provider.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/accessors/get_row_indicator_provider.ts similarity index 100% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/get_row_indicator_provider.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/accessors/get_row_indicator_provider.ts diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/index.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/accessors/index.ts similarity index 100% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/accessors/index.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/accessors/index.ts diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/consts.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/consts.ts similarity index 100% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/consts.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/consts.ts diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/create_profile_providers.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/create_profile_providers.ts similarity index 93% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/create_profile_providers.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/create_profile_providers.ts index 57edf87e8115..4b4653824ed2 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/create_profile_providers.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/create_profile_providers.ts @@ -19,7 +19,9 @@ import { createWindowsLogsDataSourceProfileProvider, } from './sub_profiles'; -export const createLogsDataSourceProfileProviders = (providerServices: ProfileProviderServices) => { +export const createObservabilityLogsDataSourceProfileProviders = ( + providerServices: ProfileProviderServices +) => { const logsDataSourceProfileProvider = createLogsDataSourceProfileProvider(providerServices); return [ diff --git a/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/index.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/index.ts new file mode 100644 index 000000000000..b9d328c7346e --- /dev/null +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/index.ts @@ -0,0 +1,10 @@ +/* + * 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". + */ + +export { createObservabilityLogsDataSourceProfileProviders } from './create_profile_providers'; diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/profile.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/profile.test.ts similarity index 83% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/profile.test.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/profile.test.ts index 9e8f661a61a3..7740602203e5 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/profile.test.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/profile.test.ts @@ -11,11 +11,18 @@ import { buildDataTableRecord } from '@kbn/discover-utils'; import type { EuiThemeComputed } from '@elastic/eui'; import { createStubIndexPattern } from '@kbn/data-views-plugin/common/data_view.stub'; import { createDataViewDataSource, createEsqlDataSource } from '../../../../../common/data_sources'; -import { DataSourceCategory, RootContext, SolutionType } from '../../../profiles'; +import { + DataSourceCategory, + DataSourceProfileProviderParams, + RootContext, + SolutionType, +} from '../../../profiles'; import { createContextAwarenessMocks } from '../../../__mocks__'; import { createLogsDataSourceProfileProvider } from './profile'; import { DataGridDensity } from '@kbn/unified-data-table'; import { dataViewWithTimefieldMock } from '../../../../__mocks__/data_view_with_timefield'; +import type { ContextWithProfileId } from '../../../profile_service'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../consts'; const mockServices = createContextAwarenessMocks().profileProviderServices; @@ -24,7 +31,10 @@ describe('logsDataSourceProfileProvider', () => { const VALID_INDEX_PATTERN = 'logs-nginx.access-*'; const MIXED_INDEX_PATTERN = 'logs-nginx.access-*,metrics-*'; const INVALID_INDEX_PATTERN = 'my_source-access-*'; - const ROOT_CONTEXT: RootContext = { solutionType: SolutionType.Default }; + const ROOT_CONTEXT: ContextWithProfileId = { + profileId: OBSERVABILITY_ROOT_PROFILE_ID, + solutionType: SolutionType.Observability, + }; const RESOLUTION_MATCH = { isMatch: true, context: { category: DataSourceCategory.Logs }, @@ -87,6 +97,34 @@ describe('logsDataSourceProfileProvider', () => { ).toEqual(RESOLUTION_MISMATCH); }); + it('does NOT match data view sources when solution type is not Observability', () => { + const params: Omit = { + dataSource: createEsqlDataSource(), + query: { esql: `from ${VALID_INDEX_PATTERN}` }, + }; + expect(logsDataSourceProfileProvider.resolve({ ...params, rootContext: ROOT_CONTEXT })).toEqual( + RESOLUTION_MATCH + ); + expect( + logsDataSourceProfileProvider.resolve({ + ...params, + rootContext: { profileId: 'other-root-profile', solutionType: SolutionType.Default }, + }) + ).toEqual(RESOLUTION_MISMATCH); + expect( + logsDataSourceProfileProvider.resolve({ + ...params, + rootContext: { profileId: 'other-root-profile', solutionType: SolutionType.Search }, + }) + ).toEqual(RESOLUTION_MISMATCH); + expect( + logsDataSourceProfileProvider.resolve({ + ...params, + rootContext: { profileId: 'other-root-profile', solutionType: SolutionType.Security }, + }) + ).toEqual(RESOLUTION_MISMATCH); + }); + const dataViewWithLogLevel = createStubIndexPattern({ spec: { title: VALID_INDEX_PATTERN, diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/profile.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/profile.ts similarity index 85% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/profile.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/profile.ts index f2818c336bf4..bebd340acfb3 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/profile.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/profile.ts @@ -15,17 +15,22 @@ import { getRowAdditionalLeadingControls, } from './accessors'; import { extractIndexPatternFrom } from '../../extract_index_pattern_from'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../consts'; export const createLogsDataSourceProfileProvider = ( services: ProfileProviderServices ): DataSourceProfileProvider => ({ - profileId: 'logs-data-source-profile', + profileId: 'observability-logs-data-source-profile', profile: { getCellRenderers, getRowIndicatorProvider, getRowAdditionalLeadingControls, }, resolve: (params) => { + if (params.rootContext.profileId !== OBSERVABILITY_ROOT_PROFILE_ID) { + return { isMatch: false }; + } + const indexPattern = extractIndexPatternFrom(params); if (!services.logsContextService.isLogsIndexPattern(indexPattern)) { diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/apache_error_logs.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/apache_error_logs.test.ts similarity index 89% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/apache_error_logs.test.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/apache_error_logs.test.ts index bda23309baec..eda5127927ad 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/apache_error_logs.test.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/apache_error_logs.test.ts @@ -13,8 +13,13 @@ import { DataSourceCategory, RootContext, SolutionType } from '../../../../profi import { createContextAwarenessMocks } from '../../../../__mocks__'; import { createLogsDataSourceProfileProvider } from '../profile'; import { createApacheErrorLogsDataSourceProfileProvider } from './apache_error_logs'; +import type { ContextWithProfileId } from '../../../../profile_service'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts'; -const ROOT_CONTEXT: RootContext = { solutionType: SolutionType.Default }; +const ROOT_CONTEXT: ContextWithProfileId = { + profileId: OBSERVABILITY_ROOT_PROFILE_ID, + solutionType: SolutionType.Observability, +}; const { profileProviderServices } = createContextAwarenessMocks(); const logsDataSourceProfileProvider = createLogsDataSourceProfileProvider(profileProviderServices); const dataSourceProfileProvider = createApacheErrorLogsDataSourceProfileProvider( diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/apache_error_logs.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/apache_error_logs.ts similarity index 94% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/apache_error_logs.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/apache_error_logs.ts index 15e8dbc0cc99..a35c10e69dc0 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/apache_error_logs.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/apache_error_logs.ts @@ -17,7 +17,7 @@ export const createApacheErrorLogsDataSourceProfileProvider = ( logsDataSourceProfileProvider: DataSourceProfileProvider ): DataSourceProfileProvider => extendProfileProvider(logsDataSourceProfileProvider, { - profileId: 'apache-error-logs-data-source', + profileId: 'observability-apache-error-logs-data-source-profile', profile: { getDefaultAppState: createGetDefaultAppState({ defaultColumns: [LOG_LEVEL_COLUMN, CLIENT_IP_COLUMN, MESSAGE_COLUMN], diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/aws_s3access_logs.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/aws_s3access_logs.test.ts similarity index 90% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/aws_s3access_logs.test.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/aws_s3access_logs.test.ts index c95cc090195a..533e069c151e 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/aws_s3access_logs.test.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/aws_s3access_logs.test.ts @@ -13,8 +13,13 @@ import { DataSourceCategory, RootContext, SolutionType } from '../../../../profi import { createContextAwarenessMocks } from '../../../../__mocks__'; import { createLogsDataSourceProfileProvider } from '../profile'; import { createAwsS3accessLogsDataSourceProfileProvider } from './aws_s3access_logs'; +import type { ContextWithProfileId } from '../../../../profile_service'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts'; -const ROOT_CONTEXT: RootContext = { solutionType: SolutionType.Default }; +const ROOT_CONTEXT: ContextWithProfileId = { + profileId: OBSERVABILITY_ROOT_PROFILE_ID, + solutionType: SolutionType.Observability, +}; const { profileProviderServices } = createContextAwarenessMocks(); const logsDataSourceProfileProvider = createLogsDataSourceProfileProvider(profileProviderServices); const dataSourceProfileProvider = createAwsS3accessLogsDataSourceProfileProvider( diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/aws_s3access_logs.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/aws_s3access_logs.ts similarity index 95% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/aws_s3access_logs.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/aws_s3access_logs.ts index e068c2de1617..d3e5967d2cb9 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/aws_s3access_logs.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/aws_s3access_logs.ts @@ -17,7 +17,7 @@ export const createAwsS3accessLogsDataSourceProfileProvider = ( logsDataSourceProfileProvider: DataSourceProfileProvider ): DataSourceProfileProvider => extendProfileProvider(logsDataSourceProfileProvider, { - profileId: 'aws-s3access-logs-data-source', + profileId: 'observability-aws-s3access-logs-data-source-profile', profile: { getDefaultAppState: createGetDefaultAppState({ defaultColumns: [ diff --git a/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/create_resolve.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/create_resolve.test.ts new file mode 100644 index 000000000000..3c7b0b4c7af8 --- /dev/null +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/create_resolve.test.ts @@ -0,0 +1,85 @@ +/* + * 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 { ContextWithProfileId } from '../../../../profile_service'; +import { createEsqlDataSource } from '../../../../../../common/data_sources'; +import { + DataSourceCategory, + DataSourceProfileProviderParams, + RootContext, + SolutionType, +} from '../../../../profiles'; +import { createResolve } from './create_resolve'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts'; + +describe('createResolve', () => { + const VALID_INDEX_PATTERN = 'valid'; + const INVALID_INDEX_PATTERN = 'invalid'; + const ROOT_CONTEXT: ContextWithProfileId = { + profileId: OBSERVABILITY_ROOT_PROFILE_ID, + solutionType: SolutionType.Observability, + }; + const RESOLUTION_MATCH = { + isMatch: true, + context: { category: DataSourceCategory.Logs }, + }; + const RESOLUTION_MISMATCH = { + isMatch: false, + }; + const resolve = createResolve(VALID_INDEX_PATTERN); + + it('should match a valid index pattern', () => { + const result = resolve({ + rootContext: ROOT_CONTEXT, + dataSource: createEsqlDataSource(), + query: { esql: `FROM ${VALID_INDEX_PATTERN}` }, + }); + expect(result).toEqual(RESOLUTION_MATCH); + }); + + it('should not match an invalid index pattern', () => { + const result = resolve({ + rootContext: ROOT_CONTEXT, + dataSource: createEsqlDataSource(), + query: { esql: `FROM ${INVALID_INDEX_PATTERN}` }, + }); + expect(result).toEqual(RESOLUTION_MISMATCH); + }); + + it('should not match when the solution type is not Observability', () => { + const params: Omit = { + dataSource: createEsqlDataSource(), + query: { esql: `FROM ${VALID_INDEX_PATTERN}` }, + }; + expect( + resolve({ + ...params, + rootContext: ROOT_CONTEXT, + }) + ).toEqual(RESOLUTION_MATCH); + expect( + resolve({ + ...params, + rootContext: { profileId: 'other-root-profile', solutionType: SolutionType.Default }, + }) + ).toEqual(RESOLUTION_MISMATCH); + expect( + resolve({ + ...params, + rootContext: { profileId: 'other-root-profile', solutionType: SolutionType.Search }, + }) + ).toEqual(RESOLUTION_MISMATCH); + expect( + resolve({ + ...params, + rootContext: { profileId: 'other-root-profile', solutionType: SolutionType.Security }, + }) + ).toEqual(RESOLUTION_MISMATCH); + }); +}); diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/create_resolve.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/create_resolve.ts similarity index 87% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/create_resolve.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/create_resolve.ts index 75598e0d96c7..fb2afd46066c 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/create_resolve.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/create_resolve.ts @@ -10,6 +10,7 @@ import { createRegExpPatternFrom, testPatternAgainstAllowedList } from '@kbn/data-view-utils'; import { DataSourceCategory, DataSourceProfileProvider } from '../../../../profiles'; import { extractIndexPatternFrom } from '../../../extract_index_pattern_from'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts'; export const createResolve = (baseIndexPattern: string): DataSourceProfileProvider['resolve'] => { const testIndexPattern = testPatternAgainstAllowedList([ @@ -17,6 +18,10 @@ export const createResolve = (baseIndexPattern: string): DataSourceProfileProvid ]); return (params) => { + if (params.rootContext.profileId !== OBSERVABILITY_ROOT_PROFILE_ID) { + return { isMatch: false }; + } + const indexPattern = extractIndexPatternFrom(params); if (!indexPattern || !testIndexPattern(indexPattern)) { diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/index.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/index.ts similarity index 100% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/index.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/index.ts diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/kubernetes_container_logs.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/kubernetes_container_logs.test.ts similarity index 90% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/kubernetes_container_logs.test.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/kubernetes_container_logs.test.ts index 3f43aa3b6808..b26bca7fd810 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/kubernetes_container_logs.test.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/kubernetes_container_logs.test.ts @@ -13,8 +13,13 @@ import { DataSourceCategory, RootContext, SolutionType } from '../../../../profi import { createContextAwarenessMocks } from '../../../../__mocks__'; import { createLogsDataSourceProfileProvider } from '../profile'; import { createKubernetesContainerLogsDataSourceProfileProvider } from './kubernetes_container_logs'; +import { ContextWithProfileId } from '../../../../profile_service'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts'; -const ROOT_CONTEXT: RootContext = { solutionType: SolutionType.Default }; +const ROOT_CONTEXT: ContextWithProfileId = { + profileId: OBSERVABILITY_ROOT_PROFILE_ID, + solutionType: SolutionType.Observability, +}; const { profileProviderServices } = createContextAwarenessMocks(); const logsDataSourceProfileProvider = createLogsDataSourceProfileProvider(profileProviderServices); const dataSourceProfileProvider = createKubernetesContainerLogsDataSourceProfileProvider( diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/kubernetes_container_logs.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/kubernetes_container_logs.ts similarity index 94% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/kubernetes_container_logs.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/kubernetes_container_logs.ts index 3f6540ace614..8c95bf062f3f 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/kubernetes_container_logs.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/kubernetes_container_logs.ts @@ -17,7 +17,7 @@ export const createKubernetesContainerLogsDataSourceProfileProvider = ( logsDataSourceProfileProvider: DataSourceProfileProvider ): DataSourceProfileProvider => extendProfileProvider(logsDataSourceProfileProvider, { - profileId: 'kubernetes-container-logs-data-source', + profileId: 'observability-kubernetes-container-logs-data-source-profile', profile: { getDefaultAppState: createGetDefaultAppState({ defaultColumns: [ diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_access_logs.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_access_logs.test.ts similarity index 90% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_access_logs.test.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_access_logs.test.ts index 3116ebd55d3e..33d0c86d838b 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_access_logs.test.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_access_logs.test.ts @@ -13,8 +13,13 @@ import { DataSourceCategory, RootContext, SolutionType } from '../../../../profi import { createContextAwarenessMocks } from '../../../../__mocks__'; import { createLogsDataSourceProfileProvider } from '../profile'; import { createNginxAccessLogsDataSourceProfileProvider } from './nginx_access_logs'; +import { ContextWithProfileId } from '../../../../profile_service'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts'; -const ROOT_CONTEXT: RootContext = { solutionType: SolutionType.Default }; +const ROOT_CONTEXT: ContextWithProfileId = { + profileId: OBSERVABILITY_ROOT_PROFILE_ID, + solutionType: SolutionType.Observability, +}; const { profileProviderServices } = createContextAwarenessMocks(); const logsDataSourceProfileProvider = createLogsDataSourceProfileProvider(profileProviderServices); const dataSourceProfileProvider = createNginxAccessLogsDataSourceProfileProvider( diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_access_logs.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_access_logs.ts similarity index 95% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_access_logs.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_access_logs.ts index 8d7af45d6b24..71a6f7f72583 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_access_logs.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_access_logs.ts @@ -17,7 +17,7 @@ export const createNginxAccessLogsDataSourceProfileProvider = ( logsDataSourceProfileProvider: DataSourceProfileProvider ): DataSourceProfileProvider => extendProfileProvider(logsDataSourceProfileProvider, { - profileId: 'nginx-access-logs-data-source', + profileId: 'observability-nginx-access-logs-data-source-profile', profile: { getDefaultAppState: createGetDefaultAppState({ defaultColumns: [ diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_error_logs.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_error_logs.test.ts similarity index 89% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_error_logs.test.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_error_logs.test.ts index c5a980c31d21..861478c56952 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_error_logs.test.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_error_logs.test.ts @@ -13,8 +13,13 @@ import { DataSourceCategory, RootContext, SolutionType } from '../../../../profi import { createContextAwarenessMocks } from '../../../../__mocks__'; import { createLogsDataSourceProfileProvider } from '../profile'; import { createNginxErrorLogsDataSourceProfileProvider } from './nginx_error_logs'; +import { ContextWithProfileId } from '../../../../profile_service'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts'; -const ROOT_CONTEXT: RootContext = { solutionType: SolutionType.Default }; +const ROOT_CONTEXT: ContextWithProfileId = { + profileId: OBSERVABILITY_ROOT_PROFILE_ID, + solutionType: SolutionType.Observability, +}; const { profileProviderServices } = createContextAwarenessMocks(); const logsDataSourceProfileProvider = createLogsDataSourceProfileProvider(profileProviderServices); const dataSourceProfileProvider = createNginxErrorLogsDataSourceProfileProvider( diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_error_logs.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_error_logs.ts similarity index 94% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_error_logs.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_error_logs.ts index b6a05cce4ecb..d71b86392088 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/nginx_error_logs.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/nginx_error_logs.ts @@ -17,7 +17,7 @@ export const createNginxErrorLogsDataSourceProfileProvider = ( logsDataSourceProfileProvider: DataSourceProfileProvider ): DataSourceProfileProvider => extendProfileProvider(logsDataSourceProfileProvider, { - profileId: 'nginx-error-logs-data-source', + profileId: 'observability-nginx-error-logs-data-source-profile', profile: { getDefaultAppState: createGetDefaultAppState({ defaultColumns: [LOG_LEVEL_COLUMN, MESSAGE_COLUMN], diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/system_logs.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/system_logs.test.ts similarity index 89% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/system_logs.test.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/system_logs.test.ts index f6105d9115fb..4d7d208a1487 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/system_logs.test.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/system_logs.test.ts @@ -13,8 +13,13 @@ import { DataSourceCategory, RootContext, SolutionType } from '../../../../profi import { createContextAwarenessMocks } from '../../../../__mocks__'; import { createLogsDataSourceProfileProvider } from '../profile'; import { createSystemLogsDataSourceProfileProvider } from './system_logs'; +import { ContextWithProfileId } from '../../../../profile_service'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts'; -const ROOT_CONTEXT: RootContext = { solutionType: SolutionType.Default }; +const ROOT_CONTEXT: ContextWithProfileId = { + profileId: OBSERVABILITY_ROOT_PROFILE_ID, + solutionType: SolutionType.Observability, +}; const { profileProviderServices } = createContextAwarenessMocks(); const logsDataSourceProfileProvider = createLogsDataSourceProfileProvider(profileProviderServices); const dataSourceProfileProvider = createSystemLogsDataSourceProfileProvider( diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/system_logs.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/system_logs.ts similarity index 95% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/system_logs.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/system_logs.ts index 023cb578221f..9b82f5c58f87 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/system_logs.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/system_logs.ts @@ -17,7 +17,7 @@ export const createSystemLogsDataSourceProfileProvider = ( logsDataSourceProfileProvider: DataSourceProfileProvider ): DataSourceProfileProvider => extendProfileProvider(logsDataSourceProfileProvider, { - profileId: 'system-logs-data-source', + profileId: 'observability-system-logs-data-source-profile', profile: { getDefaultAppState: createGetDefaultAppState({ defaultColumns: [ diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/windows_logs.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/windows_logs.test.ts similarity index 89% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/windows_logs.test.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/windows_logs.test.ts index b54cdf3787f5..65aa4da91c0f 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/windows_logs.test.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/windows_logs.test.ts @@ -13,8 +13,13 @@ import { DataSourceCategory, RootContext, SolutionType } from '../../../../profi import { createContextAwarenessMocks } from '../../../../__mocks__'; import { createLogsDataSourceProfileProvider } from '../profile'; import { createWindowsLogsDataSourceProfileProvider } from './windows_logs'; +import { ContextWithProfileId } from '../../../../profile_service'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts'; -const ROOT_CONTEXT: RootContext = { solutionType: SolutionType.Default }; +const ROOT_CONTEXT: ContextWithProfileId = { + profileId: OBSERVABILITY_ROOT_PROFILE_ID, + solutionType: SolutionType.Observability, +}; const { profileProviderServices } = createContextAwarenessMocks(); const logsDataSourceProfileProvider = createLogsDataSourceProfileProvider(profileProviderServices); const dataSourceProfileProvider = createWindowsLogsDataSourceProfileProvider( diff --git a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/windows_logs.ts b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/windows_logs.ts similarity index 94% rename from src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/windows_logs.ts rename to src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/windows_logs.ts index 084233783341..db1edd32c428 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/common/logs_data_source_profile/sub_profiles/windows_logs.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/logs_data_source_profile/sub_profiles/windows_logs.ts @@ -17,7 +17,7 @@ export const createWindowsLogsDataSourceProfileProvider = ( logsDataSourceProfileProvider: DataSourceProfileProvider ): DataSourceProfileProvider => extendProfileProvider(logsDataSourceProfileProvider, { - profileId: 'windows-logs-data-source', + profileId: 'observability-windows-logs-data-source-profile', profile: { getDefaultAppState: createGetDefaultAppState({ defaultColumns: [LOG_LEVEL_COLUMN, HOST_NAME_COLUMN, MESSAGE_COLUMN], diff --git a/src/plugins/discover/public/context_awareness/profile_providers/observability/observability_root_profile/profile.tsx b/src/plugins/discover/public/context_awareness/profile_providers/observability/observability_root_profile/profile.tsx index d4b10c8d0a09..53a427a909db 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/observability/observability_root_profile/profile.tsx +++ b/src/plugins/discover/public/context_awareness/profile_providers/observability/observability_root_profile/profile.tsx @@ -9,12 +9,13 @@ import { RootProfileProvider, SolutionType } from '../../../profiles'; import { ProfileProviderServices } from '../../profile_provider_services'; +import { OBSERVABILITY_ROOT_PROFILE_ID } from '../consts'; import { createGetAppMenu } from './accessors'; export const createObservabilityRootProfileProvider = ( services: ProfileProviderServices ): RootProfileProvider => ({ - profileId: 'observability-root-profile', + profileId: OBSERVABILITY_ROOT_PROFILE_ID, profile: { getAppMenu: createGetAppMenu(services), }, diff --git a/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.ts b/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.ts index cb4146d1b99b..b0ee4318dde2 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.ts @@ -19,8 +19,8 @@ import { createExampleSolutionViewRootProfileProvider, createExampleRootProfileProvider, } from './example/example_root_profile'; -import { createLogsDataSourceProfileProviders } from './common/logs_data_source_profile'; -import { createLogDocumentProfileProvider } from './common/log_document_profile'; +import { createObservabilityLogsDataSourceProfileProviders } from './observability/logs_data_source_profile'; +import { createObservabilityLogDocumentProfileProvider } from './observability/log_document_profile'; import { createSecurityRootProfileProvider } from './security/security_root_profile'; import { createProfileProviderServices, @@ -133,7 +133,7 @@ const createRootProfileProviders = (providerServices: ProfileProviderServices) = */ const createDataSourceProfileProviders = (providerServices: ProfileProviderServices) => [ createExampleDataSourceProfileProvider(), - ...createLogsDataSourceProfileProviders(providerServices), + ...createObservabilityLogsDataSourceProfileProviders(providerServices), ]; /** @@ -143,5 +143,5 @@ const createDataSourceProfileProviders = (providerServices: ProfileProviderServi */ const createDocumentProfileProviders = (providerServices: ProfileProviderServices) => [ createExampleDocumentProfileProvider(), - createLogDocumentProfileProvider(providerServices), + createObservabilityLogDocumentProfileProvider(providerServices), ]; diff --git a/src/plugins/discover/public/context_awareness/profiles/data_source_profile.ts b/src/plugins/discover/public/context_awareness/profiles/data_source_profile.ts index 7f3933de185a..fb23a42e18cd 100644 --- a/src/plugins/discover/public/context_awareness/profiles/data_source_profile.ts +++ b/src/plugins/discover/public/context_awareness/profiles/data_source_profile.ts @@ -10,7 +10,11 @@ import type { DataView } from '@kbn/data-views-plugin/common'; import type { AggregateQuery, Query } from '@kbn/es-query'; import type { DiscoverDataSource } from '../../../common/data_sources'; -import { AsyncProfileProvider, AsyncProfileService } from '../profile_service'; +import { + AsyncProfileProvider, + AsyncProfileService, + ContextWithProfileId, +} from '../profile_service'; import type { Profile } from '../types'; import type { RootContext } from './root_profile'; @@ -34,7 +38,7 @@ export interface DataSourceProfileProviderParams { /** * The current root context */ - rootContext: RootContext; + rootContext: ContextWithProfileId; /** * The current data source */ diff --git a/src/plugins/discover/public/context_awareness/profiles/document_profile.ts b/src/plugins/discover/public/context_awareness/profiles/document_profile.ts index f555dfe8c429..21b016447eec 100644 --- a/src/plugins/discover/public/context_awareness/profiles/document_profile.ts +++ b/src/plugins/discover/public/context_awareness/profiles/document_profile.ts @@ -9,7 +9,7 @@ import type { DataTableRecord } from '@kbn/discover-utils'; import type { Profile } from '../types'; -import { ProfileProvider, ProfileService } from '../profile_service'; +import { ContextWithProfileId, ProfileProvider, ProfileService } from '../profile_service'; import type { RootContext } from './root_profile'; import type { DataSourceContext } from './data_source_profile'; @@ -33,11 +33,11 @@ export interface DocumentProfileProviderParams { /** * The current root context */ - rootContext: RootContext; + rootContext: ContextWithProfileId; /** * The current data source context */ - dataSourceContext: DataSourceContext; + dataSourceContext: ContextWithProfileId; /** * The current data table record */ diff --git a/src/plugins/discover/public/context_awareness/profiles_manager.test.ts b/src/plugins/discover/public/context_awareness/profiles_manager.test.ts index 4e1608961f7f..006b1c9e0da3 100644 --- a/src/plugins/discover/public/context_awareness/profiles_manager.test.ts +++ b/src/plugins/discover/public/context_awareness/profiles_manager.test.ts @@ -244,12 +244,12 @@ describe('ProfilesManager', () => { it('should cancel existing data source profile resolution when another is triggered', async () => { const context = await mocks.dataSourceProfileProviderMock.resolve({ - rootContext: { solutionType: SolutionType.Default }, + rootContext: { profileId: 'root-profile', solutionType: SolutionType.Default }, dataSource: createEsqlDataSource(), query: { esql: 'from *' }, }); const newContext = await mocks.dataSourceProfileProviderMock.resolve({ - rootContext: { solutionType: SolutionType.Default }, + rootContext: { profileId: 'other-root-profile', solutionType: SolutionType.Default }, dataSource: createEsqlDataSource(), query: { esql: 'from logs-*' }, }); diff --git a/test/functional/apps/discover/context_awareness/_data_source_profile.ts b/test/functional/apps/discover/context_awareness/_data_source_profile.ts deleted file mode 100644 index eeffafa38cd4..000000000000 --- a/test/functional/apps/discover/context_awareness/_data_source_profile.ts +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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 kbnRison from '@kbn/rison'; -import expect from '@kbn/expect'; -import type { FtrProviderContext } from '../ftr_provider_context'; - -export default function ({ getService, getPageObjects }: FtrProviderContext) { - const { common, discover, unifiedFieldList } = getPageObjects([ - 'common', - 'discover', - 'unifiedFieldList', - ]); - const testSubjects = getService('testSubjects'); - const dataViews = getService('dataViews'); - const dataGrid = getService('dataGrid'); - const retry = getService('retry'); - - describe('data source profile', () => { - describe('ES|QL mode', () => { - describe('cell renderers', () => { - it('should render custom @timestamp but not custom log.level', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-* | sort @timestamp desc' }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await unifiedFieldList.clickFieldListItemAdd('log.level'); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); - expect(timestamps).to.have.length(6); - expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); - expect(await timestamps[5].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); - const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel', 2500); - expect(logLevels).to.have.length(0); - }); - - it('should render custom @timestamp and custom log.level', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-logs | sort @timestamp desc' }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await unifiedFieldList.clickFieldListItemAdd('log.level'); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); - expect(timestamps).to.have.length(3); - expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:00:00.000Z'); - expect(await timestamps[2].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); - const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel'); - expect(logLevels).to.have.length(3); - expect(await logLevels[0].getVisibleText()).to.be('Debug'); - expect(await logLevels[2].getVisibleText()).to.be('Info'); - }); - }); - - describe('doc viewer extension', () => { - it('should not render custom doc viewer view', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-* | sort @timestamp desc' }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_source'); - await testSubjects.missingOrFail('docViewerTab-doc_view_example'); - expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Result'); - }); - - it('should render custom doc viewer view', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-logs | sort @timestamp desc' }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_source'); - await testSubjects.existOrFail('docViewerTab-doc_view_example'); - expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Record #0'); - }); - }); - - describe('custom context', () => { - it('should render formatted record in doc viewer using formatter from custom context', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-logs | sort @timestamp desc' }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0, defaultTabId: 'doc_view_example' }); - await retry.try(async () => { - const formattedRecord = await testSubjects.find( - 'exampleDataSourceProfileDocViewRecord' - ); - expect(await formattedRecord.getVisibleText()).to.be( - JSON.stringify( - { - '@timestamp': '2024-06-10T16:00:00.000Z', - 'agent.name': 'java', - 'agent.name.text': 'java', - 'data_stream.type': 'logs', - 'log.level': 'debug', - message: 'This is a debug log', - 'service.name': 'product', - 'service.name.text': 'product', - }, - null, - 2 - ) - ); - }); - }); - }); - }); - - describe('data view mode', () => { - describe('cell renderers', () => { - it('should render custom @timestamp but not custom log.level', async () => { - await common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-*'); - await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await unifiedFieldList.clickFieldListItemAdd('log.level'); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); - expect(timestamps).to.have.length(6); - expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); - expect(await timestamps[5].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); - const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel', 2500); - expect(logLevels).to.have.length(0); - }); - - it('should render custom @timestamp and custom log.level', async () => { - await common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-logs'); - await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await unifiedFieldList.clickFieldListItemAdd('log.level'); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); - expect(timestamps).to.have.length(3); - expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:00:00.000Z'); - expect(await timestamps[2].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); - const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel'); - expect(logLevels).to.have.length(3); - expect(await logLevels[0].getVisibleText()).to.be('Debug'); - expect(await logLevels[2].getVisibleText()).to.be('Info'); - }); - }); - - describe('doc viewer extension', () => { - it('should not render custom doc viewer view', async () => { - await common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-*'); - await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_source'); - await testSubjects.missingOrFail('docViewerTab-doc_view_example'); - expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Document'); - }); - - it('should render custom doc viewer view', async () => { - await common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-logs'); - await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_source'); - await testSubjects.existOrFail('docViewerTab-doc_view_example'); - expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be( - 'Record #my-example-logs::XdQFDpABfGznVC1bCHLo::' - ); - }); - }); - - describe('custom context', () => { - it('should render formatted record in doc viewer using formatter from custom context', async () => { - await common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-logs'); - await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0, defaultTabId: 'doc_view_example' }); - await retry.try(async () => { - const formattedRecord = await testSubjects.find( - 'exampleDataSourceProfileDocViewRecord' - ); - expect(await formattedRecord.getVisibleText()).to.be( - JSON.stringify( - { - '@timestamp': ['2024-06-10T16:00:00.000Z'], - 'agent.name': ['java'], - 'agent.name.text': ['java'], - 'data_stream.type': ['logs'], - 'log.level': ['debug'], - message: ['This is a debug log'], - 'service.name': ['product'], - 'service.name.text': ['product'], - _id: 'XdQFDpABfGznVC1bCHLo', - _index: 'my-example-logs', - _score: null, - }, - null, - 2 - ) - ); - }); - }); - }); - }); - }); -} diff --git a/test/functional/apps/discover/context_awareness/_framework.ts b/test/functional/apps/discover/context_awareness/_framework.ts new file mode 100644 index 000000000000..31b5bd83c7b4 --- /dev/null +++ b/test/functional/apps/discover/context_awareness/_framework.ts @@ -0,0 +1,96 @@ +/* + * 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 kbnRison from '@kbn/rison'; +import expect from '@kbn/expect'; +import type { FtrProviderContext } from '../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const { common, discover } = getPageObjects(['common', 'discover']); + const testSubjects = getService('testSubjects'); + const dataViews = getService('dataViews'); + const dataGrid = getService('dataGrid'); + const retry = getService('retry'); + + describe('framework', () => { + describe('ES|QL mode', () => { + describe('custom context', () => { + it('should render formatted record in doc viewer using formatter from custom context', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { esql: 'from my-example-logs | sort @timestamp desc' }, + }); + await common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle({ rowIndex: 0, defaultTabId: 'doc_view_example' }); + await retry.try(async () => { + const formattedRecord = await testSubjects.find( + 'exampleDataSourceProfileDocViewRecord' + ); + expect(await formattedRecord.getVisibleText()).to.be( + JSON.stringify( + { + '@timestamp': '2024-06-10T16:00:00.000Z', + 'agent.name': 'java', + 'agent.name.text': 'java', + 'data_stream.type': 'logs', + 'log.level': 'debug', + message: 'This is a debug log', + 'service.name': 'product', + 'service.name.text': 'product', + }, + null, + 2 + ) + ); + }); + }); + }); + }); + + describe('data view mode', () => { + describe('custom context', () => { + it('should render formatted record in doc viewer using formatter from custom context', async () => { + await common.navigateToActualUrl('discover', undefined, { + ensureCurrentUrl: false, + }); + await dataViews.switchTo('my-example-logs'); + await discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle({ rowIndex: 0, defaultTabId: 'doc_view_example' }); + await retry.try(async () => { + const formattedRecord = await testSubjects.find( + 'exampleDataSourceProfileDocViewRecord' + ); + expect(await formattedRecord.getVisibleText()).to.be( + JSON.stringify( + { + '@timestamp': ['2024-06-10T16:00:00.000Z'], + 'agent.name': ['java'], + 'agent.name.text': ['java'], + 'data_stream.type': ['logs'], + 'log.level': ['debug'], + message: ['This is a debug log'], + 'service.name': ['product'], + 'service.name.text': ['product'], + _id: 'XdQFDpABfGznVC1bCHLo', + _index: 'my-example-logs', + _score: null, + }, + null, + 2 + ) + ); + }); + }); + }); + }); + }); +} diff --git a/test/functional/apps/discover/context_awareness/_root_profile.ts b/test/functional/apps/discover/context_awareness/_root_profile.ts deleted file mode 100644 index 59856d8ba8c1..000000000000 --- a/test/functional/apps/discover/context_awareness/_root_profile.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 kbnRison from '@kbn/rison'; -import expect from '@kbn/expect'; -import type { FtrProviderContext } from '../ftr_provider_context'; - -export default function ({ getService, getPageObjects }: FtrProviderContext) { - const { common, discover } = getPageObjects(['common', 'discover']); - const testSubjects = getService('testSubjects'); - const dataViews = getService('dataViews'); - - describe('root profile', () => { - describe('ES|QL mode', () => { - describe('cell renderers', () => { - it('should render custom @timestamp', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-* | sort @timestamp desc' }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await discover.waitUntilSearchingHasFinished(); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); - expect(timestamps).to.have.length(6); - expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); - expect(await timestamps[5].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); - }); - }); - }); - - describe('data view mode', () => { - describe('cell renderers', () => { - it('should render custom @timestamp', async () => { - await common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-*'); - await discover.waitUntilSearchingHasFinished(); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); - expect(timestamps).to.have.length(6); - expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); - expect(await timestamps[5].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); - }); - }); - }); - }); -} diff --git a/test/functional/apps/discover/context_awareness/extensions/_get_cell_renderers.ts b/test/functional/apps/discover/context_awareness/extensions/_get_cell_renderers.ts index e18f6c5860dd..84935c85ffb3 100644 --- a/test/functional/apps/discover/context_awareness/extensions/_get_cell_renderers.ts +++ b/test/functional/apps/discover/context_awareness/extensions/_get_cell_renderers.ts @@ -9,344 +9,127 @@ import kbnRison from '@kbn/rison'; import expect from '@kbn/expect'; -import type { WebElementWrapper } from '@kbn/ftr-common-functional-ui-services'; import type { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const { common, discover, unifiedFieldList, header } = getPageObjects([ + const { common, discover, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'unifiedFieldList', - 'header', ]); - const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); - const dataGrid = getService('dataGrid'); const dataViews = getService('dataViews'); - const queryBar = getService('queryBar'); - const browser = getService('browser'); - const retry = getService('retry'); describe('extension getCellRenderers', () => { - before(async () => { - await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - }); - - after(async () => { - await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); - }); - describe('ES|QL mode', () => { - describe('Log Level Badge Cell', () => { - it('should render log.level badge cell', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { - esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `log.level` is not null', - }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('log.level'); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - - const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); - const logLevelBadge = await firstCell.findByTestSubject('*logLevelBadgeCell-'); - expect(await logLevelBadge.getVisibleText()).to.be('debug'); - expect(await logLevelBadge.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - }); - - it("should not render log.level badge cell if it's not a logs data source", async () => { + describe('root profile', () => { + it('should render custom @timestamp', async () => { const state = kbnRison.encode({ dataSource: { type: 'esql' }, - query: { - esql: 'from my-example* | sort @timestamp desc | where `log.level` is not null', - }, + query: { esql: 'from my-example-* | sort @timestamp desc' }, }); await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await header.waitUntilLoadingHasFinished(); await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('log.level'); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - - await retry.try(async () => { - const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); - expect(await firstCell.getVisibleText()).to.be('debug'); - await testSubjects.missingOrFail('*logLevelBadgeCell-'); - }); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); + expect(timestamps).to.have.length(6); + expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); + expect(await timestamps[5].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); }); }); - describe('Service Name Cell', () => { - it('should render service.name cell', async () => { + describe('data source profile', () => { + it('should render custom @timestamp but not custom log.level', async () => { const state = kbnRison.encode({ dataSource: { type: 'esql' }, - query: { - esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `service.name` is not null', - }, + query: { esql: 'from my-example-* | sort @timestamp desc' }, }); await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await header.waitUntilLoadingHasFinished(); await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('service.name'); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - - const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); - const lastCell = await dataGrid.getCellElementExcludingControlColumns(2, 0); - const firstServiceNameCell = await firstCell.findByTestSubject( - 'dataTableCellActionsPopover_service.name' - ); - const lastServiceNameCell = await lastCell.findByTestSubject( - 'dataTableCellActionsPopover_service.name' - ); - expect(await firstServiceNameCell.getVisibleText()).to.be('product'); - expect(await lastServiceNameCell.getVisibleText()).to.be('accounting'); - }); - - it("should not render service.name cell if it's not a logs data source", async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { - esql: 'from my-example* | sort @timestamp desc | where `service.name` is not null', - }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('service.name'); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - - await retry.try(async () => { - const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); - expect(await firstCell.getVisibleText()).to.be('product'); - await testSubjects.missingOrFail('dataTableCellActionsPopover_service.name'); - }); - }); - }); - - describe('Summary column', () => { - it('should render a summary of the log entry replacing the original document', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { - esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `message` is not null', - }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - - await testSubjects.existOrFail('discoverDataTableMessageValue'); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); + expect(timestamps).to.have.length(6); + expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); + expect(await timestamps[5].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); + const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel', 2500); + expect(logLevels).to.have.length(0); }); - it('should NOT render the summary column if the source does not match logs', async () => { + it('should render custom @timestamp and custom log.level', async () => { const state = kbnRison.encode({ dataSource: { type: 'esql' }, - query: { - esql: 'from my-example-*', - }, + query: { esql: 'from my-example-logs | sort @timestamp desc' }, }); await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await header.waitUntilLoadingHasFinished(); await discover.waitUntilSearchingHasFinished(); - - await testSubjects.missingOrFail('discoverDataTableMessageValue'); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); + expect(timestamps).to.have.length(3); + expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:00:00.000Z'); + expect(await timestamps[2].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); + const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel'); + expect(logLevels).to.have.length(3); + expect(await logLevels[0].getVisibleText()).to.be('Debug'); + expect(await logLevels[2].getVisibleText()).to.be('Info'); }); }); }); describe('data view mode', () => { - describe('Log Level Badge Cell', () => { - it('should render log.level badge cell', async () => { - await common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-logs,logstash*'); - await queryBar.setQuery('log.level:*'); - await queryBar.submitQuery(); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('log.level'); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - - let firstCell: WebElementWrapper; - let logLevelBadge: WebElementWrapper; - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); - logLevelBadge = await firstCell.findByTestSubject('*logLevelBadgeCell-'); - expect(await logLevelBadge.getVisibleText()).to.be('debug'); - expect(await logLevelBadge.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - }); - - // check Surrounding docs page - await dataGrid.clickRowToggle(); - const [, surroundingActionEl] = await dataGrid.getRowActions(); - await surroundingActionEl.click(); - await header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await header.waitUntilLoadingHasFinished(); - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); - logLevelBadge = await firstCell.findByTestSubject('*logLevelBadgeCell-'); - expect(await logLevelBadge.getVisibleText()).to.be('debug'); - expect(await logLevelBadge.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - }); - }); - - it("should not render log.level badge cell if it's not a logs data source", async () => { + describe('root profile', () => { + it('should render custom @timestamp', async () => { await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-*'); - await queryBar.setQuery('log.level:*'); - await queryBar.submitQuery(); - await header.waitUntilLoadingHasFinished(); + await dataViews.switchTo('my-example-*'); await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('log.level'); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - - let firstCell: WebElementWrapper; - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); - expect(await firstCell.getVisibleText()).to.be('debug'); - await testSubjects.missingOrFail('*logLevelBadgeCell-'); - }); - - // check Surrounding docs page - await dataGrid.clickRowToggle(); - const [, surroundingActionEl] = await dataGrid.getRowActions(); - await surroundingActionEl.click(); - await header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await header.waitUntilLoadingHasFinished(); - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(1, 1); - expect(await firstCell.getVisibleText()).to.be('debug'); - await testSubjects.missingOrFail('*logLevelBadgeCell-'); - }); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); + expect(timestamps).to.have.length(6); + expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); + expect(await timestamps[5].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); }); }); - describe('Service Name Cell', () => { - it('should render service.name cell', async () => { + describe('data source profile', () => { + it('should render custom @timestamp but not custom log.level', async () => { await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-logs,logstash*'); - await queryBar.setQuery('service.name:*'); - await queryBar.submitQuery(); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('service.name'); - await header.waitUntilLoadingHasFinished(); + await dataViews.switchTo('my-example-*'); await discover.waitUntilSearchingHasFinished(); - - let firstCell: WebElementWrapper; - let lastCell: WebElementWrapper; - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); - lastCell = await dataGrid.getCellElementExcludingControlColumns(2, 1); - const firstServiceNameCell = await firstCell.findByTestSubject( - 'dataTableCellActionsPopover_service.name' - ); - const lastServiceNameCell = await lastCell.findByTestSubject( - 'dataTableCellActionsPopover_service.name' - ); - expect(await firstServiceNameCell.getVisibleText()).to.be('product'); - expect(await lastServiceNameCell.getVisibleText()).to.be('accounting'); - }); - }); - - it("should not render service.name cell if it's not a logs data source", async () => { - await common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-*'); - await queryBar.setQuery('service.name:*'); - await queryBar.submitQuery(); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - await unifiedFieldList.clickFieldListItemAdd('service.name'); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - - let firstCell: WebElementWrapper; - let lastCell: WebElementWrapper; - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); - lastCell = await dataGrid.getCellElementExcludingControlColumns(2, 1); - - expect(await firstCell.getVisibleText()).to.be('product'); - expect(await lastCell.getVisibleText()).to.be('accounting'); - await testSubjects.missingOrFail('dataTableCellActionsPopover_service.name'); - }); - }); - }); - - describe('Summary column', () => { - it('should render a summary of the log entry replacing the original document', async () => { - await common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-logs,logstash*'); - - await retry.try(async () => { - await testSubjects.existOrFail('discoverDataTableMessageValue'); - }); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); + expect(timestamps).to.have.length(6); + expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); + expect(await timestamps[5].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); + const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel', 2500); + expect(logLevels).to.have.length(0); }); - it('should NOT render the summary column if the source does not match logs', async () => { + it('should render custom @timestamp and custom log.level', async () => { await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await header.waitUntilLoadingHasFinished(); + await dataViews.switchTo('my-example-logs'); await discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-*'); - - await retry.try(async () => { - await testSubjects.missingOrFail('discoverDataTableMessageValue'); - }); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); + expect(timestamps).to.have.length(3); + expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:00:00.000Z'); + expect(await timestamps[2].getVisibleText()).to.be('2024-06-10T14:00:00.000Z'); + const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel'); + expect(logLevels).to.have.length(3); + expect(await logLevels[0].getVisibleText()).to.be('Debug'); + expect(await logLevels[2].getVisibleText()).to.be('Info'); }); }); }); diff --git a/test/functional/apps/discover/context_awareness/extensions/_get_doc_viewer.ts b/test/functional/apps/discover/context_awareness/extensions/_get_doc_viewer.ts index 2bc410f00ac2..ac3ed7c7c6d5 100644 --- a/test/functional/apps/discover/context_awareness/extensions/_get_doc_viewer.ts +++ b/test/functional/apps/discover/context_awareness/extensions/_get_doc_viewer.ts @@ -8,117 +8,77 @@ */ import kbnRison from '@kbn/rison'; +import expect from '@kbn/expect'; import type { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const { common, discover, header } = getPageObjects(['common', 'discover', 'header']); + const { common, discover } = getPageObjects(['common', 'discover']); const testSubjects = getService('testSubjects'); const dataViews = getService('dataViews'); const dataGrid = getService('dataGrid'); - const browser = getService('browser'); describe('extension getDocViewer', () => { describe('ES|QL mode', () => { - it('should render logs overview tab for logs data source', async () => { + it('should not render custom doc viewer view', async () => { const state = kbnRison.encode({ dataSource: { type: 'esql' }, - query: { esql: 'from my-example-logs | sort @timestamp desc' }, + query: { esql: 'from my-example-* | sort @timestamp desc' }, }); await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle(); + await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); - await dataGrid.clickDocViewerTab('doc_view_logs_overview'); - await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); + await testSubjects.existOrFail('docViewerTab-doc_view_source'); + await testSubjects.missingOrFail('docViewerTab-doc_view_example'); + expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Result'); }); - it('should not render logs overview tab for non-logs data source', async () => { + it('should render custom doc viewer view', async () => { const state = kbnRison.encode({ dataSource: { type: 'esql' }, - query: { esql: 'from my-example-metrics | sort @timestamp desc' }, + query: { esql: 'from my-example-logs | sort @timestamp desc' }, }); await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle(); + await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); + await testSubjects.existOrFail('docViewerTab-doc_view_source'); + await testSubjects.existOrFail('docViewerTab-doc_view_example'); + expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Record #0'); }); }); describe('data view mode', () => { - it('should render logs overview tab for logs data source', async () => { + it('should not render custom doc viewer view', async () => { await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await dataViews.switchTo('my-example-logs'); + await dataViews.switchTo('my-example-*'); await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle(); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); - await dataGrid.clickDocViewerTab('doc_view_logs_overview'); - await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); - - // check Surrounding docs page - const [, surroundingActionEl] = await dataGrid.getRowActions(); - await surroundingActionEl.click(); - await header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await header.waitUntilLoadingHasFinished(); - - await dataGrid.clickRowToggle({ isAnchorRow: true }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); - await dataGrid.clickDocViewerTab('doc_view_logs_overview'); - await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); - - // check Single doc page - const [singleDocActionEl] = await dataGrid.getRowActions(); - await singleDocActionEl.click(); - await header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await header.waitUntilLoadingHasFinished(); - + await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); - await dataGrid.clickDocViewerTab('doc_view_logs_overview'); - await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); + await testSubjects.existOrFail('docViewerTab-doc_view_source'); + await testSubjects.missingOrFail('docViewerTab-doc_view_example'); + expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Document'); }); - it('should not render logs overview tab for non-logs data source', async () => { + it('should render custom doc viewer view', async () => { await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await dataViews.switchTo('my-example-metrics'); + await dataViews.switchTo('my-example-logs'); await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle(); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); - - // check Surrounding docs page - const [, surroundingActionEl] = await dataGrid.getRowActions(); - await surroundingActionEl.click(); - await header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await header.waitUntilLoadingHasFinished(); - - await dataGrid.clickRowToggle({ isAnchorRow: true }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); - - // check Single doc page - const [singleDocActionEl] = await dataGrid.getRowActions(); - await singleDocActionEl.click(); - await header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await header.waitUntilLoadingHasFinished(); - + await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); + await testSubjects.existOrFail('docViewerTab-doc_view_source'); + await testSubjects.existOrFail('docViewerTab-doc_view_example'); + expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be( + 'Record #my-example-logs::XdQFDpABfGznVC1bCHLo::' + ); }); }); }); diff --git a/test/functional/apps/discover/context_awareness/extensions/_get_row_indicator_provider.ts b/test/functional/apps/discover/context_awareness/extensions/_get_row_indicator_provider.ts index 014c86d1fd29..eec9ad526624 100644 --- a/test/functional/apps/discover/context_awareness/extensions/_get_row_indicator_provider.ts +++ b/test/functional/apps/discover/context_awareness/extensions/_get_row_indicator_provider.ts @@ -7,146 +7,10 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import kbnRison from '@kbn/rison'; -import expect from '@kbn/expect'; import type { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService, getPageObjects }: FtrProviderContext) { - const { common, timePicker, discover, header } = getPageObjects([ - 'common', - 'timePicker', - 'discover', - 'header', - ]); - const esArchiver = getService('esArchiver'); - const testSubjects = getService('testSubjects'); - const dataGrid = getService('dataGrid'); - const browser = getService('browser'); - const dataViews = getService('dataViews'); - +export default function ({}: FtrProviderContext) { describe('extension getRowIndicatorProvider', () => { - before(async () => { - await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - }); - - after(async () => { - await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); - }); - - it('should not render log.level row indicators for logs data source without a log.level field', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from logstash* | sort @timestamp desc' }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await discover.waitUntilSearchingHasFinished(); - await timePicker.setDefaultAbsoluteRange(); - await discover.waitUntilSearchingHasFinished(); - // logstash does not have log.level field, so the color indicator should not be rendered - await testSubjects.existOrFail('euiDataGridBody'); - await testSubjects.missingOrFail('dataGridHeaderCell-colorIndicator'); - - // switch the time frame back - await browser.goBack(); - await discover.waitUntilSearchingHasFinished(); - }); - - it('should not render log.level row indicators if not a logs data source', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example* | sort @timestamp desc' }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await discover.waitUntilSearchingHasFinished(); - // my-example* has a log.level field, but it's not matching the logs profile, so the color indicator should not be rendered - await testSubjects.existOrFail('euiDataGridBody'); - await testSubjects.missingOrFail('dataGridHeaderCell-colorIndicator'); - }); - - it('should render log.level row indicators', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { - esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `log.level` is not null', - }, - }); - await common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await discover.waitUntilSearchingHasFinished(); - // in this case it's matching the logs data source profile and has a log.level field, so the color indicator should be rendered - await testSubjects.existOrFail('dataGridHeaderCell-colorIndicator'); - const firstCell = await dataGrid.getCellElement(0, 0); - const firstColorIndicator = await firstCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await firstColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - expect(await firstColorIndicator.getAttribute('title')).to.be('Debug'); - - const secondCell = await dataGrid.getCellElement(1, 0); - const secondColorIndicator = await secondCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await secondColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(223, 147, 82, 1)' - ); - expect(await secondColorIndicator.getAttribute('title')).to.be('Error'); - }); - - it('should render log.level row indicators on Surrounding documents page', async () => { - await common.navigateToApp('discover'); - await dataViews.switchTo('my-example-logs,logstash*'); - await discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); - const [, surroundingActionEl] = await dataGrid.getRowActions(); - await surroundingActionEl.click(); - await header.waitUntilLoadingHasFinished(); - - let anchorCell = await dataGrid.getCellElement(0, 0); - let anchorColorIndicator = await anchorCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await anchorColorIndicator.getAttribute('title')).to.be('Debug'); - expect(await anchorColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - - let nextCell = await dataGrid.getCellElement(1, 0); - let nextColorIndicator = await nextCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await nextColorIndicator.getAttribute('title')).to.be('Error'); - expect(await nextColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(223, 147, 82, 1)' - ); - - await browser.refresh(); - await header.waitUntilLoadingHasFinished(); - await discover.waitUntilSearchingHasFinished(); - - anchorCell = await dataGrid.getCellElement(0, 0); - anchorColorIndicator = await anchorCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await anchorColorIndicator.getAttribute('title')).to.be('Debug'); - expect(await anchorColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - - nextCell = await dataGrid.getCellElement(1, 0); - nextColorIndicator = await nextCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await nextColorIndicator.getAttribute('title')).to.be('Error'); - expect(await nextColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(223, 147, 82, 1)' - ); - }); + // TODO: Add an example profile implementation to test here }); } diff --git a/test/functional/apps/discover/context_awareness/index.ts b/test/functional/apps/discover/context_awareness/index.ts index 0edf18b7e902..67ed647be728 100644 --- a/test/functional/apps/discover/context_awareness/index.ts +++ b/test/functional/apps/discover/context_awareness/index.ts @@ -36,8 +36,7 @@ export default function ({ getService, getPageObjects, loadTestFile }: FtrProvid await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); }); - loadTestFile(require.resolve('./_root_profile')); - loadTestFile(require.resolve('./_data_source_profile')); + loadTestFile(require.resolve('./_framework')); loadTestFile(require.resolve('./_telemetry')); loadTestFile(require.resolve('./extensions/_get_row_indicator_provider')); loadTestFile(require.resolve('./extensions/_get_row_additional_leading_controls')); diff --git a/test/functional/apps/discover/esql/_esql_view.ts b/test/functional/apps/discover/esql/_esql_view.ts index 7953ca679088..63dab52a547d 100644 --- a/test/functional/apps/discover/esql/_esql_view.ts +++ b/test/functional/apps/discover/esql/_esql_view.ts @@ -194,6 +194,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should render correctly if there are empty fields', async function () { await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); const testQuery = `from logstash-* | limit 10 | keep machine.ram_range, bytes`; await monacoEditor.setCodeEditorValue(testQuery); @@ -202,11 +204,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await discover.waitUntilSearchingHasFinished(); const cell = await dataGrid.getCellElementExcludingControlColumns(0, 1); expect(await cell.getVisibleText()).to.be(' - '); - expect(await dataGrid.getHeaders()).to.eql([ - 'Select column', - 'Control column', - 'Access to degraded docs', - 'Access to available stacktraces', + expect((await dataGrid.getHeaders()).slice(-2)).to.eql([ 'Numberbytes', 'machine.ram_range', ]); diff --git a/test/functional/apps/discover/group1/_doc_accessibility.ts b/test/functional/apps/discover/group1/_doc_accessibility.ts index 759f222fc4e2..d5d047deb51d 100644 --- a/test/functional/apps/discover/group1/_doc_accessibility.ts +++ b/test/functional/apps/discover/group1/_doc_accessibility.ts @@ -49,7 +49,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.pressKeys(browser.keys.TAB); await browser.pressKeys(browser.keys.SPACE); await browser.pressKeys(browser.keys.TAB); - const tableTab = await testSubjects.find('docViewerTab-doc_view_logs_overview'); + const tableTab = await testSubjects.find('docViewerTab-doc_view_table'); const activeElement = await find.activeElement(); expect(await tableTab.getAttribute('data-test-subj')).to.eql( await activeElement.getAttribute('data-test-subj') diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/_data_source_profile.ts b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/_data_source_profile.ts deleted file mode 100644 index 960a79d4bba5..000000000000 --- a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/_data_source_profile.ts +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import kbnRison from '@kbn/rison'; -import expect from '@kbn/expect'; -import type { FtrProviderContext } from '../../../../ftr_provider_context'; - -export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ - 'svlCommonPage', - 'common', - 'timePicker', - 'discover', - 'unifiedFieldList', - ]); - const testSubjects = getService('testSubjects'); - const dataViews = getService('dataViews'); - const dataGrid = getService('dataGrid'); - const retry = getService('retry'); - - describe('data source profile', () => { - before(async () => { - await PageObjects.svlCommonPage.loginAsAdmin(); - }); - - describe('ES|QL mode', () => { - describe('cell renderers', () => { - it('should not render custom @timestamp or log.level', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-* | sort @timestamp desc' }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); - expect(timestamps).to.have.length(0); - const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel', 2500); - expect(logLevels).to.have.length(0); - }); - - it('should not render custom @timestamp but should render custom log.level', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-logs | sort @timestamp desc' }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); - expect(timestamps).to.have.length(0); - const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel'); - expect(logLevels).to.have.length(3); - expect(await logLevels[0].getVisibleText()).to.be('Debug'); - expect(await logLevels[2].getVisibleText()).to.be('Info'); - }); - }); - - describe('doc viewer extension', () => { - it('should not render custom doc viewer view', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-* | sort @timestamp desc' }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_source'); - await testSubjects.missingOrFail('docViewerTab-doc_view_example'); - expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Result'); - }); - - it('should render custom doc viewer view', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-logs | sort @timestamp desc' }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_source'); - await testSubjects.existOrFail('docViewerTab-doc_view_example'); - expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Record #0'); - }); - }); - - describe('custom context', () => { - it('should render formatted record in doc viewer using formatter from custom context', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-logs | sort @timestamp desc' }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0, defaultTabId: 'doc_view_example' }); - await retry.try(async () => { - const formattedRecord = await testSubjects.find( - 'exampleDataSourceProfileDocViewRecord' - ); - expect(await formattedRecord.getVisibleText()).to.be( - JSON.stringify( - { - '@timestamp': '2024-06-10T16:00:00.000Z', - 'agent.name': 'java', - 'agent.name.text': 'java', - 'data_stream.type': 'logs', - 'log.level': 'debug', - message: 'This is a debug log', - 'service.name': 'product', - 'service.name.text': 'product', - }, - null, - 2 - ) - ); - }); - }); - }); - }); - - describe('data view mode', () => { - describe('cell renderers', () => { - it('should not render custom @timestamp or log.level', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); - expect(timestamps).to.have.length(0); - const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel', 2500); - expect(logLevels).to.have.length(0); - }); - - it('should not render custom @timestamp but should render custom log.level', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); - expect(timestamps).to.have.length(0); - const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel'); - expect(logLevels).to.have.length(3); - expect(await logLevels[0].getVisibleText()).to.be('Debug'); - expect(await logLevels[2].getVisibleText()).to.be('Info'); - }); - }); - - describe('doc viewer extension', () => { - it('should not render custom doc viewer view', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_source'); - await testSubjects.missingOrFail('docViewerTab-doc_view_example'); - expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Document'); - }); - - it('should render custom doc viewer view', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_source'); - await testSubjects.existOrFail('docViewerTab-doc_view_example'); - expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be( - 'Record #my-example-logs::XdQFDpABfGznVC1bCHLo::' - ); - }); - }); - - describe('custom context', () => { - it('should render formatted record in doc viewer using formatter from custom context', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0, defaultTabId: 'doc_view_example' }); - await retry.try(async () => { - const formattedRecord = await testSubjects.find( - 'exampleDataSourceProfileDocViewRecord' - ); - expect(await formattedRecord.getVisibleText()).to.be( - JSON.stringify( - { - '@timestamp': ['2024-06-10T16:00:00.000Z'], - 'agent.name': ['java'], - 'agent.name.text': ['java'], - 'data_stream.type': ['logs'], - 'log.level': ['debug'], - message: ['This is a debug log'], - 'service.name': ['product'], - 'service.name.text': ['product'], - _id: 'XdQFDpABfGznVC1bCHLo', - _index: 'my-example-logs', - _score: null, - }, - null, - 2 - ) - ); - }); - }); - }); - }); - }); -} diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/_framework.ts b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/_framework.ts new file mode 100644 index 000000000000..77204f0612d1 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/_framework.ts @@ -0,0 +1,102 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import kbnRison from '@kbn/rison'; +import expect from '@kbn/expect'; +import type { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const { common, discover, svlCommonPage } = getPageObjects([ + 'common', + 'discover', + 'svlCommonPage', + ]); + const testSubjects = getService('testSubjects'); + const dataViews = getService('dataViews'); + const dataGrid = getService('dataGrid'); + const retry = getService('retry'); + + describe('framework', () => { + before(async () => { + await svlCommonPage.loginAsAdmin(); + }); + + describe('ES|QL mode', () => { + describe('custom context', () => { + it('should render formatted record in doc viewer using formatter from custom context', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { esql: 'from my-example-logs | sort @timestamp desc' }, + }); + await common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle({ rowIndex: 0, defaultTabId: 'doc_view_example' }); + await retry.try(async () => { + const formattedRecord = await testSubjects.find( + 'exampleDataSourceProfileDocViewRecord' + ); + expect(await formattedRecord.getVisibleText()).to.be( + JSON.stringify( + { + '@timestamp': '2024-06-10T16:00:00.000Z', + 'agent.name': 'java', + 'agent.name.text': 'java', + 'data_stream.type': 'logs', + 'log.level': 'debug', + message: 'This is a debug log', + 'service.name': 'product', + 'service.name.text': 'product', + }, + null, + 2 + ) + ); + }); + }); + }); + }); + + describe('data view mode', () => { + describe('custom context', () => { + it('should render formatted record in doc viewer using formatter from custom context', async () => { + await common.navigateToActualUrl('discover', undefined, { + ensureCurrentUrl: false, + }); + await dataViews.switchTo('my-example-logs'); + await discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle({ rowIndex: 0, defaultTabId: 'doc_view_example' }); + await retry.try(async () => { + const formattedRecord = await testSubjects.find( + 'exampleDataSourceProfileDocViewRecord' + ); + expect(await formattedRecord.getVisibleText()).to.be( + JSON.stringify( + { + '@timestamp': ['2024-06-10T16:00:00.000Z'], + 'agent.name': ['java'], + 'agent.name.text': ['java'], + 'data_stream.type': ['logs'], + 'log.level': ['debug'], + message: ['This is a debug log'], + 'service.name': ['product'], + 'service.name.text': ['product'], + _id: 'XdQFDpABfGznVC1bCHLo', + _index: 'my-example-logs', + _score: null, + }, + null, + 2 + ) + ); + }); + }); + }); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/_root_profile.ts b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/_root_profile.ts deleted file mode 100644 index e7eb75384d67..000000000000 --- a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/_root_profile.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import kbnRison from '@kbn/rison'; -import expect from '@kbn/expect'; -import type { FtrProviderContext } from '../../../../ftr_provider_context'; - -export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'timePicker', 'discover', 'svlCommonPage']); - const testSubjects = getService('testSubjects'); - const dataViews = getService('dataViews'); - - describe('root profile', () => { - before(async () => { - await PageObjects.svlCommonPage.loginAsAdmin(); - }); - - describe('ES|QL mode', () => { - describe('cell renderers', () => { - it('should not render custom @timestamp', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example-* | sort @timestamp desc' }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); - expect(timestamps).to.have.length(0); - }); - }); - }); - - describe('data view mode', () => { - describe('cell renderers', () => { - it('should not render custom @timestamp', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await dataViews.switchTo('my-example-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); - expect(timestamps).to.have.length(0); - }); - }); - }); - }); -} diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_cell_renderers.ts b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_cell_renderers.ts index b8503e0f8dca..4b599b86931d 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_cell_renderers.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_cell_renderers.ts @@ -7,345 +7,120 @@ import kbnRison from '@kbn/rison'; import expect from '@kbn/expect'; -import type { WebElementWrapper } from '@kbn/ftr-common-functional-ui-services'; import type { FtrProviderContext } from '../../../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { common, discover, unifiedFieldList, svlCommonPage } = getPageObjects([ 'common', 'discover', 'unifiedFieldList', 'svlCommonPage', - 'header', ]); - const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); - const dataGrid = getService('dataGrid'); const dataViews = getService('dataViews'); - const queryBar = getService('queryBar'); - const browser = getService('browser'); - const retry = getService('retry'); describe('extension getCellRenderers', () => { before(async () => { - await PageObjects.svlCommonPage.loginAsAdmin(); - await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - }); - - after(async () => { - await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); + await svlCommonPage.loginAsAdmin(); }); describe('ES|QL mode', () => { - describe('Log Level Badge Cell', () => { - it('should render log.level badge cell', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { - esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `log.level` is not null', - }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); - const logLevelBadge = await firstCell.findByTestSubject('*logLevelBadgeCell-'); - expect(await logLevelBadge.getVisibleText()).to.be('debug'); - expect(await logLevelBadge.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - }); - - it("should not render log.level badge cell if it's not a logs data source", async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { - esql: 'from my-example* | sort @timestamp desc | where `log.level` is not null', - }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - await retry.try(async () => { - const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); - expect(await firstCell.getVisibleText()).to.be('debug'); - await testSubjects.missingOrFail('*logLevelBadgeCell-'); - }); - }); - }); - - describe('Service Name Cell', () => { - it('should render service.name cell', async () => { + describe('root profile', () => { + it('should not render custom @timestamp', async () => { const state = kbnRison.encode({ dataSource: { type: 'esql' }, - query: { - esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `service.name` is not null', - }, + query: { esql: 'from my-example-* | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('service.name'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); - const lastCell = await dataGrid.getCellElementExcludingControlColumns(2, 0); - const firstServiceNameCell = await firstCell.findByTestSubject( - 'dataTableCellActionsPopover_service.name' - ); - const lastServiceNameCell = await lastCell.findByTestSubject( - 'dataTableCellActionsPopover_service.name' - ); - expect(await firstServiceNameCell.getVisibleText()).to.be('product'); - expect(await lastServiceNameCell.getVisibleText()).to.be('accounting'); - }); - - it("should not render service.name cell if it's not a logs data source", async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { - esql: 'from my-example* | sort @timestamp desc | where `service.name` is not null', - }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('service.name'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - await retry.try(async () => { - const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); - expect(await firstCell.getVisibleText()).to.be('product'); - await testSubjects.missingOrFail('dataTableCellActionsPopover_service.name'); - }); + await discover.waitUntilSearchingHasFinished(); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); + expect(timestamps).to.have.length(0); }); }); - describe('Summary column', () => { - it('should render a summary of the log entry replacing the original document', async () => { + describe('data source profile', () => { + it('should not render custom @timestamp or log.level', async () => { const state = kbnRison.encode({ dataSource: { type: 'esql' }, - query: { - esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `message` is not null', - }, + query: { esql: 'from my-example-* | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - await testSubjects.existOrFail('discoverDataTableMessageValue'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); + expect(timestamps).to.have.length(0); + const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel', 2500); + expect(logLevels).to.have.length(0); }); - it('should NOT render the summary column if the source does not match logs', async () => { + it('should not render custom @timestamp but should render custom log.level', async () => { const state = kbnRison.encode({ dataSource: { type: 'esql' }, - query: { - esql: 'from my-example-*', - }, + query: { esql: 'from my-example-logs | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - await testSubjects.missingOrFail('discoverDataTableMessageValue'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); + expect(timestamps).to.have.length(0); + const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel'); + expect(logLevels).to.have.length(3); + expect(await logLevels[0].getVisibleText()).to.be('Debug'); + expect(await logLevels[2].getVisibleText()).to.be('Info'); }); }); }); describe('data view mode', () => { - describe('Log Level Badge Cell', () => { - it('should render log.level badge cell', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + describe('root profile', () => { + it('should not render custom @timestamp', async () => { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-logs,logstash*'); - await queryBar.setQuery('log.level:*'); - await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - let firstCell: WebElementWrapper; - let logLevelBadge: WebElementWrapper; - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); - logLevelBadge = await firstCell.findByTestSubject('*logLevelBadgeCell-'); - expect(await logLevelBadge.getVisibleText()).to.be('debug'); - expect(await logLevelBadge.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - }); - - // check Surrounding docs page - await dataGrid.clickRowToggle(); - const [, surroundingActionEl] = await dataGrid.getRowActions(); - await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); - logLevelBadge = await firstCell.findByTestSubject('*logLevelBadgeCell-'); - expect(await logLevelBadge.getVisibleText()).to.be('debug'); - expect(await logLevelBadge.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - }); - }); - - it("should not render log.level badge cell if it's not a logs data source", async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-*'); - await queryBar.setQuery('log.level:*'); - await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - let firstCell: WebElementWrapper; - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); - expect(await firstCell.getVisibleText()).to.be('debug'); - await testSubjects.missingOrFail('*logLevelBadgeCell-'); - }); - - // check Surrounding docs page - await dataGrid.clickRowToggle(); - const [, surroundingActionEl] = await dataGrid.getRowActions(); - await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(1, 1); - expect(await firstCell.getVisibleText()).to.be('debug'); - await testSubjects.missingOrFail('*logLevelBadgeCell-'); - }); + await dataViews.switchTo('my-example-*'); + await discover.waitUntilSearchingHasFinished(); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); + expect(timestamps).to.have.length(0); }); }); - describe('Service Name Cell', () => { - it('should render service.name cell', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-logs,logstash*'); - await queryBar.setQuery('service.name:*'); - await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('service.name'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - let firstCell: WebElementWrapper; - let lastCell: WebElementWrapper; - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); - lastCell = await dataGrid.getCellElementExcludingControlColumns(2, 1); - const firstServiceNameCell = await firstCell.findByTestSubject( - 'dataTableCellActionsPopover_service.name' - ); - const lastServiceNameCell = await lastCell.findByTestSubject( - 'dataTableCellActionsPopover_service.name' - ); - expect(await firstServiceNameCell.getVisibleText()).to.be('product'); - expect(await lastServiceNameCell.getVisibleText()).to.be('accounting'); - }); - }); - - it("should not render service.name cell if it's not a logs data source", async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { - ensureCurrentUrl: false, - }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-*'); - await queryBar.setQuery('service.name:*'); - await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('service.name'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - let firstCell: WebElementWrapper; - let lastCell: WebElementWrapper; - - await retry.try(async () => { - firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); - lastCell = await dataGrid.getCellElementExcludingControlColumns(2, 1); - - expect(await firstCell.getVisibleText()).to.be('product'); - expect(await lastCell.getVisibleText()).to.be('accounting'); - await testSubjects.missingOrFail('dataTableCellActionsPopover_service.name'); - }); - }); - }); - - describe('Summary column', () => { - it('should render a summary of the log entry replacing the original document', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + describe('data source profile', () => { + it('should not render custom @timestamp or log.level', async () => { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-logs,logstash*'); - - await retry.try(async () => { - await testSubjects.existOrFail('discoverDataTableMessageValue'); - }); + await dataViews.switchTo('my-example-*'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); + expect(timestamps).to.have.length(0); + const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel', 2500); + expect(logLevels).to.have.length(0); }); - it('should NOT render the summary column if the source does not match logs', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + it('should not render custom @timestamp but should render custom log.level', async () => { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataViews.switchToAndValidate('my-example-*'); - - await retry.try(async () => { - await testSubjects.missingOrFail('discoverDataTableMessageValue'); - }); + await dataViews.switchTo('my-example-logs'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp', 2500); + expect(timestamps).to.have.length(0); + const logLevels = await testSubjects.findAll('exampleDataSourceProfileLogLevel'); + expect(logLevels).to.have.length(3); + expect(await logLevels[0].getVisibleText()).to.be('Debug'); + expect(await logLevels[2].getVisibleText()).to.be('Info'); }); }); }); diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_doc_viewer.ts b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_doc_viewer.ts index d214d295e1a7..1c5e7a44db7e 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_doc_viewer.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_doc_viewer.ts @@ -6,121 +6,85 @@ */ import kbnRison from '@kbn/rison'; +import expect from '@kbn/expect'; import type { FtrProviderContext } from '../../../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'discover', 'svlCommonPage', 'header']); + const { common, discover, svlCommonPage } = getPageObjects([ + 'common', + 'discover', + 'svlCommonPage', + ]); const testSubjects = getService('testSubjects'); const dataViews = getService('dataViews'); const dataGrid = getService('dataGrid'); - const browser = getService('browser'); describe('extension getDocViewer', () => { before(async () => { - await PageObjects.svlCommonPage.loginAsAdmin(); + await svlCommonPage.loginAsAdmin(); }); describe('ES|QL mode', () => { - it('should render logs overview tab for logs data source', async () => { + it('should not render custom doc viewer view', async () => { const state = kbnRison.encode({ dataSource: { type: 'esql' }, - query: { esql: 'from my-example-logs | sort @timestamp desc' }, + query: { esql: 'from my-example-* | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle(); + await discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); - await dataGrid.clickDocViewerTab('doc_view_logs_overview'); - await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); + await testSubjects.existOrFail('docViewerTab-doc_view_source'); + await testSubjects.missingOrFail('docViewerTab-doc_view_example'); + expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Result'); }); - it('should not render logs overview tab for non-logs data source', async () => { + it('should render custom doc viewer view', async () => { const state = kbnRison.encode({ dataSource: { type: 'esql' }, - query: { esql: 'from my-example-metrics | sort @timestamp desc' }, + query: { esql: 'from my-example-logs | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle(); + await discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); + await testSubjects.existOrFail('docViewerTab-doc_view_source'); + await testSubjects.existOrFail('docViewerTab-doc_view_example'); + expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Record #0'); }); }); describe('data view mode', () => { - it('should render logs overview tab for logs data source', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + it('should not render custom doc viewer view', async () => { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle(); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); - await dataGrid.clickDocViewerTab('doc_view_logs_overview'); - await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); - - // check Surrounding docs page - const [, surroundingActionEl] = await dataGrid.getRowActions(); - await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - - await dataGrid.clickRowToggle({ isAnchorRow: true }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); - await dataGrid.clickDocViewerTab('doc_view_logs_overview'); - await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); - - // check Single doc page - const [singleDocActionEl] = await dataGrid.getRowActions(); - await singleDocActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - + await dataViews.switchTo('my-example-*'); + await discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); - await dataGrid.clickDocViewerTab('doc_view_logs_overview'); - await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); + await testSubjects.existOrFail('docViewerTab-doc_view_source'); + await testSubjects.missingOrFail('docViewerTab-doc_view_example'); + expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be('Document'); }); - it('should not render logs overview tab for non-logs data source', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + it('should render custom doc viewer view', async () => { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await dataViews.switchTo('my-example-metrics'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle(); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); - - // check Surrounding docs page - const [, surroundingActionEl] = await dataGrid.getRowActions(); - await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - - await dataGrid.clickRowToggle({ isAnchorRow: true }); - await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); - - // check Single doc page - const [singleDocActionEl] = await dataGrid.getRowActions(); - await singleDocActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - + await dataViews.switchTo('my-example-logs'); + await discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); - await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); + await testSubjects.existOrFail('docViewerTab-doc_view_source'); + await testSubjects.existOrFail('docViewerTab-doc_view_example'); + expect(await testSubjects.getVisibleText('docViewerRowDetailsTitle')).to.be( + 'Record #my-example-logs::XdQFDpABfGznVC1bCHLo::' + ); }); }); }); diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_row_indicator_provider.ts b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_row_indicator_provider.ts index f52de21b2aaa..6a5fc64c7ee7 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_row_indicator_provider.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_row_indicator_provider.ts @@ -5,140 +5,10 @@ * 2.0. */ -import kbnRison from '@kbn/rison'; -import expect from '@kbn/expect'; import type { FtrProviderContext } from '../../../../../ftr_provider_context'; -export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ - 'common', - 'timePicker', - 'discover', - 'unifiedFieldList', - 'svlCommonPage', - 'header', - ]); - const esArchiver = getService('esArchiver'); - const testSubjects = getService('testSubjects'); - const dataGrid = getService('dataGrid'); - const browser = getService('browser'); - const dataViews = getService('dataViews'); - +export default function ({}: FtrProviderContext) { describe('extension getRowIndicatorProvider', () => { - before(async () => { - await PageObjects.svlCommonPage.loginAsAdmin(); - await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - }); - - after(async () => { - await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); - }); - - it('should not render log.level row indicators for logs data source without a log.level field', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from logstash* | sort @timestamp desc' }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - // logstash does not have log.level field, so the color indicator should not be rendered - await testSubjects.existOrFail('euiDataGridBody'); - await testSubjects.missingOrFail('dataGridHeaderCell-colorIndicator'); - - // switch the time frame back - await browser.goBack(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - }); - - it('should not render log.level row indicators if not a logs data source', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { esql: 'from my-example* | sort @timestamp desc' }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - // my-example* has a log.level field, but it's not matching the logs profile, so the color indicator should not be rendered - await testSubjects.existOrFail('euiDataGridBody'); - await testSubjects.missingOrFail('dataGridHeaderCell-colorIndicator'); - }); - - it('should render log.level row indicators', async () => { - const state = kbnRison.encode({ - dataSource: { type: 'esql' }, - query: { - esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `log.level` is not null', - }, - }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { - ensureCurrentUrl: false, - }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - // in this case it's matching the logs data source profile and has a log.level field, so the color indicator should be rendered - await testSubjects.existOrFail('dataGridHeaderCell-colorIndicator'); - const firstCell = await dataGrid.getCellElement(0, 0); - const firstColorIndicator = await firstCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await firstColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - expect(await firstColorIndicator.getAttribute('title')).to.be('Debug'); - }); - - it('should render log.level row indicators on Surrounding documents page', async () => { - await PageObjects.common.navigateToApp('discover'); - await dataViews.switchTo('my-example-logs,logstash*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); - const [, surroundingActionEl] = await dataGrid.getRowActions(); - await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); - - let anchorCell = await dataGrid.getCellElement(0, 0); - let anchorColorIndicator = await anchorCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await anchorColorIndicator.getAttribute('title')).to.be('Debug'); - expect(await anchorColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - - let nextCell = await dataGrid.getCellElement(1, 0); - let nextColorIndicator = await nextCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await nextColorIndicator.getAttribute('title')).to.be('Error'); - expect(await nextColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(223, 147, 82, 1)' - ); - - await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - anchorCell = await dataGrid.getCellElement(0, 0); - anchorColorIndicator = await anchorCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await anchorColorIndicator.getAttribute('title')).to.be('Debug'); - expect(await anchorColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(190, 207, 227, 1)' - ); - - nextCell = await dataGrid.getCellElement(1, 0); - nextColorIndicator = await nextCell.findByTestSubject( - 'unifiedDataTableRowColorIndicatorCell' - ); - expect(await nextColorIndicator.getAttribute('title')).to.be('Error'); - expect(await nextColorIndicator.getComputedStyle('background-color')).to.be( - 'rgba(223, 147, 82, 1)' - ); - }); + // TODO: Add an example profile implementation to test here }); } diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/index.ts b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/index.ts index 9fb95c5ccd96..431c338c61e2 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/index.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/index.ts @@ -35,8 +35,7 @@ export default function ({ getService, getPageObjects, loadTestFile }: FtrProvid await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); }); - loadTestFile(require.resolve('./_root_profile')); - loadTestFile(require.resolve('./_data_source_profile')); + loadTestFile(require.resolve('./_framework')); loadTestFile(require.resolve('./extensions/_get_row_indicator_provider')); loadTestFile(require.resolve('./extensions/_get_row_additional_leading_controls')); loadTestFile(require.resolve('./extensions/_get_doc_viewer')); diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/esql/_esql_view.ts b/x-pack/test_serverless/functional/test_suites/common/discover/esql/_esql_view.ts index 828f262d6c74..18adba6a4a73 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/esql/_esql_view.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/esql/_esql_view.ts @@ -195,6 +195,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should render correctly if there are empty fields', async function () { await PageObjects.discover.selectTextBaseLang(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); const testQuery = `from logstash-* | limit 10 | keep machine.ram_range, bytes`; await monacoEditor.setCodeEditorValue(testQuery); @@ -203,11 +205,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.discover.waitUntilSearchingHasFinished(); const cell = await dataGrid.getCellElementExcludingControlColumns(0, 1); expect(await cell.getVisibleText()).to.be(' - '); - expect(await dataGrid.getHeaders()).to.eql([ - 'Select column', - 'Control column', - 'Access to degraded docs', - 'Access to available stacktraces', + expect((await dataGrid.getHeaders()).slice(-2)).to.eql([ 'Numberbytes', 'machine.ram_range', ]); diff --git a/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/_get_cell_renderers.ts b/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/_get_cell_renderers.ts new file mode 100644 index 000000000000..4fb26ff1a23d --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/_get_cell_renderers.ts @@ -0,0 +1,353 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import kbnRison from '@kbn/rison'; +import expect from '@kbn/expect'; +import type { WebElementWrapper } from '@kbn/ftr-common-functional-ui-services'; +import type { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const PageObjects = getPageObjects([ + 'common', + 'discover', + 'unifiedFieldList', + 'svlCommonPage', + 'header', + ]); + const esArchiver = getService('esArchiver'); + const testSubjects = getService('testSubjects'); + const dataGrid = getService('dataGrid'); + const dataViews = getService('dataViews'); + const queryBar = getService('queryBar'); + const browser = getService('browser'); + const retry = getService('retry'); + + describe('extension getCellRenderers', () => { + before(async () => { + await PageObjects.svlCommonPage.loginAsAdmin(); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + }); + + after(async () => { + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); + }); + + describe('ES|QL mode', () => { + describe('Log Level Badge Cell', () => { + it('should render log.level badge cell', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { + esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `log.level` is not null', + }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); + const logLevelBadge = await firstCell.findByTestSubject('*logLevelBadgeCell-'); + expect(await logLevelBadge.getVisibleText()).to.be('debug'); + expect(await logLevelBadge.getComputedStyle('background-color')).to.be( + 'rgba(190, 207, 227, 1)' + ); + }); + + it("should not render log.level badge cell if it's not a logs data source", async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { + esql: 'from my-example* | sort @timestamp desc | where `log.level` is not null', + }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + await retry.try(async () => { + const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); + expect(await firstCell.getVisibleText()).to.be('debug'); + await testSubjects.missingOrFail('*logLevelBadgeCell-'); + }); + }); + }); + + describe('Service Name Cell', () => { + it('should render service.name cell', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { + esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `service.name` is not null', + }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.unifiedFieldList.clickFieldListItemAdd('service.name'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); + const lastCell = await dataGrid.getCellElementExcludingControlColumns(2, 0); + const firstServiceNameCell = await firstCell.findByTestSubject( + 'dataTableCellActionsPopover_service.name' + ); + const lastServiceNameCell = await lastCell.findByTestSubject( + 'dataTableCellActionsPopover_service.name' + ); + expect(await firstServiceNameCell.getVisibleText()).to.be('product'); + expect(await lastServiceNameCell.getVisibleText()).to.be('accounting'); + }); + + it("should not render service.name cell if it's not a logs data source", async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { + esql: 'from my-example* | sort @timestamp desc | where `service.name` is not null', + }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.unifiedFieldList.clickFieldListItemAdd('service.name'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + await retry.try(async () => { + const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); + expect(await firstCell.getVisibleText()).to.be('product'); + await testSubjects.missingOrFail('dataTableCellActionsPopover_service.name'); + }); + }); + }); + + describe('Summary column', () => { + it('should render a summary of the log entry replacing the original document', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { + esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `message` is not null', + }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + await testSubjects.existOrFail('discoverDataTableMessageValue'); + }); + + it('should NOT render the summary column if the source does not match logs', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { + esql: 'from my-example-*', + }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + await testSubjects.missingOrFail('discoverDataTableMessageValue'); + }); + }); + }); + + describe('data view mode', () => { + describe('Log Level Badge Cell', () => { + it('should render log.level badge cell', async () => { + await PageObjects.common.navigateToActualUrl('discover', undefined, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataViews.switchToAndValidate('my-example-logs,logstash*'); + await queryBar.setQuery('log.level:*'); + await queryBar.submitQuery(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + let firstCell: WebElementWrapper; + let logLevelBadge: WebElementWrapper; + + await retry.try(async () => { + firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); + logLevelBadge = await firstCell.findByTestSubject('*logLevelBadgeCell-'); + expect(await logLevelBadge.getVisibleText()).to.be('debug'); + expect(await logLevelBadge.getComputedStyle('background-color')).to.be( + 'rgba(190, 207, 227, 1)' + ); + }); + + // check Surrounding docs page + await dataGrid.clickRowToggle(); + const [, surroundingActionEl] = await dataGrid.getRowActions(); + await surroundingActionEl.click(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await browser.refresh(); + await PageObjects.header.waitUntilLoadingHasFinished(); + + await retry.try(async () => { + firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); + logLevelBadge = await firstCell.findByTestSubject('*logLevelBadgeCell-'); + expect(await logLevelBadge.getVisibleText()).to.be('debug'); + expect(await logLevelBadge.getComputedStyle('background-color')).to.be( + 'rgba(190, 207, 227, 1)' + ); + }); + }); + + it("should not render log.level badge cell if it's not a logs data source", async () => { + await PageObjects.common.navigateToActualUrl('discover', undefined, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataViews.switchToAndValidate('my-example-*'); + await queryBar.setQuery('log.level:*'); + await queryBar.submitQuery(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + let firstCell: WebElementWrapper; + + await retry.try(async () => { + firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); + expect(await firstCell.getVisibleText()).to.be('debug'); + await testSubjects.missingOrFail('*logLevelBadgeCell-'); + }); + + // check Surrounding docs page + await dataGrid.clickRowToggle(); + const [, surroundingActionEl] = await dataGrid.getRowActions(); + await surroundingActionEl.click(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await browser.refresh(); + await PageObjects.header.waitUntilLoadingHasFinished(); + + await retry.try(async () => { + firstCell = await dataGrid.getCellElementExcludingControlColumns(1, 1); + expect(await firstCell.getVisibleText()).to.be('debug'); + await testSubjects.missingOrFail('*logLevelBadgeCell-'); + }); + }); + }); + describe('Service Name Cell', () => { + it('should render service.name cell', async () => { + await PageObjects.common.navigateToActualUrl('discover', undefined, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataViews.switchToAndValidate('my-example-logs,logstash*'); + await queryBar.setQuery('service.name:*'); + await queryBar.submitQuery(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.unifiedFieldList.clickFieldListItemAdd('service.name'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + let firstCell: WebElementWrapper; + let lastCell: WebElementWrapper; + + await retry.try(async () => { + firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); + lastCell = await dataGrid.getCellElementExcludingControlColumns(2, 1); + const firstServiceNameCell = await firstCell.findByTestSubject( + 'dataTableCellActionsPopover_service.name' + ); + const lastServiceNameCell = await lastCell.findByTestSubject( + 'dataTableCellActionsPopover_service.name' + ); + expect(await firstServiceNameCell.getVisibleText()).to.be('product'); + expect(await lastServiceNameCell.getVisibleText()).to.be('accounting'); + }); + }); + + it("should not render service.name cell if it's not a logs data source", async () => { + await PageObjects.common.navigateToActualUrl('discover', undefined, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataViews.switchToAndValidate('my-example-*'); + await queryBar.setQuery('service.name:*'); + await queryBar.submitQuery(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.unifiedFieldList.clickFieldListItemAdd('service.name'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + let firstCell: WebElementWrapper; + let lastCell: WebElementWrapper; + + await retry.try(async () => { + firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); + lastCell = await dataGrid.getCellElementExcludingControlColumns(2, 1); + + expect(await firstCell.getVisibleText()).to.be('product'); + expect(await lastCell.getVisibleText()).to.be('accounting'); + await testSubjects.missingOrFail('dataTableCellActionsPopover_service.name'); + }); + }); + }); + + describe('Summary column', () => { + it('should render a summary of the log entry replacing the original document', async () => { + await PageObjects.common.navigateToActualUrl('discover', undefined, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataViews.switchToAndValidate('my-example-logs,logstash*'); + + await retry.try(async () => { + await testSubjects.existOrFail('discoverDataTableMessageValue'); + }); + }); + + it('should NOT render the summary column if the source does not match logs', async () => { + await PageObjects.common.navigateToActualUrl('discover', undefined, { + ensureCurrentUrl: false, + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataViews.switchToAndValidate('my-example-*'); + + await retry.try(async () => { + await testSubjects.missingOrFail('discoverDataTableMessageValue'); + }); + }); + }); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/_get_doc_viewer.ts b/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/_get_doc_viewer.ts new file mode 100644 index 000000000000..adc466f238a5 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/_get_doc_viewer.ts @@ -0,0 +1,127 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import kbnRison from '@kbn/rison'; +import type { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const PageObjects = getPageObjects(['common', 'discover', 'svlCommonPage', 'header']); + const testSubjects = getService('testSubjects'); + const dataViews = getService('dataViews'); + const dataGrid = getService('dataGrid'); + const browser = getService('browser'); + + describe('extension getDocViewer', () => { + before(async () => { + await PageObjects.svlCommonPage.loginAsAdmin(); + }); + + describe('ES|QL mode', () => { + it('should render logs overview tab for logs data source', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { esql: 'from my-example-logs | sort @timestamp desc' }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle(); + await testSubjects.existOrFail('docViewerTab-doc_view_table'); + await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); + await dataGrid.clickDocViewerTab('doc_view_logs_overview'); + await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); + }); + + it('should not render logs overview tab for non-logs data source', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { esql: 'from my-example-metrics | sort @timestamp desc' }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle(); + await testSubjects.existOrFail('docViewerTab-doc_view_table'); + await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); + }); + }); + + describe('data view mode', () => { + it('should render logs overview tab for logs data source', async () => { + await PageObjects.common.navigateToActualUrl('discover', undefined, { + ensureCurrentUrl: false, + }); + await dataViews.switchTo('my-example-logs'); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle(); + await testSubjects.existOrFail('docViewerTab-doc_view_table'); + await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); + await dataGrid.clickDocViewerTab('doc_view_logs_overview'); + await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); + + // check Surrounding docs page + const [, surroundingActionEl] = await dataGrid.getRowActions(); + await surroundingActionEl.click(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await browser.refresh(); + await PageObjects.header.waitUntilLoadingHasFinished(); + + await dataGrid.clickRowToggle({ isAnchorRow: true }); + await testSubjects.existOrFail('docViewerTab-doc_view_table'); + await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); + await dataGrid.clickDocViewerTab('doc_view_logs_overview'); + await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); + + // check Single doc page + const [singleDocActionEl] = await dataGrid.getRowActions(); + await singleDocActionEl.click(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await browser.refresh(); + await PageObjects.header.waitUntilLoadingHasFinished(); + + await testSubjects.existOrFail('docViewerTab-doc_view_table'); + await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); + await dataGrid.clickDocViewerTab('doc_view_logs_overview'); + await testSubjects.existOrFail('unifiedDocViewLogsOverviewHeader'); + }); + + it('should not render logs overview tab for non-logs data source', async () => { + await PageObjects.common.navigateToActualUrl('discover', undefined, { + ensureCurrentUrl: false, + }); + await dataViews.switchTo('my-example-metrics'); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle(); + await testSubjects.existOrFail('docViewerTab-doc_view_table'); + await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); + + // check Surrounding docs page + const [, surroundingActionEl] = await dataGrid.getRowActions(); + await surroundingActionEl.click(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await browser.refresh(); + await PageObjects.header.waitUntilLoadingHasFinished(); + + await dataGrid.clickRowToggle({ isAnchorRow: true }); + await testSubjects.existOrFail('docViewerTab-doc_view_table'); + await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); + + // check Single doc page + const [singleDocActionEl] = await dataGrid.getRowActions(); + await singleDocActionEl.click(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await browser.refresh(); + await PageObjects.header.waitUntilLoadingHasFinished(); + + await testSubjects.existOrFail('docViewerTab-doc_view_table'); + await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); + }); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/_get_row_indicator_provider.ts b/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/_get_row_indicator_provider.ts new file mode 100644 index 000000000000..ddc3c1827055 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/_get_row_indicator_provider.ts @@ -0,0 +1,144 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import kbnRison from '@kbn/rison'; +import expect from '@kbn/expect'; +import type { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const PageObjects = getPageObjects([ + 'common', + 'timePicker', + 'discover', + 'unifiedFieldList', + 'svlCommonPage', + 'header', + ]); + const esArchiver = getService('esArchiver'); + const testSubjects = getService('testSubjects'); + const dataGrid = getService('dataGrid'); + const browser = getService('browser'); + const dataViews = getService('dataViews'); + + describe('extension getRowIndicatorProvider', () => { + before(async () => { + await PageObjects.svlCommonPage.loginAsAdmin(); + await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); + }); + + after(async () => { + await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); + }); + + it('should not render log.level row indicators for logs data source without a log.level field', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { esql: 'from logstash* | sort @timestamp desc' }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await PageObjects.timePicker.setDefaultAbsoluteRange(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + // logstash does not have log.level field, so the color indicator should not be rendered + await testSubjects.existOrFail('euiDataGridBody'); + await testSubjects.missingOrFail('dataGridHeaderCell-colorIndicator'); + + // switch the time frame back + await browser.goBack(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + }); + + it('should not render log.level row indicators if not a logs data source', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { esql: 'from my-example* | sort @timestamp desc' }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.discover.waitUntilSearchingHasFinished(); + // my-example* has a log.level field, but it's not matching the logs profile, so the color indicator should not be rendered + await testSubjects.existOrFail('euiDataGridBody'); + await testSubjects.missingOrFail('dataGridHeaderCell-colorIndicator'); + }); + + it('should render log.level row indicators', async () => { + const state = kbnRison.encode({ + dataSource: { type: 'esql' }, + query: { + esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `log.level` is not null', + }, + }); + await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + ensureCurrentUrl: false, + }); + await PageObjects.discover.waitUntilSearchingHasFinished(); + // in this case it's matching the logs data source profile and has a log.level field, so the color indicator should be rendered + await testSubjects.existOrFail('dataGridHeaderCell-colorIndicator'); + const firstCell = await dataGrid.getCellElement(0, 0); + const firstColorIndicator = await firstCell.findByTestSubject( + 'unifiedDataTableRowColorIndicatorCell' + ); + expect(await firstColorIndicator.getComputedStyle('background-color')).to.be( + 'rgba(190, 207, 227, 1)' + ); + expect(await firstColorIndicator.getAttribute('title')).to.be('Debug'); + }); + + it('should render log.level row indicators on Surrounding documents page', async () => { + await PageObjects.common.navigateToApp('discover'); + await dataViews.switchTo('my-example-logs,logstash*'); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await dataGrid.clickRowToggle({ rowIndex: 0 }); + const [, surroundingActionEl] = await dataGrid.getRowActions(); + await surroundingActionEl.click(); + await PageObjects.header.waitUntilLoadingHasFinished(); + + let anchorCell = await dataGrid.getCellElement(0, 0); + let anchorColorIndicator = await anchorCell.findByTestSubject( + 'unifiedDataTableRowColorIndicatorCell' + ); + expect(await anchorColorIndicator.getAttribute('title')).to.be('Debug'); + expect(await anchorColorIndicator.getComputedStyle('background-color')).to.be( + 'rgba(190, 207, 227, 1)' + ); + + let nextCell = await dataGrid.getCellElement(1, 0); + let nextColorIndicator = await nextCell.findByTestSubject( + 'unifiedDataTableRowColorIndicatorCell' + ); + expect(await nextColorIndicator.getAttribute('title')).to.be('Error'); + expect(await nextColorIndicator.getComputedStyle('background-color')).to.be( + 'rgba(223, 147, 82, 1)' + ); + + await browser.refresh(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + anchorCell = await dataGrid.getCellElement(0, 0); + anchorColorIndicator = await anchorCell.findByTestSubject( + 'unifiedDataTableRowColorIndicatorCell' + ); + expect(await anchorColorIndicator.getAttribute('title')).to.be('Debug'); + expect(await anchorColorIndicator.getComputedStyle('background-color')).to.be( + 'rgba(190, 207, 227, 1)' + ); + + nextCell = await dataGrid.getCellElement(1, 0); + nextColorIndicator = await nextCell.findByTestSubject( + 'unifiedDataTableRowColorIndicatorCell' + ); + expect(await nextColorIndicator.getAttribute('title')).to.be('Error'); + expect(await nextColorIndicator.getComputedStyle('background-color')).to.be( + 'rgba(223, 147, 82, 1)' + ); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/index.ts b/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/index.ts index c8277b273f42..9434ed2a37d3 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/index.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/discover/context_awareness/index.ts @@ -35,6 +35,9 @@ export default function ({ getService, getPageObjects, loadTestFile }: FtrProvid await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); }); + loadTestFile(require.resolve('./_get_row_indicator_provider')); + loadTestFile(require.resolve('./_get_doc_viewer')); + loadTestFile(require.resolve('./_get_cell_renderers')); loadTestFile(require.resolve('./_get_app_menu')); }); }