diff --git a/.buildkite/scout_ci_config.yml b/.buildkite/scout_ci_config.yml index d28bbf624b5df..1c29be4ac8547 100644 --- a/.buildkite/scout_ci_config.yml +++ b/.buildkite/scout_ci_config.yml @@ -5,14 +5,15 @@ plugins: - console - discover_enhanced - index_management + - infra - maps - observability - observability_onboarding - painless_lab - profiling - security_solution - - streams_app - slo + - streams_app - workflows_extensions disabled: diff --git a/x-pack/solutions/observability/plugins/infra/test/scout/README.md b/x-pack/solutions/observability/plugins/infra/test/scout/README.md new file mode 100644 index 0000000000000..10c957bb238dc --- /dev/null +++ b/x-pack/solutions/observability/plugins/infra/test/scout/README.md @@ -0,0 +1,23 @@ +# How to run tests + +First start the servers: + +```bash +// ESS +node scripts/scout.js start-server --stateful + +// Serverless +node scripts/scout.js start-server --serverless=[es|oblt|security] +``` + +Then you can run the parallel tests in another terminal: + +```bash +// ESS +npx playwright test --config x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel.playwright.config.ts --project=local --grep @ess + +// Serverless +npx playwright test --project local --config x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel.playwright.config.ts --grep @svlOblt +``` + +Test results are available in `x-pack/solutions/observability/plugins/infra/test/scout/ui/output` diff --git a/x-pack/solutions/observability/plugins/infra/test/scout/ui/fixtures/index.ts b/x-pack/solutions/observability/plugins/infra/test/scout/ui/fixtures/index.ts new file mode 100644 index 0000000000000..8af156cb7ab53 --- /dev/null +++ b/x-pack/solutions/observability/plugins/infra/test/scout/ui/fixtures/index.ts @@ -0,0 +1,43 @@ +/* + * 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 type { + ObltPageObjects, + ObltTestFixtures, + ObltWorkerFixtures, + KibanaUrl, +} from '@kbn/scout-oblt'; +import { test as base, createLazyPageObject } from '@kbn/scout-oblt'; +import { InventoryPage } from './page_objects/inventory'; + +export interface ExtendedScoutTestFixtures extends ObltTestFixtures { + pageObjects: ObltPageObjects & { + inventoryPage: InventoryPage; + }; +} + +export const test = base.extend({ + pageObjects: async ( + { + pageObjects, + page, + kbnUrl, + }: { + pageObjects: ExtendedScoutTestFixtures['pageObjects']; + page: ExtendedScoutTestFixtures['page']; + kbnUrl: KibanaUrl; + }, + use: (pageObjects: ExtendedScoutTestFixtures['pageObjects']) => Promise + ) => { + const extendedPageObjects = { + ...pageObjects, + inventoryPage: createLazyPageObject(InventoryPage, page, kbnUrl), + }; + + await use(extendedPageObjects); + }, +}); diff --git a/x-pack/solutions/observability/plugins/infra/test/scout/ui/fixtures/page_objects/inventory.ts b/x-pack/solutions/observability/plugins/infra/test/scout/ui/fixtures/page_objects/inventory.ts new file mode 100644 index 0000000000000..2fffa5ab1e6d2 --- /dev/null +++ b/x-pack/solutions/observability/plugins/infra/test/scout/ui/fixtures/page_objects/inventory.ts @@ -0,0 +1,17 @@ +/* + * 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 type { KibanaUrl, ScoutPage } from '@kbn/scout-oblt'; + +export class InventoryPage { + constructor(private readonly page: ScoutPage, private readonly kbnUrl: KibanaUrl) {} + + async goto() { + await this.page.goto(`${this.kbnUrl.app('metrics')}/inventory`); + await this.page.testSubj.waitForSelector('infraMetricsPage'); + } +} diff --git a/x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel.playwright.config.ts b/x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel.playwright.config.ts new file mode 100644 index 0000000000000..f30aba1eb5285 --- /dev/null +++ b/x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel.playwright.config.ts @@ -0,0 +1,14 @@ +/* + * 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 { createPlaywrightConfig } from '@kbn/scout-oblt'; + +export default createPlaywrightConfig({ + testDir: './parallel_tests', + workers: 2, + runGlobalSetup: true, +}); diff --git a/x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel_tests/global_setup.ts b/x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel_tests/global_setup.ts new file mode 100644 index 0000000000000..9c22a9852e0ad --- /dev/null +++ b/x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel_tests/global_setup.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. + */ + +import { globalSetupHook } from '@kbn/scout-oblt'; + +globalSetupHook('Ingest data to Elasticsearch', { tag: ['@ess', '@svlOblt'] }, async ({}) => { + return; +}); diff --git a/x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel_tests/inventory/inventory.spec.ts b/x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel_tests/inventory/inventory.spec.ts new file mode 100644 index 0000000000000..75b625ed81a1b --- /dev/null +++ b/x-pack/solutions/observability/plugins/infra/test/scout/ui/parallel_tests/inventory/inventory.spec.ts @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { expect } from '@kbn/scout-oblt'; +import { test } from '../../fixtures'; + +test.describe('Infrastructure Inventory', { tag: ['@ess', '@svlOblt'] }, () => { + test('Page should load', async ({ pageObjects: { inventoryPage }, browserAuth, page }) => { + await browserAuth.loginAsViewer(); + await inventoryPage.goto(); + + await expect(page.getByTestId('breadcrumb last')).toHaveText('Infrastructure inventory'); + }); +}); diff --git a/x-pack/solutions/observability/plugins/infra/test/scout/ui/tsconfig.json b/x-pack/solutions/observability/plugins/infra/test/scout/ui/tsconfig.json new file mode 100644 index 0000000000000..e1305fbdb5a81 --- /dev/null +++ b/x-pack/solutions/observability/plugins/infra/test/scout/ui/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "@kbn/tsconfig-base/tsconfig.json", + "compilerOptions": { + "outDir": "target/types" + }, + "include": ["**/*"], + "kbn_references": ["@kbn/scout-oblt"], + "exclude": ["target/**/*"] +}