Skip to content

Commit 42e97b3

Browse files
efegurkankibanamachineelasticmachine
authored
Add Scout setup for Search Homepage (#246777)
## Summary Adds the Scout setup for Search Homepage. Enables new Search Homepage by default ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [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 - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ## Release Note: Search Homepage design is updated. --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent 5e41a33 commit 42e97b3

File tree

14 files changed

+337
-13
lines changed

14 files changed

+337
-13
lines changed

.buildkite/scout_ci_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ plugins:
1111
- observability_onboarding
1212
- painless_lab
1313
- profiling
14+
- search_homepage
1415
- security_solution
1516
- slo
1617
- spaces

x-pack/solutions/search/plugins/search_homepage/moon.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ dependsOn:
5454
- '@kbn/data-views-plugin'
5555
- '@kbn/cloud'
5656
- '@kbn/onechat-plugin'
57+
- '@kbn/scout-search'
5758
tags:
5859
- plugin
5960
- prod
@@ -66,6 +67,7 @@ fileGroups:
6667
- common/**/*
6768
- public/**/*
6869
- server/**/*
70+
- test/scout/**/*
6971
- '!target/**/*'
7072
tasks:
7173
jest:

x-pack/solutions/search/plugins/search_homepage/public/components/search_homepage/cloud_resources.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,17 @@ interface ResourceCardProps {
3030
description: string;
3131
actionHref: string;
3232
actionText: string;
33+
dataTestSubj: string;
3334
}
3435

35-
const ResourceCard = ({ title, icon, description, actionHref, actionText }: ResourceCardProps) => {
36+
const ResourceCard = ({
37+
title,
38+
icon,
39+
description,
40+
actionHref,
41+
actionText,
42+
dataTestSubj,
43+
}: ResourceCardProps) => {
3644
const assetBasePath = useAssetBasePath();
3745
const { euiTheme } = useEuiTheme();
3846

@@ -42,6 +50,7 @@ const ResourceCard = ({ title, icon, description, actionHref, actionText }: Reso
4250
css={css({
4351
maxWidth: euiTheme.base * 36,
4452
})}
53+
data-test-subj={dataTestSubj}
4554
>
4655
<EuiSplitPanel.Inner
4756
paddingSize="none"
@@ -73,7 +82,7 @@ const ResourceCard = ({ title, icon, description, actionHref, actionText }: Reso
7382
iconSide="left"
7483
iconType="sortRight"
7584
color="text"
76-
data-test-subj="searchHomepageSearchHomepageBodyEnableElasticInferenceServiceButton"
85+
data-test-subj="searchHomepageSearchCloudResourceCardAction"
7786
href={actionHref}
7887
target="_blank"
7988
>
@@ -114,6 +123,7 @@ export const CloudResources = () => {
114123
defaultMessage: 'Go to Billing',
115124
}),
116125
actionHref: billingUrl,
126+
dataTestSubj: 'cloudResourceCard-billing',
117127
},
118128
{
119129
icon: (assetBasePath: string) => `${assetBasePath}/search_analytics.svg`,
@@ -127,7 +137,8 @@ export const CloudResources = () => {
127137
actionText: i18n.translate('xpack.searchHomepage.cloudResources.autoops.actionText', {
128138
defaultMessage: 'AutoOps',
129139
}),
130-
actionHref: cloud?.performanceUrl ?? '',
140+
actionHref: cloud?.performanceUrl || `https://cloud.elastic.co`,
141+
dataTestSubj: 'cloudResourceCard-autoops',
131142
},
132143
];
133144
const HOSTED_CARDS: ResourceCardProps[] = [
@@ -144,6 +155,7 @@ export const CloudResources = () => {
144155
defaultMessage: 'Connect this cluster',
145156
}),
146157
actionHref: docLinks.cloudConnect,
158+
dataTestSubj: 'cloudResourceCard-cloudConnect',
147159
},
148160
{
149161
icon: (assetBasePath: string) => `${assetBasePath}/search_serverless.svg`,
@@ -158,6 +170,7 @@ export const CloudResources = () => {
158170
defaultMessage: 'Elastic Cloud',
159171
}),
160172
actionHref: docLinks.elasticCloud,
173+
dataTestSubj: 'cloudResourceCard-serverless',
161174
},
162175
];
163176

@@ -184,6 +197,7 @@ export const CloudResources = () => {
184197
description={card.description}
185198
actionHref={card.actionHref}
186199
actionText={card.actionText}
200+
dataTestSubj={card.dataTestSubj}
187201
/>
188202
</EuiFlexItem>
189203
))}

