Skip to content

Commit

Permalink
test: introduce functional_search suite
Browse files Browse the repository at this point in the history
Adding the function_search suite with a test for the new search solution
nav. But this suite will also be a place where we can test search
functionality not tied to the enterprise_search node.
  • Loading branch information
TattdCodeMonkey committed Oct 8, 2024
1 parent 4673bf1 commit d956117
Show file tree
Hide file tree
Showing 8 changed files with 397 additions and 0 deletions.
1 change: 1 addition & 0 deletions .buildkite/ftr_platform_stateful_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ enabled:
- x-pack/test/functional/config.upgrade_assistant.ts
- x-pack/test/functional_cloud/config.ts
- x-pack/test/functional_solution_sidenav/config.ts
- x-pack/test/functional_search/config.ts
- x-pack/test/kubernetes_security/basic/config.ts
- x-pack/test/licensing_plugin/config.public.ts
- x-pack/test/licensing_plugin/config.ts
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,7 @@ x-pack/test/api_integration/apis/management/index_management/inference_endpoints
/x-pack/test_serverless/api_integration/test_suites/search @elastic/search-kibana
/x-pack/test_serverless/functional/page_objects/svl_api_keys.ts @elastic/search-kibana
/x-pack/test_serverless/functional/page_objects/svl_search_* @elastic/search-kibana
/x-pack/test/functional_search/ @elastic/search-kibana

# Management Experience - Deployment Management
/x-pack/test_serverless/**/test_suites/common/index_management/ @elastic/kibana-management
Expand Down
12 changes: 12 additions & 0 deletions test/functional/page_objects/solution_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ export function SolutionNavigationProvider(ctx: Pick<FtrProviderContext, 'getSer
});
}
},
async expectOnlyDefinedLinks(navItemIds: string[]) {
const navItemIdRegEx = /nav-item-id-[^\s]+/g;
const allSideNavLinks = await testSubjects.findAll('*nav-item-id-');
for (const sideNavItem of allSideNavLinks) {
const dataTestSubjs = await sideNavItem.getAttribute('data-test-subj');
const navItemIdMatch = dataTestSubjs?.match(navItemIdRegEx);
expect(navItemIdMatch).to.be.ok();
const navItemId = navItemIdMatch![0].replace('nav-item-id-', '');
expect(navItemIds).to.contain(navItemId);
}
expect(allSideNavLinks.length).to.equal(navItemIds.length);
},
async clickPanelLink(deepLinkId: string) {
await testSubjects.click(`~panelNavItem-id-${deepLinkId}`);
},
Expand Down
31 changes: 31 additions & 0 deletions x-pack/test/functional_search/config.ts
Original file line number Diff line number Diff line change
@@ -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 { FtrConfigProviderContext } from '@kbn/test';

/**
* NOTE: The solution view is currently only available in the cloud environment.
* This test suite fakes a cloud environement by setting the cloud.id and cloud.base_url
*/

export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const functionalConfig = await readConfigFile(require.resolve('../functional/config.base.js'));

return {
...functionalConfig.getAll(),
testFiles: [require.resolve('.')],
kbnTestServer: {
...functionalConfig.get('kbnTestServer'),
serverArgs: [
...functionalConfig.get('kbnTestServer.serverArgs'),
// Note: the base64 string in the cloud.id config contains the ES endpoint required in the functional tests
'--xpack.cloud.id=ftr_fake_cloud_id:aGVsbG8uY29tOjQ0MyRFUzEyM2FiYyRrYm4xMjNhYmM=',
'--xpack.cloud.base_url=https://cloud.elastic.co',
],
},
};
}
13 changes: 13 additions & 0 deletions x-pack/test/functional_search/ftr_provider_context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { GenericFtrProviderContext } from '@kbn/test';
import { pageObjects } from '../functional/page_objects';
import { services } from './services';

export type FtrProviderContext = GenericFtrProviderContext<typeof services, typeof pageObjects>;
export { pageObjects };
15 changes: 15 additions & 0 deletions x-pack/test/functional_search/index.ts
Original file line number Diff line number Diff line change
@@ -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.
*/
/* eslint-disable import/no-default-export */

import { FtrProviderContext } from './ftr_provider_context';

export default ({ loadTestFile }: FtrProviderContext): void => {
describe('Search solution tests', function () {
loadTestFile(require.resolve('./tests/solution_navigation'));
});
};
10 changes: 10 additions & 0 deletions x-pack/test/functional_search/services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { services as functionalServices } from '../functional/services';

export const services = functionalServices;
Loading

0 comments on commit d956117

Please sign in to comment.