diff --git a/.buildkite/ftr_platform_stateful_configs.yml b/.buildkite/ftr_platform_stateful_configs.yml index 23297f9f834ea..e31245251ffa3 100644 --- a/.buildkite/ftr_platform_stateful_configs.yml +++ b/.buildkite/ftr_platform_stateful_configs.yml @@ -292,7 +292,6 @@ enabled: - x-pack/platform/test/functional_cloud/intercepts.config.ts - x-pack/platform/test/licensing_plugin/config.public.ts - x-pack/platform/test/licensing_plugin/config.ts - - x-pack/platform/test/plugin_functional/config.ts - x-pack/platform/test/product_intercepts_functional/config.ts - x-pack/platform/test/reporting_api_integration/reporting_and_security.config.ts - x-pack/platform/test/reporting_api_integration/reporting_without_security.config.ts diff --git a/.buildkite/scout_ci_config.yml b/.buildkite/scout_ci_config.yml index 51dcd7a4694bb..f840efb14ba19 100644 --- a/.buildkite/scout_ci_config.yml +++ b/.buildkite/scout_ci_config.yml @@ -27,6 +27,7 @@ plugins: - transform - dashboard - workflows_extensions + - global_search disabled: packages: diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f2fa6f1db60fe..56134d2680859 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1151,7 +1151,6 @@ x-pack/platform/test/plugin_api_integration/plugins/event_log @elastic/response- x-pack/platform/test/plugin_api_integration/plugins/feature_usage_test @elastic/kibana-security x-pack/platform/test/plugin_api_integration/plugins/sample_task_plugin @elastic/response-ops x-pack/platform/test/plugin_api_perf/plugins/task_manager_performance @elastic/response-ops -x-pack/platform/test/plugin_functional/plugins/global_search_test @elastic/kibana-core x-pack/platform/test/reporting_api_integration/plugins/reporting_fixture @elastic/response-ops x-pack/platform/test/reporting_api_integration/plugins/reporting_test_routes @elastic/response-ops x-pack/platform/test/saved_object_api_integration/common/plugins/saved_object_test_plugin @elastic/kibana-security @@ -3179,7 +3178,6 @@ x-pack/solutions/observability/plugins/observability_shared/public/components/pr /src/platform/test/accessibility/apps/home.ts @elastic/appex-sharedux # Assigned per https://github.com/elastic/kibana/pull/199771/files#r1840077237 /src/platform/test/api_integration/apis/home/*.ts @elastic/appex-sharedux # Assigned per https://github.com/elastic/kibana/pull/199771/files#r1840077065 /src/platform/test/functional/apps/home @elastic/appex-sharedux # Assigned per https://github.com/elastic/kibana/pull/199771/files#r1840075278 -/x-pack/platform/test/plugin_functional/plugins/global_search_test @elastic/appex-sharedux /src/platform/test/functional/services/saved_objects_finder.ts @elastic/appex-sharedux /src/platform/test/functional/apps/kibana_overview @elastic/appex-sharedux /x-pack/platform/test/functional_cloud @elastic/appex-sharedux diff --git a/package.json b/package.json index 15173745a0ee9..190a7c080599d 100644 --- a/package.json +++ b/package.json @@ -661,7 +661,6 @@ "@kbn/global-search-bar-plugin": "link:x-pack/platform/plugins/private/global_search_bar", "@kbn/global-search-plugin": "link:x-pack/platform/plugins/shared/global_search", "@kbn/global-search-providers-plugin": "link:x-pack/platform/plugins/private/global_search_providers", - "@kbn/global-search-test-plugin": "link:x-pack/platform/test/plugin_functional/plugins/global_search_test", "@kbn/graph-plugin": "link:x-pack/platform/plugins/private/graph", "@kbn/grid-example-plugin": "link:examples/grid_example", "@kbn/grid-layout": "link:src/platform/packages/private/kbn-grid-layout", diff --git a/packages/kbn-plugin-generator/src/ask_questions.ts b/packages/kbn-plugin-generator/src/ask_questions.ts index d6fdc8264c565..d3ba4844057b2 100644 --- a/packages/kbn-plugin-generator/src/ask_questions.ts +++ b/packages/kbn-plugin-generator/src/ask_questions.ts @@ -61,10 +61,6 @@ export const INTERNAL_PLUGIN_LOCATIONS: Array<{ name: string; value: string }> = name: `X-Pack ${solution}`, value: Path.resolve(REPO_ROOT, `x-pack/solutions/${solution}/plugins`), })), - { - name: 'X-Pack Functional Testing', - value: Path.resolve(REPO_ROOT, 'x-pack/platform/test/plugin_functional/plugins'), - }, ]; export const QUESTIONS = [ diff --git a/src/dev/code_coverage/docs/team_assignment/README.md b/src/dev/code_coverage/docs/team_assignment/README.md index ed1ad331a4d06..aad6c22ac7e33 100644 --- a/src/dev/code_coverage/docs/team_assignment/README.md +++ b/src/dev/code_coverage/docs/team_assignment/README.md @@ -17,8 +17,6 @@ _notice the coverage delimiter `#CC# ...`_ ``` /x-pack/solutions/security/test/fixtures/es_archives/endpoint/ @elastic/endpoint-app-team @elastic/siem -/x-pack/platform/test/plugin_functional/plugins/resolver_test/ @elastic/endpoint-app-team @elastic/siem -/x-pack/platform/test/plugin_functional/test_suites/resolver/ @elastic/endpoint-app-team @elastic/siem #CC# /x-pack/legacy/plugins/siem/ @elastic/siem #CC# /x-pack/plugins/siem/ @elastic/siem #CC# /x-pack/solutions/security/plugins/security_solution/ @elastic/siem diff --git a/tsconfig.base.json b/tsconfig.base.json index dfc53952f3177..2e8d11b3a72ec 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1242,8 +1242,6 @@ "@kbn/global-search-plugin/*": ["x-pack/platform/plugins/shared/global_search/*"], "@kbn/global-search-providers-plugin": ["x-pack/platform/plugins/private/global_search_providers"], "@kbn/global-search-providers-plugin/*": ["x-pack/platform/plugins/private/global_search_providers/*"], - "@kbn/global-search-test-plugin": ["x-pack/platform/test/plugin_functional/plugins/global_search_test"], - "@kbn/global-search-test-plugin/*": ["x-pack/platform/test/plugin_functional/plugins/global_search_test/*"], "@kbn/graph-plugin": ["x-pack/platform/plugins/private/graph"], "@kbn/graph-plugin/*": ["x-pack/platform/plugins/private/graph/*"], "@kbn/grid-example-plugin": ["examples/grid_example"], diff --git a/x-pack/platform/plugins/shared/global_search/moon.yml b/x-pack/platform/plugins/shared/global_search/moon.yml index f603f46530c62..359f6769e16ad 100644 --- a/x-pack/platform/plugins/shared/global_search/moon.yml +++ b/x-pack/platform/plugins/shared/global_search/moon.yml @@ -26,6 +26,7 @@ dependsOn: - '@kbn/utility-types' - '@kbn/core-test-helpers-test-utils' - '@kbn/licensing-types' + - '@kbn/scout' tags: - plugin - prod @@ -37,6 +38,7 @@ fileGroups: - public/**/* - server/**/* - common/**/* + - test/**/* - '!target/**/*' tasks: jest: diff --git a/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/constants.ts b/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/constants.ts new file mode 100644 index 0000000000000..d39d2701d5061 --- /dev/null +++ b/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/constants.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export const KBN_ARCHIVES = { + BASIC: + 'x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/kbn_archives/basic.json', + SEARCH_SYNTAX: + 'x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/kbn_archives/search_syntax.json', +}; diff --git a/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/index.ts b/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/index.ts new file mode 100644 index 0000000000000..a205bca8d0b36 --- /dev/null +++ b/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { ScoutPage, ScoutTestFixtures, ScoutWorkerFixtures } from '@kbn/scout'; +import { test as baseTest } from '@kbn/scout'; +import type { GlobalSearchPageObjects } from './page_objects'; +import { extendPageObjects } from './page_objects'; + +export interface GlobalSearchTestFixtures extends ScoutTestFixtures { + pageObjects: GlobalSearchPageObjects; +} + +export const test = baseTest.extend({ + pageObjects: async ( + { + pageObjects, + page, + }: { + pageObjects: GlobalSearchPageObjects; + page: ScoutPage; + }, + use: (pageObjects: GlobalSearchPageObjects) => Promise + ) => { + const extendedPageObjects = extendPageObjects(pageObjects, page); + await use(extendedPageObjects); + }, +}); diff --git a/x-pack/platform/test/functional/fixtures/kbn_archives/global_search/basic.json b/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/kbn_archives/basic.json similarity index 100% rename from x-pack/platform/test/functional/fixtures/kbn_archives/global_search/basic.json rename to x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/kbn_archives/basic.json diff --git a/x-pack/platform/test/functional/fixtures/kbn_archives/global_search/search_syntax.json b/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/kbn_archives/search_syntax.json similarity index 100% rename from x-pack/platform/test/functional/fixtures/kbn_archives/global_search/search_syntax.json rename to x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/kbn_archives/search_syntax.json diff --git a/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/page_objects/global_search.ts b/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/page_objects/global_search.ts new file mode 100644 index 0000000000000..0193117cec637 --- /dev/null +++ b/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/page_objects/global_search.ts @@ -0,0 +1,97 @@ +/* + * 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/ui'; +import type { ScoutPage } from '@kbn/scout'; + +interface SearchResult { + label: string; +} + +export class GlobalSearch { + constructor(private readonly page: ScoutPage) {} + + async navigateToHome() { + await this.page.gotoApp('home'); + } + + async focus() { + await this.page.testSubj.click('nav-search-input'); + } + + async blur() { + // Click help menu button twice to close the search popover + await this.page.testSubj.click('helpMenuButton'); + await this.page.testSubj.click('helpMenuButton'); + await this.page.locator('.navSearch__panel').waitFor({ state: 'hidden', timeout: 5000 }); + } + + async searchFor( + term: string, + { clear = true, wait = true }: { clear?: boolean; wait?: boolean } = {} + ) { + if (clear) { + await this.clearField(); + } + await this.page.testSubj.fill('nav-search-input', term); + if (wait) { + await this.waitForResultsLoaded(); + } + } + + async getFieldValue() { + return await this.page.testSubj.locator('nav-search-input').inputValue(); + } + + async clearField() { + await this.page.testSubj.locator('nav-search-input').clear(); + } + + async isPopoverDisplayed() { + return await this.page.locator('.navSearch__panel').isVisible(); + } + + async clickOnOption(index: number) { + const options = await this.page.testSubj.locator('nav-search-option').all(); + await options[index].click(); + } + + async waitForResultsLoaded() { + // Wait for at least one option to appear + await this.page.testSubj.waitForSelector('nav-search-option'); + + // Results are emitted in multiple batches. Poll the result count to ensure + // all batches have been received (count stabilizes when no more results are coming). + await expect(async () => { + const count = await this.page.testSubj.locator('nav-search-option').count(); + expect(count).toBeGreaterThan(0); + }).toPass({ timeout: 10000, intervals: [500, 1000] }); + } + + async getDisplayedResults(): Promise { + const resultElements = await this.page.testSubj.locator('nav-search-option').all(); + const results: SearchResult[] = []; + + for (const resultEl of resultElements) { + const labelEl = resultEl.locator('.euiSelectableTemplateSitewide__listItemTitle'); + const label = await labelEl.textContent(); + if (label) { + results.push({ label: label.trim() }); + } + } + + return results; + } + + async isNoResultsPlaceholderDisplayed() { + await this.page.getByRole('status').getByTestId('nav-search-no-results').waitFor({ + state: 'visible', + timeout: 5000, + }); + return true; + } +} diff --git a/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/page_objects/index.ts b/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/page_objects/index.ts new file mode 100644 index 0000000000000..6d2566c0010b4 --- /dev/null +++ b/x-pack/platform/plugins/shared/global_search/test/scout/ui/fixtures/page_objects/index.ts @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { PageObjects, ScoutPage } from '@kbn/scout'; +import { createLazyPageObject } from '@kbn/scout'; +import { GlobalSearch } from './global_search'; + +export interface GlobalSearchPageObjects extends PageObjects { + globalSearch: GlobalSearch; +} + +export function extendPageObjects( + pageObjects: PageObjects, + page: ScoutPage +): GlobalSearchPageObjects { + return { + ...pageObjects, + globalSearch: createLazyPageObject(GlobalSearch, page), + }; +} diff --git a/x-pack/platform/test/plugin_functional/page_objects.ts b/x-pack/platform/plugins/shared/global_search/test/scout/ui/playwright.config.ts similarity index 67% rename from x-pack/platform/test/plugin_functional/page_objects.ts rename to x-pack/platform/plugins/shared/global_search/test/scout/ui/playwright.config.ts index d97010fb1bac9..75a7694d12043 100644 --- a/x-pack/platform/test/plugin_functional/page_objects.ts +++ b/x-pack/platform/plugins/shared/global_search/test/scout/ui/playwright.config.ts @@ -5,4 +5,8 @@ * 2.0. */ -export { pageObjects } from '../functional/page_objects'; +import { createPlaywrightConfig } from '@kbn/scout'; + +export default createPlaywrightConfig({ + testDir: './tests', +}); diff --git a/x-pack/platform/plugins/shared/global_search/test/scout/ui/tests/global_search_bar.spec.ts b/x-pack/platform/plugins/shared/global_search/test/scout/ui/tests/global_search_bar.spec.ts new file mode 100644 index 0000000000000..b5565c1582bcf --- /dev/null +++ b/x-pack/platform/plugins/shared/global_search/test/scout/ui/tests/global_search_bar.spec.ts @@ -0,0 +1,217 @@ +/* + * 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 { tags } from '@kbn/scout'; +import { expect } from '@kbn/scout/ui'; +import { test } from '../fixtures'; +import { KBN_ARCHIVES } from '../fixtures/constants'; + +/** + * IMPORTANT: These tests only work in 'classic' navigation mode. Once https://github.com/elastic/kibana/pull/251436 is merged, we might need to revisit this and make them work in 'solution' navigation as well. + */ +test.describe('GlobalSearchBar', { tag: tags.ESS_ONLY }, () => { + test.beforeAll(async ({ kbnClient }) => { + await kbnClient.savedObjects.cleanStandardList(); + await kbnClient.importExport.load(KBN_ARCHIVES.SEARCH_SYNTAX); + }); + + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.globalSearch.navigateToHome(); + }); + + test.afterAll(async ({ kbnClient }) => { + await kbnClient.savedObjects.cleanStandardList(); + }); + + test('shows the popover on focus', async ({ pageObjects }) => { + await pageObjects.globalSearch.focus(); + expect(await pageObjects.globalSearch.isPopoverDisplayed()).toBe(true); + + await pageObjects.globalSearch.blur(); + expect(await pageObjects.globalSearch.isPopoverDisplayed()).toBe(false); + }); + + test('redirects to the correct page', async ({ page, pageObjects }) => { + await pageObjects.globalSearch.searchFor('type:application discover'); + await pageObjects.globalSearch.clickOnOption(0); + + expect(page.url()).toContain('discover'); + }); + + test('shows a suggestion when searching for a term matching a type', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('dashboard'); + + let results = await pageObjects.globalSearch.getDisplayedResults(); + expect(results.length).toBeGreaterThan(0); + expect(results[0].label).toBe('type: dashboard'); + + await pageObjects.globalSearch.clickOnOption(0); + await pageObjects.globalSearch.waitForResultsLoaded(); + + const searchTerm = await pageObjects.globalSearch.getFieldValue(); + expect(searchTerm).toBe('type:dashboard'); + + results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + expect(labels).toStrictEqual([ + 'dashboard 1 (tag-2)', + 'dashboard 2 (tag-3)', + 'dashboard 3 (tag-1 and tag-3)', + 'dashboard 4 (tag-special-chars)', + ]); + }); + + test('shows a suggestion when searching for a term matching a tag name', async ({ + pageObjects, + }) => { + await pageObjects.globalSearch.searchFor('tag-1'); + + let results = await pageObjects.globalSearch.getDisplayedResults(); + expect(results[0].label).toBe('tag: tag-1'); + + await pageObjects.globalSearch.clickOnOption(0); + await pageObjects.globalSearch.waitForResultsLoaded(); + + const searchTerm = await pageObjects.globalSearch.getFieldValue(); + expect(searchTerm).toBe('tag:tag-1'); + + results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + expect(labels).toStrictEqual([ + 'Visualization 1 (tag-1)', + 'Visualization 3 (tag-1 + tag-3)', + 'dashboard 3 (tag-1 and tag-3)', + ]); + }); + + test('allows to filter by type', async ({ pageObjects }) => { + await pageObjects.globalSearch.navigateToHome(); + await pageObjects.globalSearch.searchFor('type:dashboard'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + + expect(labels).toStrictEqual([ + 'dashboard 1 (tag-2)', + 'dashboard 2 (tag-3)', + 'dashboard 3 (tag-1 and tag-3)', + 'dashboard 4 (tag-special-chars)', + ]); + }); + + test('allows to filter by multiple types', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('type:(dashboard OR visualization)'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + + expect(labels).toStrictEqual([ + 'Visualization 1 (tag-1)', + 'Visualization 2 (tag-2)', + 'Visualization 3 (tag-1 + tag-3)', + 'Visualization 4 (tag-2)', + 'My awesome vis (tag-4)', + 'dashboard 1 (tag-2)', + 'dashboard 2 (tag-3)', + 'dashboard 3 (tag-1 and tag-3)', + 'dashboard 4 (tag-special-chars)', + ]); + }); + + test('allows to filter by tag', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('tag:tag-1'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + + expect(labels).toStrictEqual([ + 'Visualization 1 (tag-1)', + 'Visualization 3 (tag-1 + tag-3)', + 'dashboard 3 (tag-1 and tag-3)', + ]); + }); + + test('allows to filter by multiple tags', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('tag:tag-1 tag:tag-3'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + + expect(labels).toStrictEqual([ + 'Visualization 1 (tag-1)', + 'Visualization 3 (tag-1 + tag-3)', + 'dashboard 2 (tag-3)', + 'dashboard 3 (tag-1 and tag-3)', + ]); + }); + + test('allows to filter by type and tag', async ({ pageObjects }) => { + await pageObjects.globalSearch.navigateToHome(); + await pageObjects.globalSearch.searchFor('type:dashboard tag:tag-3'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + + expect(labels).toStrictEqual(['dashboard 2 (tag-3)', 'dashboard 3 (tag-1 and tag-3)']); + }); + + test('allows to filter by multiple types and tags', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor( + 'type:(dashboard OR visualization) tag:(tag-1 OR tag-3)' + ); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + + expect(labels).toStrictEqual([ + 'Visualization 1 (tag-1)', + 'Visualization 3 (tag-1 + tag-3)', + 'dashboard 2 (tag-3)', + 'dashboard 3 (tag-1 and tag-3)', + ]); + }); + + test('allows to filter by term and type', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('type:visualization awesome'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + + expect(labels).toStrictEqual(['My awesome vis (tag-4)']); + }); + + test('allows to filter by term and tag', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('tag:tag-4 awesome'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + + expect(labels).toStrictEqual(['My awesome vis (tag-4)']); + }); + + test('allows to filter by tags containing special characters', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('tag:"my%tag"'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + const labels = results.map((result) => result.label); + + expect(labels).toStrictEqual(['dashboard 4 (tag-special-chars)']); + }); + + test('returns no results when searching for an unknown tag', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('tag:unknown', { wait: false }); + + expect(await pageObjects.globalSearch.isNoResultsPlaceholderDisplayed()).toBe(true); + }); + + test('returns no results when searching for an unknown type', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('type:unknown', { wait: false }); + + expect(await pageObjects.globalSearch.isNoResultsPlaceholderDisplayed()).toBe(true); + }); +}); diff --git a/x-pack/platform/plugins/shared/global_search/test/scout/ui/tests/global_search_providers.spec.ts b/x-pack/platform/plugins/shared/global_search/test/scout/ui/tests/global_search_providers.spec.ts new file mode 100644 index 0000000000000..61133b2e1012c --- /dev/null +++ b/x-pack/platform/plugins/shared/global_search/test/scout/ui/tests/global_search_providers.spec.ts @@ -0,0 +1,99 @@ +/* + * 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 { tags } from '@kbn/scout'; +import { expect } from '@kbn/scout/ui'; +import { test } from '../fixtures'; +import { KBN_ARCHIVES } from '../fixtures/constants'; + +/** + * IMPORTANT: These tests only work in 'classic' navigation mode. Once https://github.com/elastic/kibana/pull/251436 is merged, we might need to revisit this and make them work in 'solution' navigation as well. + */ +test.describe('GlobalSearch providers', { tag: tags.ESS_ONLY }, () => { + test.beforeAll(async ({ kbnClient }) => { + await kbnClient.savedObjects.cleanStandardList(); + await kbnClient.importExport.load(KBN_ARCHIVES.BASIC); + }); + + test.beforeEach(async ({ browserAuth, pageObjects }) => { + await browserAuth.loginAsViewer(); + await pageObjects.globalSearch.navigateToHome(); + }); + + test.afterAll(async ({ kbnClient }) => { + await kbnClient.savedObjects.cleanStandardList(); + }); + + test('SavedObject provider - can search for data views', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('type:index-pattern logstash'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + expect(results).toHaveLength(1); + expect(results[0].label).toBe('logstash-*'); + }); + + test('SavedObject provider - can search for visualizations', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('type:visualization pie'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + expect(results).toHaveLength(1); + expect(results[0].label).toBe('A Pie'); + }); + + test('SavedObject provider - can search for maps', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('type:map just'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + expect(results).toHaveLength(1); + expect(results[0].label).toBe('just a map'); + }); + + test('SavedObject provider - can search for dashboards', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('type:dashboard Amazing'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + expect(results).toHaveLength(1); + expect(results[0].label).toBe('Amazing Dashboard'); + }); + + test('SavedObject provider - returns all objects matching the search', async ({ + pageObjects, + }) => { + await pageObjects.globalSearch.searchFor('type:dashboard dashboard'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + expect(results).toHaveLength(2); + const labels = results.map((r) => r.label); + expect(labels).toContain('dashboard with map'); + expect(labels).toContain('Amazing Dashboard'); + }); + + test('SavedObject provider - can search by prefix', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('type:dashboard Amaz'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + expect(results).toHaveLength(1); + expect(results[0].label).toBe('Amazing Dashboard'); + }); + + test('Applications provider - can search for root-level applications', async ({ + pageObjects, + }) => { + await pageObjects.globalSearch.searchFor('discover'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + expect(results[0].label).toBe('Discover'); + }); + + test('Applications provider - can search for application deep links', async ({ pageObjects }) => { + await pageObjects.globalSearch.searchFor('saved objects'); + + const results = await pageObjects.globalSearch.getDisplayedResults(); + expect(results).toHaveLength(1); + expect(results[0].label).toBe('Kibana / Saved Objects'); + }); +}); diff --git a/x-pack/platform/plugins/shared/global_search/tsconfig.json b/x-pack/platform/plugins/shared/global_search/tsconfig.json index 446184a01c97f..003bb46536728 100644 --- a/x-pack/platform/plugins/shared/global_search/tsconfig.json +++ b/x-pack/platform/plugins/shared/global_search/tsconfig.json @@ -7,6 +7,7 @@ "public/**/*", "server/**/*", "common/**/*", + "test/**/*", "../../../../../typings/**/*" ], "kbn_references": [ @@ -18,6 +19,7 @@ "@kbn/utility-types", "@kbn/core-test-helpers-test-utils", "@kbn/licensing-types", + "@kbn/scout" ], "exclude": [ "target/**/*", diff --git a/x-pack/platform/test/moon.yml b/x-pack/platform/test/moon.yml index 5d2fd8ff192d8..350baba90987d 100644 --- a/x-pack/platform/test/moon.yml +++ b/x-pack/platform/test/moon.yml @@ -140,8 +140,6 @@ dependsOn: - '@kbn/palettes' - '@kbn/field-formats-plugin' - '@kbn/datemath' - - '@kbn/global-search-plugin' - - '@kbn/global-search-test-plugin' - '@kbn/data-usage-plugin' - '@kbn/data-view-field-editor-plugin' - '@kbn/response-ops-rule-params' diff --git a/x-pack/platform/test/plugin_functional/config.ts b/x-pack/platform/test/plugin_functional/config.ts deleted file mode 100644 index ae000bcf6b1d4..0000000000000 --- a/x-pack/platform/test/plugin_functional/config.ts +++ /dev/null @@ -1,68 +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 { resolve } from 'path'; -import { REPO_ROOT as KIBANA_ROOT } from '@kbn/repo-info'; -import { ScoutTestRunConfigCategory } from '@kbn/scout-info'; -import type { FtrConfigProviderContext } from '@kbn/test'; -import { findTestPluginPaths } from '@kbn/test'; -import { services } from './services'; -import { pageObjects } from './page_objects'; - -// the default export of config files must be a config provider -// that returns an object with the projects config values - -export default async function ({ readConfigFile }: FtrConfigProviderContext) { - const xpackFunctionalConfig = await readConfigFile( - require.resolve('../functional/config.base.ts') - ); - - return { - testConfigCategory: ScoutTestRunConfigCategory.UI_TEST, - // list paths to the files that contain your plugins tests - testFiles: [resolve(__dirname, './test_suites/global_search')], - - services, - pageObjects, - - servers: xpackFunctionalConfig.get('servers'), - - esTestCluster: xpackFunctionalConfig.get('esTestCluster'), - - kbnTestServer: { - ...xpackFunctionalConfig.get('kbnTestServer'), - serverArgs: [ - ...xpackFunctionalConfig.get('kbnTestServer.serverArgs'), - `--plugin-path=${resolve( - KIBANA_ROOT, - 'src/platform/test/plugin_functional/plugins/core_provider_plugin' - )}`, - ...findTestPluginPaths(resolve(__dirname, 'plugins')), - ], - }, - uiSettings: xpackFunctionalConfig.get('uiSettings'), - // the apps section defines the urls that - // `PageObjects.common.navigateTo(appKey)` will use. - // Merge urls for your plugin with the urls defined in - // Kibana's config in order to use this helper - apps: { - ...xpackFunctionalConfig.get('apps'), - resolverTest: { - pathname: '/app/resolverTest', - }, - }, - - // choose where screenshots should be saved - screenshots: { - directory: resolve(__dirname, 'screenshots'), - }, - - junit: { - reportName: 'Chrome X-Pack UI Plugin Functional Tests', - }, - }; -} diff --git a/x-pack/platform/test/plugin_functional/ftr_provider_context.d.ts b/x-pack/platform/test/plugin_functional/ftr_provider_context.d.ts deleted file mode 100644 index 40f80b479a74a..0000000000000 --- a/x-pack/platform/test/plugin_functional/ftr_provider_context.d.ts +++ /dev/null @@ -1,12 +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 type { GenericFtrProviderContext } from '@kbn/test'; -import type { services } from './services'; -import type { pageObjects } from './page_objects'; - -export type FtrProviderContext = GenericFtrProviderContext; diff --git a/x-pack/platform/test/plugin_functional/plugins/global_search_test/common/utils.ts b/x-pack/platform/test/plugin_functional/plugins/global_search_test/common/utils.ts deleted file mode 100644 index 9633f687a74eb..0000000000000 --- a/x-pack/platform/test/plugin_functional/plugins/global_search_test/common/utils.ts +++ /dev/null @@ -1,19 +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 type { GlobalSearchProviderResult } from '@kbn/global-search-plugin/common/types'; - -export const createResult = ( - parts: Partial -): GlobalSearchProviderResult => ({ - id: 'test', - title: 'test result', - type: 'test_type', - url: '/some-url', - score: 100, - ...parts, -}); diff --git a/x-pack/platform/test/plugin_functional/plugins/global_search_test/kibana.jsonc b/x-pack/platform/test/plugin_functional/plugins/global_search_test/kibana.jsonc deleted file mode 100644 index 4e3a25ab12954..0000000000000 --- a/x-pack/platform/test/plugin_functional/plugins/global_search_test/kibana.jsonc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "plugin", - "id": "@kbn/global-search-test-plugin", - "owner": "@elastic/kibana-core", - "group": "platform", - "visibility": "private", - "plugin": { - "id": "globalSearchTest", - "server": false, - "browser": true, - "configPath": [ - "xpack", - "global_search_test" - ], - "requiredPlugins": [ - "globalSearch" - ] - } -} diff --git a/x-pack/platform/test/plugin_functional/plugins/global_search_test/moon.yml b/x-pack/platform/test/plugin_functional/plugins/global_search_test/moon.yml deleted file mode 100644 index b86c134f0f97e..0000000000000 --- a/x-pack/platform/test/plugin_functional/plugins/global_search_test/moon.yml +++ /dev/null @@ -1,33 +0,0 @@ -# This file is generated by the @kbn/moon package. Any manual edits will be erased! -# To extend this, write your extensions/overrides to 'moon.extend.yml' -# then regenerate this file with: 'node scripts/regenerate_moon_projects.js --update --filter @kbn/global-search-test-plugin' - -$schema: https://moonrepo.dev/schemas/project.json -id: '@kbn/global-search-test-plugin' -type: unknown -owners: - defaultOwner: '@elastic/kibana-core' -toolchain: - default: node -language: typescript -project: - name: '@kbn/global-search-test-plugin' - description: Moon project for @kbn/global-search-test-plugin - channel: '' - owner: '@elastic/kibana-core' - metadata: - sourceRoot: x-pack/platform/test/plugin_functional/plugins/global_search_test -dependsOn: - - '@kbn/core' - - '@kbn/global-search-plugin' -tags: - - plugin - - prod - - group-platform - - private -fileGroups: - src: - - '**/*.ts' - - '**/*.tsx' - - '!target/**/*' -tasks: {} diff --git a/x-pack/platform/test/plugin_functional/plugins/global_search_test/public/index.ts b/x-pack/platform/test/plugin_functional/plugins/global_search_test/public/index.ts deleted file mode 100644 index 509ea1fc75565..0000000000000 --- a/x-pack/platform/test/plugin_functional/plugins/global_search_test/public/index.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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { PluginInitializer } from '@kbn/core/public'; -import type { - GlobalSearchTestPluginSetup, - GlobalSearchTestPluginStart, - GlobalSearchTestPluginSetupDeps, - GlobalSearchTestPluginStartDeps, -} from './plugin'; -import { GlobalSearchTestPlugin } from './plugin'; - -export const plugin: PluginInitializer< - GlobalSearchTestPluginSetup, - GlobalSearchTestPluginStart, - GlobalSearchTestPluginSetupDeps, - GlobalSearchTestPluginStartDeps -> = () => new GlobalSearchTestPlugin(); - -export type { - GlobalSearchTestPluginSetup, - GlobalSearchTestPluginStart, - GlobalSearchTestPluginSetupDeps, - GlobalSearchTestPluginStartDeps, -} from './plugin'; diff --git a/x-pack/platform/test/plugin_functional/plugins/global_search_test/public/plugin.ts b/x-pack/platform/test/plugin_functional/plugins/global_search_test/public/plugin.ts deleted file mode 100644 index 1bfa7d3a06dbd..0000000000000 --- a/x-pack/platform/test/plugin_functional/plugins/global_search_test/public/plugin.ts +++ /dev/null @@ -1,68 +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 { map, reduce } from 'rxjs'; -import type { Plugin, CoreSetup, CoreStart, AppMountParameters } from '@kbn/core/public'; -import { lastValueFrom } from 'rxjs'; -import type { - GlobalSearchPluginSetup, - GlobalSearchPluginStart, - GlobalSearchResult, -} from '@kbn/global-search-plugin/public'; - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface GlobalSearchTestPluginSetup {} -export interface GlobalSearchTestPluginStart { - find: (term: string) => Promise; -} - -export interface GlobalSearchTestPluginSetupDeps { - globalSearch: GlobalSearchPluginSetup; -} -export interface GlobalSearchTestPluginStartDeps { - globalSearch: GlobalSearchPluginStart; -} - -export class GlobalSearchTestPlugin - implements - Plugin< - GlobalSearchTestPluginSetup, - GlobalSearchTestPluginStart, - GlobalSearchTestPluginSetupDeps, - GlobalSearchTestPluginStartDeps - > -{ - public setup( - { application, getStartServices }: CoreSetup, - { globalSearch }: GlobalSearchTestPluginSetupDeps - ) { - application.register({ - id: 'globalSearchTestApp', - title: 'GlobalSearch test', - mount: (params: AppMountParameters) => { - return () => undefined; - }, - }); - - return {}; - } - - public start( - {}: CoreStart, - { globalSearch }: GlobalSearchTestPluginStartDeps - ): GlobalSearchTestPluginStart { - return { - find: (term) => - lastValueFrom( - globalSearch.find({ term }, {}).pipe( - map((batch) => batch.results), - reduce((memo, results) => [...memo, ...results]) - ) - ), - }; - } -} diff --git a/x-pack/platform/test/plugin_functional/plugins/global_search_test/public/types.ts b/x-pack/platform/test/plugin_functional/plugins/global_search_test/public/types.ts deleted file mode 100644 index b0a2f2b61afe5..0000000000000 --- a/x-pack/platform/test/plugin_functional/plugins/global_search_test/public/types.ts +++ /dev/null @@ -1,10 +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 type { GlobalSearchTestPluginStart } from './plugin'; - -export type GlobalSearchTestApi = GlobalSearchTestPluginStart; diff --git a/x-pack/platform/test/plugin_functional/plugins/global_search_test/tsconfig.json b/x-pack/platform/test/plugin_functional/plugins/global_search_test/tsconfig.json deleted file mode 100644 index 6a3f92908815d..0000000000000 --- a/x-pack/platform/test/plugin_functional/plugins/global_search_test/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "@kbn/tsconfig-base/tsconfig.json", - "compilerOptions": { - "outDir": "target/types" - }, - "include": [ - "**/*.ts", - "**/*.tsx", - ], - "exclude": [ - "target/**/*", - ], - "kbn_references": [ - "@kbn/core", - "@kbn/global-search-plugin", - ] -} diff --git a/x-pack/platform/test/plugin_functional/services.ts b/x-pack/platform/test/plugin_functional/services.ts deleted file mode 100644 index e8f51add199bc..0000000000000 --- a/x-pack/platform/test/plugin_functional/services.ts +++ /dev/null @@ -1,8 +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. - */ - -export { services } from '../functional/services'; diff --git a/x-pack/platform/test/plugin_functional/test_suites/global_search/global_search_bar.ts b/x-pack/platform/test/plugin_functional/test_suites/global_search/global_search_bar.ts deleted file mode 100644 index fc69e9b678a9b..0000000000000 --- a/x-pack/platform/test/plugin_functional/test_suites/global_search/global_search_bar.ts +++ /dev/null @@ -1,220 +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/expect'; -import type { FtrProviderContext } from '../../ftr_provider_context'; - -export default function ({ getPageObjects, getService }: FtrProviderContext) { - describe('GlobalSearchBar', function () { - const { common, navigationalSearch } = getPageObjects(['common', 'navigationalSearch']); - const browser = getService('browser'); - const kibanaServer = getService('kibanaServer'); - const retry = getService('retry'); - - before(async () => { - await kibanaServer.savedObjects.cleanStandardList(); - await kibanaServer.importExport.load( - 'x-pack/platform/test/functional/fixtures/kbn_archives/global_search/search_syntax' - ); - await common.navigateToApp('home'); - }); - - after(async () => { - await kibanaServer.savedObjects.cleanStandardList(); - }); - - afterEach(async () => { - await navigationalSearch.blur(); - }); - - it('shows the popover on focus', async () => { - await navigationalSearch.focus(); - - expect(await navigationalSearch.isPopoverDisplayed()).to.eql(true); - - await navigationalSearch.blur(); - - expect(await navigationalSearch.isPopoverDisplayed()).to.eql(false); - }); - - it('redirects to the correct page', async () => { - await navigationalSearch.searchFor('type:application discover'); - await navigationalSearch.clickOnOption(0); - - expect(await browser.getCurrentUrl()).to.contain('discover'); - }); - - describe('search suggestions', () => { - it('shows a suggestion when searching for a term matching a type', async () => { - await navigationalSearch.searchFor('dashboard'); - - const dashboardTypeSearchResult = await retry.try(async () => { - await navigationalSearch.searchFor('dashboard'); - const results = await navigationalSearch.getDisplayedResults(); - // will throw if results not found - expect(results.length).greaterThan(0); - return results; - }); - - expect(dashboardTypeSearchResult[0].label).to.eql('type: dashboard'); - - await navigationalSearch.clickOnOption(0); - await navigationalSearch.waitForResultsLoaded(); - - const searchTerm = await navigationalSearch.getFieldValue(); - expect(searchTerm).to.eql('type:dashboard'); - - const results = await navigationalSearch.getDisplayedResults(); - expect(results.map((result) => result.label)).to.eql([ - 'dashboard 1 (tag-2)', - 'dashboard 2 (tag-3)', - 'dashboard 3 (tag-1 and tag-3)', - 'dashboard 4 (tag-special-chars)', - ]); - }); - it('shows a suggestion when searching for a term matching a tag name', async () => { - await navigationalSearch.searchFor('tag-1'); - - let results = await navigationalSearch.getDisplayedResults(); - expect(results[0].label).to.eql('tag: tag-1'); - - await navigationalSearch.clickOnOption(0); - await navigationalSearch.waitForResultsLoaded(); - - const searchTerm = await navigationalSearch.getFieldValue(); - expect(searchTerm).to.eql('tag:tag-1'); - - results = await navigationalSearch.getDisplayedResults(); - expect(results.map((result) => result.label)).to.eql([ - 'Visualization 1 (tag-1)', - 'Visualization 3 (tag-1 + tag-3)', - 'dashboard 3 (tag-1 and tag-3)', - ]); - }); - }); - - describe('advanced search syntax', () => { - it('allows to filter by type', async () => { - await navigationalSearch.searchFor('type:dashboard'); - - const results = await navigationalSearch.getDisplayedResults(); - - expect(results.map((result) => result.label)).to.eql([ - 'dashboard 1 (tag-2)', - 'dashboard 2 (tag-3)', - 'dashboard 3 (tag-1 and tag-3)', - 'dashboard 4 (tag-special-chars)', - ]); - }); - - it('allows to filter by multiple types', async () => { - await navigationalSearch.searchFor('type:(dashboard OR visualization)'); - - const results = await navigationalSearch.getDisplayedResults(); - - expect(results.map((result) => result.label)).to.eql([ - 'Visualization 1 (tag-1)', - 'Visualization 2 (tag-2)', - 'Visualization 3 (tag-1 + tag-3)', - 'Visualization 4 (tag-2)', - 'My awesome vis (tag-4)', - 'dashboard 1 (tag-2)', - 'dashboard 2 (tag-3)', - 'dashboard 3 (tag-1 and tag-3)', - 'dashboard 4 (tag-special-chars)', - ]); - }); - - it('allows to filter by tag', async () => { - await navigationalSearch.searchFor('tag:tag-1'); - - const results = await navigationalSearch.getDisplayedResults(); - - expect(results.map((result) => result.label)).to.eql([ - 'Visualization 1 (tag-1)', - 'Visualization 3 (tag-1 + tag-3)', - 'dashboard 3 (tag-1 and tag-3)', - ]); - }); - - it('allows to filter by multiple tags', async () => { - await navigationalSearch.searchFor('tag:tag-1 tag:tag-3'); - - const results = await navigationalSearch.getDisplayedResults(); - - expect(results.map((result) => result.label)).to.eql([ - 'Visualization 1 (tag-1)', - 'Visualization 3 (tag-1 + tag-3)', - 'dashboard 2 (tag-3)', - 'dashboard 3 (tag-1 and tag-3)', - ]); - }); - - it('allows to filter by type and tag', async () => { - await navigationalSearch.searchFor('type:dashboard tag:tag-3'); - - const results = await navigationalSearch.getDisplayedResults(); - - expect(results.map((result) => result.label)).to.eql([ - 'dashboard 2 (tag-3)', - 'dashboard 3 (tag-1 and tag-3)', - ]); - }); - - it('allows to filter by multiple types and tags', async () => { - await navigationalSearch.searchFor( - 'type:(dashboard OR visualization) tag:(tag-1 OR tag-3)' - ); - - const results = await navigationalSearch.getDisplayedResults(); - - expect(results.map((result) => result.label)).to.eql([ - 'Visualization 1 (tag-1)', - 'Visualization 3 (tag-1 + tag-3)', - 'dashboard 2 (tag-3)', - 'dashboard 3 (tag-1 and tag-3)', - ]); - }); - - it('allows to filter by term and type', async () => { - await navigationalSearch.searchFor('type:visualization awesome'); - - const results = await navigationalSearch.getDisplayedResults(); - - expect(results.map((result) => result.label)).to.eql(['My awesome vis (tag-4)']); - }); - - it('allows to filter by term and tag', async () => { - await navigationalSearch.searchFor('tag:tag-4 awesome'); - - const results = await navigationalSearch.getDisplayedResults(); - - expect(results.map((result) => result.label)).to.eql(['My awesome vis (tag-4)']); - }); - - it('allows to filter by tags containing special characters', async () => { - await navigationalSearch.searchFor('tag:"my%tag"'); - - const results = await navigationalSearch.getDisplayedResults(); - - expect(results.map((result) => result.label)).to.eql(['dashboard 4 (tag-special-chars)']); - }); - - it('returns no results when searching for an unknown tag', async () => { - await navigationalSearch.searchFor('tag:unknown'); - - expect(await navigationalSearch.isNoResultsPlaceholderDisplayed()).to.eql(true); - }); - - it('returns no results when searching for an unknown type', async () => { - await navigationalSearch.searchFor('type:unknown'); - - expect(await navigationalSearch.isNoResultsPlaceholderDisplayed()).to.eql(true); - }); - }); - }); -} diff --git a/x-pack/platform/test/plugin_functional/test_suites/global_search/global_search_providers.ts b/x-pack/platform/test/plugin_functional/test_suites/global_search/global_search_providers.ts deleted file mode 100644 index d7640b9d2167f..0000000000000 --- a/x-pack/platform/test/plugin_functional/test_suites/global_search/global_search_providers.ts +++ /dev/null @@ -1,105 +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/expect'; -import '@kbn/core-provider-plugin/types'; -import type { GlobalSearchResult } from '@kbn/global-search-plugin/common/types'; -import type { GlobalSearchTestApi } from '@kbn/global-search-test-plugin/public/types'; -import type { FtrProviderContext } from '../../ftr_provider_context'; - -export default function ({ getPageObjects, getService }: FtrProviderContext) { - const pageObjects = getPageObjects(['common']); - const browser = getService('browser'); - const kibanaServer = getService('kibanaServer'); - const log = getService('log'); - - const findResultsWithApi = async (t: string): Promise => { - return browser.executeAsync(async (term, cb) => { - const { start } = window._coreProvider; - const globalSearchTestApi: GlobalSearchTestApi = start.plugins.globalSearchTest; - globalSearchTestApi - .find(term) - .then(cb) - .catch((err) => log.error(err)); - }, t); - }; - - describe('GlobalSearch providers', function () { - before(async () => { - await pageObjects.common.navigateToApp('globalSearchTestApp'); - }); - - describe('SavedObject provider', function () { - before(async () => { - await kibanaServer.savedObjects.cleanStandardList(); - await kibanaServer.importExport.load( - 'x-pack/platform/test/functional/fixtures/kbn_archives/global_search/basic' - ); - }); - - after(async () => { - await kibanaServer.savedObjects.cleanStandardList(); - }); - - it('can search for data views', async () => { - const results = await findResultsWithApi('type:index-pattern logstash'); - expect(results.length).to.be(1); - expect(results[0].type).to.be('index-pattern'); - expect(results[0].title).to.be('logstash-*'); - expect(results[0].score).to.be.greaterThan(0.9); - }); - - it('can search for visualizations', async () => { - const results = await findResultsWithApi('type:visualization pie'); - expect(results.length).to.be(1); - expect(results[0].type).to.be('visualization'); - expect(results[0].title).to.be('A Pie'); - }); - - it('can search for maps', async () => { - const results = await findResultsWithApi('type:map just'); - expect(results.length).to.be(1); - expect(results[0].type).to.be('map'); - expect(results[0].title).to.be('just a map'); - }); - - it('can search for dashboards', async () => { - const results = await findResultsWithApi('type:dashboard Amazing'); - expect(results.length).to.be(1); - expect(results[0].type).to.be('dashboard'); - expect(results[0].title).to.be('Amazing Dashboard'); - }); - - it('returns all objects matching the search', async () => { - const results = await findResultsWithApi('type:dashboard dashboard'); - expect(results.length).to.be(2); - expect(results.map((r) => r.title)).to.contain('dashboard with map'); - expect(results.map((r) => r.title)).to.contain('Amazing Dashboard'); - }); - - it('can search by prefix', async () => { - const results = await findResultsWithApi('type:dashboard Amaz'); - expect(results.length).to.be(1); - expect(results[0].type).to.be('dashboard'); - expect(results[0].title).to.be('Amazing Dashboard'); - }); - }); - - describe('Applications provider', function () { - it('can search for root-level applications', async () => { - const results = await findResultsWithApi('discover'); - expect(results[0].title).to.be('Discover'); - }); - - it('can search for application deep links', async () => { - const results = await findResultsWithApi('saved objects'); - expect(results.length).to.be(1); - expect(results[0].title).to.be('Kibana / Saved Objects'); - }); - }); - }); -} diff --git a/x-pack/platform/test/plugin_functional/test_suites/global_search/index.ts b/x-pack/platform/test/plugin_functional/test_suites/global_search/index.ts deleted file mode 100644 index 5fc8b08b74fb8..0000000000000 --- a/x-pack/platform/test/plugin_functional/test_suites/global_search/index.ts +++ /dev/null @@ -1,15 +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 type { FtrProviderContext } from '../../ftr_provider_context'; - -export default function ({ loadTestFile }: FtrProviderContext) { - describe('GlobalSearch API', function () { - loadTestFile(require.resolve('./global_search_providers')); - loadTestFile(require.resolve('./global_search_bar')); - }); -} diff --git a/x-pack/platform/test/tsconfig.json b/x-pack/platform/test/tsconfig.json index 721018ddcebac..a84595f6abf03 100644 --- a/x-pack/platform/test/tsconfig.json +++ b/x-pack/platform/test/tsconfig.json @@ -152,8 +152,6 @@ "@kbn/palettes", "@kbn/field-formats-plugin", "@kbn/datemath", - "@kbn/global-search-plugin", - "@kbn/global-search-test-plugin", "@kbn/data-usage-plugin", "@kbn/data-view-field-editor-plugin", "@kbn/response-ops-rule-params", diff --git a/yarn.lock b/yarn.lock index 921af5d41dffe..980ba3719384d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7165,10 +7165,6 @@ version "0.0.0" uid "" -"@kbn/global-search-test-plugin@link:x-pack/platform/test/plugin_functional/plugins/global_search_test": - version "0.0.0" - uid "" - "@kbn/graph-plugin@link:x-pack/platform/plugins/private/graph": version "0.0.0" uid ""