From 43feba8f96b892cc8b5e12f4cfa6613eb9936022 Mon Sep 17 00:00:00 2001 From: Catherine Liu Date: Wed, 31 Jul 2024 15:55:12 -0700 Subject: [PATCH] Update panel actions service --- .../dashboard/group5/saved_search_embeddable.ts | 11 +---------- .../image_embeddable/image_embeddable.ts | 1 - .../services/dashboard/panel_actions.ts | 8 +------- .../test_suites/panel_actions/panel_actions.js | 4 ---- .../dashboard_to_dashboard_drilldown.ts | 2 -- .../drilldowns/dashboard_to_url_drilldown.ts | 1 - .../dashboard/group3/reporting/download_csv.ts | 7 +------ .../functional/apps/discover/visualize_field.ts | 7 +++---- .../apps/lens/group1/ad_hoc_data_view.ts | 7 ++++--- .../functional/apps/lens/group4/dashboard.ts | 5 +---- .../apps/cases/group2/attachment_framework.ts | 14 +++++++------- .../reporting_functional/services/scenarios.ts | 17 +++++------------ .../observability/cases/attachment_framework.ts | 12 +++++------- .../search/cases/attachment_framework.ts | 4 ++-- .../security/ftr/cases/attachment_framework.ts | 11 +++++------ 15 files changed, 35 insertions(+), 76 deletions(-) diff --git a/test/functional/apps/dashboard/group5/saved_search_embeddable.ts b/test/functional/apps/dashboard/group5/saved_search_embeddable.ts index f20172d10ed5c8f..c2c7c9db70aa68a 100644 --- a/test/functional/apps/dashboard/group5/saved_search_embeddable.ts +++ b/test/functional/apps/dashboard/group5/saved_search_embeddable.ts @@ -11,7 +11,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardPanelActions = getService('dashboardPanelActions'); - const testSubjects = getService('testSubjects'); const filterBar = getService('filterBar'); const find = getService('find'); const esArchiver = getService('esArchiver'); @@ -77,17 +76,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.header.waitUntilLoadingHasFinished(); await PageObjects.dashboard.waitForRenderComplete(); - await dashboardPanelActions.openContextMenu(); - const actionExists = await testSubjects.exists( + await dashboardPanelActions.clickContextMenuItem( 'embeddablePanelAction-ACTION_VIEW_SAVED_SEARCH' ); - if (!actionExists) { - await dashboardPanelActions.clickContextMenuMoreItem(); - } - const actionElement = await testSubjects.find( - 'embeddablePanelAction-ACTION_VIEW_SAVED_SEARCH' - ); - await actionElement.click(); await PageObjects.discover.waitForDiscoverAppOnScreen(); expect(await PageObjects.discover.getSavedSearchTitle()).to.equal( diff --git a/test/functional/apps/dashboard_elements/image_embeddable/image_embeddable.ts b/test/functional/apps/dashboard_elements/image_embeddable/image_embeddable.ts index 2636d00fb5cce41..922a6125fca85a3 100644 --- a/test/functional/apps/dashboard_elements/image_embeddable/image_embeddable.ts +++ b/test/functional/apps/dashboard_elements/image_embeddable/image_embeddable.ts @@ -54,7 +54,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('image embeddable should support drilldowns', async () => { await dashboardPanelActions.openContextMenu(); - await dashboardPanelActions.clickContextMenuMoreItem(); await dashboardDrilldownPanelActions.expectExistsCreateDrilldownAction(); await dashboardDrilldownPanelActions.clickCreateDrilldown(); await dashboardDrilldownsManage.expectsCreateDrilldownFlyoutOpen(); diff --git a/test/functional/services/dashboard/panel_actions.ts b/test/functional/services/dashboard/panel_actions.ts index 118f4ac5be8fad4..b4ffb9745eae8fc 100644 --- a/test/functional/services/dashboard/panel_actions.ts +++ b/test/functional/services/dashboard/panel_actions.ts @@ -92,10 +92,9 @@ export class DashboardPanelActionsService extends FtrService { } async clickContextMenuItem(itemSelector: string, parent?: WebElementWrapper) { - await this.openContextMenu(parent); const exists = await this.testSubjects.exists(itemSelector); if (!exists) { - await this.clickContextMenuMoreItem(); + await this.openContextMenu(parent); } await this.testSubjects.click(itemSelector); } @@ -112,11 +111,6 @@ export class DashboardPanelActionsService extends FtrService { async clickInlineEdit() { this.log.debug('clickInlineEditAction'); - await this.expectContextMenuToBeOpen(); - const isInlineEditingActionVisible = await this.testSubjects.exists( - INLINE_EDIT_PANEL_DATA_TEST_SUBJ - ); - if (!isInlineEditingActionVisible) await this.clickContextMenuMoreItem(); await this.testSubjects.clickWhenNotDisabledWithoutRetry(INLINE_EDIT_PANEL_DATA_TEST_SUBJ); await this.header.waitUntilLoadingHasFinished(); await this.common.waitForTopNavToBeVisible(); diff --git a/test/plugin_functional/test_suites/panel_actions/panel_actions.js b/test/plugin_functional/test_suites/panel_actions/panel_actions.js index 18ee30d52a075e2..74e7f380e3400ad 100644 --- a/test/plugin_functional/test_suites/panel_actions/panel_actions.js +++ b/test/plugin_functional/test_suites/panel_actions/panel_actions.js @@ -21,10 +21,6 @@ export default function ({ getService, getPageObjects }) { it('allows to register links into the context menu', async () => { await dashboardPanelActions.openContextMenu(); - const actionExists = await testSubjects.exists('embeddablePanelAction-samplePanelLink'); - if (!actionExists) { - await dashboardPanelActions.clickContextMenuMoreItem(); - } const actionElement = await testSubjects.find('embeddablePanelAction-samplePanelLink'); const actionElementTag = await actionElement.getTagName(); expect(actionElementTag).to.be('a'); diff --git a/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_dashboard_drilldown.ts b/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_dashboard_drilldown.ts index 95ea2dc42bc395e..a29b61fec5609ab 100644 --- a/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_dashboard_drilldown.ts +++ b/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_dashboard_drilldown.ts @@ -46,7 +46,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // create drilldown await dashboardPanelActions.openContextMenu(); - await dashboardPanelActions.clickContextMenuMoreItem(); await dashboardDrilldownPanelActions.expectExistsCreateDrilldownAction(); await dashboardDrilldownPanelActions.clickCreateDrilldown(); await dashboardDrilldownsManage.expectsCreateDrilldownFlyoutOpen(); @@ -278,7 +277,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // delete drilldown await PageObjects.dashboard.switchToEditMode(); await dashboardPanelActions.openContextMenu(); - await dashboardPanelActions.clickContextMenuMoreItem(); await dashboardDrilldownPanelActions.expectExistsManageDrilldownsAction(); await dashboardDrilldownPanelActions.clickManageDrilldowns(); await dashboardDrilldownsManage.expectsManageDrilldownsFlyoutOpen(); diff --git a/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_url_drilldown.ts b/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_url_drilldown.ts index e7c8a0819fd1a83..24e9a249377fab8 100644 --- a/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_url_drilldown.ts +++ b/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_url_drilldown.ts @@ -33,7 +33,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // create drilldown await dashboardPanelActions.openContextMenu(); - await dashboardPanelActions.clickContextMenuMoreItem(); await dashboardDrilldownPanelActions.expectExistsCreateDrilldownAction(); await dashboardDrilldownPanelActions.clickCreateDrilldown(); await dashboardDrilldownsManage.expectsCreateDrilldownFlyoutOpen(); diff --git a/x-pack/test/functional/apps/dashboard/group3/reporting/download_csv.ts b/x-pack/test/functional/apps/dashboard/group3/reporting/download_csv.ts index 858332ce4d0a3f1..9e834b80a2130a6 100644 --- a/x-pack/test/functional/apps/dashboard/group3/reporting/download_csv.ts +++ b/x-pack/test/functional/apps/dashboard/group3/reporting/download_csv.ts @@ -52,13 +52,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; const clickDownloadCsv = async () => { - log.debug('click "More"'); - await dashboardPanelActions.clickContextMenuMoreItem(); - - const actionItemTestSubj = 'embeddablePanelAction-generateCsvReport'; - await testSubjects.existOrFail(actionItemTestSubj); // wait for the full panel to display or else the test runner could click the wrong option! log.debug('click "Generate CSV"'); - await testSubjects.click(actionItemTestSubj); + await dashboardPanelActions.clickContextMenuItem('embeddablePanelAction-generateCsvReport'); await testSubjects.existOrFail('csvReportStarted'); // validate toast panel }; diff --git a/x-pack/test/functional/apps/discover/visualize_field.ts b/x-pack/test/functional/apps/discover/visualize_field.ts index bb59bbc7af283a1..b496e3ddb095dd6 100644 --- a/x-pack/test/functional/apps/discover/visualize_field.ts +++ b/x-pack/test/functional/apps/discover/visualize_field.ts @@ -29,6 +29,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ]); const elasticChart = getService('elasticChart'); const monacoEditor = getService('monacoEditor'); + const dashboardPanelActions = getService('dashboardPanelActions'); const defaultSettings = { enableESQL: true, @@ -236,8 +237,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await testSubjects.existOrFail('embeddablePanelHeading-TextBasedChart'); await elasticChart.setNewChartUiDebugFlag(true); await PageObjects.header.waitUntilLoadingHasFinished(); - await testSubjects.click('embeddablePanelToggleMenuIcon'); - await testSubjects.click('embeddablePanelAction-ACTION_CONFIGURE_IN_LENS'); + await dashboardPanelActions.clickInlineEdit(); await PageObjects.header.waitUntilLoadingHasFinished(); expect(await PageObjects.lens.canRemoveDimension('lnsXY_xDimensionPanel')).to.equal(true); await PageObjects.lens.removeDimension('lnsXY_xDimensionPanel'); @@ -266,8 +266,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await elasticChart.setNewChartUiDebugFlag(true); await PageObjects.header.waitUntilLoadingHasFinished(); // open the inline editing flyout - await testSubjects.click('embeddablePanelToggleMenuIcon'); - await testSubjects.click('embeddablePanelAction-ACTION_CONFIGURE_IN_LENS'); + await dashboardPanelActions.clickInlineEdit(); await PageObjects.header.waitUntilLoadingHasFinished(); // change the query diff --git a/x-pack/test/functional/apps/lens/group1/ad_hoc_data_view.ts b/x-pack/test/functional/apps/lens/group1/ad_hoc_data_view.ts index a97577696b0c64f..d8098b5515f75ad 100644 --- a/x-pack/test/functional/apps/lens/group1/ad_hoc_data_view.ts +++ b/x-pack/test/functional/apps/lens/group1/ad_hoc_data_view.ts @@ -28,6 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const browser = getService('browser'); const dataViews = getService('dataViews'); + const dashboardPanelActions = getService('dashboardPanelActions'); const expectedData = [ { x: '97.220.3.248', y: 19755 }, @@ -55,9 +56,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } const checkDiscoverNavigationResult = async () => { - await testSubjects.click('embeddablePanelToggleMenuIcon'); - await testSubjects.click('embeddablePanelMore-mainMenu'); - await testSubjects.click('embeddablePanelAction-ACTION_OPEN_IN_DISCOVER'); + await dashboardPanelActions.clickContextMenuItem( + 'embeddablePanelAction-ACTION_OPEN_IN_DISCOVER' + ); const [, discoverHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverHandle); diff --git a/x-pack/test/functional/apps/lens/group4/dashboard.ts b/x-pack/test/functional/apps/lens/group4/dashboard.ts index 776a4416d7d4cf8..c22a659034247a4 100644 --- a/x-pack/test/functional/apps/lens/group4/dashboard.ts +++ b/x-pack/test/functional/apps/lens/group4/dashboard.ts @@ -184,7 +184,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.try(async () => { await panelActions.openContextMenu(); - await panelActions.clickContextMenuMoreItem(); await testSubjects.existOrFail(ACTION_TEST_SUBJ); }); }); @@ -225,9 +224,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await PageObjects.lens.saveAndReturn(); - await panelActions.openContextMenu(); - await panelActions.clickContextMenuMoreItem(); - await testSubjects.click('embeddablePanelAction-openInspector'); + await panelActions.openInspector(); await inspector.openInspectorRequestsView(); const requests = await inspector.getRequestNames(); expect(requests.split(',').length).to.be(2); diff --git a/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts b/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts index c714cdba2563778..63a8546029b3f31 100644 --- a/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts +++ b/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts @@ -63,6 +63,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { const listingTable = getService('listingTable'); const toasts = getService('toasts'); const browser = getService('browser'); + const dashboardPanelActions = getService('dashboardPanelActions'); const createAttachmentAndNavigate = async (attachment: AttachmentRequest) => { const caseData = await cases.api.createCase({ @@ -400,10 +401,9 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await common.navigateToApp('dashboard'); await dashboard.preserveCrossAppState(); await dashboard.loadSavedDashboard(myDashboardName); - - await testSubjects.click('embeddablePanelToggleMenuIcon'); - await testSubjects.click('embeddablePanelMore-mainMenu'); - await testSubjects.click('embeddablePanelAction-embeddable_addToExistingCase'); + await dashboardPanelActions.clickContextMenuItem( + 'embeddablePanelAction-embeddable_addToExistingCase' + ); await testSubjects.click('cases-table-add-case-filter-bar'); await cases.create.createCase({ @@ -435,9 +435,9 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await dashboard.preserveCrossAppState(); await dashboard.loadSavedDashboard(myDashboardName); - await testSubjects.click('embeddablePanelToggleMenuIcon'); - await testSubjects.click('embeddablePanelMore-mainMenu'); - await testSubjects.click('embeddablePanelAction-embeddable_addToExistingCase'); + await dashboardPanelActions.clickContextMenuItem( + 'embeddablePanelAction-embeddable_addToExistingCase' + ); await testSubjects.click(`cases-table-row-select-${theCase.id}`); diff --git a/x-pack/test/reporting_functional/services/scenarios.ts b/x-pack/test/reporting_functional/services/scenarios.ts index 2fb9eaf249cda12..71c299f6131e77c 100644 --- a/x-pack/test/reporting_functional/services/scenarios.ts +++ b/x-pack/test/reporting_functional/services/scenarios.ts @@ -9,6 +9,8 @@ import expect from '@kbn/expect'; import { createScenarios as createAPIScenarios } from '../../reporting_api_integration/services/scenarios'; import { FtrProviderContext } from '../ftr_provider_context'; +const GENERATE_CSV_DATA_TEST_SUBJ = 'embeddablePanelAction-generateCsvReport'; + export function createScenarios( context: Pick ) { @@ -79,27 +81,18 @@ export function createScenarios( }; const tryDashboardGenerateCsvFail = async (savedSearchTitle: string) => { const savedSearchPanel = await getSavedSearchPanel(savedSearchTitle); - await dashboardPanelActions.toggleContextMenu(savedSearchPanel); - const actionItemTestSubj = 'embeddablePanelAction-generateCsvReport'; - - if (!(await testSubjects.exists(actionItemTestSubj))) { - await testSubjects.click('embeddablePanelMore-mainMenu'); - } - - await testSubjects.click(actionItemTestSubj); + await dashboardPanelActions.clickContextMenuItem(GENERATE_CSV_DATA_TEST_SUBJ, savedSearchPanel); await testSubjects.existOrFail('generateCsvFail'); }; const tryDashboardGenerateCsvNotAvailable = async (savedSearchTitle: string) => { const savedSearchPanel = await getSavedSearchPanel(savedSearchTitle); await dashboardPanelActions.toggleContextMenu(savedSearchPanel); - await dashboardPanelActions.clickContextMenuMoreItem(); - await testSubjects.missingOrFail('embeddablePanelAction-generateCsvReport'); + await testSubjects.missingOrFail(GENERATE_CSV_DATA_TEST_SUBJ); }; const tryDashboardGenerateCsvSuccess = async (savedSearchTitle: string) => { const savedSearchPanel = await getSavedSearchPanel(savedSearchTitle); await dashboardPanelActions.toggleContextMenu(savedSearchPanel); - await dashboardPanelActions.clickContextMenuMoreItem(); - const actionItemTestSubj = 'embeddablePanelAction-generateCsvReport'; + const actionItemTestSubj = GENERATE_CSV_DATA_TEST_SUBJ; await testSubjects.existOrFail(actionItemTestSubj); /* wait for the full panel to display or else the test runner could click the wrong option! */ await testSubjects.click( actionItemTestSubj diff --git a/x-pack/test_serverless/functional/test_suites/observability/cases/attachment_framework.ts b/x-pack/test_serverless/functional/test_suites/observability/cases/attachment_framework.ts index 72fb345fe012cf2..c429fef23fdd92d 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/cases/attachment_framework.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/cases/attachment_framework.ts @@ -8,6 +8,8 @@ import { expect } from 'expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; +const ADD_TO_CASE_DATA_TEST_SUBJ = 'embeddablePanelAction-embeddable_addToExistingCase'; + export default ({ getPageObject, getService }: FtrProviderContext) => { const dashboard = getPageObject('dashboard'); const lens = getPageObject('lens'); @@ -22,6 +24,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { const find = getService('find'); const toasts = getService('toasts'); const retry = getService('retry'); + const dashboardPanelActions = getService('dashboardPanelActions'); describe('Cases persistable attachments', function () { describe('lens visualization', () => { @@ -55,9 +58,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { it('adds lens visualization to a new case', async () => { const caseTitle = 'case created in observability from my dashboard with lens visualization'; - await testSubjects.click('embeddablePanelToggleMenuIcon'); - await testSubjects.click('embeddablePanelMore-mainMenu'); - await testSubjects.click('embeddablePanelAction-embeddable_addToExistingCase'); + await dashboardPanelActions.clickContextMenuItem(ADD_TO_CASE_DATA_TEST_SUBJ); await retry.waitFor('wait for the modal to open', async () => { return ( @@ -108,10 +109,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await svlCommonNavigation.sidenav.clickLink({ deepLinkId: 'dashboards' }); - await testSubjects.click('embeddablePanelToggleMenuIcon'); - await testSubjects.click('embeddablePanelMore-mainMenu'); - await testSubjects.click('embeddablePanelAction-embeddable_addToExistingCase'); - + await dashboardPanelActions.clickContextMenuItem(ADD_TO_CASE_DATA_TEST_SUBJ); // verify that solution filter is not visible await testSubjects.missingOrFail('options-filter-popover-button-owner'); diff --git a/x-pack/test_serverless/functional/test_suites/search/cases/attachment_framework.ts b/x-pack/test_serverless/functional/test_suites/search/cases/attachment_framework.ts index e4290903bdeb9e0..6f8b806e49e04bd 100644 --- a/x-pack/test_serverless/functional/test_suites/search/cases/attachment_framework.ts +++ b/x-pack/test_serverless/functional/test_suites/search/cases/attachment_framework.ts @@ -17,6 +17,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { const svlCommonNavigation = getPageObject('svlCommonNavigation'); const svlCommonPage = getPageObject('svlCommonPage'); const settings = getPageObject('settings'); + const dashboardPanelActions = getPageObject('dashboardPanelActions'); describe('persistable attachment', () => { before(async () => { @@ -49,8 +50,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { }); it('does not show actions to add lens visualization to case', async () => { - await testSubjects.click('embeddablePanelToggleMenuIcon'); - await testSubjects.click('embeddablePanelMore-mainMenu'); + await dashboardPanelActions.openContextMenu(); await testSubjects.missingOrFail('embeddablePanelAction-embeddable_addToExistingCase'); }); }); diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts index 63259b94fec1257..ab186f44418d03e 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts @@ -8,6 +8,8 @@ import { expect } from 'expect'; import { FtrProviderContext } from '../../../../ftr_provider_context'; +const ADD_TO_CASE_DATA_TEST_SUBJ = 'embeddablePanelAction-embeddable_addToExistingCase'; + export default ({ getPageObject, getService }: FtrProviderContext) => { const common = getPageObject('common'); const dashboard = getPageObject('dashboard'); @@ -20,6 +22,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { const retry = getService('retry'); const header = getPageObject('header'); const toasts = getService('toasts'); + const dashboardPanelActions = getService('dashboardPanelActions'); describe('Cases persistable attachments', () => { describe('lens visualization', () => { @@ -47,9 +50,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { const caseTitle = 'case created in security solution from my dashboard with lens visualization'; - await testSubjects.click('embeddablePanelToggleMenuIcon'); - await testSubjects.click('embeddablePanelMore-mainMenu'); - await testSubjects.click('embeddablePanelAction-embeddable_addToExistingCase'); + await dashboardPanelActions.clickContextMenuItem(ADD_TO_CASE_DATA_TEST_SUBJ); await retry.waitFor('wait for the modal to open', async () => { return ( @@ -106,9 +107,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await testSubjects.click('edit-unsaved-New-Dashboard'); } - await testSubjects.click('embeddablePanelToggleMenuIcon'); - await testSubjects.click('embeddablePanelMore-mainMenu'); - await testSubjects.click('embeddablePanelAction-embeddable_addToExistingCase'); + await dashboardPanelActions.clickContextMenuItem(ADD_TO_CASE_DATA_TEST_SUBJ); // verify that solution filter is not visible await testSubjects.missingOrFail('options-filter-popover-button-owner');