diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/run_check_ftr_configs_cli.ts b/packages/kbn-test/src/functional_test_runner/lib/config/run_check_ftr_configs_cli.ts index 5808c88901b11..265bdbe9e0082 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/config/run_check_ftr_configs_cli.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/config/run_check_ftr_configs_cli.ts @@ -25,6 +25,10 @@ const THIS_REL = Path.relative(REPO_ROOT, THIS_PATH); const IGNORED_PATHS = [ THIS_PATH, Path.resolve(REPO_ROOT, 'packages/kbn-test/src/jest/run_check_jest_configs_cli.ts'), + Path.resolve( + REPO_ROOT, + 'x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/playwright.config.ts' + ), ]; export async function runCheckFtrConfigsCli() { diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/.gitignore b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/.gitignore new file mode 100644 index 0000000000000..b88cb2a2003ab --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/.gitignore @@ -0,0 +1,2 @@ +.playwright +.env* diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/README.md b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/README.md new file mode 100644 index 0000000000000..f2952214127f4 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/README.md @@ -0,0 +1,25 @@ +# Observability Onboarding Playwright Tests + +These tests are part of the [Nightly CI workflow](https://github.com/elastic/ensemble/actions/workflows/nightly.yml) and do not run on PRs. + +Playwright tests are only responsible for UI checks and do not automate onboarding flows fully. On the CI, the missing parts (like executing code snippets on the host) are automated by Ensemble stories, but when running locally you need to do those steps manually. + +## Running The Tests Locally + +1. Run ES and Kibana +2. Create a `.env` file in the `./x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/` directory with the following content (adjust the values like Kibana URL according yo your local setup): +```bash +KIBANA_BASE_URL = "http://localhost:5601/ftw" +ELASTICSEARCH_HOST = "http://localhost:9200" +KIBANA_USERNAME = "elastic" +KIBANA_PASSWORD = "changeme" +CLUSTER_ENVIRONMENT = local +ARTIFACTS_FOLDER = ./.playwright +``` +3. Run the `playwright test` +```bash +# Assuming the working directory is the root of the Kibana repo +npx playwright test -c ./x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/playwright.config.ts --project stateful --reporter list --headed +``` +4. Once the test reaches one of the required manual steps, like executing auto-detect command snippet, do the step manually. +5. The test will proceed once the manual step is done. diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/lib/assert_env.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/lib/assert_env.ts new file mode 100644 index 0000000000000..6c54cabdc1601 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/lib/assert_env.ts @@ -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. + */ + +export function assertEnv(variable: unknown, message: string): asserts variable is string { + if (typeof variable !== 'string') { + throw new Error(message); + } +} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/lib/helpers.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/lib/helpers.ts new file mode 100644 index 0000000000000..e7c6afaefbd23 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/lib/helpers.ts @@ -0,0 +1,35 @@ +/* + * 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 { Locator } from '@playwright/test'; +import { HeaderBar } from '../stateful/pom/components/header_bar.component'; +import { SpaceSelector } from '../stateful/pom/components/space_selector.component'; + +type WaitForRes = [locatorIndex: number, locator: Locator]; + +export async function waitForOneOf(locators: Locator[]): Promise { + const res = await Promise.race([ + ...locators.map(async (locator, index): Promise => { + let timedOut = false; + await locator.waitFor({ state: 'visible' }).catch(() => (timedOut = true)); + return [timedOut ? -1 : index, locator]; + }), + ]); + if (res[0] === -1) { + throw new Error('No locator is visible before timeout.'); + } + return res; +} + +export async function spaceSelectorStateful(headerBar: HeaderBar, spaceSelector: SpaceSelector) { + const [index] = await waitForOneOf([headerBar.helpMenuButton(), spaceSelector.spaceSelector()]); + const selector = index === 1; + if (selector) { + await spaceSelector.selectDefault(); + await headerBar.assertHelpMenuButton(); + } +} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/lib/logger.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/lib/logger.ts new file mode 100644 index 0000000000000..92ec2ba6918f0 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/lib/logger.ts @@ -0,0 +1,13 @@ +/* + * 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 { ToolingLog } from '@kbn/tooling-log'; + +export const log: ToolingLog = new ToolingLog({ + level: 'info', + writeTo: process.stdout, +}); diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/playwright.config.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/playwright.config.ts new file mode 100644 index 0000000000000..39217999f5a2e --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/playwright.config.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 dotenv from 'dotenv'; +import { defineConfig, devices } from '@playwright/test'; +import path from 'path'; +import { log } from './lib/logger'; +import { assertEnv } from './lib/assert_env'; + +const dotEnvPath = process.env.DOTENV_PATH ?? path.join(__dirname, '.env'); + +dotenv.config({ path: dotEnvPath }); + +assertEnv(process.env.ARTIFACTS_FOLDER, 'ARTIFACTS_FOLDER is not defined.'); + +export const STORAGE_STATE = path.join(__dirname, process.env.ARTIFACTS_FOLDER, '.auth/user.json'); + +// eslint-disable-next-line import/no-default-export +export default defineConfig({ + testDir: './', + outputDir: './.playwright', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + // workers: 4, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: [ + ['json'], + ['json', { outputFile: path.join(process.env.ARTIFACTS_FOLDER, 'results.json') }], + ], + /* Timeouts */ + timeout: 400000, + expect: { timeout: 400000 }, + + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: process.env.KIBANA_BASE_URL, + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + testIdAttribute: 'data-test-subj', + permissions: ['clipboard-read'], + screenshot: 'only-on-failure', + }, + + projects: [ + { + name: 'auth', + testMatch: '*stateful/auth.ts', + use: { + viewport: { width: 1920, height: 1080 }, + launchOptions: { + logger: { + isEnabled: () => true, + log: (name, severity, message) => log.info(`[${severity}] ${name} ${message}`), + }, + }, + }, + }, + { + name: 'stateful', + testMatch: '*stateful/*.spec.ts', + use: { + ...devices['Desktop Chrome'], + viewport: { width: 1920, height: 1200 }, + storageState: STORAGE_STATE, + launchOptions: { + logger: { + isEnabled: () => true, + log: (name, severity, message) => log.info(`[${severity}] ${name} ${message}`), + }, + }, + }, + dependencies: ['auth'], + }, + { + name: 'teardown', + testMatch: 'teardown.setup.ts', + use: { + viewport: { width: 1920, height: 1080 }, + storageState: STORAGE_STATE, + testIdAttribute: 'data-test-subj', + launchOptions: { + logger: { + isEnabled: () => true, + log: (name, severity, message) => log.info(`[${severity}] ${name} ${message}`), + }, + }, + }, + }, + ], +}); diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/auth.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/auth.ts new file mode 100644 index 0000000000000..726085fbabc33 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/auth.ts @@ -0,0 +1,50 @@ +/* + * 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 ess_auth, expect } from '@playwright/test'; +import { STORAGE_STATE } from '../playwright.config'; +import { waitForOneOf } from '../lib/helpers'; +import { log } from '../lib/logger'; +import { assertEnv } from '../lib/assert_env'; + +const isLocalCluster = process.env.CLUSTER_ENVIRONMENT === 'local'; + +ess_auth('Authentication', async ({ page }) => { + assertEnv(process.env.KIBANA_BASE_URL, 'KIBANA_BASE_URL is not defined.'); + assertEnv(process.env.KIBANA_USERNAME, 'KIBANA_USERNAME is not defined.'); + assertEnv(process.env.KIBANA_PASSWORD, 'KIBANA_PASSWORD is not defined.'); + + await page.goto(process.env.KIBANA_BASE_URL); + log.info(`...waiting for login page elements to appear.`); + if (!isLocalCluster) { + await page.getByRole('button', { name: 'Log in with Elasticsearch' }).click(); + } + await page.getByLabel('Username').fill(process.env.KIBANA_USERNAME); + await page.getByLabel('Password', { exact: true }).click(); + await page.getByLabel('Password', { exact: true }).fill(process.env.KIBANA_PASSWORD); + await page.getByRole('button', { name: 'Log in' }).click(); + + const [index] = await waitForOneOf([ + page.getByTestId('helpMenuButton'), + page.getByText('Select your space'), + page.getByTestId('loginErrorMessage'), + ]); + + const spaceSelector = index === 1; + const isAuthenticated = index === 0; + + if (isAuthenticated) { + await page.context().storageState({ path: STORAGE_STATE }); + } else if (spaceSelector) { + await page.getByRole('link', { name: 'Default' }).click(); + await expect(page.getByTestId('helpMenuButton')).toBeVisible(); + await page.context().storageState({ path: STORAGE_STATE }); + } else { + log.error('Username or password is incorrect.'); + throw new Error('Authentication is failed.'); + } +}); diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/auto_detect.spec.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/auto_detect.spec.ts new file mode 100644 index 0000000000000..cff927a2061c1 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/auto_detect.spec.ts @@ -0,0 +1,65 @@ +/* + * 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 fs from 'node:fs'; +import path from 'node:path'; +import { test } from './fixtures/base_page'; +import { HostDetailsPage } from './pom/pages/host_details.page'; +import { assertEnv } from '../lib/assert_env'; + +test.beforeEach(async ({ page }) => { + await page.goto(`${process.env.KIBANA_BASE_URL}/app/observabilityOnboarding`); +}); + +test('Auto-detect logs and metrics', async ({ page, onboardingHomePage, autoDetectFlowPage }) => { + assertEnv(process.env.ARTIFACTS_FOLDER, 'ARTIFACTS_FOLDER is not defined.'); + + const fileName = 'code_snippet_logs_auto_detect.sh'; + const outputPath = path.join(__dirname, '..', process.env.ARTIFACTS_FOLDER, fileName); + + await onboardingHomePage.selectHostUseCase(); + await onboardingHomePage.selectAutoDetectWithElasticAgent(); + + await autoDetectFlowPage.assertVisibilityCodeBlock(); + await autoDetectFlowPage.copyToClipboard(); + + const clipboardData = (await page.evaluate('navigator.clipboard.readText()')) as string; + + /** + * Ensemble story watches for the code snippet file + * to be created and then executes it + */ + fs.writeFileSync(outputPath, clipboardData); + + await autoDetectFlowPage.assertReceivedDataIndicator(); + await autoDetectFlowPage.clickAutoDetectSystemIntegrationCTA(); + + /** + * Host Details pages open in a new tab, so it + * needs to be captured using the `popup` event. + */ + const hostDetailsPage = new HostDetailsPage(await page.waitForEvent('popup')); + + /** + * There is a glitch on the Hosts page where it can show "No data" + * screen even though data is available and it can show it with a delay + * after the Hosts page layout was loaded. This workaround waits for + * the No Data screen to be visible, and if so - reloads the page. + * If the No Data screen does not appear, the test can proceed normally. + * Seems like some caching issue with the Hosts page. + */ + try { + await hostDetailsPage.noData().waitFor({ state: 'visible', timeout: 10000 }); + await hostDetailsPage.page.waitForTimeout(2000); + await hostDetailsPage.page.reload(); + } catch { + /* Ignore if "No Data" screen never showed up */ + } + + await hostDetailsPage.clickHostDetailsLogsTab(); + await hostDetailsPage.assertHostDetailsLogsStream(); +}); diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/fixtures/base_page.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/fixtures/base_page.ts new file mode 100644 index 0000000000000..e10be1d60cc1c --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/fixtures/base_page.ts @@ -0,0 +1,47 @@ +/* + * 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 '@playwright/test'; +import { HeaderBar } from '../pom/components/header_bar.component'; +import { OnboardingHomePage } from '../pom/pages/onboarding_home.page'; +import { SpaceSelector } from '../pom/components/space_selector.component'; +import { KubernetesOverviewDashboardPage } from '../pom/pages/kubernetes_overview_dashboard.page'; +import { AutoDetectFlowPage } from '../pom/pages/auto_detect_flow.page'; +import { KubernetesEAFlowPage } from '../pom/pages/kubernetes_ea_flow.page'; + +export const test = base.extend<{ + headerBar: HeaderBar; + spaceSelector: SpaceSelector; + onboardingHomePage: OnboardingHomePage; + autoDetectFlowPage: AutoDetectFlowPage; + kubernetesEAFlowPage: KubernetesEAFlowPage; + kubernetesOverviewDashboardPage: KubernetesOverviewDashboardPage; +}>({ + headerBar: async ({ page }, use) => { + await use(new HeaderBar(page)); + }, + + spaceSelector: async ({ page }, use) => { + await use(new SpaceSelector(page)); + }, + + onboardingHomePage: async ({ page }, use) => { + await use(new OnboardingHomePage(page)); + }, + + autoDetectFlowPage: async ({ page }, use) => { + await use(new AutoDetectFlowPage(page)); + }, + + kubernetesEAFlowPage: async ({ page }, use) => { + await use(new KubernetesEAFlowPage(page)); + }, + + kubernetesOverviewDashboardPage: async ({ page }, use) => { + await use(new KubernetesOverviewDashboardPage(page)); + }, +}); diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/kubernetes_ea.spec.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/kubernetes_ea.spec.ts new file mode 100644 index 0000000000000..8478630b232f0 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/kubernetes_ea.spec.ts @@ -0,0 +1,66 @@ +/* + * 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 fs from 'node:fs'; +import path from 'node:path'; +import { test } from './fixtures/base_page'; +import { assertEnv } from '../lib/assert_env'; + +test.beforeEach(async ({ page }) => { + await page.goto(`${process.env.KIBANA_BASE_URL}/app/observabilityOnboarding`); +}); + +test('Kubernetes EA', async ({ + page, + onboardingHomePage, + kubernetesEAFlowPage, + kubernetesOverviewDashboardPage, +}) => { + assertEnv(process.env.ARTIFACTS_FOLDER, 'ARTIFACTS_FOLDER is not defined.'); + + const fileName = 'code_snippet_kubernetes.sh'; + const outputPath = path.join(__dirname, '..', process.env.ARTIFACTS_FOLDER, fileName); + + await onboardingHomePage.selectKubernetesUseCase(); + await onboardingHomePage.selectKubernetesQuickstart(); + + await kubernetesEAFlowPage.assertVisibilityCodeBlock(); + await kubernetesEAFlowPage.copyToClipboard(); + + const clipboardData = (await page.evaluate('navigator.clipboard.readText()')) as string; + /** + * The page waits for the browser window to loose + * focus as a signal to start checking for incoming data + */ + await page.evaluate('window.dispatchEvent(new Event("blur"))'); + + /** + * Ensemble story watches for the code snippet file + * to be created and then executes it + */ + fs.writeFileSync(outputPath, clipboardData); + + await kubernetesEAFlowPage.assertReceivedDataIndicatorKubernetes(); + await kubernetesEAFlowPage.clickKubernetesAgentCTA(); + + await kubernetesOverviewDashboardPage.openNodesInspector(); + /** + * There might be a case that dashboard still does not show + * the data even though it was ingested already. This usually + * happens during in the test when navigation from the onboarding + * flow to the dashboard happens almost immediately. + * Waiting for a few seconds and reloading the page handles + * this case and makes the test a bit more robust. + */ + try { + await kubernetesOverviewDashboardPage.assertNodesNoResultsNotVisible(); + } catch { + await kubernetesOverviewDashboardPage.page.waitForTimeout(2000); + await kubernetesOverviewDashboardPage.page.reload(); + } + await kubernetesOverviewDashboardPage.assetNodesInspectorStatusTableCells(); +}); diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/components/header_bar.component.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/components/header_bar.component.ts new file mode 100644 index 0000000000000..9165622bf6ce0 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/components/header_bar.component.ts @@ -0,0 +1,22 @@ +/* + * 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 { expect, Page } from '@playwright/test'; + +export class HeaderBar { + page: Page; + + constructor(page: Page) { + this.page = page; + } + + public readonly helpMenuButton = () => this.page.getByTestId('helpMenuButton'); + + public async assertHelpMenuButton() { + await expect(this.helpMenuButton(), 'Help menu button').toBeVisible(); + } +} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/components/space_selector.component.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/components/space_selector.component.ts new file mode 100644 index 0000000000000..8527141d455af --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/components/space_selector.component.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 { Page } from '@playwright/test'; + +export class SpaceSelector { + page: Page; + + constructor(page: Page) { + this.page = page; + } + + public readonly spaceSelector = () => this.page.getByText('Select your space'); + private readonly spaceSelectorDefault = () => this.page.getByRole('link', { name: 'Default' }); + + public async selectDefault() { + await this.spaceSelectorDefault().click(); + } +} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/auto_detect_flow.page.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/auto_detect_flow.page.ts new file mode 100644 index 0000000000000..b1090b3cf091d --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/auto_detect_flow.page.ts @@ -0,0 +1,51 @@ +/* + * 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 { expect, Page } from '@playwright/test'; + +export class AutoDetectFlowPage { + page: Page; + + constructor(page: Page) { + this.page = page; + } + + private readonly copyToClipboardButton = () => + this.page.getByTestId('observabilityOnboardingCopyToClipboardButton'); + + private readonly receivedDataIndicator = () => + this.page + .getByTestId('observabilityOnboardingAutoDetectPanelDataReceivedProgressIndicator') + .getByText('Your data is ready to explore!'); + + private readonly autoDetectSystemIntegrationActionLink = () => + this.page.getByTestId( + 'observabilityOnboardingDataIngestStatusActionLink-inventory-host-details' + ); + + private readonly codeBlock = () => + this.page.getByTestId('observabilityOnboardingAutoDetectPanelCodeSnippet'); + + public async copyToClipboard() { + await this.copyToClipboardButton().click(); + } + + public async assertVisibilityCodeBlock() { + await expect(this.codeBlock(), 'Code block should be visible').toBeVisible(); + } + + public async assertReceivedDataIndicator() { + await expect( + this.receivedDataIndicator(), + 'Received data indicator should be visible' + ).toBeVisible(); + } + + public async clickAutoDetectSystemIntegrationCTA() { + await this.autoDetectSystemIntegrationActionLink().click(); + } +} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/host_details.page.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/host_details.page.ts new file mode 100644 index 0000000000000..d22b33d851639 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/host_details.page.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. + */ + +import { expect, Page } from '@playwright/test'; + +export class HostDetailsPage { + page: Page; + + public readonly hostDetailsLogsTab = () => this.page.getByTestId('infraAssetDetailsLogsTab'); + + private readonly hostDetailsLogsStream = () => this.page.getByTestId('logStream'); + + public readonly noData = () => this.page.getByTestId('kbnNoDataPage'); + + constructor(page: Page) { + this.page = page; + } + + public async clickHostDetailsLogsTab() { + await this.hostDetailsLogsTab().click(); + } + + public async assertHostDetailsLogsStream() { + await expect( + this.hostDetailsLogsStream(), + 'Host details log stream should be visible' + /** + * Using toBeAttached() instead of toBeVisible() because the element + * we're selecting here has a bit weird layout with 0 height and + * overflowing child elements. 0 height makes toBeVisible() fail. + */ + ).toBeAttached(); + } +} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/kubernetes_ea_flow.page.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/kubernetes_ea_flow.page.ts new file mode 100644 index 0000000000000..e956de4855579 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/kubernetes_ea_flow.page.ts @@ -0,0 +1,51 @@ +/* + * 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 { expect, Page } from '@playwright/test'; + +export class KubernetesEAFlowPage { + page: Page; + + constructor(page: Page) { + this.page = page; + } + + private readonly receivedDataIndicatorKubernetes = () => + this.page + .getByTestId('observabilityOnboardingKubernetesPanelDataProgressIndicator') + .getByText('We are monitoring your cluster'); + + private readonly kubernetesAgentExploreDataActionLink = () => + this.page.getByTestId( + 'observabilityOnboardingDataIngestStatusActionLink-kubernetes-f4dc26db-1b53-4ea2-a78b-1bfab8ea267c' + ); + + private readonly codeBlock = () => + this.page.getByTestId('observabilityOnboardingKubernetesPanelCodeSnippet'); + + private readonly copyToClipboardButton = () => + this.page.getByTestId('observabilityOnboardingCopyToClipboardButton'); + + public async assertVisibilityCodeBlock() { + await expect(this.codeBlock(), 'Code block should be visible').toBeVisible(); + } + + public async copyToClipboard() { + await this.copyToClipboardButton().click(); + } + + public async assertReceivedDataIndicatorKubernetes() { + await expect( + this.receivedDataIndicatorKubernetes(), + 'Received data indicator should be visible' + ).toBeVisible(); + } + + public async clickKubernetesAgentCTA() { + await this.kubernetesAgentExploreDataActionLink().click(); + } +} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/kubernetes_overview_dashboard.page.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/kubernetes_overview_dashboard.page.ts new file mode 100644 index 0000000000000..9562f0262994f --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/kubernetes_overview_dashboard.page.ts @@ -0,0 +1,48 @@ +/* + * 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 { expect, Page } from '@playwright/test'; + +export class KubernetesOverviewDashboardPage { + page: Page; + + constructor(page: Page) { + this.page = page; + } + + private readonly nodesPanelHeader = () => this.page.getByTestId('embeddablePanelHeading-Nodes'); + + private readonly nodesInspectorButton = () => + this.page + .getByTestId('embeddablePanelHoverActions-Nodes') + .getByTestId('embeddablePanelAction-openInspector'); + + private readonly nodesInspectorTableNoResults = () => + this.page.getByTestId('inspectorTable').getByText('No items found'); + + private readonly nodesInspectorTableStatusTableCells = () => + this.page.getByTestId('inspectorTable').getByText('Status'); + + public async assertNodesNoResultsNotVisible() { + await expect( + this.nodesInspectorTableNoResults(), + 'Nodes "No results" message should not be visible' + ).toBeHidden(); + } + + public async openNodesInspector() { + await this.nodesPanelHeader().hover(); + await this.nodesInspectorButton().click(); + } + + public async assetNodesInspectorStatusTableCells() { + await expect( + this.nodesInspectorTableStatusTableCells(), + 'Status table cell should exist' + ).toBeVisible(); + } +} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/onboarding_home.page.ts b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/onboarding_home.page.ts new file mode 100644 index 0000000000000..6997001496521 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/playwright/stateful/pom/pages/onboarding_home.page.ts @@ -0,0 +1,44 @@ +/* + * 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 { Page } from '@playwright/test'; + +export class OnboardingHomePage { + page: Page; + + constructor(page: Page) { + this.page = page; + } + + private readonly useCaseKubernetes = () => + this.page.getByTestId('observabilityOnboardingUseCaseCard-kubernetes').getByRole('radio'); + + private readonly kubernetesQuickStartCard = () => + this.page.getByTestId('integration-card:kubernetes-quick-start'); + + private readonly useCaseHost = () => + this.page.getByTestId('observabilityOnboardingUseCaseCard-host').getByRole('radio'); + + private readonly autoDetectElasticAgent = () => + this.page.getByTestId('integration-card:auto-detect-logs'); + + public async selectHostUseCase() { + await this.useCaseHost().click(); + } + + public async selectKubernetesUseCase() { + await this.useCaseKubernetes().click(); + } + + public async selectAutoDetectWithElasticAgent() { + await this.autoDetectElasticAgent().click(); + } + + public async selectKubernetesQuickstart() { + await this.kubernetesQuickStartCard().click(); + } +} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/e2e/tsconfig.json b/x-pack/plugins/observability_solution/observability_onboarding/e2e/tsconfig.json index 94d4f2278cb63..a18951aeb8cf7 100644 --- a/x-pack/plugins/observability_solution/observability_onboarding/e2e/tsconfig.json +++ b/x-pack/plugins/observability_solution/observability_onboarding/e2e/tsconfig.json @@ -14,6 +14,7 @@ "@kbn/cypress-config", "@kbn/observability-onboarding-plugin", "@kbn/ftr-common-functional-services", - "@kbn/ftr-common-functional-ui-services" + "@kbn/ftr-common-functional-ui-services", + "@kbn/tooling-log" ] } diff --git a/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/auto_detect/auto_detect_panel.tsx b/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/auto_detect/auto_detect_panel.tsx index d12f0cae583f4..2891d4c47834d 100644 --- a/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/auto_detect/auto_detect_panel.tsx +++ b/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/auto_detect/auto_detect_panel.tsx @@ -95,7 +95,11 @@ export const AutoDetectPanel: FunctionComponent = () => { {/* Bash syntax highlighting only highlights a few random numbers (badly) so it looks less messy to go with plain text */} - + {command} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/kubernetes/command_snippet.tsx b/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/kubernetes/command_snippet.tsx index ac00190fb268d..ce22e31829730 100644 --- a/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/kubernetes/command_snippet.tsx +++ b/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/kubernetes/command_snippet.tsx @@ -63,7 +63,12 @@ export function CommandSnippet({ - + {command} diff --git a/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/kubernetes/data_ingest_status.tsx b/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/kubernetes/data_ingest_status.tsx index 659c1e5bd7b50..50725e262eb5a 100644 --- a/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/kubernetes/data_ingest_status.tsx +++ b/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/kubernetes/data_ingest_status.tsx @@ -80,6 +80,7 @@ export function DataIngestStatus({ onboardingId }: Props) { css={css` max-width: 40%; `} + data-test-subj="observabilityOnboardingKubernetesPanelDataProgressIndicator" /> {isTroubleshootingVisible && (