x-pack/solutions/search/plugins/search_homepage/public/components/search_homepage/metric_panels.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface ComplexMetricPanel {
4040
metricDescription: string;
4141
metricTitle: string;
4242
type: MetricPanelType;
43+
dataTestSubj: string;
4344
onPanelClick?: ({
4445
share,
4546
application,
@@ -49,7 +50,7 @@ export interface ComplexMetricPanel {
4950
}) => void;
5051
}
5152

52-
const METRIC_PANEL_ITEMS: Array<ComplexMetricPanel> = [
53+
export const METRIC_PANEL_ITEMS: Array<ComplexMetricPanel> = [
5354
{
5455
getImageUrl: (assetBasePath: string) => `${assetBasePath}/search_lake.svg`,
5556
metricDescription: i18n.translate('xpack.searchHomepage.metricPanels.empty.discover.desc', {
@@ -64,6 +65,7 @@ const METRIC_PANEL_ITEMS: Array<ComplexMetricPanel> = [
6465
onPanelClick: ({ application }) => {
6566
application.navigateToApp('discover');
6667
},
68+
dataTestSubj: 'searchHomepageNavLinks-discover',
6769
},
6870
{
6971
getImageUrl: (assetBasePath: string) => `${assetBasePath}/search_data_vis.svg`,
@@ -79,6 +81,7 @@ const METRIC_PANEL_ITEMS: Array<ComplexMetricPanel> = [
7981
onPanelClick: ({ application }) => {
8082
application.navigateToApp('dashboards');
8183
},
84+
dataTestSubj: 'searchHomepageNavLinks-dashboards',
8285
},
8386
{
8487
getImageUrl: (assetBasePath: string) => `${assetBasePath}/search_agents.svg`,
@@ -94,6 +97,7 @@ const METRIC_PANEL_ITEMS: Array<ComplexMetricPanel> = [
9497
onPanelClick: ({ application }) => {
9598
application.navigateToApp('agent_builder');
9699
},
100+
dataTestSubj: 'searchHomepageNavLinks-agentBuilder',
97101
},
98102

99103
{
@@ -109,6 +113,7 @@ const METRIC_PANEL_ITEMS: Array<ComplexMetricPanel> = [
109113
onPanelClick: ({ application }) => {
110114
application.navigateToApp('workflows');
111115
},
116+
dataTestSubj: 'searchHomepageNavLinks-workflows',
112117
},
113118
{
114119
type: 'machineLearning',
@@ -125,8 +130,11 @@ const METRIC_PANEL_ITEMS: Array<ComplexMetricPanel> = [
125130
defaultMessage: 'Machine Learning',
126131
}),
127132
onPanelClick: ({ application }) => {
128-
application.navigateToApp('ml');
133+
application.navigateToApp('ml', {
134+
path: 'overview',
135+
});
129136
},
137+
dataTestSubj: 'searchHomepageNavLinks-machineLearning',
130138
},
131139
{
132140
type: 'dataManagement',
@@ -147,6 +155,7 @@ const METRIC_PANEL_ITEMS: Array<ComplexMetricPanel> = [
147155
path: 'data/index_management',
148156
});
149157
},
158+
dataTestSubj: 'searchHomepageNavLinks-dataManagement',
150159
},
151160
];
152161

@@ -161,11 +170,12 @@ const MetricPanelEmpty = ({ panel }: MetricPanelEmptyProps) => {
161170
const assetBasePath = useAssetBasePath();
162171
const { euiTheme } = useEuiTheme();
163172

164-
const { getImageUrl, metricTitle, metricDescription, onPanelClick } = panel;
173+
const { getImageUrl, metricTitle, metricDescription, onPanelClick, dataTestSubj } = panel;
165174
return (
166175
<EuiSplitPanel.Outer
167176
hasBorder
168177
onClick={() => onPanelClick && onPanelClick({ share, application })}
178+
data-test-subj={dataTestSubj}
169179
>
170180
<EuiSplitPanel.Inner
171181
grow
@@ -223,7 +233,7 @@ export const MetricPanels = () => {
223233
: METRIC_PANEL_ITEMS.filter((p) => p.type !== 'workflows');
224234

225235
return (
226-
<EuiFlexGrid gutterSize="l" columns={3}>
236+
<EuiFlexGrid gutterSize="l" columns={3} data-test-subj="searchHomepageNavLinksTabGrid">
227237
{panels.map((panel, index) => (
228238
<EuiFlexItem key={panel.type + '-' + index}>
229239
<MetricPanelEmpty panel={panel} />

x-pack/solutions/search/plugins/search_homepage/public/components/search_homepage/search_homepage.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ export const SearchHomepagePage = () => {
7070
<KibanaPageTemplate.Section restrictWidth={true} grow={false}>
7171
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center">
7272
<EuiFlexItem>
73-
<EuiFlexGroup responsive={false} alignItems="center" gutterSize="s">
73+
<EuiFlexGroup
74+
responsive={false}
75+
alignItems="center"
76+
gutterSize="s"
77+
data-test-subj="searchHomepageHeaderLeftsideGroup"
78+
>
7479
<EuiFlexItem grow={false}>
7580
<EuiTitle size="m">
7681
<h3>

x-pack/solutions/search/plugins/search_homepage/public/components/search_homepage/search_homepage_body.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
import React from 'react';
99

1010
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
11-
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiSpacer } from '@elastic/eui';
11+
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiSpacer, useEuiTheme } from '@elastic/eui';
1212

13+
import { css } from '@emotion/react';
1314
import { MetricPanels } from './metric_panels';
1415
import { CloudResources } from './cloud_resources';
1516
import { BodyLinks } from './body_links';
@@ -18,18 +19,25 @@ import { useKibana } from '../../hooks/use_kibana';
1819
import { GettingStartedBanner } from './getting_started_banner';
1920

2021
export const SearchHomepageBody = () => {
22+
const { euiTheme } = useEuiTheme();
2123
const {
2224
services: { cloud },
2325
} = useKibana();
24-
const { isAdmin } = useAuthenticatedUser();
26+
const { isAdmin, isBillingAdmin } = useAuthenticatedUser();
2527
return (
26-
<KibanaPageTemplate.Section alignment="top" restrictWidth={true} grow paddingSize="none">
28+
<KibanaPageTemplate.Section
29+
alignment="top"
30+
restrictWidth={true}
31+
grow
32+
paddingSize="none"
33+
css={css({ padding: `0 ${euiTheme.size.l}` })}
34+
>
2735
<EuiFlexGroup gutterSize="l" direction="column">
2836
<EuiFlexItem>
2937
<EuiSpacer size="l" />
3038
<MetricPanels />
3139
</EuiFlexItem>
32-
{cloud?.isServerlessEnabled && !isAdmin ? null : (
40+
{cloud?.isServerlessEnabled && (!isAdmin || !isBillingAdmin) ? null : (
3341
<EuiFlexItem>
3442
<EuiSpacer size="l" />
3543
<CloudResources />

x-pack/solutions/search/plugins/search_homepage/public/router.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const HomepageRouter = () => {
1818
services: { settings },
1919
} = useKibana();
2020

21-
const isNewDesignEnabled = settings?.client.get<boolean>(SEARCH_HOMEPAGE_V2_UI_FLAG, false);
21+
const isNewDesignEnabled = settings?.client.get<boolean>(SEARCH_HOMEPAGE_V2_UI_FLAG, true);
2222

2323
return (
2424
<Routes>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## How to run tests
2+
3+
First start the servers:
4+
5+
```bash
6+
// ESS
7+
node scripts/scout.js start-server --stateful
8+
9+
// Serverless
10+
node scripts/scout.js start-server --serverless=es
11+
```
12+
13+
Then you can run the parallel tests in another terminal:
14+
15+
```bash
16+
// ESS
17+
npx playwright test --config x-pack/solutions/search/plugins/search_homepage/test/scout/ui/playwright.config.ts --project=local --grep @ess
18+
19+
// Serverless
20+
npx playwright test --project local --config x-pack/solutions/search/plugins/search_homepage/test/scout/ui/playwright.config.ts --grep @svlSearch
21+
```
22+
23+
Test results are available in `x-pack/solutions/search/plugins/search_homepage/test/scout/ui/output`
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import type {
9+
BrowserAuthFixture,
10+
KibanaUrl,
11+
PageObjects,
12+
ScoutTestFixtures,
13+
ScoutWorkerFixtures,
14+
} from '@kbn/scout-search';
15+
import { test as base, createLazyPageObject } from '@kbn/scout-search';
16+
import { Homepage } from './page_objects/homepage';
17+
18+
export interface ExtendedScoutTestFixtures extends ScoutTestFixtures {
19+
pageObjects: PageObjects & {
20+
homepage: Homepage;
21+
};
22+
browserAuth: BrowserAuthFixture;
23+
}
24+
25+
export const test = base.extend<ExtendedScoutTestFixtures, ScoutWorkerFixtures>({
26+
pageObjects: async (
27+
{
28+
pageObjects,
29+
page,
30+
}: {
31+
pageObjects: ExtendedScoutTestFixtures['pageObjects'];
32+
page: ExtendedScoutTestFixtures['page'];
33+
kbnUrl: KibanaUrl;
34+
},
35+
use: (pageObjects: ExtendedScoutTestFixtures['pageObjects']) => Promise<void>
36+
) => {
37+
const extendedPageObjects = {
38+
...pageObjects,
39+
homepage: createLazyPageObject(Homepage, page),
40+
};
41+
await use(extendedPageObjects);
42+
},
43+
});

0 commit comments

Comments
 (0)