From a42bd35793408cf496b875d8ca7ba9401e198cd3 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 15 Jan 2025 20:16:51 +0100 Subject: [PATCH 01/23] initial POC --- packages/kbn-scout/index.ts | 11 +- .../src/common/services/kibana_url.ts | 5 +- .../src/playwright/config/create_config.ts | 1 + .../fixtures/{worker => common}/index.ts | 7 +- .../common/test_scope/browser_auth.ts | 57 ++++++++ .../fixtures/common/test_scope/index.ts | 13 ++ .../{test => common/test_scope}/page.ts | 34 +++-- .../test_scope}/page_objects.ts | 6 +- .../test_scope}/validate_tags.ts | 2 +- .../{worker => common/worker_scope}/core.ts | 6 +- .../fixtures/common/worker_scope/index.ts | 10 ++ .../src/playwright/fixtures/index.ts | 37 +++-- .../{test => parallel_run}/browser_auth.ts | 12 +- .../playwright/fixtures/parallel_run/index.ts | 13 ++ .../playwright/fixtures/parallel_run/page.ts | 34 +++++ .../fixtures/parallel_run/ui_settings.ts | 57 ++++++++ .../fixtures/parallel_run/worker_space.ts | 36 +++++ .../fixtures/single_thread/index.ts | 10 ++ .../{worker => single_thread}/ui_settings.ts | 0 .../src/playwright/fixtures/types/index.ts | 2 + .../parallel_run_test_scope.ts} | 21 ++- .../types/parallel_run_worker_scope.ts | 35 +++++ packages/kbn-scout/src/playwright/index.ts | 10 +- .../kbn-scout/src/playwright/types/index.ts | 6 +- .../kbn_client/kbn_client_import_export.ts | 2 +- .../ui_tests/fixtures/index.ts | 36 ++++- .../ui_tests/parallel_tests/demo1.spec.ts | 49 +++++++ .../ui_tests/parallel_tests/demo1_2.spec.ts | 43 ++++++ .../ui_tests/parallel_tests/demo2.spec.ts | 56 ++++++++ .../ui_tests/parallel_tests/demo2_2.spec.ts | 56 ++++++++ .../parallel_tests/error_handling.spec.ts | 42 ++++++ .../ui_tests/parallel_tests/global_setup.ts | 45 ++++++ .../saved_search_embeddable.spec.ts | 108 +++++++++++++++ .../parallel_tests/saved_searches.spec.ts | 129 ++++++++++++++++++ .../parallel_tests/value_suggestions.spec.ts | 62 +++++++++ .../value_suggestions_non_time_based.spec.ts | 53 +++++++ ...uggestions_use_time_range_disabled.spec.ts | 65 +++++++++ .../ui_tests/playwright.parallel.config.ts | 15 ++ .../value_suggestions_non_time_based.spec.ts | 2 +- 39 files changed, 1124 insertions(+), 64 deletions(-) rename packages/kbn-scout/src/playwright/fixtures/{worker => common}/index.ts (67%) create mode 100644 packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/common/test_scope/index.ts rename packages/kbn-scout/src/playwright/fixtures/{test => common/test_scope}/page.ts (79%) rename packages/kbn-scout/src/playwright/fixtures/{test => common/test_scope}/page_objects.ts (82%) rename packages/kbn-scout/src/playwright/fixtures/{test => common/test_scope}/validate_tags.ts (97%) rename packages/kbn-scout/src/playwright/fixtures/{worker => common/worker_scope}/core.ts (96%) create mode 100644 packages/kbn-scout/src/playwright/fixtures/common/worker_scope/index.ts rename packages/kbn-scout/src/playwright/fixtures/{test => parallel_run}/browser_auth.ts (84%) create mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_run/index.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_run/page.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_run/ui_settings.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_run/worker_space.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/single_thread/index.ts rename packages/kbn-scout/src/playwright/fixtures/{worker => single_thread}/ui_settings.ts (100%) rename packages/kbn-scout/src/playwright/fixtures/{test/index.ts => types/parallel_run_test_scope.ts} (54%) create mode 100644 packages/kbn-scout/src/playwright/fixtures/types/parallel_run_worker_scope.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/global_setup.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.parallel.config.ts diff --git a/packages/kbn-scout/index.ts b/packages/kbn-scout/index.ts index 733d0bae1ecd1..25092cf399c01 100644 --- a/packages/kbn-scout/index.ts +++ b/packages/kbn-scout/index.ts @@ -8,7 +8,14 @@ */ export * as cli from './src/cli'; -export { expect, test, tags, createPlaywrightConfig, createLazyPageObject } from './src/playwright'; +export { + expect, + test, + spaceTest, + tags, + createPlaywrightConfig, + createLazyPageObject, +} from './src/playwright'; export type { ScoutPage, ScoutPlaywrightOptions, @@ -17,6 +24,8 @@ export type { ScoutTestFixtures, ScoutWorkerFixtures, EsArchiverFixture, + ParallelRunTestFixtures, + ParallelRunWorkerFixtures, } from './src/playwright'; export type { Client, KbnClient, KibanaUrl, SamlSessionManager, ToolingLog } from './src/types'; diff --git a/packages/kbn-scout/src/common/services/kibana_url.ts b/packages/kbn-scout/src/common/services/kibana_url.ts index 65a21c80592e8..07e906bb80b50 100644 --- a/packages/kbn-scout/src/common/services/kibana_url.ts +++ b/packages/kbn-scout/src/common/services/kibana_url.ts @@ -55,8 +55,9 @@ export class KibanaUrl { * @param appName name of the app to get the URL for * @param options optional modifications to apply to the URL */ - app(appName: string, options?: PathOptions) { - return this.get(`/app/${appName}`, options); + app(appName: string, options?: { space?: string; pathOptions?: PathOptions }) { + const relPath = options?.space ? `s/${options.space}/app/${appName}` : `/app/${appName}`; + return this.get(relPath, options?.pathOptions); } toString() { diff --git a/packages/kbn-scout/src/playwright/config/create_config.ts b/packages/kbn-scout/src/playwright/config/create_config.ts index cb1e371cb43e7..e4a21db321be2 100644 --- a/packages/kbn-scout/src/playwright/config/create_config.ts +++ b/packages/kbn-scout/src/playwright/config/create_config.ts @@ -15,6 +15,7 @@ import { ScoutPlaywrightOptions, ScoutTestOptions, VALID_CONFIG_MARKER } from '. export function createPlaywrightConfig(options: ScoutPlaywrightOptions): PlaywrightTestConfig { return defineConfig({ testDir: options.testDir, + globalSetup: options.globalSetup, /* Run tests in files in parallel */ fullyParallel: false, /* Fail the build on CI if you accidentally left test.only in the source code. */ diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/index.ts b/packages/kbn-scout/src/playwright/fixtures/common/index.ts similarity index 67% rename from packages/kbn-scout/src/playwright/fixtures/worker/index.ts rename to packages/kbn-scout/src/playwright/fixtures/common/index.ts index cfc697bf03613..4a23d4c5ce936 100644 --- a/packages/kbn-scout/src/playwright/fixtures/worker/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/index.ts @@ -7,8 +7,5 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { mergeTests } from 'playwright/test'; -import { uiSettingsFixture } from './ui_settings'; -import { coreWorkerFixtures } from './core'; - -export const scoutWorkerFixtures = mergeTests(coreWorkerFixtures, uiSettingsFixture); +export * from './test_scope'; +export * from './worker_scope'; diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts new file mode 100644 index 0000000000000..cba499ec24f22 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts @@ -0,0 +1,57 @@ +/* + * 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 { test as base } from '@playwright/test'; +import { ScoutTestConfig, ToolingLog } from '../../../../types'; +import { PROJECT_DEFAULT_ROLES } from '../../../../common'; +import { LoginFixture, SamlSessionManager } from '../../types'; +import { serviceLoadedMsg } from '../../../utils'; + +type LoginFunction = (role: string) => Promise; + +/** + * The "browserAuth" fixture simplifies the process of logging into Kibana with + * different roles during tests. It uses the "samlAuth" fixture to create an authentication session + * for the specified role and the "context" fixture to update the cookie with the role-scoped session. + */ +export const browserAuthFixture = base.extend< + { browserAuth: LoginFixture }, + { log: ToolingLog; samlAuth: SamlSessionManager; config: ScoutTestConfig } +>({ + browserAuth: async ({ log, context, samlAuth, config }, use) => { + const setSessionCookie = async (cookieValue: string) => { + await context.clearCookies(); + await context.addCookies([ + { + name: 'sid', + value: cookieValue, + path: '/', + domain: 'localhost', + }, + ]); + }; + + const loginAs: LoginFunction = async (role) => { + const cookie = await samlAuth.getInteractiveUserSessionCookieWithRoleScope(role); + await setSessionCookie(cookie); + }; + + const loginAsAdmin = () => loginAs('admin'); + const loginAsViewer = () => loginAs('viewer'); + const loginAsPrivilegedUser = () => { + const roleName = config.serverless + ? PROJECT_DEFAULT_ROLES.get(config.projectType!)! + : 'editor'; + return loginAs(roleName); + }; + + log.debug(serviceLoadedMsg('browserAuth')); + await use({ loginAsAdmin, loginAsViewer, loginAsPrivilegedUser }); + }, +}); diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/index.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/index.ts new file mode 100644 index 0000000000000..7f0cfd41ecac3 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/index.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", 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 { browserAuthFixture } from './browser_auth'; +export { pageObjectsFixture } from './page_objects'; +export { scoutPageFixture } from './page'; +export { validateTagsFixture } from './validate_tags'; diff --git a/packages/kbn-scout/src/playwright/fixtures/test/page.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts similarity index 79% rename from packages/kbn-scout/src/playwright/fixtures/test/page.ts rename to packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts index 4cab61e4ffec5..5b8d661ac347b 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/page.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts @@ -9,7 +9,7 @@ import { Page, test as base } from '@playwright/test'; import { subj } from '@kbn/test-subj-selector'; -import { ScoutPage, KibanaUrl, ScoutTestFixtures, ScoutWorkerFixtures } from '../types'; +import { KibanaUrl, ScoutPage } from '../../types'; /** * Instead of defining each method individually, we use a list of method names and loop through them, creating methods dynamically. @@ -69,6 +69,26 @@ function extendPageWithTestSubject(page: Page): ScoutPage['testSubj'] { return extendedMethods as ScoutPage['testSubj']; } +export function extendPlaywrightPage({ + page, + kbnUrl, +}: { + page: Page; + kbnUrl: KibanaUrl; +}): ScoutPage { + const extendedPage = page as ScoutPage; + // 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)); + // Method to wait for global loading indicator to be hidden + extendedPage.waitForLoadingIndicatorHidden = () => + extendedPage.testSubj.waitForSelector('globalLoadingIndicator-hidden', { + state: 'attached', + }); + return extendedPage; +} + /** * Extends the 'page' fixture with Kibana-specific functionality * @@ -95,20 +115,12 @@ function extendPageWithTestSubject(page: Page): ScoutPage['testSubj'] { * await page.gotoApp('discover); * ``` */ -export const scoutPageFixture = base.extend({ +export const scoutPageFixture = base.extend<{}, { kbnUrl: KibanaUrl }>({ page: async ( { page, kbnUrl }: { page: Page; kbnUrl: KibanaUrl }, use: (extendedPage: ScoutPage) => Promise ) => { - const extendedPage = page as ScoutPage; - // 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)); - // Method to wait for global loading indicator to be hidden - extendedPage.waitForLoadingIndicatorHidden = () => - extendedPage.testSubj.waitForSelector('globalLoadingIndicator-hidden', { state: 'attached' }); - + const extendedPage = extendPlaywrightPage({ page, kbnUrl }); await use(extendedPage); }, }); diff --git a/packages/kbn-scout/src/playwright/fixtures/test/page_objects.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page_objects.ts similarity index 82% rename from packages/kbn-scout/src/playwright/fixtures/test/page_objects.ts rename to packages/kbn-scout/src/playwright/fixtures/common/test_scope/page_objects.ts index 06be362294432..d519aa9ebf9c2 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/page_objects.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page_objects.ts @@ -8,8 +8,8 @@ */ import { test as base } from '@playwright/test'; -import { ScoutTestFixtures, ScoutWorkerFixtures } from '../types'; -import { createCorePageObjects } from '../../page_objects'; +import { ScoutPage } from '../../types'; +import { PageObjects, createCorePageObjects } from '../../../page_objects'; /** * The "pageObjects" fixture provides a centralized and consistent way to access and @@ -19,7 +19,7 @@ import { createCorePageObjects } from '../../page_objects'; * * Note: Page Objects are lazily instantiated on first access. */ -export const pageObjectsFixture = base.extend({ +export const pageObjectsFixture = base.extend<{ page: ScoutPage; pageObjects: PageObjects }>({ pageObjects: async ({ page }, use) => { const corePageObjects = createCorePageObjects(page); diff --git a/packages/kbn-scout/src/playwright/fixtures/test/validate_tags.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/validate_tags.ts similarity index 97% rename from packages/kbn-scout/src/playwright/fixtures/test/validate_tags.ts rename to packages/kbn-scout/src/playwright/fixtures/common/test_scope/validate_tags.ts index 1866935440e1a..c792f905ebe9f 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/validate_tags.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/validate_tags.ts @@ -8,7 +8,7 @@ */ import { test as base } from '@playwright/test'; -import { tags } from '../../tags'; +import { tags } from '../../../tags'; const supportedTags = tags.DEPLOYMENT_AGNOSTIC; diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/core.ts b/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/core.ts similarity index 96% rename from packages/kbn-scout/src/playwright/fixtures/worker/core.ts rename to packages/kbn-scout/src/playwright/fixtures/common/worker_scope/core.ts index 9f90f71d9c276..1cd36a997d645 100644 --- a/packages/kbn-scout/src/playwright/fixtures/worker/core.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/core.ts @@ -18,9 +18,9 @@ import { createLogger, createSamlSessionManager, createScoutConfig, -} from '../../../common/services'; -import { ScoutWorkerFixtures } from '../types/worker_scope'; -import { ScoutTestOptions } from '../../types'; +} from '../../../../common/services'; +import { ScoutWorkerFixtures } from '../../types/worker_scope'; +import { ScoutTestOptions } from '../../../types'; /** * The coreWorkerFixtures setup defines foundational fixtures that are essential diff --git a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/index.ts b/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/index.ts new file mode 100644 index 0000000000000..74e73fd76be9f --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/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 { coreWorkerFixtures } from './core'; diff --git a/packages/kbn-scout/src/playwright/fixtures/index.ts b/packages/kbn-scout/src/playwright/fixtures/index.ts index a17a592b5ada0..21ee7fd0c6f18 100644 --- a/packages/kbn-scout/src/playwright/fixtures/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/index.ts @@ -7,20 +7,27 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { mergeTests } from '@playwright/test'; +import { mergeTests } from 'playwright/test'; +import * as common from './common'; +import * as spaceAware from './parallel_run'; +import * as singleThread from './single_thread'; -import { scoutWorkerFixtures } from './worker'; -import { scoutTestFixtures } from './test'; +export const scoutCoreFixtures = mergeTests( + common.coreWorkerFixtures, + common.browserAuthFixture, + common.pageObjectsFixture, + common.scoutPageFixture, + common.validateTagsFixture, + singleThread.uiSettingsFixture +); +export const scoutCoreSpaceAwareFixtures = mergeTests( + common.coreWorkerFixtures, + spaceAware.browserAuthFixture, + common.pageObjectsFixture, + common.validateTagsFixture, + spaceAware.scoutSpacePageFixture, + spaceAware.uiSettingsSpaceFixture, + spaceAware.workerSpaceFixure +); -export const scoutCoreFixtures = mergeTests(scoutWorkerFixtures, scoutTestFixtures); - -export type { - EsArchiverFixture, - ScoutTestFixtures, - ScoutWorkerFixtures, - ScoutPage, - Client, - KbnClient, - KibanaUrl, - ToolingLog, -} from './types'; +export * from './types'; diff --git a/packages/kbn-scout/src/playwright/fixtures/test/browser_auth.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_run/browser_auth.ts similarity index 84% rename from packages/kbn-scout/src/playwright/fixtures/test/browser_auth.ts rename to packages/kbn-scout/src/playwright/fixtures/parallel_run/browser_auth.ts index 11c2d97b06673..d57945c090296 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/browser_auth.ts +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_run/browser_auth.ts @@ -9,7 +9,8 @@ import { test as base } from '@playwright/test'; import { PROJECT_DEFAULT_ROLES } from '../../../common'; -import { LoginFixture, ScoutWorkerFixtures } from '../types'; +import { SamlSessionManager, ScoutTestConfig, ToolingLog } from '../../../types'; +import { LoginFixture } from '../types'; import { serviceLoadedMsg } from '../../utils'; type LoginFunction = (role: string) => Promise; @@ -19,7 +20,10 @@ type LoginFunction = (role: string) => Promise; * different roles during tests. It uses the "samlAuth" fixture to create an authentication session * for the specified role and the "context" fixture to update the cookie with the role-scoped session. */ -export const browserAuthFixture = base.extend<{ browserAuth: LoginFixture }, ScoutWorkerFixtures>({ +export const browserAuthFixture = base.extend< + { browserAuth: LoginFixture }, + { log: ToolingLog; samlAuth: SamlSessionManager; config: ScoutTestConfig } +>({ browserAuth: async ({ log, context, samlAuth, config }, use) => { const setSessionCookie = async (cookieValue: string) => { await context.clearCookies(); @@ -34,7 +38,9 @@ export const browserAuthFixture = base.extend<{ browserAuth: LoginFixture }, Sco }; const loginAs: LoginFunction = async (role) => { - const cookie = await samlAuth.getInteractiveUserSessionCookieWithRoleScope(role); + const cookie = await samlAuth.getInteractiveUserSessionCookieWithRoleScope(role, { + forceNewSession: true, + }); await setSessionCookie(cookie); }; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_run/index.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_run/index.ts new file mode 100644 index 0000000000000..cc9a1dec43644 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_run/index.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", 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 { scoutSpacePageFixture } from './page'; +export { uiSettingsSpaceFixture } from './ui_settings'; +export { workerSpaceFixure } from './worker_space'; +export { browserAuthFixture } from './browser_auth'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_run/page.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_run/page.ts new file mode 100644 index 0000000000000..26ad7434b8a5a --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_run/page.ts @@ -0,0 +1,34 @@ +/* + * 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 { Page, test as base } from '@playwright/test'; +import { KibanaUrl, ScoutPage, WorkerSpaceFixure } from '../types'; +import { extendPlaywrightPage } from '../common/test_scope/page'; + +export const scoutSpacePageFixture = base.extend< + {}, + { kbnUrl: KibanaUrl; workerSpace: WorkerSpaceFixure } +>({ + page: async ( + { + page, + kbnUrl, + workerSpace, + }: { page: Page; kbnUrl: KibanaUrl; workerSpace: WorkerSpaceFixure }, + use: (spaceAwarePage: ScoutPage) => Promise + ) => { + const extendedPage = extendPlaywrightPage({ page, kbnUrl }); + + // Overriding navigation to specific Kibana apps to take into account the worker space + extendedPage.gotoApp = (appName: string) => + page.goto(kbnUrl.app(appName, { space: workerSpace.id })); + // Method to wait for global loading indicator to be hidden + await use(extendedPage); + }, +}); diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_run/ui_settings.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_run/ui_settings.ts new file mode 100644 index 0000000000000..b1e226a6e9fa7 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_run/ui_settings.ts @@ -0,0 +1,57 @@ +/* + * 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 { test as base } from '@playwright/test'; +import { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; +import { KbnClient, ToolingLog, UiSettingsFixture, WorkerSpaceFixure } from '../types'; +import { isValidUTCDate, formatTime } from '../../utils'; + +/** + * This fixture provides a way to interact with Kibana UI settings. + */ +export const uiSettingsSpaceFixture = base.extend< + {}, + { + kbnClient: KbnClient; + uiSettings: UiSettingsFixture; + workerSpace: WorkerSpaceFixure; + log: ToolingLog; + } +>({ + uiSettings: [ + ({ kbnClient, workerSpace, log }, use) => { + const kbnClientUiSettings = { + set: async (values: UiSettingValues) => { + log.info(`Setting UI settings for space ${workerSpace.id}: ${JSON.stringify(values)}`); + return kbnClient.uiSettings.update(values, { space: workerSpace.id }); + }, + + unset: async (...keys: string[]) => { + log.info(`Unsetting UI settings for space ${workerSpace.id}: ${keys}`); + return Promise.all( + keys.map((key) => kbnClient.uiSettings.unset(key, { space: workerSpace.id })) + ); + }, + setDefaultTime: async ({ from, to }: { from: string; to: string }) => { + const utcFrom = isValidUTCDate(from) ? from : formatTime(from); + const untcTo = isValidUTCDate(to) ? to : formatTime(to); + await kbnClient.uiSettings.update( + { + 'timepicker:timeDefaults': `{ "from": "${utcFrom}", "to": "${untcTo}"}`, + }, + { space: workerSpace.id } + ); + }, + }; + + use(kbnClientUiSettings); + }, + { scope: 'worker' }, + ], +}); diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_run/worker_space.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_run/worker_space.ts new file mode 100644 index 0000000000000..f940ccee87a13 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_run/worker_space.ts @@ -0,0 +1,36 @@ +/* + * 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 { test as base } from '@playwright/test'; +import { KbnClient, ToolingLog, WorkerSpaceFixure } from '../types'; + +export const workerSpaceFixure = base.extend< + {}, + { log: ToolingLog; kbnClient: KbnClient; workerSpace: WorkerSpaceFixure } +>({ + workerSpace: [ + async ({ log, kbnClient }: { log: ToolingLog; kbnClient: KbnClient }, use, workerInfo) => { + const id = `test-space-${workerInfo.workerIndex}`; + const spacePayload = { + id, + name: id, + disabledFeatures: [], + }; + log.debug(`Creating space ${id}`); + await kbnClient.spaces.create(spacePayload); + + await use(spacePayload); + + // Cleanup space after tests via API call + log.debug(`Deleting space ${id}`); + await kbnClient.spaces.delete(id); + }, + { scope: 'worker' }, + ], +}); diff --git a/packages/kbn-scout/src/playwright/fixtures/single_thread/index.ts b/packages/kbn-scout/src/playwright/fixtures/single_thread/index.ts new file mode 100644 index 0000000000000..14eb4ae6e41cb --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/single_thread/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 { uiSettingsFixture } from './ui_settings'; diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/ui_settings.ts b/packages/kbn-scout/src/playwright/fixtures/single_thread/ui_settings.ts similarity index 100% rename from packages/kbn-scout/src/playwright/fixtures/worker/ui_settings.ts rename to packages/kbn-scout/src/playwright/fixtures/single_thread/ui_settings.ts diff --git a/packages/kbn-scout/src/playwright/fixtures/types/index.ts b/packages/kbn-scout/src/playwright/fixtures/types/index.ts index 4a23d4c5ce936..100e6184afe6e 100644 --- a/packages/kbn-scout/src/playwright/fixtures/types/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/types/index.ts @@ -9,3 +9,5 @@ export * from './test_scope'; export * from './worker_scope'; +export * from './parallel_run_test_scope'; +export * from './parallel_run_worker_scope'; diff --git a/packages/kbn-scout/src/playwright/fixtures/test/index.ts b/packages/kbn-scout/src/playwright/fixtures/types/parallel_run_test_scope.ts similarity index 54% rename from packages/kbn-scout/src/playwright/fixtures/test/index.ts rename to packages/kbn-scout/src/playwright/fixtures/types/parallel_run_test_scope.ts index 3e2ea85b90bc3..a9d85a5491021 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/types/parallel_run_test_scope.ts @@ -7,15 +7,14 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { mergeTests } from '@playwright/test'; -import { browserAuthFixture } from './browser_auth'; -import { scoutPageFixture } from './page'; -import { pageObjectsFixture } from './page_objects'; -import { validateTagsFixture } from './validate_tags'; +import { LoginFixture, ScoutPage } from './test_scope'; +import { PageObjects } from '../../page_objects'; -export const scoutTestFixtures = mergeTests( - browserAuthFixture, - scoutPageFixture, - pageObjectsFixture, - validateTagsFixture -); +/** + * The `ParallelRunTestScopeFixtures` type defines the set of fixtures that are available + */ +export interface ParallelRunTestFixtures { + browserAuth: LoginFixture; + page: ScoutPage; + pageObjects: PageObjects; +} diff --git a/packages/kbn-scout/src/playwright/fixtures/types/parallel_run_worker_scope.ts b/packages/kbn-scout/src/playwright/fixtures/types/parallel_run_worker_scope.ts new file mode 100644 index 0000000000000..a2c2b65b88d67 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/types/parallel_run_worker_scope.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", 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 { KbnClient, SamlSessionManager } from '@kbn/test'; +import type { ToolingLog } from '@kbn/tooling-log'; +import type { Client } from '@elastic/elasticsearch'; +import { ScoutTestConfig } from '../../../types'; +import { KibanaUrl } from '../../../common/services/kibana_url'; +import { EsArchiverFixture, UiSettingsFixture } from './worker_scope'; + +export interface WorkerSpaceFixure { + id: string; + name: string; +} + +/** + * The `ScoutWorkerFixtures` type defines the set of fixtures that are available + */ +export interface ParallelRunWorkerFixtures { + log: ToolingLog; + config: ScoutTestConfig; + esArchiver: EsArchiverFixture; + esClient: Client; + kbnClient: KbnClient; + kbnUrl: KibanaUrl; + uiSettings: UiSettingsFixture; + samlAuth: SamlSessionManager; + workerSpace: WorkerSpaceFixure; +} diff --git a/packages/kbn-scout/src/playwright/index.ts b/packages/kbn-scout/src/playwright/index.ts index 0a82bc0468fce..4dee6209f43ac 100644 --- a/packages/kbn-scout/src/playwright/index.ts +++ b/packages/kbn-scout/src/playwright/index.ts @@ -7,11 +7,13 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { mergeTests } from 'playwright/test'; -import { scoutCoreFixtures } from './fixtures'; +import { scoutCoreFixtures, scoutCoreSpaceAwareFixtures } from './fixtures'; // Scout core fixtures: worker & test scope -export const test = mergeTests(scoutCoreFixtures); +export const test = scoutCoreFixtures; + +// Scout core 'space aware' fixtures: worker & test scope +export const spaceTest = scoutCoreSpaceAwareFixtures; export { createPlaywrightConfig } from './config'; export { createLazyPageObject } from './page_objects/utils'; @@ -22,6 +24,8 @@ export type { PageObjects } from './page_objects'; export type { ScoutTestFixtures, ScoutWorkerFixtures, + ParallelRunTestFixtures, + ParallelRunWorkerFixtures, ScoutPage, EsArchiverFixture, } from './fixtures'; diff --git a/packages/kbn-scout/src/playwright/types/index.ts b/packages/kbn-scout/src/playwright/types/index.ts index c8d0087d62438..78a40ff4f1c65 100644 --- a/packages/kbn-scout/src/playwright/types/index.ts +++ b/packages/kbn-scout/src/playwright/types/index.ts @@ -18,7 +18,9 @@ export interface ScoutTestOptions extends PlaywrightTestOptions { [VALID_CONFIG_MARKER]: boolean; } -export interface ScoutPlaywrightOptions extends Pick { +export interface ScoutPlaywrightOptions + extends Pick { testDir: string; - workers?: 1 | 2; + workers?: 1 | 2 | 3; // to keep performance consistent within test suites + globalSetup?: string; } diff --git a/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts b/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts index 7be362ed7a3ff..c4bd0ff23064d 100644 --- a/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts +++ b/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts @@ -70,7 +70,7 @@ export class KbnClientImportExport { method: 'POST', path: '/api/saved_objects/_import', query: { - overwrite: true, + createNewCopies: true, }, body: formData, headers: formData.getHeaders(), diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts index cf12a98368b90..38021a59dde34 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts @@ -6,11 +6,14 @@ */ import { - test as base, + test as baseTest, + spaceTest as spaceBaseTest, PageObjects, createLazyPageObject, ScoutTestFixtures, ScoutWorkerFixtures, + ParallelRunTestFixtures, + ParallelRunWorkerFixtures, } from '@kbn/scout'; import { DemoPage } from './page_objects'; @@ -20,7 +23,7 @@ export interface ExtendedScoutTestFixtures extends ScoutTestFixtures { }; } -export const test = base.extend({ +export const test = baseTest.extend({ pageObjects: async ( { pageObjects, @@ -40,5 +43,34 @@ export const test = base.extend( }, }); +export interface ExtendedParallelRunScoutTestFixtures extends ParallelRunTestFixtures { + pageObjects: PageObjects & { + demo: DemoPage; + }; +} + +export const spaceTest = spaceBaseTest.extend< + ExtendedParallelRunScoutTestFixtures, + ParallelRunWorkerFixtures +>({ + pageObjects: async ( + { + pageObjects, + page, + }: { + pageObjects: ExtendedParallelRunScoutTestFixtures['pageObjects']; + page: ExtendedParallelRunScoutTestFixtures['page']; + }, + use: (pageObjects: ExtendedScoutTestFixtures['pageObjects']) => Promise + ) => { + const extendedPageObjects = { + ...pageObjects, + demo: createLazyPageObject(DemoPage, page), + }; + + await use(extendedPageObjects); + }, +}); + export * as testData from './constants'; export * as assertionMessages from './assertion_messages'; diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1.spec.ts new file mode 100644 index 0000000000000..e53a86b4b5e16 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1.spec.ts @@ -0,0 +1,49 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData } from '../fixtures'; + +spaceTest.describe.skip( + 'Discover app - value suggestions: useTimeRange enabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace, log }) => { + log.info(`Creating data view in ${workerSpace.id} space`); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { + space: workerSpace.id, + }); + log.info(`Updating UI settings in ${workerSpace.id} space`); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + }); + }); + + spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList({ space: workerSpace.id }); + }); + + spaceTest.beforeEach(async ({ browserAuth, page, workerSpace }) => { + await browserAuth.loginAsAdmin(); + await page.goto(`http://localhost:5620/s/${workerSpace.id}/app/discover`); + }); + + spaceTest('dont show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); + }); + + // spaceTest('also displays descriptions for operators', async ({ page, pageObjects }) => { + // await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + // await page.testSubj.fill('queryInput', 'extension.raw'); + // await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); + // }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1_2.spec.ts new file mode 100644 index 0000000000000..2187690b4d290 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1_2.spec.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 { expect, tags } from '@kbn/scout'; +import { spaceTest, testData } from '../fixtures'; + +spaceTest.describe.skip( + 'Discover app - value suggestions: useTimeRange enabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace, log }) => { + log.info(`Creating data view in ${workerSpace.id} space`); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { + space: workerSpace.id, + }); + log.info(`Updating UI settings in ${workerSpace.id} space`); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + }); + }); + + spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList({ space: workerSpace.id }); + }); + + spaceTest.beforeEach(async ({ browserAuth, page, workerSpace }) => { + await browserAuth.loginAsAdmin(); + await page.goto(`http://localhost:5620/s/${workerSpace.id}/app/discover`); + }); + + spaceTest('also displays descriptions for operators', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw'); + await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2.spec.ts new file mode 100644 index 0000000000000..6e4e8cfdc8ba5 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2.spec.ts @@ -0,0 +1,56 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe.skip( + 'Discover app - value suggestions: useTimeRange disabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + spaceTest.beforeAll(async ({ workerSpace, kbnClient, uiSettings, log }) => { + log.info(`Creating data view in ${workerSpace.id} space`); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { + space: workerSpace.id, + }); + log.info(`Updating UI settings in ${workerSpace.id} space`); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + 'autocomplete:useTimeRange': false, + }); + }); + + spaceTest.afterAll(async ({ uiSettings, kbnClient, workerSpace }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await uiSettings.set({ 'autocomplete:useTimeRange': true }); + await kbnClient.savedObjects.cleanStandardList({ + space: workerSpace.id, + }); + }); + + spaceTest.beforeEach(async ({ browserAuth, page, workerSpace, log }) => { + log.info('logging in as viewer'); + await browserAuth.loginAsAdmin(); + log.info('navigating to space'); + await page.goto(`http://localhost:5620/s/${workerSpace.id}/app/discover`); + }); + + spaceTest('show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2_2.spec.ts new file mode 100644 index 0000000000000..3df99ffc6666e --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2_2.spec.ts @@ -0,0 +1,56 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe.skip( + 'Discover app - value suggestions: useTimeRange disabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + spaceTest.beforeAll(async ({ workerSpace, kbnClient, uiSettings, log }) => { + log.info(`Creating data view in ${workerSpace.id} space`); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { + space: workerSpace.id, + }); + log.info(`Updating UI settings in ${workerSpace.id} space`); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + 'autocomplete:useTimeRange': false, + }); + }); + + spaceTest.afterAll(async ({ uiSettings, kbnClient, workerSpace }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await uiSettings.set({ 'autocomplete:useTimeRange': true }); + await kbnClient.savedObjects.cleanStandardList({ + space: workerSpace.id, + }); + }); + + spaceTest.beforeEach(async ({ browserAuth, page, workerSpace, log }) => { + log.info('logging in as viewer'); + await browserAuth.loginAsAdmin(); + log.info('navigating to space'); + await page.goto(`http://localhost:5620/s/${workerSpace.id}/app/discover`); + }); + + spaceTest('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts new file mode 100644 index 0000000000000..1136ee4ad59b9 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts @@ -0,0 +1,42 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData } from '../fixtures'; + +spaceTest.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { + spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await kbnClient.savedObjects.clean({ + types: ['search', 'index-pattern'], + space: workerSpace.id, + }); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD, { + space: workerSpace.id, + }); + await uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, + }); + }); + + spaceTest.afterAll(async ({ kbnClient, workerSpace }) => { + await kbnClient.savedObjects.cleanStandardList({ space: workerSpace.id }); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest('should render invalid scripted field error', async ({ page }) => { + await page.testSubj.locator('discoverErrorCalloutTitle').waitFor({ state: 'visible' }); + await expect( + page.testSubj.locator('painlessStackTrace'), + 'Painless error stacktrace should be displayed' + ).toBeVisible(); + }); +}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/global_setup.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/global_setup.ts new file mode 100644 index 0000000000000..1fb251ce0c94e --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/global_setup.ts @@ -0,0 +1,45 @@ +/* + * 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 { ScoutTestOptions } from '@kbn/scout'; +import { + createEsArchiver, + createEsClient, + createKbnClient, + createLogger, + createScoutConfig, +} from '@kbn/scout/src/common'; +import { type FullConfig } from '@playwright/test'; +import { testData } from '../fixtures'; + +async function globalSetup(config: FullConfig) { + const log = createLogger(); + const configName = 'local'; + const projectUse = config.projects[0].use as ScoutTestOptions; + const serversConfigDir = projectUse.serversConfigDir; + const scoutConfig = createScoutConfig(serversConfigDir, configName, log); + + const esClient = createEsClient(scoutConfig, log); + const kbnCLient = createKbnClient(scoutConfig, log); + const esArchiver = createEsArchiver(esClient, kbnCLient, log); + + const archives = [ + testData.ES_ARCHIVES.LOGSTASH, + testData.ES_ARCHIVES.NO_TIME_FIELD, + testData.ES_ARCHIVES.ECOMMERCE, + ]; + + // Load archives + log.info('Loading test data with esArchiver...'); + for (const archive of archives) { + await esArchiver.loadIfNeeded(archive); + } + log.info('Test data loaded.'); +} + +// eslint-disable-next-line import/no-default-export +export default globalSetup; diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts new file mode 100644 index 0000000000000..1f508ed31c8ff --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts @@ -0,0 +1,108 @@ +/* + * 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 { ScoutWorkerFixtures, expect, tags } from '@kbn/scout'; +import { spaceTest, testData } from '../fixtures'; + +const createSavedSearch = async ( + kbnClient: ScoutWorkerFixtures['kbnClient'], + searchId: string, + searchTitle: string, + dataViewId: string, + spaceId: string +) => + await kbnClient.savedObjects.create({ + type: 'search', + id: searchId, + overwrite: false, + attributes: { + space: spaceId, + title: searchTitle, + description: '', + columns: ['agent', 'bytes', 'clientip'], + sort: [['@timestamp', 'desc']], + kibanaSavedObjectMeta: { + searchSourceJSON: + '{"highlightAll":true,"version":true,"query":{"language":"lucene","query":""},"filter":[],"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}', + }, + }, + references: [ + { + id: dataViewId, + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + }, + ], + }); + +spaceTest.describe.skip( + 'Discover app - saved search embeddable', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + const SAVED_SEARCH_TITLE = 'TempSearch'; + const SAVED_SEARCH_ID = '90943e30-9a47-11e8-b64d-95841ca0b247'; + spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { + space: workerSpace.id, + }); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + }); + }); + + spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList({ + space: workerSpace.id, + }); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsPrivilegedUser(); + await pageObjects.dashboard.goto(); + }); + + spaceTest( + 'should allow removing the dashboard panel after the underlying saved search has been deleted', + async ({ kbnClient, page, pageObjects, workerSpace }) => { + await pageObjects.dashboard.openNewDashboard(); + await createSavedSearch( + kbnClient, + SAVED_SEARCH_ID, + SAVED_SEARCH_TITLE, + testData.DATA_VIEW_ID.LOGSTASH, + workerSpace.id + ); + await pageObjects.dashboard.addPanelFromLibrary(SAVED_SEARCH_TITLE); + await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ + state: 'visible', + }); + + await pageObjects.dashboard.saveDashboard('Dashboard with deleted saved search'); + await kbnClient.savedObjects.delete({ + type: 'search', + id: SAVED_SEARCH_ID, + space: workerSpace.id, + }); + + await page.reload(); + await page.waitForLoadingIndicatorHidden(); + await expect( + page.testSubj.locator('embeddableError'), + 'Embeddable error should be displayed' + ).toBeVisible(); + + await pageObjects.dashboard.removePanel('embeddableError'); + await expect( + page.testSubj.locator('embeddableError'), + 'Embeddable error should not be displayed' + ).toBeHidden(); + } + ); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts new file mode 100644 index 0000000000000..1d393e8e50ba8 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts @@ -0,0 +1,129 @@ +/* + * 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'; +import { spaceTest, testData } from '../fixtures'; +import type { ExtendedScoutTestFixtures } from '../fixtures'; + +const assertNoFilterAndEmptyQuery = async ( + filterBadge: { field: string; value: string }, + pageObjects: ExtendedScoutTestFixtures['pageObjects'], + page: ExtendedScoutTestFixtures['page'] +) => { + expect( + // checking if filter exists, enabled or disabled + await pageObjects.filterBar.hasFilter(filterBadge), + `Filter ${JSON.stringify(filterBadge)} should not exist` + ).toBe(false); + await expect( + page.testSubj.locator('queryInput'), + 'Query Bar input field should be empty' + ).toHaveText(''); +}; + +const assertDataViewIsSelected = async (page: ExtendedScoutTestFixtures['page'], name: string) => + await expect( + page.testSubj.locator('*dataView-switch-link'), + 'Incorrect data view is selected' + ).toHaveText(name); + +spaceTest.describe( + 'Discover app - saved searches', + { tag: ['@ess', '@svlSearch', '@svlOblt'] }, + () => { + // TODO: Update to use an ES archive with an index accessible to 'viewer' + // for running this test against the Security serverless project. + const START_TIME = '2019-04-27T23:56:51.374Z'; + const END_TIME = '2019-08-23T16:18:51.821Z'; + const PANEL_NAME = 'Ecommerce Data'; + const SEARCH_QUERY = 'customer_gender:MALE'; + const SAVED_SEARCH_NAME = 'test-unselect-saved-search'; + const filterFieldAndValue = { + field: 'category', + value: `Men's Shoes`, + }; + + spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DISCOVER, { space: workerSpace.id }); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.ECOMMERCE, { space: workerSpace.id }); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.ECOMMERCE, + 'timepicker:timeDefaults': `{ "from": "${START_TIME}", "to": "${END_TIME}"}`, + }); + }); + + spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList({ space: workerSpace.id }); + }); + + spaceTest.beforeEach(async ({ browserAuth }) => { + await browserAuth.loginAsPrivilegedUser(); + }); + + spaceTest('should customize time range on dashboards', async ({ pageObjects, page }) => { + await pageObjects.dashboard.goto(); + await pageObjects.dashboard.openNewDashboard(); + await pageObjects.dashboard.addPanelFromLibrary(PANEL_NAME); + await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ + state: 'visible', + }); + + await pageObjects.dashboard.customizePanel({ + name: PANEL_NAME, + customTimeRageCommonlyUsed: { value: 'Last_90 days' }, + }); + await expect( + page.testSubj.locator('embeddedSavedSearchDocTable').locator('.euiDataGrid__noResults'), + 'No results message in Saved Search panel should be visible' + ).toBeVisible(); + }); + + spaceTest( + `should unselect saved search when navigating to a 'new'`, + async ({ pageObjects, page }) => { + await pageObjects.discover.goto(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await pageObjects.filterBar.addFilter({ + ...filterFieldAndValue, + operator: 'is', + }); + await page.testSubj.fill('queryInput', SEARCH_QUERY); + await page.testSubj.click('querySubmitButton'); + await pageObjects.discover.waitForHistogramRendered(); + + await pageObjects.discover.saveSearch(SAVED_SEARCH_NAME); + await pageObjects.discover.waitForHistogramRendered(); + + expect( + await pageObjects.filterBar.hasFilter({ + ...filterFieldAndValue, + enabled: true, // Filter is enabled by default + }) + ).toBe(true); + await expect(page.testSubj.locator('queryInput')).toHaveText(SEARCH_QUERY); + + // create new search + await pageObjects.discover.clickNewSearch(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // change data view + await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // change data view again + await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // create new search again + await pageObjects.discover.clickNewSearch(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + } + ); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts new file mode 100644 index 0000000000000..3c9e4b9196100 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts @@ -0,0 +1,62 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe( + 'Discover app - value suggestions: useTimeRange enabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { + space: workerSpace.id, + }); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + }); + }); + + spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList({ + space: workerSpace.id, + }); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest('dont show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); + }); + + spaceTest('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + + spaceTest('also displays descriptions for operators', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw'); + await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts new file mode 100644 index 0000000000000..09b45255536cf --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts @@ -0,0 +1,53 @@ +/* + * 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'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe( + 'Discover app - value suggestions non-time based', + { tag: ['@ess', '@svlSearch', '@svlOblt'] }, + // TODO: Update to use an ES archive with an index accessible to 'viewer' + // for running this test against the Security serverless project. + () => { + spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await kbnClient.importExport.load(testData.KBN_ARCHIVES.NO_TIME_FIELD, { + space: workerSpace.id, + }); + await uiSettings.set({ + defaultIndex: 'without-timefield', + }); + }); + + spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await uiSettings.unset('defaultIndex'); + await kbnClient.savedObjects.cleanStandardList({ + space: workerSpace.id, + }); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest( + 'shows all auto-suggest options for a filter in discover context app', + async ({ page }) => { + await page.testSubj.fill('queryInput', 'type.keyword : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(1); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('"apache"'); + } + ); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts new file mode 100644 index 0000000000000..6349c16b9e01f --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.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 { expect, tags } from '@kbn/scout'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe( + 'Discover app - value suggestions: useTimeRange disabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { + space: workerSpace.id, + }); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + 'autocomplete:useTimeRange': false, + }); + }); + + spaceTest.afterAll(async ({ uiSettings, kbnClient, workerSpace }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await uiSettings.set({ 'autocomplete:useTimeRange': true }); + await kbnClient.savedObjects.cleanStandardList({ + space: workerSpace.id, + }); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest('show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + + spaceTest('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.parallel.config.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.parallel.config.ts new file mode 100644 index 0000000000000..70035f4b5a40c --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.parallel.config.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 { createPlaywrightConfig } from '@kbn/scout'; + +// eslint-disable-next-line import/no-default-export +export default createPlaywrightConfig({ + globalSetup: require.resolve('./parallel_tests/global_setup'), + testDir: './parallel_tests', + workers: 2, +}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts index d8035597fa0e4..4966d32e1982f 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts @@ -8,7 +8,7 @@ import { expect } from '@kbn/scout'; import { test, testData, assertionMessages } from '../fixtures'; -test.describe( +test.describe.only( 'Discover app - value suggestions non-time based', { tag: ['@ess', '@svlSearch', '@svlOblt'] }, // TODO: Update to use an ES archive with an index accessible to 'viewer' From 7187ec88484257cc9d0f00c2b0e2c20f46024c37 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Thu, 16 Jan 2025 13:54:13 +0100 Subject: [PATCH 02/23] remove demo tests --- .../ui_tests/parallel_tests/demo1.spec.ts | 49 ---------------- .../ui_tests/parallel_tests/demo1_2.spec.ts | 43 -------------- .../ui_tests/parallel_tests/demo2.spec.ts | 56 ------------------- .../ui_tests/parallel_tests/demo2_2.spec.ts | 56 ------------------- 4 files changed, 204 deletions(-) delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2_2.spec.ts diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1.spec.ts deleted file mode 100644 index e53a86b4b5e16..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1.spec.ts +++ /dev/null @@ -1,49 +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 { expect, tags } from '@kbn/scout'; -import { spaceTest, testData } from '../fixtures'; - -spaceTest.describe.skip( - 'Discover app - value suggestions: useTimeRange enabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace, log }) => { - log.info(`Creating data view in ${workerSpace.id} space`); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { - space: workerSpace.id, - }); - log.info(`Updating UI settings in ${workerSpace.id} space`); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - }); - }); - - spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList({ space: workerSpace.id }); - }); - - spaceTest.beforeEach(async ({ browserAuth, page, workerSpace }) => { - await browserAuth.loginAsAdmin(); - await page.goto(`http://localhost:5620/s/${workerSpace.id}/app/discover`); - }); - - spaceTest('dont show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); - }); - - // spaceTest('also displays descriptions for operators', async ({ page, pageObjects }) => { - // await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - // await page.testSubj.fill('queryInput', 'extension.raw'); - // await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); - // }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1_2.spec.ts deleted file mode 100644 index 2187690b4d290..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo1_2.spec.ts +++ /dev/null @@ -1,43 +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 { expect, tags } from '@kbn/scout'; -import { spaceTest, testData } from '../fixtures'; - -spaceTest.describe.skip( - 'Discover app - value suggestions: useTimeRange enabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace, log }) => { - log.info(`Creating data view in ${workerSpace.id} space`); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { - space: workerSpace.id, - }); - log.info(`Updating UI settings in ${workerSpace.id} space`); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - }); - }); - - spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList({ space: workerSpace.id }); - }); - - spaceTest.beforeEach(async ({ browserAuth, page, workerSpace }) => { - await browserAuth.loginAsAdmin(); - await page.goto(`http://localhost:5620/s/${workerSpace.id}/app/discover`); - }); - - spaceTest('also displays descriptions for operators', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw'); - await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2.spec.ts deleted file mode 100644 index 6e4e8cfdc8ba5..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2.spec.ts +++ /dev/null @@ -1,56 +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 { expect, tags } from '@kbn/scout'; -import { spaceTest, testData, assertionMessages } from '../fixtures'; - -spaceTest.describe.skip( - 'Discover app - value suggestions: useTimeRange disabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - spaceTest.beforeAll(async ({ workerSpace, kbnClient, uiSettings, log }) => { - log.info(`Creating data view in ${workerSpace.id} space`); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { - space: workerSpace.id, - }); - log.info(`Updating UI settings in ${workerSpace.id} space`); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - 'autocomplete:useTimeRange': false, - }); - }); - - spaceTest.afterAll(async ({ uiSettings, kbnClient, workerSpace }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await uiSettings.set({ 'autocomplete:useTimeRange': true }); - await kbnClient.savedObjects.cleanStandardList({ - space: workerSpace.id, - }); - }); - - spaceTest.beforeEach(async ({ browserAuth, page, workerSpace, log }) => { - log.info('logging in as viewer'); - await browserAuth.loginAsAdmin(); - log.info('navigating to space'); - await page.goto(`http://localhost:5620/s/${workerSpace.id}/app/discover`); - }); - - spaceTest('show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2_2.spec.ts deleted file mode 100644 index 3df99ffc6666e..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/demo2_2.spec.ts +++ /dev/null @@ -1,56 +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 { expect, tags } from '@kbn/scout'; -import { spaceTest, testData, assertionMessages } from '../fixtures'; - -spaceTest.describe.skip( - 'Discover app - value suggestions: useTimeRange disabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - spaceTest.beforeAll(async ({ workerSpace, kbnClient, uiSettings, log }) => { - log.info(`Creating data view in ${workerSpace.id} space`); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { - space: workerSpace.id, - }); - log.info(`Updating UI settings in ${workerSpace.id} space`); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - 'autocomplete:useTimeRange': false, - }); - }); - - spaceTest.afterAll(async ({ uiSettings, kbnClient, workerSpace }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await uiSettings.set({ 'autocomplete:useTimeRange': true }); - await kbnClient.savedObjects.cleanStandardList({ - space: workerSpace.id, - }); - }); - - spaceTest.beforeEach(async ({ browserAuth, page, workerSpace, log }) => { - log.info('logging in as viewer'); - await browserAuth.loginAsAdmin(); - log.info('navigating to space'); - await page.goto(`http://localhost:5620/s/${workerSpace.id}/app/discover`); - }); - - spaceTest('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - } -); From 630cf033f34faee2d9f9260687fb5f83621b73a7 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Mon, 20 Jan 2025 18:54:47 +0100 Subject: [PATCH 03/23] update tests --- .../common/test_scope/browser_auth.ts | 18 +++ .../fixtures/common/test_scope/page.ts | 93 +++++++++++- .../fixtures/common/worker_scope/core.ts | 44 +++--- .../common/worker_scope/es_archiver.ts | 54 +++++++ .../fixtures/common/worker_scope/index.ts | 10 ++ .../src/playwright/fixtures/index.ts | 20 +-- .../fixtures/parallel_run/ui_settings.ts | 57 -------- .../fixtures/parallel_run/worker_space.ts | 36 ----- .../index.ts} | 13 +- .../test_scope}/browser_auth.ts | 27 +++- .../test_scope}/index.ts | 6 +- .../test_scope}/page.ts | 19 ++- .../parallel_workers/worker_scope/index.ts | 11 ++ .../worker_scope/kbn_space.ts | 137 ++++++++++++++++++ .../worker_scope}/index.ts | 1 + .../worker_scope}/ui_settings.ts | 37 ++++- .../src/playwright/fixtures/types/index.ts | 6 +- .../types/parallel_run_worker_scope.ts | 35 ----- .../fixtures/types/parallel_workers.ts | 29 ++++ .../fixtures/types/single_worker.ts | 30 ++++ .../playwright/fixtures/types/test_scope.ts | 126 ---------------- .../playwright/fixtures/types/worker_scope.ts | 74 ---------- .../kbn_client/kbn_client_import_export.ts | 9 +- .../index_pattern_without_timefield_1.json | 25 ++++ .../ui_tests/fixtures/constants.ts | 1 + .../parallel_tests/error_handling.spec.ts | 17 +-- .../saved_search_embeddable.spec.ts | 30 ++-- .../parallel_tests/saved_searches.spec.ts | 18 +-- .../parallel_tests/value_suggestions.spec.ts | 21 ++- .../value_suggestions_non_time_based.spec.ts | 18 +-- ...uggestions_use_time_range_disabled.spec.ts | 25 ++-- .../tests/saved_search_embeddable.spec.ts | 106 +++++++------- .../value_suggestions_non_time_based.spec.ts | 2 +- 33 files changed, 626 insertions(+), 529 deletions(-) create mode 100644 packages/kbn-scout/src/playwright/fixtures/common/worker_scope/es_archiver.ts delete mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_run/ui_settings.ts delete mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_run/worker_space.ts rename packages/kbn-scout/src/playwright/fixtures/{types/parallel_run_test_scope.ts => parallel_workers/index.ts} (58%) rename packages/kbn-scout/src/playwright/fixtures/{parallel_run => parallel_workers/test_scope}/browser_auth.ts (73%) rename packages/kbn-scout/src/playwright/fixtures/{parallel_run => parallel_workers/test_scope}/index.ts (76%) rename packages/kbn-scout/src/playwright/fixtures/{parallel_run => parallel_workers/test_scope}/page.ts (65%) create mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/index.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/kbn_space.ts rename packages/kbn-scout/src/playwright/fixtures/{single_thread => single_worker/worker_scope}/index.ts (90%) rename packages/kbn-scout/src/playwright/fixtures/{single_thread => single_worker/worker_scope}/ui_settings.ts (51%) delete mode 100644 packages/kbn-scout/src/playwright/fixtures/types/parallel_run_worker_scope.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/types/parallel_workers.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/types/single_worker.ts delete mode 100644 packages/kbn-scout/src/playwright/fixtures/types/test_scope.ts delete mode 100644 packages/kbn-scout/src/playwright/fixtures/types/worker_scope.ts create mode 100644 test/functional/fixtures/kbn_archiver/index_pattern_without_timefield_1.json diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts index cba499ec24f22..8a27dcd639179 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts @@ -15,6 +15,24 @@ import { serviceLoadedMsg } from '../../../utils'; type LoginFunction = (role: string) => Promise; +export interface BrowserAuthFixture { + /** + * Logs in as a user with viewer-only permissions. + * @returns A Promise that resolves once the cookie in browser is set. + */ + loginAsViewer: () => Promise; + /** + * Logs in as a user with administrative privileges + * @returns A Promise that resolves once the cookie in browser is set. + */ + loginAsAdmin: () => Promise; + /** + * Logs in as a user with elevated, but not admin, permissions. + * @returns A Promise that resolves once the cookie in browser is set. + */ + loginAsPrivilegedUser: () => Promise; +} + /** * The "browserAuth" fixture simplifies the process of logging into Kibana with * different roles during tests. It uses the "samlAuth" fixture to create an authentication session diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts index 5b8d661ac347b..d8b6ef722c1c4 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts @@ -9,7 +9,98 @@ import { Page, test as base } from '@playwright/test'; import { subj } from '@kbn/test-subj-selector'; -import { KibanaUrl, ScoutPage } from '../../types'; +import { KibanaUrl } from '../../types'; + +/** + * Extends the Playwright 'Page' interface with methods specific to Kibana. + * Reasons to use 'ReturnType' instead of Explicit Typings: + * - DRY Principle: automatically stays in sync with the Playwright API, reducing maintenance overhead. + * - Future-Proofing: If Playwright changes the return type of methods, these types will update accordingly. + * Recommendation: define Explicit Types as return types only if methods (e.g. 'typeWithDelay') + * have any additional logic or Kibana-specific behavior. + */ +export type ScoutPage = Page & { + /** + * Navigates to the specified Kibana application. + * @param appName - The name of the Kibana app (e.g., 'discover', 'dashboard'). + * @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; + /** + * Waits for the Kibana loading spinner indicator to disappear. + * @returns A Promise resolving when the indicator is hidden. + */ + waitForLoadingIndicatorHidden: () => ReturnType; + /** + * Simplified API to interact with elements using Kibana's 'data-test-subj' attribute. + */ + testSubj: { + check: (selector: string, options?: Parameters[1]) => ReturnType; + click: (selector: string, options?: Parameters[1]) => ReturnType; + dblclick: ( + selector: string, + options?: Parameters[1] + ) => ReturnType; + fill: ( + selector: string, + value: string, + options?: Parameters[2] + ) => ReturnType; + focus: (selector: string, options?: Parameters[1]) => ReturnType; + getAttribute: ( + selector: string, + name: string, + options?: Parameters[2] + ) => ReturnType; + hover: (selector: string, options?: Parameters[1]) => ReturnType; + innerText: ( + selector: string, + options?: Parameters[1] + ) => ReturnType; + isEnabled: ( + selector: string, + options?: Parameters[1] + ) => ReturnType; + isChecked: ( + selector: string, + options?: Parameters[1] + ) => ReturnType; + isHidden: ( + selector: string, + options?: Parameters[1] + ) => ReturnType; + isVisible: ( + selector: string, + options?: Parameters[1] + ) => ReturnType; + locator: ( + selector: string, + options?: Parameters[1] + ) => ReturnType; + waitForSelector: ( + selector: string, + options?: Parameters[1] + ) => ReturnType; + // custom methods + /** + * Types text into an input field character by character with a specified delay between each character. + * + * @param selector - The selector for the input element (supports 'data-test-subj' attributes). + * @param text - The text to type into the input field. + * @param options - Optional configuration object. + * @param options.delay - The delay in milliseconds between typing each character (default: 25ms). + * @returns A Promise that resolves once the text has been typed. + */ + typeWithDelay: (selector: string, text: string, options?: { delay: number }) => Promise; + /** + * Clears the input field by filling it with an empty string. + * @param selector The selector for the input element (supports 'data-test-subj' attributes). + * @returns A Promise that resolves once the text has been cleared. + */ + clearInput: (selector: string) => Promise; + }; +}; /** * Instead of defining each method individually, we use a list of method names and loop through them, creating methods dynamically. diff --git a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/core.ts b/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/core.ts index 1cd36a997d645..2f436c6027e81 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/core.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/core.ts @@ -9,18 +9,25 @@ import { test as base } from '@playwright/test'; -import { LoadActionPerfOptions } from '@kbn/es-archiver'; +import type { ToolingLog } from '@kbn/tooling-log'; import { createKbnUrl, - createEsArchiver, createEsClient, createKbnClient, createLogger, createSamlSessionManager, createScoutConfig, + KibanaUrl, } from '../../../../common/services'; -import { ScoutWorkerFixtures } from '../../types/worker_scope'; import { ScoutTestOptions } from '../../../types'; +import { Client, KbnClient, SamlSessionManager, ScoutTestConfig } from '../../../../types'; + +// re-export to import types from '@kbn-scout' +export type { KbnClient, SamlSessionManager } from '@kbn/test'; +export type { ToolingLog } from '@kbn/tooling-log'; +export type { Client as EsClient } from '@elastic/elasticsearch'; +export type { KibanaUrl } from '../../../../common/services/kibana_url'; +export type { ScoutTestConfig } from '../../../../types'; /** * The coreWorkerFixtures setup defines foundational fixtures that are essential @@ -29,7 +36,17 @@ import { ScoutTestOptions } from '../../../types'; * and isolated access to critical services such as logging, configuration, and * clients for interacting with Kibana and Elasticsearch. */ -export const coreWorkerFixtures = base.extend<{}, ScoutWorkerFixtures>({ +export const coreWorkerFixtures = base.extend< + {}, + { + log: ToolingLog; + config: ScoutTestConfig; + kbnUrl: KibanaUrl; + esClient: Client; + kbnClient: KbnClient; + samlAuth: SamlSessionManager; + } +>({ // Provides a scoped logger instance for each worker. This logger is shared across // all other fixtures within the worker scope. log: [ @@ -87,25 +104,6 @@ export const coreWorkerFixtures = base.extend<{}, ScoutWorkerFixtures>({ { scope: 'worker' }, ], - /** - * Provides utilities for managing test data in Elasticsearch. The "loadIfNeeded" method - * optimizes test execution by loading data archives only if required, avoiding redundant - * data ingestion. - * - * Note: In order to speedup test execution and avoid the overhead of deleting the data - * we only expose capability to ingest the data indexes. - */ - esArchiver: [ - ({ log, esClient, kbnClient }, use) => { - const esArchiverInstance = createEsArchiver(esClient, kbnClient, log); - const loadIfNeeded = async (name: string, performance?: LoadActionPerfOptions | undefined) => - esArchiverInstance!.loadIfNeeded(name, performance); - - use({ loadIfNeeded }); - }, - { scope: 'worker' }, - ], - /** * Creates a SAML session manager, that handles authentication tasks for tests involving * SAML-based authentication. diff --git a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/es_archiver.ts b/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/es_archiver.ts new file mode 100644 index 0000000000000..c84a680d9841b --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/es_archiver.ts @@ -0,0 +1,54 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { test as base } from '@playwright/test'; +import type { Client } from '@elastic/elasticsearch'; + +import { LoadActionPerfOptions } from '@kbn/es-archiver'; +import { IndexStats } from '@kbn/es-archiver/src/lib/stats'; +import { createEsArchiver } from '../../../../common/services'; +import { KbnClient, ToolingLog } from './core'; + +export interface EsArchiverFixture { + /** + * Loads an Elasticsearch archive if the specified data index is not present. + * @param name The name of the archive to load. + * @param performance An object of type LoadActionPerfOptions to measure and + * report performance metrics during the load operation. + * @returns A Promise that resolves to an object containing index statistics. + */ + loadIfNeeded: ( + name: string, + performance?: LoadActionPerfOptions | undefined + ) => Promise>; +} + +export const esArchiverFixture = base.extend< + {}, + { log: ToolingLog; esClient: Client; kbnClient: KbnClient; esArchiver: EsArchiverFixture } +>({ + /** + * Provides utilities for managing test data in Elasticsearch. The "loadIfNeeded" method + * optimizes test execution by loading data archives only if required, avoiding redundant + * data ingestion. + * + * Note: In order to speedup test execution and avoid the overhead of deleting the data + * we only expose capability to ingest the data indexes. + */ + esArchiver: [ + ({ log, esClient, kbnClient }, use) => { + const esArchiverInstance = createEsArchiver(esClient, kbnClient, log); + const loadIfNeeded = async (name: string, performance?: LoadActionPerfOptions | undefined) => + esArchiverInstance!.loadIfNeeded(name, performance); + + use({ loadIfNeeded }); + }, + { scope: 'worker' }, + ], +}); diff --git a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/index.ts b/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/index.ts index 74e73fd76be9f..8aafabf32e1c1 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/index.ts @@ -8,3 +8,13 @@ */ export { coreWorkerFixtures } from './core'; +export { esArchiverFixture } from './es_archiver'; +export type { EsArchiverFixture } from './es_archiver'; +export type { + ToolingLog, + ScoutTestConfig, + KibanaUrl, + EsClient, + KbnClient, + SamlSessionManager, +} from './core'; diff --git a/packages/kbn-scout/src/playwright/fixtures/index.ts b/packages/kbn-scout/src/playwright/fixtures/index.ts index 21ee7fd0c6f18..9f10d2d814ea7 100644 --- a/packages/kbn-scout/src/playwright/fixtures/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/index.ts @@ -9,25 +9,25 @@ import { mergeTests } from 'playwright/test'; import * as common from './common'; -import * as spaceAware from './parallel_run'; -import * as singleThread from './single_thread'; +import * as spaceAware from './parallel_workers'; +import * as singleThread from './single_worker/worker_scope'; export const scoutCoreFixtures = mergeTests( common.coreWorkerFixtures, - common.browserAuthFixture, - common.pageObjectsFixture, - common.scoutPageFixture, common.validateTagsFixture, + common.scoutPageFixture, + common.pageObjectsFixture, + common.esArchiverFixture, + common.browserAuthFixture, singleThread.uiSettingsFixture ); export const scoutCoreSpaceAwareFixtures = mergeTests( common.coreWorkerFixtures, - spaceAware.browserAuthFixture, - common.pageObjectsFixture, common.validateTagsFixture, - spaceAware.scoutSpacePageFixture, - spaceAware.uiSettingsSpaceFixture, - spaceAware.workerSpaceFixure + spaceAware.scoutPageSpaceFixture, + common.pageObjectsFixture, + spaceAware.browserAuthFixture, + spaceAware.kbnSpaceFixture ); export * from './types'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_run/ui_settings.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_run/ui_settings.ts deleted file mode 100644 index b1e226a6e9fa7..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_run/ui_settings.ts +++ /dev/null @@ -1,57 +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 { test as base } from '@playwright/test'; -import { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; -import { KbnClient, ToolingLog, UiSettingsFixture, WorkerSpaceFixure } from '../types'; -import { isValidUTCDate, formatTime } from '../../utils'; - -/** - * This fixture provides a way to interact with Kibana UI settings. - */ -export const uiSettingsSpaceFixture = base.extend< - {}, - { - kbnClient: KbnClient; - uiSettings: UiSettingsFixture; - workerSpace: WorkerSpaceFixure; - log: ToolingLog; - } ->({ - uiSettings: [ - ({ kbnClient, workerSpace, log }, use) => { - const kbnClientUiSettings = { - set: async (values: UiSettingValues) => { - log.info(`Setting UI settings for space ${workerSpace.id}: ${JSON.stringify(values)}`); - return kbnClient.uiSettings.update(values, { space: workerSpace.id }); - }, - - unset: async (...keys: string[]) => { - log.info(`Unsetting UI settings for space ${workerSpace.id}: ${keys}`); - return Promise.all( - keys.map((key) => kbnClient.uiSettings.unset(key, { space: workerSpace.id })) - ); - }, - setDefaultTime: async ({ from, to }: { from: string; to: string }) => { - const utcFrom = isValidUTCDate(from) ? from : formatTime(from); - const untcTo = isValidUTCDate(to) ? to : formatTime(to); - await kbnClient.uiSettings.update( - { - 'timepicker:timeDefaults': `{ "from": "${utcFrom}", "to": "${untcTo}"}`, - }, - { space: workerSpace.id } - ); - }, - }; - - use(kbnClientUiSettings); - }, - { scope: 'worker' }, - ], -}); diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_run/worker_space.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_run/worker_space.ts deleted file mode 100644 index f940ccee87a13..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_run/worker_space.ts +++ /dev/null @@ -1,36 +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 { test as base } from '@playwright/test'; -import { KbnClient, ToolingLog, WorkerSpaceFixure } from '../types'; - -export const workerSpaceFixure = base.extend< - {}, - { log: ToolingLog; kbnClient: KbnClient; workerSpace: WorkerSpaceFixure } ->({ - workerSpace: [ - async ({ log, kbnClient }: { log: ToolingLog; kbnClient: KbnClient }, use, workerInfo) => { - const id = `test-space-${workerInfo.workerIndex}`; - const spacePayload = { - id, - name: id, - disabledFeatures: [], - }; - log.debug(`Creating space ${id}`); - await kbnClient.spaces.create(spacePayload); - - await use(spacePayload); - - // Cleanup space after tests via API call - log.debug(`Deleting space ${id}`); - await kbnClient.spaces.delete(id); - }, - { scope: 'worker' }, - ], -}); diff --git a/packages/kbn-scout/src/playwright/fixtures/types/parallel_run_test_scope.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/index.ts similarity index 58% rename from packages/kbn-scout/src/playwright/fixtures/types/parallel_run_test_scope.ts rename to packages/kbn-scout/src/playwright/fixtures/parallel_workers/index.ts index a9d85a5491021..4a23d4c5ce936 100644 --- a/packages/kbn-scout/src/playwright/fixtures/types/parallel_run_test_scope.ts +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/index.ts @@ -7,14 +7,5 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { LoginFixture, ScoutPage } from './test_scope'; -import { PageObjects } from '../../page_objects'; - -/** - * The `ParallelRunTestScopeFixtures` type defines the set of fixtures that are available - */ -export interface ParallelRunTestFixtures { - browserAuth: LoginFixture; - page: ScoutPage; - pageObjects: PageObjects; -} +export * from './test_scope'; +export * from './worker_scope'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_run/browser_auth.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/browser_auth.ts similarity index 73% rename from packages/kbn-scout/src/playwright/fixtures/parallel_run/browser_auth.ts rename to packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/browser_auth.ts index d57945c090296..4b5f87d4d2010 100644 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_run/browser_auth.ts +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/browser_auth.ts @@ -8,20 +8,37 @@ */ import { test as base } from '@playwright/test'; -import { PROJECT_DEFAULT_ROLES } from '../../../common'; -import { SamlSessionManager, ScoutTestConfig, ToolingLog } from '../../../types'; -import { LoginFixture } from '../types'; -import { serviceLoadedMsg } from '../../utils'; +import { PROJECT_DEFAULT_ROLES } from '../../../../common'; +import { SamlSessionManager, ScoutTestConfig, ToolingLog } from '../../../../types'; +import { serviceLoadedMsg } from '../../../utils'; type LoginFunction = (role: string) => Promise; +export interface BrowserAuthFixture { + /** + * Logs in as a user with viewer-only permissions. + * @returns A Promise that resolves once the cookie in browser is set. + */ + loginAsViewer: () => Promise; + /** + * Logs in as a user with administrative privileges + * @returns A Promise that resolves once the cookie in browser is set. + */ + loginAsAdmin: () => Promise; + /** + * Logs in as a user with elevated, but not admin, permissions. + * @returns A Promise that resolves once the cookie in browser is set. + */ + loginAsPrivilegedUser: () => Promise; +} + /** * The "browserAuth" fixture simplifies the process of logging into Kibana with * different roles during tests. It uses the "samlAuth" fixture to create an authentication session * for the specified role and the "context" fixture to update the cookie with the role-scoped session. */ export const browserAuthFixture = base.extend< - { browserAuth: LoginFixture }, + { browserAuth: BrowserAuthFixture }, { log: ToolingLog; samlAuth: SamlSessionManager; config: ScoutTestConfig } >({ browserAuth: async ({ log, context, samlAuth, config }, use) => { diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_run/index.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/index.ts similarity index 76% rename from packages/kbn-scout/src/playwright/fixtures/parallel_run/index.ts rename to packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/index.ts index cc9a1dec43644..d58d3ae816353 100644 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_run/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/index.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export { scoutSpacePageFixture } from './page'; -export { uiSettingsSpaceFixture } from './ui_settings'; -export { workerSpaceFixure } from './worker_space'; export { browserAuthFixture } from './browser_auth'; +export type { BrowserAuthFixture } from './browser_auth'; +export { scoutPageSpaceFixture } from './page'; +export type { ScoutPageSpaceFixture } from './page'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_run/page.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/page.ts similarity index 65% rename from packages/kbn-scout/src/playwright/fixtures/parallel_run/page.ts rename to packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/page.ts index 26ad7434b8a5a..772c57cd152cd 100644 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_run/page.ts +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/page.ts @@ -8,26 +8,25 @@ */ import { Page, test as base } from '@playwright/test'; -import { KibanaUrl, ScoutPage, WorkerSpaceFixure } from '../types'; -import { extendPlaywrightPage } from '../common/test_scope/page'; +import { ScoutPage, extendPlaywrightPage } from '../../common/test_scope/page'; +import { KibanaUrl } from '../../common'; +import { KbnSpaceFixture } from '../worker_scope'; -export const scoutSpacePageFixture = base.extend< +export type ScoutPageSpaceFixture = ScoutPage; + +export const scoutPageSpaceFixture = base.extend< {}, - { kbnUrl: KibanaUrl; workerSpace: WorkerSpaceFixure } + { kbnUrl: KibanaUrl; kbnSpace: KbnSpaceFixture } >({ page: async ( - { - page, - kbnUrl, - workerSpace, - }: { page: Page; kbnUrl: KibanaUrl; workerSpace: WorkerSpaceFixure }, + { page, kbnUrl, kbnSpace }: { page: Page; kbnUrl: KibanaUrl; kbnSpace: KbnSpaceFixture }, use: (spaceAwarePage: ScoutPage) => Promise ) => { const extendedPage = extendPlaywrightPage({ page, kbnUrl }); // Overriding navigation to specific Kibana apps to take into account the worker space extendedPage.gotoApp = (appName: string) => - page.goto(kbnUrl.app(appName, { space: workerSpace.id })); + page.goto(kbnUrl.app(appName, { space: kbnSpace.id })); // Method to wait for global loading indicator to be hidden await use(extendedPage); }, diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/index.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/index.ts new file mode 100644 index 0000000000000..12ce499eda632 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/index.ts @@ -0,0 +1,11 @@ +/* + * 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 { kbnSpaceFixture } from './kbn_space'; +export type { KbnSpaceFixture } from './kbn_space'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/kbn_space.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/kbn_space.ts new file mode 100644 index 0000000000000..6fc5fe9a4139b --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/kbn_space.ts @@ -0,0 +1,137 @@ +/* + * 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 { test as base } from '@playwright/test'; +import { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; +import { formatTime, isValidUTCDate } from '../../../utils'; +import { KbnClient, ToolingLog } from '../../common'; + +export interface ImportSavedObjects { + type: string; + destinationId: string; + meta: { title: string }; +} +export interface ImportExportResponse { + successResults: ImportSavedObjects[]; +} +export interface SavedObjectResponse { + id: string; + type: string; + title: string; +} + +export interface KbnSpaceFixture { + id: string; + savedObjects: { + load: (path: string) => Promise; + cleanStandardList: () => Promise; + }; + uiSettings: { + setDefaultIndex: (dataViewId: string) => Promise; + set: (values: UiSettingValues) => Promise; + unset: (...keys: string[]) => Promise; + setDefaultTime: ({ from, to }: { from: string; to: string }) => Promise; + }; +} + +export const kbnSpaceFixture = base.extend< + {}, + { log: ToolingLog; kbnClient: KbnClient; kbnSpace: KbnSpaceFixture } +>({ + kbnSpace: [ + async ({ log, kbnClient }: { log: ToolingLog; kbnClient: KbnClient }, use, workerInfo) => { + const id = `test-space-${workerInfo.workerIndex}`; + const spacePayload = { + id, + name: id, + disabledFeatures: [], + }; + log.debug(`Creating space ${id}`); + await kbnClient.spaces.create(spacePayload); + + // cache saved objects ids in space + const savedObjectsCache = new Map(); + + const load = async (path: string) => { + const response = await kbnClient.importExport.load(path, { + space: id, + createNewCopies: true, + }); + + const results = (response.successResults as ImportSavedObjects[]).map( + (r: { type: string; destinationId: string; meta: { title: string } }) => { + return { id: r.destinationId, type: r.type, title: r.meta.title }; + } + ); + + results.forEach((r) => savedObjectsCache.set(r.title, r.id)); + + return results; + }; + + const cleanStandardList = async () => { + return kbnClient.savedObjects.cleanStandardList({ + space: id, + }); + }; + + const setDefaultIndex = async (dataViewName: string) => { + if (savedObjectsCache.has(dataViewName)) { + await kbnClient.uiSettings.update( + { + defaultIndex: savedObjectsCache.get(dataViewName)!, + }, + { space: id } + ); + } else { + throw new Error(`Data view id ${dataViewName} not found in space ${id}`); + } + }; + + const set = async (values: UiSettingValues) => { + log.info(`Setting UI settings for space ${id}: ${JSON.stringify(values)}`); + return kbnClient.uiSettings.update(values, { space: id }); + }; + + const unset = async (...keys: string[]) => { + log.info(`Unsetting UI settings for space ${id}: ${keys}`); + return Promise.all(keys.map((key) => kbnClient.uiSettings.unset(key, { space: id }))); + }; + const setDefaultTime = async ({ from, to }: { from: string; to: string }) => { + const utcFrom = isValidUTCDate(from) ? from : formatTime(from); + const untcTo = isValidUTCDate(to) ? to : formatTime(to); + await kbnClient.uiSettings.update( + { + 'timepicker:timeDefaults': `{ "from": "${utcFrom}", "to": "${untcTo}"}`, + }, + { space: id } + ); + }; + + const savedObjects = { + load, + cleanStandardList, + }; + + const uiSettings = { + setDefaultIndex, + set, + unset, + setDefaultTime, + }; + + await use({ savedObjects, uiSettings, id }); + + // Cleanup space after tests via API call + log.debug(`Deleting space ${id}`); + await kbnClient.spaces.delete(id); + }, + { scope: 'worker', auto: true }, + ], +}); diff --git a/packages/kbn-scout/src/playwright/fixtures/single_thread/index.ts b/packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/index.ts similarity index 90% rename from packages/kbn-scout/src/playwright/fixtures/single_thread/index.ts rename to packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/index.ts index 14eb4ae6e41cb..edb5e8156b538 100644 --- a/packages/kbn-scout/src/playwright/fixtures/single_thread/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/index.ts @@ -8,3 +8,4 @@ */ export { uiSettingsFixture } from './ui_settings'; +export type { UiSettingsFixture } from './ui_settings'; diff --git a/packages/kbn-scout/src/playwright/fixtures/single_thread/ui_settings.ts b/packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/ui_settings.ts similarity index 51% rename from packages/kbn-scout/src/playwright/fixtures/single_thread/ui_settings.ts rename to packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/ui_settings.ts index 20fa59da9aba7..ebcababe9d5e8 100644 --- a/packages/kbn-scout/src/playwright/fixtures/single_thread/ui_settings.ts +++ b/packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/ui_settings.ts @@ -9,17 +9,44 @@ import { test as base } from '@playwright/test'; import { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; -import { ScoutWorkerFixtures } from '../types'; -import { isValidUTCDate, formatTime } from '../../utils'; +import { isValidUTCDate, formatTime } from '../../../utils'; +import { KbnClient, ToolingLog } from '../../common'; + +export interface UiSettingsFixture { + /** + * Applies one or more UI settings + * @param values (UiSettingValues): An object containing key-value pairs of UI settings to apply. + * @returns A Promise that resolves once the settings are applied. + */ + set: (values: UiSettingValues) => Promise; + /** + * Resets specific UI settings to their default values. + * @param values A list of UI setting keys to unset. + * @returns A Promise that resolves after the settings are unset. + */ + unset: (...values: string[]) => Promise; + /** + * Sets the default time range for Kibana. + * @from The start time of the default time range. + * @to The end time of the default time range. + * @returns A Promise that resolves once the default time is set. + */ + setDefaultTime: ({ from, to }: { from: string; to: string }) => Promise; +} /** * This fixture provides a way to interact with Kibana UI settings. */ -export const uiSettingsFixture = base.extend<{}, ScoutWorkerFixtures>({ +export const uiSettingsFixture = base.extend< + {}, + { kbnClient: KbnClient; uiSettings: UiSettingsFixture; log: ToolingLog } +>({ uiSettings: [ - ({ kbnClient }, use) => { + ({ kbnClient, log }, use) => { const kbnClientUiSettings = { - set: async (values: UiSettingValues) => kbnClient.uiSettings.update(values), + set: async (values: UiSettingValues) => { + await kbnClient.uiSettings.update(values); + }, unset: async (...keys: string[]) => Promise.all(keys.map((key) => kbnClient.uiSettings.unset(key))), diff --git a/packages/kbn-scout/src/playwright/fixtures/types/index.ts b/packages/kbn-scout/src/playwright/fixtures/types/index.ts index 100e6184afe6e..5421a9946ea5b 100644 --- a/packages/kbn-scout/src/playwright/fixtures/types/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/types/index.ts @@ -7,7 +7,5 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export * from './test_scope'; -export * from './worker_scope'; -export * from './parallel_run_test_scope'; -export * from './parallel_run_worker_scope'; +export * from './parallel_workers'; +export * from './single_worker'; diff --git a/packages/kbn-scout/src/playwright/fixtures/types/parallel_run_worker_scope.ts b/packages/kbn-scout/src/playwright/fixtures/types/parallel_run_worker_scope.ts deleted file mode 100644 index a2c2b65b88d67..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/types/parallel_run_worker_scope.ts +++ /dev/null @@ -1,35 +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 type { KbnClient, SamlSessionManager } from '@kbn/test'; -import type { ToolingLog } from '@kbn/tooling-log'; -import type { Client } from '@elastic/elasticsearch'; -import { ScoutTestConfig } from '../../../types'; -import { KibanaUrl } from '../../../common/services/kibana_url'; -import { EsArchiverFixture, UiSettingsFixture } from './worker_scope'; - -export interface WorkerSpaceFixure { - id: string; - name: string; -} - -/** - * The `ScoutWorkerFixtures` type defines the set of fixtures that are available - */ -export interface ParallelRunWorkerFixtures { - log: ToolingLog; - config: ScoutTestConfig; - esArchiver: EsArchiverFixture; - esClient: Client; - kbnClient: KbnClient; - kbnUrl: KibanaUrl; - uiSettings: UiSettingsFixture; - samlAuth: SamlSessionManager; - workerSpace: WorkerSpaceFixure; -} diff --git a/packages/kbn-scout/src/playwright/fixtures/types/parallel_workers.ts b/packages/kbn-scout/src/playwright/fixtures/types/parallel_workers.ts new file mode 100644 index 0000000000000..ad500c29365ba --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/types/parallel_workers.ts @@ -0,0 +1,29 @@ +/* + * 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 { ToolingLog } from '@kbn/tooling-log'; +import { PageObjects } from '../../page_objects'; +import { BrowserAuthFixture, ScoutPageSpaceFixture } from '../parallel_workers/test_scope'; +import { EsClient, KbnClient, KibanaUrl, ScoutTestConfig } from '../common'; +import { KbnSpaceFixture } from '../parallel_workers'; + +export interface ParallelRunTestFixtures { + browserAuth: BrowserAuthFixture; + page: ScoutPageSpaceFixture; + pageObjects: PageObjects; +} + +export interface ParallelRunWorkerFixtures { + log: ToolingLog; + config: ScoutTestConfig; + esClient: EsClient; + kbnClient: KbnClient; + kbnSpace: KbnSpaceFixture; + kbnUrl: KibanaUrl; +} diff --git a/packages/kbn-scout/src/playwright/fixtures/types/single_worker.ts b/packages/kbn-scout/src/playwright/fixtures/types/single_worker.ts new file mode 100644 index 0000000000000..8e63727d4f828 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/types/single_worker.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", 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 { ToolingLog } from '@kbn/tooling-log'; +import { PageObjects } from '../../page_objects'; +import { EsClient, KbnClient, KibanaUrl, ScoutTestConfig } from '../common'; +import { ScoutPage } from '../common/test_scope/page'; +import { BrowserAuthFixture } from '../common/test_scope/browser_auth'; +import { UiSettingsFixture } from '../single_worker/worker_scope/ui_settings'; + +export interface ScoutTestFixtures { + browserAuth: BrowserAuthFixture; + page: ScoutPage; + pageObjects: PageObjects; +} + +export interface ScoutWorkerFixtures { + log: ToolingLog; + config: ScoutTestConfig; + kbnUrl: KibanaUrl; + kbnClient: KbnClient; + esClient: EsClient; + uiSettings: UiSettingsFixture; +} diff --git a/packages/kbn-scout/src/playwright/fixtures/types/test_scope.ts b/packages/kbn-scout/src/playwright/fixtures/types/test_scope.ts deleted file mode 100644 index 13a3c3ebaed83..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/types/test_scope.ts +++ /dev/null @@ -1,126 +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 { Page } from 'playwright/test'; -import { PageObjects } from '../../page_objects'; - -export interface ScoutTestFixtures { - browserAuth: LoginFixture; - page: ScoutPage; - pageObjects: PageObjects; -} - -export interface LoginFixture { - /** - * Logs in as a user with viewer-only permissions. - * @returns A Promise that resolves once the cookie in browser is set. - */ - loginAsViewer: () => Promise; - /** - * Logs in as a user with administrative privileges - * @returns A Promise that resolves once the cookie in browser is set. - */ - loginAsAdmin: () => Promise; - /** - * Logs in as a user with elevated, but not admin, permissions. - * @returns A Promise that resolves once the cookie in browser is set. - */ - loginAsPrivilegedUser: () => Promise; -} - -/** - * Extends the Playwright 'Page' interface with methods specific to Kibana. - * Reasons to use 'ReturnType' instead of Explicit Typings: - * - DRY Principle: automatically stays in sync with the Playwright API, reducing maintenance overhead. - * - Future-Proofing: If Playwright changes the return type of methods, these types will update accordingly. - * Recommendation: define Explicit Types as return types only if methods (e.g. 'typeWithDelay') - * have any additional logic or Kibana-specific behavior. - */ -export type ScoutPage = Page & { - /** - * Navigates to the specified Kibana application. - * @param appName - The name of the Kibana app (e.g., 'discover', 'dashboard'). - * @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; - /** - * Waits for the Kibana loading spinner indicator to disappear. - * @returns A Promise resolving when the indicator is hidden. - */ - waitForLoadingIndicatorHidden: () => ReturnType; - /** - * Simplified API to interact with elements using Kibana's 'data-test-subj' attribute. - */ - testSubj: { - check: (selector: string, options?: Parameters[1]) => ReturnType; - click: (selector: string, options?: Parameters[1]) => ReturnType; - dblclick: ( - selector: string, - options?: Parameters[1] - ) => ReturnType; - fill: ( - selector: string, - value: string, - options?: Parameters[2] - ) => ReturnType; - focus: (selector: string, options?: Parameters[1]) => ReturnType; - getAttribute: ( - selector: string, - name: string, - options?: Parameters[2] - ) => ReturnType; - hover: (selector: string, options?: Parameters[1]) => ReturnType; - innerText: ( - selector: string, - options?: Parameters[1] - ) => ReturnType; - isEnabled: ( - selector: string, - options?: Parameters[1] - ) => ReturnType; - isChecked: ( - selector: string, - options?: Parameters[1] - ) => ReturnType; - isHidden: ( - selector: string, - options?: Parameters[1] - ) => ReturnType; - isVisible: ( - selector: string, - options?: Parameters[1] - ) => ReturnType; - locator: ( - selector: string, - options?: Parameters[1] - ) => ReturnType; - waitForSelector: ( - selector: string, - options?: Parameters[1] - ) => ReturnType; - // custom methods - /** - * Types text into an input field character by character with a specified delay between each character. - * - * @param selector - The selector for the input element (supports 'data-test-subj' attributes). - * @param text - The text to type into the input field. - * @param options - Optional configuration object. - * @param options.delay - The delay in milliseconds between typing each character (default: 25ms). - * @returns A Promise that resolves once the text has been typed. - */ - typeWithDelay: (selector: string, text: string, options?: { delay: number }) => Promise; - /** - * Clears the input field by filling it with an empty string. - * @param selector The selector for the input element (supports 'data-test-subj' attributes). - * @returns A Promise that resolves once the text has been cleared. - */ - clearInput: (selector: string) => Promise; - }; -}; diff --git a/packages/kbn-scout/src/playwright/fixtures/types/worker_scope.ts b/packages/kbn-scout/src/playwright/fixtures/types/worker_scope.ts deleted file mode 100644 index 29283cbea4517..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/types/worker_scope.ts +++ /dev/null @@ -1,74 +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 type { KbnClient, SamlSessionManager } from '@kbn/test'; -import type { ToolingLog } from '@kbn/tooling-log'; -import type { Client } from '@elastic/elasticsearch'; -import { LoadActionPerfOptions } from '@kbn/es-archiver'; -import { IndexStats } from '@kbn/es-archiver/src/lib/stats'; -import type { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; - -import { ScoutTestConfig } from '../../../types'; -import { KibanaUrl } from '../../../common/services/kibana_url'; - -export interface EsArchiverFixture { - /** - * Loads an Elasticsearch archive if the specified data index is not present. - * @param name The name of the archive to load. - * @param performance An object of type LoadActionPerfOptions to measure and - * report performance metrics during the load operation. - * @returns A Promise that resolves to an object containing index statistics. - */ - loadIfNeeded: ( - name: string, - performance?: LoadActionPerfOptions | undefined - ) => Promise>; -} - -export interface UiSettingsFixture { - /** - * Applies one or more UI settings - * @param values (UiSettingValues): An object containing key-value pairs of UI settings to apply. - * @returns A Promise that resolves once the settings are applied. - */ - set: (values: UiSettingValues) => Promise; - /** - * Resets specific UI settings to their default values. - * @param values A list of UI setting keys to unset. - * @returns A Promise that resolves after the settings are unset. - */ - unset: (...values: string[]) => Promise; - /** - * Sets the default time range for Kibana. - * @from The start time of the default time range. - * @to The end time of the default time range. - * @returns A Promise that resolves once the default time is set. - */ - setDefaultTime: ({ from, to }: { from: string; to: string }) => Promise; -} - -/** - * The `ScoutWorkerFixtures` type defines the set of fixtures that are available - */ -export interface ScoutWorkerFixtures { - log: ToolingLog; - config: ScoutTestConfig; - kbnUrl: KibanaUrl; - esClient: Client; - kbnClient: KbnClient; - uiSettings: UiSettingsFixture; - esArchiver: EsArchiverFixture; - samlAuth: SamlSessionManager; -} - -// re-export to import types from '@kbn-scout' -export type { KbnClient, SamlSessionManager } from '@kbn/test'; -export type { ToolingLog } from '@kbn/tooling-log'; -export type { Client } from '@elastic/elasticsearch'; -export type { KibanaUrl } from '../../../common/services/kibana_url'; diff --git a/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts b/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts index c4bd0ff23064d..ba4001c5d91a1 100644 --- a/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts +++ b/packages/kbn-test/src/kbn_client/kbn_client_import_export.ts @@ -55,7 +55,7 @@ export class KbnClientImportExport { return absolutePath; } - async load(path: string, options?: { space?: string }) { + async load(path: string, options?: { space?: string; createNewCopies?: boolean }) { const src = this.resolveAndValidatePath(path); this.log.debug('resolved import for', path, 'to', src); @@ -65,19 +65,20 @@ export class KbnClientImportExport { const formData = new FormData(); formData.append('file', objects.map((obj) => JSON.stringify(obj)).join('\n'), 'import.ndjson'); + const query = options?.createNewCopies ? { createNewCopies: true } : { overwrite: true }; + // TODO: should we clear out the existing saved objects? const resp = await this.req(options?.space, { method: 'POST', path: '/api/saved_objects/_import', - query: { - createNewCopies: true, - }, + query, body: formData, headers: formData.getHeaders(), }); if (resp.data.success) { this.log.success('import success'); + return resp.data; } else { throw createFailError( `failed to import all saved objects: ${inspect(resp.data, { diff --git a/test/functional/fixtures/kbn_archiver/index_pattern_without_timefield_1.json b/test/functional/fixtures/kbn_archiver/index_pattern_without_timefield_1.json new file mode 100644 index 0000000000000..7edb8db3bcd3d --- /dev/null +++ b/test/functional/fixtures/kbn_archiver/index_pattern_without_timefield_1.json @@ -0,0 +1,25 @@ +{ + "attributes":{ + "allowHidden":false, + "fieldAttrs":"{}", + "fieldFormatMap":"{}", + "fields":"[]", + "name":"without-timefield", + "runtimeFieldMap":"{}", + "sourceFilters":"[]", + "title":"without-timefield" + }, + "coreMigrationVersion":"8.8.0", + "created_at":"2025-01-16T13:26:50.483Z", + "created_by":"u_EWATCHX9oIEsmcXj8aA1FkcaY3DE-XEpsiGTjrR2PmM_0", + "id":"c1e8af24-c7b7-4d9b-ab0e-e408c88d29c9", + "managed":false, + "references":[ + + ], + "type":"index-pattern", + "typeMigrationVersion":"8.0.0", + "updated_at":"2025-01-16T13:26:50.483Z", + "updated_by":"u_EWATCHX9oIEsmcXj8aA1FkcaY3DE-XEpsiGTjrR2PmM_0", + "version":"WzIwLDFd" +} diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/constants.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/constants.ts index 3ac2c34586f4d..60693ecfcba90 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/constants.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/constants.ts @@ -11,6 +11,7 @@ export const LOGSTASH_DEFAULT_END_TIME = '2015-09-23T18:31:44.000Z'; export const DATA_VIEW_ID = { ECOMMERCE: '5193f870-d861-11e9-a311-0fa548c5f953', LOGSTASH: 'logstash-*', + NO_TIME_FIELD: 'c1e8af24-c7b7-4d9b-ab0e-e408c88d29c9', }; export const DATA_VIEW = { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts index 1136ee4ad59b9..98d3eb78c1f9d 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts @@ -9,22 +9,17 @@ import { expect, tags } from '@kbn/scout'; import { spaceTest, testData } from '../fixtures'; spaceTest.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { - spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await kbnClient.savedObjects.clean({ - types: ['search', 'index-pattern'], - space: workerSpace.id, - }); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD, { - space: workerSpace.id, - }); - await uiSettings.setDefaultTime({ + spaceTest.beforeAll(async ({ kbnSpace }) => { + await kbnSpace.savedObjects.cleanStandardList(); + await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); + await kbnSpace.uiSettings.setDefaultTime({ from: testData.LOGSTASH_DEFAULT_START_TIME, to: testData.LOGSTASH_DEFAULT_END_TIME, }); }); - spaceTest.afterAll(async ({ kbnClient, workerSpace }) => { - await kbnClient.savedObjects.cleanStandardList({ space: workerSpace.id }); + spaceTest.afterAll(async ({ kbnSpace }) => { + await kbnSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts index 1f508ed31c8ff..21645728b96ac 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts @@ -18,7 +18,7 @@ const createSavedSearch = async ( await kbnClient.savedObjects.create({ type: 'search', id: searchId, - overwrite: false, + overwrite: true, attributes: { space: spaceId, title: searchTitle, @@ -45,21 +45,23 @@ spaceTest.describe.skip( () => { const SAVED_SEARCH_TITLE = 'TempSearch'; const SAVED_SEARCH_ID = '90943e30-9a47-11e8-b64d-95841ca0b247'; - spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { + let dataViewId: string; + spaceTest.beforeAll(async ({ kbnClient, kbnSpace }) => { + const results = await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + dataViewId = results.find((i) => i.title === 'logstash-*')!.id; + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { - space: workerSpace.id, + space: kbnSpace.id, }); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + await kbnSpace.uiSettings.set({ + defaultIndex: dataViewId, // TODO: investigate why it is required for `node scripts/playwright_test.js` run 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, }); }); - spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList({ - space: workerSpace.id, - }); + spaceTest.afterAll(async ({ kbnSpace }) => { + await kbnSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { @@ -69,14 +71,14 @@ spaceTest.describe.skip( spaceTest( 'should allow removing the dashboard panel after the underlying saved search has been deleted', - async ({ kbnClient, page, pageObjects, workerSpace }) => { + async ({ kbnClient, page, pageObjects, kbnSpace }) => { await pageObjects.dashboard.openNewDashboard(); await createSavedSearch( kbnClient, SAVED_SEARCH_ID, SAVED_SEARCH_TITLE, - testData.DATA_VIEW_ID.LOGSTASH, - workerSpace.id + dataViewId, + kbnSpace.id ); await pageObjects.dashboard.addPanelFromLibrary(SAVED_SEARCH_TITLE); await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ @@ -87,7 +89,7 @@ spaceTest.describe.skip( await kbnClient.savedObjects.delete({ type: 'search', id: SAVED_SEARCH_ID, - space: workerSpace.id, + space: kbnSpace.id, }); await page.reload(); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts index 1d393e8e50ba8..8025792b884be 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts @@ -47,18 +47,16 @@ spaceTest.describe( value: `Men's Shoes`, }; - spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DISCOVER, { space: workerSpace.id }); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.ECOMMERCE, { space: workerSpace.id }); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.ECOMMERCE, - 'timepicker:timeDefaults': `{ "from": "${START_TIME}", "to": "${END_TIME}"}`, - }); + spaceTest.beforeAll(async ({ kbnSpace }) => { + await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.DISCOVER); + await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.ECOMMERCE); + await kbnSpace.uiSettings.setDefaultIndex('ecommerce'); + await kbnSpace.uiSettings.setDefaultTime({ from: START_TIME, to: END_TIME }); }); - spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList({ space: workerSpace.id }); + spaceTest.afterAll(async ({ kbnSpace }) => { + await kbnSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts index 3c9e4b9196100..e81dcbe2e10b9 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts @@ -12,21 +12,18 @@ spaceTest.describe( 'Discover app - value suggestions: useTimeRange enabled', { tag: tags.DEPLOYMENT_AGNOSTIC }, () => { - spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { - space: workerSpace.id, - }); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + spaceTest.beforeAll(async ({ kbnSpace }) => { + await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await kbnSpace.uiSettings.setDefaultIndex('logstash-*'); + await kbnSpace.uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, }); }); - spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList({ - space: workerSpace.id, - }); + spaceTest.afterAll(async ({ kbnSpace }) => { + await kbnSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts index 09b45255536cf..2cea1e275fc9d 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts @@ -14,20 +14,14 @@ spaceTest.describe( // TODO: Update to use an ES archive with an index accessible to 'viewer' // for running this test against the Security serverless project. () => { - spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await kbnClient.importExport.load(testData.KBN_ARCHIVES.NO_TIME_FIELD, { - space: workerSpace.id, - }); - await uiSettings.set({ - defaultIndex: 'without-timefield', - }); + spaceTest.beforeAll(async ({ kbnSpace }) => { + await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); + await kbnSpace.uiSettings.setDefaultIndex('without-timefield'); }); - spaceTest.afterAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await uiSettings.unset('defaultIndex'); - await kbnClient.savedObjects.cleanStandardList({ - space: workerSpace.id, - }); + spaceTest.afterAll(async ({ kbnSpace }) => { + await kbnSpace.uiSettings.unset('defaultIndex'); + await kbnSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts index 6349c16b9e01f..3fa8650e3ca6a 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts @@ -12,23 +12,20 @@ spaceTest.describe( 'Discover app - value suggestions: useTimeRange disabled', { tag: tags.DEPLOYMENT_AGNOSTIC }, () => { - spaceTest.beforeAll(async ({ kbnClient, uiSettings, workerSpace }) => { - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { - space: workerSpace.id, - }); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - 'autocomplete:useTimeRange': false, + spaceTest.beforeAll(async ({ kbnSpace }) => { + await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await kbnSpace.uiSettings.setDefaultIndex('logstash-*'); + await kbnSpace.uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, }); + await kbnSpace.uiSettings.set({ 'autocomplete:useTimeRange': false }); }); - spaceTest.afterAll(async ({ uiSettings, kbnClient, workerSpace }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await uiSettings.set({ 'autocomplete:useTimeRange': true }); - await kbnClient.savedObjects.cleanStandardList({ - space: workerSpace.id, - }); + spaceTest.afterAll(async ({ kbnSpace }) => { + await kbnSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnSpace.uiSettings.set({ 'autocomplete:useTimeRange': true }); + await kbnSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts index 6c37611dbc202..5b38eafc6476c 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts @@ -37,62 +37,66 @@ const createSavedSearch = async ( ], }); -test.describe('Discover app - saved search embeddable', { tag: tags.DEPLOYMENT_AGNOSTIC }, () => { - const SAVED_SEARCH_TITLE = 'TempSearch'; - const SAVED_SEARCH_ID = '90943e30-9a47-11e8-b64d-95841ca0b247'; - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, +test.describe.skip( + 'Discover app - saved search embeddable', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + const SAVED_SEARCH_TITLE = 'TempSearch'; + const SAVED_SEARCH_ID = '90943e30-9a47-11e8-b64d-95841ca0b247'; + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + }); }); - }); - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList(); - }); + test.afterAll(async ({ kbnClient, uiSettings }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList(); + }); - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsPrivilegedUser(); - await pageObjects.dashboard.goto(); - }); + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsPrivilegedUser(); + await pageObjects.dashboard.goto(); + }); - test('should allow removing the dashboard panel after the underlying saved search has been deleted', async ({ - kbnClient, - page, - pageObjects, - }) => { - await pageObjects.dashboard.openNewDashboard(); - await createSavedSearch( + test('should allow removing the dashboard panel after the underlying saved search has been deleted', async ({ kbnClient, - SAVED_SEARCH_ID, - SAVED_SEARCH_TITLE, - testData.DATA_VIEW_ID.LOGSTASH - ); - await pageObjects.dashboard.addPanelFromLibrary(SAVED_SEARCH_TITLE); - await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ - state: 'visible', - }); + page, + pageObjects, + }) => { + await pageObjects.dashboard.openNewDashboard(); + await createSavedSearch( + kbnClient, + SAVED_SEARCH_ID, + SAVED_SEARCH_TITLE, + testData.DATA_VIEW_ID.LOGSTASH + ); + await pageObjects.dashboard.addPanelFromLibrary(SAVED_SEARCH_TITLE); + await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ + state: 'visible', + }); - await pageObjects.dashboard.saveDashboard('Dashboard with deleted saved search'); - await kbnClient.savedObjects.delete({ - type: 'search', - id: SAVED_SEARCH_ID, - }); + await pageObjects.dashboard.saveDashboard('Dashboard with deleted saved search'); + await kbnClient.savedObjects.delete({ + type: 'search', + id: SAVED_SEARCH_ID, + }); - await page.reload(); - await page.waitForLoadingIndicatorHidden(); - await expect( - page.testSubj.locator('embeddableError'), - 'Embeddable error should be displayed' - ).toBeVisible(); + await page.reload(); + await page.waitForLoadingIndicatorHidden(); + await expect( + page.testSubj.locator('embeddableError'), + 'Embeddable error should be displayed' + ).toBeVisible(); - await pageObjects.dashboard.removePanel('embeddableError'); - await expect( - page.testSubj.locator('embeddableError'), - 'Embeddable error should not be displayed' - ).toBeHidden(); - }); -}); + await pageObjects.dashboard.removePanel('embeddableError'); + await expect( + page.testSubj.locator('embeddableError'), + 'Embeddable error should not be displayed' + ).toBeHidden(); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts index 4966d32e1982f..d8035597fa0e4 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts @@ -8,7 +8,7 @@ import { expect } from '@kbn/scout'; import { test, testData, assertionMessages } from '../fixtures'; -test.describe.only( +test.describe( 'Discover app - value suggestions non-time based', { tag: ['@ess', '@svlSearch', '@svlOblt'] }, // TODO: Update to use an ES archive with an index accessible to 'viewer' From b99065ec8179878b304e7c113e3a19baecfedb75 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Mon, 20 Jan 2025 18:57:43 +0100 Subject: [PATCH 04/23] update pipeline --- .buildkite/scripts/steps/functional/scout_ui_tests.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.buildkite/scripts/steps/functional/scout_ui_tests.sh b/.buildkite/scripts/steps/functional/scout_ui_tests.sh index c16c92152684d..5204e78983d57 100755 --- a/.buildkite/scripts/steps/functional/scout_ui_tests.sh +++ b/.buildkite/scripts/steps/functional/scout_ui_tests.sh @@ -24,6 +24,11 @@ run_tests() { EXIT_CODE=0 +# Discovery Enhanced parallel run +for run_mode in "--stateful" "--serverless=es" "--serverless=oblt" "--serverless=security"; do + run_tests "Discovery Enhanced" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.parallel.config.ts" "$run_mode" +done + # Discovery Enhanced for run_mode in "--stateful" "--serverless=es" "--serverless=oblt" "--serverless=security"; do run_tests "Discovery Enhanced" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.config.ts" "$run_mode" From c8b1795f3592b98d67491f0450dd7b77dd817b84 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Mon, 20 Jan 2025 19:06:17 +0100 Subject: [PATCH 05/23] fix type errors --- .../playwright/fixtures/common/test_scope/browser_auth.ts | 5 ++--- .../src/playwright/fixtures/common/test_scope/page.ts | 2 +- .../playwright/fixtures/common/test_scope/page_objects.ts | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts index 8a27dcd639179..6efdf183a5787 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts @@ -8,10 +8,9 @@ */ import { test as base } from '@playwright/test'; -import { ScoutTestConfig, ToolingLog } from '../../../../types'; import { PROJECT_DEFAULT_ROLES } from '../../../../common'; -import { LoginFixture, SamlSessionManager } from '../../types'; import { serviceLoadedMsg } from '../../../utils'; +import { SamlSessionManager, ScoutTestConfig, ToolingLog } from '../worker_scope'; type LoginFunction = (role: string) => Promise; @@ -39,7 +38,7 @@ export interface BrowserAuthFixture { * for the specified role and the "context" fixture to update the cookie with the role-scoped session. */ export const browserAuthFixture = base.extend< - { browserAuth: LoginFixture }, + { browserAuth: BrowserAuthFixture }, { log: ToolingLog; samlAuth: SamlSessionManager; config: ScoutTestConfig } >({ browserAuth: async ({ log, context, samlAuth, config }, use) => { diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts index d8b6ef722c1c4..e3a41e330ced8 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts @@ -9,7 +9,7 @@ import { Page, test as base } from '@playwright/test'; import { subj } from '@kbn/test-subj-selector'; -import { KibanaUrl } from '../../types'; +import { KibanaUrl } from '../worker_scope'; /** * Extends the Playwright 'Page' interface with methods specific to Kibana. diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page_objects.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page_objects.ts index d519aa9ebf9c2..0288471faa5bc 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page_objects.ts +++ b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page_objects.ts @@ -8,8 +8,8 @@ */ import { test as base } from '@playwright/test'; -import { ScoutPage } from '../../types'; import { PageObjects, createCorePageObjects } from '../../../page_objects'; +import { ScoutPage } from './page'; /** * The "pageObjects" fixture provides a centralized and consistent way to access and From 15175ea02b9c9355aa8f185ab25f3c5a561b2e3c Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 21 Jan 2025 11:39:00 +0100 Subject: [PATCH 06/23] change config name --- .buildkite/scripts/steps/functional/scout_ui_tests.sh | 2 +- ...ywright.parallel.config.ts => parallel.playwright.config.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename x-pack/platform/plugins/private/discover_enhanced/ui_tests/{playwright.parallel.config.ts => parallel.playwright.config.ts} (100%) diff --git a/.buildkite/scripts/steps/functional/scout_ui_tests.sh b/.buildkite/scripts/steps/functional/scout_ui_tests.sh index 5204e78983d57..7037bd1db6b97 100755 --- a/.buildkite/scripts/steps/functional/scout_ui_tests.sh +++ b/.buildkite/scripts/steps/functional/scout_ui_tests.sh @@ -26,7 +26,7 @@ EXIT_CODE=0 # Discovery Enhanced parallel run for run_mode in "--stateful" "--serverless=es" "--serverless=oblt" "--serverless=security"; do - run_tests "Discovery Enhanced" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.parallel.config.ts" "$run_mode" + run_tests "Discovery Enhanced" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts" "$run_mode" done # Discovery Enhanced diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.parallel.config.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts similarity index 100% rename from x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.parallel.config.ts rename to x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts From 2b00f4f45a1eecc399b891bfb6753a30f84286c4 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 21 Jan 2025 11:42:03 +0100 Subject: [PATCH 07/23] delete SO test file --- .../index_pattern_without_timefield_1.json | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 test/functional/fixtures/kbn_archiver/index_pattern_without_timefield_1.json diff --git a/test/functional/fixtures/kbn_archiver/index_pattern_without_timefield_1.json b/test/functional/fixtures/kbn_archiver/index_pattern_without_timefield_1.json deleted file mode 100644 index 7edb8db3bcd3d..0000000000000 --- a/test/functional/fixtures/kbn_archiver/index_pattern_without_timefield_1.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "attributes":{ - "allowHidden":false, - "fieldAttrs":"{}", - "fieldFormatMap":"{}", - "fields":"[]", - "name":"without-timefield", - "runtimeFieldMap":"{}", - "sourceFilters":"[]", - "title":"without-timefield" - }, - "coreMigrationVersion":"8.8.0", - "created_at":"2025-01-16T13:26:50.483Z", - "created_by":"u_EWATCHX9oIEsmcXj8aA1FkcaY3DE-XEpsiGTjrR2PmM_0", - "id":"c1e8af24-c7b7-4d9b-ab0e-e408c88d29c9", - "managed":false, - "references":[ - - ], - "type":"index-pattern", - "typeMigrationVersion":"8.0.0", - "updated_at":"2025-01-16T13:26:50.483Z", - "updated_by":"u_EWATCHX9oIEsmcXj8aA1FkcaY3DE-XEpsiGTjrR2PmM_0", - "version":"WzIwLDFd" -} From 265bf5ddee4125b2ba1035e8ee599581b77a1dea Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 21 Jan 2025 14:21:55 +0100 Subject: [PATCH 08/23] change structure --- packages/kbn-scout/index.ts | 11 +- .../fixtures/common/test_scope/index.ts | 13 -- .../src/playwright/fixtures/index.ts | 26 +--- .../fixtures/parallel_workers/index.ts | 11 -- .../parallel_workers/worker_scope/index.ts | 11 -- .../fixtures/parallel_workers_fixtures.ts | 52 +++++++ .../fixtures/single_thread_fixtures.ts | 58 ++++++++ .../single_worker/worker_scope/index.ts | 11 -- .../fixtures/test/browser_auth/index.ts | 31 +++++ .../browser_auth/parallel.ts} | 28 +--- .../browser_auth/single_thread.ts} | 29 +--- .../test_scope => test}/index.ts | 9 +- .../{common => test/page_objects}/index.ts | 8 +- .../fixtures/test/page_objects/parallel.ts | 29 ++++ .../page_objects/single_thread.ts} | 7 +- .../page.ts => test/scout_page/index.ts} | 119 +--------------- .../page.ts => test/scout_page/parallel.ts} | 23 ++-- .../fixtures/test/scout_page/single_thread.ts | 127 ++++++++++++++++++ .../validate_tags/index.ts} | 0 .../src/playwright/fixtures/types/index.ts | 11 -- .../fixtures/types/parallel_workers.ts | 29 ---- .../fixtures/types/single_worker.ts | 30 ----- .../core.ts => worker/core_fixtures.ts} | 13 +- .../worker_scope => worker}/es_archiver.ts | 12 +- .../{common/worker_scope => worker}/index.ts | 15 ++- .../fixtures/worker/scout_space/index.ts | 40 ++++++ .../scout_space/parallel.ts} | 40 +----- .../fixtures/worker/ui_settings/index.ts | 34 +++++ .../ui_settings/single_thread.ts} | 33 +---- packages/kbn-scout/src/playwright/index.ts | 17 ++- .../playwright/page_objects/dashboard_app.ts | 2 +- .../playwright/page_objects/date_picker.ts | 3 +- .../playwright/page_objects/discover_app.ts | 2 +- .../src/playwright/page_objects/fiter_bar.ts | 2 +- .../src/playwright/page_objects/index.ts | 2 +- .../ui_tests/fixtures/index.ts | 61 +++++---- .../parallel_tests/error_handling.spec.ts | 12 +- .../saved_search_embeddable.spec.ts | 110 --------------- .../parallel_tests/saved_searches.spec.ts | 24 ++-- .../parallel_tests/value_suggestions.spec.ts | 14 +- .../value_suggestions_non_time_based.spec.ts | 12 +- ...uggestions_use_time_range_disabled.spec.ts | 18 +-- .../tests/saved_search_embeddable.spec.ts | 4 +- .../ui_tests/tests/saved_searches.spec.ts | 8 +- 44 files changed, 538 insertions(+), 613 deletions(-) delete mode 100644 packages/kbn-scout/src/playwright/fixtures/common/test_scope/index.ts delete mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_workers/index.ts delete mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/index.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/parallel_workers_fixtures.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/single_thread_fixtures.ts delete mode 100644 packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/index.ts create mode 100644 packages/kbn-scout/src/playwright/fixtures/test/browser_auth/index.ts rename packages/kbn-scout/src/playwright/fixtures/{parallel_workers/test_scope/browser_auth.ts => test/browser_auth/parallel.ts} (67%) rename packages/kbn-scout/src/playwright/fixtures/{common/test_scope/browser_auth.ts => test/browser_auth/single_thread.ts} (65%) rename packages/kbn-scout/src/playwright/fixtures/{parallel_workers/test_scope => test}/index.ts (57%) rename packages/kbn-scout/src/playwright/fixtures/{common => test/page_objects}/index.ts (66%) create mode 100644 packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts rename packages/kbn-scout/src/playwright/fixtures/{common/test_scope/page_objects.ts => test/page_objects/single_thread.ts} (85%) rename packages/kbn-scout/src/playwright/fixtures/{common/test_scope/page.ts => test/scout_page/index.ts} (55%) rename packages/kbn-scout/src/playwright/fixtures/{parallel_workers/test_scope/page.ts => test/scout_page/parallel.ts} (60%) create mode 100644 packages/kbn-scout/src/playwright/fixtures/test/scout_page/single_thread.ts rename packages/kbn-scout/src/playwright/fixtures/{common/test_scope/validate_tags.ts => test/validate_tags/index.ts} (100%) delete mode 100644 packages/kbn-scout/src/playwright/fixtures/types/index.ts delete mode 100644 packages/kbn-scout/src/playwright/fixtures/types/parallel_workers.ts delete mode 100644 packages/kbn-scout/src/playwright/fixtures/types/single_worker.ts rename packages/kbn-scout/src/playwright/fixtures/{common/worker_scope/core.ts => worker/core_fixtures.ts} (90%) rename packages/kbn-scout/src/playwright/fixtures/{common/worker_scope => worker}/es_archiver.ts (83%) rename packages/kbn-scout/src/playwright/fixtures/{common/worker_scope => worker}/index.ts (68%) create mode 100644 packages/kbn-scout/src/playwright/fixtures/worker/scout_space/index.ts rename packages/kbn-scout/src/playwright/fixtures/{parallel_workers/worker_scope/kbn_space.ts => worker/scout_space/parallel.ts} (76%) create mode 100644 packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/index.ts rename packages/kbn-scout/src/playwright/fixtures/{single_worker/worker_scope/ui_settings.ts => worker/ui_settings/single_thread.ts} (56%) delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts diff --git a/packages/kbn-scout/index.ts b/packages/kbn-scout/index.ts index 25092cf399c01..4331a8069a508 100644 --- a/packages/kbn-scout/index.ts +++ b/packages/kbn-scout/index.ts @@ -17,15 +17,14 @@ export { createLazyPageObject, } from './src/playwright'; export type { - ScoutPage, ScoutPlaywrightOptions, ScoutTestOptions, + ScoutPage, PageObjects, - ScoutTestFixtures, - ScoutWorkerFixtures, - EsArchiverFixture, - ParallelRunTestFixtures, - ParallelRunWorkerFixtures, + ScoutSingleThreadTestFixtures, + ScoutSingleThreadWorkerFixtures, + ScoutParallelTestFixtures, + ScoutParallelWorkerFixtures, } from './src/playwright'; export type { Client, KbnClient, KibanaUrl, SamlSessionManager, ToolingLog } from './src/types'; diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/index.ts b/packages/kbn-scout/src/playwright/fixtures/common/test_scope/index.ts deleted file mode 100644 index 7f0cfd41ecac3..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/index.ts +++ /dev/null @@ -1,13 +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". - */ - -export { browserAuthFixture } from './browser_auth'; -export { pageObjectsFixture } from './page_objects'; -export { scoutPageFixture } from './page'; -export { validateTagsFixture } from './validate_tags'; diff --git a/packages/kbn-scout/src/playwright/fixtures/index.ts b/packages/kbn-scout/src/playwright/fixtures/index.ts index 9f10d2d814ea7..ea1ff54933e97 100644 --- a/packages/kbn-scout/src/playwright/fixtures/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/index.ts @@ -7,27 +7,5 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { mergeTests } from 'playwright/test'; -import * as common from './common'; -import * as spaceAware from './parallel_workers'; -import * as singleThread from './single_worker/worker_scope'; - -export const scoutCoreFixtures = mergeTests( - common.coreWorkerFixtures, - common.validateTagsFixture, - common.scoutPageFixture, - common.pageObjectsFixture, - common.esArchiverFixture, - common.browserAuthFixture, - singleThread.uiSettingsFixture -); -export const scoutCoreSpaceAwareFixtures = mergeTests( - common.coreWorkerFixtures, - common.validateTagsFixture, - spaceAware.scoutPageSpaceFixture, - common.pageObjectsFixture, - spaceAware.browserAuthFixture, - spaceAware.kbnSpaceFixture -); - -export * from './types'; +export * from './single_thread_fixtures'; +export * from './parallel_workers_fixtures'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/index.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/index.ts deleted file mode 100644 index 4a23d4c5ce936..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/index.ts +++ /dev/null @@ -1,11 +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". - */ - -export * from './test_scope'; -export * from './worker_scope'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/index.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/index.ts deleted file mode 100644 index 12ce499eda632..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/index.ts +++ /dev/null @@ -1,11 +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". - */ - -export { kbnSpaceFixture } from './kbn_space'; -export type { KbnSpaceFixture } from './kbn_space'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_workers_fixtures.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_workers_fixtures.ts new file mode 100644 index 0000000000000..bd867bb2833c2 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_workers_fixtures.ts @@ -0,0 +1,52 @@ +/* + * 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 { coreWorkerFixtures, scoutSpaceParallelFixture } from './worker'; +import type { + EsClient, + KbnClient, + KibanaUrl, + ScoutSpaceParallelFixture, + ScoutTestConfig, + ToolingLog, +} from './worker'; +import { + scoutPageParallelFixture, + browserAuthParallelFixture, + pageObjectsParallelFixture, + validateTagsFixture, +} from './test'; +import type { BrowserAuthFixture, ScoutPage, PageObjects } from './test'; + +export const scoutParallelWorkersFixtures = mergeTests( + // worker scope fixtures + coreWorkerFixtures, + scoutSpaceParallelFixture, + // test scope fixtures + browserAuthParallelFixture, + scoutPageParallelFixture, + pageObjectsParallelFixture, + validateTagsFixture +); + +export interface ScoutParallelTestFixtures { + browserAuth: BrowserAuthFixture; + page: ScoutPage; + pageObjects: PageObjects; +} + +export interface ScoutParallelWorkerFixtures { + log: ToolingLog; + config: ScoutTestConfig; + kbnUrl: KibanaUrl; + kbnClient: KbnClient; + esClient: EsClient; + scoutSpace: ScoutSpaceParallelFixture; +} diff --git a/packages/kbn-scout/src/playwright/fixtures/single_thread_fixtures.ts b/packages/kbn-scout/src/playwright/fixtures/single_thread_fixtures.ts new file mode 100644 index 0000000000000..29d9a6ceea108 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/single_thread_fixtures.ts @@ -0,0 +1,58 @@ +/* + * 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 { coreWorkerFixtures, esArchiverFixture, uiSettingsFixture } from './worker'; +import type { + EsArchiverFixture, + EsClient, + KbnClient, + KibanaUrl, + ScoutTestConfig, + ToolingLog, + UiSettingsFixture, +} from './worker'; +import { + scoutPageFixture, + browserAuthFixture, + pageObjectsFixture, + validateTagsFixture, + BrowserAuthFixture, + ScoutPage, + PageObjects, +} from './test'; +export type { PageObjects, ScoutPage } from './test'; + +export const scoutSingleThreadFixtures = mergeTests( + // worker scope fixtures + coreWorkerFixtures, + esArchiverFixture, + uiSettingsFixture, + // test scope fixtures + browserAuthFixture, + scoutPageFixture, + pageObjectsFixture, + validateTagsFixture +); + +export interface ScoutSingleThreadTestFixtures { + browserAuth: BrowserAuthFixture; + page: ScoutPage; + pageObjects: PageObjects; +} + +export interface ScoutSingleThreadWorkerFixtures { + log: ToolingLog; + config: ScoutTestConfig; + kbnUrl: KibanaUrl; + kbnClient: KbnClient; + esClient: EsClient; + esArchiver: EsArchiverFixture; + uiSettings: UiSettingsFixture; +} diff --git a/packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/index.ts b/packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/index.ts deleted file mode 100644 index edb5e8156b538..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/index.ts +++ /dev/null @@ -1,11 +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". - */ - -export { uiSettingsFixture } from './ui_settings'; -export type { UiSettingsFixture } from './ui_settings'; diff --git a/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/index.ts b/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/index.ts new file mode 100644 index 0000000000000..438c6dd8d6dc1 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/index.ts @@ -0,0 +1,31 @@ +/* + * 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 type LoginFunction = (role: string) => Promise; + +export interface BrowserAuthFixture { + /** + * Logs in as a user with viewer-only permissions. + * @returns A Promise that resolves once the cookie in browser is set. + */ + loginAsViewer: () => Promise; + /** + * Logs in as a user with administrative privileges + * @returns A Promise that resolves once the cookie in browser is set. + */ + loginAsAdmin: () => Promise; + /** + * Logs in as a user with elevated, but not admin, permissions. + * @returns A Promise that resolves once the cookie in browser is set. + */ + loginAsPrivilegedUser: () => Promise; +} + +export { browserAuthParallelFixture } from './parallel'; +export { browserAuthFixture } from './single_thread'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/browser_auth.ts b/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts similarity index 67% rename from packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/browser_auth.ts rename to packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts index 4b5f87d4d2010..f3226df233eae 100644 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/browser_auth.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts @@ -7,39 +7,19 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { test as base } from '@playwright/test'; +import { BrowserAuthFixture, LoginFunction } from '.'; import { PROJECT_DEFAULT_ROLES } from '../../../../common'; -import { SamlSessionManager, ScoutTestConfig, ToolingLog } from '../../../../types'; import { serviceLoadedMsg } from '../../../utils'; - -type LoginFunction = (role: string) => Promise; - -export interface BrowserAuthFixture { - /** - * Logs in as a user with viewer-only permissions. - * @returns A Promise that resolves once the cookie in browser is set. - */ - loginAsViewer: () => Promise; - /** - * Logs in as a user with administrative privileges - * @returns A Promise that resolves once the cookie in browser is set. - */ - loginAsAdmin: () => Promise; - /** - * Logs in as a user with elevated, but not admin, permissions. - * @returns A Promise that resolves once the cookie in browser is set. - */ - loginAsPrivilegedUser: () => Promise; -} +import { coreWorkerFixtures } from '../../worker'; /** * The "browserAuth" fixture simplifies the process of logging into Kibana with * different roles during tests. It uses the "samlAuth" fixture to create an authentication session * for the specified role and the "context" fixture to update the cookie with the role-scoped session. */ -export const browserAuthFixture = base.extend< +export const browserAuthParallelFixture = coreWorkerFixtures.extend< { browserAuth: BrowserAuthFixture }, - { log: ToolingLog; samlAuth: SamlSessionManager; config: ScoutTestConfig } + {} >({ browserAuth: async ({ log, context, samlAuth, config }, use) => { const setSessionCookie = async (cookieValue: string) => { diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts b/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/single_thread.ts similarity index 65% rename from packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts rename to packages/kbn-scout/src/playwright/fixtures/test/browser_auth/single_thread.ts index 6efdf183a5787..514f7c4f9a48d 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/browser_auth.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/single_thread.ts @@ -7,40 +7,17 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { test as base } from '@playwright/test'; import { PROJECT_DEFAULT_ROLES } from '../../../../common'; import { serviceLoadedMsg } from '../../../utils'; -import { SamlSessionManager, ScoutTestConfig, ToolingLog } from '../worker_scope'; - -type LoginFunction = (role: string) => Promise; - -export interface BrowserAuthFixture { - /** - * Logs in as a user with viewer-only permissions. - * @returns A Promise that resolves once the cookie in browser is set. - */ - loginAsViewer: () => Promise; - /** - * Logs in as a user with administrative privileges - * @returns A Promise that resolves once the cookie in browser is set. - */ - loginAsAdmin: () => Promise; - /** - * Logs in as a user with elevated, but not admin, permissions. - * @returns A Promise that resolves once the cookie in browser is set. - */ - loginAsPrivilegedUser: () => Promise; -} +import { coreWorkerFixtures } from '../../worker'; +import { BrowserAuthFixture, LoginFunction } from '.'; /** * The "browserAuth" fixture simplifies the process of logging into Kibana with * different roles during tests. It uses the "samlAuth" fixture to create an authentication session * for the specified role and the "context" fixture to update the cookie with the role-scoped session. */ -export const browserAuthFixture = base.extend< - { browserAuth: BrowserAuthFixture }, - { log: ToolingLog; samlAuth: SamlSessionManager; config: ScoutTestConfig } ->({ +export const browserAuthFixture = coreWorkerFixtures.extend<{ browserAuth: BrowserAuthFixture }>({ browserAuth: async ({ log, context, samlAuth, config }, use) => { const setSessionCookie = async (cookieValue: string) => { await context.clearCookies(); diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/index.ts b/packages/kbn-scout/src/playwright/fixtures/test/index.ts similarity index 57% rename from packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/index.ts rename to packages/kbn-scout/src/playwright/fixtures/test/index.ts index d58d3ae816353..e9daddfd9d383 100644 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/index.ts @@ -7,7 +7,10 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export { browserAuthFixture } from './browser_auth'; +export { browserAuthFixture, browserAuthParallelFixture } from './browser_auth'; export type { BrowserAuthFixture } from './browser_auth'; -export { scoutPageSpaceFixture } from './page'; -export type { ScoutPageSpaceFixture } from './page'; +export { scoutPageFixture, scoutPageParallelFixture } from './scout_page'; +export type { ScoutPage } from './scout_page'; +export { validateTagsFixture } from './validate_tags'; +export { pageObjectsFixture, pageObjectsParallelFixture } from './page_objects'; +export type { PageObjects } from './page_objects'; diff --git a/packages/kbn-scout/src/playwright/fixtures/common/index.ts b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/index.ts similarity index 66% rename from packages/kbn-scout/src/playwright/fixtures/common/index.ts rename to packages/kbn-scout/src/playwright/fixtures/test/page_objects/index.ts index 4a23d4c5ce936..94aa65a2fb3bb 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/index.ts @@ -7,5 +7,9 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export * from './test_scope'; -export * from './worker_scope'; +export type LoginFunction = (role: string) => Promise; + +export type { PageObjects } from '../../../page_objects'; + +export { pageObjectsParallelFixture } from './parallel'; +export { pageObjectsFixture } from './single_thread'; diff --git a/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts new file mode 100644 index 0000000000000..d97678835bf5f --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts @@ -0,0 +1,29 @@ +/* + * 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 { PageObjects, createCorePageObjects } from '../../../page_objects'; +import { scoutPageParallelFixture } from '../scout_page'; + +/** + * The "pageObjects" fixture provides a centralized and consistent way to access and + * interact with reusable Page Objects in tests. This fixture automatically + * initializes core Page Objects and makes them available to tests, promoting + * modularity and reducing redundant setup. + * + * Note: Page Objects are lazily instantiated on first access. + */ +export const pageObjectsParallelFixture = scoutPageParallelFixture.extend<{ + pageObjects: PageObjects; +}>({ + pageObjects: async ({ page: ScoutPage }, use) => { + const corePageObjects = createCorePageObjects(page); + + await use(corePageObjects); + }, +}); diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page_objects.ts b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/single_thread.ts similarity index 85% rename from packages/kbn-scout/src/playwright/fixtures/common/test_scope/page_objects.ts rename to packages/kbn-scout/src/playwright/fixtures/test/page_objects/single_thread.ts index 0288471faa5bc..1158929f60267 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page_objects.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/single_thread.ts @@ -7,9 +7,8 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { test as base } from '@playwright/test'; import { PageObjects, createCorePageObjects } from '../../../page_objects'; -import { ScoutPage } from './page'; +import { scoutPageFixture } from '../scout_page'; /** * The "pageObjects" fixture provides a centralized and consistent way to access and @@ -19,7 +18,9 @@ import { ScoutPage } from './page'; * * Note: Page Objects are lazily instantiated on first access. */ -export const pageObjectsFixture = base.extend<{ page: ScoutPage; pageObjects: PageObjects }>({ +export const pageObjectsFixture = scoutPageFixture.extend<{ + pageObjects: PageObjects; +}>({ pageObjects: async ({ page }, use) => { const corePageObjects = createCorePageObjects(page); diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/index.ts similarity index 55% rename from packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts rename to packages/kbn-scout/src/playwright/fixtures/test/scout_page/index.ts index e3a41e330ced8..b0486f961cc2a 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/page.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/index.ts @@ -7,9 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { Page, test as base } from '@playwright/test'; -import { subj } from '@kbn/test-subj-selector'; -import { KibanaUrl } from '../worker_scope'; +import { Page } from '@playwright/test'; /** * Extends the Playwright 'Page' interface with methods specific to Kibana. @@ -102,116 +100,5 @@ export type ScoutPage = Page & { }; }; -/** - * Instead of defining each method individually, we use a list of method names and loop through them, creating methods dynamically. - * All methods must have 'selector: string' as the first argument - */ -function extendPageWithTestSubject(page: Page): ScoutPage['testSubj'] { - const methods: Array = [ - 'check', - 'click', - 'dblclick', - 'fill', - 'focus', - 'getAttribute', - 'hover', - 'isEnabled', - 'innerText', - 'isChecked', - 'isHidden', - 'isVisible', - 'locator', - 'waitForSelector', - ]; - - const extendedMethods: Partial> & { - typeWithDelay?: ScoutPage['testSubj']['typeWithDelay']; - clearInput?: ScoutPage['testSubj']['clearInput']; - } = {}; - - for (const method of methods) { - extendedMethods[method] = (...args: any[]) => { - const selector = args[0]; - const testSubjSelector = subj(selector); - return (page[method] as Function)(testSubjSelector, ...args.slice(1)); - }; - } - - // custom method to types text into an input field character by character with a delay - extendedMethods.typeWithDelay = async ( - selector: string, - text: string, - options?: { delay: number } - ) => { - const { delay = 25 } = options || {}; - const testSubjSelector = subj(selector); - await page.locator(testSubjSelector).click(); - for (const char of text) { - await page.keyboard.insertText(char); - await page.waitForTimeout(delay); - } - }; - // custom method to clear an input field - extendedMethods.clearInput = async (selector: string) => { - const testSubjSelector = subj(selector); - await page.locator(testSubjSelector).fill(''); - }; - - return extendedMethods as ScoutPage['testSubj']; -} - -export function extendPlaywrightPage({ - page, - kbnUrl, -}: { - page: Page; - kbnUrl: KibanaUrl; -}): ScoutPage { - const extendedPage = page as ScoutPage; - // 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)); - // Method to wait for global loading indicator to be hidden - extendedPage.waitForLoadingIndicatorHidden = () => - extendedPage.testSubj.waitForSelector('globalLoadingIndicator-hidden', { - state: 'attached', - }); - return extendedPage; -} - -/** - * Extends the 'page' fixture with Kibana-specific functionality - * - * 1. Allow calling methods with simplified 'data-test-subj' selectors. - * Instead of manually constructing 'data-test-subj' selectors, this extension provides a `testSubj` object on the page - * Supported methods include `click`, `check`, `fill`, and others that interact with `data-test-subj`. - * - * Example Usage: - * - * ```typescript - * // Without `testSubj` extension: - * await page.locator('[data-test-subj="foo"][data-test-subj="bar"]').click(); - * - * // With `testSubj` extension: - * await page.testSubj.click('foo & bar'); - * ``` - * - * 2. Navigate to Kibana apps by using 'kbnUrl' fixture - * - * Example Usage: - * - * ```typescript - * // Navigate to '/app/discover' - * await page.gotoApp('discover); - * ``` - */ -export const scoutPageFixture = base.extend<{}, { kbnUrl: KibanaUrl }>({ - page: async ( - { page, kbnUrl }: { page: Page; kbnUrl: KibanaUrl }, - use: (extendedPage: ScoutPage) => Promise - ) => { - const extendedPage = extendPlaywrightPage({ page, kbnUrl }); - await use(extendedPage); - }, -}); +export { scoutPageFixture } from './single_thread'; +export { scoutPageParallelFixture } from './parallel'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/page.ts b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/parallel.ts similarity index 60% rename from packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/page.ts rename to packages/kbn-scout/src/playwright/fixtures/test/scout_page/parallel.ts index 772c57cd152cd..9787d80b21f26 100644 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/test_scope/page.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/parallel.ts @@ -8,25 +8,28 @@ */ import { Page, test as base } from '@playwright/test'; -import { ScoutPage, extendPlaywrightPage } from '../../common/test_scope/page'; -import { KibanaUrl } from '../../common'; -import { KbnSpaceFixture } from '../worker_scope'; +import { ScoutPage } from '.'; +import { KibanaUrl } from '../../worker'; +import { ScoutSpaceParallelFixture } from '../../worker/scout_space'; +import { extendPlaywrightPage } from './single_thread'; -export type ScoutPageSpaceFixture = ScoutPage; - -export const scoutPageSpaceFixture = base.extend< +export const scoutPageParallelFixture = base.extend< {}, - { kbnUrl: KibanaUrl; kbnSpace: KbnSpaceFixture } + { kbnUrl: KibanaUrl; scoutSpace: ScoutSpaceParallelFixture } >({ page: async ( - { page, kbnUrl, kbnSpace }: { page: Page; kbnUrl: KibanaUrl; kbnSpace: KbnSpaceFixture }, - use: (spaceAwarePage: ScoutPage) => Promise + { + page, + kbnUrl, + scoutSpace, + }: { page: Page; kbnUrl: KibanaUrl; scoutSpace: ScoutSpaceParallelFixture }, + use: (extendedPage: ScoutPage) => Promise ) => { const extendedPage = extendPlaywrightPage({ page, kbnUrl }); // Overriding navigation to specific Kibana apps to take into account the worker space extendedPage.gotoApp = (appName: string) => - page.goto(kbnUrl.app(appName, { space: kbnSpace.id })); + page.goto(kbnUrl.app(appName, { space: scoutSpace.id })); // Method to wait for global loading indicator to be hidden 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 new file mode 100644 index 0000000000000..8609a80425549 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/test/scout_page/single_thread.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", 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 { Page } from '@playwright/test'; +import { subj } from '@kbn/test-subj-selector'; +import { KibanaUrl, coreWorkerFixtures } from '../../worker'; +import { ScoutPage } from '.'; + +/** + * Instead of defining each method individually, we use a list of method names and loop through them, creating methods dynamically. + * All methods must have 'selector: string' as the first argument + */ +function extendPageWithTestSubject(page: Page): ScoutPage['testSubj'] { + const methods: Array = [ + 'check', + 'click', + 'dblclick', + 'fill', + 'focus', + 'getAttribute', + 'hover', + 'isEnabled', + 'innerText', + 'isChecked', + 'isHidden', + 'isVisible', + 'locator', + 'waitForSelector', + ]; + + const extendedMethods: Partial> & { + typeWithDelay?: ScoutPage['testSubj']['typeWithDelay']; + clearInput?: ScoutPage['testSubj']['clearInput']; + } = {}; + + for (const method of methods) { + extendedMethods[method] = (...args: any[]) => { + const selector = args[0]; + const testSubjSelector = subj(selector); + return (page[method] as Function)(testSubjSelector, ...args.slice(1)); + }; + } + + // custom method to types text into an input field character by character with a delay + extendedMethods.typeWithDelay = async ( + selector: string, + text: string, + options?: { delay: number } + ) => { + const { delay = 25 } = options || {}; + const testSubjSelector = subj(selector); + await page.locator(testSubjSelector).click(); + for (const char of text) { + await page.keyboard.insertText(char); + await page.waitForTimeout(delay); + } + }; + // custom method to clear an input field + extendedMethods.clearInput = async (selector: string) => { + const testSubjSelector = subj(selector); + await page.locator(testSubjSelector).fill(''); + }; + + return extendedMethods as ScoutPage['testSubj']; +} + +export function extendPlaywrightPage({ + page, + kbnUrl, +}: { + page: Page; + kbnUrl: KibanaUrl; +}): ScoutPage { + const extendedPage = page as ScoutPage; + // 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)); + // Method to wait for global loading indicator to be hidden + extendedPage.waitForLoadingIndicatorHidden = () => + extendedPage.testSubj.waitForSelector('globalLoadingIndicator-hidden', { + state: 'attached', + }); + return extendedPage; +} + +/** + * Extends the 'page' fixture with Kibana-specific functionality + * + * 1. Allow calling methods with simplified 'data-test-subj' selectors. + * Instead of manually constructing 'data-test-subj' selectors, this extension provides a `testSubj` object on the page + * Supported methods include `click`, `check`, `fill`, and others that interact with `data-test-subj`. + * + * Example Usage: + * + * ```typescript + * // Without `testSubj` extension: + * await page.locator('[data-test-subj="foo"][data-test-subj="bar"]').click(); + * + * // With `testSubj` extension: + * await page.testSubj.click('foo & bar'); + * ``` + * + * 2. Navigate to Kibana apps by using 'kbnUrl' fixture + * + * Example Usage: + * + * ```typescript + * // Navigate to '/app/discover' + * await page.gotoApp('discover); + * ``` + */ +export const scoutPageFixture = coreWorkerFixtures.extend<{}, { kbnUrl: KibanaUrl }>({ + page: async ( + { page, kbnUrl }: { page: Page; kbnUrl: KibanaUrl }, + use: (extendedPage: ScoutPage) => Promise + ) => { + const extendedPage = extendPlaywrightPage({ page, kbnUrl }); + await use(extendedPage); + }, +}); diff --git a/packages/kbn-scout/src/playwright/fixtures/common/test_scope/validate_tags.ts b/packages/kbn-scout/src/playwright/fixtures/test/validate_tags/index.ts similarity index 100% rename from packages/kbn-scout/src/playwright/fixtures/common/test_scope/validate_tags.ts rename to packages/kbn-scout/src/playwright/fixtures/test/validate_tags/index.ts diff --git a/packages/kbn-scout/src/playwright/fixtures/types/index.ts b/packages/kbn-scout/src/playwright/fixtures/types/index.ts deleted file mode 100644 index 5421a9946ea5b..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/types/index.ts +++ /dev/null @@ -1,11 +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". - */ - -export * from './parallel_workers'; -export * from './single_worker'; diff --git a/packages/kbn-scout/src/playwright/fixtures/types/parallel_workers.ts b/packages/kbn-scout/src/playwright/fixtures/types/parallel_workers.ts deleted file mode 100644 index ad500c29365ba..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/types/parallel_workers.ts +++ /dev/null @@ -1,29 +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 { ToolingLog } from '@kbn/tooling-log'; -import { PageObjects } from '../../page_objects'; -import { BrowserAuthFixture, ScoutPageSpaceFixture } from '../parallel_workers/test_scope'; -import { EsClient, KbnClient, KibanaUrl, ScoutTestConfig } from '../common'; -import { KbnSpaceFixture } from '../parallel_workers'; - -export interface ParallelRunTestFixtures { - browserAuth: BrowserAuthFixture; - page: ScoutPageSpaceFixture; - pageObjects: PageObjects; -} - -export interface ParallelRunWorkerFixtures { - log: ToolingLog; - config: ScoutTestConfig; - esClient: EsClient; - kbnClient: KbnClient; - kbnSpace: KbnSpaceFixture; - kbnUrl: KibanaUrl; -} diff --git a/packages/kbn-scout/src/playwright/fixtures/types/single_worker.ts b/packages/kbn-scout/src/playwright/fixtures/types/single_worker.ts deleted file mode 100644 index 8e63727d4f828..0000000000000 --- a/packages/kbn-scout/src/playwright/fixtures/types/single_worker.ts +++ /dev/null @@ -1,30 +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 { ToolingLog } from '@kbn/tooling-log'; -import { PageObjects } from '../../page_objects'; -import { EsClient, KbnClient, KibanaUrl, ScoutTestConfig } from '../common'; -import { ScoutPage } from '../common/test_scope/page'; -import { BrowserAuthFixture } from '../common/test_scope/browser_auth'; -import { UiSettingsFixture } from '../single_worker/worker_scope/ui_settings'; - -export interface ScoutTestFixtures { - browserAuth: BrowserAuthFixture; - page: ScoutPage; - pageObjects: PageObjects; -} - -export interface ScoutWorkerFixtures { - log: ToolingLog; - config: ScoutTestConfig; - kbnUrl: KibanaUrl; - kbnClient: KbnClient; - esClient: EsClient; - uiSettings: UiSettingsFixture; -} diff --git a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/core.ts b/packages/kbn-scout/src/playwright/fixtures/worker/core_fixtures.ts similarity index 90% rename from packages/kbn-scout/src/playwright/fixtures/common/worker_scope/core.ts rename to packages/kbn-scout/src/playwright/fixtures/worker/core_fixtures.ts index 2f436c6027e81..6d9b4fa695a41 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/core.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/core_fixtures.ts @@ -10,6 +10,9 @@ import { test as base } from '@playwright/test'; import type { ToolingLog } from '@kbn/tooling-log'; + +import { KbnClient, SamlSessionManager } from '@kbn/test'; +import { Client } from '@elastic/elasticsearch'; import { createKbnUrl, createEsClient, @@ -18,16 +21,16 @@ import { createSamlSessionManager, createScoutConfig, KibanaUrl, -} from '../../../../common/services'; -import { ScoutTestOptions } from '../../../types'; -import { Client, KbnClient, SamlSessionManager, ScoutTestConfig } from '../../../../types'; +} from '../../../common/services'; +import { ScoutTestOptions } from '../../types'; +import { ScoutTestConfig } from '.'; // re-export to import types from '@kbn-scout' export type { KbnClient, SamlSessionManager } from '@kbn/test'; export type { ToolingLog } from '@kbn/tooling-log'; export type { Client as EsClient } from '@elastic/elasticsearch'; -export type { KibanaUrl } from '../../../../common/services/kibana_url'; -export type { ScoutTestConfig } from '../../../../types'; +export type { KibanaUrl } from '../../../common/services/kibana_url'; +export type { ScoutTestConfig } from '../../../types'; /** * The coreWorkerFixtures setup defines foundational fixtures that are essential diff --git a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/es_archiver.ts b/packages/kbn-scout/src/playwright/fixtures/worker/es_archiver.ts similarity index 83% rename from packages/kbn-scout/src/playwright/fixtures/common/worker_scope/es_archiver.ts rename to packages/kbn-scout/src/playwright/fixtures/worker/es_archiver.ts index c84a680d9841b..86b913cefe1f0 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/es_archiver.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/es_archiver.ts @@ -7,13 +7,10 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { test as base } from '@playwright/test'; -import type { Client } from '@elastic/elasticsearch'; - import { LoadActionPerfOptions } from '@kbn/es-archiver'; import { IndexStats } from '@kbn/es-archiver/src/lib/stats'; -import { createEsArchiver } from '../../../../common/services'; -import { KbnClient, ToolingLog } from './core'; +import { coreWorkerFixtures } from './core_fixtures'; +import { createEsArchiver } from '../../../common/services'; export interface EsArchiverFixture { /** @@ -29,10 +26,7 @@ export interface EsArchiverFixture { ) => Promise>; } -export const esArchiverFixture = base.extend< - {}, - { log: ToolingLog; esClient: Client; kbnClient: KbnClient; esArchiver: EsArchiverFixture } ->({ +export const esArchiverFixture = coreWorkerFixtures.extend<{}, { esArchiver: EsArchiverFixture }>({ /** * Provides utilities for managing test data in Elasticsearch. The "loadIfNeeded" method * optimizes test execution by loading data archives only if required, avoiding redundant diff --git a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/index.ts b/packages/kbn-scout/src/playwright/fixtures/worker/index.ts similarity index 68% rename from packages/kbn-scout/src/playwright/fixtures/common/worker_scope/index.ts rename to packages/kbn-scout/src/playwright/fixtures/worker/index.ts index 8aafabf32e1c1..f0957a22207bd 100644 --- a/packages/kbn-scout/src/playwright/fixtures/common/worker_scope/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/index.ts @@ -7,9 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export { coreWorkerFixtures } from './core'; -export { esArchiverFixture } from './es_archiver'; -export type { EsArchiverFixture } from './es_archiver'; +export { coreWorkerFixtures } from './core_fixtures'; export type { ToolingLog, ScoutTestConfig, @@ -17,4 +15,13 @@ export type { EsClient, KbnClient, SamlSessionManager, -} from './core'; +} from './core_fixtures'; + +export { esArchiverFixture } from './es_archiver'; +export type { EsArchiverFixture } from './es_archiver'; + +export { uiSettingsFixture } from './ui_settings'; +export type { UiSettingsFixture } from './ui_settings'; + +export { scoutSpaceParallelFixture } from './scout_space'; +export type { ScoutSpaceParallelFixture } from './scout_space'; diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/index.ts b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/index.ts new file mode 100644 index 0000000000000..70b91cb339918 --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/index.ts @@ -0,0 +1,40 @@ +/* + * 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 { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; + +export interface ImportSavedObjects { + type: string; + destinationId: string; + meta: { title: string }; +} +export interface ImportExportResponse { + successResults: ImportSavedObjects[]; +} +export interface SavedObjectResponse { + id: string; + type: string; + title: string; +} + +export interface ScoutSpaceParallelFixture { + id: string; + savedObjects: { + load: (path: string) => Promise; + cleanStandardList: () => Promise; + }; + uiSettings: { + setDefaultIndex: (dataViewId: string) => Promise; + set: (values: UiSettingValues) => Promise; + unset: (...keys: string[]) => Promise; + setDefaultTime: ({ from, to }: { from: string; to: string }) => Promise; + }; +} + +export { scoutSpaceParallelFixture } from './parallel'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/kbn_space.ts b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts similarity index 76% rename from packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/kbn_space.ts rename to packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts index 6fc5fe9a4139b..315fa675e2ceb 100644 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_workers/worker_scope/kbn_space.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts @@ -7,45 +7,17 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { test as base } from '@playwright/test'; import { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; import { formatTime, isValidUTCDate } from '../../../utils'; -import { KbnClient, ToolingLog } from '../../common'; +import { coreWorkerFixtures } from '..'; +import { ImportSavedObjects, ScoutSpaceParallelFixture } from '.'; -export interface ImportSavedObjects { - type: string; - destinationId: string; - meta: { title: string }; -} -export interface ImportExportResponse { - successResults: ImportSavedObjects[]; -} -export interface SavedObjectResponse { - id: string; - type: string; - title: string; -} - -export interface KbnSpaceFixture { - id: string; - savedObjects: { - load: (path: string) => Promise; - cleanStandardList: () => Promise; - }; - uiSettings: { - setDefaultIndex: (dataViewId: string) => Promise; - set: (values: UiSettingValues) => Promise; - unset: (...keys: string[]) => Promise; - setDefaultTime: ({ from, to }: { from: string; to: string }) => Promise; - }; -} - -export const kbnSpaceFixture = base.extend< +export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< {}, - { log: ToolingLog; kbnClient: KbnClient; kbnSpace: KbnSpaceFixture } + { scoutSpace: ScoutSpaceParallelFixture } >({ - kbnSpace: [ - async ({ log, kbnClient }: { log: ToolingLog; kbnClient: KbnClient }, use, workerInfo) => { + scoutSpace: [ + async ({ log, kbnClient }, use, workerInfo) => { const id = `test-space-${workerInfo.workerIndex}`; const spacePayload = { id, diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/index.ts b/packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/index.ts new file mode 100644 index 0000000000000..5fd4f8fd64dae --- /dev/null +++ b/packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/index.ts @@ -0,0 +1,34 @@ +/* + * 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 { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; + +export interface UiSettingsFixture { + /** + * Applies one or more UI settings + * @param values (UiSettingValues): An object containing key-value pairs of UI settings to apply. + * @returns A Promise that resolves once the settings are applied. + */ + set: (values: UiSettingValues) => Promise; + /** + * Resets specific UI settings to their default values. + * @param values A list of UI setting keys to unset. + * @returns A Promise that resolves after the settings are unset. + */ + unset: (...values: string[]) => Promise; + /** + * Sets the default time range for Kibana. + * @from The start time of the default time range. + * @to The end time of the default time range. + * @returns A Promise that resolves once the default time is set. + */ + setDefaultTime: ({ from, to }: { from: string; to: string }) => Promise; +} + +export { uiSettingsFixture } from './single_thread'; diff --git a/packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/ui_settings.ts b/packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/single_thread.ts similarity index 56% rename from packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/ui_settings.ts rename to packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/single_thread.ts index ebcababe9d5e8..99f1a3b0652d0 100644 --- a/packages/kbn-scout/src/playwright/fixtures/single_worker/worker_scope/ui_settings.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/single_thread.ts @@ -7,42 +7,17 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { test as base } from '@playwright/test'; import { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; import { isValidUTCDate, formatTime } from '../../../utils'; -import { KbnClient, ToolingLog } from '../../common'; - -export interface UiSettingsFixture { - /** - * Applies one or more UI settings - * @param values (UiSettingValues): An object containing key-value pairs of UI settings to apply. - * @returns A Promise that resolves once the settings are applied. - */ - set: (values: UiSettingValues) => Promise; - /** - * Resets specific UI settings to their default values. - * @param values A list of UI setting keys to unset. - * @returns A Promise that resolves after the settings are unset. - */ - unset: (...values: string[]) => Promise; - /** - * Sets the default time range for Kibana. - * @from The start time of the default time range. - * @to The end time of the default time range. - * @returns A Promise that resolves once the default time is set. - */ - setDefaultTime: ({ from, to }: { from: string; to: string }) => Promise; -} +import { coreWorkerFixtures } from '../core_fixtures'; +import { UiSettingsFixture } from '.'; /** * This fixture provides a way to interact with Kibana UI settings. */ -export const uiSettingsFixture = base.extend< - {}, - { kbnClient: KbnClient; uiSettings: UiSettingsFixture; log: ToolingLog } ->({ +export const uiSettingsFixture = coreWorkerFixtures.extend<{}, { uiSettings: UiSettingsFixture }>({ uiSettings: [ - ({ kbnClient, log }, use) => { + ({ kbnClient }, use) => { const kbnClientUiSettings = { set: async (values: UiSettingValues) => { await kbnClient.uiSettings.update(values); diff --git a/packages/kbn-scout/src/playwright/index.ts b/packages/kbn-scout/src/playwright/index.ts index 4dee6209f43ac..b22950988cde0 100644 --- a/packages/kbn-scout/src/playwright/index.ts +++ b/packages/kbn-scout/src/playwright/index.ts @@ -7,27 +7,26 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { scoutCoreFixtures, scoutCoreSpaceAwareFixtures } from './fixtures'; +import { scoutSingleThreadFixtures, scoutParallelWorkersFixtures } from './fixtures'; // Scout core fixtures: worker & test scope -export const test = scoutCoreFixtures; +export const test = scoutSingleThreadFixtures; // Scout core 'space aware' fixtures: worker & test scope -export const spaceTest = scoutCoreSpaceAwareFixtures; +export const spaceTest = scoutParallelWorkersFixtures; export { createPlaywrightConfig } from './config'; export { createLazyPageObject } from './page_objects/utils'; export { expect } from './expect'; export type { ScoutPlaywrightOptions, ScoutTestOptions } from './types'; -export type { PageObjects } from './page_objects'; export type { - ScoutTestFixtures, - ScoutWorkerFixtures, - ParallelRunTestFixtures, - ParallelRunWorkerFixtures, + ScoutSingleThreadTestFixtures, + ScoutSingleThreadWorkerFixtures, + ScoutParallelTestFixtures, + ScoutParallelWorkerFixtures, ScoutPage, - EsArchiverFixture, + PageObjects, } from './fixtures'; // use to tag tests diff --git a/packages/kbn-scout/src/playwright/page_objects/dashboard_app.ts b/packages/kbn-scout/src/playwright/page_objects/dashboard_app.ts index 367167c0304f2..bcc587ecee9a1 100644 --- a/packages/kbn-scout/src/playwright/page_objects/dashboard_app.ts +++ b/packages/kbn-scout/src/playwright/page_objects/dashboard_app.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { ScoutPage } from '../fixtures/types'; +import { ScoutPage } from '..'; type CommonlyUsedTimeRange = | 'Today' diff --git a/packages/kbn-scout/src/playwright/page_objects/date_picker.ts b/packages/kbn-scout/src/playwright/page_objects/date_picker.ts index d5d26063fb0b0..af701ea315110 100644 --- a/packages/kbn-scout/src/playwright/page_objects/date_picker.ts +++ b/packages/kbn-scout/src/playwright/page_objects/date_picker.ts @@ -7,8 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { ScoutPage } from '../fixtures/types'; -import { expect } from '..'; +import { ScoutPage, expect } from '..'; export class DatePicker { constructor(private readonly page: ScoutPage) {} diff --git a/packages/kbn-scout/src/playwright/page_objects/discover_app.ts b/packages/kbn-scout/src/playwright/page_objects/discover_app.ts index bb82984359c79..7c1dcd449497a 100644 --- a/packages/kbn-scout/src/playwright/page_objects/discover_app.ts +++ b/packages/kbn-scout/src/playwright/page_objects/discover_app.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { ScoutPage } from '../fixtures/types'; +import { ScoutPage } from '..'; export class DiscoverApp { constructor(private readonly page: ScoutPage) {} diff --git a/packages/kbn-scout/src/playwright/page_objects/fiter_bar.ts b/packages/kbn-scout/src/playwright/page_objects/fiter_bar.ts index 6026e16b9edb3..10f7ddc155aa5 100644 --- a/packages/kbn-scout/src/playwright/page_objects/fiter_bar.ts +++ b/packages/kbn-scout/src/playwright/page_objects/fiter_bar.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { ScoutPage } from '../fixtures/types'; +import { ScoutPage } from '..'; import { expect } from '..'; interface FilterCreationOptions { diff --git a/packages/kbn-scout/src/playwright/page_objects/index.ts b/packages/kbn-scout/src/playwright/page_objects/index.ts index 19bc81da669a4..5e1fbae47e831 100644 --- a/packages/kbn-scout/src/playwright/page_objects/index.ts +++ b/packages/kbn-scout/src/playwright/page_objects/index.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { ScoutPage } from '../fixtures/types'; +import { ScoutPage } from '..'; import { DashboardApp } from './dashboard_app'; import { DatePicker } from './date_picker'; import { DiscoverApp } from './discover_app'; diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts index 38021a59dde34..283df8c393313 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts @@ -10,29 +10,29 @@ import { spaceTest as spaceBaseTest, PageObjects, createLazyPageObject, - ScoutTestFixtures, - ScoutWorkerFixtures, - ParallelRunTestFixtures, - ParallelRunWorkerFixtures, + ScoutSingleThreadTestFixtures, + ScoutSingleThreadWorkerFixtures, + ScoutParallelTestFixtures, + ScoutParallelWorkerFixtures, } from '@kbn/scout'; import { DemoPage } from './page_objects'; -export interface ExtendedScoutTestFixtures extends ScoutTestFixtures { +export interface SingleThreadTestFixtures extends ScoutSingleThreadTestFixtures { pageObjects: PageObjects & { demo: DemoPage; }; } -export const test = baseTest.extend({ +export const test = baseTest.extend({ pageObjects: async ( { pageObjects, page, }: { - pageObjects: ExtendedScoutTestFixtures['pageObjects']; - page: ExtendedScoutTestFixtures['page']; + pageObjects: SingleThreadTestFixtures['pageObjects']; + page: SingleThreadTestFixtures['page']; }, - use: (pageObjects: ExtendedScoutTestFixtures['pageObjects']) => Promise + use: (pageObjects: SingleThreadTestFixtures['pageObjects']) => Promise ) => { const extendedPageObjects = { ...pageObjects, @@ -43,34 +43,33 @@ export const test = baseTest.extend({ - pageObjects: async ( - { - pageObjects, - page, - }: { - pageObjects: ExtendedParallelRunScoutTestFixtures['pageObjects']; - page: ExtendedParallelRunScoutTestFixtures['page']; - }, - use: (pageObjects: ExtendedScoutTestFixtures['pageObjects']) => Promise - ) => { - const extendedPageObjects = { - ...pageObjects, - demo: createLazyPageObject(DemoPage, page), - }; +export const spaceTest = spaceBaseTest.extend( + { + pageObjects: async ( + { + pageObjects, + page, + }: { + pageObjects: ParallelRunTestFixtures['pageObjects']; + page: ParallelRunTestFixtures['page']; + }, + use: (pageObjects: ParallelRunTestFixtures['pageObjects']) => Promise + ) => { + const extendedPageObjects = { + ...pageObjects, + demo: createLazyPageObject(DemoPage, page), + }; - await use(extendedPageObjects); - }, -}); + await use(extendedPageObjects); + }, + } +); export * as testData from './constants'; export * as assertionMessages from './assertion_messages'; diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts index 98d3eb78c1f9d..97c4e18f7f2dc 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling.spec.ts @@ -9,17 +9,17 @@ import { expect, tags } from '@kbn/scout'; import { spaceTest, testData } from '../fixtures'; spaceTest.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { - spaceTest.beforeAll(async ({ kbnSpace }) => { - await kbnSpace.savedObjects.cleanStandardList(); - await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); - await kbnSpace.uiSettings.setDefaultTime({ + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.cleanStandardList(); + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); + await scoutSpace.uiSettings.setDefaultTime({ from: testData.LOGSTASH_DEFAULT_START_TIME, to: testData.LOGSTASH_DEFAULT_END_TIME, }); }); - spaceTest.afterAll(async ({ kbnSpace }) => { - await kbnSpace.savedObjects.cleanStandardList(); + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts deleted file mode 100644 index 21645728b96ac..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_search_embeddable.spec.ts +++ /dev/null @@ -1,110 +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 { ScoutWorkerFixtures, expect, tags } from '@kbn/scout'; -import { spaceTest, testData } from '../fixtures'; - -const createSavedSearch = async ( - kbnClient: ScoutWorkerFixtures['kbnClient'], - searchId: string, - searchTitle: string, - dataViewId: string, - spaceId: string -) => - await kbnClient.savedObjects.create({ - type: 'search', - id: searchId, - overwrite: true, - attributes: { - space: spaceId, - title: searchTitle, - description: '', - columns: ['agent', 'bytes', 'clientip'], - sort: [['@timestamp', 'desc']], - kibanaSavedObjectMeta: { - searchSourceJSON: - '{"highlightAll":true,"version":true,"query":{"language":"lucene","query":""},"filter":[],"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.index"}', - }, - }, - references: [ - { - id: dataViewId, - name: 'kibanaSavedObjectMeta.searchSourceJSON.index', - type: 'index-pattern', - }, - ], - }); - -spaceTest.describe.skip( - 'Discover app - saved search embeddable', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - const SAVED_SEARCH_TITLE = 'TempSearch'; - const SAVED_SEARCH_ID = '90943e30-9a47-11e8-b64d-95841ca0b247'; - let dataViewId: string; - spaceTest.beforeAll(async ({ kbnClient, kbnSpace }) => { - const results = await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - dataViewId = results.find((i) => i.title === 'logstash-*')!.id; - - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS, { - space: kbnSpace.id, - }); - await kbnSpace.uiSettings.set({ - defaultIndex: dataViewId, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - }); - }); - - spaceTest.afterAll(async ({ kbnSpace }) => { - await kbnSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsPrivilegedUser(); - await pageObjects.dashboard.goto(); - }); - - spaceTest( - 'should allow removing the dashboard panel after the underlying saved search has been deleted', - async ({ kbnClient, page, pageObjects, kbnSpace }) => { - await pageObjects.dashboard.openNewDashboard(); - await createSavedSearch( - kbnClient, - SAVED_SEARCH_ID, - SAVED_SEARCH_TITLE, - dataViewId, - kbnSpace.id - ); - await pageObjects.dashboard.addPanelFromLibrary(SAVED_SEARCH_TITLE); - await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ - state: 'visible', - }); - - await pageObjects.dashboard.saveDashboard('Dashboard with deleted saved search'); - await kbnClient.savedObjects.delete({ - type: 'search', - id: SAVED_SEARCH_ID, - space: kbnSpace.id, - }); - - await page.reload(); - await page.waitForLoadingIndicatorHidden(); - await expect( - page.testSubj.locator('embeddableError'), - 'Embeddable error should be displayed' - ).toBeVisible(); - - await pageObjects.dashboard.removePanel('embeddableError'); - await expect( - page.testSubj.locator('embeddableError'), - 'Embeddable error should not be displayed' - ).toBeHidden(); - } - ); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts index 8025792b884be..c89060223359b 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts @@ -7,12 +7,12 @@ import { expect } from '@kbn/scout'; import { spaceTest, testData } from '../fixtures'; -import type { ExtendedScoutTestFixtures } from '../fixtures'; +import type { ParallelRunTestFixtures } from '../fixtures'; const assertNoFilterAndEmptyQuery = async ( filterBadge: { field: string; value: string }, - pageObjects: ExtendedScoutTestFixtures['pageObjects'], - page: ExtendedScoutTestFixtures['page'] + pageObjects: ParallelRunTestFixtures['pageObjects'], + page: ParallelRunTestFixtures['page'] ) => { expect( // checking if filter exists, enabled or disabled @@ -25,7 +25,7 @@ const assertNoFilterAndEmptyQuery = async ( ).toHaveText(''); }; -const assertDataViewIsSelected = async (page: ExtendedScoutTestFixtures['page'], name: string) => +const assertDataViewIsSelected = async (page: ParallelRunTestFixtures['page'], name: string) => await expect( page.testSubj.locator('*dataView-switch-link'), 'Incorrect data view is selected' @@ -47,16 +47,16 @@ spaceTest.describe( value: `Men's Shoes`, }; - spaceTest.beforeAll(async ({ kbnSpace }) => { - await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.DISCOVER); - await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.ECOMMERCE); - await kbnSpace.uiSettings.setDefaultIndex('ecommerce'); - await kbnSpace.uiSettings.setDefaultTime({ from: START_TIME, to: END_TIME }); + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DISCOVER); + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.ECOMMERCE); + await scoutSpace.uiSettings.setDefaultIndex('ecommerce'); + await scoutSpace.uiSettings.setDefaultTime({ from: START_TIME, to: END_TIME }); }); - spaceTest.afterAll(async ({ kbnSpace }) => { - await kbnSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnSpace.savedObjects.cleanStandardList(); + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await scoutSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts index e81dcbe2e10b9..dc16aa7d37419 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts @@ -12,18 +12,18 @@ spaceTest.describe( 'Discover app - value suggestions: useTimeRange enabled', { tag: tags.DEPLOYMENT_AGNOSTIC }, () => { - spaceTest.beforeAll(async ({ kbnSpace }) => { - await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await kbnSpace.uiSettings.setDefaultIndex('logstash-*'); - await kbnSpace.uiSettings.setDefaultTime({ + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); + await scoutSpace.uiSettings.setDefaultTime({ from: testData.LOGSTASH_DEFAULT_START_TIME, to: testData.LOGSTASH_DEFAULT_END_TIME, }); }); - spaceTest.afterAll(async ({ kbnSpace }) => { - await kbnSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnSpace.savedObjects.cleanStandardList(); + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await scoutSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts index 2cea1e275fc9d..ac8093d7b9264 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts @@ -14,14 +14,14 @@ spaceTest.describe( // TODO: Update to use an ES archive with an index accessible to 'viewer' // for running this test against the Security serverless project. () => { - spaceTest.beforeAll(async ({ kbnSpace }) => { - await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); - await kbnSpace.uiSettings.setDefaultIndex('without-timefield'); + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); + await scoutSpace.uiSettings.setDefaultIndex('without-timefield'); }); - spaceTest.afterAll(async ({ kbnSpace }) => { - await kbnSpace.uiSettings.unset('defaultIndex'); - await kbnSpace.savedObjects.cleanStandardList(); + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex'); + await scoutSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts index 3fa8650e3ca6a..a7301a049c847 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts @@ -12,20 +12,20 @@ spaceTest.describe( 'Discover app - value suggestions: useTimeRange disabled', { tag: tags.DEPLOYMENT_AGNOSTIC }, () => { - spaceTest.beforeAll(async ({ kbnSpace }) => { - await kbnSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await kbnSpace.uiSettings.setDefaultIndex('logstash-*'); - await kbnSpace.uiSettings.setDefaultTime({ + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); + await scoutSpace.uiSettings.setDefaultTime({ from: testData.LOGSTASH_DEFAULT_START_TIME, to: testData.LOGSTASH_DEFAULT_END_TIME, }); - await kbnSpace.uiSettings.set({ 'autocomplete:useTimeRange': false }); + await scoutSpace.uiSettings.set({ 'autocomplete:useTimeRange': false }); }); - spaceTest.afterAll(async ({ kbnSpace }) => { - await kbnSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnSpace.uiSettings.set({ 'autocomplete:useTimeRange': true }); - await kbnSpace.savedObjects.cleanStandardList(); + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await scoutSpace.uiSettings.set({ 'autocomplete:useTimeRange': true }); + await scoutSpace.savedObjects.cleanStandardList(); }); spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts index 5b38eafc6476c..2bcb0f590976f 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts @@ -5,11 +5,11 @@ * 2.0. */ -import { ScoutWorkerFixtures, expect, tags } from '@kbn/scout'; +import { ScoutSingleThreadWorkerFixtures, expect, tags } from '@kbn/scout'; import { test, testData } from '../fixtures'; const createSavedSearch = async ( - kbnClient: ScoutWorkerFixtures['kbnClient'], + kbnClient: ScoutSingleThreadWorkerFixtures['kbnClient'], searchId: string, searchTitle: string, dataViewId: string diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts index 94a0d6b7b0638..b9471ed75aa7b 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts @@ -7,12 +7,12 @@ import { expect } from '@kbn/scout'; import { test, testData } from '../fixtures'; -import type { ExtendedScoutTestFixtures } from '../fixtures'; +import type { SingleThreadTestFixtures } from '../fixtures'; const assertNoFilterAndEmptyQuery = async ( filterBadge: { field: string; value: string }, - pageObjects: ExtendedScoutTestFixtures['pageObjects'], - page: ExtendedScoutTestFixtures['page'] + pageObjects: SingleThreadTestFixtures['pageObjects'], + page: SingleThreadTestFixtures['page'] ) => { expect( // checking if filter exists, enabled or disabled @@ -25,7 +25,7 @@ const assertNoFilterAndEmptyQuery = async ( ).toHaveText(''); }; -const assertDataViewIsSelected = async (page: ExtendedScoutTestFixtures['page'], name: string) => +const assertDataViewIsSelected = async (page: SingleThreadTestFixtures['page'], name: string) => await expect( page.testSubj.locator('*dataView-switch-link'), 'Incorrect data view is selected' From 3e5a82af86dc41e231f58384edd1775058f83a7d Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 21 Jan 2025 14:42:50 +0100 Subject: [PATCH 09/23] improve logging --- .../playwright/fixtures/test/page_objects/parallel.ts | 5 +++-- .../fixtures/test/page_objects/single_thread.ts | 5 +++-- .../playwright/fixtures/test/scout_page/parallel.ts | 11 +++++++---- .../fixtures/test/scout_page/single_thread.ts | 11 ++++++++--- .../fixtures/worker/scout_space/parallel.ts | 3 ++- .../fixtures/worker/ui_settings/single_thread.ts | 7 ++++--- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts index d97678835bf5f..c97d0608f2a9f 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts @@ -8,6 +8,7 @@ */ import { PageObjects, createCorePageObjects } from '../../../page_objects'; +import { serviceLoadedMsg } from '../../../utils'; import { scoutPageParallelFixture } from '../scout_page'; /** @@ -21,9 +22,9 @@ import { scoutPageParallelFixture } from '../scout_page'; export const pageObjectsParallelFixture = scoutPageParallelFixture.extend<{ pageObjects: PageObjects; }>({ - pageObjects: async ({ page: ScoutPage }, use) => { + pageObjects: async ({ page, log }, use) => { const corePageObjects = createCorePageObjects(page); - + log.debug(serviceLoadedMsg(`pageObjectsParallel`)); await use(corePageObjects); }, }); diff --git a/packages/kbn-scout/src/playwright/fixtures/test/page_objects/single_thread.ts b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/single_thread.ts index 1158929f60267..a4f462b699261 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/page_objects/single_thread.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/single_thread.ts @@ -8,6 +8,7 @@ */ import { PageObjects, createCorePageObjects } from '../../../page_objects'; +import { serviceLoadedMsg } from '../../../utils'; import { scoutPageFixture } from '../scout_page'; /** @@ -21,9 +22,9 @@ import { scoutPageFixture } from '../scout_page'; export const pageObjectsFixture = scoutPageFixture.extend<{ pageObjects: PageObjects; }>({ - pageObjects: async ({ page }, use) => { + pageObjects: async ({ page, log }, use) => { const corePageObjects = createCorePageObjects(page); - + log.debug(serviceLoadedMsg(`pageObjects`)); await use(corePageObjects); }, }); 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 9787d80b21f26..22993301a44af 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 @@ -9,20 +9,22 @@ import { Page, test as base } from '@playwright/test'; import { ScoutPage } from '.'; -import { KibanaUrl } from '../../worker'; +import { KibanaUrl, ToolingLog } from '../../worker'; import { ScoutSpaceParallelFixture } from '../../worker/scout_space'; import { extendPlaywrightPage } from './single_thread'; +import { serviceLoadedMsg } from '../../../utils'; export const scoutPageParallelFixture = base.extend< - {}, - { kbnUrl: KibanaUrl; scoutSpace: ScoutSpaceParallelFixture } + { page: ScoutPage }, + { log: ToolingLog; kbnUrl: KibanaUrl; scoutSpace: ScoutSpaceParallelFixture } >({ page: async ( { + log, page, kbnUrl, scoutSpace, - }: { page: Page; kbnUrl: KibanaUrl; scoutSpace: ScoutSpaceParallelFixture }, + }: { log: ToolingLog; page: Page; kbnUrl: KibanaUrl; scoutSpace: ScoutSpaceParallelFixture }, use: (extendedPage: ScoutPage) => Promise ) => { const extendedPage = extendPlaywrightPage({ page, kbnUrl }); @@ -31,6 +33,7 @@ export const scoutPageParallelFixture = base.extend< extendedPage.gotoApp = (appName: string) => page.goto(kbnUrl.app(appName, { space: scoutSpace.id })); // Method to wait for global loading indicator to be hidden + log.debug(serviceLoadedMsg(`scoutPageParallel`)); 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 8609a80425549..d3e3ee7704b20 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,8 +9,9 @@ import { Page } from '@playwright/test'; import { subj } from '@kbn/test-subj-selector'; -import { KibanaUrl, coreWorkerFixtures } from '../../worker'; +import { KibanaUrl, ToolingLog, coreWorkerFixtures } from '../../worker'; import { ScoutPage } from '.'; +import { serviceLoadedMsg } from '../../../utils'; /** * Instead of defining each method individually, we use a list of method names and loop through them, creating methods dynamically. @@ -116,12 +117,16 @@ export function extendPlaywrightPage({ * await page.gotoApp('discover); * ``` */ -export const scoutPageFixture = coreWorkerFixtures.extend<{}, { kbnUrl: KibanaUrl }>({ +export const scoutPageFixture = coreWorkerFixtures.extend< + { page: ScoutPage; log: ToolingLog }, + { kbnUrl: KibanaUrl } +>({ page: async ( - { page, kbnUrl }: { page: Page; kbnUrl: KibanaUrl }, + { page, kbnUrl, log }: { page: Page; kbnUrl: KibanaUrl; log: ToolingLog }, use: (extendedPage: ScoutPage) => Promise ) => { const extendedPage = extendPlaywrightPage({ page, kbnUrl }); + log.debug(serviceLoadedMsg(`scoutPage`)); await use(extendedPage); }, }); diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts index 315fa675e2ceb..48ed1e2fd549b 100644 --- a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts @@ -8,7 +8,7 @@ */ import { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; -import { formatTime, isValidUTCDate } from '../../../utils'; +import { formatTime, isValidUTCDate, serviceLoadedMsg } from '../../../utils'; import { coreWorkerFixtures } from '..'; import { ImportSavedObjects, ScoutSpaceParallelFixture } from '.'; @@ -98,6 +98,7 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< setDefaultTime, }; + log.debug(serviceLoadedMsg(`scoutSpace`)); await use({ savedObjects, uiSettings, id }); // Cleanup space after tests via API call diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/single_thread.ts b/packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/single_thread.ts index 99f1a3b0652d0..562daea6516ed 100644 --- a/packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/single_thread.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/ui_settings/single_thread.ts @@ -8,7 +8,7 @@ */ import { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; -import { isValidUTCDate, formatTime } from '../../../utils'; +import { isValidUTCDate, formatTime, serviceLoadedMsg } from '../../../utils'; import { coreWorkerFixtures } from '../core_fixtures'; import { UiSettingsFixture } from '.'; @@ -17,7 +17,7 @@ import { UiSettingsFixture } from '.'; */ export const uiSettingsFixture = coreWorkerFixtures.extend<{}, { uiSettings: UiSettingsFixture }>({ uiSettings: [ - ({ kbnClient }, use) => { + async ({ kbnClient, log }, use) => { const kbnClientUiSettings = { set: async (values: UiSettingValues) => { await kbnClient.uiSettings.update(values); @@ -35,7 +35,8 @@ export const uiSettingsFixture = coreWorkerFixtures.extend<{}, { uiSettings: UiS }, }; - use(kbnClientUiSettings); + log.debug(serviceLoadedMsg(`uiSettings`)); + await use(kbnClientUiSettings); }, { scope: 'worker' }, ], From 17111c39e8d3ffb8b6a4eacb33509644d23ccaae Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 21 Jan 2025 15:13:52 +0100 Subject: [PATCH 10/23] [kbn-test] cache cookie per space --- .../src/playwright/fixtures/index.ts | 2 +- ...s_fixtures.ts => parallel_run_fixtures.ts} | 0 .../fixtures/test/browser_auth/parallel.ts | 10 +++---- packages/kbn-test/src/auth/session_manager.ts | 26 +++++++++++++------ packages/kbn-test/src/auth/types.ts | 1 + 5 files changed, 25 insertions(+), 14 deletions(-) rename packages/kbn-scout/src/playwright/fixtures/{parallel_workers_fixtures.ts => parallel_run_fixtures.ts} (100%) diff --git a/packages/kbn-scout/src/playwright/fixtures/index.ts b/packages/kbn-scout/src/playwright/fixtures/index.ts index ea1ff54933e97..870545e853604 100644 --- a/packages/kbn-scout/src/playwright/fixtures/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/index.ts @@ -8,4 +8,4 @@ */ export * from './single_thread_fixtures'; -export * from './parallel_workers_fixtures'; +export * from './parallel_run_fixtures'; diff --git a/packages/kbn-scout/src/playwright/fixtures/parallel_workers_fixtures.ts b/packages/kbn-scout/src/playwright/fixtures/parallel_run_fixtures.ts similarity index 100% rename from packages/kbn-scout/src/playwright/fixtures/parallel_workers_fixtures.ts rename to packages/kbn-scout/src/playwright/fixtures/parallel_run_fixtures.ts diff --git a/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts b/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts index f3226df233eae..14171b601397c 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts @@ -11,6 +11,7 @@ import { BrowserAuthFixture, LoginFunction } from '.'; import { PROJECT_DEFAULT_ROLES } from '../../../../common'; import { serviceLoadedMsg } from '../../../utils'; import { coreWorkerFixtures } from '../../worker'; +import { ScoutSpaceParallelFixture } from '../../worker/scout_space'; /** * The "browserAuth" fixture simplifies the process of logging into Kibana with @@ -19,9 +20,9 @@ import { coreWorkerFixtures } from '../../worker'; */ export const browserAuthParallelFixture = coreWorkerFixtures.extend< { browserAuth: BrowserAuthFixture }, - {} + { scoutSpace: ScoutSpaceParallelFixture } >({ - browserAuth: async ({ log, context, samlAuth, config }, use) => { + browserAuth: async ({ log, context, samlAuth, config, scoutSpace }, use) => { const setSessionCookie = async (cookieValue: string) => { await context.clearCookies(); await context.addCookies([ @@ -35,9 +36,8 @@ export const browserAuthParallelFixture = coreWorkerFixtures.extend< }; const loginAs: LoginFunction = async (role) => { - const cookie = await samlAuth.getInteractiveUserSessionCookieWithRoleScope(role, { - forceNewSession: true, - }); + const spaceId = scoutSpace.id; + const cookie = await samlAuth.getInteractiveUserSessionCookieWithRoleScope(role, { spaceId }); await setSessionCookie(cookie); }; diff --git a/packages/kbn-test/src/auth/session_manager.ts b/packages/kbn-test/src/auth/session_manager.ts index 4efd55a71aad5..4f19c05add509 100644 --- a/packages/kbn-test/src/auth/session_manager.ts +++ b/packages/kbn-test/src/auth/session_manager.ts @@ -41,7 +41,8 @@ export interface SupportedRoles { } export interface GetCookieOptions { - forceNewSession: boolean; + forceNewSession?: boolean; + spaceId?: string; } /** @@ -120,18 +121,20 @@ Set env variable 'TEST_CLOUD=1' to run FTR against your Cloud deployment` }; private getSessionByRole = async (options: GetSessionByRole): Promise => { - const { role, forceNewSession } = options; + const { role, forceNewSession, spaceId } = options; // Validate role before creating SAML session this.validateRole(role); + const cacheKey = spaceId ? `${role}:${spaceId}` : role; + // Check if session is cached and not forced to create the new one - if (!forceNewSession && this.sessionCache.has(role)) { - return this.sessionCache.get(role)!; + if (!forceNewSession && this.sessionCache.has(cacheKey)) { + return this.sessionCache.get(cacheKey)!; } const session = await this.createSessionForRole(role); - this.sessionCache.set(role, session); + this.sessionCache.set(cacheKey, session); if (forceNewSession) { this.log.debug(`Session for role '${role}' was force updated.`); @@ -181,13 +184,20 @@ Set env variable 'TEST_CLOUD=1' to run FTR against your Cloud deployment` async getApiCredentialsForRole(role: string, options?: GetCookieOptions) { const { forceNewSession } = options || { forceNewSession: false }; - const session = await this.getSessionByRole({ role, forceNewSession }); + const session = await this.getSessionByRole({ + role, + forceNewSession: forceNewSession ?? false, + }); return { Cookie: `sid=${session.getCookieValue()}` }; } async getInteractiveUserSessionCookieWithRoleScope(role: string, options?: GetCookieOptions) { - const { forceNewSession } = options || { forceNewSession: false }; - const session = await this.getSessionByRole({ role, forceNewSession }); + const forceNewSession = options?.forceNewSession ?? false; + const session = await this.getSessionByRole({ + role, + forceNewSession, + spaceId: options?.spaceId, + }); return session.getCookieValue(); } diff --git a/packages/kbn-test/src/auth/types.ts b/packages/kbn-test/src/auth/types.ts index 4a61f71d5d572..b5fe03410285a 100644 --- a/packages/kbn-test/src/auth/types.ts +++ b/packages/kbn-test/src/auth/types.ts @@ -65,4 +65,5 @@ export interface RetryParams { export interface GetSessionByRole { role: string; forceNewSession: boolean; + spaceId?: string; } From 78d0673c5b1d6b9491047520a0f6b0f5c59ee1a0 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 21 Jan 2025 15:16:58 +0100 Subject: [PATCH 11/23] fix regexp for ftr config checker --- .../lib/config/run_check_ftr_configs_cli.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 735413d2f2029..deb54771e560f 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 @@ -55,7 +55,7 @@ export async function runCheckFtrConfigsCli() { } // playwright config files - if (file.match(/\/ui_tests\/*playwright*.config.ts$/)) { + if (file.match(/\/*playwright*.config.ts$/)) { return false; } From cf913010590de1c5f9ae3554cbfad0f53a804e9f Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 21 Jan 2025 15:44:15 +0100 Subject: [PATCH 12/23] fix lint error --- packages/kbn-scout/src/playwright/page_objects/utils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-scout/src/playwright/page_objects/utils/index.ts b/packages/kbn-scout/src/playwright/page_objects/utils/index.ts index 5593a324a274f..1f50901010303 100644 --- a/packages/kbn-scout/src/playwright/page_objects/utils/index.ts +++ b/packages/kbn-scout/src/playwright/page_objects/utils/index.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { ScoutPage } from '../../fixtures/types'; +import { ScoutPage } from '../../fixtures'; /** * Creates a lazily instantiated proxy for a Page Object class, deferring the creation of the instance until From 502e276eddcf8b32d7890ae16a6e52726366f3b9 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 21 Jan 2025 18:32:43 +0100 Subject: [PATCH 13/23] revert exported interfaces to avoid breaking change --- packages/kbn-scout/index.ts | 8 +-- .../fixtures/parallel_run_fixtures.ts | 6 +- .../fixtures/single_thread_fixtures.ts | 6 +- packages/kbn-scout/src/playwright/index.ts | 14 ++--- .../ui_tests/fixtures/index.ts | 61 ++++++++++--------- .../parallel_tests/saved_searches.spec.ts | 8 +-- .../tests/saved_search_embeddable.spec.ts | 4 +- .../ui_tests/tests/saved_searches.spec.ts | 8 +-- 8 files changed, 58 insertions(+), 57 deletions(-) diff --git a/packages/kbn-scout/index.ts b/packages/kbn-scout/index.ts index 4331a8069a508..f7c32d4e6868f 100644 --- a/packages/kbn-scout/index.ts +++ b/packages/kbn-scout/index.ts @@ -21,10 +21,10 @@ export type { ScoutTestOptions, ScoutPage, PageObjects, - ScoutSingleThreadTestFixtures, - ScoutSingleThreadWorkerFixtures, - ScoutParallelTestFixtures, - ScoutParallelWorkerFixtures, + ScoutTestFixtures, + ScoutWorkerFixtures, + ScoutParallelRunTestFixtures, + ScoutParallelRunWorkerFixtures, } from './src/playwright'; export type { Client, KbnClient, KibanaUrl, SamlSessionManager, ToolingLog } from './src/types'; 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 bd867bb2833c2..018ab682f5ba8 100644 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_run_fixtures.ts +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_run_fixtures.ts @@ -25,7 +25,7 @@ import { } from './test'; import type { BrowserAuthFixture, ScoutPage, PageObjects } from './test'; -export const scoutParallelWorkersFixtures = mergeTests( +export const scoutParallelRunFixtures = mergeTests( // worker scope fixtures coreWorkerFixtures, scoutSpaceParallelFixture, @@ -36,13 +36,13 @@ export const scoutParallelWorkersFixtures = mergeTests( validateTagsFixture ); -export interface ScoutParallelTestFixtures { +export interface ScoutParallelRunTestFixtures { browserAuth: BrowserAuthFixture; page: ScoutPage; pageObjects: PageObjects; } -export interface ScoutParallelWorkerFixtures { +export interface ScoutParallelRunWorkerFixtures { log: ToolingLog; 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 29d9a6ceea108..65e5572fc92db 100644 --- a/packages/kbn-scout/src/playwright/fixtures/single_thread_fixtures.ts +++ b/packages/kbn-scout/src/playwright/fixtures/single_thread_fixtures.ts @@ -29,7 +29,7 @@ import { } from './test'; export type { PageObjects, ScoutPage } from './test'; -export const scoutSingleThreadFixtures = mergeTests( +export const scoutFixtures = mergeTests( // worker scope fixtures coreWorkerFixtures, esArchiverFixture, @@ -41,13 +41,13 @@ export const scoutSingleThreadFixtures = mergeTests( validateTagsFixture ); -export interface ScoutSingleThreadTestFixtures { +export interface ScoutTestFixtures { browserAuth: BrowserAuthFixture; page: ScoutPage; pageObjects: PageObjects; } -export interface ScoutSingleThreadWorkerFixtures { +export interface ScoutWorkerFixtures { log: ToolingLog; config: ScoutTestConfig; kbnUrl: KibanaUrl; diff --git a/packages/kbn-scout/src/playwright/index.ts b/packages/kbn-scout/src/playwright/index.ts index b22950988cde0..b2efcf95e7506 100644 --- a/packages/kbn-scout/src/playwright/index.ts +++ b/packages/kbn-scout/src/playwright/index.ts @@ -7,13 +7,13 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { scoutSingleThreadFixtures, scoutParallelWorkersFixtures } from './fixtures'; +import { scoutFixtures, scoutParallelRunFixtures } from './fixtures'; // Scout core fixtures: worker & test scope -export const test = scoutSingleThreadFixtures; +export const test = scoutFixtures; // Scout core 'space aware' fixtures: worker & test scope -export const spaceTest = scoutParallelWorkersFixtures; +export const spaceTest = scoutParallelRunFixtures; export { createPlaywrightConfig } from './config'; export { createLazyPageObject } from './page_objects/utils'; @@ -21,10 +21,10 @@ export { expect } from './expect'; export type { ScoutPlaywrightOptions, ScoutTestOptions } from './types'; export type { - ScoutSingleThreadTestFixtures, - ScoutSingleThreadWorkerFixtures, - ScoutParallelTestFixtures, - ScoutParallelWorkerFixtures, + ScoutTestFixtures, + ScoutWorkerFixtures, + ScoutParallelRunTestFixtures, + ScoutParallelRunWorkerFixtures, ScoutPage, PageObjects, } from './fixtures'; diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts index 283df8c393313..7177439dff74c 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts @@ -10,29 +10,29 @@ import { spaceTest as spaceBaseTest, PageObjects, createLazyPageObject, - ScoutSingleThreadTestFixtures, - ScoutSingleThreadWorkerFixtures, - ScoutParallelTestFixtures, - ScoutParallelWorkerFixtures, + ScoutTestFixtures, + ScoutWorkerFixtures, + ScoutParallelRunTestFixtures, + ScoutParallelRunWorkerFixtures, } from '@kbn/scout'; import { DemoPage } from './page_objects'; -export interface SingleThreadTestFixtures extends ScoutSingleThreadTestFixtures { +export interface ExtScoutTestFixtures extends ScoutTestFixtures { pageObjects: PageObjects & { demo: DemoPage; }; } -export const test = baseTest.extend({ +export const test = baseTest.extend({ pageObjects: async ( { pageObjects, page, }: { - pageObjects: SingleThreadTestFixtures['pageObjects']; - page: SingleThreadTestFixtures['page']; + pageObjects: ExtScoutTestFixtures['pageObjects']; + page: ExtScoutTestFixtures['page']; }, - use: (pageObjects: SingleThreadTestFixtures['pageObjects']) => Promise + use: (pageObjects: ExtScoutTestFixtures['pageObjects']) => Promise ) => { const extendedPageObjects = { ...pageObjects, @@ -43,33 +43,34 @@ export const test = baseTest.extend( - { - pageObjects: async ( - { - pageObjects, - page, - }: { - pageObjects: ParallelRunTestFixtures['pageObjects']; - page: ParallelRunTestFixtures['page']; - }, - use: (pageObjects: ParallelRunTestFixtures['pageObjects']) => Promise - ) => { - const extendedPageObjects = { - ...pageObjects, - demo: createLazyPageObject(DemoPage, page), - }; - - await use(extendedPageObjects); +export const spaceTest = spaceBaseTest.extend< + ExtParallelRunTestFixtures, + ScoutParallelRunWorkerFixtures +>({ + pageObjects: async ( + { + pageObjects, + page, + }: { + pageObjects: ExtParallelRunTestFixtures['pageObjects']; + page: ExtParallelRunTestFixtures['page']; }, - } -); + use: (pageObjects: ExtParallelRunTestFixtures['pageObjects']) => Promise + ) => { + const extendedPageObjects = { + ...pageObjects, + demo: createLazyPageObject(DemoPage, page), + }; + + await use(extendedPageObjects); + }, +}); export * as testData from './constants'; export * as assertionMessages from './assertion_messages'; diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts index c89060223359b..75ceb1f37116b 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts @@ -7,12 +7,12 @@ import { expect } from '@kbn/scout'; import { spaceTest, testData } from '../fixtures'; -import type { ParallelRunTestFixtures } from '../fixtures'; +import type { ExtParallelRunTestFixtures } from '../fixtures'; const assertNoFilterAndEmptyQuery = async ( filterBadge: { field: string; value: string }, - pageObjects: ParallelRunTestFixtures['pageObjects'], - page: ParallelRunTestFixtures['page'] + pageObjects: ExtParallelRunTestFixtures['pageObjects'], + page: ExtParallelRunTestFixtures['page'] ) => { expect( // checking if filter exists, enabled or disabled @@ -25,7 +25,7 @@ const assertNoFilterAndEmptyQuery = async ( ).toHaveText(''); }; -const assertDataViewIsSelected = async (page: ParallelRunTestFixtures['page'], name: string) => +const assertDataViewIsSelected = async (page: ExtParallelRunTestFixtures['page'], name: string) => await expect( page.testSubj.locator('*dataView-switch-link'), 'Incorrect data view is selected' diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts index 2bcb0f590976f..5b38eafc6476c 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts @@ -5,11 +5,11 @@ * 2.0. */ -import { ScoutSingleThreadWorkerFixtures, expect, tags } from '@kbn/scout'; +import { ScoutWorkerFixtures, expect, tags } from '@kbn/scout'; import { test, testData } from '../fixtures'; const createSavedSearch = async ( - kbnClient: ScoutSingleThreadWorkerFixtures['kbnClient'], + kbnClient: ScoutWorkerFixtures['kbnClient'], searchId: string, searchTitle: string, dataViewId: string diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts index b9471ed75aa7b..031860ecc2891 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts @@ -7,12 +7,12 @@ import { expect } from '@kbn/scout'; import { test, testData } from '../fixtures'; -import type { SingleThreadTestFixtures } from '../fixtures'; +import type { ExtScoutTestFixtures } from '../fixtures'; const assertNoFilterAndEmptyQuery = async ( filterBadge: { field: string; value: string }, - pageObjects: SingleThreadTestFixtures['pageObjects'], - page: SingleThreadTestFixtures['page'] + pageObjects: ExtScoutTestFixtures['pageObjects'], + page: ExtScoutTestFixtures['page'] ) => { expect( // checking if filter exists, enabled or disabled @@ -25,7 +25,7 @@ const assertNoFilterAndEmptyQuery = async ( ).toHaveText(''); }; -const assertDataViewIsSelected = async (page: SingleThreadTestFixtures['page'], name: string) => +const assertDataViewIsSelected = async (page: ExtScoutTestFixtures['page'], name: string) => await expect( page.testSubj.locator('*dataView-switch-link'), 'Incorrect data view is selected' From 9dbe4409fc6dd4e28f060f376947f6c7bcf80ffe Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 21 Jan 2025 19:52:57 +0100 Subject: [PATCH 14/23] add 3x tests --- .../steps/functional/scout_ui_tests.sh | 12 +- .../parallel_tests/error_handling_2.spec.ts | 37 +++++ .../parallel_tests/error_handling_3.spec.ts | 37 +++++ .../parallel_tests/saved_searches_2.spec.ts | 127 ++++++++++++++++++ .../parallel_tests/saved_searches_3.spec.ts | 127 ++++++++++++++++++ .../value_suggestions_2.spec.ts | 59 ++++++++ .../value_suggestions_3.spec.ts | 59 ++++++++ ...value_suggestions_non_time_based_2.spec.ts | 47 +++++++ ...value_suggestions_non_time_based_3.spec.ts | 47 +++++++ ...gestions_use_time_range_disabled_2.spec.ts | 62 +++++++++ ...gestions_use_time_range_disabled_3.spec.ts | 62 +++++++++ .../ui_tests/tests/error_handling_2.spec.ts | 38 ++++++ .../ui_tests/tests/error_handling_3.spec.ts | 38 ++++++ .../ui_tests/tests/saved_searches_2.spec.ts | 123 +++++++++++++++++ .../ui_tests/tests/saved_searches_3.spec.ts | 123 +++++++++++++++++ .../tests/value_suggestions_2.spec.ts | 59 ++++++++ .../tests/value_suggestions_3.spec.ts | 59 ++++++++ ...value_suggestions_non_time_based_2.spec.ts | 49 +++++++ ...value_suggestions_non_time_based_3.spec.ts | 49 +++++++ ...gestions_use_time_range_disabled_2.spec.ts | 62 +++++++++ ...gestions_use_time_range_disabled_3.spec.ts | 62 +++++++++ 21 files changed, 1332 insertions(+), 6 deletions(-) create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_3.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_3.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_3.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_3.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_3.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_3.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_3.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_3.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_3.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_2.spec.ts create mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_3.spec.ts diff --git a/.buildkite/scripts/steps/functional/scout_ui_tests.sh b/.buildkite/scripts/steps/functional/scout_ui_tests.sh index 7037bd1db6b97..16deaeeb9ccb8 100755 --- a/.buildkite/scripts/steps/functional/scout_ui_tests.sh +++ b/.buildkite/scripts/steps/functional/scout_ui_tests.sh @@ -25,19 +25,19 @@ run_tests() { EXIT_CODE=0 # Discovery Enhanced parallel run -for run_mode in "--stateful" "--serverless=es" "--serverless=oblt" "--serverless=security"; do - run_tests "Discovery Enhanced" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts" "$run_mode" +for run_mode in "--stateful" "--serverless=es"; do + run_tests "Discovery Enhanced Parallel" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts" "$run_mode" done # Discovery Enhanced -for run_mode in "--stateful" "--serverless=es" "--serverless=oblt" "--serverless=security"; do +for run_mode in "--stateful" "--serverless=es"; do run_tests "Discovery Enhanced" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.config.ts" "$run_mode" done # Observability Onboarding -for run_mode in "--stateful" "--serverless=oblt"; do - run_tests "Observability Onboarding" "x-pack/solutions/observability/plugins/observability_onboarding/ui_tests/playwright.config.ts" "$run_mode" -done +# for run_mode in "--stateful" "--serverless=oblt"; do +# run_tests "Observability Onboarding" "x-pack/solutions/observability/plugins/observability_onboarding/ui_tests/playwright.config.ts" "$run_mode" +# done exit $EXIT_CODE diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_2.spec.ts new file mode 100644 index 0000000000000..97c4e18f7f2dc --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_2.spec.ts @@ -0,0 +1,37 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData } from '../fixtures'; + +spaceTest.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.cleanStandardList(); + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); + await scoutSpace.uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, + }); + }); + + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.cleanStandardList(); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest('should render invalid scripted field error', async ({ page }) => { + await page.testSubj.locator('discoverErrorCalloutTitle').waitFor({ state: 'visible' }); + await expect( + page.testSubj.locator('painlessStackTrace'), + 'Painless error stacktrace should be displayed' + ).toBeVisible(); + }); +}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_3.spec.ts new file mode 100644 index 0000000000000..97c4e18f7f2dc --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_3.spec.ts @@ -0,0 +1,37 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData } from '../fixtures'; + +spaceTest.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.cleanStandardList(); + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); + await scoutSpace.uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, + }); + }); + + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.cleanStandardList(); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest('should render invalid scripted field error', async ({ page }) => { + await page.testSubj.locator('discoverErrorCalloutTitle').waitFor({ state: 'visible' }); + await expect( + page.testSubj.locator('painlessStackTrace'), + 'Painless error stacktrace should be displayed' + ).toBeVisible(); + }); +}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_2.spec.ts new file mode 100644 index 0000000000000..75ceb1f37116b --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_2.spec.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 { expect } from '@kbn/scout'; +import { spaceTest, testData } from '../fixtures'; +import type { ExtParallelRunTestFixtures } from '../fixtures'; + +const assertNoFilterAndEmptyQuery = async ( + filterBadge: { field: string; value: string }, + pageObjects: ExtParallelRunTestFixtures['pageObjects'], + page: ExtParallelRunTestFixtures['page'] +) => { + expect( + // checking if filter exists, enabled or disabled + await pageObjects.filterBar.hasFilter(filterBadge), + `Filter ${JSON.stringify(filterBadge)} should not exist` + ).toBe(false); + await expect( + page.testSubj.locator('queryInput'), + 'Query Bar input field should be empty' + ).toHaveText(''); +}; + +const assertDataViewIsSelected = async (page: ExtParallelRunTestFixtures['page'], name: string) => + await expect( + page.testSubj.locator('*dataView-switch-link'), + 'Incorrect data view is selected' + ).toHaveText(name); + +spaceTest.describe( + 'Discover app - saved searches', + { tag: ['@ess', '@svlSearch', '@svlOblt'] }, + () => { + // TODO: Update to use an ES archive with an index accessible to 'viewer' + // for running this test against the Security serverless project. + const START_TIME = '2019-04-27T23:56:51.374Z'; + const END_TIME = '2019-08-23T16:18:51.821Z'; + const PANEL_NAME = 'Ecommerce Data'; + const SEARCH_QUERY = 'customer_gender:MALE'; + const SAVED_SEARCH_NAME = 'test-unselect-saved-search'; + const filterFieldAndValue = { + field: 'category', + value: `Men's Shoes`, + }; + + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DISCOVER); + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.ECOMMERCE); + await scoutSpace.uiSettings.setDefaultIndex('ecommerce'); + await scoutSpace.uiSettings.setDefaultTime({ from: START_TIME, to: END_TIME }); + }); + + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await scoutSpace.savedObjects.cleanStandardList(); + }); + + spaceTest.beforeEach(async ({ browserAuth }) => { + await browserAuth.loginAsPrivilegedUser(); + }); + + spaceTest('should customize time range on dashboards', async ({ pageObjects, page }) => { + await pageObjects.dashboard.goto(); + await pageObjects.dashboard.openNewDashboard(); + await pageObjects.dashboard.addPanelFromLibrary(PANEL_NAME); + await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ + state: 'visible', + }); + + await pageObjects.dashboard.customizePanel({ + name: PANEL_NAME, + customTimeRageCommonlyUsed: { value: 'Last_90 days' }, + }); + await expect( + page.testSubj.locator('embeddedSavedSearchDocTable').locator('.euiDataGrid__noResults'), + 'No results message in Saved Search panel should be visible' + ).toBeVisible(); + }); + + spaceTest( + `should unselect saved search when navigating to a 'new'`, + async ({ pageObjects, page }) => { + await pageObjects.discover.goto(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await pageObjects.filterBar.addFilter({ + ...filterFieldAndValue, + operator: 'is', + }); + await page.testSubj.fill('queryInput', SEARCH_QUERY); + await page.testSubj.click('querySubmitButton'); + await pageObjects.discover.waitForHistogramRendered(); + + await pageObjects.discover.saveSearch(SAVED_SEARCH_NAME); + await pageObjects.discover.waitForHistogramRendered(); + + expect( + await pageObjects.filterBar.hasFilter({ + ...filterFieldAndValue, + enabled: true, // Filter is enabled by default + }) + ).toBe(true); + await expect(page.testSubj.locator('queryInput')).toHaveText(SEARCH_QUERY); + + // create new search + await pageObjects.discover.clickNewSearch(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // change data view + await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // change data view again + await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // create new search again + await pageObjects.discover.clickNewSearch(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + } + ); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_3.spec.ts new file mode 100644 index 0000000000000..75ceb1f37116b --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_3.spec.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 { expect } from '@kbn/scout'; +import { spaceTest, testData } from '../fixtures'; +import type { ExtParallelRunTestFixtures } from '../fixtures'; + +const assertNoFilterAndEmptyQuery = async ( + filterBadge: { field: string; value: string }, + pageObjects: ExtParallelRunTestFixtures['pageObjects'], + page: ExtParallelRunTestFixtures['page'] +) => { + expect( + // checking if filter exists, enabled or disabled + await pageObjects.filterBar.hasFilter(filterBadge), + `Filter ${JSON.stringify(filterBadge)} should not exist` + ).toBe(false); + await expect( + page.testSubj.locator('queryInput'), + 'Query Bar input field should be empty' + ).toHaveText(''); +}; + +const assertDataViewIsSelected = async (page: ExtParallelRunTestFixtures['page'], name: string) => + await expect( + page.testSubj.locator('*dataView-switch-link'), + 'Incorrect data view is selected' + ).toHaveText(name); + +spaceTest.describe( + 'Discover app - saved searches', + { tag: ['@ess', '@svlSearch', '@svlOblt'] }, + () => { + // TODO: Update to use an ES archive with an index accessible to 'viewer' + // for running this test against the Security serverless project. + const START_TIME = '2019-04-27T23:56:51.374Z'; + const END_TIME = '2019-08-23T16:18:51.821Z'; + const PANEL_NAME = 'Ecommerce Data'; + const SEARCH_QUERY = 'customer_gender:MALE'; + const SAVED_SEARCH_NAME = 'test-unselect-saved-search'; + const filterFieldAndValue = { + field: 'category', + value: `Men's Shoes`, + }; + + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DISCOVER); + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.ECOMMERCE); + await scoutSpace.uiSettings.setDefaultIndex('ecommerce'); + await scoutSpace.uiSettings.setDefaultTime({ from: START_TIME, to: END_TIME }); + }); + + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await scoutSpace.savedObjects.cleanStandardList(); + }); + + spaceTest.beforeEach(async ({ browserAuth }) => { + await browserAuth.loginAsPrivilegedUser(); + }); + + spaceTest('should customize time range on dashboards', async ({ pageObjects, page }) => { + await pageObjects.dashboard.goto(); + await pageObjects.dashboard.openNewDashboard(); + await pageObjects.dashboard.addPanelFromLibrary(PANEL_NAME); + await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ + state: 'visible', + }); + + await pageObjects.dashboard.customizePanel({ + name: PANEL_NAME, + customTimeRageCommonlyUsed: { value: 'Last_90 days' }, + }); + await expect( + page.testSubj.locator('embeddedSavedSearchDocTable').locator('.euiDataGrid__noResults'), + 'No results message in Saved Search panel should be visible' + ).toBeVisible(); + }); + + spaceTest( + `should unselect saved search when navigating to a 'new'`, + async ({ pageObjects, page }) => { + await pageObjects.discover.goto(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await pageObjects.filterBar.addFilter({ + ...filterFieldAndValue, + operator: 'is', + }); + await page.testSubj.fill('queryInput', SEARCH_QUERY); + await page.testSubj.click('querySubmitButton'); + await pageObjects.discover.waitForHistogramRendered(); + + await pageObjects.discover.saveSearch(SAVED_SEARCH_NAME); + await pageObjects.discover.waitForHistogramRendered(); + + expect( + await pageObjects.filterBar.hasFilter({ + ...filterFieldAndValue, + enabled: true, // Filter is enabled by default + }) + ).toBe(true); + await expect(page.testSubj.locator('queryInput')).toHaveText(SEARCH_QUERY); + + // create new search + await pageObjects.discover.clickNewSearch(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // change data view + await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // change data view again + await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // create new search again + await pageObjects.discover.clickNewSearch(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + } + ); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_2.spec.ts new file mode 100644 index 0000000000000..dc16aa7d37419 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_2.spec.ts @@ -0,0 +1,59 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe( + 'Discover app - value suggestions: useTimeRange enabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); + await scoutSpace.uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, + }); + }); + + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await scoutSpace.savedObjects.cleanStandardList(); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest('dont show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); + }); + + spaceTest('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + + spaceTest('also displays descriptions for operators', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw'); + await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_3.spec.ts new file mode 100644 index 0000000000000..dc16aa7d37419 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_3.spec.ts @@ -0,0 +1,59 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe( + 'Discover app - value suggestions: useTimeRange enabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); + await scoutSpace.uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, + }); + }); + + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await scoutSpace.savedObjects.cleanStandardList(); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest('dont show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); + }); + + spaceTest('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + + spaceTest('also displays descriptions for operators', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw'); + await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_2.spec.ts new file mode 100644 index 0000000000000..ac8093d7b9264 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_2.spec.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 { expect } from '@kbn/scout'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe( + 'Discover app - value suggestions non-time based', + { tag: ['@ess', '@svlSearch', '@svlOblt'] }, + // TODO: Update to use an ES archive with an index accessible to 'viewer' + // for running this test against the Security serverless project. + () => { + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); + await scoutSpace.uiSettings.setDefaultIndex('without-timefield'); + }); + + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex'); + await scoutSpace.savedObjects.cleanStandardList(); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest( + 'shows all auto-suggest options for a filter in discover context app', + async ({ page }) => { + await page.testSubj.fill('queryInput', 'type.keyword : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(1); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('"apache"'); + } + ); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_3.spec.ts new file mode 100644 index 0000000000000..ac8093d7b9264 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_3.spec.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 { expect } from '@kbn/scout'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe( + 'Discover app - value suggestions non-time based', + { tag: ['@ess', '@svlSearch', '@svlOblt'] }, + // TODO: Update to use an ES archive with an index accessible to 'viewer' + // for running this test against the Security serverless project. + () => { + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); + await scoutSpace.uiSettings.setDefaultIndex('without-timefield'); + }); + + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex'); + await scoutSpace.savedObjects.cleanStandardList(); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest( + 'shows all auto-suggest options for a filter in discover context app', + async ({ page }) => { + await page.testSubj.fill('queryInput', 'type.keyword : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(1); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('"apache"'); + } + ); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_2.spec.ts new file mode 100644 index 0000000000000..a7301a049c847 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_2.spec.ts @@ -0,0 +1,62 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe( + 'Discover app - value suggestions: useTimeRange disabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); + await scoutSpace.uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, + }); + await scoutSpace.uiSettings.set({ 'autocomplete:useTimeRange': false }); + }); + + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await scoutSpace.uiSettings.set({ 'autocomplete:useTimeRange': true }); + await scoutSpace.savedObjects.cleanStandardList(); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest('show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + + spaceTest('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_3.spec.ts new file mode 100644 index 0000000000000..a7301a049c847 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_3.spec.ts @@ -0,0 +1,62 @@ +/* + * 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, tags } from '@kbn/scout'; +import { spaceTest, testData, assertionMessages } from '../fixtures'; + +spaceTest.describe( + 'Discover app - value suggestions: useTimeRange disabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + spaceTest.beforeAll(async ({ scoutSpace }) => { + await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); + await scoutSpace.uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, + }); + await scoutSpace.uiSettings.set({ 'autocomplete:useTimeRange': false }); + }); + + spaceTest.afterAll(async ({ scoutSpace }) => { + await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await scoutSpace.uiSettings.set({ 'autocomplete:useTimeRange': true }); + await scoutSpace.savedObjects.cleanStandardList(); + }); + + spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + spaceTest('show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + + spaceTest('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_2.spec.ts new file mode 100644 index 0000000000000..82c45b52ad567 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_2.spec.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, tags } from '@kbn/scout'; +import { test, testData } from '../fixtures'; + +test.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await kbnClient.savedObjects.clean({ types: ['search', 'index-pattern'] }); + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); + await uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, + }); + }); + + test.afterAll(async ({ kbnClient }) => { + await kbnClient.savedObjects.cleanStandardList(); + }); + + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + test('should render invalid scripted field error', async ({ page }) => { + await page.testSubj.locator('discoverErrorCalloutTitle').waitFor({ state: 'visible' }); + await expect( + page.testSubj.locator('painlessStackTrace'), + 'Painless error stacktrace should be displayed' + ).toBeVisible(); + }); +}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_3.spec.ts new file mode 100644 index 0000000000000..82c45b52ad567 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_3.spec.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, tags } from '@kbn/scout'; +import { test, testData } from '../fixtures'; + +test.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await kbnClient.savedObjects.clean({ types: ['search', 'index-pattern'] }); + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); + await uiSettings.setDefaultTime({ + from: testData.LOGSTASH_DEFAULT_START_TIME, + to: testData.LOGSTASH_DEFAULT_END_TIME, + }); + }); + + test.afterAll(async ({ kbnClient }) => { + await kbnClient.savedObjects.cleanStandardList(); + }); + + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + test('should render invalid scripted field error', async ({ page }) => { + await page.testSubj.locator('discoverErrorCalloutTitle').waitFor({ state: 'visible' }); + await expect( + page.testSubj.locator('painlessStackTrace'), + 'Painless error stacktrace should be displayed' + ).toBeVisible(); + }); +}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_2.spec.ts new file mode 100644 index 0000000000000..031860ecc2891 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_2.spec.ts @@ -0,0 +1,123 @@ +/* + * 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'; +import { test, testData } from '../fixtures'; +import type { ExtScoutTestFixtures } from '../fixtures'; + +const assertNoFilterAndEmptyQuery = async ( + filterBadge: { field: string; value: string }, + pageObjects: ExtScoutTestFixtures['pageObjects'], + page: ExtScoutTestFixtures['page'] +) => { + expect( + // checking if filter exists, enabled or disabled + await pageObjects.filterBar.hasFilter(filterBadge), + `Filter ${JSON.stringify(filterBadge)} should not exist` + ).toBe(false); + await expect( + page.testSubj.locator('queryInput'), + 'Query Bar input field should be empty' + ).toHaveText(''); +}; + +const assertDataViewIsSelected = async (page: ExtScoutTestFixtures['page'], name: string) => + await expect( + page.testSubj.locator('*dataView-switch-link'), + 'Incorrect data view is selected' + ).toHaveText(name); + +test.describe('Discover app - saved searches', { tag: ['@ess', '@svlSearch', '@svlOblt'] }, () => { + // TODO: Update to use an ES archive with an index accessible to 'viewer' + // for running this test against the Security serverless project. + const START_TIME = '2019-04-27T23:56:51.374Z'; + const END_TIME = '2019-08-23T16:18:51.821Z'; + const PANEL_NAME = 'Ecommerce Data'; + const SEARCH_QUERY = 'customer_gender:MALE'; + const SAVED_SEARCH_NAME = 'test-unselect-saved-search'; + const filterFieldAndValue = { + field: 'category', + value: `Men's Shoes`, + }; + + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.ECOMMERCE); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DISCOVER); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.ECOMMERCE); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.ECOMMERCE, + 'timepicker:timeDefaults': `{ "from": "${START_TIME}", "to": "${END_TIME}"}`, + }); + }); + + test.afterAll(async ({ kbnClient, uiSettings }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList(); + }); + + test.beforeEach(async ({ browserAuth }) => { + await browserAuth.loginAsPrivilegedUser(); + }); + + test('should customize time range on dashboards', async ({ pageObjects, page }) => { + await pageObjects.dashboard.goto(); + await pageObjects.dashboard.openNewDashboard(); + await pageObjects.dashboard.addPanelFromLibrary(PANEL_NAME); + await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ + state: 'visible', + }); + + await pageObjects.dashboard.customizePanel({ + name: PANEL_NAME, + customTimeRageCommonlyUsed: { value: 'Last_90 days' }, + }); + await expect( + page.testSubj.locator('embeddedSavedSearchDocTable').locator('.euiDataGrid__noResults'), + 'No results message in Saved Search panel should be visible' + ).toBeVisible(); + }); + + test(`should unselect saved search when navigating to a 'new'`, async ({ pageObjects, page }) => { + await pageObjects.discover.goto(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await pageObjects.filterBar.addFilter({ + ...filterFieldAndValue, + operator: 'is', + }); + await page.testSubj.fill('queryInput', SEARCH_QUERY); + await page.testSubj.click('querySubmitButton'); + await pageObjects.discover.waitForHistogramRendered(); + + await pageObjects.discover.saveSearch(SAVED_SEARCH_NAME); + await pageObjects.discover.waitForHistogramRendered(); + + expect( + await pageObjects.filterBar.hasFilter({ + ...filterFieldAndValue, + enabled: true, // Filter is enabled by default + }) + ).toBe(true); + await expect(page.testSubj.locator('queryInput')).toHaveText(SEARCH_QUERY); + + // create new search + await pageObjects.discover.clickNewSearch(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // change data view + await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // change data view again + await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // create new search again + await pageObjects.discover.clickNewSearch(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + }); +}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_3.spec.ts new file mode 100644 index 0000000000000..031860ecc2891 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_3.spec.ts @@ -0,0 +1,123 @@ +/* + * 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'; +import { test, testData } from '../fixtures'; +import type { ExtScoutTestFixtures } from '../fixtures'; + +const assertNoFilterAndEmptyQuery = async ( + filterBadge: { field: string; value: string }, + pageObjects: ExtScoutTestFixtures['pageObjects'], + page: ExtScoutTestFixtures['page'] +) => { + expect( + // checking if filter exists, enabled or disabled + await pageObjects.filterBar.hasFilter(filterBadge), + `Filter ${JSON.stringify(filterBadge)} should not exist` + ).toBe(false); + await expect( + page.testSubj.locator('queryInput'), + 'Query Bar input field should be empty' + ).toHaveText(''); +}; + +const assertDataViewIsSelected = async (page: ExtScoutTestFixtures['page'], name: string) => + await expect( + page.testSubj.locator('*dataView-switch-link'), + 'Incorrect data view is selected' + ).toHaveText(name); + +test.describe('Discover app - saved searches', { tag: ['@ess', '@svlSearch', '@svlOblt'] }, () => { + // TODO: Update to use an ES archive with an index accessible to 'viewer' + // for running this test against the Security serverless project. + const START_TIME = '2019-04-27T23:56:51.374Z'; + const END_TIME = '2019-08-23T16:18:51.821Z'; + const PANEL_NAME = 'Ecommerce Data'; + const SEARCH_QUERY = 'customer_gender:MALE'; + const SAVED_SEARCH_NAME = 'test-unselect-saved-search'; + const filterFieldAndValue = { + field: 'category', + value: `Men's Shoes`, + }; + + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.ECOMMERCE); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DISCOVER); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.ECOMMERCE); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.ECOMMERCE, + 'timepicker:timeDefaults': `{ "from": "${START_TIME}", "to": "${END_TIME}"}`, + }); + }); + + test.afterAll(async ({ kbnClient, uiSettings }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList(); + }); + + test.beforeEach(async ({ browserAuth }) => { + await browserAuth.loginAsPrivilegedUser(); + }); + + test('should customize time range on dashboards', async ({ pageObjects, page }) => { + await pageObjects.dashboard.goto(); + await pageObjects.dashboard.openNewDashboard(); + await pageObjects.dashboard.addPanelFromLibrary(PANEL_NAME); + await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ + state: 'visible', + }); + + await pageObjects.dashboard.customizePanel({ + name: PANEL_NAME, + customTimeRageCommonlyUsed: { value: 'Last_90 days' }, + }); + await expect( + page.testSubj.locator('embeddedSavedSearchDocTable').locator('.euiDataGrid__noResults'), + 'No results message in Saved Search panel should be visible' + ).toBeVisible(); + }); + + test(`should unselect saved search when navigating to a 'new'`, async ({ pageObjects, page }) => { + await pageObjects.discover.goto(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await pageObjects.filterBar.addFilter({ + ...filterFieldAndValue, + operator: 'is', + }); + await page.testSubj.fill('queryInput', SEARCH_QUERY); + await page.testSubj.click('querySubmitButton'); + await pageObjects.discover.waitForHistogramRendered(); + + await pageObjects.discover.saveSearch(SAVED_SEARCH_NAME); + await pageObjects.discover.waitForHistogramRendered(); + + expect( + await pageObjects.filterBar.hasFilter({ + ...filterFieldAndValue, + enabled: true, // Filter is enabled by default + }) + ).toBe(true); + await expect(page.testSubj.locator('queryInput')).toHaveText(SEARCH_QUERY); + + // create new search + await pageObjects.discover.clickNewSearch(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // change data view + await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // change data view again + await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); + await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); + + // create new search again + await pageObjects.discover.clickNewSearch(); + await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + }); +}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_2.spec.ts new file mode 100644 index 0000000000000..40b07726b31e4 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_2.spec.ts @@ -0,0 +1,59 @@ +/* + * 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, tags } from '@kbn/scout'; +import { test, testData, assertionMessages } from '../fixtures'; + +test.describe( + 'Discover app - value suggestions: useTimeRange enabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + }); + }); + + test.afterAll(async ({ kbnClient, uiSettings }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList(); + }); + + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + test('dont show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); + }); + + test('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + + test('also displays descriptions for operators', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw'); + await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_3.spec.ts new file mode 100644 index 0000000000000..40b07726b31e4 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_3.spec.ts @@ -0,0 +1,59 @@ +/* + * 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, tags } from '@kbn/scout'; +import { test, testData, assertionMessages } from '../fixtures'; + +test.describe( + 'Discover app - value suggestions: useTimeRange enabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + }); + }); + + test.afterAll(async ({ kbnClient, uiSettings }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList(); + }); + + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + test('dont show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); + }); + + test('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + + test('also displays descriptions for operators', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw'); + await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_2.spec.ts new file mode 100644 index 0000000000000..d8035597fa0e4 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_2.spec.ts @@ -0,0 +1,49 @@ +/* + * 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'; +import { test, testData, assertionMessages } from '../fixtures'; + +test.describe( + 'Discover app - value suggestions non-time based', + { tag: ['@ess', '@svlSearch', '@svlOblt'] }, + // TODO: Update to use an ES archive with an index accessible to 'viewer' + // for running this test against the Security serverless project. + () => { + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.NO_TIME_FIELD); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); + await uiSettings.set({ + defaultIndex: 'without-timefield', + }); + }); + + test.afterAll(async ({ kbnClient, uiSettings }) => { + await uiSettings.unset('defaultIndex'); + await kbnClient.savedObjects.cleanStandardList(); + }); + + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + test('shows all auto-suggest options for a filter in discover context app', async ({ + page, + }) => { + await page.testSubj.fill('queryInput', 'type.keyword : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(1); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('"apache"'); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_3.spec.ts new file mode 100644 index 0000000000000..d8035597fa0e4 --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_3.spec.ts @@ -0,0 +1,49 @@ +/* + * 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'; +import { test, testData, assertionMessages } from '../fixtures'; + +test.describe( + 'Discover app - value suggestions non-time based', + { tag: ['@ess', '@svlSearch', '@svlOblt'] }, + // TODO: Update to use an ES archive with an index accessible to 'viewer' + // for running this test against the Security serverless project. + () => { + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.NO_TIME_FIELD); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); + await uiSettings.set({ + defaultIndex: 'without-timefield', + }); + }); + + test.afterAll(async ({ kbnClient, uiSettings }) => { + await uiSettings.unset('defaultIndex'); + await kbnClient.savedObjects.cleanStandardList(); + }); + + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + test('shows all auto-suggest options for a filter in discover context app', async ({ + page, + }) => { + await page.testSubj.fill('queryInput', 'type.keyword : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(1); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('"apache"'); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_2.spec.ts new file mode 100644 index 0000000000000..cce172ad8494c --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_2.spec.ts @@ -0,0 +1,62 @@ +/* + * 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, tags } from '@kbn/scout'; +import { test, testData, assertionMessages } from '../fixtures'; + +test.describe( + 'Discover app - value suggestions: useTimeRange disabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + 'autocomplete:useTimeRange': false, + }); + }); + + test.afterAll(async ({ uiSettings, kbnClient }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await uiSettings.set({ 'autocomplete:useTimeRange': true }); + await kbnClient.savedObjects.cleanStandardList(); + }); + + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + test('show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + + test('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + } +); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_3.spec.ts new file mode 100644 index 0000000000000..cce172ad8494c --- /dev/null +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_3.spec.ts @@ -0,0 +1,62 @@ +/* + * 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, tags } from '@kbn/scout'; +import { test, testData, assertionMessages } from '../fixtures'; + +test.describe( + 'Discover app - value suggestions: useTimeRange disabled', + { tag: tags.DEPLOYMENT_AGNOSTIC }, + () => { + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, + 'autocomplete:useTimeRange': false, + }); + }); + + test.afterAll(async ({ uiSettings, kbnClient }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await uiSettings.set({ 'autocomplete:useTimeRange': true }); + await kbnClient.savedObjects.cleanStandardList(); + }); + + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.discover.goto(); + }); + + test('show up if outside of range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + + test('show up if in range', async ({ page, pageObjects }) => { + await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); + await page.testSubj.fill('queryInput', 'extension.raw : '); + await expect( + page.testSubj.locator('autoCompleteSuggestionText'), + assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT + ).toHaveCount(5); + const actualSuggestions = await page.testSubj + .locator('autoCompleteSuggestionText') + .allTextContents(); + expect(actualSuggestions.join(',')).toContain('jpg'); + }); + } +); From 6159e8ea6c12c2edc30aa87b0f5704b159b4f8a1 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 22 Jan 2025 00:23:07 +0100 Subject: [PATCH 15/23] Revert "add 3x tests" This reverts commit 9dbe4409fc6dd4e28f060f376947f6c7bcf80ffe. --- .../steps/functional/scout_ui_tests.sh | 12 +- .../parallel_tests/error_handling_2.spec.ts | 37 ----- .../parallel_tests/error_handling_3.spec.ts | 37 ----- .../parallel_tests/saved_searches_2.spec.ts | 127 ------------------ .../parallel_tests/saved_searches_3.spec.ts | 127 ------------------ .../value_suggestions_2.spec.ts | 59 -------- .../value_suggestions_3.spec.ts | 59 -------- ...value_suggestions_non_time_based_2.spec.ts | 47 ------- ...value_suggestions_non_time_based_3.spec.ts | 47 ------- ...gestions_use_time_range_disabled_2.spec.ts | 62 --------- ...gestions_use_time_range_disabled_3.spec.ts | 62 --------- .../ui_tests/tests/error_handling_2.spec.ts | 38 ------ .../ui_tests/tests/error_handling_3.spec.ts | 38 ------ .../ui_tests/tests/saved_searches_2.spec.ts | 123 ----------------- .../ui_tests/tests/saved_searches_3.spec.ts | 123 ----------------- .../tests/value_suggestions_2.spec.ts | 59 -------- .../tests/value_suggestions_3.spec.ts | 59 -------- ...value_suggestions_non_time_based_2.spec.ts | 49 ------- ...value_suggestions_non_time_based_3.spec.ts | 49 ------- ...gestions_use_time_range_disabled_2.spec.ts | 62 --------- ...gestions_use_time_range_disabled_3.spec.ts | 62 --------- 21 files changed, 6 insertions(+), 1332 deletions(-) delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_3.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_3.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_3.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_3.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_3.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_3.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_3.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_3.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_3.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_2.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_3.spec.ts diff --git a/.buildkite/scripts/steps/functional/scout_ui_tests.sh b/.buildkite/scripts/steps/functional/scout_ui_tests.sh index 16deaeeb9ccb8..7037bd1db6b97 100755 --- a/.buildkite/scripts/steps/functional/scout_ui_tests.sh +++ b/.buildkite/scripts/steps/functional/scout_ui_tests.sh @@ -25,19 +25,19 @@ run_tests() { EXIT_CODE=0 # Discovery Enhanced parallel run -for run_mode in "--stateful" "--serverless=es"; do - run_tests "Discovery Enhanced Parallel" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts" "$run_mode" +for run_mode in "--stateful" "--serverless=es" "--serverless=oblt" "--serverless=security"; do + run_tests "Discovery Enhanced" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts" "$run_mode" done # Discovery Enhanced -for run_mode in "--stateful" "--serverless=es"; do +for run_mode in "--stateful" "--serverless=es" "--serverless=oblt" "--serverless=security"; do run_tests "Discovery Enhanced" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.config.ts" "$run_mode" done # Observability Onboarding -# for run_mode in "--stateful" "--serverless=oblt"; do -# run_tests "Observability Onboarding" "x-pack/solutions/observability/plugins/observability_onboarding/ui_tests/playwright.config.ts" "$run_mode" -# done +for run_mode in "--stateful" "--serverless=oblt"; do + run_tests "Observability Onboarding" "x-pack/solutions/observability/plugins/observability_onboarding/ui_tests/playwright.config.ts" "$run_mode" +done exit $EXIT_CODE diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_2.spec.ts deleted file mode 100644 index 97c4e18f7f2dc..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_2.spec.ts +++ /dev/null @@ -1,37 +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 { expect, tags } from '@kbn/scout'; -import { spaceTest, testData } from '../fixtures'; - -spaceTest.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { - spaceTest.beforeAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.cleanStandardList(); - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); - await scoutSpace.uiSettings.setDefaultTime({ - from: testData.LOGSTASH_DEFAULT_START_TIME, - to: testData.LOGSTASH_DEFAULT_END_TIME, - }); - }); - - spaceTest.afterAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - spaceTest('should render invalid scripted field error', async ({ page }) => { - await page.testSubj.locator('discoverErrorCalloutTitle').waitFor({ state: 'visible' }); - await expect( - page.testSubj.locator('painlessStackTrace'), - 'Painless error stacktrace should be displayed' - ).toBeVisible(); - }); -}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_3.spec.ts deleted file mode 100644 index 97c4e18f7f2dc..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/error_handling_3.spec.ts +++ /dev/null @@ -1,37 +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 { expect, tags } from '@kbn/scout'; -import { spaceTest, testData } from '../fixtures'; - -spaceTest.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { - spaceTest.beforeAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.cleanStandardList(); - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); - await scoutSpace.uiSettings.setDefaultTime({ - from: testData.LOGSTASH_DEFAULT_START_TIME, - to: testData.LOGSTASH_DEFAULT_END_TIME, - }); - }); - - spaceTest.afterAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - spaceTest('should render invalid scripted field error', async ({ page }) => { - await page.testSubj.locator('discoverErrorCalloutTitle').waitFor({ state: 'visible' }); - await expect( - page.testSubj.locator('painlessStackTrace'), - 'Painless error stacktrace should be displayed' - ).toBeVisible(); - }); -}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_2.spec.ts deleted file mode 100644 index 75ceb1f37116b..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_2.spec.ts +++ /dev/null @@ -1,127 +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 { expect } from '@kbn/scout'; -import { spaceTest, testData } from '../fixtures'; -import type { ExtParallelRunTestFixtures } from '../fixtures'; - -const assertNoFilterAndEmptyQuery = async ( - filterBadge: { field: string; value: string }, - pageObjects: ExtParallelRunTestFixtures['pageObjects'], - page: ExtParallelRunTestFixtures['page'] -) => { - expect( - // checking if filter exists, enabled or disabled - await pageObjects.filterBar.hasFilter(filterBadge), - `Filter ${JSON.stringify(filterBadge)} should not exist` - ).toBe(false); - await expect( - page.testSubj.locator('queryInput'), - 'Query Bar input field should be empty' - ).toHaveText(''); -}; - -const assertDataViewIsSelected = async (page: ExtParallelRunTestFixtures['page'], name: string) => - await expect( - page.testSubj.locator('*dataView-switch-link'), - 'Incorrect data view is selected' - ).toHaveText(name); - -spaceTest.describe( - 'Discover app - saved searches', - { tag: ['@ess', '@svlSearch', '@svlOblt'] }, - () => { - // TODO: Update to use an ES archive with an index accessible to 'viewer' - // for running this test against the Security serverless project. - const START_TIME = '2019-04-27T23:56:51.374Z'; - const END_TIME = '2019-08-23T16:18:51.821Z'; - const PANEL_NAME = 'Ecommerce Data'; - const SEARCH_QUERY = 'customer_gender:MALE'; - const SAVED_SEARCH_NAME = 'test-unselect-saved-search'; - const filterFieldAndValue = { - field: 'category', - value: `Men's Shoes`, - }; - - spaceTest.beforeAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DISCOVER); - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.ECOMMERCE); - await scoutSpace.uiSettings.setDefaultIndex('ecommerce'); - await scoutSpace.uiSettings.setDefaultTime({ from: START_TIME, to: END_TIME }); - }); - - spaceTest.afterAll(async ({ scoutSpace }) => { - await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await scoutSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth }) => { - await browserAuth.loginAsPrivilegedUser(); - }); - - spaceTest('should customize time range on dashboards', async ({ pageObjects, page }) => { - await pageObjects.dashboard.goto(); - await pageObjects.dashboard.openNewDashboard(); - await pageObjects.dashboard.addPanelFromLibrary(PANEL_NAME); - await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ - state: 'visible', - }); - - await pageObjects.dashboard.customizePanel({ - name: PANEL_NAME, - customTimeRageCommonlyUsed: { value: 'Last_90 days' }, - }); - await expect( - page.testSubj.locator('embeddedSavedSearchDocTable').locator('.euiDataGrid__noResults'), - 'No results message in Saved Search panel should be visible' - ).toBeVisible(); - }); - - spaceTest( - `should unselect saved search when navigating to a 'new'`, - async ({ pageObjects, page }) => { - await pageObjects.discover.goto(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - await pageObjects.filterBar.addFilter({ - ...filterFieldAndValue, - operator: 'is', - }); - await page.testSubj.fill('queryInput', SEARCH_QUERY); - await page.testSubj.click('querySubmitButton'); - await pageObjects.discover.waitForHistogramRendered(); - - await pageObjects.discover.saveSearch(SAVED_SEARCH_NAME); - await pageObjects.discover.waitForHistogramRendered(); - - expect( - await pageObjects.filterBar.hasFilter({ - ...filterFieldAndValue, - enabled: true, // Filter is enabled by default - }) - ).toBe(true); - await expect(page.testSubj.locator('queryInput')).toHaveText(SEARCH_QUERY); - - // create new search - await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // change data view - await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // change data view again - await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // create new search again - await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - } - ); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_3.spec.ts deleted file mode 100644 index 75ceb1f37116b..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches_3.spec.ts +++ /dev/null @@ -1,127 +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 { expect } from '@kbn/scout'; -import { spaceTest, testData } from '../fixtures'; -import type { ExtParallelRunTestFixtures } from '../fixtures'; - -const assertNoFilterAndEmptyQuery = async ( - filterBadge: { field: string; value: string }, - pageObjects: ExtParallelRunTestFixtures['pageObjects'], - page: ExtParallelRunTestFixtures['page'] -) => { - expect( - // checking if filter exists, enabled or disabled - await pageObjects.filterBar.hasFilter(filterBadge), - `Filter ${JSON.stringify(filterBadge)} should not exist` - ).toBe(false); - await expect( - page.testSubj.locator('queryInput'), - 'Query Bar input field should be empty' - ).toHaveText(''); -}; - -const assertDataViewIsSelected = async (page: ExtParallelRunTestFixtures['page'], name: string) => - await expect( - page.testSubj.locator('*dataView-switch-link'), - 'Incorrect data view is selected' - ).toHaveText(name); - -spaceTest.describe( - 'Discover app - saved searches', - { tag: ['@ess', '@svlSearch', '@svlOblt'] }, - () => { - // TODO: Update to use an ES archive with an index accessible to 'viewer' - // for running this test against the Security serverless project. - const START_TIME = '2019-04-27T23:56:51.374Z'; - const END_TIME = '2019-08-23T16:18:51.821Z'; - const PANEL_NAME = 'Ecommerce Data'; - const SEARCH_QUERY = 'customer_gender:MALE'; - const SAVED_SEARCH_NAME = 'test-unselect-saved-search'; - const filterFieldAndValue = { - field: 'category', - value: `Men's Shoes`, - }; - - spaceTest.beforeAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DISCOVER); - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.ECOMMERCE); - await scoutSpace.uiSettings.setDefaultIndex('ecommerce'); - await scoutSpace.uiSettings.setDefaultTime({ from: START_TIME, to: END_TIME }); - }); - - spaceTest.afterAll(async ({ scoutSpace }) => { - await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await scoutSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth }) => { - await browserAuth.loginAsPrivilegedUser(); - }); - - spaceTest('should customize time range on dashboards', async ({ pageObjects, page }) => { - await pageObjects.dashboard.goto(); - await pageObjects.dashboard.openNewDashboard(); - await pageObjects.dashboard.addPanelFromLibrary(PANEL_NAME); - await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ - state: 'visible', - }); - - await pageObjects.dashboard.customizePanel({ - name: PANEL_NAME, - customTimeRageCommonlyUsed: { value: 'Last_90 days' }, - }); - await expect( - page.testSubj.locator('embeddedSavedSearchDocTable').locator('.euiDataGrid__noResults'), - 'No results message in Saved Search panel should be visible' - ).toBeVisible(); - }); - - spaceTest( - `should unselect saved search when navigating to a 'new'`, - async ({ pageObjects, page }) => { - await pageObjects.discover.goto(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - await pageObjects.filterBar.addFilter({ - ...filterFieldAndValue, - operator: 'is', - }); - await page.testSubj.fill('queryInput', SEARCH_QUERY); - await page.testSubj.click('querySubmitButton'); - await pageObjects.discover.waitForHistogramRendered(); - - await pageObjects.discover.saveSearch(SAVED_SEARCH_NAME); - await pageObjects.discover.waitForHistogramRendered(); - - expect( - await pageObjects.filterBar.hasFilter({ - ...filterFieldAndValue, - enabled: true, // Filter is enabled by default - }) - ).toBe(true); - await expect(page.testSubj.locator('queryInput')).toHaveText(SEARCH_QUERY); - - // create new search - await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // change data view - await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // change data view again - await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // create new search again - await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - } - ); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_2.spec.ts deleted file mode 100644 index dc16aa7d37419..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_2.spec.ts +++ /dev/null @@ -1,59 +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 { expect, tags } from '@kbn/scout'; -import { spaceTest, testData, assertionMessages } from '../fixtures'; - -spaceTest.describe( - 'Discover app - value suggestions: useTimeRange enabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - spaceTest.beforeAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); - await scoutSpace.uiSettings.setDefaultTime({ - from: testData.LOGSTASH_DEFAULT_START_TIME, - to: testData.LOGSTASH_DEFAULT_END_TIME, - }); - }); - - spaceTest.afterAll(async ({ scoutSpace }) => { - await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await scoutSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - spaceTest('dont show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); - }); - - spaceTest('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - - spaceTest('also displays descriptions for operators', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw'); - await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_3.spec.ts deleted file mode 100644 index dc16aa7d37419..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_3.spec.ts +++ /dev/null @@ -1,59 +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 { expect, tags } from '@kbn/scout'; -import { spaceTest, testData, assertionMessages } from '../fixtures'; - -spaceTest.describe( - 'Discover app - value suggestions: useTimeRange enabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - spaceTest.beforeAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); - await scoutSpace.uiSettings.setDefaultTime({ - from: testData.LOGSTASH_DEFAULT_START_TIME, - to: testData.LOGSTASH_DEFAULT_END_TIME, - }); - }); - - spaceTest.afterAll(async ({ scoutSpace }) => { - await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await scoutSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - spaceTest('dont show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); - }); - - spaceTest('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - - spaceTest('also displays descriptions for operators', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw'); - await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_2.spec.ts deleted file mode 100644 index ac8093d7b9264..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_2.spec.ts +++ /dev/null @@ -1,47 +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 { expect } from '@kbn/scout'; -import { spaceTest, testData, assertionMessages } from '../fixtures'; - -spaceTest.describe( - 'Discover app - value suggestions non-time based', - { tag: ['@ess', '@svlSearch', '@svlOblt'] }, - // TODO: Update to use an ES archive with an index accessible to 'viewer' - // for running this test against the Security serverless project. - () => { - spaceTest.beforeAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); - await scoutSpace.uiSettings.setDefaultIndex('without-timefield'); - }); - - spaceTest.afterAll(async ({ scoutSpace }) => { - await scoutSpace.uiSettings.unset('defaultIndex'); - await scoutSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - spaceTest( - 'shows all auto-suggest options for a filter in discover context app', - async ({ page }) => { - await page.testSubj.fill('queryInput', 'type.keyword : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(1); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('"apache"'); - } - ); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_3.spec.ts deleted file mode 100644 index ac8093d7b9264..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based_3.spec.ts +++ /dev/null @@ -1,47 +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 { expect } from '@kbn/scout'; -import { spaceTest, testData, assertionMessages } from '../fixtures'; - -spaceTest.describe( - 'Discover app - value suggestions non-time based', - { tag: ['@ess', '@svlSearch', '@svlOblt'] }, - // TODO: Update to use an ES archive with an index accessible to 'viewer' - // for running this test against the Security serverless project. - () => { - spaceTest.beforeAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); - await scoutSpace.uiSettings.setDefaultIndex('without-timefield'); - }); - - spaceTest.afterAll(async ({ scoutSpace }) => { - await scoutSpace.uiSettings.unset('defaultIndex'); - await scoutSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - spaceTest( - 'shows all auto-suggest options for a filter in discover context app', - async ({ page }) => { - await page.testSubj.fill('queryInput', 'type.keyword : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(1); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('"apache"'); - } - ); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_2.spec.ts deleted file mode 100644 index a7301a049c847..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_2.spec.ts +++ /dev/null @@ -1,62 +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 { expect, tags } from '@kbn/scout'; -import { spaceTest, testData, assertionMessages } from '../fixtures'; - -spaceTest.describe( - 'Discover app - value suggestions: useTimeRange disabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - spaceTest.beforeAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); - await scoutSpace.uiSettings.setDefaultTime({ - from: testData.LOGSTASH_DEFAULT_START_TIME, - to: testData.LOGSTASH_DEFAULT_END_TIME, - }); - await scoutSpace.uiSettings.set({ 'autocomplete:useTimeRange': false }); - }); - - spaceTest.afterAll(async ({ scoutSpace }) => { - await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await scoutSpace.uiSettings.set({ 'autocomplete:useTimeRange': true }); - await scoutSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - spaceTest('show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - - spaceTest('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_3.spec.ts deleted file mode 100644 index a7301a049c847..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled_3.spec.ts +++ /dev/null @@ -1,62 +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 { expect, tags } from '@kbn/scout'; -import { spaceTest, testData, assertionMessages } from '../fixtures'; - -spaceTest.describe( - 'Discover app - value suggestions: useTimeRange disabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - spaceTest.beforeAll(async ({ scoutSpace }) => { - await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); - await scoutSpace.uiSettings.setDefaultTime({ - from: testData.LOGSTASH_DEFAULT_START_TIME, - to: testData.LOGSTASH_DEFAULT_END_TIME, - }); - await scoutSpace.uiSettings.set({ 'autocomplete:useTimeRange': false }); - }); - - spaceTest.afterAll(async ({ scoutSpace }) => { - await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await scoutSpace.uiSettings.set({ 'autocomplete:useTimeRange': true }); - await scoutSpace.savedObjects.cleanStandardList(); - }); - - spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - spaceTest('show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - - spaceTest('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_2.spec.ts deleted file mode 100644 index 82c45b52ad567..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_2.spec.ts +++ /dev/null @@ -1,38 +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 { expect, tags } from '@kbn/scout'; -import { test, testData } from '../fixtures'; - -test.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await kbnClient.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); - await uiSettings.setDefaultTime({ - from: testData.LOGSTASH_DEFAULT_START_TIME, - to: testData.LOGSTASH_DEFAULT_END_TIME, - }); - }); - - test.afterAll(async ({ kbnClient }) => { - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('should render invalid scripted field error', async ({ page }) => { - await page.testSubj.locator('discoverErrorCalloutTitle').waitFor({ state: 'visible' }); - await expect( - page.testSubj.locator('painlessStackTrace'), - 'Painless error stacktrace should be displayed' - ).toBeVisible(); - }); -}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_3.spec.ts deleted file mode 100644 index 82c45b52ad567..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling_3.spec.ts +++ /dev/null @@ -1,38 +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 { expect, tags } from '@kbn/scout'; -import { test, testData } from '../fixtures'; - -test.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await kbnClient.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); - await uiSettings.setDefaultTime({ - from: testData.LOGSTASH_DEFAULT_START_TIME, - to: testData.LOGSTASH_DEFAULT_END_TIME, - }); - }); - - test.afterAll(async ({ kbnClient }) => { - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('should render invalid scripted field error', async ({ page }) => { - await page.testSubj.locator('discoverErrorCalloutTitle').waitFor({ state: 'visible' }); - await expect( - page.testSubj.locator('painlessStackTrace'), - 'Painless error stacktrace should be displayed' - ).toBeVisible(); - }); -}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_2.spec.ts deleted file mode 100644 index 031860ecc2891..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_2.spec.ts +++ /dev/null @@ -1,123 +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 { expect } from '@kbn/scout'; -import { test, testData } from '../fixtures'; -import type { ExtScoutTestFixtures } from '../fixtures'; - -const assertNoFilterAndEmptyQuery = async ( - filterBadge: { field: string; value: string }, - pageObjects: ExtScoutTestFixtures['pageObjects'], - page: ExtScoutTestFixtures['page'] -) => { - expect( - // checking if filter exists, enabled or disabled - await pageObjects.filterBar.hasFilter(filterBadge), - `Filter ${JSON.stringify(filterBadge)} should not exist` - ).toBe(false); - await expect( - page.testSubj.locator('queryInput'), - 'Query Bar input field should be empty' - ).toHaveText(''); -}; - -const assertDataViewIsSelected = async (page: ExtScoutTestFixtures['page'], name: string) => - await expect( - page.testSubj.locator('*dataView-switch-link'), - 'Incorrect data view is selected' - ).toHaveText(name); - -test.describe('Discover app - saved searches', { tag: ['@ess', '@svlSearch', '@svlOblt'] }, () => { - // TODO: Update to use an ES archive with an index accessible to 'viewer' - // for running this test against the Security serverless project. - const START_TIME = '2019-04-27T23:56:51.374Z'; - const END_TIME = '2019-08-23T16:18:51.821Z'; - const PANEL_NAME = 'Ecommerce Data'; - const SEARCH_QUERY = 'customer_gender:MALE'; - const SAVED_SEARCH_NAME = 'test-unselect-saved-search'; - const filterFieldAndValue = { - field: 'category', - value: `Men's Shoes`, - }; - - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.ECOMMERCE); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DISCOVER); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.ECOMMERCE); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.ECOMMERCE, - 'timepicker:timeDefaults': `{ "from": "${START_TIME}", "to": "${END_TIME}"}`, - }); - }); - - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth }) => { - await browserAuth.loginAsPrivilegedUser(); - }); - - test('should customize time range on dashboards', async ({ pageObjects, page }) => { - await pageObjects.dashboard.goto(); - await pageObjects.dashboard.openNewDashboard(); - await pageObjects.dashboard.addPanelFromLibrary(PANEL_NAME); - await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ - state: 'visible', - }); - - await pageObjects.dashboard.customizePanel({ - name: PANEL_NAME, - customTimeRageCommonlyUsed: { value: 'Last_90 days' }, - }); - await expect( - page.testSubj.locator('embeddedSavedSearchDocTable').locator('.euiDataGrid__noResults'), - 'No results message in Saved Search panel should be visible' - ).toBeVisible(); - }); - - test(`should unselect saved search when navigating to a 'new'`, async ({ pageObjects, page }) => { - await pageObjects.discover.goto(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - await pageObjects.filterBar.addFilter({ - ...filterFieldAndValue, - operator: 'is', - }); - await page.testSubj.fill('queryInput', SEARCH_QUERY); - await page.testSubj.click('querySubmitButton'); - await pageObjects.discover.waitForHistogramRendered(); - - await pageObjects.discover.saveSearch(SAVED_SEARCH_NAME); - await pageObjects.discover.waitForHistogramRendered(); - - expect( - await pageObjects.filterBar.hasFilter({ - ...filterFieldAndValue, - enabled: true, // Filter is enabled by default - }) - ).toBe(true); - await expect(page.testSubj.locator('queryInput')).toHaveText(SEARCH_QUERY); - - // create new search - await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // change data view - await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // change data view again - await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // create new search again - await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - }); -}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_3.spec.ts deleted file mode 100644 index 031860ecc2891..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches_3.spec.ts +++ /dev/null @@ -1,123 +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 { expect } from '@kbn/scout'; -import { test, testData } from '../fixtures'; -import type { ExtScoutTestFixtures } from '../fixtures'; - -const assertNoFilterAndEmptyQuery = async ( - filterBadge: { field: string; value: string }, - pageObjects: ExtScoutTestFixtures['pageObjects'], - page: ExtScoutTestFixtures['page'] -) => { - expect( - // checking if filter exists, enabled or disabled - await pageObjects.filterBar.hasFilter(filterBadge), - `Filter ${JSON.stringify(filterBadge)} should not exist` - ).toBe(false); - await expect( - page.testSubj.locator('queryInput'), - 'Query Bar input field should be empty' - ).toHaveText(''); -}; - -const assertDataViewIsSelected = async (page: ExtScoutTestFixtures['page'], name: string) => - await expect( - page.testSubj.locator('*dataView-switch-link'), - 'Incorrect data view is selected' - ).toHaveText(name); - -test.describe('Discover app - saved searches', { tag: ['@ess', '@svlSearch', '@svlOblt'] }, () => { - // TODO: Update to use an ES archive with an index accessible to 'viewer' - // for running this test against the Security serverless project. - const START_TIME = '2019-04-27T23:56:51.374Z'; - const END_TIME = '2019-08-23T16:18:51.821Z'; - const PANEL_NAME = 'Ecommerce Data'; - const SEARCH_QUERY = 'customer_gender:MALE'; - const SAVED_SEARCH_NAME = 'test-unselect-saved-search'; - const filterFieldAndValue = { - field: 'category', - value: `Men's Shoes`, - }; - - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.ECOMMERCE); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DISCOVER); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.ECOMMERCE); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.ECOMMERCE, - 'timepicker:timeDefaults': `{ "from": "${START_TIME}", "to": "${END_TIME}"}`, - }); - }); - - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth }) => { - await browserAuth.loginAsPrivilegedUser(); - }); - - test('should customize time range on dashboards', async ({ pageObjects, page }) => { - await pageObjects.dashboard.goto(); - await pageObjects.dashboard.openNewDashboard(); - await pageObjects.dashboard.addPanelFromLibrary(PANEL_NAME); - await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ - state: 'visible', - }); - - await pageObjects.dashboard.customizePanel({ - name: PANEL_NAME, - customTimeRageCommonlyUsed: { value: 'Last_90 days' }, - }); - await expect( - page.testSubj.locator('embeddedSavedSearchDocTable').locator('.euiDataGrid__noResults'), - 'No results message in Saved Search panel should be visible' - ).toBeVisible(); - }); - - test(`should unselect saved search when navigating to a 'new'`, async ({ pageObjects, page }) => { - await pageObjects.discover.goto(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - await pageObjects.filterBar.addFilter({ - ...filterFieldAndValue, - operator: 'is', - }); - await page.testSubj.fill('queryInput', SEARCH_QUERY); - await page.testSubj.click('querySubmitButton'); - await pageObjects.discover.waitForHistogramRendered(); - - await pageObjects.discover.saveSearch(SAVED_SEARCH_NAME); - await pageObjects.discover.waitForHistogramRendered(); - - expect( - await pageObjects.filterBar.hasFilter({ - ...filterFieldAndValue, - enabled: true, // Filter is enabled by default - }) - ).toBe(true); - await expect(page.testSubj.locator('queryInput')).toHaveText(SEARCH_QUERY); - - // create new search - await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // change data view - await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // change data view again - await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // create new search again - await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - }); -}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_2.spec.ts deleted file mode 100644 index 40b07726b31e4..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_2.spec.ts +++ /dev/null @@ -1,59 +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 { expect, tags } from '@kbn/scout'; -import { test, testData, assertionMessages } from '../fixtures'; - -test.describe( - 'Discover app - value suggestions: useTimeRange enabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - }); - }); - - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('dont show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); - }); - - test('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - - test('also displays descriptions for operators', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw'); - await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_3.spec.ts deleted file mode 100644 index 40b07726b31e4..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_3.spec.ts +++ /dev/null @@ -1,59 +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 { expect, tags } from '@kbn/scout'; -import { test, testData, assertionMessages } from '../fixtures'; - -test.describe( - 'Discover app - value suggestions: useTimeRange enabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - }); - }); - - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('dont show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); - }); - - test('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - - test('also displays descriptions for operators', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw'); - await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_2.spec.ts deleted file mode 100644 index d8035597fa0e4..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_2.spec.ts +++ /dev/null @@ -1,49 +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 { expect } from '@kbn/scout'; -import { test, testData, assertionMessages } from '../fixtures'; - -test.describe( - 'Discover app - value suggestions non-time based', - { tag: ['@ess', '@svlSearch', '@svlOblt'] }, - // TODO: Update to use an ES archive with an index accessible to 'viewer' - // for running this test against the Security serverless project. - () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.NO_TIME_FIELD); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); - await uiSettings.set({ - defaultIndex: 'without-timefield', - }); - }); - - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex'); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('shows all auto-suggest options for a filter in discover context app', async ({ - page, - }) => { - await page.testSubj.fill('queryInput', 'type.keyword : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(1); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('"apache"'); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_3.spec.ts deleted file mode 100644 index d8035597fa0e4..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based_3.spec.ts +++ /dev/null @@ -1,49 +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 { expect } from '@kbn/scout'; -import { test, testData, assertionMessages } from '../fixtures'; - -test.describe( - 'Discover app - value suggestions non-time based', - { tag: ['@ess', '@svlSearch', '@svlOblt'] }, - // TODO: Update to use an ES archive with an index accessible to 'viewer' - // for running this test against the Security serverless project. - () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.NO_TIME_FIELD); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); - await uiSettings.set({ - defaultIndex: 'without-timefield', - }); - }); - - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex'); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('shows all auto-suggest options for a filter in discover context app', async ({ - page, - }) => { - await page.testSubj.fill('queryInput', 'type.keyword : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(1); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('"apache"'); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_2.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_2.spec.ts deleted file mode 100644 index cce172ad8494c..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_2.spec.ts +++ /dev/null @@ -1,62 +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 { expect, tags } from '@kbn/scout'; -import { test, testData, assertionMessages } from '../fixtures'; - -test.describe( - 'Discover app - value suggestions: useTimeRange disabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - 'autocomplete:useTimeRange': false, - }); - }); - - test.afterAll(async ({ uiSettings, kbnClient }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await uiSettings.set({ 'autocomplete:useTimeRange': true }); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - - test('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_3.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_3.spec.ts deleted file mode 100644 index cce172ad8494c..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled_3.spec.ts +++ /dev/null @@ -1,62 +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 { expect, tags } from '@kbn/scout'; -import { test, testData, assertionMessages } from '../fixtures'; - -test.describe( - 'Discover app - value suggestions: useTimeRange disabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - 'autocomplete:useTimeRange': false, - }); - }); - - test.afterAll(async ({ uiSettings, kbnClient }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await uiSettings.set({ 'autocomplete:useTimeRange': true }); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - - test('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - } -); From 28c59cb1ba8f5d6b342e0f5400d4d4abbdd8d1b8 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 22 Jan 2025 00:25:39 +0100 Subject: [PATCH 16/23] delete duplicated tests --- .../ui_tests/tests/error_handling.spec.ts | 38 ------ .../tests/saved_search_embeddable.spec.ts | 106 ++++++++------- .../ui_tests/tests/saved_searches.spec.ts | 123 ------------------ .../ui_tests/tests/value_suggestions.spec.ts | 59 --------- .../value_suggestions_non_time_based.spec.ts | 49 ------- ...uggestions_use_time_range_disabled.spec.ts | 62 --------- 6 files changed, 51 insertions(+), 386 deletions(-) delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts delete mode 100644 x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled.spec.ts diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling.spec.ts deleted file mode 100644 index 82c45b52ad567..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/error_handling.spec.ts +++ /dev/null @@ -1,38 +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 { expect, tags } from '@kbn/scout'; -import { test, testData } from '../fixtures'; - -test.describe('Discover app - errors', { tag: tags.ESS_ONLY }, () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await kbnClient.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.INVALID_SCRIPTED_FIELD); - await uiSettings.setDefaultTime({ - from: testData.LOGSTASH_DEFAULT_START_TIME, - to: testData.LOGSTASH_DEFAULT_END_TIME, - }); - }); - - test.afterAll(async ({ kbnClient }) => { - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('should render invalid scripted field error', async ({ page }) => { - await page.testSubj.locator('discoverErrorCalloutTitle').waitFor({ state: 'visible' }); - await expect( - page.testSubj.locator('painlessStackTrace'), - 'Painless error stacktrace should be displayed' - ).toBeVisible(); - }); -}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts index 5b38eafc6476c..6c37611dbc202 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts @@ -37,66 +37,62 @@ const createSavedSearch = async ( ], }); -test.describe.skip( - 'Discover app - saved search embeddable', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - const SAVED_SEARCH_TITLE = 'TempSearch'; - const SAVED_SEARCH_ID = '90943e30-9a47-11e8-b64d-95841ca0b247'; - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - }); +test.describe('Discover app - saved search embeddable', { tag: tags.DEPLOYMENT_AGNOSTIC }, () => { + const SAVED_SEARCH_TITLE = 'TempSearch'; + const SAVED_SEARCH_ID = '90943e30-9a47-11e8-b64d-95841ca0b247'; + test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { + await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); + await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); + await uiSettings.set({ + defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run + 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, }); + }); - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList(); - }); + test.afterAll(async ({ kbnClient, uiSettings }) => { + await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); + await kbnClient.savedObjects.cleanStandardList(); + }); - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsPrivilegedUser(); - await pageObjects.dashboard.goto(); - }); + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsPrivilegedUser(); + await pageObjects.dashboard.goto(); + }); - test('should allow removing the dashboard panel after the underlying saved search has been deleted', async ({ + test('should allow removing the dashboard panel after the underlying saved search has been deleted', async ({ + kbnClient, + page, + pageObjects, + }) => { + await pageObjects.dashboard.openNewDashboard(); + await createSavedSearch( kbnClient, - page, - pageObjects, - }) => { - await pageObjects.dashboard.openNewDashboard(); - await createSavedSearch( - kbnClient, - SAVED_SEARCH_ID, - SAVED_SEARCH_TITLE, - testData.DATA_VIEW_ID.LOGSTASH - ); - await pageObjects.dashboard.addPanelFromLibrary(SAVED_SEARCH_TITLE); - await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ - state: 'visible', - }); + SAVED_SEARCH_ID, + SAVED_SEARCH_TITLE, + testData.DATA_VIEW_ID.LOGSTASH + ); + await pageObjects.dashboard.addPanelFromLibrary(SAVED_SEARCH_TITLE); + await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ + state: 'visible', + }); - await pageObjects.dashboard.saveDashboard('Dashboard with deleted saved search'); - await kbnClient.savedObjects.delete({ - type: 'search', - id: SAVED_SEARCH_ID, - }); + await pageObjects.dashboard.saveDashboard('Dashboard with deleted saved search'); + await kbnClient.savedObjects.delete({ + type: 'search', + id: SAVED_SEARCH_ID, + }); - await page.reload(); - await page.waitForLoadingIndicatorHidden(); - await expect( - page.testSubj.locator('embeddableError'), - 'Embeddable error should be displayed' - ).toBeVisible(); + await page.reload(); + await page.waitForLoadingIndicatorHidden(); + await expect( + page.testSubj.locator('embeddableError'), + 'Embeddable error should be displayed' + ).toBeVisible(); - await pageObjects.dashboard.removePanel('embeddableError'); - await expect( - page.testSubj.locator('embeddableError'), - 'Embeddable error should not be displayed' - ).toBeHidden(); - }); - } -); + await pageObjects.dashboard.removePanel('embeddableError'); + await expect( + page.testSubj.locator('embeddableError'), + 'Embeddable error should not be displayed' + ).toBeHidden(); + }); +}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts deleted file mode 100644 index 031860ecc2891..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/saved_searches.spec.ts +++ /dev/null @@ -1,123 +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 { expect } from '@kbn/scout'; -import { test, testData } from '../fixtures'; -import type { ExtScoutTestFixtures } from '../fixtures'; - -const assertNoFilterAndEmptyQuery = async ( - filterBadge: { field: string; value: string }, - pageObjects: ExtScoutTestFixtures['pageObjects'], - page: ExtScoutTestFixtures['page'] -) => { - expect( - // checking if filter exists, enabled or disabled - await pageObjects.filterBar.hasFilter(filterBadge), - `Filter ${JSON.stringify(filterBadge)} should not exist` - ).toBe(false); - await expect( - page.testSubj.locator('queryInput'), - 'Query Bar input field should be empty' - ).toHaveText(''); -}; - -const assertDataViewIsSelected = async (page: ExtScoutTestFixtures['page'], name: string) => - await expect( - page.testSubj.locator('*dataView-switch-link'), - 'Incorrect data view is selected' - ).toHaveText(name); - -test.describe('Discover app - saved searches', { tag: ['@ess', '@svlSearch', '@svlOblt'] }, () => { - // TODO: Update to use an ES archive with an index accessible to 'viewer' - // for running this test against the Security serverless project. - const START_TIME = '2019-04-27T23:56:51.374Z'; - const END_TIME = '2019-08-23T16:18:51.821Z'; - const PANEL_NAME = 'Ecommerce Data'; - const SEARCH_QUERY = 'customer_gender:MALE'; - const SAVED_SEARCH_NAME = 'test-unselect-saved-search'; - const filterFieldAndValue = { - field: 'category', - value: `Men's Shoes`, - }; - - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.ECOMMERCE); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DISCOVER); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.ECOMMERCE); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.ECOMMERCE, - 'timepicker:timeDefaults': `{ "from": "${START_TIME}", "to": "${END_TIME}"}`, - }); - }); - - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth }) => { - await browserAuth.loginAsPrivilegedUser(); - }); - - test('should customize time range on dashboards', async ({ pageObjects, page }) => { - await pageObjects.dashboard.goto(); - await pageObjects.dashboard.openNewDashboard(); - await pageObjects.dashboard.addPanelFromLibrary(PANEL_NAME); - await page.testSubj.locator('savedSearchTotalDocuments').waitFor({ - state: 'visible', - }); - - await pageObjects.dashboard.customizePanel({ - name: PANEL_NAME, - customTimeRageCommonlyUsed: { value: 'Last_90 days' }, - }); - await expect( - page.testSubj.locator('embeddedSavedSearchDocTable').locator('.euiDataGrid__noResults'), - 'No results message in Saved Search panel should be visible' - ).toBeVisible(); - }); - - test(`should unselect saved search when navigating to a 'new'`, async ({ pageObjects, page }) => { - await pageObjects.discover.goto(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - await pageObjects.filterBar.addFilter({ - ...filterFieldAndValue, - operator: 'is', - }); - await page.testSubj.fill('queryInput', SEARCH_QUERY); - await page.testSubj.click('querySubmitButton'); - await pageObjects.discover.waitForHistogramRendered(); - - await pageObjects.discover.saveSearch(SAVED_SEARCH_NAME); - await pageObjects.discover.waitForHistogramRendered(); - - expect( - await pageObjects.filterBar.hasFilter({ - ...filterFieldAndValue, - enabled: true, // Filter is enabled by default - }) - ).toBe(true); - await expect(page.testSubj.locator('queryInput')).toHaveText(SEARCH_QUERY); - - // create new search - await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // change data view - await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // change data view again - await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); - await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); - - // create new search again - await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); - }); -}); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions.spec.ts deleted file mode 100644 index 40b07726b31e4..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions.spec.ts +++ /dev/null @@ -1,59 +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 { expect, tags } from '@kbn/scout'; -import { test, testData, assertionMessages } from '../fixtures'; - -test.describe( - 'Discover app - value suggestions: useTimeRange enabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - }); - }); - - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('dont show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect(page.testSubj.locator('autoCompleteSuggestionText')).toHaveCount(0); - }); - - test('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - - test('also displays descriptions for operators', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw'); - await expect(page.testSubj.locator('^autocompleteSuggestion-operator')).toHaveCount(2); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts deleted file mode 100644 index d8035597fa0e4..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_non_time_based.spec.ts +++ /dev/null @@ -1,49 +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 { expect } from '@kbn/scout'; -import { test, testData, assertionMessages } from '../fixtures'; - -test.describe( - 'Discover app - value suggestions non-time based', - { tag: ['@ess', '@svlSearch', '@svlOblt'] }, - // TODO: Update to use an ES archive with an index accessible to 'viewer' - // for running this test against the Security serverless project. - () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.NO_TIME_FIELD); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); - await uiSettings.set({ - defaultIndex: 'without-timefield', - }); - }); - - test.afterAll(async ({ kbnClient, uiSettings }) => { - await uiSettings.unset('defaultIndex'); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('shows all auto-suggest options for a filter in discover context app', async ({ - page, - }) => { - await page.testSubj.fill('queryInput', 'type.keyword : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(1); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('"apache"'); - }); - } -); diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled.spec.ts deleted file mode 100644 index cce172ad8494c..0000000000000 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled.spec.ts +++ /dev/null @@ -1,62 +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 { expect, tags } from '@kbn/scout'; -import { test, testData, assertionMessages } from '../fixtures'; - -test.describe( - 'Discover app - value suggestions: useTimeRange disabled', - { tag: tags.DEPLOYMENT_AGNOSTIC }, - () => { - test.beforeAll(async ({ esArchiver, kbnClient, uiSettings }) => { - await esArchiver.loadIfNeeded(testData.ES_ARCHIVES.LOGSTASH); - await kbnClient.importExport.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await uiSettings.set({ - defaultIndex: testData.DATA_VIEW_ID.LOGSTASH, // TODO: investigate why it is required for `node scripts/playwright_test.js` run - 'timepicker:timeDefaults': `{ "from": "${testData.LOGSTASH_DEFAULT_START_TIME}", "to": "${testData.LOGSTASH_DEFAULT_END_TIME}"}`, - 'autocomplete:useTimeRange': false, - }); - }); - - test.afterAll(async ({ uiSettings, kbnClient }) => { - await uiSettings.unset('defaultIndex', 'timepicker:timeDefaults'); - await uiSettings.set({ 'autocomplete:useTimeRange': true }); - await kbnClient.savedObjects.cleanStandardList(); - }); - - test.beforeEach(async ({ browserAuth, pageObjects }) => { - await browserAuth.loginAsViewer(); - await pageObjects.discover.goto(); - }); - - test('show up if outside of range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_OUT_OF_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - - test('show up if in range', async ({ page, pageObjects }) => { - await pageObjects.datePicker.setAbsoluteRange(testData.LOGSTASH_IN_RANGE_DATES); - await page.testSubj.fill('queryInput', 'extension.raw : '); - await expect( - page.testSubj.locator('autoCompleteSuggestionText'), - assertionMessages.QUERY_BAR_VALIDATION.SUGGESTIONS_COUNT - ).toHaveCount(5); - const actualSuggestions = await page.testSubj - .locator('autoCompleteSuggestionText') - .allTextContents(); - expect(actualSuggestions.join(',')).toContain('jpg'); - }); - } -); From db1c6cb7e3710a98761bbd3ceacdc01da6b37d3b Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 22 Jan 2025 11:26:02 +0100 Subject: [PATCH 17/23] refactor and improve logging --- packages/kbn-scout/index.ts | 1 + .../fixtures/test/browser_auth/parallel.ts | 2 +- .../fixtures/test/page_objects/parallel.ts | 14 ++++--- .../fixtures/test/scout_page/parallel.ts | 6 +-- .../fixtures/test/scout_page/single_thread.ts | 1 + .../fixtures/worker/scout_space/parallel.ts | 35 ++++++++-------- .../playwright/global_hooks/data_ingestion.ts | 41 +++++++++++++++++++ .../src/playwright/global_hooks/index.ts | 10 +++++ packages/kbn-scout/src/playwright/index.ts | 2 + .../src/playwright/utils/runner_utils.ts | 2 +- .../ui_tests/parallel_tests/global_setup.ts | 27 ++---------- 11 files changed, 90 insertions(+), 51 deletions(-) create mode 100644 packages/kbn-scout/src/playwright/global_hooks/data_ingestion.ts create mode 100644 packages/kbn-scout/src/playwright/global_hooks/index.ts diff --git a/packages/kbn-scout/index.ts b/packages/kbn-scout/index.ts index f7c32d4e6868f..ebf6be8a5f01b 100644 --- a/packages/kbn-scout/index.ts +++ b/packages/kbn-scout/index.ts @@ -15,6 +15,7 @@ export { tags, createPlaywrightConfig, createLazyPageObject, + ingestTestDataHook, } from './src/playwright'; export type { ScoutPlaywrightOptions, diff --git a/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts b/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts index 14171b601397c..8af23fe7d629d 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/browser_auth/parallel.ts @@ -50,7 +50,7 @@ export const browserAuthParallelFixture = coreWorkerFixtures.extend< return loginAs(roleName); }; - log.debug(serviceLoadedMsg('browserAuth')); + log.debug(serviceLoadedMsg(`browserAuth:${scoutSpace.id}`)); await use({ loginAsAdmin, loginAsViewer, loginAsPrivilegedUser }); }, }); diff --git a/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts index c97d0608f2a9f..f5e70acfdf327 100644 --- a/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts +++ b/packages/kbn-scout/src/playwright/fixtures/test/page_objects/parallel.ts @@ -9,6 +9,7 @@ import { PageObjects, createCorePageObjects } from '../../../page_objects'; import { serviceLoadedMsg } from '../../../utils'; +import { ScoutSpaceParallelFixture } from '../../worker'; import { scoutPageParallelFixture } from '../scout_page'; /** @@ -19,12 +20,15 @@ import { scoutPageParallelFixture } from '../scout_page'; * * Note: Page Objects are lazily instantiated on first access. */ -export const pageObjectsParallelFixture = scoutPageParallelFixture.extend<{ - pageObjects: PageObjects; -}>({ - pageObjects: async ({ page, log }, use) => { +export const pageObjectsParallelFixture = scoutPageParallelFixture.extend< + { + pageObjects: PageObjects; + }, + { scoutSpace: ScoutSpaceParallelFixture } +>({ + pageObjects: async ({ page, log, scoutSpace }, use) => { const corePageObjects = createCorePageObjects(page); - log.debug(serviceLoadedMsg(`pageObjectsParallel`)); + log.debug(serviceLoadedMsg(`pageObjects:${scoutSpace.id}`)); await use(corePageObjects); }, }); 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 22993301a44af..e204ede97be5a 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 @@ -29,11 +29,11 @@ export const scoutPageParallelFixture = base.extend< ) => { const extendedPage = extendPlaywrightPage({ page, kbnUrl }); - // Overriding navigation to specific Kibana apps to take into account the worker space + // 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 })); - // Method to wait for global loading indicator to be hidden - log.debug(serviceLoadedMsg(`scoutPageParallel`)); + + log.debug(serviceLoadedMsg(`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 d3e3ee7704b20..f7b89ecfbae53 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 @@ -126,6 +126,7 @@ export const scoutPageFixture = coreWorkerFixtures.extend< use: (extendedPage: ScoutPage) => Promise ) => { const extendedPage = extendPlaywrightPage({ page, kbnUrl }); + log.debug(serviceLoadedMsg(`scoutPage`)); await use(extendedPage); }, diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts index 48ed1e2fd549b..ceb13cd2fcae9 100644 --- a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts @@ -18,13 +18,13 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< >({ scoutSpace: [ async ({ log, kbnClient }, use, workerInfo) => { - const id = `test-space-${workerInfo.workerIndex}`; + const spaceId = `test-space-${workerInfo.workerIndex}`; const spacePayload = { - id, - name: id, + id: spaceId, + name: spaceId, disabledFeatures: [], }; - log.debug(`Creating space ${id}`); + log.debug(`[scoutSpace] creating space ${spaceId}`); await kbnClient.spaces.create(spacePayload); // cache saved objects ids in space @@ -32,7 +32,7 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< const load = async (path: string) => { const response = await kbnClient.importExport.load(path, { - space: id, + space: spaceId, createNewCopies: true, }); @@ -48,8 +48,10 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< }; const cleanStandardList = async () => { + // reset cache + savedObjectsCache.clear(); return kbnClient.savedObjects.cleanStandardList({ - space: id, + space: spaceId, }); }; @@ -59,21 +61,20 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< { defaultIndex: savedObjectsCache.get(dataViewName)!, }, - { space: id } + { space: spaceId } ); } else { - throw new Error(`Data view id ${dataViewName} not found in space ${id}`); + throw new Error(`Data view id ${dataViewName} not found in space ${spaceId}`); } }; const set = async (values: UiSettingValues) => { - log.info(`Setting UI settings for space ${id}: ${JSON.stringify(values)}`); - return kbnClient.uiSettings.update(values, { space: id }); + log.info(`Setting UI settings for space ${spaceId}: ${JSON.stringify(values)}`); + return kbnClient.uiSettings.update(values, { space: spaceId }); }; const unset = async (...keys: string[]) => { - log.info(`Unsetting UI settings for space ${id}: ${keys}`); - return Promise.all(keys.map((key) => kbnClient.uiSettings.unset(key, { space: id }))); + return Promise.all(keys.map((key) => kbnClient.uiSettings.unset(key, { space: spaceId }))); }; const setDefaultTime = async ({ from, to }: { from: string; to: string }) => { const utcFrom = isValidUTCDate(from) ? from : formatTime(from); @@ -82,7 +83,7 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< { 'timepicker:timeDefaults': `{ "from": "${utcFrom}", "to": "${untcTo}"}`, }, - { space: id } + { space: spaceId } ); }; @@ -98,12 +99,12 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< setDefaultTime, }; - log.debug(serviceLoadedMsg(`scoutSpace`)); - await use({ savedObjects, uiSettings, id }); + log.debug(serviceLoadedMsg(`scoutSpace:${spaceId}`)); + await use({ savedObjects, uiSettings, id: spaceId }); // Cleanup space after tests via API call - log.debug(`Deleting space ${id}`); - await kbnClient.spaces.delete(id); + log.debug(`[scoutSpace] deleting space ${spaceId}`); + await kbnClient.spaces.delete(spaceId); }, { scope: 'worker', auto: true }, ], diff --git a/packages/kbn-scout/src/playwright/global_hooks/data_ingestion.ts b/packages/kbn-scout/src/playwright/global_hooks/data_ingestion.ts new file mode 100644 index 0000000000000..73bbb14af7cd9 --- /dev/null +++ b/packages/kbn-scout/src/playwright/global_hooks/data_ingestion.ts @@ -0,0 +1,41 @@ +/* + * 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 { performance } from 'perf_hooks'; +import { FullConfig } from 'playwright/test'; +import { + createEsArchiver, + createEsClient, + createKbnClient, + createLogger, + createScoutConfig, +} from '../../common'; +import { ScoutTestOptions } from '../types'; + +export async function ingestTestDataHook(config: FullConfig, archives: string[]) { + const startTime = performance.now(); + const log = createLogger(); + // TODO: This should be configurable local vs cloud + const configName = 'local'; + const projectUse = config.projects[0].use as ScoutTestOptions; + const serversConfigDir = projectUse.serversConfigDir; + const scoutConfig = createScoutConfig(serversConfigDir, configName, log); + + const esClient = createEsClient(scoutConfig, log); + const kbnCLient = createKbnClient(scoutConfig, log); + const esArchiver = createEsArchiver(esClient, kbnCLient, log); + + log.info('[scout setup] loading test data (only if indexes do not exist)...'); + for (const archive of archives) { + await esArchiver.loadIfNeeded(archive); + } + const endTime = performance.now() - startTime; + + log.info('[scout setup] test data loaded. Total time: %dms', endTime.toFixed(2)); +} diff --git a/packages/kbn-scout/src/playwright/global_hooks/index.ts b/packages/kbn-scout/src/playwright/global_hooks/index.ts new file mode 100644 index 0000000000000..2e2bcf6e8004c --- /dev/null +++ b/packages/kbn-scout/src/playwright/global_hooks/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 { ingestTestDataHook } from './data_ingestion'; diff --git a/packages/kbn-scout/src/playwright/index.ts b/packages/kbn-scout/src/playwright/index.ts index b2efcf95e7506..18733a477ef33 100644 --- a/packages/kbn-scout/src/playwright/index.ts +++ b/packages/kbn-scout/src/playwright/index.ts @@ -31,3 +31,5 @@ export type { // use to tag tests export { tags } from './tags'; + +export { ingestTestDataHook } from './global_hooks'; diff --git a/packages/kbn-scout/src/playwright/utils/runner_utils.ts b/packages/kbn-scout/src/playwright/utils/runner_utils.ts index fda016f9389c8..5fb84704ba710 100644 --- a/packages/kbn-scout/src/playwright/utils/runner_utils.ts +++ b/packages/kbn-scout/src/playwright/utils/runner_utils.ts @@ -11,7 +11,7 @@ import moment from 'moment'; import { Config } from '../../config'; import { tagsByMode } from '../tags'; -export const serviceLoadedMsg = (name: string) => `scout service loaded: ${name}`; +export const serviceLoadedMsg = (name: string) => `[scout service] ${name}`; export const isValidUTCDate = (date: string): boolean => { return !isNaN(Date.parse(date)) && new Date(date).toISOString() === date; diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/global_setup.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/global_setup.ts index 1fb251ce0c94e..d427909fe87d4 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/global_setup.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/global_setup.ts @@ -5,40 +5,19 @@ * 2.0. */ -import { ScoutTestOptions } from '@kbn/scout'; -import { - createEsArchiver, - createEsClient, - createKbnClient, - createLogger, - createScoutConfig, -} from '@kbn/scout/src/common'; +import { ingestTestDataHook } from '@kbn/scout'; import { type FullConfig } from '@playwright/test'; import { testData } from '../fixtures'; async function globalSetup(config: FullConfig) { - const log = createLogger(); - const configName = 'local'; - const projectUse = config.projects[0].use as ScoutTestOptions; - const serversConfigDir = projectUse.serversConfigDir; - const scoutConfig = createScoutConfig(serversConfigDir, configName, log); - - const esClient = createEsClient(scoutConfig, log); - const kbnCLient = createKbnClient(scoutConfig, log); - const esArchiver = createEsArchiver(esClient, kbnCLient, log); - + // add archives to load, if needed const archives = [ testData.ES_ARCHIVES.LOGSTASH, testData.ES_ARCHIVES.NO_TIME_FIELD, testData.ES_ARCHIVES.ECOMMERCE, ]; - // Load archives - log.info('Loading test data with esArchiver...'); - for (const archive of archives) { - await esArchiver.loadIfNeeded(archive); - } - log.info('Test data loaded.'); + return ingestTestDataHook(config, archives); } // eslint-disable-next-line import/no-default-export From 460cad760146106ad908a685304d85005d9a5366 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 22 Jan 2025 11:27:02 +0100 Subject: [PATCH 18/23] Update scout_ui_tests.sh --- .buildkite/scripts/steps/functional/scout_ui_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/scripts/steps/functional/scout_ui_tests.sh b/.buildkite/scripts/steps/functional/scout_ui_tests.sh index 7037bd1db6b97..49d2176f1bc5e 100755 --- a/.buildkite/scripts/steps/functional/scout_ui_tests.sh +++ b/.buildkite/scripts/steps/functional/scout_ui_tests.sh @@ -26,7 +26,7 @@ EXIT_CODE=0 # Discovery Enhanced parallel run for run_mode in "--stateful" "--serverless=es" "--serverless=oblt" "--serverless=security"; do - run_tests "Discovery Enhanced" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts" "$run_mode" + run_tests "Discovery Enhanced: Parallel Run" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts" "$run_mode" done # Discovery Enhanced From 181e491c30daa4758f9d0479ea6bff3b259bf019 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 22 Jan 2025 11:39:50 +0100 Subject: [PATCH 19/23] update tests --- .../playwright/fixtures/worker/scout_space/index.ts | 2 +- .../discover_enhanced/ui_tests/fixtures/constants.ts | 11 ++++++++++- .../ui_tests/parallel_tests/saved_searches.spec.ts | 12 ++++++------ .../parallel_tests/value_suggestions.spec.ts | 2 +- .../value_suggestions_non_time_based.spec.ts | 2 +- ...value_suggestions_use_time_range_disabled.spec.ts | 2 +- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/index.ts b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/index.ts index 70b91cb339918..13a620f999c28 100644 --- a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/index.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/index.ts @@ -30,7 +30,7 @@ export interface ScoutSpaceParallelFixture { cleanStandardList: () => Promise; }; uiSettings: { - setDefaultIndex: (dataViewId: string) => Promise; + setDefaultIndex: (dataViewName: string) => Promise; set: (values: UiSettingValues) => Promise; unset: (...keys: string[]) => Promise; setDefaultTime: ({ from, to }: { from: string; to: string }) => Promise; diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/constants.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/constants.ts index 60693ecfcba90..a35a370cf7c2c 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/constants.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/constants.ts @@ -8,15 +8,24 @@ export const LOGSTASH_DEFAULT_START_TIME = '2015-09-19T06:31:44.000Z'; export const LOGSTASH_DEFAULT_END_TIME = '2015-09-23T18:31:44.000Z'; +/** + * Should be used in "single thread" tests to set default Data View + * @example uiSettings.set({ defaultIndex: testData.DATA_VIEW_ID.ECOMMERCE }); + */ export const DATA_VIEW_ID = { ECOMMERCE: '5193f870-d861-11e9-a311-0fa548c5f953', LOGSTASH: 'logstash-*', NO_TIME_FIELD: 'c1e8af24-c7b7-4d9b-ab0e-e408c88d29c9', }; -export const DATA_VIEW = { +/** + * Should be used in "parallel tests" to set default Data View, because ids are generated and can't be hardcoded + * @example scoutSpace.uiSettings.setDefaultIndex(testData.DATA_VIEW_NAME.ECOMMERCE); + */ +export const DATA_VIEW_NAME = { ECOMMERCE: 'ecommerce', LOGSTASH: 'logstash-*', + NO_TIME_FIELD: 'without-timefield', }; export const LOGSTASH_OUT_OF_RANGE_DATES = { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts index 75ceb1f37116b..24130c6ec5e5d 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/saved_searches.spec.ts @@ -50,7 +50,7 @@ spaceTest.describe( spaceTest.beforeAll(async ({ scoutSpace }) => { await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DISCOVER); await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.ECOMMERCE); - await scoutSpace.uiSettings.setDefaultIndex('ecommerce'); + await scoutSpace.uiSettings.setDefaultIndex(testData.DATA_VIEW_NAME.ECOMMERCE); await scoutSpace.uiSettings.setDefaultTime({ from: START_TIME, to: END_TIME }); }); @@ -85,7 +85,7 @@ spaceTest.describe( `should unselect saved search when navigating to a 'new'`, async ({ pageObjects, page }) => { await pageObjects.discover.goto(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await assertDataViewIsSelected(page, testData.DATA_VIEW_NAME.ECOMMERCE); await pageObjects.filterBar.addFilter({ ...filterFieldAndValue, operator: 'is', @@ -107,20 +107,20 @@ spaceTest.describe( // create new search await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await assertDataViewIsSelected(page, testData.DATA_VIEW_NAME.ECOMMERCE); await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); // change data view - await pageObjects.discover.selectDataView(testData.DATA_VIEW.LOGSTASH); + await pageObjects.discover.selectDataView(testData.DATA_VIEW_NAME.LOGSTASH); await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); // change data view again - await pageObjects.discover.selectDataView(testData.DATA_VIEW.ECOMMERCE); + await pageObjects.discover.selectDataView(testData.DATA_VIEW_NAME.ECOMMERCE); await assertNoFilterAndEmptyQuery(filterFieldAndValue, pageObjects, page); // create new search again await pageObjects.discover.clickNewSearch(); - await assertDataViewIsSelected(page, testData.DATA_VIEW.ECOMMERCE); + await assertDataViewIsSelected(page, testData.DATA_VIEW_NAME.ECOMMERCE); } ); } diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts index dc16aa7d37419..64fe9869f3dc0 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions.spec.ts @@ -14,7 +14,7 @@ spaceTest.describe( () => { spaceTest.beforeAll(async ({ scoutSpace }) => { await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); + await scoutSpace.uiSettings.setDefaultIndex(testData.DATA_VIEW_NAME.LOGSTASH); await scoutSpace.uiSettings.setDefaultTime({ from: testData.LOGSTASH_DEFAULT_START_TIME, to: testData.LOGSTASH_DEFAULT_END_TIME, diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts index ac8093d7b9264..6bed83254f003 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_non_time_based.spec.ts @@ -16,7 +16,7 @@ spaceTest.describe( () => { spaceTest.beforeAll(async ({ scoutSpace }) => { await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.NO_TIME_FIELD); - await scoutSpace.uiSettings.setDefaultIndex('without-timefield'); + await scoutSpace.uiSettings.setDefaultIndex(testData.DATA_VIEW_NAME.NO_TIME_FIELD); }); spaceTest.afterAll(async ({ scoutSpace }) => { diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts index a7301a049c847..db90b22553bff 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel_tests/value_suggestions_use_time_range_disabled.spec.ts @@ -14,7 +14,7 @@ spaceTest.describe( () => { spaceTest.beforeAll(async ({ scoutSpace }) => { await scoutSpace.savedObjects.load(testData.KBN_ARCHIVES.DASHBOARD_DRILLDOWNS); - await scoutSpace.uiSettings.setDefaultIndex('logstash-*'); + await scoutSpace.uiSettings.setDefaultIndex(testData.DATA_VIEW_NAME.LOGSTASH); await scoutSpace.uiSettings.setDefaultTime({ from: testData.LOGSTASH_DEFAULT_START_TIME, to: testData.LOGSTASH_DEFAULT_END_TIME, From 46a9b7875cd3e0a96028efe9062d04a1f2ddcde1 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 22 Jan 2025 12:08:56 +0100 Subject: [PATCH 20/23] add perf tracking --- .../fixtures/worker/scout_space/parallel.ts | 81 ++++++++++++------- .../playwright/global_hooks/data_ingestion.ts | 36 +++++---- .../kbn-scout/src/playwright/utils/index.ts | 1 + .../src/playwright/utils/performance.ts | 22 +++++ 4 files changed, 95 insertions(+), 45 deletions(-) create mode 100644 packages/kbn-scout/src/playwright/utils/performance.ts diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts index ceb13cd2fcae9..3df9cadc51519 100644 --- a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts @@ -8,7 +8,7 @@ */ import { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; -import { formatTime, isValidUTCDate, serviceLoadedMsg } from '../../../utils'; +import { formatTime, isValidUTCDate, measurePerformance, serviceLoadedMsg } from '../../../utils'; import { coreWorkerFixtures } from '..'; import { ImportSavedObjects, ScoutSpaceParallelFixture } from '.'; @@ -24,13 +24,15 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< name: spaceId, disabledFeatures: [], }; - log.debug(`[scoutSpace] creating space ${spaceId}`); - await kbnClient.spaces.create(spacePayload); + await measurePerformance(log, `scoutSpace:${spaceId} 'spaces.create'`, async () => { + return kbnClient.spaces.create(spacePayload); + }); // cache saved objects ids in space const savedObjectsCache = new Map(); const load = async (path: string) => { + const startTime = performance.now(); const response = await kbnClient.importExport.load(path, { space: spaceId, createNewCopies: true, @@ -44,46 +46,66 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< results.forEach((r) => savedObjectsCache.set(r.title, r.id)); + const endTime = performance.now() - startTime; + log.debug(`scoutSpace:${spaceId} 'savedObjects.load' took ${endTime.toFixed(2)}ms`); return results; }; const cleanStandardList = async () => { - // reset cache - savedObjectsCache.clear(); - return kbnClient.savedObjects.cleanStandardList({ - space: spaceId, - }); + return measurePerformance( + log, + `scoutSpace:${spaceId} 'savedObjects.cleanStandardList'`, + async () => { + savedObjectsCache.clear(); + await kbnClient.savedObjects.cleanStandardList({ + space: spaceId, + }); + } + ); }; const setDefaultIndex = async (dataViewName: string) => { - if (savedObjectsCache.has(dataViewName)) { - await kbnClient.uiSettings.update( - { - defaultIndex: savedObjectsCache.get(dataViewName)!, - }, - { space: spaceId } - ); - } else { - throw new Error(`Data view id ${dataViewName} not found in space ${spaceId}`); - } + return measurePerformance( + log, + `scoutSpace:${spaceId} 'savedObjects.setDefaultIndex'`, + async () => { + if (savedObjectsCache.has(dataViewName)) { + return kbnClient.uiSettings.update( + { + defaultIndex: savedObjectsCache.get(dataViewName)!, + }, + { space: spaceId } + ); + } else { + throw new Error(`Data view id ${dataViewName} not found in space ${spaceId}`); + } + } + ); }; const set = async (values: UiSettingValues) => { - log.info(`Setting UI settings for space ${spaceId}: ${JSON.stringify(values)}`); - return kbnClient.uiSettings.update(values, { space: spaceId }); + return measurePerformance(log, `scoutSpace:${spaceId} 'uiSettings.set'`, async () => { + return kbnClient.uiSettings.update(values, { space: spaceId }); + }); }; const unset = async (...keys: string[]) => { return Promise.all(keys.map((key) => kbnClient.uiSettings.unset(key, { space: spaceId }))); }; const setDefaultTime = async ({ from, to }: { from: string; to: string }) => { - const utcFrom = isValidUTCDate(from) ? from : formatTime(from); - const untcTo = isValidUTCDate(to) ? to : formatTime(to); - await kbnClient.uiSettings.update( - { - 'timepicker:timeDefaults': `{ "from": "${utcFrom}", "to": "${untcTo}"}`, - }, - { space: spaceId } + return measurePerformance( + log, + `scoutSpace:${spaceId} 'uiSettings.setDefaultTime'`, + async () => { + const utcFrom = isValidUTCDate(from) ? from : formatTime(from); + const untcTo = isValidUTCDate(to) ? to : formatTime(to); + return kbnClient.uiSettings.update( + { + 'timepicker:timeDefaults': `{ "from": "${utcFrom}", "to": "${untcTo}"}`, + }, + { space: spaceId } + ); + } ); }; @@ -103,8 +125,9 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< await use({ savedObjects, uiSettings, id: spaceId }); // Cleanup space after tests via API call - log.debug(`[scoutSpace] deleting space ${spaceId}`); - await kbnClient.spaces.delete(spaceId); + await measurePerformance(log, `scoutSpace:${spaceId} 'space.delete'`, async () => { + return kbnClient.spaces.delete(spaceId); + }); }, { scope: 'worker', auto: true }, ], diff --git a/packages/kbn-scout/src/playwright/global_hooks/data_ingestion.ts b/packages/kbn-scout/src/playwright/global_hooks/data_ingestion.ts index 73bbb14af7cd9..092665d731524 100644 --- a/packages/kbn-scout/src/playwright/global_hooks/data_ingestion.ts +++ b/packages/kbn-scout/src/playwright/global_hooks/data_ingestion.ts @@ -7,7 +7,6 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { performance } from 'perf_hooks'; import { FullConfig } from 'playwright/test'; import { createEsArchiver, @@ -17,25 +16,30 @@ import { createScoutConfig, } from '../../common'; import { ScoutTestOptions } from '../types'; +import { measurePerformance } from '../utils'; export async function ingestTestDataHook(config: FullConfig, archives: string[]) { - const startTime = performance.now(); const log = createLogger(); - // TODO: This should be configurable local vs cloud - const configName = 'local'; - const projectUse = config.projects[0].use as ScoutTestOptions; - const serversConfigDir = projectUse.serversConfigDir; - const scoutConfig = createScoutConfig(serversConfigDir, configName, log); - const esClient = createEsClient(scoutConfig, log); - const kbnCLient = createKbnClient(scoutConfig, log); - const esArchiver = createEsArchiver(esClient, kbnCLient, log); - - log.info('[scout setup] loading test data (only if indexes do not exist)...'); - for (const archive of archives) { - await esArchiver.loadIfNeeded(archive); + if (archives.length === 0) { + log.info('[scout setup] no test data to ingest'); + return; } - const endTime = performance.now() - startTime; - log.info('[scout setup] test data loaded. Total time: %dms', endTime.toFixed(2)); + return measurePerformance(log, '[scout setup]: ingestTestDataHook', async () => { + // TODO: This should be configurable local vs cloud + const configName = 'local'; + const projectUse = config.projects[0].use as ScoutTestOptions; + const serversConfigDir = projectUse.serversConfigDir; + const scoutConfig = createScoutConfig(serversConfigDir, configName, log); + + const esClient = createEsClient(scoutConfig, log); + const kbnCLient = createKbnClient(scoutConfig, log); + const esArchiver = createEsArchiver(esClient, kbnCLient, log); + + log.info('[scout setup] loading test data (only if indexes do not exist)...'); + for (const archive of archives) { + await esArchiver.loadIfNeeded(archive); + } + }); } diff --git a/packages/kbn-scout/src/playwright/utils/index.ts b/packages/kbn-scout/src/playwright/utils/index.ts index 347fe7f22d05b..702e01829b2ca 100644 --- a/packages/kbn-scout/src/playwright/utils/index.ts +++ b/packages/kbn-scout/src/playwright/utils/index.ts @@ -8,3 +8,4 @@ */ export { serviceLoadedMsg, isValidUTCDate, formatTime, getPlaywrightGrepTag } from './runner_utils'; +export { measurePerformance } from './performance'; diff --git a/packages/kbn-scout/src/playwright/utils/performance.ts b/packages/kbn-scout/src/playwright/utils/performance.ts new file mode 100644 index 0000000000000..fa4d78530d1f8 --- /dev/null +++ b/packages/kbn-scout/src/playwright/utils/performance.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", 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 { ToolingLog } from '../../types'; + +export const measurePerformance = async ( + log: ToolingLog, + label: string, + fn: () => Promise +): Promise => { + const startTime = performance.now(); + const result = await fn(); + const duration = performance.now() - startTime; + log.debug(`${label} took ${duration.toFixed(2)}ms`); + return result; +}; From 9fdb46bd8c54a40ad0041c6eb3d86849cc868853 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Wed, 22 Jan 2025 15:29:58 +0100 Subject: [PATCH 21/23] adjust perf tracking for all calls in scoutSpace --- .../fixtures/worker/scout_space/parallel.ts | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts index 3df9cadc51519..aa1b99f0c5795 100644 --- a/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts +++ b/packages/kbn-scout/src/playwright/fixtures/worker/scout_space/parallel.ts @@ -32,25 +32,24 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< const savedObjectsCache = new Map(); const load = async (path: string) => { - const startTime = performance.now(); - const response = await kbnClient.importExport.load(path, { - space: spaceId, - createNewCopies: true, - }); + return measurePerformance(log, `scoutSpace:${spaceId} 'savedObjects.load'`, async () => { + const response = await kbnClient.importExport.load(path, { + space: spaceId, + // will create new copies of saved objects with unique ids + createNewCopies: true, + }); - const results = (response.successResults as ImportSavedObjects[]).map( - (r: { type: string; destinationId: string; meta: { title: string } }) => { - return { id: r.destinationId, type: r.type, title: r.meta.title }; - } - ); + const imported = (response.successResults as ImportSavedObjects[]).map( + (r: { type: string; destinationId: string; meta: { title: string } }) => { + return { id: r.destinationId, type: r.type, title: r.meta.title }; + } + ); - results.forEach((r) => savedObjectsCache.set(r.title, r.id)); + imported.forEach((so) => savedObjectsCache.set(so.title, so.id)); - const endTime = performance.now() - startTime; - log.debug(`scoutSpace:${spaceId} 'savedObjects.load' took ${endTime.toFixed(2)}ms`); - return results; + return imported; + }); }; - const cleanStandardList = async () => { return measurePerformance( log, @@ -63,7 +62,6 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< } ); }; - const setDefaultIndex = async (dataViewName: string) => { return measurePerformance( log, @@ -82,15 +80,17 @@ export const scoutSpaceParallelFixture = coreWorkerFixtures.extend< } ); }; - const set = async (values: UiSettingValues) => { return measurePerformance(log, `scoutSpace:${spaceId} 'uiSettings.set'`, async () => { return kbnClient.uiSettings.update(values, { space: spaceId }); }); }; - const unset = async (...keys: string[]) => { - return Promise.all(keys.map((key) => kbnClient.uiSettings.unset(key, { space: spaceId }))); + return measurePerformance(log, `scoutSpace:${spaceId} 'uiSettings.unset'`, async () => { + return Promise.all( + keys.map((key) => kbnClient.uiSettings.unset(key, { space: spaceId })) + ); + }); }; const setDefaultTime = async ({ from, to }: { from: string; to: string }) => { return measurePerformance( From 63ebf599f3181535f7ca9bbf5f6af47add365f88 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Thu, 23 Jan 2025 12:46:18 +0100 Subject: [PATCH 22/23] update ci script --- .buildkite/scripts/steps/functional/scout_ui_tests.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.buildkite/scripts/steps/functional/scout_ui_tests.sh b/.buildkite/scripts/steps/functional/scout_ui_tests.sh index 49d2176f1bc5e..9eb31b6b0e6b1 100755 --- a/.buildkite/scripts/steps/functional/scout_ui_tests.sh +++ b/.buildkite/scripts/steps/functional/scout_ui_tests.sh @@ -24,13 +24,9 @@ run_tests() { EXIT_CODE=0 -# Discovery Enhanced parallel run -for run_mode in "--stateful" "--serverless=es" "--serverless=oblt" "--serverless=security"; do - run_tests "Discovery Enhanced: Parallel Run" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts" "$run_mode" -done - # Discovery Enhanced for run_mode in "--stateful" "--serverless=es" "--serverless=oblt" "--serverless=security"; do + run_tests "Discovery Enhanced: Parallel Workers" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts" "$run_mode" run_tests "Discovery Enhanced" "x-pack/platform/plugins/private/discover_enhanced/ui_tests/playwright.config.ts" "$run_mode" done From b07a636f722dbfd978b54221e1d462c79da10c71 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Thu, 23 Jan 2025 15:58:11 +0100 Subject: [PATCH 23/23] rename types/vars --- packages/kbn-scout/index.ts | 4 ++-- .../src/playwright/fixtures/parallel_run_fixtures.ts | 6 +++--- packages/kbn-scout/src/playwright/index.ts | 8 ++++---- .../private/discover_enhanced/ui_tests/fixtures/index.ts | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/kbn-scout/index.ts b/packages/kbn-scout/index.ts index ebf6be8a5f01b..f34074452be61 100644 --- a/packages/kbn-scout/index.ts +++ b/packages/kbn-scout/index.ts @@ -24,8 +24,8 @@ export type { PageObjects, ScoutTestFixtures, ScoutWorkerFixtures, - ScoutParallelRunTestFixtures, - ScoutParallelRunWorkerFixtures, + ScoutParallelTestFixtures, + ScoutParallelWorkerFixtures, } from './src/playwright'; export type { Client, KbnClient, KibanaUrl, SamlSessionManager, ToolingLog } from './src/types'; 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 018ab682f5ba8..6a171ca029e60 100644 --- a/packages/kbn-scout/src/playwright/fixtures/parallel_run_fixtures.ts +++ b/packages/kbn-scout/src/playwright/fixtures/parallel_run_fixtures.ts @@ -25,7 +25,7 @@ import { } from './test'; import type { BrowserAuthFixture, ScoutPage, PageObjects } from './test'; -export const scoutParallelRunFixtures = mergeTests( +export const scoutParallelFixtures = mergeTests( // worker scope fixtures coreWorkerFixtures, scoutSpaceParallelFixture, @@ -36,13 +36,13 @@ export const scoutParallelRunFixtures = mergeTests( validateTagsFixture ); -export interface ScoutParallelRunTestFixtures { +export interface ScoutParallelTestFixtures { browserAuth: BrowserAuthFixture; page: ScoutPage; pageObjects: PageObjects; } -export interface ScoutParallelRunWorkerFixtures { +export interface ScoutParallelWorkerFixtures { log: ToolingLog; config: ScoutTestConfig; kbnUrl: KibanaUrl; diff --git a/packages/kbn-scout/src/playwright/index.ts b/packages/kbn-scout/src/playwright/index.ts index 18733a477ef33..b5c0f125b8165 100644 --- a/packages/kbn-scout/src/playwright/index.ts +++ b/packages/kbn-scout/src/playwright/index.ts @@ -7,13 +7,13 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { scoutFixtures, scoutParallelRunFixtures } from './fixtures'; +import { scoutFixtures, scoutParallelFixtures } from './fixtures'; // Scout core fixtures: worker & test scope export const test = scoutFixtures; // Scout core 'space aware' fixtures: worker & test scope -export const spaceTest = scoutParallelRunFixtures; +export const spaceTest = scoutParallelFixtures; export { createPlaywrightConfig } from './config'; export { createLazyPageObject } from './page_objects/utils'; @@ -23,8 +23,8 @@ export type { ScoutPlaywrightOptions, ScoutTestOptions } from './types'; export type { ScoutTestFixtures, ScoutWorkerFixtures, - ScoutParallelRunTestFixtures, - ScoutParallelRunWorkerFixtures, + ScoutParallelTestFixtures, + ScoutParallelWorkerFixtures, ScoutPage, PageObjects, } from './fixtures'; diff --git a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts index 7177439dff74c..1be4d85f151e0 100644 --- a/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts +++ b/x-pack/platform/plugins/private/discover_enhanced/ui_tests/fixtures/index.ts @@ -12,8 +12,8 @@ import { createLazyPageObject, ScoutTestFixtures, ScoutWorkerFixtures, - ScoutParallelRunTestFixtures, - ScoutParallelRunWorkerFixtures, + ScoutParallelTestFixtures, + ScoutParallelWorkerFixtures, } from '@kbn/scout'; import { DemoPage } from './page_objects'; @@ -43,7 +43,7 @@ export const test = baseTest.extend({ }, }); -export interface ExtParallelRunTestFixtures extends ScoutParallelRunTestFixtures { +export interface ExtParallelRunTestFixtures extends ScoutParallelTestFixtures { pageObjects: PageObjects & { demo: DemoPage; }; @@ -51,7 +51,7 @@ export interface ExtParallelRunTestFixtures extends ScoutParallelRunTestFixtures export const spaceTest = spaceBaseTest.extend< ExtParallelRunTestFixtures, - ScoutParallelRunWorkerFixtures + ScoutParallelWorkerFixtures >({ pageObjects: async ( {