[Dashboard] Add functional test for panel listing types (#205808)

Fixes #192663

## Summary

Add functional tests that verify the number of panel types registered in
the dashboards Add panel flyout. Any changes to the number of registered
panel types will trigger a review from the
`@elastic/kibana-presentation` team.

This PR also adds an additional test for panel types registered with an
advanced license.
This commit is contained in:
Nick Peihl 2025-01-09 08:37:29 -05:00 committed by GitHub
parent d4196cd902
commit ce072268aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 83 additions and 1 deletions

View file

@ -33,7 +33,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await kibanaServer.savedObjects.cleanStandardList();
});
it('renders a panel with predefined order of panel groups', async () => {
it('renders a panel with predefined order of panel groups and panels', async () => {
await PageObjects.dashboard.navigateToApp();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.switchToEditMode();
@ -48,6 +48,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'[data-test-subj*="dashboardEditorMenu-"]'
);
const panelTypes = await panelSelectionList.findAllByCssSelector('li');
for (let i = 0; i < panelGroups.length; i++) {
const panelGroup = panelGroups[i];
const order = await panelGroup.getAttribute('data-group-sort-order');
@ -67,6 +69,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'observabilityGroup',
'legacyGroup',
]);
// Any changes to the number of panels needs to be audited by @elastic/kibana-presentation
expect(panelTypes.length).to.eql(11);
});
});
}

View file

@ -0,0 +1,76 @@
/*
* 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 { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const { dashboard } = getPageObjects(['dashboard']);
const testSubjects = getService('testSubjects');
const kibanaServer = getService('kibanaServer');
const dashboardAddPanel = getService('dashboardAddPanel');
describe('dashboard panel listing', function () {
this.tags('skipFIPS');
before(async () => {
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana'
);
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
});
after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
});
it('renders a panel with predefined order of panel groups and panels', async () => {
await dashboard.navigateToApp();
await dashboard.clickNewDashboard();
await dashboard.switchToEditMode();
await dashboardAddPanel.clickEditorMenuButton();
const panelSelectionList = await testSubjects.find('dashboardPanelSelectionList');
const panelGroupByOrder = new Map();
const panelGroups = await panelSelectionList.findAllByCssSelector(
'[data-test-subj*="dashboardEditorMenu-"]'
);
const panelTypes = await panelSelectionList.findAllByCssSelector('li');
for (let i = 0; i < panelGroups.length; i++) {
const panelGroup = panelGroups[i];
const order = await panelGroup.getAttribute('data-group-sort-order');
// @ts-ignore
const [, panelGroupTitle] = (await panelGroup.getAttribute('data-test-subj'))?.match(
/dashboardEditorMenu-(.*)/
);
panelGroupByOrder.set(order, panelGroupTitle);
}
expect(panelGroupByOrder.size).to.eql(5);
expect([...panelGroupByOrder.values()]).to.eql([
'visualizationsGroup',
'annotation-and-navigationGroup',
'mlGroup',
'observabilityGroup',
'legacyGroup',
]);
// Any changes to the number of panels needs to be audited by @elastic/kibana-presentation
expect(panelTypes.length).to.eql(21);
});
});
}

View file

@ -14,6 +14,7 @@ export default function ({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./dashboard_lens_by_value'));
loadTestFile(require.resolve('./dashboard_maps_by_value'));
loadTestFile(require.resolve('./dashboard_search_by_value'));
loadTestFile(require.resolve('./dashboard_panel_listing'));
loadTestFile(require.resolve('./panel_titles'));
loadTestFile(require.resolve('./panel_time_range'));