Skip to content

Commit

Permalink
Update panel actions service
Browse files Browse the repository at this point in the history
  • Loading branch information
cqliu1 committed Jul 31, 2024
1 parent dd1a624 commit 43feba8
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 76 deletions.
11 changes: 1 addition & 10 deletions test/functional/apps/dashboard/group5/saved_search_embeddable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 1 addition & 7 deletions test/functional/services/dashboard/panel_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
7 changes: 3 additions & 4 deletions x-pack/test/functional/apps/discover/visualize_field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions x-pack/test/functional/apps/lens/group1/ad_hoc_data_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions x-pack/test/functional/apps/lens/group4/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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}`);

Expand Down
17 changes: 5 additions & 12 deletions x-pack/test/reporting_functional/services/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FtrProviderContext, 'getPageObjects' | 'getService'>
) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 43feba8

Please sign in to comment.