Skip to content

Commit

Permalink
[Search][FTR] Solution Nav (#195327)
Browse files Browse the repository at this point in the history
## Summary

Adding `functional_search` suite with a set of test for the search
solution navigation. But this suite will also grow to test search
solution pages that do not require the enterprise search node.

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

(cherry picked from commit 71fd96a)

# Conflicts:
#	.github/CODEOWNERS
  • Loading branch information
TattdCodeMonkey committed Oct 9, 2024
1 parent deeb604 commit b5ebb4a
Show file tree
Hide file tree
Showing 8 changed files with 407 additions and 3 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
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
14 changes: 11 additions & 3 deletions x-pack/plugins/enterprise_search/public/navigation_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const getNavigationTreeDefinition = ({
return pathNameSerialized.startsWith(prepend('/app/dev_tools'));
},
id: 'dev_tools',
link: 'dev_tools:console',
link: 'dev_tools',
title: i18n.translate('xpack.enterpriseSearch.searchNav.devTools', {
defaultMessage: 'Dev Tools',
}),
Expand Down Expand Up @@ -218,7 +218,11 @@ export const getNavigationTreeDefinition = ({
{
children: [
{
getIsActive: () => false,
getIsActive: ({ pathNameSerialized, prepend }) => {
return pathNameSerialized.startsWith(
prepend('/app/enterprise_search/app_search')
);
},
link: 'appSearch:engines',
title: i18n.translate(
'xpack.enterpriseSearch.searchNav.entsearch.appSearch',
Expand All @@ -235,7 +239,11 @@ export const getNavigationTreeDefinition = ({
: {}),
},
{
getIsActive: () => false,
getIsActive: ({ pathNameSerialized, prepend }) => {
return pathNameSerialized.startsWith(
prepend('/app/enterprise_search/workplace_search')
);
},
link: 'workplaceSearch',
...(workplaceSearch
? {
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 b5ebb4a

Please sign in to comment.