diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2ab013b8c4ac8..2be6a68143c60 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -794,6 +794,7 @@ src/platform/packages/shared/kbn-saved-search-component @elastic/obs-ux-logs-tea src/platform/plugins/shared/saved_search @elastic/kibana-data-discovery packages/kbn-scout @elastic/appex-qa packages/kbn-scout-info @elastic/appex-qa +x-pack/solutions/observability/packages/kbn-scout-oblt @elastic/appex-qa packages/kbn-scout-reporting @elastic/appex-qa examples/screenshot_mode_example @elastic/appex-sharedux src/platform/plugins/shared/screenshot_mode @elastic/appex-sharedux diff --git a/package.json b/package.json index f6cadd3f4156e..6e9770f9b593a 100644 --- a/package.json +++ b/package.json @@ -1496,6 +1496,7 @@ "@kbn/reporting-mocks-server": "link:src/platform/packages/private/kbn-reporting/mocks_server", "@kbn/scout": "link:packages/kbn-scout", "@kbn/scout-info": "link:packages/kbn-scout-info", + "@kbn/scout-oblt": "link:x-pack/solutions/observability/packages/kbn-scout-oblt", "@kbn/scout-reporting": "link:packages/kbn-scout-reporting", "@kbn/security-api-integration-helpers": "link:x-pack/test/security_api_integration/packages/helpers", "@kbn/serverless-storybook-config": "link:packages/serverless/storybook/config", diff --git a/packages/kbn-scout/index.ts b/packages/kbn-scout/index.ts index a7803d5e7104b..0b8fdad7e09c1 100644 --- a/packages/kbn-scout/index.ts +++ b/packages/kbn-scout/index.ts @@ -36,3 +36,8 @@ export type { ScoutServerConfig, ScoutTestConfig, } from './src/types'; + +// re-export from Playwright +export type { Locator } from 'playwright/test'; + +export { measurePerformance, measurePerformanceAsync } from './src/common'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_run_fixtures.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_run_fixtures.ts index 854a3696ce183..7638b0eb91a2c 100644 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_run_fixtures.ts +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_run_fixtures.ts @@ -8,8 +8,9 @@ */ import { mergeTests } from 'playwright/test'; -import { coreWorkerFixtures, scoutSpaceParallelFixture } from './worker'; +import { apiFixtures, coreWorkerFixtures, scoutSpaceParallelFixture } from './worker'; import type { + ApiParallelWorkerFixtures, EsClient, KbnClient, KibanaUrl, @@ -29,6 +30,7 @@ export const scoutParallelFixtures = mergeTests( // worker scope fixtures coreWorkerFixtures, scoutSpaceParallelFixture, + apiFixtures, // test scope fixtures browserAuthFixture, scoutPageParallelFixture, @@ -42,7 +44,7 @@ export interface ScoutParallelTestFixtures { pageObjects: PageObjects; } -export interface ScoutParallelWorkerFixtures { +export interface ScoutParallelWorkerFixtures extends ApiParallelWorkerFixtures { log: ScoutLogger; config: ScoutTestConfig; kbnUrl: KibanaUrl; diff --git a/packages/kbn-scout/src/playwright/fixtures/single_thread_fixtures.ts b/packages/kbn-scout/src/playwright/fixtures/single_thread_fixtures.ts index 541695bc3ce7d..931f6e6f4d7c5 100644 --- a/packages/kbn-scout/src/playwright/fixtures/single_thread_fixtures.ts +++ b/packages/kbn-scout/src/playwright/fixtures/single_thread_fixtures.ts @@ -8,7 +8,13 @@ */ import { mergeTests } from 'playwright/test'; -import { coreWorkerFixtures, esArchiverFixture, uiSettingsFixture } from './worker'; +import { + ApiFixtures, + apiFixtures, + coreWorkerFixtures, + esArchiverFixture, + uiSettingsFixture, +} from './worker'; import type { EsArchiverFixture, EsClient, @@ -34,6 +40,8 @@ export const scoutFixtures = mergeTests( coreWorkerFixtures, esArchiverFixture, uiSettingsFixture, + // api fixtures + apiFixtures, // test scope fixtures browserAuthFixture, scoutPageFixture, @@ -47,7 +55,7 @@ export interface ScoutTestFixtures { pageObjects: PageObjects; } -export interface ScoutWorkerFixtures { +export interface ScoutWorkerFixtures extends ApiFixtures { log: ScoutLogger; config: ScoutTestConfig; kbnUrl: KibanaUrl; diff --git a/packages/kbn-scout/src/playwright/fixtures/test/scout_page/index.ts b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/index.ts index b0486f961cc2a..7ea3887ccf826 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/scout_page/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/index.ts @@ -8,6 +8,7 @@ */ import { Page } from '@playwright/test'; +import { PathOptions } from '../../../../common/services/kibana_url'; /** * Extends the Playwright 'Page' interface with methods specific to Kibana. @@ -24,7 +25,7 @@ export type ScoutPage = Page & { * @param options - Additional navigation options, passed directly to Playwright's `goto` method. * @returns A Promise resolving to a Playwright `Response` or `null`. */ - gotoApp: (appName: string, options?: Parameters[1]) => ReturnType; + gotoApp: (appName: string, pathOptions?: PathOptions) => ReturnType; /** * Waits for the Kibana loading spinner indicator to disappear. * @returns A Promise resolving when the indicator is hidden. diff --git a/packages/kbn-scout/src/playwright/fixtures/test/scout_page/parallel.ts b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/parallel.ts index 8db44ef77c702..baceb3defbfe9 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/scout_page/parallel.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/parallel.ts @@ -8,6 +8,7 @@ */ import { Page, test as base } from '@playwright/test'; +import { PathOptions } from '../../../../common/services/kibana_url'; import { ScoutPage } from '.'; import { KibanaUrl, ScoutLogger } from '../../worker'; import { ScoutSpaceParallelFixture } from '../../worker/scout_space'; @@ -29,8 +30,8 @@ export const scoutPageParallelFixture = base.extend< const extendedPage = extendPlaywrightPage({ page, kbnUrl }); // Overriding navigation to specific Kibana apps: url should respect the Kibana Space id - extendedPage.gotoApp = (appName: string) => - page.goto(kbnUrl.app(appName, { space: scoutSpace.id })); + extendedPage.gotoApp = (appName: string, pathOptions?: PathOptions) => + page.goto(kbnUrl.app(appName, { space: scoutSpace.id, pathOptions })); log.serviceLoaded(`scoutPage:${scoutSpace.id}`); await use(extendedPage); diff --git a/packages/kbn-scout/src/playwright/fixtures/test/scout_page/single_thread.ts b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/single_thread.ts index 239498a9554da..12a50ee925815 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/scout_page/single_thread.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/single_thread.ts @@ -9,6 +9,7 @@ import { Page } from '@playwright/test'; import { subj } from '@kbn/test-subj-selector'; +import { PathOptions } from '../../../../common/services/kibana_url'; import { KibanaUrl, ScoutLogger, coreWorkerFixtures } from '../../worker'; import { ScoutPage } from '.'; @@ -81,7 +82,8 @@ export function extendPlaywrightPage({ // Extend page with '@kbn/test-subj-selector' support extendedPage.testSubj = extendPageWithTestSubject(page); // Method to navigate to specific Kibana apps - extendedPage.gotoApp = (appName: string) => page.goto(kbnUrl.app(appName)); + extendedPage.gotoApp = (appName: string, pathOptions?: PathOptions) => + page.goto(kbnUrl.app(appName, { pathOptions })); // Method to wait for global loading indicator to be hidden extendedPage.waitForLoadingIndicatorHidden = () => extendedPage.testSubj.waitForSelector('globalLoadingIndicator-hidden', { diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/apis/fleet/index.ts b/packages/kbn-scout/src/playwright/fixtures/worker/apis/fleet/index.ts new file mode 100644 index 0000000000000..b645cf1933673 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/worker/apis/fleet/index.ts @@ -0,0 +1,71 @@ +/* + * 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 { measurePerformanceAsync } from '../../../../../common'; +import { coreWorkerFixtures } from '../../core_fixtures'; + +export interface FleetApiFixture { + integration: { + install: (name: string) => Promise; + delete: (name: string) => Promise; + }; +} + +/** + * This fixture provides a helper to interact with the Fleet API. + */ +export const fleetApiFixture = coreWorkerFixtures.extend<{}, { fleetApi: FleetApiFixture }>({ + fleetApi: [ + async ({ kbnClient, log }, use) => { + const fleetApiHelper = { + integration: { + install: async (name: string) => { + await measurePerformanceAsync( + log, + `fleetApi.integration.install [${name}]`, + async () => { + await kbnClient.request({ + method: 'POST', + path: `/api/fleet/epm/custom_integrations`, + body: { + force: true, + integrationName: name, + datasets: [ + { name: `${name}.access`, type: 'logs' }, + { name: `${name}.error`, type: 'metrics' }, + { name: `${name}.warning`, type: 'logs' }, + ], + }, + }); + } + ); + }, + + delete: async (name: string) => { + await measurePerformanceAsync( + log, + `fleetApi.integration.delete [${name}]`, + async () => { + await kbnClient.request({ + method: 'DELETE', + path: `/api/fleet/epm/packages/${name}`, + ignoreErrors: [400], + }); + } + ); + }, + }, + }; + + log.serviceLoaded('fleetApi'); + await use(fleetApiHelper); + }, + { scope: 'worker' }, + ], +}); diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/apis/index.ts b/packages/kbn-scout/src/playwright/fixtures/worker/apis/index.ts new file mode 100644 index 0000000000000..ab3b50a2e4bd4 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/worker/apis/index.ts @@ -0,0 +1,21 @@ +/* + * 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 { mergeTests } from 'playwright/test'; +import { FleetApiFixture, fleetApiFixture } from './fleet'; + +export const apiFixtures = mergeTests(fleetApiFixture); + +export interface ApiFixtures { + fleetApi: FleetApiFixture; +} + +export interface ApiParallelWorkerFixtures { + fleetApi: FleetApiFixture; +} diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/index.ts b/packages/kbn-scout/src/playwright/fixtures/worker/index.ts index f6ca4561eaa07..ab4a966ee9199 100644 --- a/packages/kbn-scout/src/playwright/fixtures/worker/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/index.ts @@ -25,3 +25,6 @@ export type { UiSettingsFixture } from './ui_settings'; export { scoutSpaceParallelFixture } from './scout_space'; export type { ScoutSpaceParallelFixture } from './scout_space'; + +export { apiFixtures } from './apis'; +export type { ApiFixtures, ApiParallelWorkerFixtures } from './apis'; diff --git a/tsconfig.base.json b/tsconfig.base.json index 77bf90b837287..905ab227a8dd7 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1582,6 +1582,8 @@ "@kbn/scout/*": ["packages/kbn-scout/*"], "@kbn/scout-info": ["packages/kbn-scout-info"], "@kbn/scout-info/*": ["packages/kbn-scout-info/*"], + "@kbn/scout-oblt": ["x-pack/solutions/observability/packages/kbn-scout-oblt"], + "@kbn/scout-oblt/*": ["x-pack/solutions/observability/packages/kbn-scout-oblt/*"], "@kbn/scout-reporting": ["packages/kbn-scout-reporting"], "@kbn/scout-reporting/*": ["packages/kbn-scout-reporting/*"], "@kbn/screenshot-mode-example-plugin": ["examples/screenshot_mode_example"], diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/README.md b/x-pack/solutions/observability/packages/kbn-scout-oblt/README.md new file mode 100644 index 0000000000000..5da551151c71e --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/README.md @@ -0,0 +1,45 @@ +# @kbn/scout-oblt + +`@kbn/scout-oblt` is a test library that extends `@kbn/scout` with test helpers specifically designed for `Observability` products in Kibana. + +Its primary goal is to simplify the test development experience for teams working on `Observability` plugins by providing custom Playwright fixtures, page objects, and utilities tailored for Observability-related testing scenarios. + +### Table of Contents + +1. Folder Structure +2. How to Use +3. Contributing + +### Folder Structure + +The `@kbn/scout-oblt` structure includes the following key directories and files: + +``` +x-pack/solutions/observability/packages/kbn-scout-oblt/ +├── src/ +│ ├── playwright/ +│ │ └── fixtures +│ │ │ └── test/ +│ │ │ │ └── // Observability test-scope fixtures +│ │ │ └── worker/ +│ │ │ │ └── // Observability worker-scope fixtures +│ │ │ └── single_thread_fixtures.ts +│ │ │ └── parallel_run_fixtures.ts +│ │ │ └── index.ts +│ │ └── page_objects/ +│ │ │ └── // Observability pages +│ └── index.ts +├── package.json +├── tsconfig.json +``` + +### How to use + +``` +import { test } from '@kbn/scout-oblt'; + +test('verifies Observability Home loads', async ({ page, pageObjects }) => { + await pageObjects.onboardingHome.goto(); + expect(await page.title()).toContain('Observability'); +}); +``` diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/index.ts b/x-pack/solutions/observability/packages/kbn-scout-oblt/index.ts new file mode 100644 index 0000000000000..804af1d20f7ab --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/index.ts @@ -0,0 +1,38 @@ +/* + * 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. + */ + +export { test, spaceTest } from './src/playwright'; +export type { + ObltPageObjects, + ObltTestFixtures, + ObltWorkerFixtures, + ObltParallelTestFixtures, + ObltParallelWorkerFixtures, +} from './src/playwright'; + +// re-export from @kbn/scout +export { + expect, + tags, + createPlaywrightConfig, + createLazyPageObject, + ingestTestDataHook, +} from '@kbn/scout'; + +export type { + EsClient, + KbnClient, + KibanaUrl, + ScoutLogger, + ScoutPage, + PageObjects, + ScoutServerConfig, + ScoutTestConfig, + ScoutPlaywrightOptions, + ScoutTestOptions, + Locator, +} from '@kbn/scout'; diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/jest.config.js b/x-pack/solutions/observability/packages/kbn-scout-oblt/jest.config.js new file mode 100644 index 0000000000000..00a75697f0624 --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/jest.config.js @@ -0,0 +1,12 @@ +/* + * 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. + */ + +module.exports = { + preset: '@kbn/test/jest_node', + rootDir: '../../../../..', + roots: ['/x-pack/solutions/observability/packages/kbn-scout-oblt'], +}; diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/kibana.jsonc b/x-pack/solutions/observability/packages/kbn-scout-oblt/kibana.jsonc new file mode 100644 index 0000000000000..76ad3d24c94b1 --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/kibana.jsonc @@ -0,0 +1,6 @@ +{ + "type": "test-helper", + "id": "@kbn/scout-oblt", + "owner": "@elastic/appex-qa", + "devOnly": true +} diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/package.json b/x-pack/solutions/observability/packages/kbn-scout-oblt/package.json new file mode 100644 index 0000000000000..5da158d710001 --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/scout-oblt", + "private": true, + "version": "1.0.0", + "license": "Elastic License 2.0" +} \ No newline at end of file diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/index.ts b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/index.ts new file mode 100644 index 0000000000000..b05e86d128a2e --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { test } from './single_thread_fixtures'; +export { spaceTest } from './parallel_run_fixtures'; +export * from './types'; diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/parallel_run_fixtures.ts b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/parallel_run_fixtures.ts new file mode 100644 index 0000000000000..09501b5231749 --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/parallel_run_fixtures.ts @@ -0,0 +1,30 @@ +/* + * 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 { spaceTest as spaceBase } from '@kbn/scout'; + +import { extendPageObjects } from '../page_objects'; +import { ObltParallelTestFixtures, ObltParallelWorkerFixtures } from './types'; + +/** + * Should be used test spec files, running in parallel in isolated spaces agaist the same Kibana instance. + */ +export const spaceTest = spaceBase.extend({ + pageObjects: async ( + { + pageObjects, + page, + }: { + pageObjects: ObltParallelTestFixtures['pageObjects']; + page: ObltParallelTestFixtures['page']; + }, + use: (pageObjects: ObltParallelTestFixtures['pageObjects']) => Promise + ) => { + const extendedPageObjects = extendPageObjects(pageObjects, page); + await use(extendedPageObjects); + }, +}); diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/single_thread_fixtures.ts b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/single_thread_fixtures.ts new file mode 100644 index 0000000000000..24497b4f414be --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/single_thread_fixtures.ts @@ -0,0 +1,30 @@ +/* + * 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 { test as base } from '@kbn/scout'; + +import { extendPageObjects } from '../page_objects'; +import { ObltTestFixtures, ObltWorkerFixtures } from './types'; + +/** + * Should be used for the test spec files executed seqentially. + */ +export const test = base.extend({ + pageObjects: async ( + { + pageObjects, + page, + }: { + pageObjects: ObltTestFixtures['pageObjects']; + page: ObltTestFixtures['page']; + }, + use: (pageObjects: ObltTestFixtures['pageObjects']) => Promise + ) => { + const extendedPageObjects = extendPageObjects(pageObjects, page); + await use(extendedPageObjects); + }, +}); diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/types.ts b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/types.ts new file mode 100644 index 0000000000000..ca432dfb4820f --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/fixtures/types.ts @@ -0,0 +1,26 @@ +/* + * 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 { + ScoutParallelTestFixtures, + ScoutParallelWorkerFixtures, + ScoutTestFixtures, + ScoutWorkerFixtures, +} from '@kbn/scout'; +import { ObltPageObjects } from '../page_objects'; + +export interface ObltTestFixtures extends ScoutTestFixtures { + pageObjects: ObltPageObjects; +} + +export type ObltWorkerFixtures = ScoutWorkerFixtures; + +export interface ObltParallelTestFixtures extends ScoutParallelTestFixtures { + pageObjects: ObltPageObjects; +} + +export type ObltParallelWorkerFixtures = ScoutParallelWorkerFixtures; diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/index.ts b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/index.ts new file mode 100644 index 0000000000000..6547510ec58a9 --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export * from './fixtures'; +export type { ObltPageObjects } from './page_objects'; diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/page_objects/custom_logs.ts b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/page_objects/custom_logs.ts new file mode 100644 index 0000000000000..6001bf086fed3 --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/page_objects/custom_logs.ts @@ -0,0 +1,125 @@ +/* + * 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 { ScoutPage, Locator } from '@kbn/scout'; + +export class CustomLogsPage { + public advancedSettingsContent: Locator; + public logFilePathList: Locator; + public addLogFilePathButton: Locator; + public integrationNameInput: Locator; + public datasetNameInput: Locator; + public serviceNameInput: Locator; + public namespaceInput: Locator; + public customConfigInput: Locator; + public customIntegrationInstalledCallout: Locator; + public customIntegrationErrorCallout: Locator; + public apiKeyCreatedCallout: Locator; + public apiKeyPrivilegesErrorCallout: Locator; + public apiKeyCreateErrorCallout: Locator; + public autoDownloadConfigurationToggle: Locator; + public autoDownloadConfigurationCallout: Locator; + public installCodeSnippet: Locator; + public windowsInstallElasticAgentDocLink: Locator; + public configureElasticAgentStep: Locator; + public downloadConfigurationButton: Locator; + public continueButton: Locator; + public exploreLogsButton: Locator; + public checkLogsStepMessage: Locator; + + constructor(private readonly page: ScoutPage) { + this.advancedSettingsContent = this.page.testSubj + .locator('obltOnboardingCustomLogsAdvancedSettings') + .getByRole('group'); + this.logFilePathList = this.page.locator(`[data-test-subj^=obltOnboardingLogFilePath-]`); + this.addLogFilePathButton = this.page.testSubj.locator('obltOnboardingCustomLogsAddFilePath'); + this.integrationNameInput = this.page.testSubj.locator( + 'obltOnboardingCustomLogsIntegrationsName' + ); + this.datasetNameInput = this.page.testSubj.locator('obltOnboardingCustomLogsDatasetName'); + this.serviceNameInput = this.page.testSubj.locator('obltOnboardingCustomLogsServiceName'); + this.namespaceInput = this.page.testSubj.locator('obltOnboardingCustomLogsNamespace'); + + this.continueButton = page.testSubj.locator('obltOnboardingCustomLogsContinue'); + + this.customConfigInput = this.page.testSubj.locator('obltOnboardingCustomLogsCustomConfig'); + this.customIntegrationInstalledCallout = this.page.testSubj.locator( + 'obltOnboardingCustomIntegrationInstalled' + ); + this.customIntegrationErrorCallout = this.page.testSubj.locator( + 'obltOnboardingCustomIntegrationErrorCallout' + ); + this.apiKeyCreatedCallout = this.page.testSubj.locator('obltOnboardingLogsApiKeyCreated'); + this.apiKeyPrivilegesErrorCallout = this.page.testSubj.locator( + 'obltOnboardingLogsApiKeyCreationNoPrivileges' + ); + this.apiKeyCreateErrorCallout = this.page.testSubj.locator( + 'obltOnboardingLogsApiKeyCreationFailed' + ); + this.autoDownloadConfigurationToggle = this.page.testSubj.locator( + 'obltOnboardingInstallElasticAgentAutoDownloadConfig' + ); + this.autoDownloadConfigurationCallout = this.page.testSubj.locator( + 'obltOnboardingInstallElasticAgentAutoDownloadConfigCallout' + ); + this.installCodeSnippet = this.page.testSubj + .locator('obltOnboardingInstallElasticAgentStep') + .getByRole('code'); + this.windowsInstallElasticAgentDocLink = this.page.testSubj.locator( + 'obltOnboardingInstallElasticAgentWindowsDocsLink' + ); + this.configureElasticAgentStep = this.page.testSubj.locator( + 'obltOnboardingConfigureElasticAgentStep' + ); + this.downloadConfigurationButton = this.page.testSubj.locator( + 'obltOnboardingConfigureElasticAgentStepDownloadConfig' + ); + + this.exploreLogsButton = this.page.testSubj.locator('obltOnboardingExploreLogs'); + this.checkLogsStepMessage = this.page.testSubj + .locator('obltOnboardingCheckLogsStep') + .locator(`.euiStep__title`); + } + + async goto() { + return this.page.gotoApp('observabilityOnboarding/customLogs'); + } + + async clickBackButton() { + return this.page.testSubj.click('observabilityOnboardingFlowBackToSelectionButton'); + } + + getLogFilePathInputField(index: number) { + return this.page.testSubj.locator(`obltOnboardingLogFilePath-${index}`).getByRole('textbox'); + } + + logFilePathDeleteButton(index: number) { + return this.page.testSubj.locator(`obltOnboardingLogFilePathDelete-${index}`); + } + + async clickAdvancedSettingsButton() { + return this.page.testSubj + .locator('obltOnboardingCustomLogsAdvancedSettings') + .getByRole('button') + .first() + .click(); + } + + getStepStatusLocator(status: 'loading' | 'complete' | 'danger' | 'warning') { + return this.page.testSubj.locator(`obltOnboardingStepStatus-${status}`); + } + + async selectPlatform(name: 'linux' | 'macos' | 'windows') { + return this.page.testSubj.click(name); + } + + getCheckLogsStepLocator(status: 'loading' | 'incomplete' | 'complete') { + return this.page.testSubj + .locator('obltOnboardingCheckLogsStep') + .locator(`.euiStep__titleWrapper [class$="euiStepNumber-s-${status}"]`); + } +} diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/page_objects/index.ts b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/page_objects/index.ts new file mode 100644 index 0000000000000..b77086fc337a6 --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/page_objects/index.ts @@ -0,0 +1,23 @@ +/* + * 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 { PageObjects, ScoutPage, createLazyPageObject } from '@kbn/scout'; +import { OnboardingHomePage } from './onboarding_home'; +import { CustomLogsPage } from './custom_logs'; + +export interface ObltPageObjects extends PageObjects { + onboardingHome: OnboardingHomePage; + customLogs: CustomLogsPage; +} + +export function extendPageObjects(pageObjects: PageObjects, page: ScoutPage): ObltPageObjects { + return { + ...pageObjects, + onboardingHome: createLazyPageObject(OnboardingHomePage, page), + customLogs: createLazyPageObject(CustomLogsPage, page), + }; +} diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/page_objects/onboarding_home.ts b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/page_objects/onboarding_home.ts new file mode 100644 index 0000000000000..a1b1f6769beaf --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/src/playwright/page_objects/onboarding_home.ts @@ -0,0 +1,15 @@ +/* + * 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 { i18n } from '@kbn/i18n'; + +export const QUERY_TESTER_TITLE = i18n.translate( + 'xpack.enterpriseSearch.appSearch.engine.queryTesterTitle', + { + defaultMessage: 'Query tester', + } +); diff --git a/x-pack/solutions/observability/packages/kbn-scout-oblt/tsconfig.json b/x-pack/solutions/observability/packages/kbn-scout-oblt/tsconfig.json new file mode 100644 index 0000000000000..0db5429ff903d --- /dev/null +++ b/x-pack/solutions/observability/packages/kbn-scout-oblt/tsconfig.json @@ -0,0 +1,20 @@ +{ + "extends": "../../../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node" + ] + }, + "include": [ + "**/*.ts", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/scout", + "@kbn/i18n", + ] +} diff --git a/yarn.lock b/yarn.lock index 8fa976f9c87eb..b763485ddc795 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7014,6 +7014,10 @@ version "0.0.0" uid "" +"@kbn/scout-oblt@link:x-pack/solutions/observability/packages/kbn-scout-oblt": + version "0.0.0" + uid "" + "@kbn/scout-reporting@link:packages/kbn-scout-reporting": version "0.0.0" uid ""