Skip to content

Commit 811cf90

Browse files
authored
migrate home app ui tests to scout (#271356)
## Summary Migrates the `home/feature_controls` FTR suite to Scout, splitting the assertions across the layer that owns each contract: - Scout UI (`src/platform/plugins/shared/home/test/scout/ui/tests/feature_controls.spec.ts`): 1 parametrized spec, 2 roles. Asserts the visible solution panels and the Manage section / Stack Management quick-link on the Home page — the wiring between capabilities, the feature catalogue and the rendered DOM. - Existing Jest (`manage_data.test.tsx`): already locks the component-level contract (section/button visibility given a navLinks shape) — left as-is, no new unit test needed. Custom roles live once in `test/scout/common/custom_roles.ts` ### Test coverage parity Every assertion from the deleted FTR is still covered: - Solutions list per role → Scout UI - homeDataManage section visibility per role → Scout UI + existing Jest - homeManage button visibility per role → Scout UI + existing Jest
1 parent 9861fd2 commit 811cf90

11 files changed

Lines changed: 128 additions & 380 deletions

File tree

.buildkite/ftr-manifests/ftr_platform_stateful_configs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ enabled:
259259
- x-pack/platform/test/functional/apps/discover/group2/config.ts
260260
- x-pack/platform/test/functional/apps/discover/group3/config.ts
261261
- x-pack/platform/test/functional/apps/graph/config.ts
262-
- x-pack/platform/test/functional/apps/home/config.ts
263262
- x-pack/platform/test/functional/apps/index_lifecycle_management/config.ts
264263
- x-pack/platform/test/functional/apps/index_management/config.ts
265264
- x-pack/platform/test/functional/apps/lens/group1/config.ts

.github/CODEOWNERS

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,7 +2670,6 @@ x-pack/platform/test/functional/page_objects/search_profiler_page.ts @elastic/se
26702670

26712671
# Management Experience - Deployment Management
26722672
/src/platform/test/functional/fixtures/kbn_archiver/management.json @elastic/kibana-management @elastic/kibana-data-discovery # Assigned per 2 uses: test/functional/apps/management/_import_objects.ts && test/functional/apps/management/data_views/_scripted_fields_filter.ts
2673-
/x-pack/platform/test/functional/fixtures/kbn_archives/home/feature_controls/security/security.json @elastic/kibana-management
26742673
/x-pack/platform/test/fixtures/es_archives/upgrade_assistant @elastic/kibana-management
26752674
/x-pack/platform/test/functional/services/ace_editor.ts @elastic/kibana-management
26762675
/x-pack/platform/test/functional/page_objects/remote_clusters_page.ts @elastic/kibana-management
@@ -2694,7 +2693,6 @@ x-pack/platform/test/functional/page_objects/search_profiler_page.ts @elastic/se
26942693
/src/platform/test/functional/services/management @elastic/kibana-management
26952694
/x-pack/platform/test/functional/apps/cross_cluster_replication @elastic/kibana-management
26962695
/x-pack/platform/test/functional/apps/ingest_pipelines @elastic/kibana-management
2697-
/x-pack/platform/test/functional/apps/home @elastic/kibana-management
26982696
/x-pack/platform/test/functional/apps/license_management @elastic/kibana-management
26992697
/x-pack/platform/test/functional/apps/management @elastic/kibana-management
27002698
/x-pack/platform/test/functional/apps/remote_clusters @elastic/kibana-management

src/platform/packages/shared/kbn-scout/src/playwright/page_objects/home_page.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,35 @@ export class HomePage {
1616
return this.page.testSubj.locator('homeApp');
1717
}
1818

19+
public get manageSection() {
20+
return this.page.testSubj.locator('homeDataManage');
21+
}
22+
23+
public get stackManagementButton() {
24+
return this.page.testSubj.locator('homeManage');
25+
}
26+
1927
public async goto() {
2028
await this.page.addInitScript(() => {
2129
window.localStorage.setItem('home:welcome:show', 'false');
2230
});
2331
await this.page.gotoApp('home');
2432
await this.homeApp.waitFor({ state: 'visible' });
2533
}
34+
35+
// The home page renders one solution card per registered solution, with
36+
// `data-test-subj="homeSolutionPanel homeSolutionPanel_${solution.id}"`.
37+
// Match on the second token via an attribute-contains-word selector so
38+
// unrelated future test-subj strings starting with `homeSolutionPanel`
39+
// (e.g. a panel header) cannot leak into the result.
40+
public async getVisibleSolutions(): Promise<string[]> {
41+
const locator = this.page.locator('[data-test-subj~="homeSolutionPanel"]');
42+
const attributes = await locator.evaluateAll((nodes) =>
43+
nodes.map((node) => node.getAttribute('data-test-subj') ?? '')
44+
);
45+
return attributes
46+
.flatMap((value) => value.split(' '))
47+
.filter((token) => token.startsWith('homeSolutionPanel_'))
48+
.map((token) => token.slice('homeSolutionPanel_'.length));
49+
}
2650
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
import type { KibanaRole } from '@kbn/scout';
11+
12+
// Custom roles shared by the Home plugin's Scout UI and API tests.
13+
//
14+
// KibanaRole requires both `base` and `feature` in kibana entries, and `cluster`
15+
// in elasticsearch (use empty arrays/objects when those privileges are not needed).
16+
export const CUSTOM_ROLES: Record<string, KibanaRole> = {
17+
// Kibana base:all across all spaces. Sees every registered solution panel
18+
// and the Stack Management quick-link on the Home page.
19+
global_all: {
20+
elasticsearch: { cluster: [] },
21+
kibana: [{ base: ['all'], feature: {}, spaces: ['*'] }],
22+
},
23+
24+
// dashboard:all only — no management privileges and no other solution access.
25+
// Sees only the Kibana solution panel and the Manage section is hidden.
26+
global_dashboard_all: {
27+
elasticsearch: { cluster: [] },
28+
kibana: [{ base: [], feature: { dashboard: ['all'] }, spaces: ['*'] }],
29+
},
30+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
export { test } from '@kbn/scout';
11+
export { CUSTOM_ROLES } from '../../common/custom_roles';
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
// Kibana Home page role-based visibility of solution cards and the Manage section.
11+
12+
import { expect } from '@kbn/scout/ui';
13+
import { tags } from '@kbn/scout';
14+
import { test, CUSTOM_ROLES } from '../fixtures';
15+
16+
test.describe('Home page — feature controls', { tag: tags.stateful.classic }, () => {
17+
test('global:all sees every solution panel and the Manage section', async ({
18+
browserAuth,
19+
pageObjects,
20+
}) => {
21+
await browserAuth.loginWithCustomRole(CUSTOM_ROLES.global_all);
22+
23+
await test.step('navigate to the Home app', async () => {
24+
await pageObjects.home.goto();
25+
});
26+
27+
await test.step('shows all registered solutions', async () => {
28+
const solutions = await pageObjects.home.getVisibleSolutions();
29+
expect(solutions).toStrictEqual([
30+
'enterpriseSearch',
31+
'observability',
32+
'securitySolution',
33+
'kibana',
34+
]);
35+
});
36+
37+
await test.step('shows the Manage section and Stack Management quick-link', async () => {
38+
await expect(pageObjects.home.manageSection).toBeVisible();
39+
await expect(pageObjects.home.stackManagementButton).toBeVisible();
40+
});
41+
});
42+
43+
test('dashboard:all sees only the Kibana solution and no Manage section', async ({
44+
browserAuth,
45+
pageObjects,
46+
}) => {
47+
await browserAuth.loginWithCustomRole(CUSTOM_ROLES.global_dashboard_all);
48+
49+
await test.step('navigate to the Home app', async () => {
50+
await pageObjects.home.goto();
51+
});
52+
53+
await test.step('shows only the Kibana solution', async () => {
54+
const solutions = await pageObjects.home.getVisibleSolutions();
55+
expect(solutions).toStrictEqual(['kibana']);
56+
});
57+
58+
await test.step('hides the Manage section and Stack Management quick-link', async () => {
59+
await expect(pageObjects.home.manageSection).toBeHidden();
60+
await expect(pageObjects.home.stackManagementButton).toBeHidden();
61+
});
62+
});
63+
});

x-pack/platform/test/functional/apps/home/config.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

x-pack/platform/test/functional/apps/home/feature_controls/home_security.ts

Lines changed: 0 additions & 139 deletions
This file was deleted.

x-pack/platform/test/functional/apps/home/feature_controls/index.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

x-pack/platform/test/functional/apps/home/index.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)