diff --git a/src/plugins/dashboard/public/dashboard_actions/index.ts b/src/plugins/dashboard/public/dashboard_actions/index.ts index 6afbb424f1823..30f6819bd37dd 100644 --- a/src/plugins/dashboard/public/dashboard_actions/index.ts +++ b/src/plugins/dashboard/public/dashboard_actions/index.ts @@ -17,10 +17,8 @@ import { CopyToDashboardAction } from './copy_to_dashboard_action'; import { ExpandPanelAction } from './expand_panel_action'; import { ExportCSVAction } from './export_csv_action'; import { FiltersNotificationAction } from './filters_notification_action'; -import { LegacyLibraryNotificationAction } from './legacy_library_notification_action'; import { UnlinkFromLibraryAction } from './unlink_from_library_action'; import { LegacyUnlinkFromLibraryAction } from './legacy_unlink_from_library_action'; -import { LibraryNotificationAction } from './library_notification_action'; interface BuildAllDashboardActionsProps { core: CoreStart; @@ -64,20 +62,10 @@ export const buildAllDashboardActions = async ({ uiActions.registerAction(unlinkFromLibraryAction); uiActions.attachAction(CONTEXT_MENU_TRIGGER, unlinkFromLibraryAction.id); - const libraryNotificationAction = new LibraryNotificationAction(unlinkFromLibraryAction); - uiActions.registerAction(libraryNotificationAction); - uiActions.attachAction(PANEL_NOTIFICATION_TRIGGER, libraryNotificationAction.id); - const legacyUnlinkFromLibraryAction = new LegacyUnlinkFromLibraryAction(); uiActions.registerAction(legacyUnlinkFromLibraryAction); uiActions.attachAction(CONTEXT_MENU_TRIGGER, legacyUnlinkFromLibraryAction.id); - const legacyLibraryNotificationAction = new LegacyLibraryNotificationAction( - legacyUnlinkFromLibraryAction - ); - uiActions.registerAction(legacyLibraryNotificationAction); - uiActions.attachAction(PANEL_NOTIFICATION_TRIGGER, legacyLibraryNotificationAction.id); - const copyToDashboardAction = new CopyToDashboardAction(core); uiActions.registerAction(copyToDashboardAction); uiActions.attachAction(CONTEXT_MENU_TRIGGER, copyToDashboardAction.id); diff --git a/src/plugins/dashboard/public/dashboard_actions/legacy_library_notification_action.test.tsx b/src/plugins/dashboard/public/dashboard_actions/legacy_library_notification_action.test.tsx deleted file mode 100644 index 687787e377a83..0000000000000 --- a/src/plugins/dashboard/public/dashboard_actions/legacy_library_notification_action.test.tsx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import { ViewMode } from '@kbn/presentation-publishing'; -import { waitFor } from '@testing-library/react'; -import { BehaviorSubject } from 'rxjs'; -import { LegacyLibraryNotificationAction } from './legacy_library_notification_action'; -import { - LegacyUnlinkFromLibraryAction, - LegacyUnlinkPanelFromLibraryActionApi, -} from './legacy_unlink_from_library_action'; - -describe('library notification action', () => { - let action: LegacyLibraryNotificationAction; - let unlinkAction: LegacyUnlinkFromLibraryAction; - let context: { embeddable: LegacyUnlinkPanelFromLibraryActionApi }; - - let updateViewMode: (viewMode: ViewMode) => void; - - beforeEach(() => { - const viewModeSubject = new BehaviorSubject('edit'); - updateViewMode = (viewMode) => viewModeSubject.next(viewMode); - - unlinkAction = new LegacyUnlinkFromLibraryAction(); - action = new LegacyLibraryNotificationAction(unlinkAction); - context = { - embeddable: { - viewMode: viewModeSubject, - canUnlinkFromLibrary: jest.fn().mockResolvedValue(true), - unlinkFromLibrary: jest.fn(), - canLinkToLibrary: jest.fn().mockResolvedValue(true), - linkToLibrary: jest.fn(), - }, - }; - }); - - it('is compatible when api meets all conditions', async () => { - expect(await action.isCompatible(context)).toBe(true); - }); - - it('is incompatible when api is missing required functions', async () => { - const emptyContext = { embeddable: {} }; - expect(await action.isCompatible(emptyContext)).toBe(false); - }); - - it('is incompatible when can unlink from library resolves to false', async () => { - context.embeddable.canUnlinkFromLibrary = jest.fn().mockResolvedValue(false); - expect(await action.isCompatible(context)).toBe(false); - }); - - it('calls onChange when view mode changes', async () => { - const onChange = jest.fn(); - action.subscribeToCompatibilityChanges(context, onChange); - updateViewMode('view'); - await waitFor(() => expect(onChange).toHaveBeenCalledWith(false, action)); - }); -}); diff --git a/src/plugins/dashboard/public/dashboard_actions/legacy_library_notification_action.tsx b/src/plugins/dashboard/public/dashboard_actions/legacy_library_notification_action.tsx deleted file mode 100644 index 6716add2ee03a..0000000000000 --- a/src/plugins/dashboard/public/dashboard_actions/legacy_library_notification_action.tsx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import React from 'react'; - -import { - EmbeddableApiContext, - getInheritedViewMode, - getViewModeSubject, -} from '@kbn/presentation-publishing'; -import { Action, IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; -import { LibraryNotificationPopover } from './library_notification_popover'; -import { - legacyUnlinkActionIsCompatible, - LegacyUnlinkFromLibraryAction, -} from './legacy_unlink_from_library_action'; -import { dashboardLibraryNotificationStrings } from './_dashboard_actions_strings'; - -export const LEGACY_ACTION_LIBRARY_NOTIFICATION = 'LEGACY_ACTION_LIBRARY_NOTIFICATION'; - -export class LegacyLibraryNotificationAction implements Action { - public readonly id = LEGACY_ACTION_LIBRARY_NOTIFICATION; - public readonly type = LEGACY_ACTION_LIBRARY_NOTIFICATION; - public readonly order = 1; - - constructor(private unlinkAction: LegacyUnlinkFromLibraryAction) {} - - public readonly MenuItem = ({ context }: { context: EmbeddableApiContext }) => { - const { embeddable } = context; - if (!legacyUnlinkActionIsCompatible(embeddable)) throw new IncompatibleActionError(); - return ; - }; - - public couldBecomeCompatible({ embeddable }: EmbeddableApiContext) { - return legacyUnlinkActionIsCompatible(embeddable); - } - - public subscribeToCompatibilityChanges( - { embeddable }: EmbeddableApiContext, - onChange: (isCompatible: boolean, action: LegacyLibraryNotificationAction) => void - ) { - if (!legacyUnlinkActionIsCompatible(embeddable)) return; - - /** - * TODO: Upgrade this action by subscribing to changes in the existance of a saved object id. Currently, - * this is unnecessary because a link or unlink operation will cause the panel to unmount and remount. - */ - return getViewModeSubject(embeddable)?.subscribe((viewMode) => { - embeddable.canUnlinkFromLibrary().then((canUnlink) => { - onChange(viewMode === 'edit' && canUnlink, this); - }); - }); - } - - public getDisplayName({ embeddable }: EmbeddableApiContext) { - if (!legacyUnlinkActionIsCompatible(embeddable)) throw new IncompatibleActionError(); - return dashboardLibraryNotificationStrings.getDisplayName(); - } - - public getIconType({ embeddable }: EmbeddableApiContext) { - if (!legacyUnlinkActionIsCompatible(embeddable)) throw new IncompatibleActionError(); - return 'folderCheck'; - } - - public isCompatible = async ({ embeddable }: EmbeddableApiContext) => { - if (!legacyUnlinkActionIsCompatible(embeddable)) return false; - return getInheritedViewMode(embeddable) === 'edit' && embeddable.canUnlinkFromLibrary(); - }; - - public execute = async () => {}; -} diff --git a/src/plugins/dashboard/public/dashboard_actions/library_notification_action.tsx b/src/plugins/dashboard/public/dashboard_actions/library_notification_action.tsx deleted file mode 100644 index 4dd0b4df6f483..0000000000000 --- a/src/plugins/dashboard/public/dashboard_actions/library_notification_action.tsx +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import React from 'react'; - -import { - apiHasInPlaceLibraryTransforms, - EmbeddableApiContext, - getInheritedViewMode, - getViewModeSubject, -} from '@kbn/presentation-publishing'; -import { Action, IncompatibleActionError } from '@kbn/ui-actions-plugin/public'; -import { BehaviorSubject, combineLatest } from 'rxjs'; -import { LibraryNotificationPopover } from './library_notification_popover'; -import { isApiCompatible, UnlinkFromLibraryAction } from './unlink_from_library_action'; -import { dashboardLibraryNotificationStrings } from './_dashboard_actions_strings'; - -export const ACTION_LIBRARY_NOTIFICATION = 'ACTION_LIBRARY_NOTIFICATION'; - -export class LibraryNotificationAction implements Action { - public readonly id = ACTION_LIBRARY_NOTIFICATION; - public readonly type = ACTION_LIBRARY_NOTIFICATION; - public readonly order = 1; - - constructor(private unlinkAction: UnlinkFromLibraryAction) {} - - public readonly MenuItem = ({ context }: { context: EmbeddableApiContext }) => { - const { embeddable } = context; - if (!isApiCompatible(embeddable)) throw new IncompatibleActionError(); - return ; - }; - - public couldBecomeCompatible({ embeddable }: EmbeddableApiContext) { - return isApiCompatible(embeddable); - } - - public subscribeToCompatibilityChanges = ( - { embeddable }: EmbeddableApiContext, - onChange: (isCompatible: boolean, action: LibraryNotificationAction) => void - ) => { - if (!isApiCompatible(embeddable)) return; - const libraryIdSubject = apiHasInPlaceLibraryTransforms(embeddable) - ? embeddable.libraryId$ - : new BehaviorSubject(undefined); - const viewModeSubject = getViewModeSubject(embeddable); - if (!viewModeSubject) throw new IncompatibleActionError(); - - /** - * TODO: Upgrade this action by subscribing to changes in the existance of a saved object id. Currently, - * this is unnecessary because a link or unlink operation will cause the panel to unmount and remount. - */ - return combineLatest([libraryIdSubject, viewModeSubject]).subscribe(([libraryId, viewMode]) => { - this.unlinkAction.canUnlinkFromLibrary(embeddable).then((canUnlink) => { - onChange(viewMode === 'edit' && canUnlink, this); - }); - }); - }; - - public getDisplayName({ embeddable }: EmbeddableApiContext) { - if (!isApiCompatible(embeddable)) throw new IncompatibleActionError(); - return dashboardLibraryNotificationStrings.getDisplayName(); - } - - public getIconType({ embeddable }: EmbeddableApiContext) { - if (!isApiCompatible(embeddable)) throw new IncompatibleActionError(); - return 'folderCheck'; - } - - public isCompatible = async ({ embeddable }: EmbeddableApiContext) => { - if (!isApiCompatible(embeddable)) return false; - return ( - getInheritedViewMode(embeddable) === 'edit' && - this.unlinkAction.canUnlinkFromLibrary(embeddable) - ); - }; - - public execute = async () => {}; -} diff --git a/src/plugins/dashboard/public/dashboard_actions/library_notification_popover.test.tsx b/src/plugins/dashboard/public/dashboard_actions/library_notification_popover.test.tsx deleted file mode 100644 index 774e3c72242d4..0000000000000 --- a/src/plugins/dashboard/public/dashboard_actions/library_notification_popover.test.tsx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import { waitForEuiPopoverOpen } from '@elastic/eui/lib/test/rtl'; -import { I18nProvider } from '@kbn/i18n-react'; -import { ViewMode } from '@kbn/presentation-publishing'; -import { render, screen } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import React from 'react'; -import { BehaviorSubject } from 'rxjs'; -import { LibraryNotificationPopover } from './library_notification_popover'; -import { - LegacyUnlinkFromLibraryAction, - LegacyUnlinkPanelFromLibraryActionApi, -} from './legacy_unlink_from_library_action'; - -const mockUnlinkFromLibraryAction = { - execute: jest.fn(), - isCompatible: jest.fn().mockResolvedValue(true), - getDisplayName: jest.fn().mockReturnValue('Test Unlink'), -} as unknown as LegacyUnlinkFromLibraryAction; - -describe('library notification popover', () => { - let api: LegacyUnlinkPanelFromLibraryActionApi; - - beforeEach(async () => { - api = { - viewMode: new BehaviorSubject('edit'), - canUnlinkFromLibrary: jest.fn().mockResolvedValue(true), - unlinkFromLibrary: jest.fn(), - canLinkToLibrary: jest.fn().mockResolvedValue(true), - linkToLibrary: jest.fn(), - }; - }); - - const renderAndOpenPopover = async () => { - render( - - - - ); - await userEvent.click( - await screen.findByTestId('embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION') - ); - await waitForEuiPopoverOpen(); - }; - - it('renders the unlink button', async () => { - await renderAndOpenPopover(); - expect(await screen.findByText('Test Unlink')).toBeInTheDocument(); - }); - - it('calls the unlink action execute method on click', async () => { - await renderAndOpenPopover(); - const button = await screen.findByTestId('libraryNotificationUnlinkButton'); - await userEvent.click(button); - expect(mockUnlinkFromLibraryAction.execute).toHaveBeenCalled(); - }); -}); diff --git a/src/plugins/dashboard/public/dashboard_actions/library_notification_popover.tsx b/src/plugins/dashboard/public/dashboard_actions/library_notification_popover.tsx deleted file mode 100644 index dc2fe80e570ba..0000000000000 --- a/src/plugins/dashboard/public/dashboard_actions/library_notification_popover.tsx +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import React, { useState } from 'react'; -import { - EuiButton, - EuiButtonIcon, - EuiFlexGroup, - EuiFlexItem, - EuiPopover, - EuiPopoverFooter, - EuiPopoverTitle, - EuiText, -} from '@elastic/eui'; - -import { - LegacyUnlinkFromLibraryAction, - LegacyUnlinkPanelFromLibraryActionApi, -} from './legacy_unlink_from_library_action'; -import { dashboardLibraryNotificationStrings } from './_dashboard_actions_strings'; -import { - UnlinkFromLibraryAction, - UnlinkPanelFromLibraryActionApi, -} from './unlink_from_library_action'; - -export interface LibraryNotificationProps { - api: UnlinkPanelFromLibraryActionApi | LegacyUnlinkPanelFromLibraryActionApi; - unlinkAction: UnlinkFromLibraryAction | LegacyUnlinkFromLibraryAction; -} - -export function LibraryNotificationPopover({ unlinkAction, api }: LibraryNotificationProps) { - const [isPopoverOpen, setIsPopoverOpen] = useState(false); - - return ( - setIsPopoverOpen(!isPopoverOpen)} - data-test-subj={'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION'} - aria-label={dashboardLibraryNotificationStrings.getPopoverAriaLabel()} - /> - } - isOpen={isPopoverOpen} - closePopover={() => setIsPopoverOpen(false)} - anchorPosition="upCenter" - > - {dashboardLibraryNotificationStrings.getDisplayName()} -
- -

{dashboardLibraryNotificationStrings.getTooltip()}

-
-
- - - - { - setIsPopoverOpen(false); - unlinkAction.execute({ embeddable: api }); - }} - > - {unlinkAction.getDisplayName({ embeddable: api })} - - - - -
- ); -} diff --git a/test/accessibility/apps/dashboard.ts b/test/accessibility/apps/dashboard.ts index 73b841dbf3b71..2984c22d7c848 100644 --- a/test/accessibility/apps/dashboard.ts +++ b/test/accessibility/apps/dashboard.ts @@ -10,7 +10,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'home', 'settings']); + const { common, dashboard } = getPageObjects(['common', 'dashboard']); const a11y = getService('a11y'); const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardSettings = getService('dashboardSettings'); @@ -22,22 +22,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const clonedDashboardName = 'Dashboard Listing A11y (1)'; it('navitate to dashboard app', async () => { - await PageObjects.common.navigateToApp('dashboard'); + await common.navigateToApp('dashboard'); await a11y.testAppSnapshot(); }); it('create dashboard button', async () => { - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.clickNewDashboard(); await a11y.testAppSnapshot(); }); it('save empty dashboard', async () => { - await PageObjects.dashboard.saveDashboard(dashboardName); + await dashboard.saveDashboard(dashboardName); await a11y.testAppSnapshot(); }); it('Open Edit mode', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await a11y.testAppSnapshot(); }); @@ -58,17 +58,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('save the dashboard', async () => { - await PageObjects.dashboard.saveDashboard(dashboardName, { saveAsNew: false }); + await dashboard.saveDashboard(dashboardName, { saveAsNew: false }); await a11y.testAppSnapshot(); }); it('Open Edit mode again', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await a11y.testAppSnapshot(); }); it('open settings flyout', async () => { - await PageObjects.dashboard.openSettingsFlyout(); + await dashboard.openSettingsFlyout(); await a11y.testAppSnapshot(); }); @@ -106,35 +106,35 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Exit out of edit mode', async () => { - await PageObjects.dashboard.clickCancelOutOfEditMode(false); + await dashboard.clickCancelOutOfEditMode(false); await a11y.testAppSnapshot(); }); it('Discard changes', async () => { - await PageObjects.common.clickConfirmOnModal(); - await PageObjects.dashboard.getIsInViewMode(); + await common.clickConfirmOnModal(); + await dashboard.getIsInViewMode(); await a11y.testAppSnapshot(); }); // https://github.com/elastic/kibana/issues/153597 it.skip('Test full screen', async () => { - await PageObjects.dashboard.clickFullScreenMode(); + await dashboard.clickFullScreenMode(); await a11y.testAppSnapshot(); }); // https://github.com/elastic/kibana/issues/153597 it.skip('Exit out of full screen mode', async () => { - await PageObjects.dashboard.exitFullScreenMode(); + await dashboard.exitFullScreenMode(); await a11y.testAppSnapshot(); }); it('Make a clone of the dashboard', async () => { - await PageObjects.dashboard.duplicateDashboard(); + await dashboard.duplicateDashboard(); await a11y.testAppSnapshot(); }); it('Dashboard listing table', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); await a11y.testAppSnapshot(); }); @@ -143,7 +143,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await listingTable.checkListingSelectAllCheckbox(); await listingTable.clickDeleteSelected(); await a11y.testAppSnapshot(); - await PageObjects.common.clickConfirmOnModal(); + await common.clickConfirmOnModal(); await listingTable.isShowingEmptyPromptCreateNewButton(); }); }); diff --git a/test/accessibility/apps/discover.ts b/test/accessibility/apps/discover.ts index a24b5710a9d68..f94bc2d3c427e 100644 --- a/test/accessibility/apps/discover.ts +++ b/test/accessibility/apps/discover.ts @@ -10,10 +10,9 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { common, discover, share, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', - 'header', 'share', 'timePicker', 'unifiedFieldList', @@ -30,8 +29,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Discover a11y tests', () => { before(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setCommonlyUsedTime('Last_7 days'); + await common.navigateToApp('discover'); + await timePicker.setCommonlyUsedTime('Last_7 days'); }); it('Discover main page', async () => { @@ -39,29 +38,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('a11y test on save button', async () => { - await PageObjects.discover.clickSaveSearchButton(); + await discover.clickSaveSearchButton(); await a11y.testAppSnapshot(); }); it('a11y test on save search panel', async () => { - await PageObjects.discover.inputSavedSearchTitle('a11ySearch'); + await discover.inputSavedSearchTitle('a11ySearch'); await a11y.testAppSnapshot(); }); it('a11y test on clicking on confirm save', async () => { - await PageObjects.discover.clickConfirmSavedSearch(); + await discover.clickConfirmSavedSearch(); await a11y.testAppSnapshot(); }); it('a11y test on click new to reload discover', async () => { - await PageObjects.discover.clickNewSearchButton(); + await discover.clickNewSearchButton(); await a11y.testAppSnapshot(); }); it('a11y test on load saved search panel', async () => { - await PageObjects.discover.openLoadSavedSearchPanel(); + await discover.openLoadSavedSearchPanel(); await a11y.testAppSnapshot(); - await PageObjects.discover.closeLoadSavedSearchPanel(); + await discover.closeLoadSavedSearchPanel(); }); it('a11y test on inspector panel', async () => { @@ -71,45 +70,45 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('a11y test on share panel', async () => { - await PageObjects.share.clickShareTopNavButton(); + await share.clickShareTopNavButton(); await a11y.testAppSnapshot(); - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); }); it('a11y test on open sidenav filter', async () => { - await PageObjects.share.closeShareModal(); - await PageObjects.unifiedFieldList.openSidebarFieldFilter(); + await share.closeShareModal(); + await unifiedFieldList.openSidebarFieldFilter(); await a11y.testAppSnapshot(); - await PageObjects.unifiedFieldList.closeSidebarFieldFilter(); + await unifiedFieldList.closeSidebarFieldFilter(); }); it('a11y test on tables with columns view', async () => { for (const columnName of TEST_COLUMN_NAMES) { - await PageObjects.unifiedFieldList.clickFieldListItemToggle(columnName); + await unifiedFieldList.clickFieldListItemToggle(columnName); } await a11y.testAppSnapshot(); }); it('a11y test on save queries popover', async () => { - await PageObjects.discover.clickSavedQueriesPopOver(); + await discover.clickSavedQueriesPopOver(); await a11y.testAppSnapshot(); }); it('a11y test on save queries panel', async () => { - await PageObjects.discover.clickCurrentSavedQuery(); + await discover.clickCurrentSavedQuery(); await a11y.testAppSnapshot(); }); it('a11y test on toggle include filters option on saved queries panel', async () => { - await PageObjects.discover.setSaveQueryFormTitle('test'); - await PageObjects.discover.toggleIncludeFilters(); + await discover.setSaveQueryFormTitle('test'); + await discover.toggleIncludeFilters(); await a11y.testAppSnapshot(); - await PageObjects.discover.saveCurrentSavedQuery(); + await discover.saveCurrentSavedQuery(); }); it('a11y test on saved queries list panel', async () => { await savedQueryManagementComponent.loadSavedQuery('test'); - await PageObjects.discover.clickSavedQueriesPopOver(); + await discover.clickSavedQueriesPopOver(); await testSubjects.click('saved-query-management-load-button'); await savedQueryManagementComponent.deleteSavedQuery('test'); await a11y.testAppSnapshot({ @@ -128,12 +127,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('a11y test on JSON view of the document', async () => { - await PageObjects.discover.clickDocViewerTab('doc_view_source'); + await discover.clickDocViewerTab('doc_view_source'); await a11y.testAppSnapshot(); }); it('a11y test for actions on a field', async () => { - await PageObjects.discover.clickDocViewerTab('doc_view_table'); + await discover.clickDocViewerTab('doc_view_table'); await dataGrid.expandFieldNameCellInFlyout('Cancelled'); await a11y.testAppSnapshot(); await browser.pressKeys(browser.keys.ESCAPE); @@ -165,9 +164,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('a11y test for data grid with hidden chart', async () => { - await PageObjects.discover.closeHistogramPanel(); + await discover.closeHistogramPanel(); await a11y.testAppSnapshot(); - await PageObjects.discover.openHistogramPanel(); + await discover.openHistogramPanel(); }); it('a11y test for time interval panel', async () => { @@ -194,14 +193,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('a11y test for field statistics data grid view', async () => { - await PageObjects.discover.clickViewModeFieldStatsButton(); + await discover.clickViewModeFieldStatsButton(); await a11y.testAppSnapshot(); }); it('a11y test for data grid with collapsed side bar', async () => { - await PageObjects.discover.closeSidebar(); + await discover.closeSidebar(); await a11y.testAppSnapshot(); - await PageObjects.discover.openSidebar(); + await discover.openSidebar(); }); it('a11y test for adding a field from side bar', async () => { diff --git a/test/accessibility/apps/filter_panel.ts b/test/accessibility/apps/filter_panel.ts index 8cadea04968f5..2945c54e1cbae 100644 --- a/test/accessibility/apps/filter_panel.ts +++ b/test/accessibility/apps/filter_panel.ts @@ -10,7 +10,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'discover']); + const { common, discover } = getPageObjects(['common', 'discover']); const a11y = getService('a11y'); const filterBar = getService('filterBar'); const testSubjects = getService('testSubjects'); @@ -18,13 +18,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Filter panel', () => { before(async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); it('a11y test on add filter panel', async () => { - await PageObjects.discover.openAddFilterPanel(); + await discover.openAddFilterPanel(); await a11y.testAppSnapshot(); - await PageObjects.discover.closeAddFilterPanel(); + await discover.closeAddFilterPanel(); await filterBar.addFilter({ field: 'OriginCityName', operation: 'is', value: 'Rome' }); }); diff --git a/test/accessibility/apps/visualize.ts b/test/accessibility/apps/visualize.ts index e2df882b1f01d..c2ffc0d844c4b 100644 --- a/test/accessibility/apps/visualize.ts +++ b/test/accessibility/apps/visualize.ts @@ -10,24 +10,24 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'visualize', 'header']); + const { visualize } = getPageObjects(['visualize']); const a11y = getService('a11y'); describe('Visualize', () => { it('visualize', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await a11y.testAppSnapshot(); }); it('click on create visualize wizard', async () => { - await PageObjects.visualize.navigateToNewVisualization(); + await visualize.navigateToNewVisualization(); await a11y.testAppSnapshot(); }); it('create visualize button', async () => { - await PageObjects.visualize.clickAggBasedVisualizations(); - await PageObjects.visualize.waitForVisualizationSelectPage(); - await PageObjects.visualize.clickAreaChart(); + await visualize.clickAggBasedVisualizations(); + await visualize.waitForVisualizationSelectPage(); + await visualize.clickAreaChart(); await a11y.testAppSnapshot(); }); }); diff --git a/test/examples/discover_customization_examples/customizations.ts b/test/examples/discover_customization_examples/customizations.ts index 10246c7799910..f9e29611dc0cc 100644 --- a/test/examples/discover_customization_examples/customizations.ts +++ b/test/examples/discover_customization_examples/customizations.ts @@ -15,7 +15,7 @@ const TEST_END_TIME = 'Sep 23, 2015 @ 18:31:44.000'; // eslint-disable-next-line import/no-default-export export default ({ getService, getPageObjects }: FtrProviderContext) => { - const PageObjects = getPageObjects(['common', 'timePicker', 'header']); + const { common, timePicker, header } = getPageObjects(['common', 'timePicker', 'header']); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); @@ -30,14 +30,14 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('home'); + await common.navigateToApp('home'); const currentUrl = await browser.getCurrentUrl(); const customizationUrl = currentUrl.substring(0, currentUrl.indexOf('/app/home')) + '/app/discoverCustomizationExamples'; await browser.get(customizationUrl); - await PageObjects.timePicker.setAbsoluteRange(TEST_START_TIME, TEST_END_TIME); - await PageObjects.header.waitUntilLoadingHasFinished(); + await timePicker.setAbsoluteRange(TEST_START_TIME, TEST_END_TIME); + await header.waitUntilLoadingHasFinished(); }); after(async () => { @@ -62,9 +62,9 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { it('Search bar', async () => { await testSubjects.click('logsViewSelectorButton'); await testSubjects.click('logsViewSelectorOption-ASavedSearch'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { - const { title, description } = await PageObjects.common.getSharedItemTitleAndDescription(); + const { title, description } = await common.getSharedItemTitleAndDescription(); const expected = { title: 'A Saved Search', description: 'A Saved Search Description', @@ -73,7 +73,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { expect(description).to.eql(expected.description); }); await browser.goBack(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); it('Search bar Prepend Filters exists and should apply filter properly', async () => { @@ -97,7 +97,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { // Click the item to apply filter await item.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // Validate that filter is applied const rows = await dataGrid.getDocTableRows(); diff --git a/test/examples/expressions_explorer/index.ts b/test/examples/expressions_explorer/index.ts index 67b2102239645..d3c39a38cc1e3 100644 --- a/test/examples/expressions_explorer/index.ts +++ b/test/examples/expressions_explorer/index.ts @@ -16,12 +16,12 @@ export default function ({ loadTestFile, }: PluginFunctionalProviderContext) { const browser = getService('browser'); - const PageObjects = getPageObjects(['common', 'header']); + const { common } = getPageObjects(['common']); describe('expressions explorer', function () { before(async () => { await browser.setWindowSize(1300, 900); - await PageObjects.common.navigateToApp('expressionsExplorer'); + await common.navigateToApp('expressionsExplorer'); }); loadTestFile(require.resolve('./expressions')); diff --git a/test/examples/ui_actions/index.ts b/test/examples/ui_actions/index.ts index e977571bf9168..5a4d8de1f1527 100644 --- a/test/examples/ui_actions/index.ts +++ b/test/examples/ui_actions/index.ts @@ -16,12 +16,12 @@ export default function ({ loadTestFile, }: PluginFunctionalProviderContext) { const browser = getService('browser'); - const PageObjects = getPageObjects(['common', 'header']); + const { common } = getPageObjects(['common']); describe('ui actions explorer', function () { before(async () => { await browser.setWindowSize(1300, 900); - await PageObjects.common.navigateToApp('uiActionsExplorer'); + await common.navigateToApp('uiActionsExplorer'); }); loadTestFile(require.resolve('./ui_actions')); diff --git a/test/functional/apps/context/_discover_navigation.ts b/test/functional/apps/context/_discover_navigation.ts index 3b806d6b2ed52..37dd92a8be50c 100644 --- a/test/functional/apps/context/_discover_navigation.ts +++ b/test/functional/apps/context/_discover_navigation.ts @@ -20,16 +20,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const dataGrid = getService('dataGrid'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects([ - 'common', - 'discover', - 'timePicker', - 'settings', - 'dashboard', - 'context', - 'header', - 'unifiedFieldList', - ]); + const { common, discover, timePicker, dashboard, context, header, unifiedFieldList } = + getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'dashboard', + 'context', + 'header', + 'unifiedFieldList', + ]); const testSubjects = getService('testSubjects'); const dashboardAddPanel = getService('dashboardAddPanel'); const browser = getService('browser'); @@ -37,20 +37,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('context link in discover', () => { before(async () => { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: 'logstash-*', }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); for (const columnName of TEST_COLUMN_NAMES) { - await PageObjects.unifiedFieldList.clickFieldListItemAdd(columnName); + await unifiedFieldList.clickFieldListItemAdd(columnName); } for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) { await filterBar.addFilter({ field: columnName, operation: 'is', value }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); } }); @@ -77,7 +77,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const rowActions = await dataGrid.getRowActions({ rowIndex: 0 }); await rowActions[1].click(); - await PageObjects.context.waitUntilContextLoadingHasFinished(); + await context.waitUntilContextLoadingHasFinished(); const anchorTimestamp = await getTimestamp(true); return anchorTimestamp === firstDiscoverTimestamp; }); @@ -89,7 +89,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const rowActions = await dataGrid.getRowActions({ rowIndex: 0 }); await rowActions[1].click(); - await PageObjects.context.waitUntilContextLoadingHasFinished(); + await context.waitUntilContextLoadingHasFinished(); const anchorTimestamp = await getTimestamp(true); return anchorTimestamp === firstContextTimestamp; }); @@ -111,7 +111,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should navigate to the first document and then back to discover', async () => { - await PageObjects.context.waitUntilContextLoadingHasFinished(); + await context.waitUntilContextLoadingHasFinished(); // click the open action await retry.try(async () => { @@ -126,26 +126,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(hasDocHit).to.be(true); await testSubjects.click('~breadcrumb & ~first'); - await PageObjects.discover.waitForDiscoverAppOnScreen(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitForDiscoverAppOnScreen(); + await discover.waitUntilSearchingHasFinished(); }); it('navigates to doc view from embeddable', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.saveSearch('my search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await discover.saveSearch('my search'); + await header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.addSavedSearch('my search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dataGrid.clickRowToggle({ rowIndex: 0 }); const rowActions = await dataGrid.getRowActions({ rowIndex: 0 }); await rowActions[0].click(); - await PageObjects.common.sleep(250); + await common.sleep(250); // close popup const alert = await browser.getAlert(); @@ -159,7 +159,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return currentUrl.includes('#/doc'); }); await retry.waitFor('doc view being rendered', async () => { - return await PageObjects.discover.isShowingDocViewer(); + return await discover.isShowingDocViewer(); }); }); }); diff --git a/test/functional/apps/context/classic/_discover_navigation.ts b/test/functional/apps/context/classic/_discover_navigation.ts index a053d22e8a516..a0bd5847544c5 100644 --- a/test/functional/apps/context/classic/_discover_navigation.ts +++ b/test/functional/apps/context/classic/_discover_navigation.ts @@ -20,16 +20,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const docTable = getService('docTable'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects([ - 'common', - 'discover', - 'timePicker', - 'settings', - 'dashboard', - 'context', - 'header', - 'unifiedFieldList', - ]); + const { common, discover, timePicker, dashboard, context, header, unifiedFieldList } = + getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'dashboard', + 'context', + 'header', + 'unifiedFieldList', + ]); const testSubjects = getService('testSubjects'); const dashboardAddPanel = getService('dashboardAddPanel'); const browser = getService('browser'); @@ -37,20 +37,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('context link in discover classic', () => { before(async () => { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ 'doc_table:legacy': true, defaultIndex: 'logstash-*', }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); for (const columnName of TEST_COLUMN_NAMES) { - await PageObjects.unifiedFieldList.clickFieldListItemAdd(columnName); + await unifiedFieldList.clickFieldListItemAdd(columnName); } for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) { - await PageObjects.unifiedFieldList.clickFieldListItem(columnName); - await PageObjects.unifiedFieldList.clickFieldListPlusFilter(columnName, value); + await unifiedFieldList.clickFieldListItem(columnName); + await unifiedFieldList.clickFieldListPlusFilter(columnName, value); } }); after(async () => { @@ -76,7 +76,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await docTable.clickRowToggle({ rowIndex: 0 }); const rowActions = await docTable.getRowActions({ rowIndex: 0 }); await rowActions[0].click(); - await PageObjects.context.waitUntilContextLoadingHasFinished(); + await context.waitUntilContextLoadingHasFinished(); const anchorTimestamp = await getTimestamp(true); return anchorTimestamp === firstDiscoverTimestamp; }); @@ -87,7 +87,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await docTable.clickRowToggle({ rowIndex: 0 }); const rowActions = await docTable.getRowActions({ rowIndex: 0 }); await rowActions[0].click(); - await PageObjects.context.waitUntilContextLoadingHasFinished(); + await context.waitUntilContextLoadingHasFinished(); const anchorTimestamp = await getTimestamp(true); return anchorTimestamp === firstContextTimestamp; }); @@ -110,7 +110,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // bugfix: https://github.com/elastic/kibana/issues/92099 it('should navigate to the first document and then back to discover', async () => { - await PageObjects.context.waitUntilContextLoadingHasFinished(); + await context.waitUntilContextLoadingHasFinished(); // navigate to the doc view await docTable.clickRowToggle({ rowIndex: 0 }); @@ -128,26 +128,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(hasDocHit).to.be(true); await testSubjects.click('~breadcrumb & ~first'); - await PageObjects.discover.waitForDiscoverAppOnScreen(); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await discover.waitForDiscoverAppOnScreen(); + await discover.waitForDocTableLoadingComplete(); }); it('navigates to doc view from embeddable', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.saveSearch('my classic search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await discover.saveSearch('my classic search'); + await header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.addSavedSearch('my classic search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await docTable.clickRowToggle({ rowIndex: 0 }); const rowActions = await docTable.getRowActions({ rowIndex: 0 }); await rowActions[1].click(); - await PageObjects.common.sleep(250); + await common.sleep(250); // close popup const alert = await browser.getAlert(); @@ -161,7 +161,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return currentUrl.includes('#/doc'); }); await retry.waitFor('doc view being rendered', async () => { - return await PageObjects.discover.isShowingDocViewer(); + return await discover.isShowingDocViewer(); }); }); }); diff --git a/test/functional/apps/dashboard/group1/create_and_add_embeddables.ts b/test/functional/apps/dashboard/group1/create_and_add_embeddables.ts index a5a32af88ccab..61929b19ff468 100644 --- a/test/functional/apps/dashboard/group1/create_and_add_embeddables.ts +++ b/test/functional/apps/dashboard/group1/create_and_add_embeddables.ts @@ -14,7 +14,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); - const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'settings', 'common']); + const { dashboard, header, visualize } = getPageObjects(['dashboard', 'header', 'visualize']); const browser = getService('browser'); const kibanaServer = getService('kibanaServer'); const dashboardAddPanel = getService('dashboardAddPanel'); @@ -31,9 +31,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('ensure toolbar popover closes on add', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + await dashboard.switchToEditMode(); await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAddNewPanelFromUIActionLink('Log stream (deprecated)'); await dashboardAddPanel.expectEditorMenuClosed(); @@ -45,73 +45,70 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('add new visualization link', () => { before(async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('few panels'); }); it('adds new visualization via the top nav link', async () => { - const originalPanelCount = await PageObjects.dashboard.getPanelCount(); - await PageObjects.dashboard.switchToEditMode(); + const originalPanelCount = await dashboard.getPanelCount(); + await dashboard.switchToEditMode(); await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAggBasedVisualizations(); - await PageObjects.visualize.clickAreaChart(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visualize.saveVisualizationExpectSuccess( - 'visualization from top nav add new panel', - { redirectToOrigin: true } - ); + await visualize.clickAreaChart(); + await visualize.clickNewSearch(); + await visualize.saveVisualizationExpectSuccess('visualization from top nav add new panel', { + redirectToOrigin: true, + }); await retry.try(async () => { - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(originalPanelCount + 1); }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); }); it('adds a new visualization', async () => { - const originalPanelCount = await PageObjects.dashboard.getPanelCount(); + const originalPanelCount = await dashboard.getPanelCount(); await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAggBasedVisualizations(); - await PageObjects.visualize.clickAreaChart(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visualize.saveVisualizationExpectSuccess( - 'visualization from add new link', - { redirectToOrigin: true } - ); + await visualize.clickAreaChart(); + await visualize.clickNewSearch(); + await visualize.saveVisualizationExpectSuccess('visualization from add new link', { + redirectToOrigin: true, + }); await retry.try(async () => { - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(originalPanelCount + 1); }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); }); it('adds a new timelion visualization', async () => { // adding this case, as the timelion agg-based viz doesn't need the `clickNewSearch()` step - const originalPanelCount = await PageObjects.dashboard.getPanelCount(); + const originalPanelCount = await dashboard.getPanelCount(); await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAggBasedVisualizations(); - await PageObjects.visualize.clickTimelion(); - await PageObjects.visualize.saveVisualizationExpectSuccess( - 'timelion visualization from add new link', - { redirectToOrigin: true } - ); + await visualize.clickTimelion(); + await visualize.saveVisualizationExpectSuccess('timelion visualization from add new link', { + redirectToOrigin: true, + }); await retry.try(async () => { - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(originalPanelCount + 1); }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); }); it('saves the listing page instead of the visualization to the app link', async () => { - await PageObjects.header.clickVisualize(true); + await header.clickVisualize(true); const currentUrl = await browser.getCurrentUrl(); expect(currentUrl).not.to.contain(VisualizeConstants.EDIT_PATH); }); after(async () => { - await PageObjects.header.clickDashboard(); + await header.clickDashboard(); }); }); }); diff --git a/test/functional/apps/dashboard/group1/dashboard_unsaved_listing.ts b/test/functional/apps/dashboard/group1/dashboard_unsaved_listing.ts index a1c649de32f62..9a46ca1051d6a 100644 --- a/test/functional/apps/dashboard/group1/dashboard_unsaved_listing.ts +++ b/test/functional/apps/dashboard/group1/dashboard_unsaved_listing.ts @@ -12,7 +12,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'settings', 'common']); + const { dashboard, header, visualize } = getPageObjects(['dashboard', 'header', 'visualize']); const kibanaServer = getService('kibanaServer'); const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardPanelActions = getService('dashboardPanelActions'); @@ -27,9 +27,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // add an area chart by value await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAggBasedVisualizations(); - await PageObjects.visualize.clickAreaChart(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visualize.saveVisualizationAndReturn(); + await visualize.clickAreaChart(); + await visualize.clickNewSearch(); + await visualize.saveVisualizationAndReturn(); // add a metric by reference await dashboardAddPanel.addVisualization('Rendering-Test: metric'); @@ -43,8 +43,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); }); after(async () => { @@ -52,126 +52,126 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('lists unsaved changes to existing dashboards', async () => { - await PageObjects.dashboard.loadSavedDashboard(dashboardTitle); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.loadSavedDashboard(dashboardTitle); + await dashboard.switchToEditMode(); await addSomePanels(); - existingDashboardPanelCount = await PageObjects.dashboard.getPanelCount(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.expectUnsavedChangesListingExists(dashboardTitle); + existingDashboardPanelCount = await dashboard.getPanelCount(); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); + await dashboard.expectUnsavedChangesListingExists(dashboardTitle); }); it('restores unsaved changes to existing dashboards', async () => { - await PageObjects.dashboard.clickUnsavedChangesContinueEditing(dashboardTitle); - await PageObjects.header.waitUntilLoadingHasFinished(); - const currentPanelCount = await PageObjects.dashboard.getPanelCount(); + await dashboard.clickUnsavedChangesContinueEditing(dashboardTitle); + await header.waitUntilLoadingHasFinished(); + const currentPanelCount = await dashboard.getPanelCount(); expect(currentPanelCount).to.eql(existingDashboardPanelCount); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); }); it('lists unsaved changes to new dashboards', async () => { - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.clickNewDashboard(); await addSomePanels(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.expectUnsavedChangesListingExists(unsavedDashboardTitle); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); + await dashboard.expectUnsavedChangesListingExists(unsavedDashboardTitle); }); it('restores unsaved changes to new dashboards', async () => { - await PageObjects.dashboard.clickUnsavedChangesContinueEditing(unsavedDashboardTitle); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect(await PageObjects.dashboard.getPanelCount()).to.eql(2); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.clickUnsavedChangesContinueEditing(unsavedDashboardTitle); + await header.waitUntilLoadingHasFinished(); + expect(await dashboard.getPanelCount()).to.eql(2); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); }); it('shows a warning on create new, and restores panels if continue is selected', async () => { - await PageObjects.dashboard.clickNewDashboard({ continueEditing: true, expectWarning: true }); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect(await PageObjects.dashboard.getPanelCount()).to.eql(2); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.clickNewDashboard({ continueEditing: true, expectWarning: true }); + await header.waitUntilLoadingHasFinished(); + expect(await dashboard.getPanelCount()).to.eql(2); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); }); it('shows a warning on create new, and clears unsaved panels if discard is selected', async () => { - await PageObjects.dashboard.clickNewDashboard({ + await dashboard.clickNewDashboard({ continueEditing: false, expectWarning: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect(await PageObjects.dashboard.getPanelCount()).to.eql(0); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); + expect(await dashboard.getPanelCount()).to.eql(0); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); }); it('does not show unsaved changes on new dashboard when no panels have been added', async () => { - await PageObjects.dashboard.expectUnsavedChangesListingDoesNotExist(unsavedDashboardTitle); + await dashboard.expectUnsavedChangesListingDoesNotExist(unsavedDashboardTitle); }); it('can discard unsaved changes using the discard link', async () => { - await PageObjects.dashboard.clickUnsavedChangesDiscard( + await dashboard.clickUnsavedChangesDiscard( `discard-unsaved-${dashboardTitle.split(' ').join('-')}` ); - await PageObjects.dashboard.expectUnsavedChangesListingDoesNotExist(dashboardTitle); - await PageObjects.dashboard.loadSavedDashboard(dashboardTitle); - await PageObjects.dashboard.switchToEditMode(); - const currentPanelCount = await PageObjects.dashboard.getPanelCount(); + await dashboard.expectUnsavedChangesListingDoesNotExist(dashboardTitle); + await dashboard.loadSavedDashboard(dashboardTitle); + await dashboard.switchToEditMode(); + const currentPanelCount = await dashboard.getPanelCount(); expect(currentPanelCount).to.eql(existingDashboardPanelCount - 2); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); }); it('loses unsaved changes to new dashboard upon saving', async () => { - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.clickNewDashboard(); await addSomePanels(); // ensure that the unsaved listing exists first - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.clickUnsavedChangesContinueEditing(unsavedDashboardTitle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); + await dashboard.clickUnsavedChangesContinueEditing(unsavedDashboardTitle); + await header.waitUntilLoadingHasFinished(); // Save the dashboard, and check that it now does not exist - await PageObjects.dashboard.saveDashboard(newDashboartTitle); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.expectUnsavedChangesListingDoesNotExist(unsavedDashboardTitle); + await dashboard.saveDashboard(newDashboartTitle); + await header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.expectUnsavedChangesListingDoesNotExist(unsavedDashboardTitle); }); it('does not list unsaved changes when unsaved version of the dashboard is the same', async () => { - await PageObjects.dashboard.loadSavedDashboard(newDashboartTitle); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.loadSavedDashboard(newDashboartTitle); + await dashboard.switchToEditMode(); // add another panel so we can delete it later await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAggBasedVisualizations(); - await PageObjects.visualize.clickAreaChart(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visualize.saveVisualizationExpectSuccess('Wildvis', { + await visualize.clickAreaChart(); + await visualize.clickNewSearch(); + await visualize.saveVisualizationExpectSuccess('Wildvis', { redirectToOrigin: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); // wait for the unsaved changes badge to appear. - await PageObjects.dashboard.expectUnsavedChangesBadge(); + await dashboard.expectUnsavedChangesBadge(); // ensure that the unsaved listing exists - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.expectUnsavedChangesListingExists(newDashboartTitle); - await PageObjects.dashboard.clickUnsavedChangesContinueEditing(newDashboartTitle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); + await dashboard.expectUnsavedChangesListingExists(newDashboartTitle); + await dashboard.clickUnsavedChangesContinueEditing(newDashboartTitle); + await header.waitUntilLoadingHasFinished(); // Remove the panel that was just added await dashboardPanelActions.removePanelByTitle('Wildvis'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // Check that it now does not exist - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.expectUnsavedChangesListingDoesNotExist(newDashboartTitle); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); + await dashboard.expectUnsavedChangesListingDoesNotExist(newDashboartTitle); }); }); } diff --git a/test/functional/apps/dashboard/group1/dashboard_unsaved_state.ts b/test/functional/apps/dashboard/group1/dashboard_unsaved_state.ts index d50e281888124..a26b8d9f9b913 100644 --- a/test/functional/apps/dashboard/group1/dashboard_unsaved_state.ts +++ b/test/functional/apps/dashboard/group1/dashboard_unsaved_state.ts @@ -12,7 +12,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'settings', 'common']); + const { dashboard, header, visualize } = getPageObjects(['dashboard', 'header', 'visualize']); const browser = getService('browser'); const queryBar = getService('queryBar'); const filterBar = getService('filterBar'); @@ -33,12 +33,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); - originalPanelCount = await PageObjects.dashboard.getPanelCount(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('few panels'); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); + originalPanelCount = await dashboard.getPanelCount(); }); after(async () => { @@ -60,21 +60,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; it('persists after navigating to the listing page and back', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); + await dashboard.loadSavedDashboard('few panels'); + await dashboard.waitForRenderComplete(); await validateQueryAndFilter(); }); it('persists after navigating to Visualize and back', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.visualize.gotoVisualizationLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await visualize.gotoVisualizationLandingPage(); + await header.waitUntilLoadingHasFinished(); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('few panels'); + await dashboard.waitForRenderComplete(); await validateQueryAndFilter(); }); @@ -82,13 +82,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.refresh(); const alert = await browser.getAlert(); await alert?.accept(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await validateQueryAndFilter(); }); it('can discard changes', async () => { - await PageObjects.dashboard.clickDiscardChanges(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.clickDiscardChanges(); + await dashboard.waitForRenderComplete(); const query = await queryBar.getQueryString(); expect(query).to.eql(''); @@ -102,9 +102,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // add an area chart by value await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAggBasedVisualizations(); - await PageObjects.visualize.clickAreaChart(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visualize.saveVisualizationAndReturn(); + await visualize.clickAreaChart(); + await visualize.clickNewSearch(); + await visualize.saveVisualizationAndReturn(); // add a metric by reference await dashboardAddPanel.addVisualization('Rendering-Test: metric'); @@ -115,67 +115,67 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('shows the unsaved changes badge after adding panels', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await addPanels(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('dashboardUnsavedChangesBadge'); }); it('has correct number of panels', async () => { - unsavedPanelCount = await PageObjects.dashboard.getPanelCount(); + unsavedPanelCount = await dashboard.getPanelCount(); expect(unsavedPanelCount).to.eql(originalPanelCount + 2); }); it('retains unsaved panel count after navigating to listing page and back', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); - const currentPanelCount = await PageObjects.dashboard.getPanelCount(); + await header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); + await dashboard.loadSavedDashboard('few panels'); + const currentPanelCount = await dashboard.getPanelCount(); expect(currentPanelCount).to.eql(unsavedPanelCount); }); it('retains unsaved panel count after navigating to another app and back', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.visualize.gotoVisualizationLandingPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.navigateToApp(); - if (await PageObjects.dashboard.onDashboardLandingPage()) { + await header.waitUntilLoadingHasFinished(); + await visualize.gotoVisualizationLandingPage(); + await header.waitUntilLoadingHasFinished(); + await dashboard.navigateToApp(); + if (await dashboard.onDashboardLandingPage()) { await testSubjects.existOrFail('unsavedDashboardsCallout'); } - await PageObjects.dashboard.loadSavedDashboard('few panels'); - const currentPanelCount = await PageObjects.dashboard.getPanelCount(); + await dashboard.loadSavedDashboard('few panels'); + const currentPanelCount = await dashboard.getPanelCount(); expect(currentPanelCount).to.eql(unsavedPanelCount); }); it('can discard changes', async () => { - unsavedPanelCount = await PageObjects.dashboard.getPanelCount(); + unsavedPanelCount = await dashboard.getPanelCount(); expect(unsavedPanelCount).to.eql(originalPanelCount + 2); - await PageObjects.dashboard.clickDiscardChanges(); - const currentPanelCount = await PageObjects.dashboard.getPanelCount(); + await dashboard.clickDiscardChanges(); + const currentPanelCount = await dashboard.getPanelCount(); expect(currentPanelCount).to.eql(originalPanelCount); }); it('resets to original panel count after switching to view mode and discarding changes', async () => { await addPanels(); - await PageObjects.header.waitUntilLoadingHasFinished(); - unsavedPanelCount = await PageObjects.dashboard.getPanelCount(); + await header.waitUntilLoadingHasFinished(); + unsavedPanelCount = await dashboard.getPanelCount(); expect(unsavedPanelCount).to.eql(originalPanelCount + 2); - await PageObjects.dashboard.clickCancelOutOfEditMode(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const currentPanelCount = await PageObjects.dashboard.getPanelCount(); + await dashboard.clickCancelOutOfEditMode(); + await header.waitUntilLoadingHasFinished(); + const currentPanelCount = await dashboard.getPanelCount(); expect(currentPanelCount).to.eql(originalPanelCount); - expect(PageObjects.dashboard.getIsInViewMode()).to.eql(true); + expect(dashboard.getIsInViewMode()).to.eql(true); }); it('does not show unsaved changes badge after saving', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await addPanels(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.saveDashboard('Unsaved State Test'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await dashboard.saveDashboard('Unsaved State Test'); + await header.waitUntilLoadingHasFinished(); await testSubjects.missingOrFail('dashboardUnsavedChangesBadge'); }); }); diff --git a/test/functional/apps/dashboard/group1/edit_embeddable_redirects.ts b/test/functional/apps/dashboard/group1/edit_embeddable_redirects.ts index 624014b02862f..2f40111ce1ed0 100644 --- a/test/functional/apps/dashboard/group1/edit_embeddable_redirects.ts +++ b/test/functional/apps/dashboard/group1/edit_embeddable_redirects.ts @@ -12,7 +12,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'settings', 'common']); + const { dashboard, header, visualize } = getPageObjects(['dashboard', 'header', 'visualize']); const kibanaServer = getService('kibanaServer'); const dashboardPanelActions = getService('dashboardPanelActions'); const dashboardAddPanel = getService('dashboardAddPanel'); @@ -26,10 +26,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('few panels'); + await dashboard.switchToEditMode(); }); after(async () => { @@ -38,64 +38,64 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('redirects via save and return button after edit', async () => { await dashboardPanelActions.clickEdit(); - await PageObjects.visualize.saveVisualizationAndReturn(); + await visualize.saveVisualizationAndReturn(); }); it('redirects via save as button after edit, renaming itself', async () => { const newTitle = 'wowee, looks like I have a new title'; - await PageObjects.header.waitUntilLoadingHasFinished(); - const originalPanelCount = await PageObjects.dashboard.getPanelCount(); + await header.waitUntilLoadingHasFinished(); + const originalPanelCount = await dashboard.getPanelCount(); await dashboardPanelActions.clickEdit(); - await PageObjects.visualize.saveVisualizationExpectSuccess(newTitle, { + await visualize.saveVisualizationExpectSuccess(newTitle, { saveAsNew: false, redirectToOrigin: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + await header.waitUntilLoadingHasFinished(); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.eql(originalPanelCount); - const titles = await PageObjects.dashboard.getPanelTitles(); + const titles = await dashboard.getPanelTitles(); expect(titles.indexOf(newTitle)).to.not.be(-1); }); it('redirects via save as button after edit, adding a new panel', async () => { const newTitle = 'wowee, my title just got cooler'; - await PageObjects.header.waitUntilLoadingHasFinished(); - const originalPanelCount = await PageObjects.dashboard.getPanelCount(); + await header.waitUntilLoadingHasFinished(); + const originalPanelCount = await dashboard.getPanelCount(); await dashboardPanelActions.clickEdit(); - await PageObjects.visualize.saveVisualizationExpectSuccess(newTitle, { + await visualize.saveVisualizationExpectSuccess(newTitle, { saveAsNew: true, redirectToOrigin: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + await header.waitUntilLoadingHasFinished(); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.eql(originalPanelCount + 1); - const titles = await PageObjects.dashboard.getPanelTitles(); + const titles = await dashboard.getPanelTitles(); expect(titles.indexOf(newTitle)).to.not.be(-1); }); it('loses originatingApp connection after save as when redirectToOrigin is false', async () => { const newTitle = 'wowee, my title just got cooler again'; - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dashboardPanelActions.editPanelByTitle('wowee, my title just got cooler'); - await PageObjects.visualize.linkedToOriginatingApp(); - await PageObjects.visualize.saveVisualizationExpectSuccess(newTitle, { + await visualize.linkedToOriginatingApp(); + await visualize.saveVisualizationExpectSuccess(newTitle, { saveAsNew: true, redirectToOrigin: false, }); - await PageObjects.visualize.notLinkedToOriginatingApp(); - await PageObjects.dashboard.navigateToApp(); + await visualize.notLinkedToOriginatingApp(); + await dashboard.navigateToApp(); }); it('loses originatingApp connection after first save when redirectToOrigin is false', async () => { const newTitle = 'test create panel originatingApp'; - await PageObjects.dashboard.loadSavedDashboard('few panels'); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.loadSavedDashboard('few panels'); + await dashboard.switchToEditMode(); await dashboardAddPanel.clickMarkdownQuickButton(); - await PageObjects.visualize.saveVisualizationExpectSuccess(newTitle, { + await visualize.saveVisualizationExpectSuccess(newTitle, { saveAsNew: true, redirectToOrigin: false, }); - await PageObjects.visualize.notLinkedToOriginatingApp(); + await visualize.notLinkedToOriginatingApp(); }); }); } diff --git a/test/functional/apps/dashboard/group1/edit_visualizations.js b/test/functional/apps/dashboard/group1/edit_visualizations.js index fce7bac23a5c4..decd7441e1d45 100644 --- a/test/functional/apps/dashboard/group1/edit_visualizations.js +++ b/test/functional/apps/dashboard/group1/edit_visualizations.js @@ -10,7 +10,13 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { - const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'common', 'visEditor']); + const { dashboard, header, visualize, common, visEditor } = getPageObjects([ + 'dashboard', + 'header', + 'visualize', + 'common', + 'visEditor', + ]); const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); const kibanaServer = getService('kibanaServer'); @@ -22,23 +28,23 @@ export default function ({ getService, getPageObjects }) { const createMarkdownVis = async (title) => { await dashboardAddPanel.clickMarkdownQuickButton(); - await PageObjects.visEditor.setMarkdownTxt(originalMarkdownText); - await PageObjects.visEditor.clickGo(); + await visEditor.setMarkdownTxt(originalMarkdownText); + await visEditor.clickGo(); if (title) { - await PageObjects.visualize.saveVisualizationExpectSuccess(title, { + await visualize.saveVisualizationExpectSuccess(title, { saveAsNew: true, redirectToOrigin: true, }); } else { - await PageObjects.visualize.saveVisualizationAndReturn(); + await visualize.saveVisualizationAndReturn(); } }; const editMarkdownVis = async () => { await dashboardPanelActions.clickEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.visEditor.setMarkdownTxt(modifiedMarkdownText); - await PageObjects.visEditor.clickGo(); + await header.waitUntilLoadingHasFinished(); + await visEditor.setMarkdownTxt(modifiedMarkdownText); + await visEditor.clickGo(); }; describe('edit visualizations from dashboard', () => { @@ -50,7 +56,7 @@ export default function ({ getService, getPageObjects }) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); }); after(async () => { @@ -59,13 +65,13 @@ export default function ({ getService, getPageObjects }) { it('save button returns to dashboard after editing visualization with changes saved', async () => { const title = 'test save'; - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); await createMarkdownVis(title); await editMarkdownVis(); - await PageObjects.visualize.saveVisualizationAndReturn(); + await visualize.saveVisualizationAndReturn(); const markdownText = await testSubjects.find('markdownBody'); expect(await markdownText.getVisibleText()).to.eql(modifiedMarkdownText); @@ -73,13 +79,13 @@ export default function ({ getService, getPageObjects }) { it('cancel button returns to dashboard after editing visualization without saving', async () => { const title = 'test cancel'; - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); await createMarkdownVis(title); await editMarkdownVis(); - await PageObjects.visualize.cancelAndReturn(true); + await visualize.cancelAndReturn(true); const markdownText = await testSubjects.find('markdownBody'); expect(await markdownText.getVisibleText()).to.eql(originalMarkdownText); @@ -87,106 +93,106 @@ export default function ({ getService, getPageObjects }) { it('cancel button returns to dashboard with no modal if there are no changes to apply', async () => { await dashboardPanelActions.clickEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.visualize.cancelAndReturn(false); + await visualize.cancelAndReturn(false); const markdownText = await testSubjects.find('markdownBody'); expect(await markdownText.getVisibleText()).to.eql(originalMarkdownText); }); it('visualize app menu navigates to the visualize listing page if the last opened visualization was by value', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); // Create markdown by value. await createMarkdownVis(); // Edit then save and return await editMarkdownVis(); - await PageObjects.visualize.saveVisualizationAndReturn(); + await visualize.saveVisualizationAndReturn(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await appsMenu.clickLink('Visualize Library'); - await PageObjects.common.clickConfirmOnModal(); + await common.clickConfirmOnModal(); expect(await testSubjects.exists('visualizationLandingPage')).to.be(true); }); it('visualize app menu navigates to the visualize listing page if the last opened visualization was linked to dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); // Create markdown by reference. await createMarkdownVis('by reference'); // Edit then save and return await editMarkdownVis(); - await PageObjects.visualize.saveVisualizationAndReturn(); + await visualize.saveVisualizationAndReturn(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await appsMenu.clickLink('Visualize Library'); - await PageObjects.common.clickConfirmOnModal(); + await common.clickConfirmOnModal(); expect(await testSubjects.exists('visualizationLandingPage')).to.be(true); }); describe('by value', () => { it('save and return button returns to dashboard after editing visualization with changes saved', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await createMarkdownVis(); - const originalPanelCount = PageObjects.dashboard.getPanelCount(); + const originalPanelCount = dashboard.getPanelCount(); await editMarkdownVis(); - await PageObjects.visualize.saveVisualizationAndReturn(); + await visualize.saveVisualizationAndReturn(); const markdownText = await testSubjects.find('markdownBody'); expect(await markdownText.getVisibleText()).to.eql(modifiedMarkdownText); - const newPanelCount = PageObjects.dashboard.getPanelCount(); + const newPanelCount = dashboard.getPanelCount(); expect(newPanelCount).to.eql(originalPanelCount); }); it('cancel button returns to dashboard after editing visualization without saving', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); await createMarkdownVis(); await editMarkdownVis(); - await PageObjects.visualize.cancelAndReturn(true); + await visualize.cancelAndReturn(true); const markdownText = await testSubjects.find('markdownBody'); expect(await markdownText.getVisibleText()).to.eql(originalMarkdownText); }); it('save to library button returns to dashboard after editing visualization with changes saved', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); await createMarkdownVis(); - const originalPanelCount = PageObjects.dashboard.getPanelCount(); + const originalPanelCount = dashboard.getPanelCount(); await editMarkdownVis(); - await PageObjects.visualize.saveVisualization('test save to library', { + await visualize.saveVisualization('test save to library', { redirectToOrigin: true, }); const markdownText = await testSubjects.find('markdownBody'); expect(await markdownText.getVisibleText()).to.eql(modifiedMarkdownText); - const newPanelCount = PageObjects.dashboard.getPanelCount(); + const newPanelCount = dashboard.getPanelCount(); expect(newPanelCount).to.eql(originalPanelCount); }); it('should lose its connection to the dashboard when creating new visualization', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); - await PageObjects.visualize.clickNewVisualization(); - await PageObjects.visualize.clickMarkdownWidget(); - await PageObjects.visualize.notLinkedToOriginatingApp(); + await visualize.gotoVisualizationLandingPage(); + await visualize.clickNewVisualization(); + await visualize.clickMarkdownWidget(); + await visualize.notLinkedToOriginatingApp(); // return to origin should not be present in save modal await testSubjects.click('visualizeSaveButton'); diff --git a/test/functional/apps/dashboard/group1/embeddable_data_grid.ts b/test/functional/apps/dashboard/group1/embeddable_data_grid.ts index 0fc763a26abd8..781f9cda2d685 100644 --- a/test/functional/apps/dashboard/group1/embeddable_data_grid.ts +++ b/test/functional/apps/dashboard/group1/embeddable_data_grid.ts @@ -16,7 +16,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const find = getService('find'); - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker', 'discover']); + const { common, dashboard, header, timePicker } = getPageObjects([ + 'common', + 'dashboard', + 'header', + 'timePicker', + ]); const retry = getService('retry'); const dataGrid = getService('dataGrid'); @@ -33,13 +38,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', 'doc_table:legacy': false, }); - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await filterBar.ensureFieldEditorModalIsClosed(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultDataRange(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultDataRange(); await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); after(async function () { @@ -59,11 +64,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('are added when a cell filter is clicked', async function () { await find.clickByCssSelector(`[role="gridcell"]:nth-child(4)`); // needs a short delay between becoming visible & being clickable - await PageObjects.common.sleep(250); + await common.sleep(250); await find.clickByCssSelector(`[data-test-subj="filterOutButton"]`); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await find.clickByCssSelector(`[role="gridcell"]:nth-child(4)`); - await PageObjects.common.sleep(250); + await common.sleep(250); await find.clickByCssSelector(`[data-test-subj="filterForButton"]`); const filterCount = await filterBar.getFilterCount(); expect(filterCount).to.equal(2); diff --git a/test/functional/apps/dashboard/group1/embeddable_rendering.ts b/test/functional/apps/dashboard/group1/embeddable_rendering.ts index 746a8c159e68f..d721bd5eb1945 100644 --- a/test/functional/apps/dashboard/group1/embeddable_rendering.ts +++ b/test/functional/apps/dashboard/group1/embeddable_rendering.ts @@ -29,13 +29,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardExpect = getService('dashboardExpect'); const dashboardAddPanel = getService('dashboardAddPanel'); const queryBar = getService('queryBar'); - const PageObjects = getPageObjects([ + const { common, dashboard, header, timePicker } = getPageObjects([ 'common', 'dashboard', 'header', - 'visualize', - 'visChart', - 'discover', 'timePicker', ]); let visNames: string[] = []; @@ -114,10 +111,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.common.setTime({ from, to }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); + await common.setTime({ from, to }); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); await elasticChart.setNewChartUiDebugFlag(true); }); @@ -127,7 +124,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const newUrl = currentUrl.replace(/\?.*$/, ''); await browser.get(newUrl, false); await security.testUser.restoreDefaults(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); await kibanaServer.savedObjects.cleanStandardList(); }); @@ -138,10 +135,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // This one is rendered via svg which lets us do better testing of what is being rendered. visNames.push(await dashboardAddPanel.addVisualization('Filter Bytes Test: vega')); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dashboardExpect.visualizationsArePresent(visNames); expect(visNames.length).to.be.equal(25); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); }); it('adding saved searches', async () => { @@ -149,20 +146,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardAddPanel.addEverySavedSearch('"Rendering Test"') ); await dashboardAddPanel.closeAddPanel(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dashboardExpect.visualizationsArePresent(visAndSearchNames); expect(visAndSearchNames.length).to.be.equal(26); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - await PageObjects.dashboard.saveDashboard('embeddable rendering test', { + await dashboard.saveDashboard('embeddable rendering test', { saveAsNew: true, storeTimeWithDashboard: true, }); }); it('initial render test', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); await expectAllDataRenders(); }); @@ -170,9 +167,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Change the time to make sure that it's updated when re-opened from the listing page. const fromTime = 'May 10, 2018 @ 00:00:00.000'; const toTime = 'May 11, 2018 @ 00:00:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); - await PageObjects.dashboard.loadSavedDashboard('embeddable rendering test'); - await PageObjects.dashboard.waitForRenderComplete(); + await timePicker.setAbsoluteRange(fromTime, toTime); + await dashboard.loadSavedDashboard('embeddable rendering test'); + await dashboard.waitForRenderComplete(); await expectAllDataRenders(); }); @@ -184,28 +181,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // setNewChartUiDebugFlag required because window._echDebugStateFlag flag is reset after refresh await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); // call query refresh to guarantee all panels are rendered after window._echDebugStateFlag is set await queryBar.clickQuerySubmitButton(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await expectAllDataRenders(); }); it('panels are updated when time changes outside of data', async () => { const fromTime = 'May 11, 2018 @ 00:00:00.000'; const toTime = 'May 12, 2018 @ 00:00:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); - await PageObjects.dashboard.waitForRenderComplete(); + await timePicker.setAbsoluteRange(fromTime, toTime); + await dashboard.waitForRenderComplete(); await expectNoDataRenders(); }); it('panels are updated when time changes inside of data', async () => { const fromTime = 'Jan 1, 2018 @ 00:00:00.000'; const toTime = 'Apr 13, 2018 @ 00:00:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); - await PageObjects.dashboard.waitForRenderComplete(); + await timePicker.setAbsoluteRange(fromTime, toTime); + await dashboard.waitForRenderComplete(); await expectAllDataRenders(); }); }); diff --git a/test/functional/apps/dashboard/group2/dashboard_filter_bar.ts b/test/functional/apps/dashboard/group2/dashboard_filter_bar.ts index 30c9d39b9b5bc..591647bedc65d 100644 --- a/test/functional/apps/dashboard/group2/dashboard_filter_bar.ts +++ b/test/functional/apps/dashboard/group2/dashboard_filter_bar.ts @@ -23,12 +23,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const browser = getService('browser'); const queryBar = getService('queryBar'); const security = getService('security'); - const PageObjects = getPageObjects([ - 'common', + const { dashboard, discover, header, timePicker } = getPageObjects([ 'dashboard', 'discover', 'header', - 'visualize', 'timePicker', ]); @@ -48,7 +46,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); }); after(async () => { @@ -58,11 +56,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Add a filter bar', function () { before(async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); }); it('should show on an empty dashboard', async function () { - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.clickNewDashboard(); const hasAddFilter = await testSubjects.exists('addFilter'); expect(hasAddFilter).to.be(true); }); @@ -78,8 +76,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { this.tags(['skipFirefox']); before(async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); }); it('uses default index pattern on an empty dashboard', async () => { @@ -90,7 +88,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('shows index pattern of vis when one is added', async () => { await dashboardAddPanel.addVisualization('Rendering-Test:-animal-sounds-pie'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await filterBar.ensureFieldEditorModalIsClosed(); await testSubjects.click('addFilter'); await dashboardExpect.fieldSuggestions(['animal']); @@ -99,7 +97,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('works when a vis with no index pattern is added', async () => { await dashboardAddPanel.addVisualization('Rendering-Test:-markdown'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await filterBar.ensureFieldEditorModalIsClosed(); await testSubjects.click('addFilter'); await dashboardExpect.fieldSuggestions(['animal']); @@ -109,9 +107,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('filter pills', function () { before(async () => { await filterBar.ensureFieldEditorModalIsClosed(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultDataRange(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultDataRange(); await elasticChart.setNewChartUiDebugFlag(true); }); @@ -122,7 +120,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('are added when a pie chart slice is clicked', async function () { await dashboardAddPanel.addVisualization('Rendering Test: pie'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await pieChart.filterOnPieSlice('4886'); const filterCount = await filterBar.getFilterCount(); expect(filterCount).to.equal(1); @@ -131,8 +129,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('are preserved after saving a dashboard', async () => { - await PageObjects.dashboard.saveDashboard('with filters'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.saveDashboard('with filters'); + await header.waitUntilLoadingHasFinished(); await elasticChart.setNewChartUiDebugFlag(true); const filterCount = await filterBar.getFilterCount(); @@ -142,9 +140,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('are preserved after opening a dashboard saved with filters', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard('with filters'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard('with filters'); + await header.waitUntilLoadingHasFinished(); await elasticChart.setNewChartUiDebugFlag(true); await queryBar.submitQuery(); @@ -155,10 +153,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it("restoring filters doesn't break back button", async () => { await browser.goBack(); - await PageObjects.dashboard.expectExistsDashboardLandingPage(); + await dashboard.expectExistsDashboardLandingPage(); await browser.goForward(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); await elasticChart.setNewChartUiDebugFlag(true); await queryBar.submitQuery(); await pieChart.expectPieSliceCount(1); @@ -167,26 +165,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it("saving with pinned filter doesn't unpin them", async () => { const filterKey = 'bytes'; await filterBar.toggleFilterPinned(filterKey); - await PageObjects.dashboard.switchToEditMode(); - await PageObjects.dashboard.saveDashboard('saved with pinned filters'); + await dashboard.switchToEditMode(); + await dashboard.saveDashboard('saved with pinned filters'); expect(await filterBar.isFilterPinned(filterKey)).to.be(true); await pieChart.expectPieSliceCount(1); }); it("navigating to a dashboard with global filter doesn't unpin it if same filter is saved with dashboard", async () => { - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard('with filters'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.preserveCrossAppState(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard('with filters'); + await header.waitUntilLoadingHasFinished(); expect(await filterBar.isFilterPinned('bytes')).to.be(true); await pieChart.expectPieSliceCount(1); }); it("pinned filters aren't saved", async () => { await filterBar.removeFilter('bytes'); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard('saved with pinned filters'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard('saved with pinned filters'); + await header.waitUntilLoadingHasFinished(); expect(await filterBar.getFilterCount()).to.be(0); await pieChart.expectPieSliceCount(5); }); @@ -195,15 +193,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('saved search filtering', function () { before(async () => { await filterBar.ensureFieldEditorModalIsClosed(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultDataRange(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultDataRange(); }); it('are added when a cell magnifying glass is clicked', async function () { await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); - await PageObjects.dashboard.waitForRenderComplete(); - const isLegacyDefault = await PageObjects.discover.useLegacyTable(); + await dashboard.waitForRenderComplete(); + const isLegacyDefault = await discover.useLegacyTable(); if (isLegacyDefault) { await testSubjects.click('docTableCellFilter'); } else { @@ -217,8 +215,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('bad filters are loaded properly', function () { before(async () => { await filterBar.ensureFieldEditorModalIsClosed(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard('dashboard with bad filters'); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard('dashboard with bad filters'); }); it('filter with non-existent index pattern renders if it matches a field', async function () { diff --git a/test/functional/apps/dashboard/group2/dashboard_filtering.ts b/test/functional/apps/dashboard/group2/dashboard_filtering.ts index 9b960369aaefe..05b831849cf44 100644 --- a/test/functional/apps/dashboard/group2/dashboard_filtering.ts +++ b/test/functional/apps/dashboard/group2/dashboard_filtering.ts @@ -27,13 +27,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const security = getService('security'); const dashboardPanelActions = getService('dashboardPanelActions'); - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'visualize', 'timePicker']); + const { dashboard, header, visualize, timePicker } = getPageObjects([ + 'dashboard', + 'header', + 'visualize', + 'timePicker', + ]); // Failing: See https://github.com/elastic/kibana/issues/160062 describe.skip('dashboard filtering', function () { const populateDashboard = async () => { - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultDataRange(); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultDataRange(); await dashboardAddPanel.addEveryVisualization('"Filter Bytes Test"'); await dashboardAddPanel.addEverySavedSearch('"Filter Bytes Test"'); @@ -41,15 +46,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; const addFilterAndRefresh = async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); await filterBar.addFilter({ field: 'bytes', operation: 'is', value: '12345678' }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); // first round of requests sometimes times out, refresh all visualizations to fetch again await queryBar.clickQuerySubmitButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); await elasticChart.setNewChartUiDebugFlag(true); }; @@ -68,9 +73,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.gotoDashboardLandingPage(); }); after(async () => { @@ -85,7 +90,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); }); it('filters on pie charts', async () => { @@ -144,13 +149,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await addFilterAndRefresh(); await filterBar.toggleFilterPinned('bytes'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); }); after(async () => { await filterBar.toggleFilterPinned('bytes'); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); }); it('filters on pie charts', async () => { @@ -205,8 +210,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await addFilterAndRefresh(); await filterBar.toggleFilterEnabled('bytes'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); }); it('pie charts', async () => { @@ -256,67 +261,63 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('nested filtering', () => { before(async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); await elasticChart.setNewChartUiDebugFlag(true); }); it('visualization saved with a query filters data', async () => { - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultDataRange(); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultDataRange(); await dashboardAddPanel.addVisualization('Rendering-Test:-animal-sounds-pie'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); await pieChart.expectPieSliceCount(5); await dashboardPanelActions.clickEdit(); await queryBar.setQuery('weightLbs:>50'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - // We are on the visualize page, not dashboard, so can't use "PageObjects.dashboard.waitForRenderComplete();" + // We are on the visualize page, not dashboard, so can't use "dashboard.waitForRenderComplete();" // as that expects an item with the `data-shared-items-count` tag. await renderable.waitForRender(); await pieChart.expectPieSliceCount(3); - await PageObjects.visualize.saveVisualizationExpectSuccess( - 'Rendering Test: animal sounds pie' - ); - await PageObjects.header.clickDashboard(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await visualize.saveVisualizationExpectSuccess('Rendering Test: animal sounds pie'); + await header.clickDashboard(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); await pieChart.expectPieSliceCount(3); }); it('Nested visualization filter pills filters data as expected', async () => { await dashboardPanelActions.clickEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); await pieChart.filterOnPieSlice('grr'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await pieChart.expectPieSliceCount(1); - await PageObjects.visualize.saveVisualizationExpectSuccess('animal sounds pie'); - await PageObjects.header.clickDashboard(); + await visualize.saveVisualizationExpectSuccess('animal sounds pie'); + await header.clickDashboard(); await pieChart.expectPieSliceCount(1); }); it('Removing filter pills and query unfiters data as expected', async () => { await dashboardPanelActions.clickEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); await queryBar.setQuery(''); await queryBar.submitQuery(); await filterBar.removeFilter('sound.keyword'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await pieChart.expectPieSliceCount(5); - await PageObjects.visualize.saveVisualizationExpectSuccess( - 'Rendering Test: animal sounds pie' - ); - await PageObjects.header.clickDashboard(); + await visualize.saveVisualizationExpectSuccess('Rendering Test: animal sounds pie'); + await header.clickDashboard(); await pieChart.expectPieSliceCount(5); }); @@ -333,7 +334,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await elasticChart.setNewChartUiDebugFlag(true); await queryBar.setQuery('weightLbs<40'); await queryBar.submitQuery(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await pieChart.expectPieSliceCount(5); }); diff --git a/test/functional/apps/dashboard/group2/full_screen_mode.ts b/test/functional/apps/dashboard/group2/full_screen_mode.ts index 3b91f43c9883a..ef9a615f195b7 100644 --- a/test/functional/apps/dashboard/group2/full_screen_mode.ts +++ b/test/functional/apps/dashboard/group2/full_screen_mode.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const browser = getService('browser'); const kibanaServer = getService('kibanaServer'); const dashboardPanelActions = getService('dashboardPanelActions'); - const PageObjects = getPageObjects(['dashboard', 'common']); + const { dashboard, common } = getPageObjects(['dashboard', 'common']); const filterBar = getService('filterBar'); describe('full screen mode', () => { @@ -28,9 +28,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('few panels'); }); after(async () => { @@ -38,80 +38,80 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('option not available in edit mode', async () => { - await PageObjects.dashboard.switchToEditMode(); - const exists = await PageObjects.dashboard.fullScreenModeMenuItemExists(); + await dashboard.switchToEditMode(); + const exists = await dashboard.fullScreenModeMenuItemExists(); expect(exists).to.be(false); }); it('available in view mode', async () => { - await PageObjects.dashboard.saveDashboard('full screen test', { + await dashboard.saveDashboard('full screen test', { saveAsNew: true, exitFromEditMode: true, }); - const exists = await PageObjects.dashboard.fullScreenModeMenuItemExists(); + const exists = await dashboard.fullScreenModeMenuItemExists(); expect(exists).to.be(true); }); it('hides the chrome', async () => { - const isChromeVisible = await PageObjects.common.isChromeVisible(); + const isChromeVisible = await common.isChromeVisible(); expect(isChromeVisible).to.be(true); - await PageObjects.dashboard.clickFullScreenMode(); + await dashboard.clickFullScreenMode(); await retry.try(async () => { - const isChromeHidden = await PageObjects.common.isChromeHidden(); + const isChromeHidden = await common.isChromeHidden(); expect(isChromeHidden).to.be(true); }); }); it('displays exit full screen logo button', async () => { - const exists = await PageObjects.dashboard.exitFullScreenLogoButtonExists(); + const exists = await dashboard.exitFullScreenLogoButtonExists(); expect(exists).to.be(true); }); it('displays exit full screen logo button when panel is expanded', async () => { await dashboardPanelActions.clickExpandPanelToggle(); - const exists = await PageObjects.dashboard.exitFullScreenTextButtonExists(); + const exists = await dashboard.exitFullScreenTextButtonExists(); expect(exists).to.be(true); }); it('exits when the text button is clicked on', async () => { - await PageObjects.dashboard.exitFullScreenMode(); + await dashboard.exitFullScreenMode(); await retry.try(async () => { - const isChromeVisible = await PageObjects.common.isChromeVisible(); + const isChromeVisible = await common.isChromeVisible(); expect(isChromeVisible).to.be(true); }); }); it('shows filter bar in fullscreen mode', async () => { await filterBar.addFilter({ field: 'bytes', operation: 'is', value: '12345678' }); - await PageObjects.dashboard.waitForRenderComplete(); - await PageObjects.dashboard.clickFullScreenMode(); + await dashboard.waitForRenderComplete(); + await dashboard.clickFullScreenMode(); await retry.try(async () => { - const isChromeHidden = await PageObjects.common.isChromeHidden(); + const isChromeHidden = await common.isChromeHidden(); expect(isChromeHidden).to.be(true); }); expect(await filterBar.getFilterCount()).to.be(1); - await PageObjects.dashboard.clickExitFullScreenLogoButton(); + await dashboard.clickExitFullScreenLogoButton(); await retry.try(async () => { - const isChromeVisible = await PageObjects.common.isChromeVisible(); + const isChromeVisible = await common.isChromeVisible(); expect(isChromeVisible).to.be(true); }); await filterBar.removeFilter('bytes'); }); it('exits full screen mode when back button pressed', async () => { - await PageObjects.dashboard.clickFullScreenMode(); + await dashboard.clickFullScreenMode(); await browser.goBack(); await retry.try(async () => { - const isChromeVisible = await PageObjects.common.isChromeVisible(); + const isChromeVisible = await common.isChromeVisible(); expect(isChromeVisible).to.be(true); }); await browser.goForward(); await retry.try(async () => { - const isChromeVisible = await PageObjects.common.isChromeVisible(); + const isChromeVisible = await common.isChromeVisible(); expect(isChromeVisible).to.be(true); }); }); diff --git a/test/functional/apps/dashboard/group2/multiple_data_views.ts b/test/functional/apps/dashboard/group2/multiple_data_views.ts index 7debd46f9c4b0..21778771917a2 100644 --- a/test/functional/apps/dashboard/group2/multiple_data_views.ts +++ b/test/functional/apps/dashboard/group2/multiple_data_views.ts @@ -19,28 +19,33 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const filterBar = getService('filterBar'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'dashboard', 'timePicker', 'home']); + const { common, dashboard, timePicker, home } = getPageObjects([ + 'common', + 'dashboard', + 'timePicker', + 'home', + ]); describe('dashboard multiple data views', () => { before(async () => { await kibanaServer.uiSettings.update({ 'courier:ignoreFilterIfFieldNotInIndex': true }); - await PageObjects.common.navigateToApp('home'); - await PageObjects.home.goToSampleDataPage(); - await PageObjects.home.addSampleDataSet('flights'); - await PageObjects.home.addSampleDataSet('logs'); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await common.navigateToApp('home'); + await home.goToSampleDataPage(); + await home.addSampleDataSet('flights'); + await home.addSampleDataSet('logs'); + await dashboard.navigateToApp(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.addSavedSearches(['[Flights] Flight Log', '[Logs] Visits']); - await PageObjects.dashboard.waitForRenderComplete(); - await PageObjects.timePicker.setCommonlyUsedTime('This_week'); + await dashboard.waitForRenderComplete(); + await timePicker.setCommonlyUsedTime('This_week'); }); after(async () => { - await PageObjects.common.navigateToApp('home'); - await PageObjects.home.goToSampleDataPage(); - await PageObjects.home.removeSampleDataSet('flights'); - await PageObjects.home.removeSampleDataSet('logs'); + await common.navigateToApp('home'); + await home.goToSampleDataPage(); + await home.removeSampleDataSet('flights'); + await home.removeSampleDataSet('logs'); await kibanaServer.uiSettings.unset('courier:ignoreFilterIfFieldNotInIndex'); }); @@ -56,9 +61,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('applies filters on panels using a data view without the filter field', async () => { await kibanaServer.uiSettings.update({ 'courier:ignoreFilterIfFieldNotInIndex': false }); - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await testSubjects.click('edit-unsaved-New-Dashboard'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); const logsSavedSearchPanel = (await testSubjects.findAll('embeddedSavedSearchDocTable'))[1]; expect( await ( diff --git a/test/functional/apps/dashboard/group2/panel_expand_toggle.ts b/test/functional/apps/dashboard/group2/panel_expand_toggle.ts index 63b1ab776051c..54dbdd03ba973 100644 --- a/test/functional/apps/dashboard/group2/panel_expand_toggle.ts +++ b/test/functional/apps/dashboard/group2/panel_expand_toggle.ts @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const kibanaServer = getService('kibanaServer'); const dashboardPanelActions = getService('dashboardPanelActions'); - const PageObjects = getPageObjects(['dashboard', 'visualize', 'header', 'common']); + const { dashboard } = getPageObjects(['dashboard']); describe('expanding a panel', () => { before(async () => { @@ -26,9 +26,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('few panels'); }); after(async () => { @@ -38,13 +38,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('hides other panels', async () => { await dashboardPanelActions.clickExpandPanelToggle(); await retry.try(async () => { - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); }); }); it('shows other panels after being minimized', async () => { - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); // Panels are all minimized on a fresh open of a dashboard, so we need to re-expand in order to then minimize. await dashboardPanelActions.clickExpandPanelToggle(); await dashboardPanelActions.clickExpandPanelToggle(); @@ -52,7 +52,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Add a retry to fix https://github.com/elastic/kibana/issues/14574. Perhaps the recent changes to this // being a CSS update is causing the UI to change slower than grabbing the panels? await retry.try(async () => { - const panelCountAfterMaxThenMinimize = await PageObjects.dashboard.getPanelCount(); + const panelCountAfterMaxThenMinimize = await dashboard.getPanelCount(); expect(panelCountAfterMaxThenMinimize).to.be(panelCount); }); }); diff --git a/test/functional/apps/dashboard/group3/bwc_shared_urls.ts b/test/functional/apps/dashboard/group3/bwc_shared_urls.ts index c3b6b3bbfc07e..3b6e25715987e 100644 --- a/test/functional/apps/dashboard/group3/bwc_shared_urls.ts +++ b/test/functional/apps/dashboard/group3/bwc_shared_urls.ts @@ -12,7 +12,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['dashboard', 'header']); + const { dashboard, header } = getPageObjects(['dashboard', 'header']); const toasts = getService('toasts'); const browser = getService('browser'); const log = getService('log'); @@ -43,8 +43,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('bwc shared urls', function describeIndexTests() { before(async function () { - await PageObjects.dashboard.initTests(); - await PageObjects.dashboard.preserveCrossAppState(); + await dashboard.initTests(); + await dashboard.preserveCrossAppState(); const currentUrl = await browser.getCurrentUrl(); kibanaLegacyBaseUrl = @@ -74,7 +74,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const url = `${kibanaLegacyBaseUrl}#/dashboard?${url56}`; log.debug(`Navigating to ${url}`); await browser.get(url, true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const query = await queryBar.getQueryString(); expect(query).to.equal('memory:>220000'); @@ -82,7 +82,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const warningToast = await toasts.getElementByIndex(1); expect(await warningToast.getVisibleText()).to.contain('Cannot load panels'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); }); }); @@ -93,74 +93,74 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const url = `${kibanaLegacyBaseUrl}#/dashboard?${urlQuery}`; log.debug(`Navigating to ${url}`); await browser.get(url, true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const query = await queryBar.getQueryString(); expect(query).to.equal('memory:>220000'); const warningToast = await toasts.getElementByIndex(1); expect(await warningToast.getVisibleText()).to.contain('Cannot load panels'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); }); it('loads a saved dashboard', async function () { - await PageObjects.dashboard.saveDashboard('saved with colors', { + await dashboard.saveDashboard('saved with colors', { saveAsNew: true, storeTimeWithDashboard: true, }); - savedDashboardId = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); + savedDashboardId = await dashboard.getDashboardIdFromCurrentUrl(); const url = `${kibanaLegacyBaseUrl}#/dashboard/${savedDashboardId}`; log.debug(`Navigating to ${url}`); await browser.get(url, true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const query = await queryBar.getQueryString(); expect(query).to.equal('memory:>220000'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); }); it('loads a saved dashboard with query via dashboard_no_match', async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); const currentUrl = await browser.getCurrentUrl(); const dashboardBaseUrl = currentUrl.substring(0, currentUrl.indexOf('/app/dashboards')); const url = `${dashboardBaseUrl}/app/dashboards#/dashboard/${savedDashboardId}?_a=(query:(language:kuery,query:'boop'))`; log.debug(`Navigating to ${url}`); await browser.get(url); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const query = await queryBar.getQueryString(); expect(query).to.equal('boop'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); }); it('uiState in url takes precedence over saved dashboard state', async function () { - const id = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); + const id = await dashboard.getDashboardIdFromCurrentUrl(); const updatedQuery = urlQuery.replace(/F9D9F9/g, '000000'); const url = `${kibanaLegacyBaseUrl}#/dashboard/${id}?${updatedQuery}`; log.debug(`Navigating to ${url}`); await browser.get(url, true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); it('back button works for old dashboards after state migrations', async () => { - await PageObjects.dashboard.preserveCrossAppState(); - const oldId = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.preserveCrossAppState(); + const oldId = await dashboard.getDashboardIdFromCurrentUrl(); + await dashboard.waitForRenderComplete(); const url = `${kibanaLegacyBaseUrl}#/dashboard?${urlQuery}`; log.debug(`Navigating to ${url}`); await browser.get(url); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); await browser.goBack(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const newId = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); + await header.waitUntilLoadingHasFinished(); + const newId = await dashboard.getDashboardIdFromCurrentUrl(); expect(newId).to.be.equal(oldId); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await queryBar.submitQuery(); }); }); diff --git a/test/functional/apps/dashboard/group3/copy_panel_to.ts b/test/functional/apps/dashboard/group3/copy_panel_to.ts index 5398606439319..f39166c5696e2 100644 --- a/test/functional/apps/dashboard/group3/copy_panel_to.ts +++ b/test/functional/apps/dashboard/group3/copy_panel_to.ts @@ -16,14 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects([ - 'header', - 'common', - 'discover', - 'dashboard', - 'visualize', - 'timePicker', - ]); + const { dashboard, timePicker } = getPageObjects(['dashboard', 'timePicker']); const fewPanelsTitle = 'few panels'; const markdownTitle = 'Copy To Markdown'; @@ -46,15 +39,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard(fewPanelsTitle); - await PageObjects.dashboard.waitForRenderComplete(); - fewPanelsPanelCount = await PageObjects.dashboard.getPanelCount(); - - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setHistoricalDataRange(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard(fewPanelsTitle); + await dashboard.waitForRenderComplete(); + fewPanelsPanelCount = await dashboard.getPanelCount(); + + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await timePicker.setHistoricalDataRange(); await dashboardVisualizations.createAndAddMarkdown({ name: markdownTitle, markdown: 'Please add me to some other dashboard', @@ -62,7 +55,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); await kibanaServer.savedObjects.cleanStandardList(); }); @@ -91,16 +84,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click(`dashboard-picker-option-few-panels`); await testSubjects.click('confirmCopyToButton'); - await PageObjects.dashboard.waitForRenderComplete(); - await PageObjects.dashboard.expectOnDashboard(`Editing ${fewPanelsTitle}`); - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + await dashboard.waitForRenderComplete(); + await dashboard.expectOnDashboard(`Editing ${fewPanelsTitle}`); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.be(fewPanelsPanelCount + 1); // Save & ensure that view mode is applied properly. - await PageObjects.dashboard.clickQuickSave(); + await dashboard.clickQuickSave(); await testSubjects.existOrFail('saveDashboardSuccess'); - await PageObjects.dashboard.clickCancelOutOfEditMode(); + await dashboard.clickCancelOutOfEditMode(); await dashboardPanelActions.expectMissingEditPanelAction(markdownTitle); }); @@ -126,12 +119,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await label.click(); await testSubjects.click('confirmCopyToButton'); - await PageObjects.dashboard.waitForRenderComplete(); - await PageObjects.dashboard.expectOnDashboard(`Editing New Dashboard`); + await dashboard.waitForRenderComplete(); + await dashboard.expectOnDashboard(`Editing New Dashboard`); }); it('it always appends new panels instead of overwriting', async () => { - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.be(2); }); }); diff --git a/test/functional/apps/dashboard/group3/dashboard_state.ts b/test/functional/apps/dashboard/group3/dashboard_state.ts index 8ed7721647274..40022c155f456 100644 --- a/test/functional/apps/dashboard/group3/dashboard_state.ts +++ b/test/functional/apps/dashboard/group3/dashboard_state.ts @@ -16,17 +16,16 @@ import { PIE_CHART_VIS_NAME, AREA_CHART_VIS_NAME } from '../../../page_objects/d import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ - 'common', - 'dashboard', - 'visualize', - 'header', - 'discover', - 'visChart', - 'share', - 'timePicker', - 'unifiedFieldList', - ]); + const { dashboard, header, discover, visChart, share, timePicker, unifiedFieldList } = + getPageObjects([ + 'dashboard', + 'header', + 'discover', + 'visChart', + 'share', + 'timePicker', + 'unifiedFieldList', + ]); const testSubjects = getService('testSubjects'); const browser = getService('browser'); const queryBar = getService('queryBar'); @@ -67,7 +66,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; const enableNewChartLibraryDebug = async (force = false) => { - if ((await PageObjects.visChart.isNewChartsLibraryEnabled()) || force) { + if ((await visChart.isNewChartsLibraryEnabled()) || force) { await elasticChart.setNewChartUiDebugFlag(); await queryBar.submitQuery(); } @@ -75,42 +74,42 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard state', function () { before(async function () { - await PageObjects.dashboard.initTests(); - await PageObjects.dashboard.preserveCrossAppState(); + await dashboard.initTests(); + await dashboard.preserveCrossAppState(); await browser.refresh(); }); after(async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); }); it('Overriding colors on an area chart is preserved', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setHistoricalDataRange(); + await dashboard.clickNewDashboard(); + await timePicker.setHistoricalDataRange(); const visName = AREA_CHART_VIS_NAME; await dashboardAddPanel.addVisualization(visName); const dashboardName = 'Overridden colors - new charts library'; - await PageObjects.dashboard.saveDashboard(dashboardName); + await dashboard.saveDashboard(dashboardName); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await queryBar.clickQuerySubmitButton(); - await PageObjects.visChart.openLegendOptionColorsForXY('Count', `[data-title="${visName}"]`); + await visChart.openLegendOptionColorsForXY('Count', `[data-title="${visName}"]`); const overwriteColor = '#d36086'; - await PageObjects.visChart.selectNewLegendColorChoice(overwriteColor); + await visChart.selectNewLegendColorChoice(overwriteColor); - await PageObjects.dashboard.saveDashboard(dashboardName, { saveAsNew: false }); + await dashboard.saveDashboard(dashboardName, { saveAsNew: false }); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard(dashboardName); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard(dashboardName); await enableNewChartLibraryDebug(true); - const colorChoiceRetained = await PageObjects.visChart.doesSelectedLegendColorExistForXY( + const colorChoiceRetained = await visChart.doesSelectedLegendColorExistForXY( overwriteColor, xyChartSelector ); @@ -119,60 +118,60 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Saved search with no changes will update when the saved object changes', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); - await PageObjects.header.clickDiscover(); - await PageObjects.timePicker.setHistoricalDataRange(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.discover.saveSearch('my search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.clickDiscover(); + await timePicker.setHistoricalDataRange(); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await discover.saveSearch('my search'); + await header.waitUntilLoadingHasFinished(); - await PageObjects.header.clickDashboard(); - await PageObjects.dashboard.clickNewDashboard(); + await header.clickDashboard(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.addSavedSearch('my search'); - await PageObjects.dashboard.saveDashboard('No local edits'); + await dashboard.saveDashboard('No local edits'); const inViewMode = await testSubjects.exists('dashboardEditMode'); expect(inViewMode).to.be(true); - await PageObjects.header.clickDiscover(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('agent'); - await PageObjects.discover.saveSearch('my search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.clickDiscover(); + await unifiedFieldList.clickFieldListItemAdd('agent'); + await discover.saveSearch('my search'); + await header.waitUntilLoadingHasFinished(); - await PageObjects.header.clickDashboard(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.clickDashboard(); + await header.waitUntilLoadingHasFinished(); - const headers = await PageObjects.discover.getColumnHeaders(); + const headers = await discover.getColumnHeaders(); expect(headers.length).to.be(3); expect(headers[1]).to.be('bytes'); expect(headers[2]).to.be('agent'); }); it('Saved search with column changes will not update when the saved object changes', async () => { - await PageObjects.dashboard.switchToEditMode(); - await PageObjects.discover.removeHeaderColumn('bytes'); - await PageObjects.dashboard.saveDashboard('Has local edits'); + await dashboard.switchToEditMode(); + await discover.removeHeaderColumn('bytes'); + await dashboard.saveDashboard('Has local edits'); - await PageObjects.header.clickDiscover(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('clientip'); - await PageObjects.discover.saveSearch('my search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.clickDiscover(); + await unifiedFieldList.clickFieldListItemAdd('clientip'); + await discover.saveSearch('my search'); + await header.waitUntilLoadingHasFinished(); - await PageObjects.header.clickDashboard(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.clickDashboard(); + await header.waitUntilLoadingHasFinished(); - const headers = await PageObjects.discover.getColumnHeaders(); + const headers = await discover.getColumnHeaders(); expect(headers.length).to.be(2); expect(headers[1]).to.be('agent'); }); const getUrlFromShare = async () => { log.debug(`getUrlFromShare`); - await PageObjects.share.clickShareTopNavButton(); - const sharedUrl = await PageObjects.share.getSharedUrl(); - await PageObjects.share.closeShareModal(); + await share.clickShareTopNavButton(); + const sharedUrl = await share.getSharedUrl(); + await share.closeShareModal(); log.debug(`sharedUrl: ${sharedUrl}`); return sharedUrl; }; @@ -183,16 +182,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const alert = await browser.getAlert(); await alert?.accept(); await enableNewChartLibraryDebug(true); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); }; // Skip this test; directly modifying the URL app state isn't fully supported in the new // React embeddable framework, but this user interaction is not a high priority describe.skip('Directly modifying url updates dashboard state', () => { before(async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setHistoricalDataRange(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await timePicker.setHistoricalDataRange(); }); const changeQuery = async (useHardRefresh: boolean, newQuery: string) => { @@ -211,7 +210,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await browser.get(newUrl.toString(), !useHardRefresh); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); const queryBarContentsAfterRefresh = await queryBar.getQueryString(); expect(queryBarContentsAfterRefresh).to.equal(newQuery); }; @@ -220,13 +219,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await changeQuery(true, 'hi:hello'); await queryBar.clearQuery(); await queryBar.clickQuerySubmitButton(); - await PageObjects.dashboard.expectAppStateRemovedFromURL(); + await dashboard.expectAppStateRemovedFromURL(); }); it('for panel size parameters', async function () { await dashboardAddPanel.addVisualization(PIE_CHART_VIS_NAME); const currentUrl = await getUrlFromShare(); - const currentPanelDimensions = await PageObjects.dashboard.getPanelDimensions(); + const currentPanelDimensions = await dashboard.getPanelDimensions(); const newUrl = updateAppStateQueryParam( currentUrl, (appState: Partial) => { @@ -250,12 +249,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await hardRefresh(newUrl); await retry.try(async () => { - const newPanelDimensions = await PageObjects.dashboard.getPanelDimensions(); + const newPanelDimensions = await dashboard.getPanelDimensions(); if (newPanelDimensions.length < 0) { throw new Error('No panel dimensions...'); } - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); // Add a "margin" of error - because of page margins, it won't be a straight doubling of width. const marginOfError = 10; expect(newPanelDimensions[0].width).to.be.lessThan( @@ -268,7 +267,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('when removing a panel', async function () { - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); const currentUrl = (await getUrlFromShare()) ?? ''; const newUrl = updateAppStateQueryParam( currentUrl, @@ -281,7 +280,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await hardRefresh(newUrl); await retry.try(async () => { - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.be(0); }); }); @@ -297,11 +296,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('updates a pie slice color on a hard refresh', async function () { - await PageObjects.visChart.openLegendOptionColorsForPie( + await visChart.openLegendOptionColorsForPie( '80,000', `[data-title="${PIE_CHART_VIS_NAME}"]` ); - await PageObjects.visChart.selectNewLegendColorChoice('#F9D9F9'); + await visChart.selectNewLegendColorChoice('#F9D9F9'); const currentUrl = await getUrlFromShare(); const newUrl = updateAppStateQueryParam( currentUrl, @@ -326,7 +325,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } ); await hardRefresh(newUrl); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { const allPieSlicesColor = await pieChart.getAllPieSliceColor('80,000'); @@ -340,9 +339,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('and updates the pie slice legend color', async function () { await retry.try(async () => { - const colorExists = await PageObjects.visChart.doesSelectedLegendColorExistForPie( - '#FFFFFF' - ); + const colorExists = await visChart.doesSelectedLegendColorExistForPie('#FFFFFF'); expect(colorExists).to.be(true); }); }); @@ -370,7 +367,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await hardRefresh(newUrl); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { const pieSliceStyle = await pieChart.getPieSliceStyle('80,000'); @@ -382,9 +379,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('resets the legend color as well', async function () { await retry.try(async () => { - const colorExists = await PageObjects.visChart.doesSelectedLegendColorExistForPie( - '#57c17b' - ); + const colorExists = await visChart.doesSelectedLegendColorExistForPie('#57c17b'); expect(colorExists).to.be(true); }); }); diff --git a/test/functional/apps/dashboard/group3/dashboard_time_picker.ts b/test/functional/apps/dashboard/group3/dashboard_time_picker.ts index 6cc7147aa5fc0..2e5d4217909f0 100644 --- a/test/functional/apps/dashboard/group3/dashboard_time_picker.ts +++ b/test/functional/apps/dashboard/group3/dashboard_time_picker.ts @@ -17,10 +17,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const pieChart = getService('pieChart'); const elasticChart = getService('elasticChart'); const dashboardVisualizations = getService('dashboardVisualizations'); - const PageObjects = getPageObjects([ + const { dashboard, header, timePicker, discover } = getPageObjects([ 'dashboard', 'header', - 'visualize', 'timePicker', 'discover', ]); @@ -31,8 +30,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard time picker', function describeIndexTests() { before(async function () { - await PageObjects.dashboard.initTests(); - await PageObjects.dashboard.preserveCrossAppState(); + await dashboard.initTests(); + await dashboard.preserveCrossAppState(); await elasticChart.setNewChartUiDebugFlag(true); }); @@ -44,28 +43,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Visualization updated when time picker changes', async () => { - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.addVisualizations([PIE_CHART_VIS_NAME]); + await dashboard.clickNewDashboard(); + await dashboard.addVisualizations([PIE_CHART_VIS_NAME]); await pieChart.expectEmptyPieChart(); - await PageObjects.timePicker.setHistoricalDataRange(); + await timePicker.setHistoricalDataRange(); await pieChart.expectPieSliceCount(10); }); it('Saved search updated when time picker changes', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); await dashboardVisualizations.createAndAddSavedSearch({ name: 'saved search', fields: ['bytes', 'agent'], }); - const isLegacyDefault = await PageObjects.discover.useLegacyTable(); + const isLegacyDefault = await discover.useLegacyTable(); if (isLegacyDefault) { await dashboardExpect.docTableFieldCount(150); // Set to time range with no data - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Jan 1, 2000 @ 00:00:00.000', 'Jan 1, 2000 @ 01:00:00.000' ); @@ -75,7 +74,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(docCount).to.above(10); // Set to time range with no data - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Jan 1, 2000 @ 00:00:00.000', 'Jan 1, 2000 @ 01:00:00.000' ); @@ -85,9 +84,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Timepicker start, end, interval values are set by url', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); log.debug('Went to landing page'); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.clickNewDashboard(); log.debug('Clicked new dashboard'); await dashboardVisualizations.createAndAddSavedSearch({ name: 'saved search', @@ -106,9 +105,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.get(`${kibanaBaseUrl}#${urlQuery}`, true); const alert = await browser.getAlert(); await alert?.accept(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const time = await PageObjects.timePicker.getTimeConfig(); - const refresh = await PageObjects.timePicker.getRefreshConfig(); + await header.waitUntilLoadingHasFinished(); + const time = await timePicker.getTimeConfig(); + const refresh = await timePicker.getRefreshConfig(); expect(time.start).to.be('Nov 17, 2012 @ 00:00:00.000'); expect(time.end).to.be('Nov 17, 2015 @ 18:01:36.621'); expect(refresh.interval).to.be('2'); @@ -122,15 +121,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.addVisualizations([PIE_CHART_VIS_NAME]); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.addVisualizations([PIE_CHART_VIS_NAME]); // Same date range as `timePicker.setHistoricalDataRange()` - await PageObjects.timePicker.setAbsoluteRange( - '2015-09-19 06:31:44.000', - '2015-09-23 18:31:44.000' - ); - await PageObjects.dashboard.waitForRenderComplete(); + await timePicker.setAbsoluteRange('2015-09-19 06:31:44.000', '2015-09-23 18:31:44.000'); + await dashboard.waitForRenderComplete(); await pieChart.expectPieSliceCount(10); }); }); diff --git a/test/functional/apps/dashboard/group3/panel_cloning.ts b/test/functional/apps/dashboard/group3/panel_cloning.ts index 9dfc9949b8b3b..4233ad2e28ba5 100644 --- a/test/functional/apps/dashboard/group3/panel_cloning.ts +++ b/test/functional/apps/dashboard/group3/panel_cloning.ts @@ -14,78 +14,59 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const dashboardAddPanel = getService('dashboardAddPanel'); - const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ - 'dashboard', - 'header', - 'visualize', - 'discover', - 'timePicker', - ]); + const { dashboard, header, timePicker } = getPageObjects(['dashboard', 'header', 'timePicker']); describe('dashboard panel cloning', function viewEditModeTests() { before(async function () { - await PageObjects.dashboard.initTests(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setHistoricalDataRange(); + await dashboard.initTests(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); + await timePicker.setHistoricalDataRange(); await dashboardAddPanel.addVisualization(PIE_CHART_VIS_NAME); }); after(async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); }); it('clones a panel', async () => { - const initialPanelTitles = await PageObjects.dashboard.getPanelTitles(); - await dashboardPanelActions.clonePanelByTitle(PIE_CHART_VIS_NAME); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); - const postPanelTitles = await PageObjects.dashboard.getPanelTitles(); + const initialPanelTitles = await dashboard.getPanelTitles(); + await dashboardPanelActions.clonePanel(PIE_CHART_VIS_NAME); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); + const postPanelTitles = await dashboard.getPanelTitles(); expect(postPanelTitles.length).to.equal(initialPanelTitles.length + 1); }); it('appends a clone title tag', async () => { - const panelTitles = await PageObjects.dashboard.getPanelTitles(); - expect(panelTitles[1]).to.equal(PIE_CHART_VIS_NAME + ' (copy)'); + const panelTitles = await dashboard.getPanelTitles(); + expect(panelTitles[1]).to.equal(`${PIE_CHART_VIS_NAME} (copy)`); }); it('retains original panel dimensions', async () => { - const panelDimensions = await PageObjects.dashboard.getPanelDimensions(); + const panelDimensions = await dashboard.getPanelDimensions(); expect(panelDimensions[0]).to.eql(panelDimensions[1]); }); it('clone of a by reference embeddable is by value', async () => { - const panelName = PIE_CHART_VIS_NAME.replace(/\s+/g, ''); - const clonedPanel = await testSubjects.find(`embeddablePanelHeading-${panelName}(copy)`); - const descendants = await testSubjects.findAllDescendant( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - clonedPanel - ); - expect(descendants.length).to.equal(0); + await dashboardPanelActions.expectNotLinkedToLibrary(`${PIE_CHART_VIS_NAME} (copy)`); }); it('gives a correct title to the clone of a clone', async () => { - const initialPanelTitles = await PageObjects.dashboard.getPanelTitles(); + const initialPanelTitles = await dashboard.getPanelTitles(); const clonedPanelName = initialPanelTitles[initialPanelTitles.length - 1]; - await dashboardPanelActions.clonePanelByTitle(clonedPanelName); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); - const postPanelTitles = await PageObjects.dashboard.getPanelTitles(); + await dashboardPanelActions.clonePanel(clonedPanelName); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); + const postPanelTitles = await dashboard.getPanelTitles(); expect(postPanelTitles.length).to.equal(initialPanelTitles.length + 1); expect(postPanelTitles[postPanelTitles.length - 1]).to.equal( - PIE_CHART_VIS_NAME + ' (copy 1)' + `${PIE_CHART_VIS_NAME} (copy 1)` ); }); it('clone of a by value embeddable is by value', async () => { - const panelName = PIE_CHART_VIS_NAME.replace(/\s+/g, ''); - const clonedPanel = await testSubjects.find(`embeddablePanelHeading-${panelName}(copy1)`); - const descendants = await testSubjects.findAllDescendant( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - clonedPanel - ); - expect(descendants.length).to.equal(0); + await dashboardPanelActions.expectNotLinkedToLibrary(`${PIE_CHART_VIS_NAME} (copy)`); }); }); } diff --git a/test/functional/apps/dashboard/group3/panel_context_menu.ts b/test/functional/apps/dashboard/group3/panel_context_menu.ts index 499e046f99a67..0bf31cf58616c 100644 --- a/test/functional/apps/dashboard/group3/panel_context_menu.ts +++ b/test/functional/apps/dashboard/group3/panel_context_menu.ts @@ -17,10 +17,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardVisualizations = getService('dashboardVisualizations'); - const PageObjects = getPageObjects([ + const { dashboard, header, discover, timePicker } = getPageObjects([ 'dashboard', 'header', - 'visualize', 'discover', 'timePicker', ]); @@ -28,26 +27,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard panel context menu', function viewEditModeTests() { before(async function () { - await PageObjects.dashboard.initTests(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setHistoricalDataRange(); + await dashboard.initTests(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); + await timePicker.setHistoricalDataRange(); await dashboardAddPanel.addVisualization(PIE_CHART_VIS_NAME); }); after(async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); }); it('are hidden in view mode', async function () { - await PageObjects.dashboard.saveDashboard(dashboardName); + await dashboard.saveDashboard(dashboardName); await dashboardPanelActions.expectMissingEditPanelAction(); await dashboardPanelActions.expectMissingRemovePanelAction(); }); it('are shown in edit mode', async function () { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); const isContextMenuIconVisible = await dashboardPanelActions.isContextMenuIconVisible(); expect(isContextMenuIconVisible).to.equal(true); @@ -65,7 +64,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // The second parameter of true will include the timestamp in the url and // trigger a hard refresh. await browser.get(currentUrl.toString(), true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dashboardPanelActions.expectExistsEditPanelAction(); await dashboardPanelActions.expectExistsClonePanelAction(); @@ -78,17 +77,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('visualization object edit menu', () => { it('opens a visualization when edit link is clicked', async () => { await dashboardPanelActions.clickEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const currentUrl = await browser.getCurrentUrl(); expect(currentUrl).to.contain(VisualizeConstants.EDIT_PATH); }); it('deletes the visualization when delete link is clicked', async () => { - await PageObjects.header.clickDashboard(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.clickDashboard(); + await header.waitUntilLoadingHasFinished(); await dashboardPanelActions.removePanel(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.be(0); }); }); @@ -97,39 +96,39 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const searchName = 'my search'; before(async () => { - await PageObjects.header.clickDiscover(true); - await PageObjects.discover.clickNewSearchButton(); + await header.clickDiscover(true); + await discover.clickNewSearchButton(); await dashboardVisualizations.createSavedSearch({ name: searchName, fields: ['bytes'] }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.header.clickDashboard(); + await header.waitUntilLoadingHasFinished(); + await header.clickDashboard(); // The following tests require a fresh dashboard. - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); - const inViewMode = await PageObjects.dashboard.getIsInViewMode(); - if (inViewMode) await PageObjects.dashboard.switchToEditMode(); + const inViewMode = await dashboard.getIsInViewMode(); + if (inViewMode) await dashboard.switchToEditMode(); await dashboardAddPanel.addSavedSearch(searchName); }); it('should be one panel on dashboard', async () => { - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.be(1); }); it('opens a saved search when edit link is clicked', async () => { await dashboardPanelActions.clickEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const queryName = await PageObjects.discover.getCurrentQueryName(); + await header.waitUntilLoadingHasFinished(); + const queryName = await discover.getCurrentQueryName(); expect(queryName).to.be(searchName); }); it('deletes the saved search when delete link is clicked', async () => { - await PageObjects.header.clickDashboard(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.clickDashboard(); + await header.waitUntilLoadingHasFinished(); await dashboardPanelActions.removePanel(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.be(0); }); }); @@ -139,7 +138,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const currentUrl = await browser.getCurrentUrl(); await browser.get(currentUrl.toString(), false); await dashboardAddPanel.addVisualization(PIE_CHART_VIS_NAME); - await PageObjects.dashboard.saveDashboard(dashboardName + '2'); + await dashboard.saveDashboard(dashboardName + '2'); await dashboardPanelActions.clickExpandPanelToggle(); }); @@ -151,7 +150,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('in edit mode', () => { it('switch to edit mode', async function () { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); }); it('some context menu actions should be present', async function () { diff --git a/test/functional/apps/dashboard/group4/dashboard_clone.ts b/test/functional/apps/dashboard/group4/dashboard_clone.ts index c406eaff15391..5166d690a8e6f 100644 --- a/test/functional/apps/dashboard/group4/dashboard_clone.ts +++ b/test/functional/apps/dashboard/group4/dashboard_clone.ts @@ -14,54 +14,52 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const listingTable = getService('listingTable'); - const PageObjects = getPageObjects(['dashboard', 'header', 'common']); + const { dashboard } = getPageObjects(['dashboard']); describe('dashboard clone', function describeIndexTests() { const dashboardName = 'Dashboard Clone Test'; const clonedDashboardName = dashboardName + ' (1)'; before(async function () { - return PageObjects.dashboard.initTests(); + return dashboard.initTests(); }); it('Clone saves a copy', async function () { - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.addVisualizations( - PageObjects.dashboard.getTestVisualizationNames() - ); - await PageObjects.dashboard.saveDashboard(dashboardName); + await dashboard.clickNewDashboard(); + await dashboard.addVisualizations(dashboard.getTestVisualizationNames()); + await dashboard.saveDashboard(dashboardName); - await PageObjects.dashboard.duplicateDashboard(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.duplicateDashboard(); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', clonedDashboardName, 1); }); it('the copy should have all the same visualizations', async function () { - await PageObjects.dashboard.loadSavedDashboard(clonedDashboardName); + await dashboard.loadSavedDashboard(clonedDashboardName); await retry.try(async () => { - const panelTitles = await PageObjects.dashboard.getPanelTitles(); - expect(panelTitles).to.eql(PageObjects.dashboard.getTestVisualizationNames()); + const panelTitles = await dashboard.getPanelTitles(); + expect(panelTitles).to.eql(dashboard.getTestVisualizationNames()); }); }); it('Clone should suggest a unique title', async function () { - await PageObjects.dashboard.loadSavedDashboard(clonedDashboardName); - await PageObjects.dashboard.duplicateDashboard(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard(clonedDashboardName); + await dashboard.duplicateDashboard(); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', `${dashboardName} (2)`, 1); }); it('Clone should always increment from the last duplicated dashboard with a unique title', async function () { - await PageObjects.dashboard.loadSavedDashboard(clonedDashboardName); + await dashboard.loadSavedDashboard(clonedDashboardName); // force dashboard duplicate id to increment out of logical progression bounds - await PageObjects.dashboard.duplicateDashboard(`${dashboardName} (20)`); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.duplicateDashboard(`${dashboardName} (20)`); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', `${dashboardName} (20)`, 1); // load dashboard with duplication id 1 - await PageObjects.dashboard.loadSavedDashboard(clonedDashboardName); + await dashboard.loadSavedDashboard(clonedDashboardName); // run normal clone - await PageObjects.dashboard.duplicateDashboard(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.duplicateDashboard(); + await dashboard.gotoDashboardLandingPage(); // clone gets duplication id, that picks off from last duplicated dashboard await listingTable.searchAndExpectItemsCount('dashboard', `${dashboardName} (21)`, 1); }); diff --git a/test/functional/apps/dashboard/group4/dashboard_empty.ts b/test/functional/apps/dashboard/group4/dashboard_empty.ts index 7e370bcb78c45..1d38b777cd691 100644 --- a/test/functional/apps/dashboard/group4/dashboard_empty.ts +++ b/test/functional/apps/dashboard/group4/dashboard_empty.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker']); + const { common, dashboard, header } = getPageObjects(['common', 'dashboard', 'header']); describe('dashboard empty state', () => { const kbnDirectory = 'test/functional/fixtures/kbn_archiver/dashboard/current/kibana'; @@ -27,7 +27,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); log.debug('load kibana with no data'); await kibanaServer.importExport.unload(kbnDirectory); - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); }); after(async () => { @@ -35,11 +35,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Opens the integrations page when there is no data', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const addIntegrations = await testSubjects.find('kbnOverviewAddIntegrations'); await addIntegrations.click(); - await PageObjects.common.waitUntilUrlIncludes('integrations/browse'); + await common.waitUntilUrlIncludes('integrations/browse'); }); it('adds a new data view when no data views', async () => { @@ -47,7 +47,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); // create the new data view from the dashboards/create route in order to test that the dashboard is loaded properly as soon as the data view is created... - await PageObjects.common.navigateToApp('dashboards', { hash: '/create' }); + await common.navigateToApp('dashboards', { hash: '/create' }); const dataViewToCreate = 'logstash'; await dataViews.createFromPrompt({ name: dataViewToCreate }); diff --git a/test/functional/apps/dashboard/group4/dashboard_listing.ts b/test/functional/apps/dashboard/group4/dashboard_listing.ts index e33b2cc87082d..6816a298f36da 100644 --- a/test/functional/apps/dashboard/group4/dashboard_listing.ts +++ b/test/functional/apps/dashboard/group4/dashboard_listing.ts @@ -12,7 +12,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['dashboard', 'header', 'common']); + const { dashboard, header, common } = getPageObjects(['dashboard', 'header', 'common']); const browser = getService('browser'); const listingTable = getService('listingTable'); const dashboardAddPanel = getService('dashboardAddPanel'); @@ -22,32 +22,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardName = 'Dashboard Listing Test'; before(async function () { - await PageObjects.dashboard.initTests(); + await dashboard.initTests(); }); describe('create prompt', () => { it('appears when there are no dashboards', async function () { - const promptExists = await PageObjects.dashboard.getCreateDashboardPromptExists(); + const promptExists = await dashboard.getCreateDashboardPromptExists(); expect(promptExists).to.be(true); }); it('creates a new dashboard', async function () { - await PageObjects.dashboard.clickCreateDashboardPrompt(); - await PageObjects.dashboard.saveDashboard(dashboardName); + await dashboard.clickCreateDashboardPrompt(); + await dashboard.saveDashboard(dashboardName); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', dashboardName, 1); }); it('is not shown when there is a dashboard', async function () { - const promptExists = await PageObjects.dashboard.getCreateDashboardPromptExists(); + const promptExists = await dashboard.getCreateDashboardPromptExists(); expect(promptExists).to.be(false); }); it('is not shown when there are no dashboards shown during a search', async function () { await listingTable.searchAndExpectItemsCount('dashboard', 'gobeldeguck', 0); - const promptExists = await PageObjects.dashboard.getCreateDashboardPromptExists(); + const promptExists = await dashboard.getCreateDashboardPromptExists(); expect(promptExists).to.be(false); await listingTable.clearSearchFilter(); }); @@ -59,11 +59,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await listingTable.checkListingSelectAllCheckbox(); await listingTable.clickDeleteSelected(); - await PageObjects.common.expectConfirmModalOpenState(true); + await common.expectConfirmModalOpenState(true); - await PageObjects.common.pressEnterKey(); + await common.pressEnterKey(); - await PageObjects.common.expectConfirmModalOpenState(false); + await common.expectConfirmModalOpenState(false); await listingTable.searchAndExpectItemsCount('dashboard', dashboardName, 1); }); @@ -72,7 +72,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await listingTable.checkListingSelectAllCheckbox(); await listingTable.clickDeleteSelected(); - await PageObjects.common.clickConfirmOnModal(); + await common.clickConfirmOnModal(); await listingTable.searchAndExpectItemsCount('dashboard', dashboardName, 0); }); @@ -81,9 +81,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('search', function () { before(async () => { await listingTable.clearSearchFilter(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.saveDashboard('Two Words'); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.saveDashboard('Two Words'); + await dashboard.gotoDashboardLandingPage(); }); it('matches on the first word', async function () { @@ -125,37 +125,37 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const useTimeStamp = true; await browser.get(newUrl.toString(), useTimeStamp); - await PageObjects.header.awaitKibanaChrome(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const onDashboardLandingPage = await PageObjects.dashboard.onDashboardLandingPage(); + await header.awaitKibanaChrome(); + await header.waitUntilLoadingHasFinished(); + const onDashboardLandingPage = await dashboard.onDashboardLandingPage(); expect(onDashboardLandingPage).to.equal(false); }); it('title match is case insensitive', async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); const currentUrl = await browser.getCurrentUrl(); const newUrl = currentUrl + '&title=two%20words'; // Only works on a hard refresh. const useTimeStamp = true; await browser.get(newUrl.toString(), useTimeStamp); - await PageObjects.header.awaitKibanaChrome(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const onDashboardLandingPage = await PageObjects.dashboard.onDashboardLandingPage(); + await header.awaitKibanaChrome(); + await header.waitUntilLoadingHasFinished(); + const onDashboardLandingPage = await dashboard.onDashboardLandingPage(); expect(onDashboardLandingPage).to.equal(false); }); it('stays on listing page if title matches no dashboards', async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); const currentUrl = await browser.getCurrentUrl(); const newUrl = currentUrl + '&title=nodashboardsnamedme'; // Only works on a hard refresh. const useTimeStamp = true; await browser.get(newUrl.toString(), useTimeStamp); - await PageObjects.header.awaitKibanaChrome(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const onDashboardLandingPage = await PageObjects.dashboard.onDashboardLandingPage(); + await header.awaitKibanaChrome(); + await header.waitUntilLoadingHasFinished(); + const onDashboardLandingPage = await dashboard.onDashboardLandingPage(); expect(onDashboardLandingPage).to.equal(true); }); @@ -165,21 +165,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('stays on listing page if title matches two dashboards', async function () { - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.saveDashboard('two words', { + await dashboard.clickNewDashboard(); + await dashboard.saveDashboard('two words', { saveAsNew: true, needsConfirm: true, }); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); const currentUrl = await browser.getCurrentUrl(); const newUrl = currentUrl + '&title=two%20words'; // Only works on a hard refresh. const useTimeStamp = true; await browser.get(newUrl.toString(), useTimeStamp); - await PageObjects.header.awaitKibanaChrome(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const onDashboardLandingPage = await PageObjects.dashboard.onDashboardLandingPage(); + await header.awaitKibanaChrome(); + await header.waitUntilLoadingHasFinished(); + const onDashboardLandingPage = await dashboard.onDashboardLandingPage(); expect(onDashboardLandingPage).to.equal(true); }); @@ -189,9 +189,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('matches a title with many special characters', async function () { - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.saveDashboard('i am !@#$%^&*()_+~`,.<>{}[]; so special'); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.saveDashboard('i am !@#$%^&*()_+~`,.<>{}[]; so special'); + await dashboard.gotoDashboardLandingPage(); const currentUrl = await browser.getCurrentUrl(); // Need to encode that one. const newUrl = @@ -201,24 +201,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const useTimeStamp = true; await browser.get(newUrl.toString(), useTimeStamp); - await PageObjects.header.awaitKibanaChrome(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const onDashboardLandingPage = await PageObjects.dashboard.onDashboardLandingPage(); + await header.awaitKibanaChrome(); + await header.waitUntilLoadingHasFinished(); + const onDashboardLandingPage = await dashboard.onDashboardLandingPage(); expect(onDashboardLandingPage).to.equal(false); }); }); describe('edit meta data', () => { it('saves changes to dashboard metadata', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickCreateDashboardPrompt(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickCreateDashboardPrompt(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addEveryEmbeddableOnCurrentPage(); await dashboardAddPanel.ensureAddPanelIsClosed(); - await PageObjects.dashboard.saveDashboard(`${dashboardName}-editMetaData`); - const originalPanelCount = await PageObjects.dashboard.getPanelCount(); + await dashboard.saveDashboard(`${dashboardName}-editMetaData`); + const originalPanelCount = await dashboard.getPanelCount(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchForItemWithName(`${dashboardName}-editMetaData`); await listingTable.inspectVisualization(); await listingTable.editVisualizationDetails({ @@ -230,9 +230,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await listingTable.setSearchFilterValue('new description'); await listingTable.expectItemsCount('dashboard', 1); await listingTable.clickItemLink('dashboard', 'new title'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.equal(originalPanelCount); }); }); @@ -241,14 +241,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const DASHBOARD_NAME = 'Insights Dashboard'; before(async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.saveDashboard(DASHBOARD_NAME, { + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + await dashboard.saveDashboard(DASHBOARD_NAME, { saveAsNew: true, waitDialogIsClosed: false, exitFromEditMode: false, }); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); }); it('shows the insights panel and counts the views', async () => { @@ -268,8 +268,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(views1).to.be(1); await listingTable.clickItemLink('dashboard', DASHBOARD_NAME); - await PageObjects.dashboard.waitForRenderComplete(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.waitForRenderComplete(); + await dashboard.gotoDashboardLandingPage(); const views2 = await getViewsCount(); expect(views2).to.be(2); }); diff --git a/test/functional/apps/dashboard/group4/dashboard_save.ts b/test/functional/apps/dashboard/group4/dashboard_save.ts index 384cbc1b860e0..ed615b6ac5fbb 100644 --- a/test/functional/apps/dashboard/group4/dashboard_save.ts +++ b/test/functional/apps/dashboard/group4/dashboard_save.ts @@ -10,7 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['dashboard', 'header', 'visualize']); + const { dashboard, header, visualize } = getPageObjects(['dashboard', 'header', 'visualize']); const listingTable = getService('listingTable'); const testSubjects = getService('testSubjects'); const dashboardAddPanel = getService('dashboardAddPanel'); @@ -23,64 +23,64 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async function () { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - await PageObjects.dashboard.initTests(); + await dashboard.initTests(); }); describe('create new', () => { it('warns on duplicate name for new dashboard', async function () { - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.saveDashboard(dashboardName); + await dashboard.clickNewDashboard(); + await dashboard.saveDashboard(dashboardName); - await PageObjects.dashboard.expectDuplicateTitleWarningDisplayed({ displayed: false }); + await dashboard.expectDuplicateTitleWarningDisplayed({ displayed: false }); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.enterDashboardSaveModalApplyUpdatesAndClickSave(dashboardName, { + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.enterDashboardSaveModalApplyUpdatesAndClickSave(dashboardName, { waitDialogIsClosed: false, }); - await PageObjects.dashboard.expectDuplicateTitleWarningDisplayed({ displayed: true }); + await dashboard.expectDuplicateTitleWarningDisplayed({ displayed: true }); }); it('does not save on reject confirmation', async function () { - await PageObjects.dashboard.cancelSave(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.cancelSave(); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', dashboardName, 1); }); it('Saves on confirm duplicate title warning', async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.enterDashboardSaveModalApplyUpdatesAndClickSave(dashboardName, { + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.enterDashboardSaveModalApplyUpdatesAndClickSave(dashboardName, { waitDialogIsClosed: false, }); - await PageObjects.dashboard.ensureDuplicateTitleCallout(); - await PageObjects.dashboard.clickSave(); + await dashboard.ensureDuplicateTitleCallout(); + await dashboard.clickSave(); // This is important since saving a new dashboard will cause a refresh of the page. We have to // wait till it finishes reloading or it might reload the url after simulating the // dashboard landing page click. - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // after saving a new dashboard, the app state must be removed - await await PageObjects.dashboard.expectAppStateRemovedFromURL(); + await await dashboard.expectAppStateRemovedFromURL(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', dashboardName, 2); }); it('Saves new Dashboard using the Enter key', async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.enterDashboardTitleAndPressEnter(dashboardNameEnterKey); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.enterDashboardTitleAndPressEnter(dashboardNameEnterKey); // This is important since saving a new dashboard will cause a refresh of the page. We have to // wait till it finishes reloading or it might reload the url after simulating the // dashboard landing page click. - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', dashboardNameEnterKey, 1); }); @@ -88,63 +88,63 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('quick save', () => { it('Does not show quick save menu item on a new dashboard', async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.expectMissingQuickSaveOption(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.expectMissingQuickSaveOption(); }); it('Does not show dashboard save modal when on quick save', async function () { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.saveDashboard('test quick save'); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.saveDashboard('test quick save'); - await PageObjects.dashboard.switchToEditMode(); - await PageObjects.dashboard.expectExistsQuickSaveOption(); + await dashboard.switchToEditMode(); + await dashboard.expectExistsQuickSaveOption(); await dashboardAddPanel.clickMarkdownQuickButton(); - await PageObjects.visualize.saveVisualizationAndReturn(); - await PageObjects.dashboard.waitForRenderComplete(); - await PageObjects.dashboard.clickQuickSave(); + await visualize.saveVisualizationAndReturn(); + await dashboard.waitForRenderComplete(); + await dashboard.clickQuickSave(); await testSubjects.existOrFail('saveDashboardSuccess'); }); it('Stays in edit mode after performing a quick save', async function () { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('dashboardQuickSaveMenuItem'); }); }); describe('duplication (edit mode)', () => { it('Warns you when you Save as New Dashboard, and the title is a duplicate', async function () { - await PageObjects.dashboard.switchToEditMode(); - await PageObjects.dashboard.enterDashboardSaveModalApplyUpdatesAndClickSave(dashboardName, { + await dashboard.switchToEditMode(); + await dashboard.enterDashboardSaveModalApplyUpdatesAndClickSave(dashboardName, { waitDialogIsClosed: false, }); - await PageObjects.dashboard.expectDuplicateTitleWarningDisplayed({ displayed: true }); + await dashboard.expectDuplicateTitleWarningDisplayed({ displayed: true }); - await PageObjects.dashboard.cancelSave(); + await dashboard.cancelSave(); }); it('Does not warn when only the prefix matches', async function () { - await PageObjects.dashboard.saveDashboard(dashboardName.split(' ')[0]); + await dashboard.saveDashboard(dashboardName.split(' ')[0]); - await PageObjects.dashboard.expectDuplicateTitleWarningDisplayed({ displayed: false }); + await dashboard.expectDuplicateTitleWarningDisplayed({ displayed: false }); }); it('Warns when case is different', async function () { - await PageObjects.dashboard.switchToEditMode(); - await PageObjects.dashboard.enterDashboardSaveModalApplyUpdatesAndClickSave( + await dashboard.switchToEditMode(); + await dashboard.enterDashboardSaveModalApplyUpdatesAndClickSave( dashboardName.toUpperCase(), { waitDialogIsClosed: false, } ); - await PageObjects.dashboard.expectDuplicateTitleWarningDisplayed({ displayed: true }); + await dashboard.expectDuplicateTitleWarningDisplayed({ displayed: true }); - await PageObjects.dashboard.cancelSave(); + await dashboard.cancelSave(); }); }); @@ -152,17 +152,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardNameFlyout = 'Dashboard Save Test with Flyout'; it('Does not warn when you save an existing dashboard with the title it already has', async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.enterDashboardTitleAndPressEnter(dashboardNameFlyout); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.enterDashboardTitleAndPressEnter(dashboardNameFlyout); // This is important since saving a new dashboard will cause a refresh of the page. We have to // wait till it finishes reloading or it might reload the url after simulating the // dashboard landing page click. - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.switchToEditMode(); - await PageObjects.dashboard.modifyExistingDashboardDetails(dashboardNameFlyout); + await dashboard.switchToEditMode(); + await dashboard.modifyExistingDashboardDetails(dashboardNameFlyout); }); }); }); diff --git a/test/functional/apps/dashboard/group4/dashboard_time.ts b/test/functional/apps/dashboard/group4/dashboard_time.ts index e47210c0bb071..e9a34705cc72c 100644 --- a/test/functional/apps/dashboard/group4/dashboard_time.ts +++ b/test/functional/apps/dashboard/group4/dashboard_time.ts @@ -14,64 +14,62 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; const dashboardName = 'Dashboard Test Time'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker']); + const { dashboard, header, timePicker } = getPageObjects(['dashboard', 'header', 'timePicker']); const pieChart = getService('pieChart'); const browser = getService('browser'); describe('dashboard time', () => { before(async function () { - await PageObjects.dashboard.initTests(); - await PageObjects.dashboard.preserveCrossAppState(); + await dashboard.initTests(); + await dashboard.preserveCrossAppState(); }); after(async function () { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); }); describe('dashboard without stored timed', () => { it('is saved', async () => { - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.addVisualizations([ - PageObjects.dashboard.getTestVisualizationNames()[0], - ]); - await PageObjects.dashboard.saveDashboard(dashboardName, { + await dashboard.clickNewDashboard(); + await dashboard.addVisualizations([dashboard.getTestVisualizationNames()[0]]); + await dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: false, saveAsNew: true, }); }); it('Does not set the time picker on open', async () => { - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); - await PageObjects.dashboard.loadSavedDashboard(dashboardName); + await dashboard.loadSavedDashboard(dashboardName); - const time = await PageObjects.timePicker.getTimeConfig(); - expect(time.start).to.equal(PageObjects.timePicker.defaultStartTime); - expect(time.end).to.equal(PageObjects.timePicker.defaultEndTime); + const time = await timePicker.getTimeConfig(); + expect(time.start).to.equal(timePicker.defaultStartTime); + expect(time.end).to.equal(timePicker.defaultEndTime); }); }); describe('dashboard with stored timed', function () { it('is saved with time', async function () { - await PageObjects.dashboard.switchToEditMode(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.dashboard.saveDashboard(dashboardName, { + await dashboard.switchToEditMode(); + await timePicker.setDefaultAbsoluteRange(); + await dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: true, saveAsNew: false, }); }); it('sets time on open', async function () { - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Jan 1, 2019 @ 00:00:00.000', 'Jan 2, 2019 @ 00:00:00.000' ); - await PageObjects.dashboard.loadSavedDashboard(dashboardName); + await dashboard.loadSavedDashboard(dashboardName); - const time = await PageObjects.timePicker.getTimeConfig(); - expect(time.start).to.equal(PageObjects.timePicker.defaultStartTime); - expect(time.end).to.equal(PageObjects.timePicker.defaultEndTime); + const time = await timePicker.getTimeConfig(); + expect(time.start).to.equal(timePicker.defaultStartTime); + expect(time.end).to.equal(timePicker.defaultEndTime); }); // If time is stored with a dashboard, it's supposed to override the current time settings when opened. @@ -80,13 +78,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be overwritten by global state', async function () { const currentUrl = await browser.getCurrentUrl(); const kibanaBaseUrl = currentUrl.substring(0, currentUrl.indexOf('#')); - const id = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); + const id = await dashboard.getDashboardIdFromCurrentUrl(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); const urlWithGlobalTime = `${kibanaBaseUrl}#/view/${id}?_g=(time:(from:now-1h,to:now))`; await browser.get(urlWithGlobalTime, false); - const time = await PageObjects.timePicker.getTimeConfig(); + const time = await timePicker.getTimeConfig(); expect(time.start).to.equal('~ an hour ago'); expect(time.end).to.equal('now'); @@ -100,39 +98,39 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should use saved time, if time is missing in global state, but _g is present in the url', async function () { const currentUrl = await browser.getCurrentUrl(); const kibanaBaseUrl = currentUrl.substring(0, currentUrl.indexOf('#')); - const id = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); + const id = await dashboard.getDashboardIdFromCurrentUrl(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); const urlWithGlobalTime = `${kibanaBaseUrl}#/view/${id}?_g=(filters:!())`; await browser.get(urlWithGlobalTime, false); - const time = await PageObjects.timePicker.getTimeConfig(); - expect(time.start).to.equal(PageObjects.timePicker.defaultStartTime); - expect(time.end).to.equal(PageObjects.timePicker.defaultEndTime); + const time = await timePicker.getTimeConfig(); + expect(time.start).to.equal(timePicker.defaultStartTime); + expect(time.end).to.equal(timePicker.defaultEndTime); }); it('should use saved time after time change is undone', async function () { const currentUrl = await browser.getCurrentUrl(); const kibanaBaseUrl = currentUrl.substring(0, currentUrl.indexOf('#')); - const id = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); + const id = await dashboard.getDashboardIdFromCurrentUrl(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); const urlWithGlobalTime = `${kibanaBaseUrl}#/view/${id}?_g=(filters:!())`; await browser.get(urlWithGlobalTime, false); // set the time to something else - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Jan 1, 2019 @ 00:00:00.000', 'Jan 2, 2019 @ 00:00:00.000' ); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await browser.goBack(); // time should have restored to the saved time range. - const time = await PageObjects.timePicker.getTimeConfig(); - expect(time.start).to.equal(PageObjects.timePicker.defaultStartTime); - expect(time.end).to.equal(PageObjects.timePicker.defaultEndTime); + const time = await timePicker.getTimeConfig(); + expect(time.start).to.equal(timePicker.defaultStartTime); + expect(time.end).to.equal(timePicker.defaultEndTime); }); }); @@ -142,16 +140,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // during navigation or page refreshes. describe('time changes', function () { it('preserved during navigation', async function () { - await PageObjects.dashboard.loadSavedDashboard(dashboardName); + await dashboard.loadSavedDashboard(dashboardName); - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Jan 1, 2019 @ 00:00:00.000', 'Jan 2, 2019 @ 00:00:00.000' ); - await PageObjects.header.clickVisualize(); - await PageObjects.header.clickDashboard(); + await header.clickVisualize(); + await header.clickDashboard(); - const time = await PageObjects.timePicker.getTimeConfig(); + const time = await timePicker.getTimeConfig(); expect(time.start).to.equal('Jan 1, 2019 @ 00:00:00.000'); expect(time.end).to.equal('Jan 2, 2019 @ 00:00:00.000'); }); diff --git a/test/functional/apps/dashboard/group5/dashboard_back_button.ts b/test/functional/apps/dashboard/group5/dashboard_back_button.ts index 41ea17d306d26..79eda218ee556 100644 --- a/test/functional/apps/dashboard/group5/dashboard_back_button.ts +++ b/test/functional/apps/dashboard/group5/dashboard_back_button.ts @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['dashboard', 'header', 'common', 'visualize', 'timePicker']); + const { dashboard } = getPageObjects(['dashboard']); const browser = getService('browser'); const security = getService('security'); @@ -26,8 +26,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); }); after(async () => { @@ -36,11 +36,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('after navigation from listing page to dashboard back button works', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard('dashboard with everything'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard('dashboard with everything'); + await dashboard.waitForRenderComplete(); await browser.goBack(); - expect(await PageObjects.dashboard.onDashboardLandingPage()).to.be(true); + expect(await dashboard.onDashboardLandingPage()).to.be(true); }); }); } diff --git a/test/functional/apps/dashboard/group5/dashboard_error_handling.ts b/test/functional/apps/dashboard/group5/dashboard_error_handling.ts index 9721050f190ca..35bc57d31eb58 100644 --- a/test/functional/apps/dashboard/group5/dashboard_error_handling.ts +++ b/test/functional/apps/dashboard/group5/dashboard_error_handling.ts @@ -11,7 +11,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['dashboard', 'header', 'common']); + const { dashboard, header } = getPageObjects(['dashboard', 'header']); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); const filterBar = getService('filterBar'); @@ -34,7 +34,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'test/functional/fixtures/kbn_archiver/dashboard_error_cases.json' ); - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); }); after(async () => { @@ -42,11 +42,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('correctly loads default index pattern on first load with an error embeddable', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard('Dashboard with Missing Lens Panel'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard('Dashboard with Missing Lens Panel'); + await header.waitUntilLoadingHasFinished(); await filterBar.addFilter({ field: 'bytes', operation: 'is', value: '12345678' }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect(await filterBar.getFilterCount()).to.be(1); }); @@ -54,9 +54,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // see: https://github.com/elastic/kibana/pull/67280#discussion_r430528122 describe('when the saved object is missing', () => { it('shows the missing data view error message', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard('dashboard with missing index pattern'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard('dashboard with missing index pattern'); + await header.waitUntilLoadingHasFinished(); const embeddableError = await testSubjects.find('embeddableError'); const errorMessage = await embeddableError.getVisibleText(); diff --git a/test/functional/apps/dashboard/group5/dashboard_query_bar.ts b/test/functional/apps/dashboard/group5/dashboard_query_bar.ts index bec9466023958..923cb58b87671 100644 --- a/test/functional/apps/dashboard/group5/dashboard_query_bar.ts +++ b/test/functional/apps/dashboard/group5/dashboard_query_bar.ts @@ -18,7 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const queryBar = getService('queryBar'); const retry = getService('retry'); const security = getService('security'); - const PageObjects = getPageObjects(['common', 'dashboard', 'discover']); + const { dashboard, discover } = getPageObjects(['dashboard', 'discover']); describe('dashboard query bar', () => { before(async () => { @@ -30,9 +30,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('dashboard with filter'); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('dashboard with filter'); }); after(async () => { @@ -44,7 +44,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.unload('test/functional/fixtures/es_archiver/dashboard/current/data'); await queryBar.clickQuerySubmitButton(); await retry.tryForTime(5000, async () => { - const headers = await PageObjects.discover.getColumnHeaders(); + const headers = await discover.getColumnHeaders(); expect(headers.length).to.be(0); await pieChart.expectEmptyPieChart(); }); diff --git a/test/functional/apps/dashboard/group5/dashboard_settings.ts b/test/functional/apps/dashboard/group5/dashboard_settings.ts index 70a131699ddd9..c04b4a1e4a56d 100644 --- a/test/functional/apps/dashboard/group5/dashboard_settings.ts +++ b/test/functional/apps/dashboard/group5/dashboard_settings.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const globalNav = getService('globalNav'); const kibanaServer = getService('kibanaServer'); const dashboardSettings = getService('dashboardSettings'); - const PageObjects = getPageObjects(['common', 'dashboard']); + const { dashboard } = getPageObjects(['dashboard']); describe('dashboard settings', () => { let originalTitles: string[] = []; @@ -38,11 +38,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); - await PageObjects.dashboard.switchToEditMode(); - originalTitles = await PageObjects.dashboard.getPanelTitles(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('few panels'); + await dashboard.switchToEditMode(); + originalTitles = await dashboard.getPanelTitles(); }); after(async () => { @@ -50,21 +50,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should be able to hide all panel titles', async () => { - await PageObjects.dashboard.openSettingsFlyout(); + await dashboard.openSettingsFlyout(); await dashboardSettings.toggleShowPanelTitles(false); await dashboardSettings.clickApplyButton(); await retry.try(async () => { - const titles = await PageObjects.dashboard.getPanelTitles(); + const titles = await dashboard.getPanelTitles(); expect(titles[0]).to.eql(undefined); }); }); it('should be able to unhide all panel titles', async () => { - await PageObjects.dashboard.openSettingsFlyout(); + await dashboard.openSettingsFlyout(); await dashboardSettings.toggleShowPanelTitles(true); await dashboardSettings.clickApplyButton(); await retry.try(async () => { - const titles = await PageObjects.dashboard.getPanelTitles(); + const titles = await dashboard.getPanelTitles(); expect(titles[0]).to.eql(originalTitles[0]); }); }); @@ -73,7 +73,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await checkDashboardTitle('few panels'); const newTitle = 'My awesome dashboard!!1'; - await PageObjects.dashboard.openSettingsFlyout(); + await dashboard.openSettingsFlyout(); await dashboardSettings.setCustomPanelTitle(newTitle); await dashboardSettings.clickApplyButton(); @@ -81,25 +81,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should disable quick save when the settings are open', async () => { - await PageObjects.dashboard.expectQuickSaveButtonEnabled(); - await PageObjects.dashboard.openSettingsFlyout(); + await dashboard.expectQuickSaveButtonEnabled(); + await dashboard.openSettingsFlyout(); await retry.try(async () => { - await PageObjects.dashboard.expectQuickSaveButtonDisabled(); + await dashboard.expectQuickSaveButtonDisabled(); }); await dashboardSettings.clickCancelButton(); }); it('should enable quick save when the settings flyout is closed', async () => { - await PageObjects.dashboard.expectQuickSaveButtonEnabled(); - await PageObjects.dashboard.openSettingsFlyout(); + await dashboard.expectQuickSaveButtonEnabled(); + await dashboard.openSettingsFlyout(); await dashboardSettings.clickCloseFlyoutButton(); await retry.try(async () => { - await PageObjects.dashboard.expectQuickSaveButtonEnabled(); + await dashboard.expectQuickSaveButtonEnabled(); }); }); it('should warn when creating a duplicate title', async () => { - await PageObjects.dashboard.openSettingsFlyout(); + await dashboard.openSettingsFlyout(); await dashboardSettings.setCustomPanelTitle('couple panels'); await dashboardSettings.clickApplyButton(false); await retry.try(async () => { @@ -110,7 +110,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should allow duplicate title if warned once', async () => { const newTitle = 'couple panels'; - await PageObjects.dashboard.openSettingsFlyout(); + await dashboard.openSettingsFlyout(); await dashboardSettings.setCustomPanelTitle(newTitle); await dashboardSettings.clickApplyButton(false); await retry.try(async () => { diff --git a/test/functional/apps/dashboard/group5/data_shared_attributes.ts b/test/functional/apps/dashboard/group5/data_shared_attributes.ts index f92afbfb0eed7..4b13b3bd077c3 100644 --- a/test/functional/apps/dashboard/group5/data_shared_attributes.ts +++ b/test/functional/apps/dashboard/group5/data_shared_attributes.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const dashboardCustomizePanel = getService('dashboardCustomizePanel'); const security = getService('security'); - const PageObjects = getPageObjects(['common', 'dashboard', 'timePicker']); + const { dashboard, timePicker } = getPageObjects(['dashboard', 'timePicker']); describe('dashboard data-shared attributes', function describeIndexTests() { let originalPanelTitles: string[]; @@ -31,10 +31,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('dashboard with everything'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('dashboard with everything'); + await dashboard.waitForRenderComplete(); }); after(async () => { @@ -44,29 +44,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should have time picker with data-shared-timefilter-duration', async () => { await retry.try(async () => { - const sharedData = await PageObjects.timePicker.getTimeDurationForSharing(); + const sharedData = await timePicker.getTimeDurationForSharing(); expect(sharedData).to.not.be(null); }); }); it('should have data-shared-items-count set to the number of embeddables on the dashboard', async () => { await retry.try(async () => { - const sharedItemsCount = await PageObjects.dashboard.getSharedItemsCount(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const sharedItemsCount = await dashboard.getSharedItemsCount(); + const panelCount = await dashboard.getPanelCount(); expect(sharedItemsCount).to.eql(panelCount); }); }); it('should have panels with expected data-shared-item title', async () => { await retry.try(async () => { - const sharedData = await PageObjects.dashboard.getPanelSharedItemData(); - originalPanelTitles = await PageObjects.dashboard.getPanelTitles(); + const sharedData = await dashboard.getPanelSharedItemData(); + originalPanelTitles = await dashboard.getPanelTitles(); expect(sharedData.map((item) => item.title)).to.eql(originalPanelTitles); }); }); it('data shared item container data has description and title set', async () => { - const sharedContainerData = await PageObjects.dashboard.getSharedContainerData(); + const sharedContainerData = await dashboard.getSharedContainerData(); expect(sharedContainerData.title).to.be('dashboard with everything'); expect(sharedContainerData.description).to.be( 'I have one of every visualization type since the last time I was created!' @@ -74,7 +74,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('data-shared-item title should update a viz when using a custom panel title', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); const CUSTOM_VIS_TITLE = 'ima custom title for a vis!'; await dashboardPanelActions.customizePanel(); await dashboardCustomizePanel.expectCustomizePanelSettingsFlyoutOpen(); @@ -83,7 +83,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardCustomizePanel.expectCustomizePanelSettingsFlyoutClosed(); await retry.try(async () => { - const sharedData = await PageObjects.dashboard.getPanelSharedItemData(); + const sharedData = await dashboard.getPanelSharedItemData(); const foundSharedItemTitle = !!sharedData.find((item) => { return item.title === CUSTOM_VIS_TITLE; }); @@ -102,7 +102,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await toggleHideTitle(); await retry.try(async () => { - const sharedData = await PageObjects.dashboard.getPanelSharedItemData(); + const sharedData = await dashboard.getPanelSharedItemData(); const foundSharedItemTitle = !!sharedData.find((item) => { return item.title === ''; }); @@ -112,14 +112,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('data-shared-item title can be reset', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await dashboardPanelActions.customizePanel(); await dashboardCustomizePanel.resetCustomPanelTitle(); await dashboardCustomizePanel.clickSaveButton(); await dashboardCustomizePanel.expectCustomizePanelSettingsFlyoutClosed(); await retry.try(async () => { - const sharedData = await PageObjects.dashboard.getPanelSharedItemData(); + const sharedData = await dashboard.getPanelSharedItemData(); const foundOriginalSharedItemTitle = !!sharedData.find((item) => { return item.title === originalPanelTitles[0]; }); @@ -128,16 +128,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('data-shared-item title should update a saved search when using a custom panel title', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); const CUSTOM_SEARCH_TITLE = 'ima custom title for a search!'; - await dashboardPanelActions.customizePanelByTitle('Rendering Test: saved search'); + await dashboardPanelActions.customizePanel('Rendering Test: saved search'); await dashboardCustomizePanel.expectCustomizePanelSettingsFlyoutOpen(); await dashboardCustomizePanel.setCustomPanelTitle(CUSTOM_SEARCH_TITLE); await dashboardCustomizePanel.clickSaveButton(); await dashboardCustomizePanel.expectCustomizePanelSettingsFlyoutClosed(); await retry.try(async () => { - const sharedData = await PageObjects.dashboard.getPanelSharedItemData(); + const sharedData = await dashboard.getPanelSharedItemData(); const foundSharedItemTitle = !!sharedData.find((item) => { return item.title === CUSTOM_SEARCH_TITLE; }); diff --git a/test/functional/apps/dashboard/group5/embed_mode.ts b/test/functional/apps/dashboard/group5/embed_mode.ts index 654992ebc40c7..965f448b38a3f 100644 --- a/test/functional/apps/dashboard/group5/embed_mode.ts +++ b/test/functional/apps/dashboard/group5/embed_mode.ts @@ -19,7 +19,7 @@ export default function ({ const testSubjects = getService('testSubjects'); const retry = getService('retry'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['dashboard', 'common']); + const { dashboard } = getPageObjects(['dashboard']); const browser = getService('browser'); const globalNav = getService('globalNav'); const screenshot = getService('screenshots'); @@ -50,9 +50,9 @@ export default function ({ await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('dashboard with everything'); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('dashboard with everything'); await browser.setWindowSize(1300, 900); }); @@ -82,7 +82,7 @@ export default function ({ }); it('renders as expected', async () => { - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); const percentDifference = await screenshot.compareAgainstBaseline( 'dashboard_embed_mode', updateBaselines @@ -105,7 +105,7 @@ export default function ({ }); it('renders as expected', async () => { - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); const percentDifference = await screenshot.compareAgainstBaseline( 'dashboard_embed_mode_with_url_params', updateBaselines @@ -114,7 +114,7 @@ export default function ({ }); it('renders as expected when scrolling', async () => { - const panels = await PageObjects.dashboard.getDashboardPanels(); + const panels = await dashboard.getDashboardPanels(); const lastPanel = panels[panels.length - 1]; const lastPanelHeight = -parseInt(await lastPanel.getComputedStyle('height'), 10); log.debug( diff --git a/test/functional/apps/dashboard/group5/empty_dashboard.ts b/test/functional/apps/dashboard/group5/empty_dashboard.ts index 37a92a471ab36..a154b3d936fd4 100644 --- a/test/functional/apps/dashboard/group5/empty_dashboard.ts +++ b/test/functional/apps/dashboard/group5/empty_dashboard.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardVisualizations = getService('dashboardVisualizations'); const dashboardExpect = getService('dashboardExpect'); - const PageObjects = getPageObjects(['common', 'dashboard']); + const { dashboard } = getPageObjects(['dashboard']); describe('empty dashboard', () => { before(async () => { @@ -28,14 +28,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); }); after(async () => { await dashboardAddPanel.closeAddPanel(); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); await kibanaServer.savedObjects.cleanStandardList(); }); diff --git a/test/functional/apps/dashboard/group5/legacy_urls.ts b/test/functional/apps/dashboard/group5/legacy_urls.ts index e15441b2ca861..62ae63baa8fc8 100644 --- a/test/functional/apps/dashboard/group5/legacy_urls.ts +++ b/test/functional/apps/dashboard/group5/legacy_urls.ts @@ -10,10 +10,9 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { dashboard, header, timePicker, visualize, visEditor } = getPageObjects([ 'dashboard', 'header', - 'common', 'timePicker', 'visualize', 'visEditor', @@ -39,14 +38,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'test/functional/fixtures/kbn_archiver/dashboard/current/kibana' ); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.addVisualization('Rendering-Test:-animal-sounds-pie'); - await PageObjects.dashboard.saveDashboard('legacyTest', { + await dashboard.saveDashboard('legacyTest', { waitDialogIsClosed: true, saveAsNew: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const currentUrl = await browser.getCurrentUrl(); await log.debug(`Current url is ${currentUrl}`); testDashboardId = /#\/view\/(.+)\?/.exec(currentUrl)![1]; @@ -58,7 +57,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); await listingTable.deleteItem('legacyTest', testDashboardId); await security.testUser.restoreDefaults(); }); @@ -67,11 +66,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('redirects from old kibana app URL', async () => { const url = `${kibanaLegacyBaseUrl}#/dashboard/${testDashboardId}`; await browser.get(url, true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.timePicker.setDefaultDataRange(); + await timePicker.setDefaultDataRange(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await pieChart.expectPieSliceCount(5); }); @@ -79,27 +78,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const url = `${kibanaVisualizeBaseUrl}#/dashboard/${testDashboardId}`; await browser.get(url, true); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.timePicker.setDefaultDataRange(); + await header.waitUntilLoadingHasFinished(); + await timePicker.setDefaultDataRange(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await pieChart.expectPieSliceCount(5); }); it('resolves markdown link', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickMarkdownWidget(); - await PageObjects.visEditor.setMarkdownTxt(`[abc](#/dashboard/${testDashboardId})`); - await PageObjects.visEditor.clickGo(); + await visualize.navigateToNewVisualization(); + await visualize.clickMarkdownWidget(); + await visEditor.setMarkdownTxt(`[abc](#/dashboard/${testDashboardId})`); + await visEditor.clickGo(); - await PageObjects.visualize.saveVisualizationExpectSuccess('legacy url markdown'); + await visualize.saveVisualizationExpectSuccess('legacy url markdown'); await (await find.byLinkText('abc')).click(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.timePicker.setDefaultDataRange(); + await header.waitUntilLoadingHasFinished(); + await timePicker.setDefaultDataRange(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await pieChart.expectPieSliceCount(5); }); @@ -108,20 +107,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.goBack(); // back to last app await browser.goBack(); - await PageObjects.visEditor.expectMarkdownTextArea(); + await visEditor.expectMarkdownTextArea(); await browser.goForward(); }); it('resolves markdown link from dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.addVisualization('legacy url markdown'); await (await find.byLinkText('abc')).click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.timePicker.setDefaultDataRange(); + await timePicker.setDefaultDataRange(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await pieChart.expectPieSliceCount(5); }); }); diff --git a/test/functional/apps/dashboard/group5/saved_search_embeddable.ts b/test/functional/apps/dashboard/group5/saved_search_embeddable.ts index 1997012cbcf13..4b488fdb25d8a 100644 --- a/test/functional/apps/dashboard/group5/saved_search_embeddable.ts +++ b/test/functional/apps/dashboard/group5/saved_search_embeddable.ts @@ -17,7 +17,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const find = getService('find'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker', 'discover']); + const { common, dashboard, header, discover } = getPageObjects([ + 'common', + 'dashboard', + 'header', + 'discover', + ]); const from = 'Sep 22, 2015 @ 00:00:00.000'; const to = 'Sep 23, 2015 @ 00:00:00.000'; @@ -32,23 +37,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.common.setTime({ from, to }); - await PageObjects.dashboard.navigateToApp(); + await common.setTime({ from, to }); + await dashboard.navigateToApp(); await filterBar.ensureFieldEditorModalIsClosed(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); }); after(async () => { await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('highlighting on filtering works', async function () { await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); await filterBar.addFilter({ field: 'agent', operation: 'is', value: 'Mozilla' }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); const dataTable = await find.byCssSelector(`[data-test-subj="embeddedSavedSearchDocTable"]`); const $ = await dataTable.parseDomContent(); const marks = $('mark') @@ -59,8 +64,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('removing a filter removes highlights', async function () { await filterBar.removeAllFilters(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); const dataTable = await find.byCssSelector(`[data-test-subj="embeddedSavedSearchDocTable"]`); const $ = await dataTable.parseDomContent(); const marks = $('mark') @@ -71,22 +76,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('view action leads to a saved search', async function () { await filterBar.removeAllFilters(); - await PageObjects.dashboard.saveDashboard('Dashboard With Saved Search'); - await PageObjects.dashboard.clickCancelOutOfEditMode(false); - const inViewMode = await PageObjects.dashboard.getIsInViewMode(); + await dashboard.saveDashboard('Dashboard With Saved Search'); + await dashboard.clickCancelOutOfEditMode(false); + const inViewMode = await dashboard.getIsInViewMode(); expect(inViewMode).to.equal(true); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); await dashboardPanelActions.clickContextMenuItem( 'embeddablePanelAction-ACTION_VIEW_SAVED_SEARCH' ); - await PageObjects.discover.waitForDiscoverAppOnScreen(); - expect(await PageObjects.discover.getSavedSearchTitle()).to.equal( - 'Rendering Test: saved search' - ); + await discover.waitForDiscoverAppOnScreen(); + expect(await discover.getSavedSearchTitle()).to.equal('Rendering Test: saved search'); }); }); } diff --git a/test/functional/apps/dashboard/group5/share.ts b/test/functional/apps/dashboard/group5/share.ts index b21f8e4b96b65..ebb1b6a68e9f5 100644 --- a/test/functional/apps/dashboard/group5/share.ts +++ b/test/functional/apps/dashboard/group5/share.ts @@ -43,19 +43,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const dashboardCustomizePanel = getService('dashboardCustomizePanel'); - const PageObjects = getPageObjects(['dashboard', 'common', 'share', 'timePicker']); + const { dashboard, common, share } = getPageObjects(['dashboard', 'common', 'share']); const getSharedUrl = async (mode: TestingModes): Promise => { await retry.waitFor('share menu to open', async () => { - await PageObjects.share.clickShareTopNavButton(); - return await PageObjects.share.isShareMenuOpen(); + await share.clickShareTopNavButton(); + return await share.isShareMenuOpen(); }); - return await PageObjects.share.getSharedUrl(); + return await share.getSharedUrl(); }; const unpinnedFilterIsOnlyWhenDashboardIsUnsaved = async (mode: TestingModes) => { await filterBar.addFilter({ field: 'geo.src', operation: 'is', value: 'AE' }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); const sharedUrl = await getSharedUrl(mode); const { globalState, appState } = getStateFromUrl(sharedUrl); @@ -68,8 +68,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; const unpinnedFilterIsRemoved = async (mode: TestingModes) => { - await PageObjects.dashboard.clickQuickSave(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.clickQuickSave(); + await dashboard.waitForRenderComplete(); const sharedUrl = await getSharedUrl(mode); expect(sharedUrl).to.not.contain('appState'); @@ -77,8 +77,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const pinnedFilterIsWhenDashboardInGlobalState = async (mode: TestingModes) => { await filterBar.toggleFilterPinned('geo.src'); - await PageObjects.dashboard.clickQuickSave(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.clickQuickSave(); + await dashboard.waitForRenderComplete(); const sharedUrl = await getSharedUrl(mode); const { globalState, appState } = getStateFromUrl(sharedUrl); @@ -99,17 +99,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); const from = 'Sep 19, 2017 @ 06:31:44.000'; const to = 'Sep 23, 2018 @ 18:31:44.000'; - await PageObjects.common.setTime({ from, to }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); - await PageObjects.dashboard.switchToEditMode(); - await PageObjects.dashboard.waitForRenderComplete(); + await common.setTime({ from, to }); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('few panels'); + await dashboard.switchToEditMode(); + await dashboard.waitForRenderComplete(); }); after(async () => { await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); describe('snapshot share', () => { @@ -123,7 +123,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardPanelActions.customizePanel(); await dashboardCustomizePanel.setCustomPanelTitle('Test New Title'); await dashboardCustomizePanel.clickSaveButton(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await testSubjects.existOrFail('dashboardUnsavedChangesBadge'); const sharedUrl = await getSharedUrl('snapshot'); @@ -132,8 +132,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should once again not have "panels" state when save is clicked', async () => { - await PageObjects.dashboard.clickQuickSave(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.clickQuickSave(); + await dashboard.waitForRenderComplete(); await testSubjects.missingOrFail('dashboardUnsavedChangesBadge'); expect(await getSharedUrl('snapshot')).to.not.contain('panels'); }); @@ -161,8 +161,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await filterBar.removeAllFilters(); - await PageObjects.dashboard.clickQuickSave(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.clickQuickSave(); + await dashboard.waitForRenderComplete(); }); }); diff --git a/test/functional/apps/dashboard/group6/dashboard_esql_chart.ts b/test/functional/apps/dashboard/group6/dashboard_esql_chart.ts index eb2d05da0d450..fd234bfa7e4cb 100644 --- a/test/functional/apps/dashboard/group6/dashboard_esql_chart.ts +++ b/test/functional/apps/dashboard/group6/dashboard_esql_chart.ts @@ -14,7 +14,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'dashboard', 'timePicker', 'header']); + const { dashboard, timePicker, header } = getPageObjects(['dashboard', 'timePicker', 'header']); const testSubjects = getService('testSubjects'); const monacoEditor = getService('monacoEditor'); const dashboardAddPanel = getService('dashboardAddPanel'); @@ -31,17 +31,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should add an ES|QL datatable chart when the ES|QL panel action is clicked', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultDataRange(); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultDataRange(); + await dashboard.switchToEditMode(); await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAddNewPanelFromUIActionLink('ES|QL'); await dashboardAddPanel.expectEditorMenuClosed(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await retry.try(async () => { - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); }); @@ -50,9 +50,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should remove the panel if cancel button is clicked', async () => { await testSubjects.click('cancelFlyoutButton'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await retry.try(async () => { - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(0); }); }); @@ -61,11 +61,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAddNewPanelFromUIActionLink('ES|QL'); await dashboardAddPanel.expectEditorMenuClosed(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await monacoEditor.setCodeEditorValue('from logstash-* | stats maxB = max(bytes)'); await testSubjects.click('TextBasedLangEditor-run-query-button'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('applyFlyoutButton'); expect(await testSubjects.exists('mtrVis')).to.be(true); diff --git a/test/functional/apps/dashboard/group6/dashboard_grid.ts b/test/functional/apps/dashboard/group6/dashboard_grid.ts index a68ec3f96eebb..ddabac7ace11a 100644 --- a/test/functional/apps/dashboard/group6/dashboard_grid.ts +++ b/test/functional/apps/dashboard/group6/dashboard_grid.ts @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const browser = getService('browser'); const kibanaServer = getService('kibanaServer'); const dashboardPanelActions = getService('dashboardPanelActions'); - const PageObjects = getPageObjects(['common', 'dashboard']); + const { dashboard } = getPageObjects(['dashboard']); describe('dashboard grid', function () { before(async () => { @@ -26,10 +26,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('few panels'); + await dashboard.switchToEditMode(); }); after(async () => { diff --git a/test/functional/apps/dashboard/group6/dashboard_saved_query.ts b/test/functional/apps/dashboard/group6/dashboard_saved_query.ts index 7ec58ed8ce54a..acb3e7980b5ef 100644 --- a/test/functional/apps/dashboard/group6/dashboard_saved_query.ts +++ b/test/functional/apps/dashboard/group6/dashboard_saved_query.ts @@ -13,7 +13,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'dashboard', 'timePicker']); + const { dashboard, timePicker } = getPageObjects(['dashboard', 'timePicker']); const browser = getService('browser'); const queryBar = getService('queryBar'); const savedQueryManagementComponent = getService('savedQueryManagementComponent'); @@ -28,7 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); }); after(async () => { @@ -38,8 +38,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // FLAKY: https://github.com/elastic/kibana/issues/189023 describe.skip('saved query management component functionality', function () { before(async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); }); it('should show the saved query management load button as disabled when there are no saved queries', async () => { @@ -71,19 +71,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('reinstates filters and the time filter when a saved query has filters and a time filter included', async () => { - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); await savedQueryManagementComponent.clearCurrentlyLoadedQuery(); await savedQueryManagementComponent.loadSavedQuery('OkResponse'); - const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); - expect(timePickerValues.start).to.not.eql(PageObjects.timePicker.defaultStartTime); - expect(timePickerValues.end).to.not.eql(PageObjects.timePicker.defaultEndTime); + const timePickerValues = await timePicker.getTimeConfigAsAbsoluteTimes(); + expect(timePickerValues.start).to.not.eql(timePicker.defaultStartTime); + expect(timePickerValues.end).to.not.eql(timePicker.defaultEndTime); }); it('preserves the currently loaded query when the page is reloaded', async () => { await browser.refresh(); - const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); - expect(timePickerValues.start).to.not.eql(PageObjects.timePicker.defaultStartTime); - expect(timePickerValues.end).to.not.eql(PageObjects.timePicker.defaultEndTime); + const timePickerValues = await timePicker.getTimeConfigAsAbsoluteTimes(); + expect(timePickerValues.start).to.not.eql(timePicker.defaultStartTime); + expect(timePickerValues.end).to.not.eql(timePicker.defaultEndTime); expect(await savedQueryManagementComponent.getCurrentlyLoadedQueryID()).to.be('OkResponse'); }); diff --git a/test/functional/apps/dashboard/group6/dashboard_snapshots.ts b/test/functional/apps/dashboard/group6/dashboard_snapshots.ts index 2dec441ed2c52..4a4b21f21e600 100644 --- a/test/functional/apps/dashboard/group6/dashboard_snapshots.ts +++ b/test/functional/apps/dashboard/group6/dashboard_snapshots.ts @@ -17,12 +17,10 @@ export default function ({ getPageObjects, updateBaselines, }: FtrProviderContext & { updateBaselines: boolean }) { - const PageObjects = getPageObjects([ + const { dashboard, dashboardControls, header, timePicker } = getPageObjects([ 'dashboard', 'dashboardControls', 'header', - 'visualize', - 'common', 'timePicker', ]); const screenshot = getService('screenshots'); @@ -47,7 +45,7 @@ export default function ({ await browser.setScreenshotSize(1000, 500); // adding this navigate adds the timestamp hash to the url which invalidates previous // session. If we don't do this, the colors on the visualizations are different and the screenshots won't match. - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); }); after(async function () { @@ -56,50 +54,50 @@ export default function ({ }); it('compare TSVB snapshot', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setLogstashDataRange(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await timePicker.setLogstashDataRange(); await dashboardAddPanel.addVisualization('Rendering Test: tsvb-ts'); await toasts.dismissIfExists(); - await PageObjects.dashboard.saveDashboard('tsvb'); - await PageObjects.dashboard.clickFullScreenMode(); + await dashboard.saveDashboard('tsvb'); + await dashboard.clickFullScreenMode(); await dashboardPanelActions.clickExpandPanelToggle(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); const percentDifference = await screenshot.compareAgainstBaseline( 'tsvb_dashboard', updateBaselines ); - await PageObjects.dashboard.clickExitFullScreenLogoButton(); + await dashboard.clickExitFullScreenLogoButton(); expect(percentDifference).to.be.lessThan(0.022); }); it('compare area chart snapshot', async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setLogstashDataRange(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await timePicker.setLogstashDataRange(); await dashboardAddPanel.addVisualization('Rendering Test: area with not filter'); await toasts.dismissIfExists(); - await PageObjects.dashboard.saveDashboard('area'); - await PageObjects.dashboard.clickFullScreenMode(); + await dashboard.saveDashboard('area'); + await dashboard.clickFullScreenMode(); await dashboardPanelActions.clickExpandPanelToggle(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); const percentDifference = await screenshot.compareAgainstBaseline( 'area_chart', updateBaselines ); - await PageObjects.dashboard.clickExitFullScreenLogoButton(); + await dashboard.clickExitFullScreenLogoButton(); expect(percentDifference).to.be.lessThan(0.029); }); describe('compare controls snapshot', () => { const waitForPageReady = async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('page ready for screenshot', async () => { const queryBarVisible = await testSubjects.exists('globalQueryBar'); const controlGroupVisible = await testSubjects.exists('controls-group-wrapper'); @@ -108,21 +106,21 @@ export default function ({ }; before(async () => { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboardControls.createControl({ + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboardControls.createControl({ controlType: OPTIONS_LIST_CONTROL, dataViewTitle: 'logstash-*', fieldName: 'machine.os.raw', title: 'Machine OS', }); - await PageObjects.dashboardControls.createControl({ + await dashboardControls.createControl({ controlType: RANGE_SLIDER_CONTROL, dataViewTitle: 'logstash-*', fieldName: 'bytes', title: 'Bytes', }); - await PageObjects.dashboard.saveDashboard('Dashboard Controls'); + await dashboard.saveDashboard('Dashboard Controls'); }); it('in light mode', async () => { diff --git a/test/functional/apps/dashboard/group6/embeddable_library.ts b/test/functional/apps/dashboard/group6/embeddable_library.ts index 72cd36521d490..b7b0a1c3712d8 100644 --- a/test/functional/apps/dashboard/group6/embeddable_library.ts +++ b/test/functional/apps/dashboard/group6/embeddable_library.ts @@ -7,18 +7,16 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import expect from '@kbn/expect'; - import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'settings', 'common']); + const { dashboard } = getPageObjects(['dashboard']); const find = getService('find'); const kibanaServer = getService('kibanaServer'); - const testSubjects = getService('testSubjects'); const dashboardAddPanel = getService('dashboardAddPanel'); const panelActions = getService('dashboardPanelActions'); const savedObjectsFinder = getService('savedObjectsFinder'); + const title = 'Rendering Test: heatmap'; describe('embeddable library', () => { before(async () => { @@ -29,48 +27,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); }); it('unlink visualize panel from embeddable library', async () => { // add heatmap panel from library await dashboardAddPanel.clickOpenAddPanel(); - await savedObjectsFinder.filterEmbeddableNames('Rendering Test: heatmap'); - await find.clickByButtonText('Rendering Test: heatmap'); + await savedObjectsFinder.filterEmbeddableNames(title); + await find.clickByButtonText(title); await dashboardAddPanel.closeAddPanel(); - const originalPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:heatmap'); - await panelActions.unlinkFromLibrary(originalPanel); - await testSubjects.existOrFail('unlinkPanelSuccess'); - - const updatedPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:heatmap'); - const libraryActionExists = await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - updatedPanel - ); - expect(libraryActionExists).to.be(false); + await panelActions.unlinkFromLibrary(title); + await panelActions.expectNotLinkedToLibrary(title); await dashboardAddPanel.clickOpenAddPanel(); - await savedObjectsFinder.filterEmbeddableNames('Rendering Test: heatmap'); - await find.existsByLinkText('Rendering Test: heatmap'); + await savedObjectsFinder.filterEmbeddableNames(title); + await find.existsByLinkText(title); await dashboardAddPanel.closeAddPanel(); }); it('save visualize panel to embeddable library', async () => { - const originalPanel = await testSubjects.find('embeddablePanelHeading-RenderingTest:heatmap'); - await panelActions.saveToLibrary('Rendering Test: heatmap - copy', originalPanel); - await testSubjects.existOrFail('addPanelToLibrarySuccess'); - - const updatedPanel = await testSubjects.find( - 'embeddablePanelHeading-RenderingTest:heatmap-copy' - ); - const libraryActionExists = await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - updatedPanel - ); - expect(libraryActionExists).to.be(true); + const newTitle = 'Rendering Test: heatmap - copy'; + await panelActions.saveToLibrary(newTitle, title); + await panelActions.expectLinkedToLibrary(newTitle); }); }); } diff --git a/test/functional/apps/dashboard/group6/view_edit.ts b/test/functional/apps/dashboard/group6/view_edit.ts index b7bb75d9af807..487adc753e652 100644 --- a/test/functional/apps/dashboard/group6/view_edit.ts +++ b/test/functional/apps/dashboard/group6/view_edit.ts @@ -15,7 +15,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const queryBar = getService('queryBar'); const kibanaServer = getService('kibanaServer'); const dashboardAddPanel = getService('dashboardAddPanel'); - const PageObjects = getPageObjects(['dashboard', 'header', 'common', 'visualize', 'timePicker']); + const { dashboard, common, visualize, timePicker } = getPageObjects([ + 'dashboard', + 'common', + 'visualize', + 'timePicker', + ]); const dashboardName = 'dashboard with filter'; const filterBar = getService('filterBar'); const security = getService('security'); @@ -30,8 +35,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); }); after(async () => { @@ -40,47 +45,47 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('existing dashboard opens in last used view mode', async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard(dashboardName); - expect(await PageObjects.dashboard.getIsInViewMode()).to.equal(true); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard(dashboardName); + expect(await dashboard.getIsInViewMode()).to.equal(true); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard(dashboardName); - expect(await PageObjects.dashboard.getIsInViewMode()).to.equal(false); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard(dashboardName); + expect(await dashboard.getIsInViewMode()).to.equal(false); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.loadSavedDashboard('few panels'); - expect(await PageObjects.dashboard.getIsInViewMode()).to.equal(false); + await dashboard.gotoDashboardLandingPage(); + await dashboard.loadSavedDashboard('few panels'); + expect(await dashboard.getIsInViewMode()).to.equal(false); - await PageObjects.dashboard.clickCancelOutOfEditMode(); + await dashboard.clickCancelOutOfEditMode(); }); it('create new dashboard opens in edit mode', async function () { - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - const isInViewMode = await PageObjects.dashboard.getIsInViewMode(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + const isInViewMode = await dashboard.getIsInViewMode(); expect(isInViewMode).to.be(false); }); describe('save as new', () => { it('keeps duplicated dashboard in edit mode', async () => { - await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); - await PageObjects.dashboard.duplicateDashboard('edit'); - const isViewMode = await PageObjects.dashboard.getIsInViewMode(); + await dashboard.gotoDashboardEditMode(dashboardName); + await dashboard.duplicateDashboard('edit'); + const isViewMode = await dashboard.getIsInViewMode(); expect(isViewMode).to.equal(false); }); }); describe('save', function () { it('keeps dashboard in edit mode', async function () { - await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); - await PageObjects.dashboard.saveDashboard(dashboardName, { + await dashboard.gotoDashboardEditMode(dashboardName); + await dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: true, saveAsNew: false, }); - const isViewMode = await PageObjects.dashboard.getIsInViewMode(); + const isViewMode = await dashboard.getIsInViewMode(); expect(isViewMode).to.equal(false); }); }); @@ -88,26 +93,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('shows lose changes warning', function () { describe('and loses changes on confirmation', function () { beforeEach(async function () { - await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); + await dashboard.gotoDashboardEditMode(dashboardName); }); it('when time changed is stored with dashboard', async function () { - await PageObjects.timePicker.setDefaultDataRange(); + await timePicker.setDefaultDataRange(); - const originalTime = await PageObjects.timePicker.getTimeConfig(); + const originalTime = await timePicker.getTimeConfig(); - await PageObjects.dashboard.saveDashboard(dashboardName, { + await dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: true, saveAsNew: false, }); - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 19, 2013 @ 06:31:44.000', 'Sep 19, 2013 @ 06:31:44.000' ); - await PageObjects.dashboard.clickCancelOutOfEditMode(); + await dashboard.clickCancelOutOfEditMode(); - const newTime = await PageObjects.timePicker.getTimeConfig(); + const newTime = await timePicker.getTimeConfig(); expect(newTime.start).to.equal(originalTime.start); expect(newTime.end).to.equal(originalTime.end); @@ -118,7 +123,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await queryBar.setQuery(`${originalQuery}and extra stuff`); await queryBar.submitQuery(); - await PageObjects.dashboard.clickCancelOutOfEditMode(); + await dashboard.clickCancelOutOfEditMode(); const query = await queryBar.getQueryString(); expect(query).to.equal(originalQuery); @@ -127,8 +132,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('when a filter is deleted', async function () { // This may seem like a pointless line but there was a bug that only arose when the dashboard // was loaded initially - await PageObjects.dashboard.loadSavedDashboard(dashboardName); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.loadSavedDashboard(dashboardName); + await dashboard.switchToEditMode(); let hasFilter = await filterBar.hasFilter('animal', 'dog'); expect(hasFilter).to.be(true); @@ -138,69 +143,69 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { hasFilter = await filterBar.hasFilter('animal', 'dog'); expect(hasFilter).to.be(false); - await PageObjects.dashboard.clickCancelOutOfEditMode(); + await dashboard.clickCancelOutOfEditMode(); hasFilter = await filterBar.hasFilter('animal', 'dog'); expect(hasFilter).to.be(true); }); it('when a new vis is added', async function () { - const originalPanelCount = await PageObjects.dashboard.getPanelCount(); + const originalPanelCount = await dashboard.getPanelCount(); await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAggBasedVisualizations(); - await PageObjects.visualize.clickAreaChart(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visualize.saveVisualizationExpectSuccess('new viz panel', { + await visualize.clickAreaChart(); + await visualize.clickNewSearch(); + await visualize.saveVisualizationExpectSuccess('new viz panel', { saveAsNew: false, redirectToOrigin: true, }); - await PageObjects.dashboard.clickCancelOutOfEditMode(false); + await dashboard.clickCancelOutOfEditMode(false); // for this sleep see https://github.com/elastic/kibana/issues/22299 - await PageObjects.common.sleep(500); + await common.sleep(500); // confirm lose changes - await PageObjects.common.clickConfirmOnModal(); + await common.clickConfirmOnModal(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(originalPanelCount); }); it('when an existing vis is added', async function () { - const originalPanelCount = await PageObjects.dashboard.getPanelCount(); + const originalPanelCount = await dashboard.getPanelCount(); await dashboardAddPanel.addVisualization('new viz panel'); - await PageObjects.dashboard.clickCancelOutOfEditMode(); + await dashboard.clickCancelOutOfEditMode(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(originalPanelCount); }); }); describe('and preserves edits on cancel', function () { it('when time changed is stored with dashboard', async function () { - await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); - await PageObjects.timePicker.setAbsoluteRange( + await dashboard.gotoDashboardEditMode(dashboardName); + await timePicker.setAbsoluteRange( 'Sep 19, 2013 @ 06:31:44.000', 'Sep 19, 2013 @ 06:31:44.000' ); - await PageObjects.dashboard.saveDashboard(dashboardName, { saveAsNew: false }); - await PageObjects.dashboard.switchToEditMode(); - await PageObjects.timePicker.setAbsoluteRange( + await dashboard.saveDashboard(dashboardName, { saveAsNew: false }); + await dashboard.switchToEditMode(); + await timePicker.setAbsoluteRange( 'Sep 19, 2015 @ 06:31:44.000', 'Sep 19, 2015 @ 06:31:44.000' ); - await PageObjects.dashboard.clickCancelOutOfEditMode(false); + await dashboard.clickCancelOutOfEditMode(false); - await PageObjects.common.clickCancelOnModal(); - await PageObjects.dashboard.saveDashboard(dashboardName, { + await common.clickCancelOnModal(); + await dashboard.saveDashboard(dashboardName, { saveAsNew: false, storeTimeWithDashboard: true, }); - await PageObjects.dashboard.loadSavedDashboard(dashboardName); + await dashboard.loadSavedDashboard(dashboardName); - const time = await PageObjects.timePicker.getTimeConfig(); + const time = await timePicker.getTimeConfig(); expect(time.start).to.equal('Sep 19, 2015 @ 06:31:44.000'); expect(time.end).to.equal('Sep 19, 2015 @ 06:31:44.000'); @@ -210,26 +215,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('and preserves edits on cancel', function () { it('when time changed is stored with dashboard', async function () { - await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); - await PageObjects.timePicker.setDefaultDataRange(); - await PageObjects.dashboard.saveDashboard(dashboardName, { saveAsNew: false }); - await PageObjects.timePicker.setAbsoluteRange( + await dashboard.gotoDashboardEditMode(dashboardName); + await timePicker.setDefaultDataRange(); + await dashboard.saveDashboard(dashboardName, { saveAsNew: false }); + await timePicker.setAbsoluteRange( 'Sep 19, 2013 @ 06:31:44.000', 'Sep 19, 2013 @ 06:31:44.000' ); - const newTime = await PageObjects.timePicker.getTimeConfig(); + const newTime = await timePicker.getTimeConfig(); - await PageObjects.dashboard.clickCancelOutOfEditMode(false); + await dashboard.clickCancelOutOfEditMode(false); - await PageObjects.common.clickCancelOnModal(); - await PageObjects.dashboard.saveDashboard(dashboardName, { + await common.clickCancelOnModal(); + await dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: true, saveAsNew: false, }); - await PageObjects.dashboard.loadSavedDashboard(dashboardName); + await dashboard.loadSavedDashboard(dashboardName); - const time = await PageObjects.timePicker.getTimeConfig(); + const time = await timePicker.getTimeConfig(); expect(time.start).to.equal(newTime.start); expect(time.end).to.equal(newTime.end); @@ -238,32 +243,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Does not show lose changes warning', function () { it('when time changed is not stored with dashboard', async function () { - await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); - await PageObjects.dashboard.saveDashboard(dashboardName, { + await dashboard.gotoDashboardEditMode(dashboardName); + await dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: false, saveAsNew: false, }); - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Oct 19, 2014 @ 06:31:44.000', 'Dec 19, 2014 @ 06:31:44.000' ); - await PageObjects.dashboard.clickCancelOutOfEditMode(false); + await dashboard.clickCancelOutOfEditMode(false); - await PageObjects.common.expectConfirmModalOpenState(false); + await common.expectConfirmModalOpenState(false); }); // See https://github.com/elastic/kibana/issues/10110 - this is intentional. it('when the query is edited but not applied', async function () { - await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); + await dashboard.gotoDashboardEditMode(dashboardName); const originalQuery = await queryBar.getQueryString(); await queryBar.setQuery(`${originalQuery}extra stuff`); - await PageObjects.dashboard.clickCancelOutOfEditMode(false); + await dashboard.clickCancelOutOfEditMode(false); - await PageObjects.common.expectConfirmModalOpenState(false); + await common.expectConfirmModalOpenState(false); - await PageObjects.dashboard.loadSavedDashboard(dashboardName); + await dashboard.loadSavedDashboard(dashboardName); const query = await queryBar.getQueryString(); expect(query).to.equal(originalQuery); }); 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 5b279eff7833b..1639c273dffbb 100644 --- a/test/functional/apps/dashboard_elements/image_embeddable/image_embeddable.ts +++ b/test/functional/apps/dashboard_elements/image_embeddable/image_embeddable.ts @@ -11,7 +11,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'dashboard', 'discover', 'header']); + const { common, dashboard, header } = getPageObjects(['common', 'dashboard', 'header']); const testSubjects = getService('testSubjects'); const dashboardAddPanel = getService('dashboardAddPanel'); const kibanaServer = getService('kibanaServer'); @@ -30,9 +30,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + await dashboard.switchToEditMode(); }); it('should create an image embeddable', async () => { @@ -40,13 +40,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickAddNewPanelFromUIActionLink('Image'); await testSubjects.exists(`createImageEmbeddableFlyout`); - await PageObjects.common.setFileInputPath(require.resolve('./elastic_logo.png')); + await common.setFileInputPath(require.resolve('./elastic_logo.png')); await testSubjects.clickWhenNotDisabled(`imageEmbeddableEditorSave`); // check that it is added on the dashboard - expect(await PageObjects.dashboard.getSharedItemsCount()).to.be('1'); - await PageObjects.dashboard.waitForRenderComplete(); - const panel = (await PageObjects.dashboard.getDashboardPanels())[0]; + expect(await dashboard.getSharedItemsCount()).to.be('1'); + await dashboard.waitForRenderComplete(); + const panel = (await dashboard.getDashboardPanels())[0]; const img = await panel.findByCssSelector('img.euiImage'); const imgSrc = await img.getAttribute('src'); expect(imgSrc).to.contain(`files/defaultImage`); @@ -66,21 +66,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardDrilldownsManage.saveChanges(); await dashboardDrilldownsManage.closeFlyout(); - expect(await PageObjects.dashboard.getPanelDrilldownCount()).to.be(1); + expect(await dashboardDrilldownPanelActions.getPanelDrilldownCount()).to.be(1); - const panel = (await PageObjects.dashboard.getDashboardPanels())[0]; + const panel = (await dashboard.getDashboardPanels())[0]; const img = await panel.findByCssSelector('img.euiImage'); - const oldDashboardId = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); + const oldDashboardId = await dashboard.getDashboardIdFromCurrentUrl(); await img.click(); await retry.waitFor('navigate to different dashboard', async () => { - const newDashboardId = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); + const newDashboardId = await dashboard.getDashboardIdFromCurrentUrl(); return typeof newDashboardId === 'string' && oldDashboardId !== newDashboardId; }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); }); }); } diff --git a/test/functional/apps/dashboard_elements/input_control_vis/chained_controls.ts b/test/functional/apps/dashboard_elements/input_control_vis/chained_controls.ts index 1339b22af0e07..6e26a11e29c4a 100644 --- a/test/functional/apps/dashboard_elements/input_control_vis/chained_controls.ts +++ b/test/functional/apps/dashboard_elements/input_control_vis/chained_controls.ts @@ -13,7 +13,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'visualize', 'visEditor', 'header', 'timePicker']); + const { common, visualize, visEditor } = getPageObjects(['common', 'visualize', 'visEditor']); const testSubjects = getService('testSubjects'); const find = getService('find'); const comboBox = getService('comboBox'); @@ -22,9 +22,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { this.tags('includeFirefox'); before(async () => { - await PageObjects.visualize.initTests(); - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.visualize.loadSavedVisualization('chained input control', { + await visualize.initTests(); + await common.navigateToApp('visualize'); + await visualize.loadSavedVisualization('chained input control', { navigateToVisualize: false, }); await testSubjects.waitForEnabled('addFilter', 10000); @@ -50,7 +50,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should create a seperate filter pill for parent control and child control', async () => { await comboBox.set('listControlSelect1', '14.61.182.136'); - await PageObjects.visEditor.inputControlSubmit(); + await visEditor.inputControlSubmit(); const hasParentControlFilter = await filterBar.hasFilter('geo.src', 'BR'); expect(hasParentControlFilter).to.equal(true); @@ -61,7 +61,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should clear child control dropdown when parent control value is removed', async () => { await comboBox.clear('listControlSelect0'); - await PageObjects.common.sleep(500); // give time for filter to be removed and event handlers to fire + await common.sleep(500); // give time for filter to be removed and event handlers to fire const childControlInput = await find.byCssSelector('[data-test-subj="inputControl1"] input'); const isDisabled = await childControlInput.getAttribute('disabled'); @@ -72,7 +72,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should clear child control dropdown when parent control filter pill removed', async () => { await filterBar.removeFilter('geo.src'); - await PageObjects.common.sleep(500); // give time for filter to be removed and event handlers to fire + await common.sleep(500); // give time for filter to be removed and event handlers to fire const hasValue = await comboBox.doesComboBoxHaveSelectedOptions('listControlSelect0'); expect(hasValue).to.equal(false); diff --git a/test/functional/apps/dashboard_elements/input_control_vis/dynamic_options.ts b/test/functional/apps/dashboard_elements/input_control_vis/dynamic_options.ts index b963118933df1..1ceec60dc0688 100644 --- a/test/functional/apps/dashboard_elements/input_control_vis/dynamic_options.ts +++ b/test/functional/apps/dashboard_elements/input_control_vis/dynamic_options.ts @@ -12,18 +12,23 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'visualize', 'visEditor', 'header', 'timePicker']); + const { common, visualize, visEditor, header } = getPageObjects([ + 'common', + 'visualize', + 'visEditor', + 'header', + ]); const comboBox = getService('comboBox'); describe('dynamic options', () => { before(async () => { - await PageObjects.visualize.initTests(); + await visualize.initTests(); }); describe('without chained controls', () => { beforeEach(async () => { - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.visualize.loadSavedVisualization('dynamic options input control', { + await common.navigateToApp('visualize'); + await visualize.loadSavedVisualization('dynamic options input control', { navigateToVisualize: false, }); }); @@ -33,7 +38,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(initialOptions.trim().split('\n').join()).to.equal('BD,BR,CN,ID,IN,JP,NG,PK,RU'); await comboBox.filterOptionsList('listControlSelect0', 'R'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const updatedOptions = await comboBox.getOptionsList('listControlSelect0'); expect(updatedOptions.trim().split('\n').join()).to.equal('AR,BR,FR,GR,IR,KR,RO,RU,RW'); @@ -41,7 +46,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should not fetch new options when non-string is filtered', async () => { await comboBox.set('fieldSelect-0', 'clientip'); - await PageObjects.visEditor.clickGo(); + await visEditor.clickGo(); const initialOptions = await comboBox.getOptionsList('listControlSelect0'); expect(initialOptions.trim().split('\n').join()).to.equal( @@ -49,7 +54,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await comboBox.filterOptionsList('listControlSelect0', '17'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const updatedOptions = await comboBox.getOptionsList('listControlSelect0'); expect(updatedOptions.trim().split('\n').join()).to.equal( @@ -60,11 +65,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('with chained controls', () => { before(async () => { - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.visualize.loadSavedVisualization( - 'chained input control with dynamic options', - { navigateToVisualize: false } - ); + await common.navigateToApp('visualize'); + await visualize.loadSavedVisualization('chained input control with dynamic options', { + navigateToVisualize: false, + }); await comboBox.set('listControlSelect0', 'win 7'); }); @@ -73,7 +77,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(initialOptions.trim().split('\n').join()).to.equal('BD,BR,CN,ID,IN,JP,MX,NG,PK'); await comboBox.filterOptionsList('listControlSelect1', 'R'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const updatedOptions = await comboBox.getOptionsList('listControlSelect1'); expect(updatedOptions.trim().split('\n').join()).to.equal('AR,BR,FR,GR,IR,KR,RO,RS,RU'); diff --git a/test/functional/apps/dashboard_elements/input_control_vis/input_control_options.ts b/test/functional/apps/dashboard_elements/input_control_vis/input_control_options.ts index c33c356ecc31a..cccf19de4070a 100644 --- a/test/functional/apps/dashboard_elements/input_control_vis/input_control_options.ts +++ b/test/functional/apps/dashboard_elements/input_control_vis/input_control_options.ts @@ -13,7 +13,12 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'visualize', 'visEditor', 'header', 'timePicker']); + const { common, visualize, visEditor, timePicker } = getPageObjects([ + 'common', + 'visualize', + 'visEditor', + 'timePicker', + ]); const testSubjects = getService('testSubjects'); const inspector = getService('inspector'); const find = getService('find'); @@ -22,9 +27,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('input control options', () => { before(async () => { - await PageObjects.visualize.initTests(); - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.visualize.loadSavedVisualization('input control options', { + await visualize.initTests(); + await common.navigateToApp('visualize'); + await visualize.loadSavedVisualization('input control options', { navigateToVisualize: false, }); }); @@ -68,7 +73,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should add filter pill when submit button is clicked', async () => { - await PageObjects.visEditor.inputControlSubmit(); + await visEditor.inputControlSubmit(); const hasFilter = await filterBar.hasFilter(FIELD_NAME, 'ios'); expect(hasFilter).to.equal(true); @@ -77,8 +82,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should replace existing filter pill(s) when new item is selected', async () => { await comboBox.clear('listControlSelect0'); await comboBox.set('listControlSelect0', 'osx'); - await PageObjects.visEditor.inputControlSubmit(); - await PageObjects.common.sleep(1000); + await visEditor.inputControlSubmit(); + await common.sleep(1000); const hasOldFilter = await filterBar.hasFilter(FIELD_NAME, 'ios'); const hasNewFilter = await filterBar.hasFilter(FIELD_NAME, 'osx'); @@ -88,7 +93,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should clear dropdown when filter pill removed', async () => { await filterBar.removeFilter(FIELD_NAME); - await PageObjects.common.sleep(500); // give time for filter to be removed and event handlers to fire + await common.sleep(500); // give time for filter to be removed and event handlers to fire const hasValue = await comboBox.doesComboBoxHaveSelectedOptions('listControlSelect0'); expect(hasValue).to.equal(false); @@ -96,11 +101,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should clear form when Clear button is clicked but not remove filter pill', async () => { await comboBox.set('listControlSelect0', 'ios'); - await PageObjects.visEditor.inputControlSubmit(); + await visEditor.inputControlSubmit(); const hasFilterBeforeClearBtnClicked = await filterBar.hasFilter(FIELD_NAME, 'ios'); expect(hasFilterBeforeClearBtnClicked).to.equal(true); - await PageObjects.visEditor.inputControlClear(); + await visEditor.inputControlClear(); const hasValue = await comboBox.doesComboBoxHaveSelectedOptions('listControlSelect0'); expect(hasValue).to.equal(false); @@ -109,7 +114,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should remove filter pill when cleared form is submitted', async () => { - await PageObjects.visEditor.inputControlSubmit(); + await visEditor.inputControlSubmit(); const hasFilter = await filterBar.hasFilter(FIELD_NAME, 'ios'); expect(hasFilter).to.equal(false); }); @@ -117,17 +122,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('updateFiltersOnChange is true', () => { before(async () => { - await PageObjects.visEditor.clickVisEditorTab('options'); - await PageObjects.visEditor.checkSwitch('inputControlEditorUpdateFiltersOnChangeCheckbox'); - await PageObjects.visEditor.clickGo(); + await visEditor.clickVisEditorTab('options'); + await visEditor.checkSwitch('inputControlEditorUpdateFiltersOnChangeCheckbox'); + await visEditor.clickGo(); }); after(async () => { - await PageObjects.visEditor.clickVisEditorTab('options'); - await PageObjects.visEditor.uncheckSwitch( - 'inputControlEditorUpdateFiltersOnChangeCheckbox' - ); - await PageObjects.visEditor.clickGo(); + await visEditor.clickVisEditorTab('options'); + await visEditor.uncheckSwitch('inputControlEditorUpdateFiltersOnChangeCheckbox'); + await visEditor.clickGo(); }); it('should not display staging control buttons', async () => { @@ -152,9 +155,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('useTimeFilter', () => { it('should use global time filter when getting terms', async () => { - await PageObjects.visEditor.clickVisEditorTab('options'); + await visEditor.clickVisEditorTab('options'); await testSubjects.setCheckbox('inputControlEditorUseTimeFilterCheckbox', 'check'); - await PageObjects.visEditor.clickGo(); + await visEditor.clickGo(); // Expect control to be disabled because no terms could be gathered with time filter applied const input = await find.byCssSelector('[data-test-subj="inputControl0"] input'); @@ -163,7 +166,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should re-create control when global time filter is updated', async () => { - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Jan 1, 2015 @ 00:00:00.000', 'Jan 1, 2016 @ 00:00:00.000' ); @@ -175,7 +178,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); }); } diff --git a/test/functional/apps/dashboard_elements/links/index.ts b/test/functional/apps/dashboard_elements/links/index.ts index 5882a20b2fe4d..423dec5591465 100644 --- a/test/functional/apps/dashboard_elements/links/index.ts +++ b/test/functional/apps/dashboard_elements/links/index.ts @@ -14,7 +14,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid const kibanaServer = getService('kibanaServer'); const security = getService('security'); - const { dashboard } = getPageObjects(['dashboardControls', 'dashboard']); + const { dashboard } = getPageObjects(['dashboard']); async function setup() { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/dashboard/current/data'); diff --git a/test/functional/apps/dashboard_elements/links/links_create_edit.ts b/test/functional/apps/dashboard_elements/links/links_create_edit.ts index 688d5cf58b77f..df930b42c2001 100644 --- a/test/functional/apps/dashboard_elements/links/links_create_edit.ts +++ b/test/functional/apps/dashboard_elements/links/links_create_edit.ts @@ -77,7 +77,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await common.waitForSaveModalToClose(); await testSubjects.exists('addObjectToDashboardSuccess'); await testSubjects.existOrFail('links--component'); - await testSubjects.existOrFail('embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION'); + await dashboardPanelActions.expectLinkedToLibrary(LINKS_PANEL_NAME, false); expect(await dashboardLinks.getNumberOfLinksInPanel()).to.equal(4); await dashboard.clickDiscardChanges(); @@ -106,9 +106,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardLinks.clickPanelEditorSaveButton(); await testSubjects.exists('addObjectToDashboardSuccess'); await testSubjects.existOrFail('links--component'); - await testSubjects.missingOrFail( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION' - ); + await dashboardPanelActions.expectNotLinkedToLibrary(); expect(await dashboardLinks.getNumberOfLinksInPanel()).to.equal(4); }); @@ -120,13 +118,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboard.waitForRenderComplete(); await dashboardPanelActions.saveToLibrary('Some more links'); - await testSubjects.existOrFail('addPanelToLibrarySuccess'); }); it('can unlink a panel from the library', async () => { - const panel = await testSubjects.find('embeddablePanelHeading-Somemorelinks'); - await dashboardPanelActions.unlinkFromLibrary(panel); - await testSubjects.existOrFail('unlinkPanelSuccess'); + await dashboardPanelActions.unlinkFromLibrary('Some more links'); }); after(async () => { diff --git a/test/functional/apps/dashboard_elements/markdown/_markdown_vis.ts b/test/functional/apps/dashboard_elements/markdown/_markdown_vis.ts index a9169b3ff21bd..18402669293f7 100644 --- a/test/functional/apps/dashboard_elements/markdown/_markdown_vis.ts +++ b/test/functional/apps/dashboard_elements/markdown/_markdown_vis.ts @@ -12,7 +12,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'visEditor', 'visChart', 'header']); + const { visualize, visEditor, visChart, header } = getPageObjects([ + 'visualize', + 'visEditor', + 'visChart', + 'header', + ]); const find = getService('find'); const inspector = getService('inspector'); const markdown = ` @@ -23,11 +28,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('markdown app in visualize app', () => { before(async function () { - await PageObjects.visualize.initTests(); - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickMarkdownWidget(); - await PageObjects.visEditor.setMarkdownTxt(markdown); - await PageObjects.visEditor.clickGo(); + await visualize.initTests(); + await visualize.navigateToNewVisualization(); + await visualize.clickMarkdownWidget(); + await visEditor.setMarkdownTxt(markdown); + await visEditor.clickGo(); }); describe('markdown vis', () => { @@ -36,12 +41,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render markdown as html', async function () { - const h1Txt = await PageObjects.visChart.getMarkdownBodyDescendentText('h1'); + const h1Txt = await visChart.getMarkdownBodyDescendentText('h1'); expect(h1Txt).to.equal('Heading 1'); }); it('should not render html in markdown as html', async function () { - const actual = await PageObjects.visChart.getMarkdownText(); + const actual = await visChart.getMarkdownText(); expect(actual).to.equal( 'Heading 1\n

Inline HTML that should not be rendered as html

' @@ -50,17 +55,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should auto apply changes if auto mode is turned on', async function () { const markdown2 = '## Heading 2'; - await PageObjects.visEditor.toggleAutoMode(); - await PageObjects.visEditor.setMarkdownTxt(markdown2); - await PageObjects.header.waitUntilLoadingHasFinished(); - const h1Txt = await PageObjects.visChart.getMarkdownBodyDescendentText('h2'); + await visEditor.toggleAutoMode(); + await visEditor.setMarkdownTxt(markdown2); + await header.waitUntilLoadingHasFinished(); + const h1Txt = await visChart.getMarkdownBodyDescendentText('h2'); expect(h1Txt).to.equal('Heading 2'); }); it('should resize the editor', async function () { const editorSidebar = await find.byCssSelector('.visEditor__collapsibleSidebar'); const initialSize = await editorSidebar.getSize(); - await PageObjects.visEditor.sizeUpEditor(); + await visEditor.sizeUpEditor(); const afterSize = await editorSidebar.getSize(); expect(afterSize.width).to.be.greaterThan(initialSize.width); }); diff --git a/test/functional/apps/discover/ccs_compatibility/_data_view_editor.ts b/test/functional/apps/discover/ccs_compatibility/_data_view_editor.ts index e87d9149a28ef..8c02a437980d1 100644 --- a/test/functional/apps/discover/ccs_compatibility/_data_view_editor.ts +++ b/test/functional/apps/discover/ccs_compatibility/_data_view_editor.ts @@ -15,13 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const security = getService('security'); const config = getService('config'); - const PageObjects = getPageObjects([ - 'common', - 'discover', - 'header', - 'timePicker', - 'unifiedSearch', - ]); + const { common, timePicker } = getPageObjects(['common', 'timePicker']); const defaultIndexPatternString = config.get('esTestCluster.ccs') ? 'ftr-remote:logstash-*' : 'logstash-*'; @@ -47,8 +41,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.savedObjects.clean({ types: ['saved-search', 'index-pattern'] }); await kibanaServer.importExport.load(kbnDirectory); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); after(async () => { diff --git a/test/functional/apps/discover/ccs_compatibility/_saved_queries.ts b/test/functional/apps/discover/ccs_compatibility/_saved_queries.ts index d7bf3de1d4017..4c02ea7cdf21d 100644 --- a/test/functional/apps/discover/ccs_compatibility/_saved_queries.ts +++ b/test/functional/apps/discover/ccs_compatibility/_saved_queries.ts @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const log = getService('log'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); + const { common, discover, timePicker } = getPageObjects(['common', 'discover', 'timePicker']); const browser = getService('browser'); const filterBar = getService('filterBar'); const queryBar = getService('queryBar'); @@ -54,24 +54,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.savedObjects.clean({ types: ['search', 'query'] }); // set up a query with filters and a time filter log.debug('set up a query with filters to save'); - await PageObjects.common.setTime({ from, to }); - await PageObjects.common.navigateToApp('discover'); + await common.setTime({ from, to }); + await common.navigateToApp('discover'); await dataViews.switchToAndValidate(logstashIndexPatternString); await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be('4,731'); }); await filterBar.addFilter({ field: 'extension.raw', operation: 'is one of', value: ['jpg'] }); await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be('3,029'); }); await queryBar.setQuery('response:200'); await queryBar.submitQuery(); await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be('2,792'); }); }; @@ -88,7 +88,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace(defaultSettings); log.debug('discover'); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async () => { @@ -98,7 +98,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.savedObjects.clean({ types: ['search', 'query'] }); await esNode.unload('test/functional/fixtures/es_archiver/date_nested'); await esNode.unload('test/functional/fixtures/es_archiver/logstash_functional'); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); describe('saved query selection', () => { @@ -117,7 +117,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true); expect(await queryBar.getQueryString()).to.eql('response:200'); - await PageObjects.discover.clickNewSearchButton(); + await discover.clickNewSearchButton(); expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(false); expect(await queryBar.getQueryString()).to.eql(''); @@ -129,7 +129,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataViews.switchToAndValidate(logstashIndexPatternString); await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be('4,731'); }); @@ -164,10 +164,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('reinstates filters and the time filter when a saved query has filters and a time filter included', async () => { - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); await savedQueryManagementComponent.clearCurrentlyLoadedQuery(); await savedQueryManagementComponent.loadSavedQuery('OkResponse'); - const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); + const timePickerValues = await timePicker.getTimeConfigAsAbsoluteTimes(); expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true); expect(timePickerValues.start).to.eql(from); expect(timePickerValues.end).to.eql(to); @@ -175,12 +175,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('preserves the currently loaded query when the page is reloaded', async () => { await browser.refresh(); - const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); + const timePickerValues = await timePicker.getTimeConfigAsAbsoluteTimes(); expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true); expect(timePickerValues.start).to.eql(from); expect(timePickerValues.end).to.eql(to); await retry.waitForWithTimeout('the right hit count', 65000, async () => { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); log.debug(`Found hit count is ${hitCount}. Looking for 2,792.`); return hitCount === '2,792'; }); @@ -253,7 +253,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('allows clearing if non default language was remembered in localstorage', async () => { await savedQueryManagementComponent.openSavedQueryManagementComponent(); await queryBar.switchQueryLanguage('lucene'); - await PageObjects.common.navigateToApp('discover'); // makes sure discovered is reloaded without any state in url + await common.navigateToApp('discover'); // makes sure discovered is reloaded without any state in url await savedQueryManagementComponent.openSavedQueryManagementComponent(); await queryBar.expectQueryLanguageOrFail('lucene'); // make sure lucene is remembered after refresh (comes from localstorage) await savedQueryManagementComponent.loadSavedQuery('OkResponse'); diff --git a/test/functional/apps/discover/ccs_compatibility/_search_errors.ts b/test/functional/apps/discover/ccs_compatibility/_search_errors.ts index 34d5601ae8c11..7045e0e7d1a3b 100644 --- a/test/functional/apps/discover/ccs_compatibility/_search_errors.ts +++ b/test/functional/apps/discover/ccs_compatibility/_search_errors.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const testSubjects = getService('testSubjects'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); + const { common, discover, timePicker } = getPageObjects(['common', 'discover', 'timePicker']); const isCcsTest = config.get('esTestCluster.ccs'); const archiveDirectory = isCcsTest @@ -41,11 +41,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('exception on single shard shows warning and results', async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await dataViews.switchToAndValidate(defaultIndex); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); await retry.try(async () => { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be('14,004'); }); await filterBar.addDslFilter(` @@ -65,7 +65,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Ensure documents are still returned for the successful shards await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be('9,247'); }); @@ -74,11 +74,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('exception on all shards shows error', async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await dataViews.switchToAndValidate(defaultIndex); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); await retry.try(async () => { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be('14,004'); }); await filterBar.addDslFilter(` diff --git a/test/functional/apps/discover/ccs_compatibility/_timeout_results.ts b/test/functional/apps/discover/ccs_compatibility/_timeout_results.ts index 3f55a407a846a..3f0ea5a4ab2e4 100644 --- a/test/functional/apps/discover/ccs_compatibility/_timeout_results.ts +++ b/test/functional/apps/discover/ccs_compatibility/_timeout_results.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const testSubjects = getService('testSubjects'); const toasts = getService('toasts'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); + const { common, discover } = getPageObjects(['common', 'discover']); const dataViews = getService('dataViews'); const esArchiver = getService('esArchiver'); @@ -41,7 +41,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('bfetch enabled', () => { it('timeout on single shard shows warning and results with bfetch enabled', async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await dataViews.createFromSearchBar({ name: 'ftr-remote:logstash-*,logstash-*', hasTimeField: false, @@ -86,7 +86,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Ensure documents are still returned for the successful shards await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be('14,004'); }); }); @@ -102,7 +102,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('timeout on single shard shows warning and results', async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await dataViews.createFromSearchBar({ name: 'ftr-remote:logstash-*,logstash-*', hasTimeField: false, @@ -147,7 +147,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Ensure documents are still returned for the successful shards await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be('14,004'); }); }); diff --git a/test/functional/apps/discover/classic/_classic_table_doc_navigation.ts b/test/functional/apps/discover/classic/_classic_table_doc_navigation.ts index bad480e12b963..c56ecc020f2bf 100644 --- a/test/functional/apps/discover/classic/_classic_table_doc_navigation.ts +++ b/test/functional/apps/discover/classic/_classic_table_doc_navigation.ts @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const docTable = getService('docTable'); const filterBar = getService('filterBar'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'context']); + const { common, discover, timePicker } = getPageObjects(['common', 'discover', 'timePicker']); const esArchiver = getService('esArchiver'); const retry = getService('retry'); const kibanaServer = getService('kibanaServer'); @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: 'logstash-*', 'doc_table:legacy': true, @@ -37,9 +37,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); + await discover.waitForDocTableLoadingComplete(); }); it('should open the doc view of the selected document', async function () { @@ -62,7 +62,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should create an exists filter from the doc view of the selected document', async function () { - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await docTable.toggleRowExpanded(); const detailsRow = await docTable.getDetailsRow(); diff --git a/test/functional/apps/discover/classic/_discover_fields_api.ts b/test/functional/apps/discover/classic/_discover_fields_api.ts index 46dc8e60eb4a7..e0fe867a25c8b 100644 --- a/test/functional/apps/discover/classic/_discover_fields_api.ts +++ b/test/functional/apps/discover/classic/_discover_fields_api.ts @@ -15,10 +15,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, settings, unifiedFieldList } = getPageObjects([ 'common', 'discover', - 'header', 'timePicker', 'settings', 'unifiedFieldList', @@ -35,8 +34,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); after(async () => { @@ -45,55 +44,55 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should correctly display documents', async function () { log.debug('check if Document title exists in the grid'); - expect(await PageObjects.discover.getDocHeader()).to.have.string('Document'); - const rowData = await PageObjects.discover.getDocTableIndex(1); + expect(await discover.getDocHeader()).to.have.string('Document'); + const rowData = await discover.getDocTableIndex(1); log.debug('check the newest doc timestamp in UTC (check diff timezone in last test)'); expect(rowData.startsWith('Sep 22, 2015 @ 23:50:13.253')).to.be.ok(); const expectedHitCount = '14,004'; await retry.try(async function () { - expect(await PageObjects.discover.getHitCount()).to.be(expectedHitCount); + expect(await discover.getHitCount()).to.be(expectedHitCount); }); }); it('adding a column removes a default column', async function () { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('_score'); - expect(await PageObjects.discover.getDocHeader()).to.have.string('_score'); - expect(await PageObjects.discover.getDocHeader()).not.to.have.string('Document'); + await unifiedFieldList.clickFieldListItemAdd('_score'); + expect(await discover.getDocHeader()).to.have.string('_score'); + expect(await discover.getDocHeader()).not.to.have.string('Document'); }); it('removing a column adds a default column', async function () { - await PageObjects.unifiedFieldList.clickFieldListItemRemove('_score'); - expect(await PageObjects.discover.getDocHeader()).not.to.have.string('_score'); - expect(await PageObjects.discover.getDocHeader()).to.have.string('Document'); + await unifiedFieldList.clickFieldListItemRemove('_score'); + expect(await discover.getDocHeader()).not.to.have.string('_score'); + expect(await discover.getDocHeader()).to.have.string('Document'); }); it('displays _source viewer in doc viewer', async function () { - await PageObjects.discover.clickDocTableRowToggle(0); - await PageObjects.discover.isShowingDocViewer(); - await PageObjects.discover.clickDocViewerTab('doc_view_source'); - await PageObjects.discover.expectSourceViewerToExist(); + await discover.clickDocTableRowToggle(0); + await discover.isShowingDocViewer(); + await discover.clickDocViewerTab('doc_view_source'); + await discover.expectSourceViewerToExist(); }); it('switches to _source column when fields API is no longer used', async function () { - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSettings(); - await PageObjects.settings.toggleAdvancedSettingCheckbox('discover:searchFieldsFromSource'); + await settings.navigateTo(); + await settings.clickKibanaSettings(); + await settings.toggleAdvancedSettingCheckbox('discover:searchFieldsFromSource'); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); - expect(await PageObjects.discover.getDocHeader()).to.have.string('_source'); + expect(await discover.getDocHeader()).to.have.string('_source'); }); it('switches to Document column when fields API is used', async function () { - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSettings(); - await PageObjects.settings.toggleAdvancedSettingCheckbox('discover:searchFieldsFromSource'); + await settings.navigateTo(); + await settings.clickKibanaSettings(); + await settings.toggleAdvancedSettingCheckbox('discover:searchFieldsFromSource'); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); - expect(await PageObjects.discover.getDocHeader()).to.have.string('Document'); + expect(await discover.getDocHeader()).to.have.string('Document'); }); }); } diff --git a/test/functional/apps/discover/classic/_doc_table.ts b/test/functional/apps/discover/classic/_doc_table.ts index 4f880a5b86c50..5c765a6b2ef21 100644 --- a/test/functional/apps/discover/classic/_doc_table.ts +++ b/test/functional/apps/discover/classic/_doc_table.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const docTable = getService('docTable'); const queryBar = getService('queryBar'); const find = getService('find'); - const PageObjects = getPageObjects([ + const { common, discover, header, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', @@ -44,9 +44,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); log.debug('discover doc table'); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async function () { @@ -57,29 +57,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show records by default', async function () { // with the default range the number of hits is ~14000 - const rows = await PageObjects.discover.getDocTableRows(); + const rows = await discover.getDocTableRows(); expect(rows.length).to.be.greaterThan(0); }); it('should refresh the table content when changing time window', async function () { - const initialRows = await PageObjects.discover.getDocTableRows(); + const initialRows = await discover.getDocTableRows(); const fromTime = 'Sep 20, 2015 @ 23:00:00.000'; const toTime = 'Sep 20, 2015 @ 23:14:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setAbsoluteRange(fromTime, toTime); + await discover.waitUntilSearchingHasFinished(); - const finalRows = await PageObjects.discover.getDocTableRows(); + const finalRows = await discover.getDocTableRows(); expect(finalRows.length).to.be.below(initialRows.length); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); }); describe('classic table in window 900x700', function () { before(async () => { await browser.setWindowSize(900, 700); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); it('should load more rows when scrolling down the document table', async function () { @@ -97,8 +97,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('classic table in window 600x700', function () { before(async () => { await browser.setWindowSize(600, 700); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); it('should load more rows when scrolling down the document table', async function () { @@ -115,8 +115,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('legacy', function () { before(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); after(async () => { await kibanaServer.uiSettings.replace({}); @@ -124,21 +124,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it(`should load up to ${rowsHardLimit} rows when scrolling at the end of the table`, async function () { const initialRows = await testSubjects.findAll('docTableRow'); // click the Skip to the end of the table - await PageObjects.discover.skipToEndOfDocTable(); + await discover.skipToEndOfDocTable(); // now count the rows const finalRows = await testSubjects.findAll('docTableRow'); expect(finalRows.length).to.be.above(initialRows.length); expect(finalRows.length).to.be(rowsHardLimit); - await PageObjects.discover.backToTop(); + await discover.backToTop(); }); it('should go the end and back to top of the classic table when using the accessible buttons', async function () { // click the Skip to the end of the table - await PageObjects.discover.skipToEndOfDocTable(); + await discover.skipToEndOfDocTable(); // now check the footer text content - const footer = await PageObjects.discover.getDocTableFooter(); + const footer = await discover.getDocTableFooter(); expect(await footer.getVisibleText()).to.have.string(rowsHardLimit); - await PageObjects.discover.backToTop(); + await discover.backToTop(); // check that the skip to end of the table button now has focus const skipButton = await testSubjects.find('discoverSkipTableButton'); const activeElement = await find.activeElement(); @@ -171,7 +171,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show the detail panel actions', async function () { await retry.try(async function () { await docTable.clickRowToggle({ isAnchorRow: false, rowIndex: rowToInspect - 1 }); - // const detailsEl = await PageObjects.discover.getDocTableRowDetails(rowToInspect); + // const detailsEl = await discover.getDocTableRowDetails(rowToInspect); const [surroundingActionEl, singleActionEl] = await docTable.getRowActions({ isAnchorRow: false, rowIndex: rowToInspect - 1, @@ -184,7 +184,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should not close the detail panel actions when data is re-requested', async function () { await retry.try(async function () { - const nrOfFetches = await PageObjects.discover.getNrOfFetches(); + const nrOfFetches = await discover.getNrOfFetches(); await docTable.clickRowToggle({ isAnchorRow: false, rowIndex: rowToInspect - 1 }); const detailsEl = await docTable.getDetailsRows(); const defaultMessageEl = await detailsEl[0].findByTestSubject( @@ -192,7 +192,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); expect(defaultMessageEl).to.be.ok(); await queryBar.submitQuery(); - const nrOfFetchesResubmit = await PageObjects.discover.getNrOfFetches(); + const nrOfFetchesResubmit = await discover.getNrOfFetches(); expect(nrOfFetchesResubmit).to.be.above(nrOfFetches); const defaultMessageElResubmit = await detailsEl[0].findByTestSubject( 'docViewerRowDetailsTitle' @@ -203,7 +203,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show allow toggling columns from the expanded document', async function () { - await PageObjects.discover.clickNewSearchButton(); + await discover.clickNewSearchButton(); await retry.try(async function () { await docTable.clickRowToggle({ isAnchorRow: false, rowIndex: rowToInspect - 1 }); @@ -237,23 +237,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; afterEach(async function () { for (const column of extraColumns) { - await PageObjects.unifiedFieldList.clickFieldListItemRemove(column); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove(column); + await header.waitUntilLoadingHasFinished(); } }); it('should add more columns to the table', async function () { for (const column of extraColumns) { - await PageObjects.unifiedFieldList.clearFieldSearchInput(); - await PageObjects.unifiedFieldList.findFieldByName(column); - await PageObjects.unifiedFieldList.waitUntilFieldlistHasCountOfFields( - expectedFieldLength[column] - ); + await unifiedFieldList.clearFieldSearchInput(); + await unifiedFieldList.findFieldByName(column); + await unifiedFieldList.waitUntilFieldlistHasCountOfFields(expectedFieldLength[column]); await retry.waitFor('field to appear', async function () { return await testSubjects.exists(`field-${column}`); }); - await PageObjects.unifiedFieldList.clickFieldListItemAdd(column); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd(column); + await header.waitUntilLoadingHasFinished(); // test the header now const docHeader = await find.byCssSelector('thead > tr:nth-child(1)'); const docHeaderText = await docHeader.getVisibleText(); @@ -263,17 +261,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should remove columns from the table', async function () { for (const column of extraColumns) { - await PageObjects.unifiedFieldList.clearFieldSearchInput(); - await PageObjects.unifiedFieldList.findFieldByName(column); - await PageObjects.unifiedFieldList.waitUntilFieldlistHasCountOfFields( - expectedFieldLength[column] - ); - await PageObjects.unifiedFieldList.clickFieldListItemAdd(column); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clearFieldSearchInput(); + await unifiedFieldList.findFieldByName(column); + await unifiedFieldList.waitUntilFieldlistHasCountOfFields(expectedFieldLength[column]); + await unifiedFieldList.clickFieldListItemAdd(column); + await header.waitUntilLoadingHasFinished(); } // remove the second column - await PageObjects.unifiedFieldList.clickFieldListItemRemove(extraColumns[1]); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove(extraColumns[1]); + await header.waitUntilLoadingHasFinished(); // test that the second column is no longer there const docHeader = await find.byCssSelector('thead > tr:nth-child(1)'); expect(await docHeader.getVisibleText()).to.not.have.string(extraColumns[1]); @@ -281,9 +277,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should make the document table scrollable', async function () { - await PageObjects.unifiedFieldList.clearFieldSearchInput(); + await unifiedFieldList.clearFieldSearchInput(); const dscTableWrapper = await find.byCssSelector('.kbnDocTableWrapper'); - const fieldNames = await PageObjects.unifiedFieldList.getAllFieldNames(); + const fieldNames = await unifiedFieldList.getAllFieldNames(); const clientHeight = await dscTableWrapper.getAttribute('clientHeight'); let fieldCounter = 0; const checkScrollable = async () => { @@ -293,7 +289,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return Number(scrollWidth) > Number(clientWidth); }; const addColumn = async () => { - await PageObjects.unifiedFieldList.clickFieldListItemAdd(fieldNames[fieldCounter++]); + await unifiedFieldList.clickFieldListItemAdd(fieldNames[fieldCounter++]); }; await addColumn(); diff --git a/test/functional/apps/discover/classic/_doc_table_newline.ts b/test/functional/apps/discover/classic/_doc_table_newline.ts index d18c007b845f3..3c2b426a2dbe4 100644 --- a/test/functional/apps/discover/classic/_doc_table_newline.ts +++ b/test/functional/apps/discover/classic/_doc_table_newline.ts @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'discover', 'unifiedFieldList']); + const { common, unifiedFieldList } = getPageObjects(['common', 'unifiedFieldList']); const find = getService('find'); const log = getService('log'); const retry = getService('retry'); @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { defaultIndex: 'newline-test', 'doc_table:legacy': true, }); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async () => { @@ -40,7 +40,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should break text on newlines', async function () { - await PageObjects.unifiedFieldList.clickFieldListItemToggle('message'); + await unifiedFieldList.clickFieldListItemToggle('message'); const dscTableRows = await find.allByCssSelector('.kbnDocTable__row'); await retry.waitFor('height of multi-line content > single-line content', async () => { @@ -48,7 +48,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const heightWithNewline = await dscTableRows[1].getAttribute('clientHeight'); log.debug(`Without newlines: ${heightWithoutNewline}, With newlines: ${heightWithNewline}`); - await PageObjects.common.sleep(10000); + await common.sleep(10000); return Number(heightWithNewline) > Number(heightWithoutNewline); }); }); diff --git a/test/functional/apps/discover/classic/_esql_grid.ts b/test/functional/apps/discover/classic/_esql_grid.ts index f49c32bada69f..94dcabdba4efc 100644 --- a/test/functional/apps/discover/classic/_esql_grid.ts +++ b/test/functional/apps/discover/classic/_esql_grid.ts @@ -17,13 +17,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dataGrid = getService('dataGrid'); const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardPanelActions = getService('dashboardPanelActions'); - const PageObjects = getPageObjects([ + const { common, discover, dashboard, header, timePicker } = getPageObjects([ 'common', 'discover', 'dashboard', 'header', 'timePicker', - 'unifiedFieldList', ]); const defaultSettings = { @@ -37,8 +36,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); after(async () => { @@ -50,16 +49,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should render esql view correctly', async function () { const savedSearchESQL = 'testESQLWithLegacySetting'; - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('docTableHeader'); await testSubjects.missingOrFail('euiDataGridBody'); - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('docTableHeader'); await testSubjects.existOrFail('euiDataGridBody'); @@ -68,14 +67,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.existOrFail('docViewerFlyout'); - await PageObjects.discover.saveSearch(savedSearchESQL); + await discover.saveSearch(savedSearchESQL); - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('dashboard'); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultAbsoluteRange(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch(savedSearchESQL); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.missingOrFail('docTableHeader'); await testSubjects.existOrFail('euiDataGridBody'); @@ -88,7 +87,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardAddPanel.addSavedSearch('A Saved Search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('docTableHeader'); await testSubjects.missingOrFail('euiDataGridBody'); }); diff --git a/test/functional/apps/discover/classic/_field_data.ts b/test/functional/apps/discover/classic/_field_data.ts index bce589ee7d293..2ebd49bb24ae2 100644 --- a/test/functional/apps/discover/classic/_field_data.ts +++ b/test/functional/apps/discover/classic/_field_data.ts @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'header', 'discover', 'visualize', 'timePicker']); + const { common, timePicker } = getPageObjects(['common', 'timePicker']); const find = getService('find'); const testSubjects = getService('testSubjects'); @@ -30,8 +30,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'discover:searchFieldsFromSource': true, 'doc_table:legacy': true, }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); after(async function () { @@ -52,7 +52,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // we don't technically need this sleep here because the tryForTime will retry and the // results will match on the 2nd or 3rd attempt, but that debug output is huge in this // case and it can be avoided with just a few seconds sleep. - await PageObjects.common.sleep(2000); + await common.sleep(2000); await retry.try(async function tryingForTime() { const row = await find.byCssSelector(`tr.kbnDocTable__row:nth-child(1)`); const rowData = await row.getVisibleText(); diff --git a/test/functional/apps/discover/classic/_field_data_with_fields_api.ts b/test/functional/apps/discover/classic/_field_data_with_fields_api.ts index 4549d57eb3b76..4932ba3e24348 100644 --- a/test/functional/apps/discover/classic/_field_data_with_fields_api.ts +++ b/test/functional/apps/discover/classic/_field_data_with_fields_api.ts @@ -14,7 +14,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'header', 'discover', 'visualize', 'timePicker']); + const { common, timePicker } = getPageObjects(['common', 'timePicker']); const find = getService('find'); const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); @@ -29,8 +29,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'discover:searchFieldsFromSource': false, 'doc_table:legacy': true, }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); after(async function () { @@ -44,7 +44,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // we don't technically need this sleep here because the tryForTime will retry and the // results will match on the 2nd or 3rd attempt, but that debug output is huge in this // case and it can be avoided with just a few seconds sleep. - await PageObjects.common.sleep(2000); + await common.sleep(2000); await retry.try(async function tryingForTime() { const row = await find.byCssSelector(`tr.kbnDocTable__row:nth-child(1)`); const rowData = await row.getVisibleText(); diff --git a/test/functional/apps/discover/classic/_hide_announcements.ts b/test/functional/apps/discover/classic/_hide_announcements.ts index 2c84a45be0205..df7fcbb628136 100644 --- a/test/functional/apps/discover/classic/_hide_announcements.ts +++ b/test/functional/apps/discover/classic/_hide_announcements.ts @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'timePicker']); + const { common, discover, timePicker } = getPageObjects(['common', 'discover', 'timePicker']); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); const browser = getService('browser'); @@ -25,8 +25,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { defaultIndex: 'logstash-*', 'doc_table:legacy': true, }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); after(async () => { @@ -34,7 +34,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should display try document explorer button', async function () { - await PageObjects.discover.selectIndexPattern('logstash-*'); + await discover.selectIndexPattern('logstash-*'); const tourButtonExists = await testSubjects.exists('tryDocumentExplorerButton'); expect(tourButtonExists).to.be(true); }); diff --git a/test/functional/apps/discover/context_awareness/_data_source_profile.ts b/test/functional/apps/discover/context_awareness/_data_source_profile.ts index f7625025b0671..35e3552afa655 100644 --- a/test/functional/apps/discover/context_awareness/_data_source_profile.ts +++ b/test/functional/apps/discover/context_awareness/_data_source_profile.ts @@ -12,7 +12,11 @@ import expect from '@kbn/expect'; import type { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'timePicker', 'discover', 'unifiedFieldList']); + const { common, discover, unifiedFieldList } = getPageObjects([ + 'common', + 'discover', + 'unifiedFieldList', + ]); const testSubjects = getService('testSubjects'); const dataViews = getService('dataViews'); const dataGrid = getService('dataGrid'); @@ -25,12 +29,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from my-example-* | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); expect(timestamps).to.have.length(6); expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); @@ -44,12 +48,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from my-example-logs | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); expect(timestamps).to.have.length(3); expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:00:00.000Z'); @@ -67,10 +71,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from my-example-* | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); await testSubjects.existOrFail('docViewerTab-doc_view_source'); @@ -83,10 +87,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from my-example-logs | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); await testSubjects.existOrFail('docViewerTab-doc_view_source'); @@ -99,13 +103,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('data view mode', () => { describe('cell renderers', () => { it('should render custom @timestamp but not custom log.level', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); expect(timestamps).to.have.length(6); expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); @@ -115,13 +119,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render custom @timestamp and custom log.level', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('log.level'); const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); expect(timestamps).to.have.length(3); expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:00:00.000Z'); @@ -135,11 +139,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('doc viewer extension', () => { it('should not render custom doc viewer view', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); await testSubjects.existOrFail('docViewerTab-doc_view_source'); @@ -148,11 +152,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render custom doc viewer view', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle({ rowIndex: 0 }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); await testSubjects.existOrFail('docViewerTab-doc_view_source'); diff --git a/test/functional/apps/discover/context_awareness/_root_profile.ts b/test/functional/apps/discover/context_awareness/_root_profile.ts index a8338c52a73da..59856d8ba8c1f 100644 --- a/test/functional/apps/discover/context_awareness/_root_profile.ts +++ b/test/functional/apps/discover/context_awareness/_root_profile.ts @@ -12,7 +12,7 @@ import expect from '@kbn/expect'; import type { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'timePicker', 'discover']); + const { common, discover } = getPageObjects(['common', 'discover']); const testSubjects = getService('testSubjects'); const dataViews = getService('dataViews'); @@ -24,10 +24,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from my-example-* | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); expect(timestamps).to.have.length(6); expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); @@ -39,11 +39,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('data view mode', () => { describe('cell renderers', () => { it('should render custom @timestamp', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); const timestamps = await testSubjects.findAll('exampleRootProfileTimestamp'); expect(timestamps).to.have.length(6); expect(await timestamps[0].getVisibleText()).to.be('2024-06-10T16:30:00.000Z'); diff --git a/test/functional/apps/discover/context_awareness/extensions/_get_cell_renderers.ts b/test/functional/apps/discover/context_awareness/extensions/_get_cell_renderers.ts index 9dbdd5fe7355d..b82bc9241b392 100644 --- a/test/functional/apps/discover/context_awareness/extensions/_get_cell_renderers.ts +++ b/test/functional/apps/discover/context_awareness/extensions/_get_cell_renderers.ts @@ -13,7 +13,12 @@ import type { WebElementWrapper } from '@kbn/ftr-common-functional-ui-services'; import type { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'discover', 'unifiedFieldList', 'header']); + const { common, discover, unifiedFieldList, header } = getPageObjects([ + 'common', + 'discover', + 'unifiedFieldList', + 'header', + ]); const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); const dataGrid = getService('dataGrid'); @@ -39,14 +44,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `log.level` is not null', }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); const logLevelBadge = await firstCell.findByTestSubject('*logLevelBadgeCell-'); @@ -63,14 +68,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { esql: 'from my-example* | sort @timestamp desc | where `log.level` is not null', }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.try(async () => { const firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 0); @@ -82,19 +87,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('data view mode', () => { it('should render log.level badge cell', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataViews.switchToAndValidate('my-example-logs,logstash*'); await queryBar.setQuery('log.level:*'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); let firstCell: WebElementWrapper; let logLevelBadge: WebElementWrapper; @@ -112,9 +117,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.clickRowToggle(); const [, surroundingActionEl] = await dataGrid.getRowActions(); await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { firstCell = await dataGrid.getCellElementExcludingControlColumns(0, 1); @@ -127,19 +132,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it("should not render log.level badge cell if it's not a logs data source", async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataViews.switchToAndValidate('my-example-*'); await queryBar.setQuery('log.level:*'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('log.level'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('log.level'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); let firstCell: WebElementWrapper; @@ -153,9 +158,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.clickRowToggle(); const [, surroundingActionEl] = await dataGrid.getRowActions(); await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { firstCell = await dataGrid.getCellElementExcludingControlColumns(1, 1); diff --git a/test/functional/apps/discover/context_awareness/extensions/_get_default_app_state.ts b/test/functional/apps/discover/context_awareness/extensions/_get_default_app_state.ts index d26bd525a4b9f..6ed126bad8c7e 100644 --- a/test/functional/apps/discover/context_awareness/extensions/_get_default_app_state.ts +++ b/test/functional/apps/discover/context_awareness/extensions/_get_default_app_state.ts @@ -12,7 +12,12 @@ import kbnRison from '@kbn/rison'; import type { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'discover', 'unifiedFieldList', 'header']); + const { common, discover, unifiedFieldList, header } = getPageObjects([ + 'common', + 'discover', + 'unifiedFieldList', + 'header', + ]); const dataViews = getService('dataViews'); const dataGrid = getService('dataGrid'); const queryBar = getService('queryBar'); @@ -27,10 +32,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); async function expectColumns(columns: string[]) { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.try(async () => { - const actualColumns = await PageObjects.discover.getColumnHeaders(); + const actualColumns = await discover.getColumnHeaders(); expect(actualColumns).to.eql(columns); }); } @@ -43,7 +48,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { esql: 'from my-example-logs', }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); await expectColumns(['@timestamp', 'log.level', 'message']); @@ -61,7 +66,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { esql: 'from my-example-*', }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); await expectColumns(['@timestamp', 'Document']); @@ -87,13 +92,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { esql: 'from my-example-logs', }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('log.level'); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('message'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove('log.level'); + await unifiedFieldList.clickFieldListItemRemove('message'); await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); await dataGrid.changeRowHeightValue('Single'); @@ -118,7 +123,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { esql: 'from my-example-logs', }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); await expectColumns(['@timestamp', 'log.level', 'message', 'data_stream.type']); @@ -127,11 +132,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('data view mode', () => { it('should render default columns and row height', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataViews.switchToAndValidate('my-example-logs'); await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); @@ -142,11 +147,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render default columns and row height when switching data views', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataViews.switchToAndValidate('my-example-*'); await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); @@ -164,15 +169,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should reset default columns and row height when clicking "New"', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataViews.switchToAndValidate('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('log.level'); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('message'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove('log.level'); + await unifiedFieldList.clickFieldListItemRemove('message'); await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); await dataGrid.changeRowHeightValue('Single'); @@ -191,11 +196,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.update({ defaultColumns: ['bad_column', 'data_stream.type', 'message'], }); - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataViews.switchToAndValidate('my-example-logs'); await expectColumns(['@timestamp', 'log.level', 'message', 'data_stream.type']); }); diff --git a/test/functional/apps/discover/context_awareness/extensions/_get_doc_viewer.ts b/test/functional/apps/discover/context_awareness/extensions/_get_doc_viewer.ts index 411e293eb8c25..2bc410f00ac27 100644 --- a/test/functional/apps/discover/context_awareness/extensions/_get_doc_viewer.ts +++ b/test/functional/apps/discover/context_awareness/extensions/_get_doc_viewer.ts @@ -11,7 +11,7 @@ import kbnRison from '@kbn/rison'; import type { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'discover', 'header']); + const { common, discover, header } = getPageObjects(['common', 'discover', 'header']); const testSubjects = getService('testSubjects'); const dataViews = getService('dataViews'); const dataGrid = getService('dataGrid'); @@ -24,10 +24,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from my-example-logs | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle(); await testSubjects.existOrFail('docViewerTab-doc_view_table'); await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); @@ -40,10 +40,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from my-example-metrics | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle(); await testSubjects.existOrFail('docViewerTab-doc_view_table'); await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); @@ -52,11 +52,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('data view mode', () => { it('should render logs overview tab for logs data source', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle(); await testSubjects.existOrFail('docViewerTab-doc_view_table'); await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); @@ -66,9 +66,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // check Surrounding docs page const [, surroundingActionEl] = await dataGrid.getRowActions(); await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dataGrid.clickRowToggle({ isAnchorRow: true }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); @@ -79,9 +79,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // check Single doc page const [singleDocActionEl] = await dataGrid.getRowActions(); await singleDocActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('docViewerTab-doc_view_table'); await testSubjects.existOrFail('docViewerTab-doc_view_logs_overview'); @@ -90,11 +90,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not render logs overview tab for non-logs data source', async () => { - await PageObjects.common.navigateToActualUrl('discover', undefined, { + await common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-metrics'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle(); await testSubjects.existOrFail('docViewerTab-doc_view_table'); await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); @@ -102,9 +102,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // check Surrounding docs page const [, surroundingActionEl] = await dataGrid.getRowActions(); await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dataGrid.clickRowToggle({ isAnchorRow: true }); await testSubjects.existOrFail('docViewerTab-doc_view_table'); @@ -113,9 +113,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // check Single doc page const [singleDocActionEl] = await dataGrid.getRowActions(); await singleDocActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('docViewerTab-doc_view_table'); await testSubjects.missingOrFail('docViewerTab-doc_view_logs_overview'); diff --git a/test/functional/apps/discover/context_awareness/extensions/_get_row_additional_leading_controls.ts b/test/functional/apps/discover/context_awareness/extensions/_get_row_additional_leading_controls.ts index e9ff182beed57..b56a67fef2c9d 100644 --- a/test/functional/apps/discover/context_awareness/extensions/_get_row_additional_leading_controls.ts +++ b/test/functional/apps/discover/context_awareness/extensions/_get_row_additional_leading_controls.ts @@ -11,7 +11,7 @@ import kbnRison from '@kbn/rison'; import type { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'discover', 'header']); + const { common, discover, header } = getPageObjects(['common', 'discover', 'header']); const testSubjects = getService('testSubjects'); const dataViews = getService('dataViews'); const dataGrid = getService('dataGrid'); @@ -24,10 +24,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from my-example-logs | sort @timestamp desc' }, }); - await PageObjects.common.navigateToApp('discover', { + await common.navigateToApp('discover', { hash: `/?_a=${state}`, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('exampleLogsControl_visBarVerticalStacked'); await testSubjects.existOrFail('unifiedDataTable_additionalRowControl_menuControl'); }); @@ -37,10 +37,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from my-example-metrics | sort @timestamp desc' }, }); - await PageObjects.common.navigateToApp('discover', { + await common.navigateToApp('discover', { hash: `/?_a=${state}`, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('exampleLogsControl_visBarVerticalStacked'); await testSubjects.missingOrFail('unifiedDataTable_additionalRowControl_menuControl'); }); @@ -48,9 +48,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('data view mode', () => { it('should render logs controls for logs data source', async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('exampleLogsControl_visBarVerticalStacked'); await testSubjects.existOrFail('unifiedDataTable_additionalRowControl_menuControl'); @@ -58,18 +58,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.clickRowToggle(); const [, surroundingActionEl] = await dataGrid.getRowActions(); await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('exampleLogsControl_visBarVerticalStacked'); await testSubjects.existOrFail('unifiedDataTable_additionalRowControl_menuControl'); }); it('should not render logs controls for non-logs data source', async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await dataViews.switchTo('my-example-metrics'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('exampleLogsControl_visBarVerticalStacked'); await testSubjects.missingOrFail('unifiedDataTable_additionalRowControl_menuControl'); @@ -77,9 +77,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.clickRowToggle(); const [, surroundingActionEl] = await dataGrid.getRowActions(); await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.missingOrFail('exampleLogsControl_visBarVerticalStacked'); await testSubjects.missingOrFail('unifiedDataTable_additionalRowControl_menuControl'); diff --git a/test/functional/apps/discover/context_awareness/extensions/_get_row_indicator_provider.ts b/test/functional/apps/discover/context_awareness/extensions/_get_row_indicator_provider.ts index 22c05022ea8f6..563d7bc33d1ce 100644 --- a/test/functional/apps/discover/context_awareness/extensions/_get_row_indicator_provider.ts +++ b/test/functional/apps/discover/context_awareness/extensions/_get_row_indicator_provider.ts @@ -12,11 +12,10 @@ import expect from '@kbn/expect'; import type { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { common, timePicker, discover, header } = getPageObjects([ 'common', 'timePicker', 'discover', - 'unifiedFieldList', 'header', ]); const esArchiver = getService('esArchiver'); @@ -39,19 +38,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from logstash* | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRange(); + await discover.waitUntilSearchingHasFinished(); // logstash does not have log.level field, so the color indicator should not be rendered await testSubjects.existOrFail('euiDataGridBody'); await testSubjects.missingOrFail('dataGridHeaderCell-colorIndicator'); // switch the time frame back await browser.goBack(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); it('should not render log.level row indicators if not a logs data source', async () => { @@ -59,10 +58,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from my-example* | sort @timestamp desc' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // my-example* has a log.level field, but it's not matching the logs profile, so the color indicator should not be rendered await testSubjects.existOrFail('euiDataGridBody'); await testSubjects.missingOrFail('dataGridHeaderCell-colorIndicator'); @@ -75,10 +74,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { esql: 'from my-example-logs,logstash* | sort @timestamp desc | where `log.level` is not null', }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // in this case it's matching the logs data source profile and has a log.level field, so the color indicator should be rendered await testSubjects.existOrFail('dataGridHeaderCell-colorIndicator'); const firstCell = await dataGrid.getCellElement(0, 0); @@ -101,13 +100,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render log.level row indicators on Surrounding documents page', async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await dataViews.switchTo('my-example-logs,logstash*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle({ rowIndex: 0 }); const [, surroundingActionEl] = await dataGrid.getRowActions(); await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); let anchorCell = await dataGrid.getCellElement(0, 0); let anchorColorIndicator = await anchorCell.findByTestSubject( @@ -128,7 +127,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); anchorCell = await dataGrid.getCellElement(0, 0); anchorColorIndicator = await anchorCell.findByTestSubject( diff --git a/test/functional/apps/discover/context_awareness/index.ts b/test/functional/apps/discover/context_awareness/index.ts index 59dad4caa32f1..d3da15973b49b 100644 --- a/test/functional/apps/discover/context_awareness/index.ts +++ b/test/functional/apps/discover/context_awareness/index.ts @@ -12,7 +12,8 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects, loadTestFile }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['timePicker']); + const { timePicker } = getPageObjects(['timePicker']); + const from = '2024-06-10T14:00:00.000Z'; const to = '2024-06-10T16:30:00.000Z'; @@ -32,7 +33,7 @@ export default function ({ getService, getPageObjects, loadTestFile }: FtrProvid await kibanaServer.importExport.unload( 'test/functional/fixtures/kbn_archiver/discover/context_awareness' ); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); }); loadTestFile(require.resolve('./_root_profile')); diff --git a/test/functional/apps/discover/embeddable/_saved_search_embeddable.ts b/test/functional/apps/discover/embeddable/_saved_search_embeddable.ts index 096d6fc3f2f6d..c6f5fd9724629 100644 --- a/test/functional/apps/discover/embeddable/_saved_search_embeddable.ts +++ b/test/functional/apps/discover/embeddable/_saved_search_embeddable.ts @@ -19,7 +19,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker', 'discover']); + const { common, dashboard, header, discover } = getPageObjects([ + 'common', + 'dashboard', + 'header', + 'discover', + ]); describe('discover saved search embeddable', () => { before(async () => { @@ -32,7 +37,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.common.setTime({ + await common.setTime({ from: 'Sep 22, 2015 @ 00:00:00.000', to: 'Sep 23, 2015 @ 00:00:00.000', }); @@ -40,28 +45,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); beforeEach(async () => { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await filterBar.ensureFieldEditorModalIsClosed(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); }); const addSearchEmbeddableToDashboard = async () => { await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); const rows = await dataGrid.getDocTableRows(); expect(rows.length).to.be.above(0); }; const refreshDashboardPage = async () => { await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); }; it('can save a search embeddable with a defined rows per page number', async function () { @@ -69,7 +74,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await addSearchEmbeddableToDashboard(); await dataGrid.checkCurrentRowsPerPageToBe(100); - await PageObjects.dashboard.saveDashboard(dashboardName, { + await dashboard.saveDashboard(dashboardName, { saveAsNew: true, waitDialogIsClosed: true, exitFromEditMode: false, @@ -81,7 +86,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.changeRowsPerPageTo(10); - await PageObjects.dashboard.saveDashboard(dashboardName, { saveAsNew: false }); + await dashboard.saveDashboard(dashboardName, { saveAsNew: false }); await refreshDashboardPage(); await dataGrid.checkCurrentRowsPerPageToBe(10); @@ -89,7 +94,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should control columns correctly', async () => { await addSearchEmbeddableToDashboard(); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); expect(await cell.getVisibleText()).to.be('Sep 22, 2015 @ 23:50:13.253'); @@ -118,11 +123,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await addSearchEmbeddableToDashboard(); await queryBar.setQuery('bytes > 5000'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect(await PageObjects.discover.getSavedSearchDocumentCount()).to.be('2,572 documents'); + await header.waitUntilLoadingHasFinished(); + expect(await discover.getSavedSearchDocumentCount()).to.be('2,572 documents'); await queryBar.setQuery('this < is not : a valid > query'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const embeddableError = await testSubjects.find('embeddableError'); const errorMessage = await embeddableError.findByTestSubject('errorMessageMarkdown'); const errorText = await errorMessage.getVisibleText(); diff --git a/test/functional/apps/discover/esql/_esql_columns.ts b/test/functional/apps/discover/esql/_esql_columns.ts index a3d115d1117f6..2eba53aaab806 100644 --- a/test/functional/apps/discover/esql/_esql_columns.ts +++ b/test/functional/apps/discover/esql/_esql_columns.ts @@ -24,10 +24,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const browser = getService('browser'); const monacoEditor = getService('monacoEditor'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { common, discover, header, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', - 'dashboard', 'header', 'timePicker', 'unifiedFieldList', @@ -44,17 +43,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); + await discover.waitUntilSearchingHasFinished(); + await discover.selectTextBaseLang(); + await discover.waitUntilSearchingHasFinished(); }); beforeEach(async () => { - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.clickNewSearchButton(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); it('should render initial columns for non-transformational commands correctly', async () => { @@ -62,32 +61,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await dataGrid.getHeaderFields()).to.eql(columns); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); - await PageObjects.discover.saveSearch(SAVED_SEARCH_NON_TRANSFORMATIONAL_INITIAL_COLUMNS); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch(SAVED_SEARCH_NON_TRANSFORMATIONAL_INITIAL_COLUMNS); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); }); it('should render custom columns for non-transformational commands correctly', async () => { const columns = ['bytes', 'extension']; - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); - await PageObjects.discover.saveSearch(SAVED_SEARCH_NON_TRANSFORMATIONAL_CUSTOM_COLUMNS); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch(SAVED_SEARCH_NON_TRANSFORMATIONAL_CUSTOM_COLUMNS); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); }); @@ -97,31 +96,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await monacoEditor.setCodeEditorValue('from logstash-* | limit 500'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); await monacoEditor.setCodeEditorValue('from logs* | limit 500'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['bytes']); // different index pattern => reset columns await monacoEditor.setCodeEditorValue('from logstash-* | limit 500'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['extension']); // same index pattern => don't reset columns @@ -129,8 +128,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { `${await monacoEditor.getCodeEditorValue()} | where bytes > 0` ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['extension']); }); @@ -140,18 +139,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { `${await monacoEditor.getCodeEditorValue()} | keep ip, @timestamp` ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); - await PageObjects.discover.saveSearch(SAVED_SEARCH_TRANSFORMATIONAL_INITIAL_COLUMNS); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch(SAVED_SEARCH_TRANSFORMATIONAL_INITIAL_COLUMNS); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); }); @@ -161,38 +160,38 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { `${await monacoEditor.getCodeEditorValue()} | keep ip, @timestamp, bytes` ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['ip', '@timestamp', 'bytes']); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('@timestamp'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove('@timestamp'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); - await PageObjects.discover.saveSearch(SAVED_SEARCH_TRANSFORMATIONAL_CUSTOM_COLUMNS); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch(SAVED_SEARCH_TRANSFORMATIONAL_CUSTOM_COLUMNS); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(columns); }); it('should reset columns if available fields or index pattern are different in transformational query', async () => { await monacoEditor.setCodeEditorValue('from logstash-* | keep ip, @timestamp'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['ip', '@timestamp']); // reset columns if available fields are different await monacoEditor.setCodeEditorValue('from logstash-* | keep ip, @timestamp, bytes'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['ip', '@timestamp', 'bytes']); // don't reset columns if available fields and index pattern are the same @@ -200,46 +199,46 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'from logstash-* | keep ip, @timestamp, bytes | limit 1' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['ip', '@timestamp', 'bytes']); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('@timestamp'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove('@timestamp'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['ip', 'bytes']); // reset columns if index pattern is different await monacoEditor.setCodeEditorValue('from logs* | keep ip, @timestamp, bytes | limit 1'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['ip', '@timestamp', 'bytes']); }); it('should restore columns correctly when switching between saved searches', async () => { - await PageObjects.discover.loadSavedSearch(SAVED_SEARCH_NON_TRANSFORMATIONAL_INITIAL_COLUMNS); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(SAVED_SEARCH_NON_TRANSFORMATIONAL_INITIAL_COLUMNS); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'Document']); - await PageObjects.discover.loadSavedSearch(SAVED_SEARCH_NON_TRANSFORMATIONAL_CUSTOM_COLUMNS); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(SAVED_SEARCH_NON_TRANSFORMATIONAL_CUSTOM_COLUMNS); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['bytes', 'extension']); - await PageObjects.discover.loadSavedSearch(SAVED_SEARCH_TRANSFORMATIONAL_INITIAL_COLUMNS); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(SAVED_SEARCH_TRANSFORMATIONAL_INITIAL_COLUMNS); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['ip', '@timestamp']); - await PageObjects.discover.loadSavedSearch(SAVED_SEARCH_TRANSFORMATIONAL_CUSTOM_COLUMNS); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(SAVED_SEARCH_TRANSFORMATIONAL_CUSTOM_COLUMNS); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['ip', 'bytes']); - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.clickNewSearchButton(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'Document']); }); }); diff --git a/test/functional/apps/discover/esql/_esql_view.ts b/test/functional/apps/discover/esql/_esql_view.ts index d382722748a84..f8871ded33fcf 100644 --- a/test/functional/apps/discover/esql/_esql_view.ts +++ b/test/functional/apps/discover/esql/_esql_view.ts @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const find = getService('find'); const esql = getService('esql'); const dashboardAddPanel = getService('dashboardAddPanel'); - const PageObjects = getPageObjects([ + const { common, discover, dashboard, header, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'dashboard', @@ -52,17 +52,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'test/functional/fixtures/kbn_archiver/kibana_sample_data_flights_index_pattern' ); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); after(async () => { - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); }); describe('ES|QL in Discover', () => { it('should render esql view correctly', async function () { - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); expect(await testSubjects.exists('showQueryBarMenu')).to.be(true); expect(await testSubjects.exists('superDatePickerToggleQuickMenuButton')).to.be(true); @@ -79,8 +79,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('field-@message-showDetails'); expect(await testSubjects.exists('discoverFieldListPanelEdit-@message')).to.be(true); - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.selectTextBaseLang(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); expect(await testSubjects.exists('fieldListFiltersFieldSearch')).to.be(true); expect(await testSubjects.exists('TextBasedLangEditor')).to.be(true); @@ -103,15 +103,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not render the histogram for indices with no @timestamp field', async function () { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.selectTextBaseLang(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); const testQuery = `from kibana_sample_data_flights | limit 10`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await testSubjects.exists('TextBasedLangEditor')).to.be(true); // I am not rendering the histogram for indices with no @timestamp field @@ -119,33 +119,33 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render the histogram for indices with no @timestamp field when the ?t_start, ?t_end params are in the query', async function () { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.selectTextBaseLang(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); const testQuery = `from kibana_sample_data_flights | limit 10 | where timestamp >= ?t_start and timestamp <= ?t_end`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); const fromTime = 'Apr 10, 2018 @ 00:00:00.000'; const toTime = 'Nov 15, 2018 @ 00:00:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await timePicker.setAbsoluteRange(fromTime, toTime); expect(await testSubjects.exists('TextBasedLangEditor')).to.be(true); expect(await testSubjects.exists('unifiedHistogramChart')).to.be(true); }); it('should perform test query correctly', async function () { - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.selectTextBaseLang(); + await timePicker.setDefaultAbsoluteRange(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | limit 10 | stats countB = count(bytes) by geo.dest | sort countB`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // here Lens suggests a XY so it is rendered expect(await testSubjects.exists('unifiedHistogramChart')).to.be(true); expect(await testSubjects.exists('xyVisChart')).to.be(true); @@ -154,48 +154,48 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render when switching to a time range with no data, then back to a time range with data', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | limit 10 | stats countB = count(bytes) by geo.dest | sort countB`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); let cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); expect(await cell.getVisibleText()).to.be('1'); - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 19, 2015 @ 06:31:44.000', 'Sep 19, 2015 @ 06:31:44.000' ); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await testSubjects.exists('discoverNoResults')).to.be(true); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRange(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); expect(await cell.getVisibleText()).to.be('1'); }); it('should query an index pattern that doesnt translate to a dataview correctly', async function () { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash* | limit 10 | stats countB = count(bytes) by geo.dest | sort countB`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); expect(await cell.getVisibleText()).to.be('1'); }); it('should render correctly if there are empty fields', async function () { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | limit 10 | keep machine.ram_range, bytes`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); const cell = await dataGrid.getCellElementExcludingControlColumns(0, 1); expect(await cell.getVisibleText()).to.be(' - '); expect(await dataGrid.getHeaders()).to.eql([ @@ -207,14 +207,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should work without a FROM statement', async function () { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `ROW a = 1, b = "two", c = null`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.discover.dragFieldToTable('a'); + await discover.dragFieldToTable('a'); const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); expect(await cell.getVisibleText()).to.be('1'); }); @@ -222,7 +222,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('errors', () => { it('should show error messages for syntax errors in query', async function () { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const brokenQueries = [ 'from logstash-* | limit 10*', 'from logstash-* | limit A', @@ -232,10 +232,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { for (const testQuery of brokenQueries) { await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // error in fetching documents because of the invalid query - await PageObjects.discover.showsErrorCallout(); + await discover.showsErrorCallout(); const message = await testSubjects.getVisibleText('discoverErrorCalloutMessage'); expect(message).to.contain( "[esql] > Couldn't parse Elasticsearch ES|QL query. Check your query and try again." @@ -250,14 +250,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('switch modal', () => { beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); it('should show switch modal when switching to a data view', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.click('switch-to-dataviews'); await retry.try(async () => { await testSubjects.existOrFail('discover-esql-to-dataview-modal'); @@ -265,12 +265,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not show switch modal when switching to a data view while a saved search is open', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = 'from logstash-* | limit 100 | drop @timestamp'; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.click('switch-to-dataviews'); await retry.try(async () => { await testSubjects.existOrFail('discover-esql-to-dataview-modal'); @@ -281,21 +281,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.try(async () => { await testSubjects.missingOrFail('discover-esql-to-dataview-modal'); }); - await PageObjects.discover.saveSearch('esql_test'); + await discover.saveSearch('esql_test'); await testSubjects.click('switch-to-dataviews'); await testSubjects.missingOrFail('discover-esql-to-dataview-modal'); }); it('should show switch modal when switching to a data view while a saved search with unsaved changes is open', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.saveSearch('esql_test2'); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await discover.saveSearch('esql_test2'); const testQuery = 'from logstash-* | limit 100 | drop @timestamp'; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.click('switch-to-dataviews'); await retry.try(async () => { await testSubjects.existOrFail('discover-esql-to-dataview-modal'); @@ -305,23 +305,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('inspector', () => { beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); it('shows Discover and Lens requests in Inspector', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); let retries = 0; await retry.try(async () => { if (retries > 0) { await inspector.close(); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); } await inspector.open(); retries = retries + 1; @@ -337,10 +337,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dataSource: { type: 'esql' }, query: { esql: 'from kibana_sample_data_flights' }, }); - await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { + await common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | limit 10`; await monacoEditor.setCodeEditorValue(testQuery); @@ -348,7 +348,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { window.ELASTIC_ESQL_DELAY_SECONDS = 5; }); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.execute(() => { window.ELASTIC_ESQL_DELAY_SECONDS = undefined; }); @@ -366,15 +366,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('query history', () => { beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); it('should see my current query in the history', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); await testSubjects.click('TextBasedLangEditor-toggle-query-history-button'); const historyItems = await esql.getHistoryItems(); @@ -387,16 +387,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('updating the query should add this to the history', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); const testQuery = 'from logstash-* | limit 100 | drop @timestamp'; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.click('TextBasedLangEditor-toggle-query-history-button'); const historyItems = await esql.getHistoryItems(); @@ -409,10 +409,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should select a query from the history and submit it', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); await testSubjects.click('TextBasedLangEditor-toggle-query-history-button'); // click a history item @@ -428,16 +428,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should add a failed query to the history', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); const testQuery = 'from logstash-* | limit 100 | woof and meow'; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.click('TextBasedLangEditor-toggle-query-history-button'); const historyItem = await esql.getHistoryItem(0); @@ -449,21 +449,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should sort correctly', async () => { const savedSearchName = 'testSorting'; - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); const testQuery = 'from logstash-* | sort @timestamp | limit 100'; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor('first cell contains an initial value', async () => { const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); @@ -477,7 +477,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.clickDocSortDesc('bytes', 'Sort High-Low'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor('first cell contains the highest value', async () => { const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); @@ -489,10 +489,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'Sort fields\n1' ); - await PageObjects.discover.saveSearch(savedSearchName); + await discover.saveSearch(savedSearchName); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor('first cell contains the same highest value', async () => { const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); @@ -502,8 +502,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor('first cell contains the same highest value after reload', async () => { const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); @@ -511,15 +511,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return text === '17,966'; }); - await PageObjects.discover.clickNewSearchButton(); + await discover.clickNewSearchButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.loadSavedSearch(savedSearchName); + await discover.loadSavedSearch(savedSearchName); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor( 'first cell contains the same highest value after reopening', @@ -532,7 +532,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.clickDocSortDesc('bytes', 'Sort Low-High'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor('first cell contains the lowest value', async () => { const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); @@ -544,10 +544,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'Sort fields\n1' ); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); + await unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickDocSortDesc('extension', 'Sort A-Z'); @@ -563,8 +563,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor('first cell contains the same lowest value after reload', async () => { const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); @@ -581,14 +581,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } ); - await PageObjects.discover.saveSearch(savedSearchName); + await discover.saveSearch(savedSearchName); - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('dashboard'); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultAbsoluteRange(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch(savedSearchName); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.waitFor( 'first cell contains the same lowest value as dashboard panel', @@ -616,24 +616,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('filtering by clicking on the table', () => { beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); it('should append a where clause by clicking the table', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | sort @timestamp desc | limit 10000 | stats countB = count(bytes) by geo.dest | sort countB`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); await dataGrid.clickCellFilterForButtonExcludingControlColumns(0, 1); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); const editorValue = await monacoEditor.getCodeEditorValue(); expect(editorValue).to.eql( @@ -642,9 +642,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // negate await dataGrid.clickCellFilterOutButtonExcludingControlColumns(0, 1); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); const newValue = await monacoEditor.getCodeEditorValue(); expect(newValue).to.eql( @@ -653,19 +653,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should append an end in existing where clause by clicking the table', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | sort @timestamp desc | limit 10000 | stats countB = count(bytes) by geo.dest | sort countB | where countB > 0`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); await dataGrid.clickCellFilterForButtonExcludingControlColumns(0, 1); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); const editorValue = await monacoEditor.getCodeEditorValue(); expect(editorValue).to.eql( diff --git a/test/functional/apps/discover/group1/_date_nanos.ts b/test/functional/apps/discover/group1/_date_nanos.ts index fa14a78c80ddf..f8450b10141a4 100644 --- a/test/functional/apps/discover/group1/_date_nanos.ts +++ b/test/functional/apps/discover/group1/_date_nanos.ts @@ -13,7 +13,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common', 'timePicker', 'discover']); + const { common, timePicker, discover } = getPageObjects(['common', 'timePicker', 'discover']); const kibanaServer = getService('kibanaServer'); const security = getService('security'); const fromTime = 'Sep 22, 2019 @ 20:31:44.000'; @@ -26,8 +26,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/date_nanos'); await kibanaServer.uiSettings.replace({ defaultIndex: 'date-nanos' }); await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos']); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await common.navigateToApp('discover'); + await timePicker.setAbsoluteRange(fromTime, toTime); }); after(async function unloadMakelogs() { @@ -37,10 +37,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show a timestamp with nanoseconds in the first result row', async function () { - const time = await PageObjects.timePicker.getTimeConfig(); + const time = await timePicker.getTimeConfig(); expect(time.start).to.be(fromTime); expect(time.end).to.be(toTime); - const rowData = await PageObjects.discover.getDocTableIndex(1); + const rowData = await discover.getDocTableIndex(1); expect(rowData.startsWith('Sep 22, 2019 @ 23:50:13.253123345')).to.be.ok(); }); }); diff --git a/test/functional/apps/discover/group1/_date_nanos_mixed.ts b/test/functional/apps/discover/group1/_date_nanos_mixed.ts index 05f6928ea0d4d..7162d01bb96cc 100644 --- a/test/functional/apps/discover/group1/_date_nanos_mixed.ts +++ b/test/functional/apps/discover/group1/_date_nanos_mixed.ts @@ -13,7 +13,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common', 'timePicker', 'discover']); + const { common, discover } = getPageObjects(['common', 'discover']); const kibanaServer = getService('kibanaServer'); const security = getService('security'); const browser = getService('browser'); @@ -33,26 +33,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await browser.setWindowSize(1200, 900); await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos_mixed']); - await PageObjects.common.setTime({ from, to }); - await PageObjects.common.navigateToApp('discover'); + await common.setTime({ from, to }); + await common.navigateToApp('discover'); }); after(async () => { await security.testUser.restoreDefaults(); await esArchiver.unload('test/functional/fixtures/es_archiver/date_nanos_mixed'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('shows a list of records of indices with date & date_nanos fields in the right order', async function () { - const isLegacy = await PageObjects.discover.useLegacyTable(); - const rowData1 = await PageObjects.discover.getDocTableIndex(1); + const isLegacy = await discover.useLegacyTable(); + const rowData1 = await discover.getDocTableIndex(1); expect(rowData1).to.contain('Jan 1, 2019 @ 12:10:30.124000000'); - const rowData2 = await PageObjects.discover.getDocTableIndex(isLegacy ? 3 : 2); + const rowData2 = await discover.getDocTableIndex(isLegacy ? 3 : 2); expect(rowData2).to.contain('Jan 1, 2019 @ 12:10:30.123498765'); - const rowData3 = await PageObjects.discover.getDocTableIndex(isLegacy ? 5 : 3); + const rowData3 = await discover.getDocTableIndex(isLegacy ? 5 : 3); expect(rowData3).to.contain('Jan 1, 2019 @ 12:10:30.123456789'); - const rowData4 = await PageObjects.discover.getDocTableIndex(isLegacy ? 7 : 4); + const rowData4 = await discover.getDocTableIndex(isLegacy ? 7 : 4); expect(rowData4).to.contain('Jan 1, 2019 @ 12:10:30.123000000'); }); }); diff --git a/test/functional/apps/discover/group1/_discover.ts b/test/functional/apps/discover/group1/_discover.ts index e0936a122034b..1326758fe0912 100644 --- a/test/functional/apps/discover/group1/_discover.ts +++ b/test/functional/apps/discover/group1/_discover.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const queryBar = getService('queryBar'); const inspector = getService('inspector'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { common, discover, header, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', @@ -39,8 +39,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); after(async () => { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); @@ -49,63 +49,63 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const queryName1 = 'Query # 1'; it('should show correct time range string by timepicker', async function () { - const time = await PageObjects.timePicker.getTimeConfig(); - expect(time.start).to.be(PageObjects.timePicker.defaultStartTime); - expect(time.end).to.be(PageObjects.timePicker.defaultEndTime); - const rowData = await PageObjects.discover.getDocTableIndex(1); + const time = await timePicker.getTimeConfig(); + expect(time.start).to.be(timePicker.defaultStartTime); + expect(time.end).to.be(timePicker.defaultEndTime); + const rowData = await discover.getDocTableIndex(1); log.debug('check the newest doc timestamp in UTC (check diff timezone in last test)'); expect(rowData).to.contain('Sep 22, 2015 @ 23:50:13.253'); }); it('save query should show toast message and display query name', async function () { - await PageObjects.discover.saveSearch(queryName1); - const actualQueryNameString = await PageObjects.discover.getCurrentQueryName(); + await discover.saveSearch(queryName1); + const actualQueryNameString = await discover.getCurrentQueryName(); expect(actualQueryNameString).to.be(queryName1); }); it('load query should show query name', async function () { - await PageObjects.discover.loadSavedSearch(queryName1); + await discover.loadSavedSearch(queryName1); await retry.try(async function () { - expect(await PageObjects.discover.getCurrentQueryName()).to.be(queryName1); + expect(await discover.getCurrentQueryName()).to.be(queryName1); }); }); it('renaming a saved query should modify name in breadcrumb', async function () { const queryName2 = 'Modified Query # 1'; - await PageObjects.discover.loadSavedSearch(queryName1); - await PageObjects.discover.saveSearch(queryName2); + await discover.loadSavedSearch(queryName1); + await discover.saveSearch(queryName2); await retry.try(async function () { - expect(await PageObjects.discover.getCurrentQueryName()).to.be(queryName2); + expect(await discover.getCurrentQueryName()).to.be(queryName2); }); }); it('should show the correct hit count', async function () { const expectedHitCount = '14,004'; await retry.try(async function () { - expect(await PageObjects.discover.getHitCount()).to.be(expectedHitCount); + expect(await discover.getHitCount()).to.be(expectedHitCount); }); }); it('should show correct time range string in chart', async function () { - const actualTimeString = await PageObjects.discover.getChartTimespan(); - const expectedTimeString = `${PageObjects.timePicker.defaultStartTime} - ${PageObjects.timePicker.defaultEndTime} (interval: Auto - 3 hours)`; + const actualTimeString = await discover.getChartTimespan(); + const expectedTimeString = `${timePicker.defaultStartTime} - ${timePicker.defaultEndTime} (interval: Auto - 3 hours)`; expect(actualTimeString).to.be(expectedTimeString); }); it('should modify the time range when a bar is clicked', async function () { - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.clickHistogramBar(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const time = await PageObjects.timePicker.getTimeConfig(); + await timePicker.setDefaultAbsoluteRange(); + await discover.clickHistogramBar(); + await discover.waitUntilSearchingHasFinished(); + const time = await timePicker.getTimeConfig(); expect(time.start).to.be('Sep 21, 2015 @ 12:00:00.000'); expect(time.end).to.be('Sep 21, 2015 @ 15:00:00.000'); await retry.waitForWithTimeout( 'table to contain the right search result', 3000, async () => { - const rowData = await PageObjects.discover.getDocTableField(1); + const rowData = await discover.getDocTableField(1); log.debug(`The first timestamp value in doc table: ${rowData}`); return rowData.includes('Sep 21, 2015 @ 14:59:08.840'); } @@ -113,37 +113,37 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show correct initial chart interval of Auto', async function () { - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRange(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.click('discoverQueryHits'); // to cancel out tooltips - const actualInterval = await PageObjects.discover.getChartInterval(); + const actualInterval = await discover.getChartInterval(); const expectedInterval = 'auto'; expect(actualInterval).to.be(expectedInterval); }); it('should not show "no results"', async () => { - const isVisible = await PageObjects.discover.hasNoResults(); + const isVisible = await discover.hasNoResults(); expect(isVisible).to.be(false); }); it('should reload the saved search with persisted query to show the initial hit count', async function () { - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRange(); + await discover.waitUntilSearchingHasFinished(); // apply query some changes await queryBar.setQuery('test'); await queryBar.submitQuery(); await retry.try(async function () { - expect(await PageObjects.discover.getHitCount()).to.be('22'); + expect(await discover.getHitCount()).to.be('22'); }); // reset to persisted state await queryBar.clearQuery(); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); const expectedHitCount = '14,004'; await retry.try(async function () { expect(await queryBar.getQueryString()).to.be(''); - expect(await PageObjects.discover.getHitCount()).to.be(expectedHitCount); + expect(await discover.getHitCount()).to.be(expectedHitCount); }); }); }); @@ -154,27 +154,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { log.debug('setAbsoluteRangeForAnotherQuery'); - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setAbsoluteRange(fromTime, toTime); + await discover.waitUntilSearchingHasFinished(); }); it('should show "no results"', async () => { await retry.waitFor('no results screen is displayed', async function () { - const isVisible = await PageObjects.discover.hasNoResults(); + const isVisible = await discover.hasNoResults(); return isVisible === true; }); }); it('should suggest a new time range is picked', async () => { - const isVisible = await PageObjects.discover.hasNoResultsTimepicker(); + const isVisible = await discover.hasNoResultsTimepicker(); expect(isVisible).to.be(true); }); it('should show matches when time range is expanded', async () => { - await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage(); + await discover.expandTimeRangeAsSuggestedInNoResultsMessage(); await retry.try(async function () { - expect(await PageObjects.discover.hasNoResults()).to.be(false); - expect(await PageObjects.discover.getHitCountInt()).to.be.above(0); + expect(await discover.hasNoResults()).to.be(false); + expect(await discover.getHitCountInt()).to.be.above(0); }); }); }); @@ -182,15 +182,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('nested query', () => { before(async () => { log.debug('setAbsoluteRangeForAnotherQuery'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRange(); + await discover.waitUntilSearchingHasFinished(); }); it('should support querying on nested fields', async function () { await queryBar.setQuery('nestedField:{ child: nestedValue }'); await queryBar.submitQuery(); await retry.try(async function () { - expect(await PageObjects.discover.getHitCount()).to.be('1'); + expect(await discover.getHitCount()).to.be('1'); }); }); }); @@ -203,9 +203,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; await retry.try(async () => { - await PageObjects.discover.loadSavedSearch(expected.title); - const { title, description } = - await PageObjects.common.getSharedItemTitleAndDescription(); + await discover.loadSavedSearch(expected.title); + const { title, description } = await common.getSharedItemTitleAndDescription(); expect(title).to.eql(expected.title); expect(description).to.eql(expected.description); }); @@ -215,32 +214,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('time zone switch', () => { it('should show bars in the correct time zone after switching', async function () { await kibanaServer.uiSettings.update({ 'dateFormat:tz': 'America/Phoenix' }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.awaitKibanaChrome(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await header.awaitKibanaChrome(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRange(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await queryBar.clearQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); log.debug( 'check that the newest doc timestamp is now -7 hours from the UTC time in the first test' ); - const rowData = await PageObjects.discover.getDocTableIndex(1); + const rowData = await discover.getDocTableIndex(1); expect(rowData.startsWith('Sep 22, 2015 @ 16:50:13.253')).to.be.ok(); }); }); describe('invalid time range in URL', function () { it('should get the default timerange', async function () { - await PageObjects.common.navigateToUrl('discover', '#/?_g=(time:(from:now-15m,to:null))', { + await common.navigateToUrl('discover', '#/?_g=(time:(from:now-15m,to:null))', { useActualUrl: true, }); - await PageObjects.header.awaitKibanaChrome(); - const time = await PageObjects.timePicker.getTimeConfig(); + await header.awaitKibanaChrome(); + const time = await timePicker.getTimeConfig(); expect(time.start).to.be('~ 15 minutes ago'); expect(time.end).to.be('now'); }); @@ -248,23 +247,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('managing fields', function () { it('should add a field, sort by it, remove it and also sorting by it', async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('_score'); - await PageObjects.discover.clickFieldSort('_score', 'Sort Low-High'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); + await unifiedFieldList.clickFieldListItemAdd('_score'); + await discover.clickFieldSort('_score', 'Sort Low-High'); const currentUrlWithScore = await browser.getCurrentUrl(); expect(currentUrlWithScore).to.contain('_score'); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('_score'); + await unifiedFieldList.clickFieldListItemRemove('_score'); const currentUrlWithoutScore = await browser.getCurrentUrl(); expect(currentUrlWithoutScore).not.to.contain('_score'); }); it('should add a field with customLabel, sort by it, display it correctly', async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('referer'); - await PageObjects.discover.clickFieldSort('referer', 'Sort A-Z'); - expect(await PageObjects.discover.getDocHeader()).to.have.string('Referer custom'); - expect(await PageObjects.unifiedFieldList.getAllFieldNames()).to.contain('Referer custom'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); + await unifiedFieldList.clickFieldListItemAdd('referer'); + await discover.clickFieldSort('referer', 'Sort A-Z'); + expect(await discover.getDocHeader()).to.have.string('Referer custom'); + expect(await unifiedFieldList.getAllFieldNames()).to.contain('Referer custom'); const url = await browser.getCurrentUrl(); expect(url).to.contain('referer'); }); @@ -273,7 +272,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('refresh interval', function () { it('should refetch when autofresh is enabled', async () => { const intervalS = 5; - await PageObjects.timePicker.startAutoRefresh(intervalS); + await timePicker.startAutoRefresh(intervalS); const getRequestTimestamp = async () => { // check inspector panel request stats for timestamp @@ -301,7 +300,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await inspector.close(); - await PageObjects.timePicker.pauseAutoRefresh(); + await timePicker.pauseAutoRefresh(); }); }); diff --git a/test/functional/apps/discover/group1/_discover_accessibility.ts b/test/functional/apps/discover/group1/_discover_accessibility.ts index b6ad925c6d0f7..9749328be31bc 100644 --- a/test/functional/apps/discover/group1/_discover_accessibility.ts +++ b/test/functional/apps/discover/group1/_discover_accessibility.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const find = getService('find'); const testSubjects = getService('testSubjects'); const retry = getService('retry'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); + const { common } = getPageObjects(['common']); const defaultSettings = { defaultIndex: 'logstash-*', @@ -39,7 +39,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async () => { diff --git a/test/functional/apps/discover/group1/_discover_histogram.ts b/test/functional/apps/discover/group1/_discover_histogram.ts index 1289885fc0cee..aaabc64456b27 100644 --- a/test/functional/apps/discover/group1/_discover_histogram.ts +++ b/test/functional/apps/discover/group1/_discover_histogram.ts @@ -16,10 +16,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const elasticChart = getService('elasticChart'); const kibanaServer = getService('kibanaServer'); const security = getService('security'); - const PageObjects = getPageObjects([ + const { timePicker, dashboard, discover, common, header } = getPageObjects([ 'timePicker', 'dashboard', - 'settings', 'discover', 'common', 'header', @@ -44,29 +43,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await security.testUser.setRoles(['kibana_admin', 'long_window_logstash']); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); after(async () => { await esArchiver.unload('test/functional/fixtures/es_archiver/long_window_logstash'); await kibanaServer.savedObjects.cleanStandardList(); await security.testUser.restoreDefaults(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); async function prepareTest(time: TimeStrings, interval?: string) { - await PageObjects.common.setTime(time); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.setTime(time); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); if (interval) { - await PageObjects.discover.setChartInterval(interval); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.setChartInterval(interval); + await header.waitUntilLoadingHasFinished(); } } it('should modify the time range when the histogram is brushed', async function () { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); const prevRenderingCount = await elasticChart.getVisualizationRenderingCount(); await retry.waitFor('chart rendering complete', async () => { const actualCount = await elasticChart.getVisualizationRenderingCount(); @@ -77,12 +76,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { let prevRowData = ''; // to make sure the table is already rendered await retry.try(async () => { - prevRowData = await PageObjects.discover.getDocTableField(1); + prevRowData = await discover.getDocTableField(1); log.debug(`The first timestamp value in doc table before brushing: ${prevRowData}`); }); - await PageObjects.discover.brushHistogram(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.brushHistogram(); + await discover.waitUntilSearchingHasFinished(); const renderingCountInc = 2; await retry.waitFor('chart rendering complete after being brushed', async () => { const actualCount = await elasticChart.getVisualizationRenderingCount(); @@ -90,42 +89,42 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug(`renderings after brushing - actual: ${actualCount} expected: ${expectedCount}`); return actualCount <= expectedCount; }); - const newDurationHours = await PageObjects.timePicker.getTimeDurationInHours(); + const newDurationHours = await timePicker.getTimeDurationInHours(); expect(Math.round(newDurationHours)).to.be(24); // might fail if histogram's width changes await retry.waitFor('doc table containing the documents of the brushed range', async () => { - const rowData = await PageObjects.discover.getDocTableField(1); + const rowData = await discover.getDocTableField(1); log.debug(`The first timestamp value in doc table after brushing: ${rowData}`); return prevRowData !== rowData; }); }); it('should update correctly when switching data views and brushing the histogram', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.selectIndexPattern('logstash-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.selectIndexPattern('long-window-logstash-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.brushHistogram(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCount()).to.be('7'); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); + await discover.selectIndexPattern('logstash-*'); + await discover.waitUntilSearchingHasFinished(); + await discover.selectIndexPattern('long-window-logstash-*'); + await discover.waitUntilSearchingHasFinished(); + await discover.brushHistogram(); + await discover.waitUntilSearchingHasFinished(); + expect(await discover.getHitCount()).to.be('7'); }); it('should update the histogram timerange when the query is resubmitted', async function () { await kibanaServer.uiSettings.update({ 'timepicker:timeDefaults': '{ "from": "2015-09-18T19:37:13.000Z", "to": "now"}', }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.awaitKibanaChrome(); - const initialTimeString = await PageObjects.discover.getChartTimespan(); + await common.navigateToApp('discover'); + await header.awaitKibanaChrome(); + const initialTimeString = await discover.getChartTimespan(); await queryBar.clickQuerySubmitButton(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor('chart timespan to have changed', async () => { - const refreshedTimeString = await PageObjects.discover.getChartTimespan(); + const refreshedTimeString = await discover.getChartTimespan(); await queryBar.clickQuerySubmitButton(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); log.debug( `Timestamp before: ${initialTimeString}, Timestamp after: ${refreshedTimeString}` ); @@ -153,7 +152,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await prepareTest({ from, to }, 'Day'); const chartCanvasExist = await elasticChart.canvasExists(); expect(chartCanvasExist).to.be(true); - const chartIntervalIconTip = await PageObjects.discover.getChartIntervalWarningIcon(); + const chartIntervalIconTip = await discover.getChartIntervalWarningIcon(); expect(chartIntervalIconTip).to.be(false); }); it('should visualize monthly data with different years scaled to seconds', async () => { @@ -162,7 +161,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await prepareTest({ from, to }, 'Second'); const chartCanvasExist = await elasticChart.canvasExists(); expect(chartCanvasExist).to.be(true); - const chartIntervalIconTip = await PageObjects.discover.getChartIntervalWarningIcon(); + const chartIntervalIconTip = await discover.getChartIntervalWarningIcon(); expect(chartIntervalIconTip).to.be(true); }); it('should allow hide/show histogram, persisted in url state', async () => { @@ -171,7 +170,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await prepareTest({ from, to }); let canvasExists = await elasticChart.canvasExists(); expect(canvasExists).to.be(true); - await PageObjects.discover.toggleChartVisibility(); + await discover.toggleChartVisibility(); await retry.try(async () => { canvasExists = await elasticChart.canvasExists(); expect(canvasExists).to.be(false); @@ -180,8 +179,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.refresh(); canvasExists = await elasticChart.canvasExists(); expect(canvasExists).to.be(false); - await PageObjects.discover.toggleChartVisibility(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.toggleChartVisibility(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { canvasExists = await elasticChart.canvasExists(); expect(canvasExists).to.be(true); @@ -194,7 +193,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await prepareTest({ from, to }); // close chart for saved search - await PageObjects.discover.toggleChartVisibility(); + await discover.toggleChartVisibility(); let canvasExists: boolean; await retry.try(async () => { canvasExists = await elasticChart.canvasExists(); @@ -202,43 +201,43 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // save search - await PageObjects.discover.saveSearch(savedSearch); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.saveSearch(savedSearch); + await header.waitUntilLoadingHasFinished(); // open new search - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.clickNewSearchButton(); + await header.waitUntilLoadingHasFinished(); // load saved search - await PageObjects.discover.loadSavedSearch(savedSearch); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.loadSavedSearch(savedSearch); + await header.waitUntilLoadingHasFinished(); canvasExists = await elasticChart.canvasExists(); expect(canvasExists).to.be(false); // open chart for saved search - await PageObjects.discover.toggleChartVisibility(); + await discover.toggleChartVisibility(); await retry.waitFor(`Discover histogram to be displayed`, async () => { canvasExists = await elasticChart.canvasExists(); return canvasExists; }); // save search - await PageObjects.discover.saveSearch(savedSearch); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.saveSearch(savedSearch); + await header.waitUntilLoadingHasFinished(); // open new search - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.clickNewSearchButton(); + await header.waitUntilLoadingHasFinished(); // load saved search - await PageObjects.discover.loadSavedSearch(savedSearch); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.loadSavedSearch(savedSearch); + await header.waitUntilLoadingHasFinished(); canvasExists = await elasticChart.canvasExists(); expect(canvasExists).to.be(true); }); it('should show permitted hidden histogram state when returning back to discover', async () => { // close chart - await PageObjects.discover.toggleChartVisibility(); + await discover.toggleChartVisibility(); let canvasExists: boolean; await retry.try(async () => { canvasExists = await elasticChart.canvasExists(); @@ -246,28 +245,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // save search - await PageObjects.discover.saveSearch('persisted hidden histogram'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.saveSearch('persisted hidden histogram'); + await header.waitUntilLoadingHasFinished(); // open chart - await PageObjects.discover.toggleChartVisibility(); + await discover.toggleChartVisibility(); await retry.try(async () => { canvasExists = await elasticChart.canvasExists(); expect(canvasExists).to.be(true); }); // go to dashboard - await PageObjects.dashboard.navigateToApp(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.navigateToApp(); + await header.waitUntilLoadingHasFinished(); // go to discover - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); canvasExists = await elasticChart.canvasExists(); expect(canvasExists).to.be(true); // close chart - await PageObjects.discover.toggleChartVisibility(); + await discover.toggleChartVisibility(); await retry.try(async () => { canvasExists = await elasticChart.canvasExists(); expect(canvasExists).to.be(false); @@ -275,33 +274,33 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should recover from broken query search when clearing the query bar', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); // Make sure the chart is visible - await PageObjects.discover.toggleChartVisibility(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.toggleChartVisibility(); + await discover.waitUntilSearchingHasFinished(); // type an invalid search query, hit refresh await queryBar.setQuery('this is > not valid'); await queryBar.submitQuery(); - await PageObjects.discover.showsErrorCallout(); + await discover.showsErrorCallout(); // now remove the query await queryBar.clearQuery(); await queryBar.submitQuery(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // check no error state - expect(await PageObjects.discover.isChartVisible()).to.be(true); + expect(await discover.isChartVisible()).to.be(true); }); it('should reset all histogram state when resetting the saved search', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRange(); const savedSearch = 'histogram state'; - await PageObjects.discover.saveSearch(savedSearch); - await PageObjects.discover.chooseBreakdownField('extension.keyword'); - await PageObjects.discover.setChartInterval('Second'); + await discover.saveSearch(savedSearch); + await discover.chooseBreakdownField('extension.keyword'); + await discover.setChartInterval('Second'); let requestData = (await testSubjects.getAttribute('unifiedHistogramChart', 'data-request-data')) ?? ''; expect(JSON.parse(requestData)).to.eql({ @@ -310,10 +309,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { timeInterval: 's', breakdownField: 'extension.keyword', }); - await PageObjects.discover.toggleChartVisibility(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.revertUnsavedChanges(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.toggleChartVisibility(); + await discover.waitUntilSearchingHasFinished(); + await discover.revertUnsavedChanges(); + await discover.waitUntilSearchingHasFinished(); requestData = (await testSubjects.getAttribute('unifiedHistogramChart', 'data-request-data')) ?? ''; expect(JSON.parse(requestData)).to.eql({ diff --git a/test/functional/apps/discover/group1/_discover_histogram_breakdown.ts b/test/functional/apps/discover/group1/_discover_histogram_breakdown.ts index d95305abd0794..5ce8732e5355a 100644 --- a/test/functional/apps/discover/group1/_discover_histogram_breakdown.ts +++ b/test/functional/apps/discover/group1/_discover_histogram_breakdown.ts @@ -14,17 +14,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); + const { common, discover, header, timePicker } = getPageObjects([ + 'common', + 'discover', + 'header', + 'timePicker', + ]); describe('discover unified histogram breakdown', function describeIndexTests() { before(async () => { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await timePicker.setDefaultAbsoluteRange(); + await discover.waitUntilSearchingHasFinished(); }); after(async () => { @@ -32,30 +37,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should choose breakdown field', async () => { - await PageObjects.discover.chooseBreakdownField('extension.raw'); - await PageObjects.header.waitUntilLoadingHasFinished(); - const list = await PageObjects.discover.getHistogramLegendList(); + await discover.chooseBreakdownField('extension.raw'); + await header.waitUntilLoadingHasFinished(); + const list = await discover.getHistogramLegendList(); expect(list).to.eql(['jpg', 'css', 'png', 'Other']); }); it('should add filter using histogram legend values', async () => { - await PageObjects.discover.clickLegendFilter('png', '+'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.clickLegendFilter('png', '+'); + await header.waitUntilLoadingHasFinished(); expect(await filterBar.hasFilter('extension.raw', 'png')).to.be(true); }); it('should save breakdown field in saved search', async () => { await filterBar.removeFilter('extension.raw'); - await PageObjects.discover.saveSearch('with breakdown'); + await discover.saveSearch('with breakdown'); - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const prevList = await PageObjects.discover.getHistogramLegendList(); + await discover.clickNewSearchButton(); + await header.waitUntilLoadingHasFinished(); + const prevList = await discover.getHistogramLegendList(); expect(prevList).to.eql([]); - await PageObjects.discover.loadSavedSearch('with breakdown'); - await PageObjects.header.waitUntilLoadingHasFinished(); - const list = await PageObjects.discover.getHistogramLegendList(); + await discover.loadSavedSearch('with breakdown'); + await header.waitUntilLoadingHasFinished(); + const list = await discover.getHistogramLegendList(); expect(list).to.eql(['jpg', 'css', 'png', 'Other']); }); }); diff --git a/test/functional/apps/discover/group1/_doc_accessibility.ts b/test/functional/apps/discover/group1/_doc_accessibility.ts index d924700d748fa..759f222fc4e29 100644 --- a/test/functional/apps/discover/group1/_doc_accessibility.ts +++ b/test/functional/apps/discover/group1/_doc_accessibility.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const find = getService('find'); const testSubjects = getService('testSubjects'); const dataGrid = getService('dataGrid'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker', 'context']); + const { common, header, timePicker } = getPageObjects(['common', 'header', 'timePicker']); const defaultSettings = { defaultIndex: 'logstash-*', @@ -32,9 +32,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); }); after(async () => { @@ -45,7 +45,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.clickRowToggle({ rowIndex: 0 }); const rowActions = await dataGrid.getRowActions({ rowIndex: 0 }); await rowActions[0].click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.pressKeys(browser.keys.TAB); await browser.pressKeys(browser.keys.SPACE); await browser.pressKeys(browser.keys.TAB); diff --git a/test/functional/apps/discover/group1/_errors.ts b/test/functional/apps/discover/group1/_errors.ts index 003c4a266a3aa..d6f2eae89c9f1 100644 --- a/test/functional/apps/discover/group1/_errors.ts +++ b/test/functional/apps/discover/group1/_errors.ts @@ -14,7 +14,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'header', 'discover', 'timePicker']); + const { common, header, discover, timePicker } = getPageObjects([ + 'common', + 'header', + 'discover', + 'timePicker', + ]); describe('errors', function describeIndexTests() { before(async function () { @@ -23,8 +28,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'test/functional/fixtures/kbn_archiver/invalid_scripted_field' ); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); after(async function () { @@ -33,7 +38,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('invalid scripted field error', () => { it('is rendered', async () => { - await PageObjects.discover.showsErrorCallout(); + await discover.showsErrorCallout(); const painlessStackTrace = await testSubjects.find('painlessStackTrace'); expect(painlessStackTrace).not.to.be(undefined); }); @@ -41,11 +46,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('not found', () => { it('should redirect to main page when trying to access invalid route', async () => { - await PageObjects.common.navigateToUrl('discover', '#/invalid-route', { + await common.navigateToUrl('discover', '#/invalid-route', { useActualUrl: true, ensureCurrentUrl: false, }); - await PageObjects.header.awaitKibanaChrome(); + await header.awaitKibanaChrome(); const invalidLink = await testSubjects.find('invalidRouteMessage'); expect(await invalidLink.getVisibleText()).to.be( diff --git a/test/functional/apps/discover/group2_data_grid1/_data_grid.ts b/test/functional/apps/discover/group2_data_grid1/_data_grid.ts index 580cbd4a2ae41..90cf9067cd852 100644 --- a/test/functional/apps/discover/group2_data_grid1/_data_grid.ts +++ b/test/functional/apps/discover/group2_data_grid1/_data_grid.ts @@ -13,7 +13,11 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover data grid tests', function describeDiscoverDataGrid() { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'unifiedFieldList']); + const { common, timePicker, unifiedFieldList } = getPageObjects([ + 'common', + 'timePicker', + 'unifiedFieldList', + ]); const kibanaServer = getService('kibanaServer'); const defaultSettings = { defaultIndex: 'logstash-*' }; const testSubjects = getService('testSubjects'); @@ -27,8 +31,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); it('can add fields to the table', async function () { @@ -37,16 +41,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await getTitles()).to.be('@timestamp Document'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); expect(await getTitles()).to.be('@timestamp bytes'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('agent'); + await unifiedFieldList.clickFieldListItemAdd('agent'); expect(await getTitles()).to.be('@timestamp bytes agent'); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('bytes'); + await unifiedFieldList.clickFieldListItemRemove('bytes'); expect(await getTitles()).to.be('@timestamp agent'); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('agent'); + await unifiedFieldList.clickFieldListItemRemove('agent'); expect(await getTitles()).to.be('@timestamp Document'); }); diff --git a/test/functional/apps/discover/group2_data_grid1/_data_grid_context.ts b/test/functional/apps/discover/group2_data_grid1/_data_grid_context.ts index 5fad9c4460c80..cbd9221311f16 100644 --- a/test/functional/apps/discover/group2_data_grid1/_data_grid_context.ts +++ b/test/functional/apps/discover/group2_data_grid1/_data_grid_context.ts @@ -22,11 +22,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const filterBar = getService('filterBar'); const dataGrid = getService('dataGrid'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, dashboard, header, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'timePicker', - 'settings', 'dashboard', 'header', 'unifiedFieldList', @@ -47,21 +46,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); for (const columnName of TEST_COLUMN_NAMES) { - await PageObjects.unifiedFieldList.clickFieldListItemAdd(columnName); + await unifiedFieldList.clickFieldListItemAdd(columnName); } for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) { - await PageObjects.unifiedFieldList.clickFieldListItem(columnName); - await PageObjects.unifiedFieldList.clickFieldListPlusFilter(columnName, value); + await unifiedFieldList.clickFieldListItem(columnName); + await unifiedFieldList.clickFieldListPlusFilter(columnName, value); } }); after(async () => { - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); }); it('should open the context view with the selected document as anchor', async () => { @@ -103,16 +102,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('navigates to context view from embeddable', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.saveSearch('my search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await discover.saveSearch('my search'); + await header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.addSavedSearch('my search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dataGrid.clickRowToggle({ rowIndex: 0 }); const rowActions = await dataGrid.getRowActions({ rowIndex: 0 }); diff --git a/test/functional/apps/discover/group2_data_grid1/_data_grid_copy_to_clipboard.ts b/test/functional/apps/discover/group2_data_grid1/_data_grid_copy_to_clipboard.ts index 1f93c918125f0..a58dcf94e3a4a 100644 --- a/test/functional/apps/discover/group2_data_grid1/_data_grid_copy_to_clipboard.ts +++ b/test/functional/apps/discover/group2_data_grid1/_data_grid_copy_to_clipboard.ts @@ -18,7 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const browser = getService('browser'); const toasts = getService('toasts'); const security = getService('security'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker', 'dashboard']); + const { common, discover, timePicker } = getPageObjects(['common', 'discover', 'timePicker']); const defaultSettings = { defaultIndex: 'logstash-*', }; @@ -31,11 +31,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async function () { @@ -45,7 +45,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to copy a column values to clipboard', async () => { const canReadClipboard = await browser.checkBrowserPermission('clipboard-read'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickCopyColumnValues('@timestamp'); @@ -75,7 +75,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to copy a column name to clipboard', async () => { const canReadClipboard = await browser.checkBrowserPermission('clipboard-read'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickCopyColumnName('@timestamp'); if (canReadClipboard) { diff --git a/test/functional/apps/discover/group2_data_grid1/_data_grid_doc_navigation.ts b/test/functional/apps/discover/group2_data_grid1/_data_grid_doc_navigation.ts index fe5882bf0d299..37f9d930ef1a0 100644 --- a/test/functional/apps/discover/group2_data_grid1/_data_grid_doc_navigation.ts +++ b/test/functional/apps/discover/group2_data_grid1/_data_grid_doc_navigation.ts @@ -14,7 +14,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const filterBar = getService('filterBar'); const dataGrid = getService('dataGrid'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'context']); + const { common, discover, timePicker } = getPageObjects(['common', 'discover', 'timePicker']); const esArchiver = getService('esArchiver'); const retry = getService('retry'); const kibanaServer = getService('kibanaServer'); @@ -33,9 +33,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); it('should open the doc view of the selected document', async function () { @@ -58,7 +58,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should create an exists filter from doc view of the selected document', async function () { - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle({ rowIndex: 0 }); await dataGrid.clickFieldActionInFlyout('@timestamp', 'addExistsFilterButton'); diff --git a/test/functional/apps/discover/group2_data_grid1/_data_grid_doc_table.ts b/test/functional/apps/discover/group2_data_grid1/_data_grid_doc_table.ts index d75218f598dc8..b8743f65e73ce 100644 --- a/test/functional/apps/discover/group2_data_grid1/_data_grid_doc_table.ts +++ b/test/functional/apps/discover/group2_data_grid1/_data_grid_doc_table.ts @@ -18,7 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const monacoEditor = getService('monacoEditor'); const dashboardAddPanel = getService('dashboardAddPanel'); - const PageObjects = getPageObjects([ + const { common, discover, header, timePicker, dashboard, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', @@ -41,11 +41,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async function () { @@ -65,17 +65,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const fromTime = 'Sep 20, 2015 @ 23:00:00.000'; const toTime = 'Sep 20, 2015 @ 23:14:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setAbsoluteRange(fromTime, toTime); + await discover.waitUntilSearchingHasFinished(); - const finalRows = await PageObjects.discover.getDocTableRows(); + const finalRows = await discover.getDocTableRows(); expect(finalRows.length).to.be.below(initialRows.length); }); it('should show popover with expanded cell content by click on expand button', async () => { log.debug('open popover with expanded cell content to get json from the editor'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRange(); + await discover.waitUntilSearchingHasFinished(); await retry.waitForWithTimeout('timestamp matches expected doc', 5000, async () => { const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); @@ -111,14 +111,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show popover with expanded cell content by click on expand button on embeddable', async () => { log.debug('open popover with expanded cell content to get json from the editor'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.saveSearch('expand-cell-search'); - - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await timePicker.setDefaultAbsoluteRange(); + await discover.waitUntilSearchingHasFinished(); + await discover.saveSearch('expand-cell-search'); + + await dashboard.navigateToApp(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await header.waitUntilLoadingHasFinished(); await dashboardAddPanel.addSavedSearch('expand-cell-search'); await retry.waitForWithTimeout('timestamp matches expected doc', 5000, async () => { @@ -221,42 +221,38 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { afterEach(async function () { for (const column of extraColumns) { - await PageObjects.unifiedFieldList.clickFieldListItemRemove(column); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove(column); + await header.waitUntilLoadingHasFinished(); } }); it('should add more columns to the table', async function () { for (const column of extraColumns) { - await PageObjects.unifiedFieldList.clearFieldSearchInput(); - await PageObjects.unifiedFieldList.findFieldByName(column); - await PageObjects.unifiedFieldList.waitUntilFieldlistHasCountOfFields( - expectedFieldLength[column] - ); - await PageObjects.unifiedFieldList.clickFieldListItemAdd(column); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clearFieldSearchInput(); + await unifiedFieldList.findFieldByName(column); + await unifiedFieldList.waitUntilFieldlistHasCountOfFields(expectedFieldLength[column]); + await unifiedFieldList.clickFieldListItemAdd(column); + await header.waitUntilLoadingHasFinished(); // test the header now - const header = await dataGrid.getHeaderFields(); - expect(header.join(' ')).to.have.string(column); + const headerFields = await dataGrid.getHeaderFields(); + expect(headerFields.join(' ')).to.have.string(column); } }); it('should remove columns from the table', async function () { for (const column of extraColumns) { - await PageObjects.unifiedFieldList.clearFieldSearchInput(); - await PageObjects.unifiedFieldList.findFieldByName(column); - await PageObjects.unifiedFieldList.waitUntilFieldlistHasCountOfFields( - expectedFieldLength[column] - ); - await PageObjects.unifiedFieldList.clickFieldListItemAdd(column); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clearFieldSearchInput(); + await unifiedFieldList.findFieldByName(column); + await unifiedFieldList.waitUntilFieldlistHasCountOfFields(expectedFieldLength[column]); + await unifiedFieldList.clickFieldListItemAdd(column); + await header.waitUntilLoadingHasFinished(); } // remove the second column - await PageObjects.unifiedFieldList.clickFieldListItemRemove(extraColumns[1]); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove(extraColumns[1]); + await header.waitUntilLoadingHasFinished(); // test that the second column is no longer there - const header = await dataGrid.getHeaderFields(); - expect(header.join(' ')).to.not.have.string(extraColumns[1]); + const headerFields = await dataGrid.getHeaderFields(); + expect(headerFields.join(' ')).to.not.have.string(extraColumns[1]); }); }); }); diff --git a/test/functional/apps/discover/group2_data_grid2/_data_grid_field_data.ts b/test/functional/apps/discover/group2_data_grid2/_data_grid_field_data.ts index 3e99c7c74cf40..9f826f9a75ee5 100644 --- a/test/functional/apps/discover/group2_data_grid2/_data_grid_field_data.ts +++ b/test/functional/apps/discover/group2_data_grid2/_data_grid_field_data.ts @@ -15,11 +15,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const queryBar = getService('queryBar'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, unifiedFieldList } = getPageObjects([ 'common', - 'header', 'discover', - 'visualize', 'timePicker', 'unifiedFieldList', ]); @@ -34,9 +32,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); describe('field data', function () { it('search php should show the correct hit count', async function () { @@ -44,18 +42,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.try(async function () { await queryBar.setQuery('php'); await queryBar.submitQuery(); - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be(expectedHitCount); }); }); it('the search term should be highlighted in the field data', async function () { // marks is the style that highlights the text in yellow - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - const marks = await PageObjects.discover.getMarks(); + await unifiedFieldList.clickFieldListItemAdd('extension'); + const marks = await discover.getMarks(); expect(marks.length).to.be.greaterThan(0); expect(marks.indexOf('php')).to.be(0); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('extension'); + await unifiedFieldList.clickFieldListItemRemove('extension'); }); it('search type:apache should show the correct hit count', async function () { @@ -63,7 +61,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await queryBar.setQuery('type:apache'); await queryBar.submitQuery(); await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be(expectedHitCount); }); }); @@ -77,7 +75,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('doc view should sort ascending', async function () { const expectedTimeStamp = 'Sep 20, 2015 @ 00:00:00.000'; await dataGrid.clickDocSortAsc(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor('first cell contains expected timestamp', async () => { const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); @@ -92,8 +90,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'whitespace but "(" found.'; await queryBar.setQuery('xxx(yyy))'); await queryBar.submitQuery(); - await PageObjects.discover.showsErrorCallout(); - const message = await PageObjects.discover.getDiscoverErrorMessage(); + await discover.showsErrorCallout(); + const message = await discover.getDiscoverErrorMessage(); expect(message).to.contain(expectedError); }); }); diff --git a/test/functional/apps/discover/group2_data_grid2/_data_grid_field_tokens.ts b/test/functional/apps/discover/group2_data_grid2/_data_grid_field_tokens.ts index fac2ec812b3ba..3b6cd56aa9c3a 100644 --- a/test/functional/apps/discover/group2_data_grid2/_data_grid_field_tokens.ts +++ b/test/functional/apps/discover/group2_data_grid2/_data_grid_field_tokens.ts @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const dataGrid = getService('dataGrid'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, dashboard, unifiedFieldList, header } = getPageObjects([ 'common', 'discover', 'timePicker', @@ -33,14 +33,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; async function findFirstColumnTokens() { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); return await findFirstFieldIcons('euiDataGridBody > dataGridHeader'); } async function findFirstDocViewerTokens() { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); let fieldTokens: string[] | undefined = []; await retry.try(async () => { await dataGrid.clickRowToggle({ rowIndex: 0 }); @@ -85,14 +85,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); it('should not render field tokens when Document column is visible', async function () { - expect(await PageObjects.discover.getHitCount()).to.be('14,004'); + expect(await discover.getHitCount()).to.be('14,004'); expect(await findFirstColumnTokens()).to.eql([]); @@ -111,10 +111,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render field tokens correctly when columns are selected', async function () { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('ip'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('geo.coordinates'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await unifiedFieldList.clickFieldListItemAdd('ip'); + await unifiedFieldList.clickFieldListItemAdd('geo.coordinates'); expect(await findFirstColumnTokens()).to.eql(['Number', 'Text', 'IP address', 'Geo point']); @@ -133,13 +133,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render field tokens correctly for ES|QL', async function () { - await PageObjects.discover.selectTextBaseLang(); - expect(await PageObjects.discover.getHitCount()).to.be('10'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('ip'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('geo.coordinates'); + await discover.selectTextBaseLang(); + expect(await discover.getHitCount()).to.be('10'); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await unifiedFieldList.clickFieldListItemAdd('ip'); + await unifiedFieldList.clickFieldListItemAdd('geo.coordinates'); expect(await findFirstColumnTokens()).to.eql(['Number', 'Text', 'IP address', 'Geo point']); @@ -158,16 +158,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render field tokens correctly on Dashboard', async function () { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('geo.coordinates'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd( - 'relatedContent.article:modified_time' - ); - await PageObjects.discover.saveSearch('With columns'); - - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await unifiedFieldList.clickFieldListItemAdd('geo.coordinates'); + await unifiedFieldList.clickFieldListItemAdd('relatedContent.article:modified_time'); + await discover.saveSearch('With columns'); + + await common.navigateToApp('dashboard'); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch('With columns'); @@ -188,8 +186,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render field tokens correctly on Surrounding Documents page', async function () { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('extension'); // navigate to the context view await dataGrid.clickRowToggle({ rowIndex: 0 }); @@ -198,7 +196,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { rowIndex: 0, }); await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect(await findFirstColumnTokens()).to.eql(['Number', 'Text']); }); diff --git a/test/functional/apps/discover/group2_data_grid2/_data_grid_footer.ts b/test/functional/apps/discover/group2_data_grid2/_data_grid_footer.ts index 1afa0f3aace45..0e233db2ee54c 100644 --- a/test/functional/apps/discover/group2_data_grid2/_data_grid_footer.ts +++ b/test/functional/apps/discover/group2_data_grid2/_data_grid_footer.ts @@ -17,7 +17,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const dataGrid = getService('dataGrid'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'unifiedFieldList']); + const { common, discover, timePicker, unifiedFieldList } = getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'unifiedFieldList', + ]); const defaultSettings = { defaultIndex: 'logstash-*' }; const testSubjects = getService('testSubjects'); const retry = getService('retry'); @@ -39,10 +44,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); it('should show footer only for the last page and allow to load more', async () => { @@ -71,7 +76,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // press "Load more" await testSubjects.click(LOAD_MORE_SELECTOR); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // more pages appeared and the footer is gone await retry.try(async function () { @@ -86,7 +91,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // press "Load more" await testSubjects.click(LOAD_MORE_SELECTOR); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // more pages appeared and the footer is gone await retry.try(async function () { @@ -110,7 +115,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await testSubjects.isEnabled(LOAD_MORE_SELECTOR)).to.be(true); // enable the refresh interval - await PageObjects.timePicker.startAutoRefresh(10); + await timePicker.startAutoRefresh(10); // the button is disabled now await retry.waitFor('disabled state', async function () { @@ -118,7 +123,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // disable the refresh interval - await PageObjects.timePicker.pauseAutoRefresh(); + await timePicker.pauseAutoRefresh(); // the button is enabled again await retry.waitFor('enabled state', async function () { @@ -142,7 +147,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.common.setTime({ + await common.setTime({ from: 'Sep 10, 2015 @ 00:00:00.000', to: 'Sep 30, 2019 @ 00:00:00.000', }); @@ -151,13 +156,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'discover:sampleSize': 4, 'discover:sampleRowsPerPage': 2, }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); it('should work for date nanos too', async () => { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('_id'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('_id'); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getRowsText()).to.eql([ 'Sep 22, 2019 @ 23:50:13.253123345AU_x3-TaGFA8no6QjiSJ', @@ -185,7 +190,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // press "Load more" await testSubjects.click(LOAD_MORE_SELECTOR); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // more pages appeared and the footer is gone await retry.try(async function () { @@ -205,7 +210,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // press "Load more" await testSubjects.click(LOAD_MORE_SELECTOR); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // more pages appeared and the footer is gone await retry.try(async function () { diff --git a/test/functional/apps/discover/group2_data_grid2/_data_grid_new_line.ts b/test/functional/apps/discover/group2_data_grid2/_data_grid_new_line.ts index 72b0c99acf51b..217044f03e882 100644 --- a/test/functional/apps/discover/group2_data_grid2/_data_grid_new_line.ts +++ b/test/functional/apps/discover/group2_data_grid2/_data_grid_new_line.ts @@ -21,11 +21,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const dataGrid = getService('dataGrid'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects([ - 'settings', + const { common, discover, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', - 'header', 'timePicker', 'unifiedFieldList', ]); @@ -60,12 +58,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); await dataViews.createFromSearchBar({ name: INDEX_NAME, adHoc: true, hasTimeField: false }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); it('should not show new lines for Document column', async () => { @@ -79,8 +77,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show new lines for "message" column except for Single row height setting', async () => { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('message'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('message'); + await discover.waitUntilSearchingHasFinished(); let cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); let content = await cell.findByCssSelector('.unifiedDataTable__cellValue'); diff --git a/test/functional/apps/discover/group2_data_grid3/_data_grid_column_widths.ts b/test/functional/apps/discover/group2_data_grid3/_data_grid_column_widths.ts index a197628250807..ba6f64d929fb1 100644 --- a/test/functional/apps/discover/group2_data_grid3/_data_grid_column_widths.ts +++ b/test/functional/apps/discover/group2_data_grid3/_data_grid_column_widths.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const dataGrid = getService('dataGrid'); const dashboardAddPanel = getService('dashboardAddPanel'); - const PageObjects = getPageObjects([ + const { common, discover, header, timePicker, dashboard, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', @@ -39,7 +39,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); after(async () => { @@ -49,27 +49,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); it('should not show reset width button for auto width column', async () => { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@message'); + await unifiedFieldList.clickFieldListItemAdd('@message'); expect(await dataGrid.resetColumnWidthExists('@message')).to.be(false); }); it('should show reset width button for absolute width column, and allow resetting to auto width', async () => { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@message'); + await unifiedFieldList.clickFieldListItemAdd('@message'); await testResizeColumn('@message'); }); it('should reset the last column to auto width if only absolute width columns remain', async () => { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@message'); + await unifiedFieldList.clickFieldListItemAdd('@message'); const { originalWidth: messageOriginalWidth, newWidth: messageNewWidth } = await dataGrid.resizeColumn('@message', -300); expect(messageNewWidth).to.be(messageOriginalWidth - 300); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); const { originalWidth: bytesOriginalWidth, newWidth: bytesNewWidth } = await dataGrid.resizeColumn('bytes', -100); expect(bytesNewWidth).to.be(bytesOriginalWidth - 100); @@ -81,12 +81,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not reset the last column to auto width when there are remaining auto width columns', async () => { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@message'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('@message'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); const { originalWidth: bytesOriginalWidth, newWidth: bytesNewWidth } = await dataGrid.resizeColumn('bytes', -200); expect(bytesNewWidth).to.be(bytesOriginalWidth - 200); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('agent'); + await unifiedFieldList.clickFieldListItemAdd('agent'); const { originalWidth: agentOriginalWidth, newWidth: agentNewWidth } = await dataGrid.resizeColumn('agent', -100); expect(agentNewWidth).to.be(agentOriginalWidth - 100); @@ -96,34 +96,34 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should allow resetting column width in surrounding docs view', async () => { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@message'); + await unifiedFieldList.clickFieldListItemAdd('@message'); await dataGrid.clickRowToggle({ rowIndex: 0 }); const [, surroundingActionEl] = await dataGrid.getRowActions({ rowIndex: 0 }); await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testResizeColumn('@message'); }); it('should allow resetting column width in Dashboard panel', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); + await common.navigateToApp('dashboard'); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch('A Saved Search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testResizeColumn('_source'); }); it('should use custom column width on Dashboard when specified', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); + await common.navigateToApp('dashboard'); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch('A Saved Search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const { originalWidth, newWidth } = await dataGrid.resizeColumn('_source', -100); expect(newWidth).to.be(originalWidth - 100); - await PageObjects.dashboard.saveDashboard('test'); + await dashboard.saveDashboard('test'); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const initialWidth = (await (await dataGrid.getHeaderElement('_source')).getSize()).width; expect(initialWidth).to.be(newWidth); }); diff --git a/test/functional/apps/discover/group2_data_grid3/_data_grid_density.ts b/test/functional/apps/discover/group2_data_grid3/_data_grid_density.ts index 938f6544f68a6..b50cd7e16cf01 100644 --- a/test/functional/apps/discover/group2_data_grid3/_data_grid_density.ts +++ b/test/functional/apps/discover/group2_data_grid3/_data_grid_density.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const dataGrid = getService('dataGrid'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['settings', 'common', 'discover', 'header', 'timePicker']); + const { common, discover, timePicker } = getPageObjects(['common', 'discover', 'timePicker']); const defaultSettings = { defaultIndex: 'logstash-*' }; const security = getService('security'); @@ -35,10 +35,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); it('should use the default density', async () => { @@ -66,7 +66,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await dataGrid.getCurrentDensityValue()).to.be('Expanded'); await browser.refresh(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentDensityValue()).to.be('Expanded'); @@ -74,12 +74,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should save and revert unsaved densities properly', async () => { // Open saved search - await PageObjects.discover.loadSavedSearch('A Saved Search'); + await discover.loadSavedSearch('A Saved Search'); // Change density await dataGrid.clickGridSettings(); await dataGrid.changeDensityValue('Expanded'); - await PageObjects.discover.saveUnsavedChanges(); + await discover.saveUnsavedChanges(); // Change density await dataGrid.clickGridSettings(); @@ -87,7 +87,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.existOrFail('unsavedChangesBadge'); // Revert change - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); // Verify density reset await dataGrid.clickGridSettings(); diff --git a/test/functional/apps/discover/group2_data_grid3/_data_grid_pagination.ts b/test/functional/apps/discover/group2_data_grid3/_data_grid_pagination.ts index eab07ae66419f..3e349129dc474 100644 --- a/test/functional/apps/discover/group2_data_grid3/_data_grid_pagination.ts +++ b/test/functional/apps/discover/group2_data_grid3/_data_grid_pagination.ts @@ -15,8 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const dataGrid = getService('dataGrid'); - const PageObjects = getPageObjects([ - 'settings', + const { common, discover, header, timePicker, dashboard } = getPageObjects([ 'common', 'discover', 'header', @@ -48,10 +47,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); it('should show pagination', async () => { @@ -105,8 +104,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // first render is based on settings value - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); expect((await dataGrid.getDocTableRows()).length).to.be(6); await dataGrid.checkCurrentRowsPerPageToBe(6); @@ -115,34 +114,34 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // save as a new search const savedSearchTitle = 'search with saved rowsPerPage'; - await PageObjects.discover.saveSearch(savedSearchTitle); + await discover.saveSearch(savedSearchTitle); // start a new search session await testSubjects.click('discoverNewButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect((await dataGrid.getDocTableRows()).length).to.be(6); // as in settings await dataGrid.checkCurrentRowsPerPageToBe(6); // open the saved search - await PageObjects.discover.loadSavedSearch(savedSearchTitle); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(savedSearchTitle); + await discover.waitUntilSearchingHasFinished(); expect((await dataGrid.getDocTableRows()).length).to.be(10); // as in the saved search await dataGrid.checkCurrentRowsPerPageToBe(10); // should use "rowsPerPage" form the saved search on dashboard - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('dashboard'); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultAbsoluteRange(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch(savedSearchTitle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect((await dataGrid.getDocTableRows()).length).to.be(10); // as in the saved search await dataGrid.checkCurrentRowsPerPageToBe(10); // should use "rowsPerPage" form settings by default on dashboard await dashboardPanelActions.removePanelByTitle(savedSearchTitle); await dashboardAddPanel.addSavedSearch('A Saved Search'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect((await dataGrid.getDocTableRows()).length).to.be(6); // as in settings await dataGrid.checkCurrentRowsPerPageToBe(6); }); @@ -156,31 +155,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { hideAnnouncements: true, }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); // expect pagination to be present for data view mode expect((await dataGrid.getDocTableRows()).length).to.be(rowsPerPage); await dataGrid.checkCurrentRowsPerPageToBe(rowsPerPage); await testSubjects.existOrFail('pagination-button-0'); - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // expect no pagination for ES|QL mode expect((await dataGrid.getDocTableRows()).length).to.above(rowsPerPage); await testSubjects.missingOrFail('pagination-button-0'); - await PageObjects.discover.saveSearch(savedSearchESQL); + await discover.saveSearch(savedSearchESQL); - await PageObjects.common.navigateToApp('dashboard'); + await common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultAbsoluteRange(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch(savedSearchESQL); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // expect no pagination for ES|QL mode on Dashboard expect((await dataGrid.getDocTableRows()).length).to.above(rowsPerPage); diff --git a/test/functional/apps/discover/group2_data_grid3/_data_grid_row_height.ts b/test/functional/apps/discover/group2_data_grid3/_data_grid_row_height.ts index 9dd549e3fa90b..fc5ccf9323ef2 100644 --- a/test/functional/apps/discover/group2_data_grid3/_data_grid_row_height.ts +++ b/test/functional/apps/discover/group2_data_grid3/_data_grid_row_height.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const dataGrid = getService('dataGrid'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['settings', 'common', 'discover', 'header', 'timePicker']); + const { common, discover, timePicker } = getPageObjects(['common', 'discover', 'timePicker']); const defaultSettings = { defaultIndex: 'logstash-*' }; const security = getService('security'); @@ -35,10 +35,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); it('should use the default row height', async () => { @@ -85,7 +85,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.refresh(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentRowHeightValue()).to.be('Single'); @@ -135,7 +135,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.refresh(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentHeaderRowHeightValue()).to.be('Single'); diff --git a/test/functional/apps/discover/group2_data_grid3/_data_grid_row_navigation.ts b/test/functional/apps/discover/group2_data_grid3/_data_grid_row_navigation.ts index 8d8027e4b3ed9..f2715e2af85cd 100644 --- a/test/functional/apps/discover/group2_data_grid3/_data_grid_row_navigation.ts +++ b/test/functional/apps/discover/group2_data_grid3/_data_grid_row_navigation.ts @@ -13,7 +13,12 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const dataGrid = getService('dataGrid'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'settings', 'header']); + const { common, discover, timePicker, settings } = getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'settings', + ]); const es = getService('es'); const security = getService('security'); @@ -32,18 +37,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover data grid row navigation', function () { before(async () => { await security.testUser.setRoles(['kibana_admin', 'similar_index', 'similar_index_two']); - await PageObjects.common.navigateToApp('settings'); + await common.navigateToApp('settings'); await createIndex('similar_index'); await createIndex('similar_index_two'); - await PageObjects.settings.createIndexPattern('similar_index*', '@timestamp', true); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await settings.createIndexPattern('similar_index*', '@timestamp', true); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); it('should navigate through rows with the same id but different indices correctly', async () => { - await PageObjects.discover.selectIndexPattern('similar_index*'); + await discover.selectIndexPattern('similar_index*'); await dataGrid.clickRowToggle(); const indexBeforePaginating = await testSubjects.getVisibleText( diff --git a/test/functional/apps/discover/group2_data_grid3/_data_grid_row_selection.ts b/test/functional/apps/discover/group2_data_grid3/_data_grid_row_selection.ts index 26c53042741fc..97e56a1de868c 100644 --- a/test/functional/apps/discover/group2_data_grid3/_data_grid_row_selection.ts +++ b/test/functional/apps/discover/group2_data_grid3/_data_grid_row_selection.ts @@ -18,7 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const security = getService('security'); const testSubjects = getService('testSubjects'); const browser = getService('browser'); - const PageObjects = getPageObjects([ + const { common, discover, header, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', @@ -39,13 +39,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); after(async function () { @@ -211,8 +211,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('can copy columns for selected rows as text', async () => { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); await retry.try(async () => { expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'extension', 'bytes']); }); diff --git a/test/functional/apps/discover/group2_data_grid3/_data_grid_sample_size.ts b/test/functional/apps/discover/group2_data_grid3/_data_grid_sample_size.ts index 34427b2d2a312..759990efcaa22 100644 --- a/test/functional/apps/discover/group2_data_grid3/_data_grid_sample_size.ts +++ b/test/functional/apps/discover/group2_data_grid3/_data_grid_sample_size.ts @@ -26,8 +26,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); const dashboardAddPanel = getService('dashboardAddPanel'); - const PageObjects = getPageObjects([ - 'settings', + const { common, discover, header, timePicker, dashboard } = getPageObjects([ 'common', 'discover', 'header', @@ -57,11 +56,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); async function goToLastPageAndCheckFooterMessage(sampleSize: number) { @@ -90,8 +89,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.changeSampleSizeValue(CUSTOM_SAMPLE_SIZE); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getCurrentSampleSizeValue()).to.be(CUSTOM_SAMPLE_SIZE); await goToLastPageAndCheckFooterMessage(CUSTOM_SAMPLE_SIZE); @@ -103,12 +102,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.changeSampleSizeValue(CUSTOM_SAMPLE_SIZE); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await browser.refresh(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentSampleSizeValue()).to.be(CUSTOM_SAMPLE_SIZE); @@ -121,39 +120,39 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.changeSampleSizeValue(CUSTOM_SAMPLE_SIZE_FOR_SAVED_SEARCH); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.saveSearch(SAVED_SEARCH_NAME); + await discover.saveSearch(SAVED_SEARCH_NAME); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentSampleSizeValue()).to.be(CUSTOM_SAMPLE_SIZE_FOR_SAVED_SEARCH); await goToLastPageAndCheckFooterMessage(CUSTOM_SAMPLE_SIZE_FOR_SAVED_SEARCH); // reset to the default value - await PageObjects.discover.clickNewSearchButton(); + await discover.clickNewSearchButton(); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentSampleSizeValue()).to.be(DEFAULT_SAMPLE_SIZE); await goToLastPageAndCheckFooterMessage(DEFAULT_SAMPLE_SIZE); // load the saved search again - await PageObjects.discover.loadSavedSearch(SAVED_SEARCH_NAME); + await discover.loadSavedSearch(SAVED_SEARCH_NAME); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentSampleSizeValue()).to.be(CUSTOM_SAMPLE_SIZE_FOR_SAVED_SEARCH); await goToLastPageAndCheckFooterMessage(CUSTOM_SAMPLE_SIZE_FOR_SAVED_SEARCH); // load another saved search without a custom sample size - await PageObjects.discover.loadSavedSearch('A Saved Search'); + await discover.loadSavedSearch('A Saved Search'); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentSampleSizeValue()).to.be(DEFAULT_SAMPLE_SIZE); await goToLastPageAndCheckFooterMessage(DEFAULT_SAMPLE_SIZE); }); it('should use the default sample size on Dashboard', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); + await common.navigateToApp('dashboard'); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch('A Saved Search'); @@ -163,8 +162,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should use custom sample size on Dashboard when specified', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); + await common.navigateToApp('dashboard'); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch(SAVED_SEARCH_NAME); @@ -173,7 +172,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.changeSampleSizeValue(CUSTOM_SAMPLE_SIZE_FOR_DASHBOARD_PANEL); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentSampleSizeValue()).to.be( @@ -181,10 +180,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await goToLastPageAndCheckFooterMessage(CUSTOM_SAMPLE_SIZE_FOR_DASHBOARD_PANEL); - await PageObjects.dashboard.saveDashboard('test'); + await dashboard.saveDashboard('test'); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentSampleSizeValue()).to.be( diff --git a/test/functional/apps/discover/group3/_default_columns.ts b/test/functional/apps/discover/group3/_default_columns.ts index e599b99fd0ebe..b3670833b8329 100644 --- a/test/functional/apps/discover/group3/_default_columns.ts +++ b/test/functional/apps/discover/group3/_default_columns.ts @@ -13,13 +13,11 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const dataGrid = getService('dataGrid'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'timePicker', 'unifiedFieldList', - 'unifiedSearch', - 'header', ]); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); @@ -57,10 +55,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); it('should render default columns', async function () { @@ -81,35 +79,35 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]); await dataViews.switchToAndValidate('Kibana Sample Data Logs (TSDB)'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await discover.expandTimeRangeAsSuggestedInNoResultsMessage(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['timestamp', 'message', 'extension']); await dataViews.switchToAndValidate('kibana_sample_data_flights'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await discover.expandTimeRangeAsSuggestedInNoResultsMessage(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['timestamp', 'DestCountry']); await dataViews.switchToAndValidate('logstash-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await discover.expandTimeRangeAsSuggestedInNoResultsMessage(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'extension']); }); it('should combine selected columns and default columns after switching data views', async function () { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('DestCountry'); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('message'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemRemove('DestCountry'); + await unifiedFieldList.clickFieldListItemRemove('message'); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'extension', 'bytes']); await dataViews.switchToAndValidate('Kibana Sample Data Logs (TSDB)'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await discover.expandTimeRangeAsSuggestedInNoResultsMessage(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql([ 'timestamp', 'extension', @@ -118,9 +116,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]); await dataViews.switchToAndValidate('logstash-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await discover.expandTimeRangeAsSuggestedInNoResultsMessage(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'extension', 'bytes']); }); @@ -128,8 +126,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.update({ 'discover:modifyColumnsOnSwitch': false, }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql([ '@timestamp', @@ -139,9 +137,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]); await dataViews.switchToAndValidate('kibana_sample_data_flights'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await discover.expandTimeRangeAsSuggestedInNoResultsMessage(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql([ 'timestamp', 'message', diff --git a/test/functional/apps/discover/group3/_doc_viewer.ts b/test/functional/apps/discover/group3/_doc_viewer.ts index 32b2af1b2d627..6da0725978afe 100644 --- a/test/functional/apps/discover/group3/_doc_viewer.ts +++ b/test/functional/apps/discover/group3/_doc_viewer.ts @@ -13,7 +13,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, header, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'timePicker', @@ -39,10 +39,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { defaultIndex: 'logstash-*', hideAnnouncements: true, }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); afterEach(async () => { @@ -54,7 +54,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('search', function () { beforeEach(async () => { await dataGrid.clickRowToggle(); - await PageObjects.discover.isShowingDocViewer(); + await discover.isShowingDocViewer(); await retry.waitFor('rendered items', async () => { return (await find.allByCssSelector('.kbnDocViewer__fieldName')).length > 0; }); @@ -66,13 +66,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should be able to search by string', async function () { - await PageObjects.discover.findFieldByNameInDocViewer('geo'); + await discover.findFieldByNameInDocViewer('geo'); await retry.waitFor('first updates', async () => { return (await find.allByCssSelector('.kbnDocViewer__fieldName')).length === 4; }); - await PageObjects.discover.findFieldByNameInDocViewer('.sr'); + await discover.findFieldByNameInDocViewer('.sr'); await retry.waitFor('second updates', async () => { return (await find.allByCssSelector('.kbnDocViewer__fieldName')).length === 2; @@ -80,21 +80,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should be able to search by wildcard', async function () { - await PageObjects.discover.findFieldByNameInDocViewer('relatedContent*image'); + await discover.findFieldByNameInDocViewer('relatedContent*image'); await retry.waitFor('updates', async () => { return (await find.allByCssSelector('.kbnDocViewer__fieldName')).length === 2; }); }); it('should be able to search with spaces as wildcard', async function () { - await PageObjects.discover.findFieldByNameInDocViewer('relatedContent image'); + await discover.findFieldByNameInDocViewer('relatedContent image'); await retry.waitFor('updates', async () => { return (await find.allByCssSelector('.kbnDocViewer__fieldName')).length === 4; }); }); it('should be able to search with fuzzy search (1 typo)', async function () { - await PageObjects.discover.findFieldByNameInDocViewer('rel4tedContent.art'); + await discover.findFieldByNameInDocViewer('rel4tedContent.art'); await retry.waitFor('updates', async () => { return (await find.allByCssSelector('.kbnDocViewer__fieldName')).length === 3; @@ -102,7 +102,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should ignore empty search', async function () { - await PageObjects.discover.findFieldByNameInDocViewer(' '); // only spaces + await discover.findFieldByNameInDocViewer(' '); // only spaces await retry.waitFor('the clear button', async () => { return await testSubjects.exists('clearSearchButton'); @@ -118,22 +118,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('filter by field type', function () { beforeEach(async () => { await dataGrid.clickRowToggle(); - await PageObjects.discover.isShowingDocViewer(); + await discover.isShowingDocViewer(); await retry.waitFor('rendered items', async () => { return (await find.allByCssSelector('.kbnDocViewer__fieldName')).length > 0; }); }); it('should reveal and hide the filter form when the toggle is clicked', async function () { - await PageObjects.discover.openFilterByFieldTypeInDocViewer(); + await discover.openFilterByFieldTypeInDocViewer(); expect(await find.allByCssSelector('[data-test-subj*="typeFilter"]')).to.have.length(6); - await PageObjects.discover.closeFilterByFieldTypeInDocViewer(); + await discover.closeFilterByFieldTypeInDocViewer(); }); it('should filter by field type', async function () { const initialFieldsCount = (await find.allByCssSelector('.kbnDocViewer__fieldName')).length; - await PageObjects.discover.openFilterByFieldTypeInDocViewer(); + await discover.openFilterByFieldTypeInDocViewer(); await testSubjects.click('typeFilter-date'); @@ -157,16 +157,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show filters by type in ES|QL view', async function () { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | limit 10000`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickRowToggle(); - await PageObjects.discover.isShowingDocViewer(); + await discover.isShowingDocViewer(); await retry.waitFor('rendered items', async () => { return (await find.allByCssSelector('.kbnDocViewer__fieldName')).length > 0; }); @@ -179,7 +179,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const pinnedFieldsCount = 1; await dataGrid.togglePinActionInFlyout('agent'); - await PageObjects.discover.openFilterByFieldTypeInDocViewer(); + await discover.openFilterByFieldTypeInDocViewer(); expect(await find.allByCssSelector('[data-test-subj*="typeFilter"]')).to.have.length(6); await testSubjects.click('typeFilter-number'); @@ -195,19 +195,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('hide null values switch - ES|QL mode', function () { beforeEach(async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); const testQuery = 'from logstash-* | sort @timestamp | limit 10000'; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); await dataGrid.clickRowToggle(); - await PageObjects.discover.isShowingDocViewer(); + await discover.isShowingDocViewer(); }); afterEach(async () => { @@ -220,7 +220,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should hide fields with null values ', async function () { - await PageObjects.discover.findFieldByNameInDocViewer('machine'); + await discover.findFieldByNameInDocViewer('machine'); const results = (await find.allByCssSelector('.kbnDocViewer__fieldName')).length; const hideNullValuesSwitch = await testSubjects.find( 'unifiedDocViewerHideNullValuesSwitch' @@ -236,7 +236,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('pinning fields', function () { it('should be able to pin and unpin fields', async function () { await dataGrid.clickRowToggle(); - await PageObjects.discover.isShowingDocViewer(); + await discover.isShowingDocViewer(); await retry.waitFor('rendered items', async () => { return (await find.allByCssSelector('.kbnDocViewer__fieldName')).length > 0; }); diff --git a/test/functional/apps/discover/group3/_drag_drop.ts b/test/functional/apps/discover/group3/_drag_drop.ts index 32d7f8e3bada8..b6ea2186c0ce2 100644 --- a/test/functional/apps/discover/group3/_drag_drop.ts +++ b/test/functional/apps/discover/group3/_drag_drop.ts @@ -13,7 +13,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, header, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'timePicker', @@ -31,65 +31,57 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); afterEach(async () => { await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.savedObjects.cleanStandardList(); await kibanaServer.uiSettings.replace({}); - await PageObjects.unifiedFieldList.cleanSidebarLocalStorage(); + await unifiedFieldList.cleanSidebarLocalStorage(); }); describe('should add fields as columns via drag and drop', function () { it('should support dragging and dropping a field onto the grid', async function () { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '48 available fields. 5 empty fields. 4 meta fields.' ); - expect((await PageObjects.discover.getColumnHeaders()).join(', ')).to.be( - '@timestamp, Document' - ); + expect((await discover.getColumnHeaders()).join(', ')).to.be('@timestamp, Document'); - await PageObjects.discover.dragFieldToTable('extension'); + await discover.dragFieldToTable('extension'); - expect((await PageObjects.discover.getColumnHeaders()).join(', ')).to.be( - '@timestamp, extension' - ); + expect((await discover.getColumnHeaders()).join(', ')).to.be('@timestamp, extension'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ') - ).to.be('extension'); + expect((await unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ')).to.be( + 'extension' + ); }); it('should support dragging and dropping a field onto the grid (with keyboard)', async function () { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '48 available fields. 5 empty fields. 4 meta fields.' ); - expect((await PageObjects.discover.getColumnHeaders()).join(', ')).to.be( - '@timestamp, Document' - ); + expect((await discover.getColumnHeaders()).join(', ')).to.be('@timestamp, Document'); - await PageObjects.discover.dragFieldWithKeyboardToTable('@message'); + await discover.dragFieldWithKeyboardToTable('@message'); - expect((await PageObjects.discover.getColumnHeaders()).join(', ')).to.be( - '@timestamp, @message' - ); + expect((await discover.getColumnHeaders()).join(', ')).to.be('@timestamp, @message'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ') - ).to.be('@message'); + expect((await unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ')).to.be( + '@message' + ); }); }); }); diff --git a/test/functional/apps/discover/group3/_lens_vis.ts b/test/functional/apps/discover/group3/_lens_vis.ts index 6d2788cfd18b3..2577958b03599 100644 --- a/test/functional/apps/discover/group3/_lens_vis.ts +++ b/test/functional/apps/discover/group3/_lens_vis.ts @@ -19,7 +19,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const browser = getService('browser'); const toasts = getService('toasts'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); + const { common, discover, header, timePicker } = getPageObjects([ + 'common', + 'discover', + 'header', + 'timePicker', + ]); const security = getService('security'); const defaultSettings = { defaultIndex: 'logstash-*', @@ -32,28 +37,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const defaultTotalCount = '14,004'; async function checkNoVis(totalCount: string) { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.isChartVisible()).to.be(false); - expect(await PageObjects.discover.getHitCount()).to.be(totalCount); + expect(await discover.isChartVisible()).to.be(false); + expect(await discover.getHitCount()).to.be(totalCount); } async function checkHistogramVis(timespan: string, totalCount: string) { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('xyVisChart'); await testSubjects.existOrFail('unifiedHistogramEditVisualization'); await testSubjects.existOrFail('unifiedHistogramBreakdownSelectorButton'); await testSubjects.existOrFail('unifiedHistogramTimeIntervalSelectorButton'); - expect(await PageObjects.discover.getChartTimespan()).to.be(timespan); - expect(await PageObjects.discover.getHitCount()).to.be(totalCount); + expect(await discover.getChartTimespan()).to.be(timespan); + expect(await discover.getHitCount()).to.be(totalCount); } async function checkESQLHistogramVis(timespan: string, totalCount: string) { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('xyVisChart'); await testSubjects.existOrFail('unifiedHistogramSaveVisualization'); @@ -61,8 +66,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.missingOrFail('unifiedHistogramEditVisualization'); await testSubjects.missingOrFail('unifiedHistogramBreakdownSelectorButton'); await testSubjects.missingOrFail('unifiedHistogramTimeIntervalSelectorButton'); - expect(await PageObjects.discover.getChartTimespan()).to.be(timespan); - expect(await PageObjects.discover.getHitCount()).to.be(totalCount); + expect(await discover.getChartTimespan()).to.be(timespan); + expect(await discover.getHitCount()).to.be(totalCount); } async function openLensEditFlyout() { @@ -112,17 +117,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); it('should show histogram by default', async () => { await checkHistogramVis(defaultTimespan, defaultTotalCount); - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 23:50:13.253' ); @@ -132,7 +137,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const savedSearchTotalCount = '4,756'; await checkHistogramVis(savedSearchTimeSpan, savedSearchTotalCount); - await PageObjects.discover.saveSearch('testDefault'); + await discover.saveSearch('testDefault'); await checkHistogramVis(savedSearchTimeSpan, savedSearchTotalCount); @@ -142,14 +147,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show no histogram for no results view and recover when time range expanded', async () => { - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 19, 2015 @ 00:00:00.000', 'Sep 19, 2015 @ 00:00:00.000' ); - expect(await PageObjects.discover.hasNoResults()).to.be(true); + expect(await discover.hasNoResults()).to.be(true); - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 00:00:00.000' ); @@ -158,9 +163,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'Sep 20, 2015 @ 00:00:00.000 - Sep 20, 2015 @ 00:00:00.000 (interval: Auto - millisecond)', '1' ); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be( - 'histogramForDataView' - ); + expect(await discover.getVisContextSuggestionType()).to.be('histogramForDataView'); }); it('should show no histogram for non-time-based data views and recover for time-based data views', async () => { @@ -170,18 +173,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { hasTimeField: true, changeTimestampField: `--- I don't want to use the time filter ---`, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await checkNoVis(defaultTotalCount); await dataViews.editFromSearchBar({ newName: 'logs', newTimeField: '@timestamp' }); await checkHistogramVis(defaultTimespan, defaultTotalCount); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be( - 'histogramForDataView' - ); + expect(await discover.getVisContextSuggestionType()).to.be('histogramForDataView'); }); it('should show ESQL histogram for ES|QL query', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); await monacoEditor.setCodeEditorValue('from logstash-* | limit 10'); await testSubjects.click('querySubmitButton'); @@ -191,7 +192,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '10' ); - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 00:00:00.000' ); @@ -200,16 +201,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should be able to customize ESQL histogram and save it', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); await monacoEditor.setCodeEditorValue('from logstash-* | limit 10'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await changeVisShape('Line'); - await PageObjects.discover.saveSearch('testCustomESQLHistogram'); + await discover.saveSearch('testCustomESQLHistogram'); await checkESQLHistogramVis( 'Sep 19, 2015 @ 06:31:44.000 - Sep 23, 2015 @ 18:31:44.000', @@ -218,14 +219,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('unifiedHistogramEditFlyoutVisualization'); expect(await getCurrentVisTitle()).to.be('Line'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('histogramForESQL'); + expect(await discover.getVisContextSuggestionType()).to.be('histogramForESQL'); }); it('should be able to load a saved search with custom histogram vis, edit vis and revert changes', async () => { - await PageObjects.discover.loadSavedSearch('testCustomESQLHistogram'); + await discover.loadSavedSearch('testCustomESQLHistogram'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Line'); @@ -240,10 +241,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Line'); @@ -255,10 +256,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should be able to load a saved search with custom histogram vis, edit query and revert changes', async () => { - await PageObjects.discover.loadSavedSearch('testCustomESQLHistogram'); + await discover.loadSavedSearch('testCustomESQLHistogram'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Line'); @@ -273,8 +274,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await monacoEditor.setCodeEditorValue('from logstash-* | limit 100'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Bar'); @@ -283,15 +284,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.existOrFail('unsavedChangesBadge'); expect(await monacoEditor.getCodeEditorValue()).to.be('from logstash-* | limit 100'); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Line'); await testSubjects.existOrFail('xyVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('histogramForESQL'); + expect(await discover.getVisContextSuggestionType()).to.be('histogramForESQL'); await checkESQLHistogramVis(defaultTimespanESQL, '10'); expect(await monacoEditor.getCodeEditorValue()).to.be('from logstash-* | limit 10'); @@ -302,38 +303,38 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await checkESQLHistogramVis(defaultTimespanESQL, '5'); - await PageObjects.discover.chooseLensSuggestion('pie'); + await discover.chooseLensSuggestion('pie'); await testSubjects.existOrFail('unsavedChangesBadge'); expect(await monacoEditor.getCodeEditorValue()).to.contain('averageA'); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Line'); await testSubjects.existOrFail('xyVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('histogramForESQL'); + expect(await discover.getVisContextSuggestionType()).to.be('histogramForESQL'); await checkESQLHistogramVis(defaultTimespanESQL, '10'); expect(await monacoEditor.getCodeEditorValue()).to.be('from logstash-* | limit 10'); }); it('should be able to load a saved search with custom histogram vis and handle invalidations', async () => { - await PageObjects.discover.loadSavedSearch('testCustomESQLHistogram'); + await discover.loadSavedSearch('testCustomESQLHistogram'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Line'); @@ -343,7 +344,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '10' ); expect(await monacoEditor.getCodeEditorValue()).to.be('from logstash-* | limit 10'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('histogramForESQL'); + expect(await discover.getVisContextSuggestionType()).to.be('histogramForESQL'); // now we are changing to a different query to check invalidation logic await monacoEditor.setCodeEditorValue( @@ -351,43 +352,43 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await checkESQLHistogramVis(defaultTimespanESQL, '5'); - await PageObjects.discover.chooseLensSuggestion('pie'); + await discover.chooseLensSuggestion('pie'); await testSubjects.existOrFail('unsavedChangesBadge'); expect(await monacoEditor.getCodeEditorValue()).to.contain('averageA'); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); - await PageObjects.discover.saveSearch('testCustomESQLHistogramInvalidation', true); + await discover.saveSearch('testCustomESQLHistogramInvalidation', true); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); }); it('should be able to load a saved search with custom histogram vis and save new customization', async () => { - await PageObjects.discover.loadSavedSearch('testCustomESQLHistogram'); + await discover.loadSavedSearch('testCustomESQLHistogram'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Line'); @@ -404,11 +405,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await checkESQLHistogramVis(defaultTimespanESQL, '5'); - await PageObjects.discover.chooseLensSuggestion('pie'); + await discover.chooseLensSuggestion('pie'); await testSubjects.existOrFail('unsavedChangesBadge'); expect(await monacoEditor.getCodeEditorValue()).to.contain('averageA'); @@ -417,19 +418,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.existOrFail('partitionVisChart'); // now we customize the vis again - await PageObjects.discover.chooseLensSuggestion('waffle'); + await discover.chooseLensSuggestion('waffle'); expect(await getCurrentVisTitle()).to.be('Waffle'); await testSubjects.existOrFail('partitionVisChart'); await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.discover.saveSearch( - 'testCustomESQLHistogramInvalidationPlusCustomization', - true - ); + await discover.saveSearch('testCustomESQLHistogramInvalidationPlusCustomization', true); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Waffle'); @@ -437,49 +435,49 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Waffle'); await testSubjects.existOrFail('partitionVisChart'); }); it('should be able to customize ESQL vis and save it', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); await monacoEditor.setCodeEditorValue( 'from logstash-* | stats averageB = avg(bytes) by extension' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await checkESQLHistogramVis(defaultTimespanESQL, '5'); - await PageObjects.discover.chooseLensSuggestion('pie'); + await discover.chooseLensSuggestion('pie'); - await PageObjects.discover.saveSearch('testCustomESQLVis'); - await PageObjects.discover.saveSearch('testCustomESQLVisPartition', true); + await discover.saveSearch('testCustomESQLVis'); + await discover.saveSearch('testCustomESQLVisPartition', true); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); }); it('should be able to load a saved search with custom vis, edit query and revert changes', async () => { - await PageObjects.discover.loadSavedSearch('testCustomESQLVisPartition'); + await discover.loadSavedSearch('testCustomESQLVisPartition'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); await testSubjects.missingOrFail('unsavedChangesBadge'); @@ -487,46 +485,46 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await monacoEditor.setCodeEditorValue('from logstash-* | limit 100'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Bar'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('histogramForESQL'); + expect(await discover.getVisContextSuggestionType()).to.be('histogramForESQL'); await checkESQLHistogramVis(defaultTimespanESQL, '100'); await testSubjects.existOrFail('unsavedChangesBadge'); expect(await monacoEditor.getCodeEditorValue()).to.be('from logstash-* | limit 100'); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); expect(await monacoEditor.getCodeEditorValue()).to.contain('averageB'); // should be still Pie after reverting and saving again - await PageObjects.discover.saveSearch('testCustomESQLVisPartition'); + await discover.saveSearch('testCustomESQLVisPartition'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); }); it('should be able to change to an unfamiliar vis type via lens flyout', async () => { - await PageObjects.discover.loadSavedSearch('testCustomESQLVisPartition'); + await discover.loadSavedSearch('testCustomESQLVisPartition'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); @@ -539,41 +537,41 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await getCurrentVisTitle()).to.be('Treemap'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); - await PageObjects.discover.saveSearch('testCustomESQLVisTreemap', true); + await discover.saveSearch('testCustomESQLVisTreemap', true); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Treemap'); await testSubjects.existOrFail('partitionVisChart'); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Treemap'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); await monacoEditor.setCodeEditorValue( 'from logstash-* | stats averageB = avg(bytes) by extension.raw' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Bar'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Treemap'); @@ -581,39 +579,39 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should be able to load a saved search with custom vis, edit vis and revert changes', async () => { - await PageObjects.discover.loadSavedSearch('testCustomESQLVis'); + await discover.loadSavedSearch('testCustomESQLVis'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); await testSubjects.missingOrFail('unsavedChangesBadge'); - await PageObjects.discover.chooseLensSuggestion('waffle'); + await discover.chooseLensSuggestion('waffle'); expect(await getCurrentVisTitle()).to.be('Waffle'); await testSubjects.existOrFail('partitionVisChart'); await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); - await PageObjects.discover.chooseLensSuggestion('barVerticalStacked'); + await discover.chooseLensSuggestion('barVerticalStacked'); await changeVisShape('Line'); await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.discover.saveUnsavedChanges(); + await discover.saveUnsavedChanges(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await getCurrentVisTitle()).to.be('Line'); @@ -621,48 +619,48 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should close lens flyout on revert changes', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); await monacoEditor.setCodeEditorValue( 'from logstash-* | stats averageB = avg(bytes) by extension' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await getCurrentVisTitle()).to.be('Bar'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); await testSubjects.missingOrFail('unsavedChangesBadge'); - await PageObjects.discover.chooseLensSuggestion('treemap'); + await discover.chooseLensSuggestion('treemap'); expect(await getCurrentVisTitle()).to.be('Treemap'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); - await PageObjects.discover.saveSearch('testCustomESQLVisRevert'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch('testCustomESQLVisRevert'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); - await PageObjects.discover.chooseLensSuggestion('pie'); + await discover.chooseLensSuggestion('pie'); expect(await getCurrentVisTitle()).to.be('Pie'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); await openLensEditFlyout(); await testSubjects.existOrFail('lnsEditOnFlyFlyout'); await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.discover.revertUnsavedChanges(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.revertUnsavedChanges(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); await testSubjects.missingOrFail('lnsEditOnFlyFlyout'); // it should close the flyout expect(await getCurrentVisTitle()).to.be('Treemap'); await testSubjects.existOrFail('partitionVisChart'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); }); }); } diff --git a/test/functional/apps/discover/group3/_panels_toggle.ts b/test/functional/apps/discover/group3/_panels_toggle.ts index 7b9e431bf080a..a789e6f92c2fd 100644 --- a/test/functional/apps/discover/group3/_panels_toggle.ts +++ b/test/functional/apps/discover/group3/_panels_toggle.ts @@ -16,8 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const monacoEditor = getService('monacoEditor'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects([ - 'settings', + const { common, discover, header, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', @@ -54,20 +53,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { isChartAvailable: boolean; totalHits: string; }) { - expect(await PageObjects.discover.getHitCount()).to.be(totalHits); + expect(await discover.getHitCount()).to.be(totalHits); if (shouldSidebarBeOpen) { - expect(await PageObjects.discover.isSidebarPanelOpen()).to.be(true); + expect(await discover.isSidebarPanelOpen()).to.be(true); await testSubjects.existOrFail('unifiedFieldListSidebar__toggle-collapse'); await testSubjects.missingOrFail('dscShowSidebarButton'); } else { - expect(await PageObjects.discover.isSidebarPanelOpen()).to.be(false); + expect(await discover.isSidebarPanelOpen()).to.be(false); await testSubjects.missingOrFail('unifiedFieldListSidebar__toggle-collapse'); await testSubjects.existOrFail('dscShowSidebarButton'); } if (isChartAvailable) { - expect(await PageObjects.discover.isChartVisible()).to.be(shouldHistogramBeOpen); + expect(await discover.isChartVisible()).to.be(shouldHistogramBeOpen); if (shouldHistogramBeOpen) { await testSubjects.existOrFail('dscPanelsToggleInHistogram'); await testSubjects.existOrFail('dscHideHistogramButton'); @@ -82,7 +81,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.missingOrFail('dscHideHistogramButton'); } } else { - expect(await PageObjects.discover.isChartVisible()).to.be(false); + expect(await discover.isChartVisible()).to.be(false); await testSubjects.missingOrFail('dscPanelsToggleInHistogram'); await testSubjects.missingOrFail('dscHideHistogramButton'); await testSubjects.missingOrFail('dscShowHistogramButton'); @@ -110,7 +109,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { totalHits, }); - await PageObjects.discover.closeSidebar(); + await discover.closeSidebar(); await checkSidebarAndHistogram({ shouldSidebarBeOpen: false, @@ -119,7 +118,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { totalHits, }); - await PageObjects.discover.openSidebar(); + await discover.openSidebar(); await checkSidebarAndHistogram({ shouldSidebarBeOpen: true, @@ -138,7 +137,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { totalHits, }); - await PageObjects.discover.closeHistogramPanel(); + await discover.closeHistogramPanel(); await checkSidebarAndHistogram({ shouldSidebarBeOpen: true, @@ -147,7 +146,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { totalHits, }); - await PageObjects.discover.openHistogramPanel(); + await discover.openHistogramPanel(); await checkSidebarAndHistogram({ shouldSidebarBeOpen: true, @@ -165,8 +164,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { totalHits, }); - await PageObjects.discover.closeSidebar(); - await PageObjects.discover.closeHistogramPanel(); + await discover.closeSidebar(); + await discover.closeHistogramPanel(); await checkSidebarAndHistogram({ shouldSidebarBeOpen: false, @@ -175,8 +174,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { totalHits, }); - await PageObjects.discover.openSidebar(); - await PageObjects.discover.openHistogramPanel(); + await discover.openSidebar(); + await discover.openHistogramPanel(); await checkSidebarAndHistogram({ shouldSidebarBeOpen: true, @@ -190,12 +189,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('time based data view', function () { before(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); }); checkPanelsToggle({ isChartAvailable: true, totalHits: '14,004' }); @@ -203,17 +202,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('non-time based data view', function () { before(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); await dataViews.createFromSearchBar({ name: 'log*', adHoc: true, hasTimeField: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); }); checkPanelsToggle({ isChartAvailable: false, totalHits: '14,004' }); @@ -221,12 +220,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('ES|QL with histogram chart', function () { before(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await discover.selectTextBaseLang(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); }); checkPanelsToggle({ isChartAvailable: true, totalHits: '10' }); @@ -234,17 +233,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('ES|QL with aggs chart', function () { before(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.selectTextBaseLang(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await discover.selectTextBaseLang(); await monacoEditor.setCodeEditorValue( 'from logstash-* | stats avg(bytes) by extension | limit 100' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); }); checkPanelsToggle({ isChartAvailable: true, totalHits: '5' }); @@ -252,18 +251,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('ES|QL without a time field', function () { before(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); await dataViews.createFromSearchBar({ name: 'log*', adHoc: true, hasTimeField: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.waitUntilSearchingHasFinished(); + await discover.selectTextBaseLang(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); }); checkPanelsToggle({ isChartAvailable: false, totalHits: '10' }); diff --git a/test/functional/apps/discover/group3/_request_counts.ts b/test/functional/apps/discover/group3/_request_counts.ts index 449fcca90adfb..8a029928af0cb 100644 --- a/test/functional/apps/discover/group3/_request_counts.ts +++ b/test/functional/apps/discover/group3/_request_counts.ts @@ -13,13 +13,11 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, header } = getPageObjects([ 'common', 'discover', 'timePicker', 'header', - 'unifiedSearch', - 'settings', ]); const testSubjects = getService('testSubjects'); const browser = getService('browser'); @@ -40,7 +38,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'bfetch:disable': true, enableESQL: true, }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); after(async () => { @@ -50,8 +48,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); }); const getSearchCount = async (type: 'ese' | 'esql') => { @@ -64,8 +62,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; const waitForLoadingToFinish = async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await header.waitUntilLoadingHasFinished(); + await discover.waitForDocTableLoadingComplete(); await elasticChart.canvasExists(); }; @@ -124,7 +122,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it(`should send ${expectedRequests} requests (documents + chart) when changing the time range`, async () => { await expectSearches(type, expectedRequests, async () => { - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 21, 2015 @ 06:31:44.000', 'Sep 23, 2015 @ 00:00:00.000' ); @@ -134,7 +132,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it(`should send ${savedSearchesRequests} requests for saved search changes`, async () => { await setQuery(query1); await queryBar.clickQuerySubmitButton(); - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 21, 2015 @ 06:31:44.000', 'Sep 23, 2015 @ 00:00:00.000' ); @@ -143,14 +141,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // https://github.com/elastic/kibana/issues/165192 // creating the saved search await expectSearches(type, savedSearchesRequests ?? expectedRequests, async () => { - await PageObjects.discover.saveSearch(savedSearch); + await discover.saveSearch(savedSearch); }); // resetting the saved search await setQuery(query2); await queryBar.clickQuerySubmitButton(); await waitForLoadingToFinish(); await expectSearches(type, expectedRequests, async () => { - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); }); // clearing the saved search await expectSearches('ese', savedSearchesRequests ?? expectedRequests, async () => { @@ -160,7 +158,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // loading the saved search // TODO: https://github.com/elastic/kibana/issues/165192 await expectSearches(type, savedSearchesRequests ?? expectedRequests, async () => { - await PageObjects.discover.loadSavedSearch(savedSearch); + await discover.loadSavedSearch(savedSearch); }); }); }; @@ -178,10 +176,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it(`should send 2 requests (documents + chart) when toggling the chart visibility`, async () => { await expectSearches(type, 2, async () => { - await PageObjects.discover.toggleChartVisibility(); + await discover.toggleChartVisibility(); }); await expectSearches(type, 2, async () => { - await PageObjects.discover.toggleChartVisibility(); + await discover.toggleChartVisibility(); }); }); @@ -197,31 +195,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should send 2 requests (documents + chart) when sorting', async () => { await expectSearches(type, 2, async () => { - await PageObjects.discover.clickFieldSort('@timestamp', 'Sort Old-New'); + await discover.clickFieldSort('@timestamp', 'Sort Old-New'); }); }); it('should send 2 requests (documents + chart) when changing to a breakdown field without an other bucket', async () => { await expectSearches(type, 2, async () => { - await PageObjects.discover.chooseBreakdownField('type'); + await discover.chooseBreakdownField('type'); }); }); it('should send 3 requests (documents + chart + other bucket) when changing to a breakdown field with an other bucket', async () => { await expectSearches(type, 3, async () => { - await PageObjects.discover.chooseBreakdownField('extension.raw'); + await discover.chooseBreakdownField('extension.raw'); }); }); it('should send 2 requests (documents + chart) when changing the chart interval', async () => { await expectSearches(type, 2, async () => { - await PageObjects.discover.setChartInterval('Day'); + await discover.setChartInterval('Day'); }); }); it('should send 2 requests (documents + chart) when changing the data view', async () => { await expectSearches(type, 2, async () => { - await PageObjects.discover.selectIndexPattern('long-window-logstash-*'); + await discover.selectIndexPattern('long-window-logstash-*'); }); }); }); diff --git a/test/functional/apps/discover/group4/_adhoc_data_views.ts b/test/functional/apps/discover/group4/_adhoc_data_views.ts index 33dc3557fa247..8175e1f139293 100644 --- a/test/functional/apps/discover/group4/_adhoc_data_views.ts +++ b/test/functional/apps/discover/group4/_adhoc_data_views.ts @@ -22,25 +22,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const queryBar = getService('queryBar'); const testSubjects = getService('testSubjects'); const browser = getService('browser'); - const PageObjects = getPageObjects([ - 'common', - 'unifiedSearch', - 'discover', - 'timePicker', - 'settings', - 'header', - 'context', - 'dashboard', - 'unifiedFieldList', - ]); + const { common, discover, timePicker, header, context, dashboard, unifiedFieldList } = + getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'header', + 'context', + 'dashboard', + 'unifiedFieldList', + ]); const find = getService('find'); const security = getService('security'); const dataViews = getService('dataViews'); const addSearchToDashboard = async (name: string) => { await dashboardAddPanel.addSavedSearch(name); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); }; describe('adhoc data views', function () { @@ -49,8 +48,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); after(async () => { @@ -64,26 +63,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { adHoc: true, hasTimeField: true, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const first = await PageObjects.discover.getCurrentDataViewId(); + await discover.waitUntilSearchingHasFinished(); + const first = await discover.getCurrentDataViewId(); - await PageObjects.discover.addRuntimeField( - '_bytes-runtimefield', - `emit(doc["bytes"].value.toString())` - ); - await PageObjects.unifiedFieldList.clickFieldListItemToggle('_bytes-runtimefield'); + await discover.addRuntimeField('_bytes-runtimefield', `emit(doc["bytes"].value.toString())`); + await unifiedFieldList.clickFieldListItemToggle('_bytes-runtimefield'); - const second = await PageObjects.discover.getCurrentDataViewId(); + const second = await discover.getCurrentDataViewId(); expect(first).not.to.equal(second); // navigate to context view await dataGrid.clickRowToggle({ rowIndex: 0 }); const [, surrDocs] = await dataGrid.getRowActions({ rowIndex: 0 }); await surrDocs.click(); - await PageObjects.context.waitUntilContextLoadingHasFinished(); + await context.waitUntilContextLoadingHasFinished(); await testSubjects.click('~breadcrumb & ~first'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect(await dataViews.getSelectedName()).to.be('logstash*'); @@ -91,10 +87,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.clickRowToggle({ rowIndex: 0 }); const [singleView] = await dataGrid.getRowActions({ rowIndex: 0 }); await singleView.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('~breadcrumb & ~first'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect(await dataViews.getSelectedName()).to.be('logstash*'); }); @@ -107,36 +103,36 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); expect(await filterBar.hasFilter('nestedField.child', 'nestedValue')).to.be(true); await retry.try(async function () { - expect(await PageObjects.discover.getHitCount()).to.be('1'); + expect(await discover.getHitCount()).to.be('1'); }); await filterBar.removeFilter('nestedField.child'); await queryBar.setQuery('test'); await queryBar.submitQuery(); - await retry.try(async () => expect(await PageObjects.discover.getHitCount()).to.be('22')); + await retry.try(async () => expect(await discover.getHitCount()).to.be('22')); await queryBar.clearQuery(); await queryBar.submitQuery(); }); it('should not update data view id when saving search first time', async () => { - const prevDataViewId = await PageObjects.discover.getCurrentDataViewId(); + const prevDataViewId = await discover.getCurrentDataViewId(); - await PageObjects.discover.saveSearch('logstash*-ss'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.saveSearch('logstash*-ss'); + await header.waitUntilLoadingHasFinished(); - const newDataViewId = await PageObjects.discover.getCurrentDataViewId(); + const newDataViewId = await discover.getCurrentDataViewId(); expect(prevDataViewId).to.equal(newDataViewId); }); it('should update data view id when saving new search copy', async () => { - const prevDataViewId = await PageObjects.discover.getCurrentDataViewId(); + const prevDataViewId = await discover.getCurrentDataViewId(); - await PageObjects.discover.saveSearch('logstash*-ss-new', true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.saveSearch('logstash*-ss-new', true); + await header.waitUntilLoadingHasFinished(); - const newDataViewId = await PageObjects.discover.getCurrentDataViewId(); + const newDataViewId = await discover.getCurrentDataViewId(); expect(prevDataViewId).not.to.equal(newDataViewId); }); @@ -147,44 +143,41 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { adHoc: true, hasTimeField: true, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const prevDataViewId = await PageObjects.discover.getCurrentDataViewId(); + await discover.waitUntilSearchingHasFinished(); + const prevDataViewId = await discover.getCurrentDataViewId(); // trigger data view id update - await PageObjects.discover.addRuntimeField( - '_bytes-runtimefield', - `emit(doc["bytes"].value.toString())` - ); - await PageObjects.unifiedFieldList.clickFieldListItemToggle('_bytes-runtimefield'); - const newDataViewId = await PageObjects.discover.getCurrentDataViewId(); + await discover.addRuntimeField('_bytes-runtimefield', `emit(doc["bytes"].value.toString())`); + await unifiedFieldList.clickFieldListItemToggle('_bytes-runtimefield'); + const newDataViewId = await discover.getCurrentDataViewId(); expect(newDataViewId).not.to.equal(prevDataViewId); // save first search - await PageObjects.discover.saveSearch('logst*-ss-_bytes-runtimefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.saveSearch('logst*-ss-_bytes-runtimefield'); + await header.waitUntilLoadingHasFinished(); // remove field and create with the same name, but different value - await PageObjects.unifiedFieldList.clickFieldListItemRemove('_bytes-runtimefield'); - await PageObjects.discover.removeField('_bytes-runtimefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove('_bytes-runtimefield'); + await discover.removeField('_bytes-runtimefield'); + await header.waitUntilLoadingHasFinished(); // trigger data view id update - await PageObjects.discover.addRuntimeField( + await discover.addRuntimeField( '_bytes-runtimefield', `emit((doc["bytes"].value * 2).toString())` ); - await PageObjects.unifiedFieldList.clickFieldListItemToggle('_bytes-runtimefield'); + await unifiedFieldList.clickFieldListItemToggle('_bytes-runtimefield'); // save second search - await PageObjects.discover.saveSearch('logst*-ss-_bytes-runtimefield-updated', true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.saveSearch('logst*-ss-_bytes-runtimefield-updated', true); + await header.waitUntilLoadingHasFinished(); // open searches on dashboard - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await filterBar.ensureFieldEditorModalIsClosed(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await addSearchToDashboard('logst*-ss-_bytes-runtimefield'); await addSearchToDashboard('logst*-ss-_bytes-runtimefield-updated'); @@ -208,35 +201,35 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { if (await testSubjects.exists('confirmModalConfirmButton')) { await testSubjects.click('confirmModalConfirmButton'); } - await PageObjects.context.waitUntilContextLoadingHasFinished(); + await context.waitUntilContextLoadingHasFinished(); // open saved search await testSubjects.click('~breadcrumb & ~first'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const savedSearch = await find.byCssSelector(`[data-test-subj="breadcrumb last"]`); const savedSearchName = await savedSearch.getVisibleText(); expect(savedSearchName).to.be.equal('logst*-ss-_bytes-runtimefield'); // test the header now - const header = await dataGrid.getHeaderFields(); - expect(header.join(' ')).to.have.string('_bytes-runtimefield'); + const headerFields = await dataGrid.getHeaderFields(); + expect(headerFields.join(' ')).to.have.string('_bytes-runtimefield'); }); it('should update id after data view field edit', async () => { - await PageObjects.discover.loadSavedSearch('logst*-ss-_bytes-runtimefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.loadSavedSearch('logst*-ss-_bytes-runtimefield'); + await header.waitUntilLoadingHasFinished(); - const prevDataViewId = await PageObjects.discover.getCurrentDataViewId(); + const prevDataViewId = await discover.getCurrentDataViewId(); // trigger data view id update await dataGrid.clickEditField('_bytes-runtimefield'); await fieldEditor.setName('_bytes-runtimefield-edited', true); await fieldEditor.save(); await fieldEditor.confirmSave(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - const newDataViewId = await PageObjects.discover.getCurrentDataViewId(); + const newDataViewId = await discover.getCurrentDataViewId(); expect(prevDataViewId).not.to.equal(newDataViewId); }); @@ -246,32 +239,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { adHoc: true, hasTimeField: true, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await filterBar.addFilter({ field: 'nestedField.child', operation: 'is', value: 'nestedValue', }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await filterBar.addFilter({ field: 'extension', operation: 'is', value: 'jpg' }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - const first = await PageObjects.discover.getCurrentDataViewId(); + const first = await discover.getCurrentDataViewId(); // trigger data view id update - await PageObjects.discover.addRuntimeField( + await discover.addRuntimeField( '_bytes-runtimefield', `emit((doc["bytes"].value * 2).toString())` ); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - const second = await PageObjects.discover.getCurrentDataViewId(); + const second = await discover.getCurrentDataViewId(); expect(first).not.equal(second); await toasts.dismissAll(); await browser.goBack(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const [firstToast, secondToast] = await toasts.getAll(); diff --git a/test/functional/apps/discover/group4/_chart_hidden.ts b/test/functional/apps/discover/group4/_chart_hidden.ts index 5a9c22501a1c6..f0b7a151dd084 100644 --- a/test/functional/apps/discover/group4/_chart_hidden.ts +++ b/test/functional/apps/discover/group4/_chart_hidden.ts @@ -15,7 +15,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const security = getService('security'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker', 'dashboard']); + const { common, discover, header, timePicker, dashboard } = getPageObjects([ + 'common', + 'discover', + 'header', + 'timePicker', + 'dashboard', + ]); const defaultSettings = { defaultIndex: 'logstash-*', @@ -31,8 +37,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); after(async () => { @@ -40,35 +46,35 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('shows chart by default', async function () { - expect(await PageObjects.discover.isChartVisible()).to.be(true); + expect(await discover.isChartVisible()).to.be(true); }); it('hiding the chart persists the setting', async function () { - await PageObjects.discover.toggleChartVisibility(); - expect(await PageObjects.discover.isChartVisible()).to.be(false); + await discover.toggleChartVisibility(); + expect(await discover.isChartVisible()).to.be(false); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.navigateToApp(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); + await header.waitUntilLoadingHasFinished(); - expect(await PageObjects.discover.isChartVisible()).to.be(false); + expect(await discover.isChartVisible()).to.be(false); }); it('persists hidden chart option on the saved search ', async function () { const savedSearchTitle = 'chart hidden'; - await PageObjects.discover.saveSearch(savedSearchTitle); + await discover.saveSearch(savedSearchTitle); - await PageObjects.discover.toggleChartVisibility(); - expect(await PageObjects.discover.isChartVisible()).to.be(true); + await discover.toggleChartVisibility(); + expect(await discover.isChartVisible()).to.be(true); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect(await PageObjects.discover.isChartVisible()).to.be(true); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); + await header.waitUntilLoadingHasFinished(); + expect(await discover.isChartVisible()).to.be(true); - await PageObjects.discover.loadSavedSearch(savedSearchTitle); - expect(await PageObjects.discover.isChartVisible()).to.be(false); + await discover.loadSavedSearch(savedSearchTitle); + expect(await discover.isChartVisible()).to.be(false); }); }); } diff --git a/test/functional/apps/discover/group4/_context_encoded_url_params.ts b/test/functional/apps/discover/group4/_context_encoded_url_params.ts index 018ece69ed849..052c96de30b6e 100644 --- a/test/functional/apps/discover/group4/_context_encoded_url_params.ts +++ b/test/functional/apps/discover/group4/_context_encoded_url_params.ts @@ -16,14 +16,20 @@ const customDocIdParam = '1+1=2/&?#'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const dataGrid = getService('dataGrid'); const security = getService('security'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'settings', 'header']); + const { common, discover, timePicker, settings, header } = getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'settings', + 'header', + ]); const testSubjects = getService('testSubjects'); const es = getService('es'); describe('encoded URL params in context page', () => { before(async function () { await security.testUser.setRoles(['kibana_admin', 'context_encoded_param']); - await PageObjects.common.navigateToApp('settings'); + await common.navigateToApp('settings'); await es.transport.request({ path: `/_bulk`, method: 'PUT', @@ -32,20 +38,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { { '@timestamp': '2015-09-21T09:30:23', name: 'Dmitry' }, ], }); - await PageObjects.settings.createIndexPattern( + await settings.createIndexPattern( 'context_encoded_param', '@timestamp', true, customDataViewIdParam ); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); it('should navigate correctly', async () => { - await PageObjects.discover.selectIndexPattern('context_encoded_param'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await discover.selectIndexPattern('context_encoded_param'); + await header.waitUntilLoadingHasFinished(); + await discover.waitForDocTableLoadingComplete(); // navigate to the context view await dataGrid.clickRowToggle({ rowIndex: 0 }); @@ -54,7 +60,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { rowIndex: 0, }); await surroundingActionEl.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const headerElement = await testSubjects.find('contextDocumentSurroundingHeader'); diff --git a/test/functional/apps/discover/group4/_data_view_edit.ts b/test/functional/apps/discover/group4/_data_view_edit.ts index 0d2760e0a0048..c0c5216010191 100644 --- a/test/functional/apps/discover/group4/_data_view_edit.ts +++ b/test/functional/apps/discover/group4/_data_view_edit.ts @@ -18,12 +18,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, unifiedFieldList } = getPageObjects([ 'common', - 'unifiedSearch', 'discover', 'timePicker', - 'dashboard', 'unifiedFieldList', ]); @@ -33,9 +31,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setCommonlyUsedTime('This_week'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); + await timePicker.setCommonlyUsedTime('This_week'); }); after(async () => { @@ -81,11 +79,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { hasTimeField: true, }); await dataViews.waitForSwitcherToBe(`${initialPattern}*`); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.discover.getHitCountInt()).to.be(2); - expect((await PageObjects.unifiedFieldList.getAllFieldNames()).length).to.be(3); + expect(await discover.getHitCountInt()).to.be(2); + expect((await unifiedFieldList.getAllFieldNames()).length).to.be(3); }); it('create saved data view', async function () { @@ -95,14 +93,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { adHoc: false, hasTimeField: true, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.try(async () => { - expect(await PageObjects.discover.getHitCountInt()).to.be(1); + expect(await discover.getHitCountInt()).to.be(1); }); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - expect((await PageObjects.unifiedFieldList.getAllFieldNames()).length).to.be(2); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + expect((await unifiedFieldList.getAllFieldNames()).length).to.be(2); }); it('update data view with a different time field', async function () { @@ -129,12 +127,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } await dataViews.editFromSearchBar({ newName: updatedPattern, newTimeField: 'timestamp' }); await retry.try(async () => { - expect(await PageObjects.discover.getHitCountInt()).to.be(3); + expect(await discover.getHitCountInt()).to.be(3); }); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - expect((await PageObjects.unifiedFieldList.getAllFieldNames()).length).to.be(3); - expect(await PageObjects.discover.isChartVisible()).to.be(true); - expect(await PageObjects.timePicker.timePickerExists()).to.be(true); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + expect((await unifiedFieldList.getAllFieldNames()).length).to.be(3); + expect(await discover.isChartVisible()).to.be(true); + expect(await timePicker.timePickerExists()).to.be(true); }); it('update data view with no time field', async function () { @@ -142,12 +140,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { newTimeField: "--- I don't want to use the time filter ---", }); await retry.try(async () => { - expect(await PageObjects.discover.getHitCountInt()).to.be(4); + expect(await discover.getHitCountInt()).to.be(4); }); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - expect((await PageObjects.unifiedFieldList.getAllFieldNames()).length).to.be(3); - expect(await PageObjects.discover.isChartVisible()).to.be(false); - expect(await PageObjects.timePicker.timePickerExists()).to.be(false); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + expect((await unifiedFieldList.getAllFieldNames()).length).to.be(3); + expect(await discover.isChartVisible()).to.be(false); + expect(await timePicker.timePickerExists()).to.be(false); }); }); } diff --git a/test/functional/apps/discover/group4/_date_nested.ts b/test/functional/apps/discover/group4/_date_nested.ts index b2ba884e48f1f..215ad2b26af44 100644 --- a/test/functional/apps/discover/group4/_date_nested.ts +++ b/test/functional/apps/discover/group4/_date_nested.ts @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common', 'timePicker', 'discover']); + const { common, discover } = getPageObjects(['common', 'discover']); const security = getService('security'); const kibanaServer = getService('kibanaServer'); @@ -22,7 +22,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'test/functional/fixtures/kbn_archiver/date_nested.json' ); await security.testUser.setRoles(['kibana_admin', 'kibana_date_nested']); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async function unloadMakelogs() { @@ -32,9 +32,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show an error message', async function () { - await PageObjects.discover.selectIndexPattern('date-nested'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.showsErrorCallout(); + await discover.selectIndexPattern('date-nested'); + await discover.waitUntilSearchingHasFinished(); + await discover.showsErrorCallout(); }); }); } diff --git a/test/functional/apps/discover/group4/_discover_fields_api.ts b/test/functional/apps/discover/group4/_discover_fields_api.ts index 96c6cb4c174d0..dd10c4020a87d 100644 --- a/test/functional/apps/discover/group4/_discover_fields_api.ts +++ b/test/functional/apps/discover/group4/_discover_fields_api.ts @@ -16,10 +16,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const dataGrid = getService('dataGrid'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, settings, unifiedFieldList } = getPageObjects([ 'common', 'discover', - 'header', 'timePicker', 'settings', 'unifiedFieldList', @@ -37,8 +36,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); after(async () => { @@ -47,55 +46,55 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should correctly display documents', async function () { log.debug('check if Document title exists in the grid'); - expect(await PageObjects.discover.getDocHeader()).to.have.string('Document'); - const rowData = await PageObjects.discover.getDocTableIndex(1); + expect(await discover.getDocHeader()).to.have.string('Document'); + const rowData = await discover.getDocTableIndex(1); log.debug('check the newest doc timestamp in UTC (check diff timezone in last test)'); expect(rowData.startsWith('Sep 22, 2015 @ 23:50:13.253')).to.be.ok(); const expectedHitCount = '14,004'; await retry.try(async function () { - expect(await PageObjects.discover.getHitCount()).to.be(expectedHitCount); + expect(await discover.getHitCount()).to.be(expectedHitCount); }); }); it('adding a column removes a default column', async function () { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('_score'); - expect(await PageObjects.discover.getDocHeader()).to.have.string('_score'); - expect(await PageObjects.discover.getDocHeader()).not.to.have.string('Document'); + await unifiedFieldList.clickFieldListItemAdd('_score'); + expect(await discover.getDocHeader()).to.have.string('_score'); + expect(await discover.getDocHeader()).not.to.have.string('Document'); }); it('removing a column adds a default column', async function () { - await PageObjects.unifiedFieldList.clickFieldListItemRemove('_score'); - expect(await PageObjects.discover.getDocHeader()).not.to.have.string('_score'); - expect(await PageObjects.discover.getDocHeader()).to.have.string('Document'); + await unifiedFieldList.clickFieldListItemRemove('_score'); + expect(await discover.getDocHeader()).not.to.have.string('_score'); + expect(await discover.getDocHeader()).to.have.string('Document'); }); it('displays _source viewer in doc viewer', async function () { await dataGrid.clickRowToggle(); - await PageObjects.discover.isShowingDocViewer(); - await PageObjects.discover.clickDocViewerTab('doc_view_source'); - await PageObjects.discover.expectSourceViewerToExist(); + await discover.isShowingDocViewer(); + await discover.clickDocViewerTab('doc_view_source'); + await discover.expectSourceViewerToExist(); }); it('switches to _source column when fields API is no longer used', async function () { - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSettings(); - await PageObjects.settings.toggleAdvancedSettingCheckbox('discover:searchFieldsFromSource'); + await settings.navigateTo(); + await settings.clickKibanaSettings(); + await settings.toggleAdvancedSettingCheckbox('discover:searchFieldsFromSource'); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); - expect(await PageObjects.discover.getDocHeader()).to.have.string('Document'); + expect(await discover.getDocHeader()).to.have.string('Document'); }); it('switches to Document column when fields API is used', async function () { - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSettings(); - await PageObjects.settings.toggleAdvancedSettingCheckbox('discover:searchFieldsFromSource'); + await settings.navigateTo(); + await settings.clickKibanaSettings(); + await settings.toggleAdvancedSettingCheckbox('discover:searchFieldsFromSource'); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); - expect(await PageObjects.discover.getDocHeader()).to.have.string('Document'); + expect(await discover.getDocHeader()).to.have.string('Document'); }); }); } diff --git a/test/functional/apps/discover/group4/_document_comparison.ts b/test/functional/apps/discover/group4/_document_comparison.ts index 6298be89817b9..1138150bcdcd5 100644 --- a/test/functional/apps/discover/group4/_document_comparison.ts +++ b/test/functional/apps/discover/group4/_document_comparison.ts @@ -12,7 +12,12 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'unifiedFieldList']); + const { common, discover, timePicker, unifiedFieldList } = getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'unifiedFieldList', + ]); const kibanaServer = getService('kibanaServer'); const security = getService('security'); const dataGrid = getService('dataGrid'); @@ -36,9 +41,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('data view mode', () => { before(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); + await discover.waitUntilSearchingHasFinished(); }); runComparisonTests({ @@ -69,12 +74,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('ES|QL mode', () => { before(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.selectTextBaseLang(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); + await discover.selectTextBaseLang(); await monacoEditor.setCodeEditorValue('from logstash-* | sort @timestamp desc | limit 10'); await testSubjects.click('querySubmitButton'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); runComparisonTests({ @@ -137,10 +142,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(fieldNames.slice(0, fullFieldNames.length)).to.eql(fullFieldNames); await dataGrid.openComparisonSettingsMenu(); expect(await dataGrid.showAllFieldsSwitchExists()).to.be(false); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@message'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('agent'); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('@message'); + await unifiedFieldList.clickFieldListItemAdd('agent'); fieldNames = await dataGrid.getComparisonFieldNames(); expect(fieldNames).have.length(selectedFieldNames.length); expect(fieldNames).to.eql(selectedFieldNames); @@ -257,7 +262,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should allow exiting comparison mode', async () => { await dataGrid.exitComparisonMode(); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await discover.waitForDocTableLoadingComplete(); }); } } diff --git a/test/functional/apps/discover/group4/_field_list_new_fields.ts b/test/functional/apps/discover/group4/_field_list_new_fields.ts index 02274ecd25ecf..391d31f91d877 100644 --- a/test/functional/apps/discover/group4/_field_list_new_fields.ts +++ b/test/functional/apps/discover/group4/_field_list_new_fields.ts @@ -18,7 +18,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const queryBar = getService('queryBar'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'unifiedFieldList']); + const { common, discover, timePicker, unifiedFieldList } = getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'unifiedFieldList', + ]); describe('Field list new fields in background handling', function () { before(async () => { @@ -26,8 +31,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setCommonlyUsedTime('This_week'); + await common.navigateToApp('discover'); + await timePicker.setCommonlyUsedTime('This_week'); }); after(async () => { @@ -60,11 +65,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { hasTimeField: true, }); await dataViews.waitForSwitcherToBe(`${initialPattern}*`); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.discover.getHitCountInt()).to.be(1); - expect(await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).to.eql([ + expect(await discover.getHitCountInt()).to.be(1); + expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.eql([ '@timestamp', 'a', ]); @@ -80,11 +85,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.waitFor('the new record was found', async () => { await queryBar.submitQuery(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - return (await PageObjects.discover.getHitCountInt()) === 2; + await unifiedFieldList.waitUntilSidebarHasLoaded(); + return (await discover.getHitCountInt()) === 2; }); - expect(await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).to.eql([ + expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.eql([ '@timestamp', 'a', 'b', @@ -108,11 +113,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { hasTimeField: true, }); await dataViews.waitForSwitcherToBe(`${initialPattern}*`); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.discover.getHitCountInt()).to.be(1); - expect(await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).to.eql([ + expect(await discover.getHitCountInt()).to.be(1); + expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.eql([ '@timestamp', 'a', ]); @@ -141,11 +146,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.waitFor('the new record was found', async () => { await queryBar.submitQuery(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - return (await PageObjects.discover.getHitCountInt()) === 2; + await unifiedFieldList.waitUntilSidebarHasLoaded(); + return (await discover.getHitCountInt()) === 2; }); - expect(await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).to.eql([ + expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.eql([ '@timestamp', 'a', ]); diff --git a/test/functional/apps/discover/group5/_field_data.ts b/test/functional/apps/discover/group5/_field_data.ts index 72f0727d6876b..c155e679ac524 100644 --- a/test/functional/apps/discover/group5/_field_data.ts +++ b/test/functional/apps/discover/group5/_field_data.ts @@ -17,11 +17,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const queryBar = getService('queryBar'); const browser = getService('browser'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, unifiedFieldList } = getPageObjects([ 'common', - 'header', 'discover', - 'visualize', 'timePicker', 'unifiedFieldList', ]); @@ -36,8 +34,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { defaultIndex: 'logstash-*', 'discover:searchFieldsFromSource': true, }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); describe('field data', function () { it('search php should show the correct hit count', async function () { @@ -45,7 +43,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.try(async function () { await queryBar.setQuery('php'); await queryBar.submitQuery(); - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be(expectedHitCount); }); }); @@ -54,11 +52,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // marks is the style that highlights the text in yellow await queryBar.setQuery('php'); await queryBar.submitQuery(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - const marks = await PageObjects.discover.getMarks(); + await unifiedFieldList.clickFieldListItemAdd('extension'); + const marks = await discover.getMarks(); expect(marks.length).to.be.greaterThan(0); expect(marks.indexOf('php')).to.be(0); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('extension'); + await unifiedFieldList.clickFieldListItemRemove('extension'); }); it('search type:apache should show the correct hit count', async function () { @@ -66,7 +64,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await queryBar.setQuery('type:apache'); await queryBar.submitQuery(); await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be(expectedHitCount); }); }); @@ -77,8 +75,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'whitespace but "(" found.'; await queryBar.setQuery('xxx(yyy))'); await queryBar.submitQuery(); - await PageObjects.discover.showsErrorCallout(); - const message = await PageObjects.discover.getDiscoverErrorMessage(); + await discover.showsErrorCallout(); + const message = await discover.getDiscoverErrorMessage(); expect(message).to.contain(expectedError); }); @@ -87,19 +85,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await queryBar.submitQuery(); const currentUrl = await browser.getCurrentUrl(); const [, hash] = currentUrl.split('#/'); - await PageObjects.common.navigateToUrl( + await common.navigateToUrl( 'discover', hash.replace('columns:!(_source)', 'columns:!(relatedContent)'), { useActualUrl: true } ); await retry.try(async function tryingForTime() { - expect(await PageObjects.discover.getDocHeader()).to.contain('relatedContent'); + expect(await discover.getDocHeader()).to.contain('relatedContent'); - const field = await PageObjects.discover.getDocTableIndex(1); + const field = await discover.getDocTableIndex(1); expect(field).to.contain('og:description'); }); - const marks = await PageObjects.discover.getMarks(); + const marks = await discover.getMarks(); expect(marks.length).to.be(0); }); }); diff --git a/test/functional/apps/discover/group5/_field_data_with_fields_api.ts b/test/functional/apps/discover/group5/_field_data_with_fields_api.ts index 0fa97db9bfbec..4b301c3d5e946 100644 --- a/test/functional/apps/discover/group5/_field_data_with_fields_api.ts +++ b/test/functional/apps/discover/group5/_field_data_with_fields_api.ts @@ -17,11 +17,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const queryBar = getService('queryBar'); const browser = getService('browser'); - const PageObjects = getPageObjects([ + const { common, header, discover, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'header', 'discover', - 'visualize', 'timePicker', 'unifiedFieldList', ]); @@ -36,8 +35,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { defaultIndex: 'logstash-*', 'discover:searchFieldsFromSource': false, }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); describe('field data', function () { it('search php should show the correct hit count', async function () { @@ -45,18 +44,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.try(async function () { await queryBar.setQuery('php'); await queryBar.submitQuery(); - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be(expectedHitCount); }); }); it('the search term should be highlighted in the field data', async function () { // marks is the style that highlights the text in yellow - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - const marks = await PageObjects.discover.getMarks(); + await unifiedFieldList.clickFieldListItemAdd('extension'); + const marks = await discover.getMarks(); expect(marks.length).to.be.greaterThan(0); expect(marks.indexOf('php')).to.be(0); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('extension'); + await unifiedFieldList.clickFieldListItemRemove('extension'); }); it('search type:apache should show the correct hit count', async function () { @@ -64,13 +63,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await queryBar.setQuery('type:apache'); await queryBar.submitQuery(); await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be(expectedHitCount); }); }); it('doc view should show @timestamp and Document columns', async function () { - const Docheader = await PageObjects.discover.getDocHeader(); + const Docheader = await discover.getDocHeader(); expect(Docheader).to.contain('@timestamp'); expect(Docheader).to.contain('Document'); }); @@ -81,8 +80,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'whitespace but "(" found.'; await queryBar.setQuery('xxx(yyy))'); await queryBar.submitQuery(); - await PageObjects.discover.showsErrorCallout(); - const message = await PageObjects.discover.getDiscoverErrorMessage(); + await discover.showsErrorCallout(); + const message = await discover.getDiscoverErrorMessage(); expect(message).to.contain(expectedError); }); @@ -91,21 +90,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await queryBar.submitQuery(); const currentUrl = await browser.getCurrentUrl(); const [, hash] = currentUrl.split('#/'); - await PageObjects.common.navigateToUrl( + await common.navigateToUrl( 'discover', hash.replace('columns:!()', 'columns:!(relatedContent)'), { useActualUrl: true } ); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async function tryingForTime() { - expect(await PageObjects.discover.getDocHeader()).to.contain('relatedContent'); + expect(await discover.getDocHeader()).to.contain('relatedContent'); - const field = await PageObjects.discover.getDocTableIndex(1); + const field = await discover.getDocTableIndex(1); expect(field).to.contain('relatedContent.url'); }); - const marks = await PageObjects.discover.getMarks(); + const marks = await discover.getMarks(); expect(marks.length).to.be.above(0); expect(marks).to.contain('election'); }); diff --git a/test/functional/apps/discover/group5/_filter_editor.ts b/test/functional/apps/discover/group5/_filter_editor.ts index f23c3cdcaa6a2..e2f568b8eb21d 100644 --- a/test/functional/apps/discover/group5/_filter_editor.ts +++ b/test/functional/apps/discover/group5/_filter_editor.ts @@ -20,7 +20,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const security = getService('security'); const browser = getService('browser'); const dataGrid = getService('dataGrid'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'unifiedFieldList']); + const { common, discover, timePicker, unifiedFieldList } = getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'unifiedFieldList', + ]); const defaultSettings = { defaultIndex: 'logstash-*', }; @@ -35,9 +40,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); log.debug('discover filter editor'); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); describe('filter editor', function () { @@ -66,7 +71,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); expect(await filterBar.hasFilter('nestedField.child', 'nestedValue')).to.be(true); await retry.try(async function () { - expect(await PageObjects.discover.getHitCount()).to.be('1'); + expect(await discover.getHitCount()).to.be('1'); }); }); @@ -111,8 +116,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await indexPatterns.create({ title: indexTitle }, { override: true }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern(indexTitle); + await common.navigateToApp('discover'); + await discover.selectIndexPattern(indexTitle); }); it('should support range filter on version fields', async () => { @@ -123,18 +128,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); expect(await filterBar.hasFilter('version', '2.0.0 to 3.0.0')).to.be(true); await retry.try(async function () { - expect(await PageObjects.discover.getHitCount()).to.be('1'); + expect(await discover.getHitCount()).to.be('1'); }); }); }); const runFilterTest = async (pinned = false) => { await filterBar.removeAllFilters(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); + await unifiedFieldList.clickFieldListItemAdd('extension'); await retry.try(async function () { const cell = await dataGrid.getCellElementExcludingControlColumns(0, 1); expect(await cell.getVisibleText()).to.be('jpg'); - expect(await PageObjects.discover.getHitCount()).to.be('14,004'); + expect(await discover.getHitCount()).to.be('14,004'); }); await filterBar.addFilter({ field: 'extension.raw', @@ -148,12 +153,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await filterBar.hasFilter('extension.raw', 'css', true, pinned)).to.be(true); const cell = await dataGrid.getCellElementExcludingControlColumns(0, 1); expect(await cell.getVisibleText()).to.be('css'); - expect(await PageObjects.discover.getHitCount()).to.be('2,159'); + expect(await discover.getHitCount()).to.be('2,159'); }); await browser.refresh(); await retry.try(async function () { expect(await filterBar.hasFilter('extension.raw', 'css', true, pinned)).to.be(true); - expect(await PageObjects.discover.getHitCount()).to.be('2,159'); + expect(await discover.getHitCount()).to.be('2,159'); const cell = await dataGrid.getCellElementExcludingControlColumns(0, 1); expect(await cell.getVisibleText()).to.be('css'); }); @@ -170,7 +175,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await security.testUser.restoreDefaults(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); }); } diff --git a/test/functional/apps/discover/group5/_greeting_screen.ts b/test/functional/apps/discover/group5/_greeting_screen.ts index 76728f71fde62..d60e8bb9a32ce 100644 --- a/test/functional/apps/discover/group5/_greeting_screen.ts +++ b/test/functional/apps/discover/group5/_greeting_screen.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const security = getService('security'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects(['common', 'header', 'discover', 'timePicker']); + const { common, header, discover } = getPageObjects(['common', 'header', 'discover']); const defaultSettings = { defaultIndex: 'logstash-*', }; @@ -37,16 +37,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should create a data view when there are no data views', async () => { await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('management'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('management'); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('dataViews'); await testSubjects.click('checkboxSelectAll'); await testSubjects.click('delete-data-views-button'); await testSubjects.click('confirmModalConfirmButton'); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); await dataViews.createFromPrompt({ name: 'logs', hasTimeField: true }); expect(await dataViews.isAdHoc()).to.be(false); @@ -54,7 +54,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataViews.createFromSearchBar({ name: 'log', adHoc: true, hasTimeField: true }); expect(await dataViews.isAdHoc()).to.be(true); - expect(await PageObjects.discover.getIndexPatterns()).to.eql(['log*\nTemporary', 'logs*']); + expect(await discover.getIndexPatterns()).to.eql(['log*\nTemporary', 'logs*']); }); }); } diff --git a/test/functional/apps/discover/group5/_inspector.ts b/test/functional/apps/discover/group5/_inspector.ts index 5c599778b9cc9..79a13dbe219a0 100644 --- a/test/functional/apps/discover/group5/_inspector.ts +++ b/test/functional/apps/discover/group5/_inspector.ts @@ -12,7 +12,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'visualize', 'timePicker']); + const { common, timePicker } = getPageObjects(['common', 'timePicker']); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const inspector = getService('inspector'); @@ -40,8 +40,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); // delete .kibana index and update configDoc await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); afterEach(async () => { @@ -67,7 +67,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should display request stats with results', async () => { - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); await inspector.open(); await testSubjects.click('inspectorRequestChooser'); await testSubjects.click(`inspectorRequestChooserDocuments`); diff --git a/test/functional/apps/discover/group5/_large_string.ts b/test/functional/apps/discover/group5/_large_string.ts index 792d5a93504a9..1c5d203d5c8bd 100644 --- a/test/functional/apps/discover/group5/_large_string.ts +++ b/test/functional/apps/discover/group5/_large_string.ts @@ -18,7 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const queryBar = getService('queryBar'); const security = getService('security'); - const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover']); + const { common, discover } = getPageObjects(['common', 'discover']); describe('test large strings', function () { before(async function () { @@ -42,9 +42,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ' you’ll have to check the laws of the country where you are' + ' located before using this ebook.'; - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await retry.try(async function tryingForTime() { - const rowData = await PageObjects.discover.getDocTableIndex(1, true); + const rowData = await discover.getDocTableIndex(1, true); expect(rowData).to.contain(expectedText); }); }); @@ -55,7 +55,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await queryBar.setQuery('Newsletter'); await queryBar.submitQuery(); await retry.try(async function tryingForTime() { - const hitCount = await PageObjects.discover.getHitCount(); + const hitCount = await discover.getHitCount(); expect(hitCount).to.be(expectedHitCount); log.debug('test Newsletter keyword is searched'); }); @@ -63,7 +63,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('the search term Newsletter should be highlighted in the field data', async function () { // marks is the style that highlights the text in yellow - const marks = await PageObjects.discover.getMarks(); + const marks = await discover.getMarks(); expect(marks.length).to.be(1); log.debug('Newsletter appears only once'); }); diff --git a/test/functional/apps/discover/group5/_no_data.ts b/test/functional/apps/discover/group5/_no_data.ts index da889b5646a96..6c65dbb2fd735 100644 --- a/test/functional/apps/discover/group5/_no_data.ts +++ b/test/functional/apps/discover/group5/_no_data.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const dataGrid = getService('dataGrid'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); + const { common, discover, header } = getPageObjects(['common', 'discover', 'header']); describe('discover no data', () => { const kbnDirectory = 'test/functional/fixtures/kbn_archiver/discover'; @@ -27,7 +27,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); log.debug('load kibana with no data'); await kibanaServer.importExport.unload(kbnDirectory); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async () => { @@ -36,17 +36,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('when no data opens integrations', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const addIntegrations = await testSubjects.find('kbnOverviewAddIntegrations'); await addIntegrations.click(); - await PageObjects.common.waitUntilUrlIncludes('integrations/browse'); + await common.waitUntilUrlIncludes('integrations/browse'); }); it('adds a new data view when no data views', async () => { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); const dataViewToCreate = 'logstash'; await dataViews.createFromPrompt({ name: dataViewToCreate }); @@ -59,12 +59,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.update({ 'timepicker:timeDefaults': '{ "from": "2015-09-18T19:37:13.000Z", "to": "now"}', }); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await testSubjects.click('tryESQLLink'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('TextBasedLangEditor'); await testSubjects.existOrFail('unifiedHistogramChart'); const rows = await dataGrid.getDocTableRows(); diff --git a/test/functional/apps/discover/group5/_shared_links.ts b/test/functional/apps/discover/group5/_shared_links.ts index 84802a2dd0d4e..56d4c922f7fc4 100644 --- a/test/functional/apps/discover/group5/_shared_links.ts +++ b/test/functional/apps/discover/group5/_shared_links.ts @@ -16,7 +16,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'discover', 'share', 'timePicker']); + const { common, discover, share, timePicker } = getPageObjects([ + 'common', + 'discover', + 'share', + 'timePicker', + ]); const browser = getService('browser'); const toasts = getService('toasts'); const deployment = getService('deployment'); @@ -41,10 +46,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'state:storeInSessionStorage': storeStateInSessionStorage, defaultIndex: 'logstash-*', }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.share.clickShareTopNavButton(); + await common.navigateToApp('discover'); + await share.clickShareTopNavButton(); return async () => { await kibanaServer.uiSettings.unset('state:storeInSessionStorage'); @@ -65,7 +70,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should allow for copying the snapshot URL', async function () { const re = new RegExp(baseUrl + '/app/r.+$'); await retry.try(async () => { - const actualUrl = await PageObjects.share.getSharedUrl(); + const actualUrl = await share.getSharedUrl(); expect(actualUrl).match(re); }); }); @@ -80,7 +85,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { "*',interval:auto,query:(language:kuery,query:'')" + ',sort:!())'; await browser.navigateTo(expectedUrl); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor('url to contain default sorting', async () => { // url fallback default sort should have been pushed to URL const url = await browser.getCurrentUrl(); @@ -88,7 +93,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await retry.waitFor('document table to contain the right timestamp', async () => { - const firstRowText = await PageObjects.discover.getDocTableIndex(1); + const firstRowText = await discover.getDocTableIndex(1); return firstRowText.includes('Sep 22, 2015 @ 23:50:13.253'); }); }); @@ -109,18 +114,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const re = new RegExp(baseUrl + '/app/r.*$'); let actualUrl: string = ''; await retry.try(async () => { - actualUrl = await PageObjects.share.getSharedUrl(); + actualUrl = await share.getSharedUrl(); expect(actualUrl).match(re); }); - const actualTime = await PageObjects.timePicker.getTimeConfig(); + const actualTime = await timePicker.getTimeConfig(); await browser.clearSessionStorage(); await browser.get(actualUrl, false); await retry.try(async () => { const resolvedUrl = await browser.getCurrentUrl(); expect(resolvedUrl).to.match(/discover/); - const resolvedTime = await PageObjects.timePicker.getTimeConfig(); + const resolvedTime = await timePicker.getTimeConfig(); expect(resolvedTime.start).to.equal(actualTime.start); expect(resolvedTime.end).to.equal(actualTime.end); }); diff --git a/test/functional/apps/discover/group5/_source_filters.ts b/test/functional/apps/discover/group5/_source_filters.ts index 72163aa75e2f8..9c66cff8f0df3 100644 --- a/test/functional/apps/discover/group5/_source_filters.ts +++ b/test/functional/apps/discover/group5/_source_filters.ts @@ -16,11 +16,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const retry = getService('retry'); - const PageObjects = getPageObjects([ + const { common, timePicker, discover, settings, unifiedFieldList } = getPageObjects([ 'common', 'timePicker', 'discover', - 'header', 'settings', 'unifiedFieldList', ]); @@ -35,19 +34,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); log.debug('management'); - await PageObjects.common.navigateToApp('settings'); - await PageObjects.settings.clickKibanaIndexPatterns(); - await PageObjects.settings.clickIndexPatternLogstash(); - await PageObjects.settings.addFieldFilter('referer'); - await PageObjects.settings.addFieldFilter('relatedContent*'); + await common.navigateToApp('settings'); + await settings.clickKibanaIndexPatterns(); + await settings.clickIndexPatternLogstash(); + await settings.addFieldFilter('referer'); + await settings.addFieldFilter('relatedContent*'); log.debug('discover'); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); + await discover.waitUntilSearchingHasFinished(); await retry.try(async function () { - expect(await PageObjects.discover.getDocHeader()).to.have.string('Document'); + expect(await discover.getDocHeader()).to.have.string('Document'); }); }); @@ -59,7 +58,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not get the field referer', async function () { - const fieldNames = await PageObjects.unifiedFieldList.getAllFieldNames(); + const fieldNames = await unifiedFieldList.getAllFieldNames(); expect(fieldNames).to.not.contain('referer'); const relatedContentFields = fieldNames.filter( (fieldName) => fieldName.indexOf('relatedContent') === 0 diff --git a/test/functional/apps/discover/group5/_url_state.ts b/test/functional/apps/discover/group5/_url_state.ts index dc99c0ea1a61d..f8abcc1101dad 100644 --- a/test/functional/apps/discover/group5/_url_state.ts +++ b/test/functional/apps/discover/group5/_url_state.ts @@ -22,13 +22,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); const dataGrid = getService('dataGrid'); - const PageObjects = getPageObjects([ + const { common, discover, header, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', 'timePicker', 'unifiedFieldList', - 'visualize', ]); const defaultSettings = { @@ -43,8 +42,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // and load a set of makelogs data await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); after(async () => { @@ -52,14 +51,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show a warning and fall back to the default data view when navigating to a URL with an invalid data view ID', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const dataViewId = await PageObjects.discover.getCurrentDataViewId(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); + await header.waitUntilLoadingHasFinished(); + const dataViewId = await discover.getCurrentDataViewId(); const originalUrl = await browser.getCurrentUrl(); const newUrl = originalUrl.replace(dataViewId, 'invalid-data-view-id'); await browser.get(newUrl); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { expect(await browser.getCurrentUrl()).to.be(originalUrl); expect(await testSubjects.exists('dscDataViewNotFoundShowDefaultWarning')).to.be(true); @@ -67,13 +66,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show a warning and fall back to the current data view if the URL is updated to an invalid data view ID', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); const originalHash = await browser.execute<[], string>('return window.location.hash'); - const dataViewId = await PageObjects.discover.getCurrentDataViewId(); + const dataViewId = await discover.getCurrentDataViewId(); const newHash = originalHash.replace(dataViewId, 'invalid-data-view-id'); await browser.execute(`window.location.hash = "${newHash}"`); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { const currentHash = await browser.execute<[], string>('return window.location.hash'); expect(currentHash).to.be(originalHash); @@ -82,8 +81,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should sync Lens global state to Discover sidebar link and carry over the state when navigating to Discover', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.common.navigateToApp('lens'); + await common.navigateToApp('discover'); + await common.navigateToApp('lens'); await appsMenu.openCollapsibleNav(); let discoverLink = await appsMenu.getLink('Discover'); expect(discoverLink?.href).to.contain( @@ -91,14 +90,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { "&_a=(columns:!(),dataSource:(dataViewId:'logstash-*',type:dataView),filters:!(),interval:auto,query:(language:kuery,query:''),sort:!(!('@timestamp',desc)))" ); await appsMenu.closeCollapsibleNav(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); await filterBar.addFilter({ field: 'extension.raw', operation: 'is one of', value: ['jpg', 'css'], }); await filterBar.toggleFilterPinned('extension.raw'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await appsMenu.openCollapsibleNav(); discoverLink = await appsMenu.getLink('Discover'); expect(discoverLink?.href).to.contain( @@ -112,14 +111,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { "interval:auto,query:(language:kuery,query:''),sort:!(!('@timestamp',desc)))" ); await appsMenu.clickLink('Discover', { category: 'kibana' }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect(await filterBar.hasFilter('extension.raw', '', undefined, true)).to.be(true); expect(await filterBar.isFilterPinned('extension.raw')).to.be(true); - expect(await PageObjects.timePicker.getTimeConfig()).to.eql({ + expect(await timePicker.getTimeConfig()).to.eql({ start: 'Sep 19, 2015 @ 06:31:44.000', end: 'Sep 23, 2015 @ 18:31:44.000', }); - expect(await PageObjects.discover.getHitCount()).to.be('11,268'); + expect(await discover.getHitCount()).to.be('11,268'); }); it('should merge custom global filters with saved search filters', async () => { @@ -127,40 +126,40 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'timepicker:timeDefaults': '{ "from": "Sep 18, 2015 @ 19:37:13.000", "to": "Sep 23, 2015 @ 02:30:09.000"}', }); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await filterBar.addFilter({ field: 'bytes', operation: 'is between', value: { from: '1000', to: '2000' }, }); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); const totalHitsForOneFilter = '737'; const totalHitsForTwoFilters = '137'; - expect(await PageObjects.discover.getHitCount()).to.be(totalHitsForOneFilter); + expect(await discover.getHitCount()).to.be(totalHitsForOneFilter); - await PageObjects.discover.saveSearch('testFilters'); + await discover.saveSearch('testFilters'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCount()).to.be(totalHitsForOneFilter); + expect(await discover.getHitCount()).to.be(totalHitsForOneFilter); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCount()).to.be(totalHitsForOneFilter); + expect(await discover.getHitCount()).to.be(totalHitsForOneFilter); const url = await browser.getCurrentUrl(); const savedSearchIdMatch = url.match(/view\/([^?]+)\?/); @@ -171,8 +170,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.openNewTab(); await browser.get(`${deployment.getHostPort()}/app/discover#/view/${savedSearchId}`); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect((await dataGrid.getRowsText()).slice(0, 6)).to.eql([ 'Sep 22, 2015 @ 20:44:05.521jpg1,808', @@ -183,7 +182,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'Sep 22, 2015 @ 19:40:17.903jpg1,557', ]); - expect(await PageObjects.discover.getHitCount()).to.be(totalHitsForOneFilter); + expect(await discover.getHitCount()).to.be(totalHitsForOneFilter); await browser.openNewTab(); await browser.get( @@ -197,8 +196,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { "to:'2015-09-23T18:31:44.000Z'))" ); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); const filteredRows = [ 'Sep 22, 2015 @ 20:41:53.463png1,969', @@ -210,16 +209,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]; expect((await dataGrid.getRowsText()).slice(0, 6)).to.eql(filteredRows); - expect(await PageObjects.discover.getHitCount()).to.be(totalHitsForTwoFilters); + expect(await discover.getHitCount()).to.be(totalHitsForTwoFilters); await testSubjects.existOrFail('unsavedChangesBadge'); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect((await dataGrid.getRowsText()).slice(0, 6)).to.eql(filteredRows); - expect(await PageObjects.discover.getHitCount()).to.be(totalHitsForTwoFilters); + expect(await discover.getHitCount()).to.be(totalHitsForTwoFilters); await testSubjects.existOrFail('unsavedChangesBadge'); }); }); diff --git a/test/functional/apps/discover/group6/_field_stats_table.ts b/test/functional/apps/discover/group6/_field_stats_table.ts index a56f1f3fe9dae..c8381976ffbab 100644 --- a/test/functional/apps/discover/group6/_field_stats_table.ts +++ b/test/functional/apps/discover/group6/_field_stats_table.ts @@ -10,7 +10,12 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'header']); + const { common, discover, timePicker, header } = getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'header', + ]); const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); @@ -35,14 +40,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { [true, false].forEach((shouldSearchFieldsFromSource) => { describe(`discover:searchFieldsFromSource: ${shouldSearchFieldsFromSource}`, function () { before(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ ...defaultSettings, 'discover:searchFieldsFromSource': shouldSearchFieldsFromSource, }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); after(async () => { @@ -51,20 +56,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show Field Statistics data in data view mode', async () => { await testSubjects.click('dscViewModeFieldStatsButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('dataVisualizerTableContainer'); await testSubjects.click('dscViewModeDocumentButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('discoverDocTable'); }); it('should show Field Statistics data in ES|QL mode', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.selectTextBaseLang(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.click('dscViewModeFieldStatsButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('dataVisualizerTableContainer'); }); }); diff --git a/test/functional/apps/discover/group6/_sidebar.ts b/test/functional/apps/discover/group6/_sidebar.ts index 9193f0d582c13..3e746a3726bcc 100644 --- a/test/functional/apps/discover/group6/_sidebar.ts +++ b/test/functional/apps/discover/group6/_sidebar.ts @@ -13,7 +13,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, header, unifiedSearch, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'timePicker', @@ -42,30 +42,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); afterEach(async () => { await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.savedObjects.cleanStandardList(); await kibanaServer.uiSettings.replace({}); - await PageObjects.unifiedFieldList.cleanSidebarLocalStorage(); + await unifiedFieldList.cleanSidebarLocalStorage(); }); describe('field filtering', function () { it('should reveal and hide the filter form when the toggle is clicked', async function () { - await PageObjects.unifiedFieldList.openSidebarFieldFilter(); - await PageObjects.unifiedFieldList.closeSidebarFieldFilter(); + await unifiedFieldList.openSidebarFieldFilter(); + await unifiedFieldList.closeSidebarFieldFilter(); }); it('should filter by field type', async function () { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - await PageObjects.unifiedFieldList.openSidebarFieldFilter(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.openSidebarFieldFilter(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); @@ -73,7 +73,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.waitFor('first updates', async () => { return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === + (await unifiedFieldList.getSidebarAriaDescription()) === '6 available fields. 1 empty field. 3 meta fields.' ); }); @@ -82,7 +82,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.waitFor('second updates', async () => { return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === + (await unifiedFieldList.getSidebarAriaDescription()) === '10 available fields. 3 empty fields. 4 meta fields.' ); }); @@ -91,56 +91,50 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.waitFor('reset', async () => { return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - INITIAL_FIELD_LIST_SUMMARY + (await unifiedFieldList.getSidebarAriaDescription()) === INITIAL_FIELD_LIST_SUMMARY ); }); }); it('should show filters by type in ES|QL view', async function () { - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - await PageObjects.unifiedFieldList.openSidebarFieldFilter(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.openSidebarFieldFilter(); let options = await find.allByCssSelector('[data-test-subj*="typeFilter"]'); expect(options).to.have.length(6); - await PageObjects.unifiedFieldList.closeSidebarFieldFilter(); + await unifiedFieldList.closeSidebarFieldFilter(); - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | limit 10000`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - await PageObjects.unifiedFieldList.openSidebarFieldFilter(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.openSidebarFieldFilter(); options = await find.allByCssSelector('[data-test-subj*="typeFilter"]'); expect(options).to.have.length(6); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '82 available fields.' - ); + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be('82 available fields.'); await testSubjects.click('typeFilter-number'); await retry.waitFor('updates', async () => { - return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - '6 available fields.' - ); + return (await unifiedFieldList.getSidebarAriaDescription()) === '6 available fields.'; }); }); it('should show empty fields in ES|QL view', async function () { - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - await PageObjects.discover.selectTextBaseLang(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | limit 10 | keep machine.ram_range, bytes `; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - await PageObjects.unifiedFieldList.openSidebarFieldFilter(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.openSidebarFieldFilter(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '2 selected fields. 1 available field. 1 empty field.' ); }); @@ -148,10 +142,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('search', function () { beforeEach(async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); }); @@ -162,94 +156,89 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.waitFor('reset', async () => { return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === - INITIAL_FIELD_LIST_SUMMARY + (await unifiedFieldList.getSidebarAriaDescription()) === INITIAL_FIELD_LIST_SUMMARY ); }); }); it('should be able to search by string', async function () { - await PageObjects.unifiedFieldList.findFieldByName('i'); + await unifiedFieldList.findFieldByName('i'); await retry.waitFor('first updates', async () => { return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === + (await unifiedFieldList.getSidebarAriaDescription()) === '28 available fields. 2 empty fields. 3 meta fields.' ); }); - await PageObjects.unifiedFieldList.findFieldByName('p'); + await unifiedFieldList.findFieldByName('p'); await retry.waitFor('second updates', async () => { return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === + (await unifiedFieldList.getSidebarAriaDescription()) === '4 available fields. 0 meta fields.' ); }); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ') - ).to.be('clientip, ip, relatedContent.og:description, relatedContent.twitter:description'); + expect((await unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ')).to.be( + 'clientip, ip, relatedContent.og:description, relatedContent.twitter:description' + ); }); it('should be able to search by wildcard', async function () { - await PageObjects.unifiedFieldList.findFieldByName('relatedContent*image'); + await unifiedFieldList.findFieldByName('relatedContent*image'); await retry.waitFor('updates', async () => { return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === + (await unifiedFieldList.getSidebarAriaDescription()) === '2 available fields. 0 meta fields.' ); }); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ') - ).to.be('relatedContent.og:image, relatedContent.twitter:image'); + expect((await unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ')).to.be( + 'relatedContent.og:image, relatedContent.twitter:image' + ); }); it('should be able to search with spaces as wildcard', async function () { - await PageObjects.unifiedFieldList.findFieldByName('relatedContent image'); + await unifiedFieldList.findFieldByName('relatedContent image'); await retry.waitFor('updates', async () => { return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === + (await unifiedFieldList.getSidebarAriaDescription()) === '4 available fields. 0 meta fields.' ); }); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ') - ).to.be( + expect((await unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ')).to.be( 'relatedContent.og:image, relatedContent.og:image:height, relatedContent.og:image:width, relatedContent.twitter:image' ); }); it('should be able to search with fuzzy search (1 typo)', async function () { - await PageObjects.unifiedFieldList.findFieldByName('rel4tedContent.art'); + await unifiedFieldList.findFieldByName('rel4tedContent.art'); await retry.waitFor('updates', async () => { return ( - (await PageObjects.unifiedFieldList.getSidebarAriaDescription()) === + (await unifiedFieldList.getSidebarAriaDescription()) === '4 available fields. 0 meta fields.' ); }); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ') - ).to.be( + expect((await unifiedFieldList.getSidebarSectionFieldNames('available')).join(', ')).to.be( 'relatedContent.article:modified_time, relatedContent.article:published_time, relatedContent.article:section, relatedContent.article:tag' ); }); it('should ignore empty search', async function () { - await PageObjects.unifiedFieldList.findFieldByName(' '); // only spaces + await unifiedFieldList.findFieldByName(' '); // only spaces await retry.waitFor('the clear button', async () => { return await testSubjects.exists('clearSearchButton'); }); // expect no changes in the list - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); }); @@ -257,47 +246,47 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('field stats', function () { it('should work for regular and pinned filters', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const allTermsResult = 'jpg\n65.0%\ncss\n15.4%\npng\n9.8%\ngif\n6.6%\nphp\n3.2%'; - await PageObjects.unifiedFieldList.clickFieldListItem('extension'); + await unifiedFieldList.clickFieldListItem('extension'); expect(await testSubjects.getVisibleText('dscFieldStats-topValues')).to.be(allTermsResult); await filterBar.addFilter({ field: 'extension', operation: 'is', value: 'jpg' }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const onlyJpgResult = 'jpg\n100%'; - await PageObjects.unifiedFieldList.clickFieldListItem('extension'); + await unifiedFieldList.clickFieldListItem('extension'); expect(await testSubjects.getVisibleText('dscFieldStats-topValues')).to.be(onlyJpgResult); await filterBar.toggleFilterNegated('extension'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const jpgExcludedResult = 'css\n44.1%\npng\n28.0%\ngif\n18.8%\nphp\n9.1%'; - await PageObjects.unifiedFieldList.clickFieldListItem('extension'); + await unifiedFieldList.clickFieldListItem('extension'); expect(await testSubjects.getVisibleText('dscFieldStats-topValues')).to.be( jpgExcludedResult ); await filterBar.toggleFilterPinned('extension'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItem('extension'); + await unifiedFieldList.clickFieldListItem('extension'); expect(await testSubjects.getVisibleText('dscFieldStats-topValues')).to.be( jpgExcludedResult ); await browser.refresh(); - await PageObjects.unifiedFieldList.clickFieldListItem('extension'); + await unifiedFieldList.clickFieldListItem('extension'); expect(await testSubjects.getVisibleText('dscFieldStats-topValues')).to.be( jpgExcludedResult ); await filterBar.toggleFilterEnabled('extension'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItem('extension'); + await unifiedFieldList.clickFieldListItem('extension'); expect(await testSubjects.getVisibleText('dscFieldStats-topValues')).to.be(allTermsResult); }); }); @@ -309,13 +298,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should collapse when clicked', async function () { - await PageObjects.discover.closeSidebar(); + await discover.closeSidebar(); await testSubjects.existOrFail('dscShowSidebarButton'); await testSubjects.missingOrFail('fieldList'); }); it('should expand when clicked', async function () { - await PageObjects.discover.openSidebar(); + await discover.openSidebar(); await testSubjects.existOrFail('discover-sidebar'); await testSubjects.existOrFail('fieldList'); }); @@ -323,40 +312,36 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('renders field groups', function () { it('should show field list groups excluding subfields', async function () { - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(true); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(true); // Initial Available fields const expectedInitialAvailableFields = '@message, @tags, @timestamp, agent, bytes, clientip, extension, geo.coordinates, geo.dest, geo.src, geo.srcdest, headings, host, index, ip, links, machine.os, machine.ram, machine.ram_range, memory, nestedField.child, phpmemory, referer, relatedContent.article:modified_time, relatedContent.article:published_time, relatedContent.article:section, relatedContent.article:tag, relatedContent.og:description, relatedContent.og:image, relatedContent.og:image:height, relatedContent.og:image:width, relatedContent.og:site_name, relatedContent.og:title, relatedContent.og:type, relatedContent.og:url, relatedContent.twitter:card, relatedContent.twitter:description, relatedContent.twitter:image, relatedContent.twitter:site, relatedContent.twitter:title, relatedContent.url, request, response, spaces, type, url, utc_time, xss'; - let availableFields = await PageObjects.unifiedFieldList.getSidebarSectionFieldNames( - 'available' - ); + let availableFields = await unifiedFieldList.getSidebarSectionFieldNames('available'); expect(availableFields.length).to.be(48); expect(availableFields.join(', ')).to.be(expectedInitialAvailableFields); // Available fields after scrolling down const metaSectionButton = await find.byCssSelector( - PageObjects.unifiedFieldList.getSidebarSectionSelector('meta', true) + unifiedFieldList.getSidebarSectionSelector('meta', true) ); await metaSectionButton.scrollIntoViewIfNecessary(); await retry.waitFor('list to update after scrolling', async () => { - availableFields = await PageObjects.unifiedFieldList.getSidebarSectionFieldNames( - 'available' - ); + availableFields = await unifiedFieldList.getSidebarSectionFieldNames('available'); return availableFields.length === 48; }); expect(availableFields.join(', ')).to.be(`${expectedInitialAvailableFields}`); // Expand Meta section - await PageObjects.unifiedFieldList.toggleSidebarSection('meta'); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('meta')).join(', ') - ).to.be('_id, _ignored, _index, _score'); + await unifiedFieldList.toggleSidebarSection('meta'); + expect((await unifiedFieldList.getSidebarSectionFieldNames('meta')).join(', ')).to.be( + '_id, _ignored, _index, _score' + ); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); }); @@ -365,13 +350,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.update({ 'discover:searchFieldsFromSource': true }); await browser.refresh(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(true); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(true); // Initial Available fields - const availableFields = await PageObjects.unifiedFieldList.getSidebarSectionFieldNames( - 'available' - ); + const availableFields = await unifiedFieldList.getSidebarSectionFieldNames('available'); expect(availableFields.length).to.be(48); expect( availableFields @@ -383,124 +366,115 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Available fields after scrolling down const metaSectionButton = await find.byCssSelector( - PageObjects.unifiedFieldList.getSidebarSectionSelector('meta', true) + unifiedFieldList.getSidebarSectionSelector('meta', true) ); await metaSectionButton.scrollIntoViewIfNecessary(); // Expand Meta section - await PageObjects.unifiedFieldList.toggleSidebarSection('meta'); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('meta')).join(', ') - ).to.be('_id, _ignored, _index, _score'); + await unifiedFieldList.toggleSidebarSection('meta'); + expect((await unifiedFieldList.getSidebarSectionFieldNames('meta')).join(', ')).to.be( + '_id, _ignored, _index, _score' + ); // Expand Unmapped section - await PageObjects.unifiedFieldList.toggleSidebarSection('unmapped'); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('unmapped')).join(', ') - ).to.be('relatedContent'); + await unifiedFieldList.toggleSidebarSection('unmapped'); + expect((await unifiedFieldList.getSidebarSectionFieldNames('unmapped')).join(', ')).to.be( + 'relatedContent' + ); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '48 available fields. 1 unmapped field. 5 empty fields. 4 meta fields.' ); }); it('should show selected and popular fields', async function () { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@message'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ') - ).to.be('extension, @message'); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@message'); + await discover.waitUntilSearchingHasFinished(); - const availableFields = await PageObjects.unifiedFieldList.getSidebarSectionFieldNames( - 'available' + expect((await unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ')).to.be( + 'extension, @message' ); + + const availableFields = await unifiedFieldList.getSidebarSectionFieldNames('available'); expect(availableFields.includes('extension')).to.be(true); expect(availableFields.includes('@message')).to.be(true); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '2 selected fields. 2 popular fields. 48 available fields. 5 empty fields. 4 meta fields.' ); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('@message'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove('@message'); + await discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('_id'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@message'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('_id'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@message'); + await discover.waitUntilSearchingHasFinished(); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ') - ).to.be('extension, _id, @message'); + expect((await unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ')).to.be( + 'extension, _id, @message' + ); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('popular')).join(', ') - ).to.be('@message, _id, extension'); + expect((await unifiedFieldList.getSidebarSectionFieldNames('popular')).join(', ')).to.be( + '@message, _id, extension' + ); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '3 selected fields. 3 popular fields. 48 available fields. 5 empty fields. 4 meta fields.' ); // verify popular fields were persisted await browser.refresh(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + await unifiedFieldList.waitUntilSidebarHasLoaded(); + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '3 selected fields. 3 popular fields. 48 available fields. 5 empty fields. 4 meta fields.' ); }); it('should show selected and available fields in ES|QL mode', async function () { - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); await monacoEditor.setCodeEditorValue('from logstash-* | limit 10000'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '82 available fields.' - ); + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be('82 available fields.'); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('extension'); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.clickFieldListItemRemove('extension'); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( - '82 available fields.' - ); + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be('82 available fields.'); const testQuery = `from logstash-* | limit 10 | stats countB = count(bytes) by geo.dest | sort countB`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '2 selected fields. 2 available fields.' ); - expect( - (await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ') - ).to.be('countB, geo.dest'); + expect((await unifiedFieldList.getSidebarSectionFieldNames('selected')).join(', ')).to.be( + 'countB, geo.dest' + ); - await PageObjects.unifiedSearch.switchToDataViewMode(); + await unifiedSearch.switchToDataViewMode(); - await PageObjects.unifiedSearch.switchDataView( - 'discover-dataView-switch-link', - 'logstash-*' - ); + await unifiedSearch.switchDataView('discover-dataView-switch-link', 'logstash-*'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '48 available fields. 5 empty fields. 4 meta fields.' ); }); @@ -511,35 +485,33 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'test/functional/fixtures/kbn_archiver/index_pattern_without_timefield' ); await browser.refresh(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); await dataViews.switchToAndValidate('with-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '0 available fields. 0 meta fields.' ); await testSubjects.missingOrFail( - `${PageObjects.unifiedFieldList.getSidebarSectionSelector('available')}-fetchWarning` + `${unifiedFieldList.getSidebarSectionSelector('available')}-fetchWarning` ); await testSubjects.existOrFail( - `${PageObjects.unifiedFieldList.getSidebarSectionSelector( - 'available' - )}NoFieldsCallout-noFieldsExist` + `${unifiedFieldList.getSidebarSectionSelector('available')}NoFieldsCallout-noFieldsExist` ); await dataViews.switchToAndValidate('logstash-*'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); await kibanaServer.importExport.unload( @@ -556,41 +528,39 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await browser.refresh(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); await dataViews.switchToAndValidate('without-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '6 available fields. 4 meta fields.' ); await dataViews.switchToAndValidate('with-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '0 available fields. 7 empty fields. 4 meta fields.' ); await testSubjects.existOrFail( - `${PageObjects.unifiedFieldList.getSidebarSectionSelector( - 'available' - )}NoFieldsCallout-noFieldsMatch` + `${unifiedFieldList.getSidebarSectionSelector('available')}NoFieldsCallout-noFieldsMatch` ); await dataViews.switchToAndValidate('logstash-*'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); @@ -604,27 +574,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should work when filters change', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); - await PageObjects.unifiedFieldList.clickFieldListItem('extension'); + await unifiedFieldList.clickFieldListItem('extension'); expect(await testSubjects.getVisibleText('dscFieldStats-topValues')).to.be( 'jpg\n65.0%\ncss\n15.4%\npng\n9.8%\ngif\n6.6%\nphp\n3.2%' ); await filterBar.addFilter({ field: 'extension', operation: 'is', value: 'jpg' }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); // check that the filter was passed down to the sidebar - await PageObjects.unifiedFieldList.clickFieldListItem('extension'); + await unifiedFieldList.clickFieldListItem('extension'); expect(await testSubjects.getVisibleText('dscFieldStats-topValues')).to.be('jpg\n100%'); }); @@ -635,27 +605,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await browser.refresh(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); await dataViews.switchToAndValidate('indices-stats*'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '6873 available fields. 4 meta fields.' ); await dataViews.switchToAndValidate('logstash-*'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); @@ -671,14 +641,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { adHoc: true, hasTimeField: true, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); - await PageObjects.discover.addRuntimeField( + await discover.addRuntimeField( '_bytes-runtimefield', `emit((doc["bytes"].value * 2).toString())` ); @@ -687,17 +657,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return !(await testSubjects.exists('fieldEditor')); }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '49 available fields. 5 empty fields. 4 meta fields.' ); - let allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); + let allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_bytes-runtimefield')).to.be(true); - await PageObjects.discover.editField('_bytes-runtimefield'); + await discover.editField('_bytes-runtimefield'); await fieldEditor.enableCustomLabel(); await fieldEditor.setCustomLabel('_bytes-runtimefield2'); await fieldEditor.save(); @@ -706,64 +676,64 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return !(await testSubjects.exists('fieldEditor')); }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '49 available fields. 5 empty fields. 4 meta fields.' ); - allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); + allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_bytes-runtimefield2')).to.be(true); expect(allFields.includes('_bytes-runtimefield')).to.be(false); - await PageObjects.discover.removeField('_bytes-runtimefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.removeField('_bytes-runtimefield'); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); - allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); + allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_bytes-runtimefield2')).to.be(false); expect(allFields.includes('_bytes-runtimefield')).to.be(false); }); it('should render even when retrieving documents failed with an error', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); - await PageObjects.discover.addRuntimeField('_invalid-runtimefield', `emit(‘’);`); + await discover.addRuntimeField('_invalid-runtimefield', `emit(‘’);`); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // error in fetching documents because of the invalid runtime field - await PageObjects.discover.showsErrorCallout(); + await discover.showsErrorCallout(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); // check that the sidebar is rendered - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '49 available fields. 5 empty fields. 4 meta fields.' ); - let allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); + let allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_invalid-runtimefield')).to.be(true); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.showsErrorCallout(); // still has error + await header.waitUntilLoadingHasFinished(); + await discover.showsErrorCallout(); // still has error // check that the sidebar is rendered event after a refresh - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); - allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); + allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('_invalid-runtimefield')).to.be(true); - await PageObjects.discover.removeField('_invalid-runtimefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.removeField('_invalid-runtimefield'); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); }); it('should work correctly when time range is updated', async function () { @@ -775,35 +745,33 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await browser.refresh(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( INITIAL_FIELD_LIST_SUMMARY ); await dataViews.switchToAndValidate('with-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '0 available fields. 7 empty fields. 4 meta fields.' ); await testSubjects.existOrFail( - `${PageObjects.unifiedFieldList.getSidebarSectionSelector( - 'available' - )}NoFieldsCallout-noFieldsMatch` + `${unifiedFieldList.getSidebarSectionSelector('available')}NoFieldsCallout-noFieldsMatch` ); - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 21, 2019 @ 00:00:00.000', 'Sep 23, 2019 @ 00:00:00.000' ); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - expect(await PageObjects.unifiedFieldList.getSidebarAriaDescription()).to.be( + expect(await unifiedFieldList.getSidebarAriaDescription()).to.be( '7 available fields. 4 meta fields.' ); @@ -818,35 +786,33 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should remove the table column after a field was deleted', async () => { const newField = '_test_field_and_column_removal'; - await PageObjects.discover.addRuntimeField(newField, `emit("hi there")`); + await discover.addRuntimeField(newField, `emit("hi there")`); await retry.waitFor('form to close', async () => { return !(await testSubjects.exists('fieldEditor')); }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - let selectedFields = await PageObjects.unifiedFieldList.getSidebarSectionFieldNames( - 'selected' - ); + let selectedFields = await unifiedFieldList.getSidebarSectionFieldNames('selected'); expect(selectedFields.includes(newField)).to.be(false); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'Document']); - await PageObjects.unifiedFieldList.clickFieldListItemAdd(newField); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await unifiedFieldList.clickFieldListItemAdd(newField); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - selectedFields = await PageObjects.unifiedFieldList.getSidebarSectionFieldNames('selected'); + selectedFields = await unifiedFieldList.getSidebarSectionFieldNames('selected'); expect(selectedFields.includes(newField)).to.be(true); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', newField]); - await PageObjects.discover.removeField(newField); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await discover.removeField(newField); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); await retry.waitFor('sidebar to update', async () => { - return !(await PageObjects.unifiedFieldList.getAllFieldNames()).includes(newField); + return !(await unifiedFieldList.getAllFieldNames()).includes(newField); }); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'Document']); diff --git a/test/functional/apps/discover/group6/_sidebar_field_stats.ts b/test/functional/apps/discover/group6/_sidebar_field_stats.ts index e2c890a8916a5..3cfa2c1da20af 100644 --- a/test/functional/apps/discover/group6/_sidebar_field_stats.ts +++ b/test/functional/apps/discover/group6/_sidebar_field_stats.ts @@ -13,7 +13,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, header, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'timePicker', @@ -42,26 +42,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('data view fields', function () { before(async () => { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - - await PageObjects.discover.addRuntimeField( - '_is_large', - 'emit(doc["bytes"].value > 1024)', - 'boolean' - ); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); + + await discover.addRuntimeField('_is_large', 'emit(doc["bytes"].value > 1024)', 'boolean'); await retry.waitFor('form to close', async () => { return !(await testSubjects.exists('fieldEditor')); }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); }); it('should show a top values popover for a boolean runtime field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('_is_large'); + await unifiedFieldList.clickFieldListItem('_is_large'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Top values'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -71,11 +67,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await testSubjects.getVisibleText('dscFieldStats-statsFooter')).to.contain( '14,004 records' ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show a histogram and top values popover for numeric field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('bytes'); + await unifiedFieldList.clickFieldListItem('bytes'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.contain('Top values'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.contain('Distribution'); @@ -88,11 +84,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await testSubjects.getVisibleText('dscFieldStats-statsFooter')).to.contain( '14,004 records' ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show a top values popover for a keyword field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('extension'); + await unifiedFieldList.clickFieldListItem('extension'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Top values'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -102,11 +98,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await testSubjects.getVisibleText('dscFieldStats-statsFooter')).to.contain( '14,004 records' ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show a top values popover for an ip field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('clientip'); + await unifiedFieldList.clickFieldListItem('clientip'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Top values'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -116,21 +112,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await testSubjects.getVisibleText('dscFieldStats-statsFooter')).to.contain( '14,004 records' ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show a date histogram popover for a date field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('@timestamp'); + await unifiedFieldList.clickFieldListItem('@timestamp'); await testSubjects.existOrFail('unifiedFieldStats-timeDistribution'); await testSubjects.missingOrFail('dscFieldStats-buttonGroup-topValuesButton'); expect(await testSubjects.getVisibleText('dscFieldStats-statsFooter')).to.contain( '14,004 records' ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show examples for geo points field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('geo.coordinates'); + await unifiedFieldList.clickFieldListItem('geo.coordinates'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Examples'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -140,27 +136,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await testSubjects.getVisibleText('dscFieldStats-statsFooter')).to.contain( '100 sample records' ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); }); describe('ES|QL columns', function () { beforeEach(async () => { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* [METADATA _index, _id] | sort @timestamp desc | limit 500`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); }); it('should show top values popover for numeric field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('bytes'); + await unifiedFieldList.clickFieldListItem('bytes'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Top values'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -169,16 +165,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '42 sample values' ); - await PageObjects.unifiedFieldList.clickFieldListPlusFilter('bytes', '0'); + await unifiedFieldList.clickFieldListPlusFilter('bytes', '0'); const editorValue = await monacoEditor.getCodeEditorValue(); expect(editorValue).to.eql( `from logstash-* [METADATA _index, _id] | sort @timestamp desc | limit 500\n| WHERE \`bytes\`==0` ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show a top values popover for a keyword field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('extension.raw'); + await unifiedFieldList.clickFieldListItem('extension.raw'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Top values'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -189,17 +185,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '500 sample values' ); - await PageObjects.unifiedFieldList.clickFieldListPlusFilter('extension.raw', 'css'); + await unifiedFieldList.clickFieldListPlusFilter('extension.raw', 'css'); const editorValue = await monacoEditor.getCodeEditorValue(); expect(editorValue).to.eql( `from logstash-* [METADATA _index, _id] | sort @timestamp desc | limit 500\n| WHERE \`extension.raw\`=="css"` ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show a top values popover for an ip field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('clientip'); + await unifiedFieldList.clickFieldListItem('clientip'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Top values'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -210,17 +206,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '32 sample values' ); - await PageObjects.unifiedFieldList.clickFieldListPlusFilter('clientip', '216.126.255.31'); + await unifiedFieldList.clickFieldListPlusFilter('clientip', '216.126.255.31'); const editorValue = await monacoEditor.getCodeEditorValue(); expect(editorValue).to.eql( `from logstash-* [METADATA _index, _id] | sort @timestamp desc | limit 500\n| WHERE \`clientip\`::string=="216.126.255.31"` ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show a top values popover for _index field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('_index'); + await unifiedFieldList.clickFieldListItem('_index'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Top values'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -230,22 +226,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await testSubjects.getVisibleText('dscFieldStats-statsFooter')).to.contain( '500 sample values' ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should not have stats for a date field yet but create an is not null filter', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('@timestamp'); - await PageObjects.unifiedFieldList.clickFieldListExistsFilter('@timestamp'); + await unifiedFieldList.clickFieldListItem('@timestamp'); + await unifiedFieldList.clickFieldListExistsFilter('@timestamp'); const editorValue = await monacoEditor.getCodeEditorValue(); expect(editorValue).to.eql( `from logstash-* [METADATA _index, _id] | sort @timestamp desc | limit 500\n| WHERE \`@timestamp\` is not null` ); await testSubjects.missingOrFail('dscFieldStats-statsFooter'); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show examples for geo points field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('geo.coordinates'); + await unifiedFieldList.clickFieldListItem('geo.coordinates'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Examples'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -255,11 +251,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await testSubjects.getVisibleText('dscFieldStats-statsFooter')).to.contain( '100 sample records' ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show examples for text field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('extension'); + await unifiedFieldList.clickFieldListItem('extension'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Examples'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -270,17 +266,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '100 sample records' ); - await PageObjects.unifiedFieldList.clickFieldListPlusFilter('extension', 'css'); + await unifiedFieldList.clickFieldListPlusFilter('extension', 'css'); const editorValue = await monacoEditor.getCodeEditorValue(); expect(editorValue).to.eql( `from logstash-* [METADATA _index, _id] | sort @timestamp desc | limit 500\n| WHERE \`extension\`=="css"` ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show examples for _id field', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('_id'); + await unifiedFieldList.clickFieldListItem('_id'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Examples'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -290,17 +286,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await testSubjects.getVisibleText('dscFieldStats-statsFooter')).to.contain( '100 sample records' ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show a top values popover for a more complex query', async () => { const testQuery = `from logstash-* | sort @timestamp desc | limit 50 | stats avg(bytes) by geo.dest | limit 3`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - await PageObjects.unifiedFieldList.clickFieldListItem('avg(bytes)'); + await unifiedFieldList.clickFieldListItem('avg(bytes)'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Top values'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); @@ -309,38 +305,38 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '3 sample values' ); - await PageObjects.unifiedFieldList.clickFieldListPlusFilter('avg(bytes)', '5453'); + await unifiedFieldList.clickFieldListPlusFilter('avg(bytes)', '5453'); const editorValue = await monacoEditor.getCodeEditorValue(); expect(editorValue).to.eql( `from logstash-* | sort @timestamp desc | limit 50 | stats avg(bytes) by geo.dest | limit 3\n| WHERE \`avg(bytes)\`==5453` ); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); it('should show a top values popover for a boolean field', async () => { const testQuery = `row enabled = true`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); - await PageObjects.unifiedFieldList.clickFieldListItem('enabled'); + await unifiedFieldList.clickFieldListItem('enabled'); await testSubjects.existOrFail('dscFieldStats-topValues'); expect(await testSubjects.getVisibleText('dscFieldStats-title')).to.be('Top values'); const topValuesRows = await testSubjects.findAll('dscFieldStats-topValues-bucket'); expect(topValuesRows.length).to.eql(1); - expect(await PageObjects.unifiedFieldList.getFieldStatsTopValueBucketsVisibleText()).to.be( + expect(await unifiedFieldList.getFieldStatsTopValueBucketsVisibleText()).to.be( 'true\n100%' ); expect(await testSubjects.getVisibleText('dscFieldStats-statsFooter')).to.contain( '1 sample value' ); - await PageObjects.unifiedFieldList.clickFieldListMinusFilter('enabled', 'true'); + await unifiedFieldList.clickFieldListMinusFilter('enabled', 'true'); const editorValue = await monacoEditor.getCodeEditorValue(); expect(editorValue).to.eql(`row enabled = true\n| WHERE \`enabled\`!=true`); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); }); }); }); diff --git a/test/functional/apps/discover/group6/_time_field_column.ts b/test/functional/apps/discover/group6/_time_field_column.ts index 4ad9ecbdde715..f8279d532e6c4 100644 --- a/test/functional/apps/discover/group6/_time_field_column.ts +++ b/test/functional/apps/discover/group6/_time_field_column.ts @@ -17,7 +17,7 @@ const SEARCH_WITH_SELECTED_COLUMNS_AND_TIMESTAMP = 'searchWithSelectedColumnsAnd export default function ({ getService, getPageObjects }: FtrProviderContext) { const dataGrid = getService('dataGrid'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, dashboard, unifiedFieldList, header } = getPageObjects([ 'common', 'discover', 'timePicker', @@ -69,13 +69,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await dataGrid.getHeaderFields()).to.eql( hideTimeFieldColumnSetting || !hasTimeField ? ['Document'] : ['@timestamp', 'Document'] ); - await PageObjects.discover.saveSearch(`${SEARCH_NO_COLUMNS}${savedSearchSuffix}`); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch(`${SEARCH_NO_COLUMNS}${savedSearchSuffix}`); + await discover.waitUntilSearchingHasFinished(); const isTimestampUnavailableInSidebar = isEsqlMode && !hasTimeField; if (!isTimestampUnavailableInSidebar) { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await discover.waitUntilSearchingHasFinished(); await retry.try(async () => { expect(await dataGrid.getHeaderFields()).to.eql( !hasTimeField @@ -86,13 +86,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); }); - await PageObjects.discover.saveSearch( - `${SEARCH_WITH_ONLY_TIMESTAMP}${savedSearchSuffix}`, - true - ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch(`${SEARCH_WITH_ONLY_TIMESTAMP}${savedSearchSuffix}`, true); + await discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('@timestamp'); + await unifiedFieldList.clickFieldListItemRemove('@timestamp'); await retry.try(async () => { expect(await dataGrid.getHeaderFields()).to.eql( hideTimeFieldColumnSetting || !hasTimeField ? ['Document'] : ['@timestamp', 'Document'] @@ -101,12 +98,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } // check in Dashboard - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); + await common.navigateToApp('dashboard'); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch(`${SEARCH_NO_COLUMNS}${savedSearchSuffix}`); await dashboardAddPanel.closeAddPanel(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { expect(await dataGrid.getHeaderFields()).to.eql( @@ -116,11 +113,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { if (!isTimestampUnavailableInSidebar) { await dashboardPanelActions.removePanelByTitle(`${SEARCH_NO_COLUMNS}${savedSearchSuffix}`); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch(`${SEARCH_WITH_ONLY_TIMESTAMP}${savedSearchSuffix}`); await dashboardAddPanel.closeAddPanel(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { expect(await dataGrid.getHeaderFields()).to.eql( @@ -146,8 +143,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { isEsqlMode?: boolean; }) { // check in Discover - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('extension'); await retry.try(async () => { expect(await dataGrid.getHeaderFields()).to.eql( @@ -157,19 +154,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); }); - await PageObjects.discover.saveSearch(`${SEARCH_WITH_SELECTED_COLUMNS}${savedSearchSuffix}`); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch(`${SEARCH_WITH_SELECTED_COLUMNS}${savedSearchSuffix}`); + await discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('@timestamp'); + await unifiedFieldList.clickFieldListItemAdd('@timestamp'); await retry.try(async () => { expect(await dataGrid.getHeaderFields()).to.eql(['bytes', 'extension', '@timestamp']); }); - await PageObjects.discover.saveSearch( + await discover.saveSearch( `${SEARCH_WITH_SELECTED_COLUMNS_AND_TIMESTAMP}${savedSearchSuffix}`, true ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await dataGrid.clickMoveColumnLeft('@timestamp'); await retry.try(async () => { @@ -181,7 +178,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'bytes', 'extension']); }); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('@timestamp'); + await unifiedFieldList.clickFieldListItemRemove('@timestamp'); await retry.try(async () => { expect(await dataGrid.getHeaderFields()).to.eql( hideTimeFieldColumnSetting || !hasTimeField || isEsqlMode @@ -191,12 +188,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // check in Dashboard - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); + await common.navigateToApp('dashboard'); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch(`${SEARCH_WITH_SELECTED_COLUMNS}${savedSearchSuffix}`); await dashboardAddPanel.closeAddPanel(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { expect(await dataGrid.getHeaderFields()).to.eql( @@ -209,13 +206,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardPanelActions.removePanelByTitle( `${SEARCH_WITH_SELECTED_COLUMNS}${savedSearchSuffix}` ); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch( `${SEARCH_WITH_SELECTED_COLUMNS_AND_TIMESTAMP}${savedSearchSuffix}` ); await dashboardAddPanel.closeAddPanel(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { expect(await dataGrid.getHeaderFields()).to.eql(['bytes', 'extension', '@timestamp']); @@ -228,14 +225,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe(`should${hideTimeFieldColumnSetting ? ' not' : ''} add a time field column`, () => { beforeEach(async () => { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ ...defaultSettings, 'doc_table:legacy': false, 'doc_table:hideTimeColumn': hideTimeFieldColumnSetting, }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); describe('data view mode', () => { @@ -264,7 +261,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { adHoc: true, hasTimeField: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); it('should render initial columns correctly', async () => { @@ -287,7 +284,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('ESQL mode', () => { it('should render initial columns correctly', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); await checkInitialColumns({ hasTimeField: true, @@ -298,10 +295,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render initial columns correctly when no time field', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); await monacoEditor.setCodeEditorValue('from logstash-* | limit 10 | drop @timestamp'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await checkInitialColumns({ hasTimeField: false, @@ -312,7 +309,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render selected columns correctly', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); await checkSelectedColumns({ hasTimeField: true, @@ -331,55 +328,45 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'doc_table:hideTimeColumn': hideTimeFieldColumnSetting, 'doc_table:legacy': true, }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); it('should render initial columns correctly', async () => { // no columns - await PageObjects.discover.loadSavedSearch(`${SEARCH_NO_COLUMNS}${savedSearchSuffix}`); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(`${SEARCH_NO_COLUMNS}${savedSearchSuffix}`); + await discover.waitUntilSearchingHasFinished(); expect(await docTable.getHeaderFields()).to.eql( hideTimeFieldColumnSetting ? ['Document'] : ['@timestamp', 'Document'] ); - await PageObjects.discover.loadSavedSearch(`${SEARCH_NO_COLUMNS}${savedSearchSuffix}-`); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(`${SEARCH_NO_COLUMNS}${savedSearchSuffix}-`); + await discover.waitUntilSearchingHasFinished(); expect(await docTable.getHeaderFields()).to.eql(['Document']); - await PageObjects.discover.loadSavedSearch( - `${SEARCH_NO_COLUMNS}${savedSearchSuffix}ESQL` - ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(`${SEARCH_NO_COLUMNS}${savedSearchSuffix}ESQL`); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql( hideTimeFieldColumnSetting ? ['Document'] : ['@timestamp', 'Document'] ); - await PageObjects.discover.loadSavedSearch( - `${SEARCH_NO_COLUMNS}${savedSearchSuffix}ESQLdrop` - ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(`${SEARCH_NO_COLUMNS}${savedSearchSuffix}ESQLdrop`); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['Document']); // only @timestamp is selected - await PageObjects.discover.loadSavedSearch( - `${SEARCH_WITH_ONLY_TIMESTAMP}${savedSearchSuffix}` - ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(`${SEARCH_WITH_ONLY_TIMESTAMP}${savedSearchSuffix}`); + await discover.waitUntilSearchingHasFinished(); expect(await docTable.getHeaderFields()).to.eql( hideTimeFieldColumnSetting ? ['@timestamp'] : ['@timestamp', '@timestamp'] ); - await PageObjects.discover.loadSavedSearch( - `${SEARCH_WITH_ONLY_TIMESTAMP}${savedSearchSuffix}-` - ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(`${SEARCH_WITH_ONLY_TIMESTAMP}${savedSearchSuffix}-`); + await discover.waitUntilSearchingHasFinished(); expect(await docTable.getHeaderFields()).to.eql(['@timestamp']); - await PageObjects.discover.loadSavedSearch( - `${SEARCH_WITH_ONLY_TIMESTAMP}${savedSearchSuffix}ESQL` - ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(`${SEARCH_WITH_ONLY_TIMESTAMP}${savedSearchSuffix}ESQL`); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql( hideTimeFieldColumnSetting ? ['@timestamp'] : ['@timestamp', 'Document'] ); @@ -387,49 +374,45 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should render selected columns correctly', async () => { // with selected columns - await PageObjects.discover.loadSavedSearch( - `${SEARCH_WITH_SELECTED_COLUMNS}${savedSearchSuffix}` - ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(`${SEARCH_WITH_SELECTED_COLUMNS}${savedSearchSuffix}`); + await discover.waitUntilSearchingHasFinished(); expect(await docTable.getHeaderFields()).to.eql( hideTimeFieldColumnSetting ? ['bytes', 'extension'] : ['@timestamp', 'bytes', 'extension'] ); - await PageObjects.discover.loadSavedSearch( - `${SEARCH_WITH_SELECTED_COLUMNS}${savedSearchSuffix}-` - ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.loadSavedSearch(`${SEARCH_WITH_SELECTED_COLUMNS}${savedSearchSuffix}-`); + await discover.waitUntilSearchingHasFinished(); expect(await docTable.getHeaderFields()).to.eql(['bytes', 'extension']); - await PageObjects.discover.loadSavedSearch( + await discover.loadSavedSearch( `${SEARCH_WITH_SELECTED_COLUMNS}${savedSearchSuffix}ESQL` ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['bytes', 'extension']); // with selected columns and @timestamp - await PageObjects.discover.loadSavedSearch( + await discover.loadSavedSearch( `${SEARCH_WITH_SELECTED_COLUMNS_AND_TIMESTAMP}${savedSearchSuffix}` ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await docTable.getHeaderFields()).to.eql( hideTimeFieldColumnSetting ? ['bytes', 'extension', '@timestamp'] : ['@timestamp', 'bytes', 'extension', '@timestamp'] ); - await PageObjects.discover.loadSavedSearch( + await discover.loadSavedSearch( `${SEARCH_WITH_SELECTED_COLUMNS_AND_TIMESTAMP}${savedSearchSuffix}-` ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await docTable.getHeaderFields()).to.eql(['bytes', 'extension', '@timestamp']); - await PageObjects.discover.loadSavedSearch( + await discover.loadSavedSearch( `${SEARCH_WITH_SELECTED_COLUMNS_AND_TIMESTAMP}${savedSearchSuffix}ESQL` ); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['bytes', 'extension', '@timestamp']); }); }); diff --git a/test/functional/apps/discover/group6/_unsaved_changes_badge.ts b/test/functional/apps/discover/group6/_unsaved_changes_badge.ts index aedbc7f99372e..d1c6e42e34aa7 100644 --- a/test/functional/apps/discover/group6/_unsaved_changes_badge.ts +++ b/test/functional/apps/discover/group6/_unsaved_changes_badge.ts @@ -22,13 +22,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const filterBar = getService('filterBar'); const monacoEditor = getService('monacoEditor'); const browser = getService('browser'); - const PageObjects = getPageObjects([ - 'settings', + const { common, discover, header, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', 'timePicker', - 'dashboard', 'unifiedFieldList', ]); const security = getService('security'); @@ -51,65 +49,65 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); }); it('should not show the badge initially nor after changes to a draft saved search', async () => { await testSubjects.missingOrFail('unsavedChangesBadge'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); + await unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); }); it('should show the badge only after changes to a persisted saved search', async () => { - await PageObjects.discover.saveSearch(SAVED_SEARCH_NAME); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch(SAVED_SEARCH_NAME); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.discover.saveUnsavedChanges(); + await discover.saveUnsavedChanges(); await testSubjects.missingOrFail('unsavedChangesBadge'); }); it('should not show a badge after loading a saved search, only after changes', async () => { - await PageObjects.discover.loadSavedSearch(SAVED_SEARCH_NAME); + await discover.loadSavedSearch(SAVED_SEARCH_NAME); await testSubjects.missingOrFail('unsavedChangesBadge'); - await PageObjects.discover.chooseBreakdownField('_index'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.chooseBreakdownField('_index'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('unsavedChangesBadge'); }); it('should allow to revert changes', async () => { - await PageObjects.discover.loadSavedSearch(SAVED_SEARCH_NAME); + await discover.loadSavedSearch(SAVED_SEARCH_NAME); await testSubjects.missingOrFail('unsavedChangesBadge'); // test changes to columns expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'bytes']); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'bytes', 'extension']); await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'bytes']); await testSubjects.missingOrFail('unsavedChangesBadge'); @@ -118,13 +116,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await dataGrid.getCurrentSampleSizeValue()).to.be(500); await dataGrid.changeSampleSizeValue(250); await dataGrid.clickGridSettings(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('unsavedChangesBadge'); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentSampleSizeValue()).to.be(250); await dataGrid.clickGridSettings(); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); await testSubjects.missingOrFail('unsavedChangesBadge'); await dataGrid.clickGridSettings(); expect(await dataGrid.getCurrentSampleSizeValue()).to.be(500); @@ -133,95 +131,95 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // test changes to rows per page await dataGrid.checkCurrentRowsPerPageToBe(100); await dataGrid.changeRowsPerPageTo(25); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('unsavedChangesBadge'); await dataGrid.checkCurrentRowsPerPageToBe(25); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); await testSubjects.missingOrFail('unsavedChangesBadge'); await dataGrid.checkCurrentRowsPerPageToBe(100); }); it('should hide the badge once user manually reverts changes', async () => { - await PageObjects.discover.loadSavedSearch(SAVED_SEARCH_NAME); + await discover.loadSavedSearch(SAVED_SEARCH_NAME); await testSubjects.missingOrFail('unsavedChangesBadge'); // changes to columns expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'bytes']); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'bytes', 'extension']); await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.unifiedFieldList.clickFieldListItemRemove('extension'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemRemove('extension'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await dataGrid.getHeaderFields()).to.eql(['@timestamp', 'bytes']); await testSubjects.missingOrFail('unsavedChangesBadge'); // test changes to breakdown field - await PageObjects.discover.chooseBreakdownField('_index'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.chooseBreakdownField('_index'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.discover.clearBreakdownField(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.clearBreakdownField(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); }); it('should not show the badge after pinning the first filter but after disabling a filter', async () => { await filterBar.addFilter({ field: 'extension', operation: 'is', value: 'png' }); await filterBar.addFilter({ field: 'bytes', operation: 'exists' }); - await PageObjects.discover.saveSearch(SAVED_SEARCH_WITH_FILTERS_NAME); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch(SAVED_SEARCH_WITH_FILTERS_NAME); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); await filterBar.toggleFilterPinned('extension'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await filterBar.isFilterPinned('extension')).to.be(true); await testSubjects.missingOrFail('unsavedChangesBadge'); await filterBar.toggleFilterNegated('bytes'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); expect(await filterBar.isFilterNegated('bytes')).to.be(true); await testSubjects.existOrFail('unsavedChangesBadge'); - await PageObjects.discover.revertUnsavedChanges(); + await discover.revertUnsavedChanges(); await testSubjects.missingOrFail('unsavedChangesBadge'); expect(await filterBar.getFilterCount()).to.be(2); expect(await filterBar.isFilterPinned('extension')).to.be(false); expect(await filterBar.isFilterNegated('bytes')).to.be(false); - expect(await PageObjects.discover.getHitCount()).to.be('1,373'); + expect(await discover.getHitCount()).to.be('1,373'); }); it('should not show a badge after loading an ES|QL saved search, only after changes', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); await monacoEditor.setCodeEditorValue('from logstash-* | limit 10'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); - await PageObjects.discover.saveSearch(SAVED_SEARCH_ESQL); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.saveSearch(SAVED_SEARCH_ESQL); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.missingOrFail('unsavedChangesBadge'); await monacoEditor.setCodeEditorValue('from logstash-* | limit 100'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('unsavedChangesBadge'); }); diff --git a/test/functional/apps/discover/group6/_view_mode_toggle.ts b/test/functional/apps/discover/group6/_view_mode_toggle.ts index 25a4a68ab8d6c..21882a9dffc73 100644 --- a/test/functional/apps/discover/group6/_view_mode_toggle.ts +++ b/test/functional/apps/discover/group6/_view_mode_toggle.ts @@ -11,11 +11,10 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { common, discover, timePicker, unifiedFieldList, header } = getPageObjects([ 'common', 'discover', 'timePicker', - 'dashboard', 'unifiedFieldList', 'header', ]); @@ -45,13 +44,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { [true, false].forEach((useLegacyTable) => { describe(`isLegacy: ${useLegacyTable}`, function () { before(async function () { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ ...defaultSettings, 'doc_table:legacy': useLegacyTable, }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); }); after(async () => { @@ -78,13 +77,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show an error callout', async () => { await queryBar.setQuery('@message::'); // invalid await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.discover.showsErrorCallout(); + await discover.showsErrorCallout(); await queryBar.clearQuery(); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.missingOrFail('discoverErrorCalloutTitle'); }); @@ -118,7 +117,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.existOrFail('dscViewModeToggle'); - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); await testSubjects.existOrFail('dscViewModeToggle'); @@ -129,8 +128,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show ES|QL columns callout', async () => { await testSubjects.missingOrFail('dscSelectedColumnsCallout'); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('extension'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('extension'); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('dscSelectedColumnsCallout'); }); }); diff --git a/test/functional/apps/discover/group7/_huge_fields.ts b/test/functional/apps/discover/group7/_huge_fields.ts index 43b2c6466e057..bf07991146d0a 100644 --- a/test/functional/apps/discover/group7/_huge_fields.ts +++ b/test/functional/apps/discover/group7/_huge_fields.ts @@ -13,7 +13,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const security = getService('security'); - const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'timePicker']); + const { common, discover } = getPageObjects(['common', 'discover']); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); @@ -26,11 +26,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.update({ 'timepicker:timeDefaults': `{ "from": "2016-10-05T00:00:00", "to": "2016-10-06T00:00:00"}`, }); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); it('test_huge data should have expected number of fields', async function () { - await PageObjects.discover.selectIndexPattern('testhuge*'); + await discover.selectIndexPattern('testhuge*'); // initially this field should not be rendered const fieldExistsBeforeScrolling = await testSubjects.exists('field-myvar1050'); expect(fieldExistsBeforeScrolling).to.be(false); diff --git a/test/functional/apps/discover/group7/_indexpattern_with_unmapped_fields.ts b/test/functional/apps/discover/group7/_indexpattern_with_unmapped_fields.ts index f8ca905cca5a8..7af4ec11f7997 100644 --- a/test/functional/apps/discover/group7/_indexpattern_with_unmapped_fields.ts +++ b/test/functional/apps/discover/group7/_indexpattern_with_unmapped_fields.ts @@ -15,7 +15,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const security = getService('security'); const retry = getService('retry'); - const PageObjects = getPageObjects(['common', 'timePicker', 'discover', 'unifiedFieldList']); + const { common, discover, unifiedFieldList } = getPageObjects([ + 'common', + 'discover', + 'unifiedFieldList', + ]); describe('index pattern with unmapped fields', () => { before(async () => { @@ -32,8 +36,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'timepicker:timeDefaults': `{ "from": "${fromTime}", "to": "${toTime}"}`, }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('test-index-unmapped-fields'); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('test-index-unmapped-fields'); }); after(async () => { @@ -47,42 +51,42 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('unmapped fields exist on a new saved search', async () => { const expectedHitCount = '4'; await retry.try(async function () { - expect(await PageObjects.discover.getHitCount()).to.be(expectedHitCount); + expect(await discover.getHitCount()).to.be(expectedHitCount); }); - let allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); + let allFields = await unifiedFieldList.getAllFieldNames(); // message is a mapped field expect(allFields.includes('message')).to.be(true); // sender is not a mapped field expect(allFields.includes('sender')).to.be(false); - await PageObjects.unifiedFieldList.toggleSidebarSection('unmapped'); + await unifiedFieldList.toggleSidebarSection('unmapped'); - allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); + allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('sender')).to.be(true); // now visible under Unmapped section - await PageObjects.unifiedFieldList.toggleSidebarSection('unmapped'); + await unifiedFieldList.toggleSidebarSection('unmapped'); }); it('unmapped fields exist on an existing saved search', async () => { - await PageObjects.discover.loadSavedSearch('Existing Saved Search'); + await discover.loadSavedSearch('Existing Saved Search'); const expectedHitCount = '4'; await retry.try(async function () { - expect(await PageObjects.discover.getHitCount()).to.be(expectedHitCount); + expect(await discover.getHitCount()).to.be(expectedHitCount); }); - let allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); + let allFields = await unifiedFieldList.getAllFieldNames(); expect(allFields.includes('message')).to.be(true); expect(allFields.includes('sender')).to.be(false); expect(allFields.includes('receiver')).to.be(false); - await PageObjects.unifiedFieldList.toggleSidebarSection('unmapped'); + await unifiedFieldList.toggleSidebarSection('unmapped'); - allFields = await PageObjects.unifiedFieldList.getAllFieldNames(); + allFields = await unifiedFieldList.getAllFieldNames(); // now visible under Unmapped section expect(allFields.includes('sender')).to.be(true); expect(allFields.includes('receiver')).to.be(true); - await PageObjects.unifiedFieldList.toggleSidebarSection('unmapped'); + await unifiedFieldList.toggleSidebarSection('unmapped'); }); }); } diff --git a/test/functional/apps/discover/group7/_indexpattern_without_timefield.ts b/test/functional/apps/discover/group7/_indexpattern_without_timefield.ts index adb96e28222da..d8eb3319f077b 100644 --- a/test/functional/apps/discover/group7/_indexpattern_without_timefield.ts +++ b/test/functional/apps/discover/group7/_indexpattern_without_timefield.ts @@ -17,7 +17,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const security = getService('security'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'timePicker', 'discover', 'header']); + const { common, timePicker, discover, header } = getPageObjects([ + 'common', + 'timePicker', + 'discover', + 'header', + ]); describe('indexpattern without timefield', () => { before(async () => { @@ -33,7 +38,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { defaultIndex: 'without-timefield', 'timepicker:timeDefaults': '{ "from": "2019-01-18T19:37:13.000Z", "to": "now"}', }); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async () => { @@ -47,43 +52,43 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not display a timepicker', async () => { - if (await PageObjects.timePicker.timePickerExists()) { + if (await timePicker.timePickerExists()) { throw new Error('Expected timepicker not to exist'); } }); it('should adapt sidebar fields when switching', async () => { - await PageObjects.discover.selectIndexPattern('with-timefield'); + await discover.selectIndexPattern('with-timefield'); const timefieldExistsWithTimefield = await testSubjects.exists('field-@timestamp'); expect(timefieldExistsWithTimefield).to.be(true); - await PageObjects.discover.selectIndexPattern('without-timefield'); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await discover.selectIndexPattern('without-timefield'); + await discover.waitForDocTableLoadingComplete(); const timefieldExistsWithoutTimefield = await testSubjects.exists('field-@timestamp'); expect(timefieldExistsWithoutTimefield).to.be(false); }); it('should display a timepicker after switching to an index pattern with timefield', async () => { - await PageObjects.discover.selectIndexPattern('with-timefield'); - await PageObjects.discover.waitForDocTableLoadingComplete(); - if (!(await PageObjects.timePicker.timePickerExists())) { + await discover.selectIndexPattern('with-timefield'); + await discover.waitForDocTableLoadingComplete(); + if (!(await timePicker.timePickerExists())) { throw new Error('Expected timepicker to exist'); } }); it('should switch between with and without timefield using the browser back button', async () => { - await PageObjects.discover.selectIndexPattern('without-timefield'); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await discover.selectIndexPattern('without-timefield'); + await discover.waitForDocTableLoadingComplete(); await retry.waitForWithTimeout( 'The timepicker not to exist', 5000, - async () => !(await PageObjects.timePicker.timePickerExists()) + async () => !(await timePicker.timePickerExists()) ); - await PageObjects.discover.selectIndexPattern('with-timefield'); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await discover.selectIndexPattern('with-timefield'); + await discover.waitForDocTableLoadingComplete(); await retry.waitForWithTimeout( 'The timepicker to exist', 5000, - async () => await PageObjects.timePicker.timePickerExists() + async () => await timePicker.timePickerExists() ); await retry.waitForWithTimeout( 'index pattern to have been switched back to "without-timefield"', @@ -91,7 +96,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { async () => { // Navigating back await browser.goBack(); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await discover.waitForDocTableLoadingComplete(); return ( (await testSubjects.getVisibleText('discover-dataView-switch-link')) === 'without-timefield' @@ -102,49 +107,49 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.waitForWithTimeout( 'The timepicker not to exist', 5000, - async () => !(await PageObjects.timePicker.timePickerExists()) + async () => !(await timePicker.timePickerExists()) ); }); it('should disable the auto refresh interval when switching to a data view without a time field', async () => { const autoRefreshInterval = 5; - await PageObjects.discover.selectIndexPattern('with-timefield'); - await PageObjects.timePicker.startAutoRefresh(autoRefreshInterval); + await discover.selectIndexPattern('with-timefield'); + await timePicker.startAutoRefresh(autoRefreshInterval); let url = await browser.getCurrentUrl(); expect(url).to.contain(`refreshInterval:(pause:!f,value:${autoRefreshInterval * 1000})`); - await PageObjects.discover.selectIndexPattern('without-timefield'); + await discover.selectIndexPattern('without-timefield'); url = await browser.getCurrentUrl(); expect(url).to.contain(`refreshInterval:(pause:!t,value:${autoRefreshInterval * 1000})`); }); it('should allow switching from a saved search with a time field to a saved search without a time field', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('with-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.saveSearch('with-timefield'); - await PageObjects.discover.selectIndexPattern('without-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.saveSearch('without-timefield', true); - await PageObjects.discover.loadSavedSearch('with-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.loadSavedSearch('without-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.assertHitCount('1'); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('with-timefield'); + await header.waitUntilLoadingHasFinished(); + await discover.saveSearch('with-timefield'); + await discover.selectIndexPattern('without-timefield'); + await header.waitUntilLoadingHasFinished(); + await discover.saveSearch('without-timefield', true); + await discover.loadSavedSearch('with-timefield'); + await header.waitUntilLoadingHasFinished(); + await discover.loadSavedSearch('without-timefield'); + await header.waitUntilLoadingHasFinished(); + await discover.assertHitCount('1'); }); it('should allow switching from data views with different timefields and sort correctly', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('with-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('with-timefield'); + await header.waitUntilLoadingHasFinished(); let url = await browser.getCurrentUrl(); expect(url).to.contain(`@timestamp`); - await PageObjects.discover.selectIndexPattern('with-different-timefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectIndexPattern('with-different-timefield'); + await header.waitUntilLoadingHasFinished(); url = await browser.getCurrentUrl(); expect(url).to.contain(`with-different-timefield`); await browser.goBack(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); url = await browser.getCurrentUrl(); expect(url).to.contain(`@timestamp`); }); diff --git a/test/functional/apps/discover/group7/_new_search.ts b/test/functional/apps/discover/group7/_new_search.ts index 48ac6c239ecfa..d983415399a32 100644 --- a/test/functional/apps/discover/group7/_new_search.ts +++ b/test/functional/apps/discover/group7/_new_search.ts @@ -12,12 +12,11 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, header } = getPageObjects([ 'common', 'discover', 'timePicker', 'header', - 'unifiedSearch', ]); const kibanaServer = getService('kibanaServer'); const filterBar = getService('filterBar'); @@ -33,8 +32,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); after(async () => { @@ -46,18 +45,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should work correctly for data view mode', async function () { await filterBar.addFilter({ field: 'extension', operation: 'is', value: 'png' }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await queryBar.setQuery('bytes > 15000'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCount()).to.be('353'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + expect(await discover.getHitCount()).to.be('353'); expect(await filterBar.hasFilter('extension', 'png')).to.be(true); expect(await queryBar.getQueryString()).to.be('bytes > 15000'); - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCount()).to.be('14,004'); + await discover.clickNewSearchButton(); + await discover.waitUntilSearchingHasFinished(); + expect(await discover.getHitCount()).to.be('14,004'); expect(await filterBar.hasFilter('extension', 'png')).to.be(false); expect(await queryBar.getQueryString()).to.be(''); }); @@ -68,25 +67,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { adHoc: true, hasTimeField: true, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await filterBar.addFilter({ field: 'extension', operation: 'is', value: 'css' }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await queryBar.setQuery('bytes > 100'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCount()).to.be('2,108'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + expect(await discover.getHitCount()).to.be('2,108'); expect(await filterBar.hasFilter('extension', 'css')).to.be(true); expect(await queryBar.getQueryString()).to.be('bytes > 100'); - await PageObjects.discover.saveSearch('adHoc'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCount()).to.be('2,108'); + await discover.saveSearch('adHoc'); + await discover.waitUntilSearchingHasFinished(); + expect(await discover.getHitCount()).to.be('2,108'); - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCount()).to.be('14,004'); + await discover.clickNewSearchButton(); + await discover.waitUntilSearchingHasFinished(); + expect(await discover.getHitCount()).to.be('14,004'); expect(await filterBar.hasFilter('extension', 'css')).to.be(false); expect(await queryBar.getQueryString()).to.be(''); expect(await dataViews.getSelectedName()).to.be('logs**'); @@ -94,41 +93,41 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should work correctly for ESQL mode', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | limit 100 | stats countB = count(bytes) by geo.dest | sort countB`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCountInt()).to.greaterThan(10); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('lensSuggestion'); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + expect(await discover.getHitCountInt()).to.greaterThan(10); + expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion'); - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.clickNewSearchButton(); + await discover.waitUntilSearchingHasFinished(); expect(await monacoEditor.getCodeEditorValue()).to.be('FROM logstash-* | LIMIT 10'); - expect(await PageObjects.discover.getVisContextSuggestionType()).to.be('histogramForESQL'); - expect(await PageObjects.discover.getHitCount()).to.be('10'); + expect(await discover.getVisContextSuggestionType()).to.be('histogramForESQL'); + expect(await discover.getHitCount()).to.be('10'); }); it('should work correctly for a saved search in ESQL mode', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from logstash-* | limit 100 | stats countB = count(bytes) by geo.dest | sort countB`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCountInt()).to.greaterThan(10); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); + expect(await discover.getHitCountInt()).to.greaterThan(10); - await PageObjects.discover.saveSearch('esql'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - expect(await PageObjects.discover.getHitCountInt()).to.greaterThan(10); + await discover.saveSearch('esql'); + await discover.waitUntilSearchingHasFinished(); + expect(await discover.getHitCountInt()).to.greaterThan(10); - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.clickNewSearchButton(); + await discover.waitUntilSearchingHasFinished(); expect(await monacoEditor.getCodeEditorValue()).to.be('FROM logstash-* | LIMIT 10'); - expect(await PageObjects.discover.getHitCount()).to.be('10'); + expect(await discover.getHitCount()).to.be('10'); }); }); } diff --git a/test/functional/apps/discover/group7/_request_cancellation.ts b/test/functional/apps/discover/group7/_request_cancellation.ts index d9f57091254d6..55ab8f8bdd638 100644 --- a/test/functional/apps/discover/group7/_request_cancellation.ts +++ b/test/functional/apps/discover/group7/_request_cancellation.ts @@ -17,30 +17,35 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const filterBar = getService('filterBar'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'header']); + const { common, discover, timePicker, header } = getPageObjects([ + 'common', + 'discover', + 'timePicker', + 'header', + ]); describe('Discover request cancellation', () => { before(async () => { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); after(async () => { await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); }); beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); it('should allow cancelling active requests', async () => { - await PageObjects.discover.selectIndexPattern('logstash-*'); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect(await PageObjects.discover.hasNoResults()).to.be(false); + await discover.selectIndexPattern('logstash-*'); + await header.waitUntilLoadingHasFinished(); + expect(await discover.hasNoResults()).to.be(false); await testSubjects.existOrFail('querySubmitButton'); await testSubjects.missingOrFail('queryCancelButton'); await filterBar.addDslFilter( @@ -63,7 +68,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await testSubjects.click('queryCancelButton'); await retry.try(async () => { - expect(await PageObjects.discover.hasNoResults()).to.be(true); + expect(await discover.hasNoResults()).to.be(true); await testSubjects.existOrFail('querySubmitButton'); await testSubjects.missingOrFail('queryCancelButton'); }); diff --git a/test/functional/apps/discover/group7/_runtime_fields_editor.ts b/test/functional/apps/discover/group7/_runtime_fields_editor.ts index 97da057d78237..ab8711c362b77 100644 --- a/test/functional/apps/discover/group7/_runtime_fields_editor.ts +++ b/test/functional/apps/discover/group7/_runtime_fields_editor.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const security = getService('security'); const dataGrid = getService('dataGrid'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects([ + const { common, discover, header, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', @@ -38,7 +38,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await fieldEditor.typeScript("emit('abc')"); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }; describe('discover integration with runtime fields editor', function describeIndexTests() { @@ -47,8 +47,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); after(async () => { @@ -59,50 +59,48 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('allows adding custom label to existing fields', async function () { const customLabel = 'megabytes'; - await PageObjects.discover.editField('bytes'); + await discover.editField('bytes'); await fieldEditor.enableCustomLabel(); await fieldEditor.setCustomLabel(customLabel); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect((await PageObjects.unifiedFieldList.getAllFieldNames()).includes(customLabel)).to.be( - true - ); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('bytes'); - expect(await PageObjects.discover.getDocHeader()).to.have.string(customLabel); + await header.waitUntilLoadingHasFinished(); + expect((await unifiedFieldList.getAllFieldNames()).includes(customLabel)).to.be(true); + await unifiedFieldList.clickFieldListItemAdd('bytes'); + expect(await discover.getDocHeader()).to.have.string(customLabel); }); it('allows adding custom description to existing fields', async function () { const customDescription = 'custom agent description here'; const customDescription2 = `${customDescription} updated`; // set a custom description - await PageObjects.discover.editField('agent'); + await discover.editField('agent'); await fieldEditor.enableCustomDescription(); await fieldEditor.setCustomDescription(customDescription); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItem('agent'); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItem('agent'); await retry.waitFor('field popover text', async () => { return (await testSubjects.getVisibleText('fieldDescription-agent')) === customDescription; }); - await PageObjects.unifiedFieldList.clickFieldListItemToggle('agent'); + await unifiedFieldList.clickFieldListItemToggle('agent'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); // edit the custom description again - await PageObjects.discover.editField('agent'); + await discover.editField('agent'); await fieldEditor.enableCustomDescription(); await fieldEditor.setCustomDescription(customDescription2); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItem('agent'); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItem('agent'); await retry.waitFor('field popover text', async () => { return (await testSubjects.getVisibleText('fieldDescription-agent')) === customDescription2; }); - await PageObjects.unifiedFieldList.clickFieldListItemToggle('agent'); + await unifiedFieldList.clickFieldListItemToggle('agent'); // check it in the doc viewer too await dataGrid.clickRowToggle({ rowIndex: 0 }); @@ -115,13 +113,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('allows to replace ECS description with a custom field description', async function () { - await PageObjects.unifiedFieldList.clickFieldListItem('@timestamp'); + await unifiedFieldList.clickFieldListItem('@timestamp'); await retry.waitFor('field popover text', async () => { return (await testSubjects.getVisibleText('fieldDescription-@timestamp')).startsWith( 'Date' ); }); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); // check it in the doc viewer too await dataGrid.clickRowToggle({ rowIndex: 0 }); await dataGrid.expandFieldNameCellInFlyout('@timestamp'); @@ -134,19 +132,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const customDescription = 'custom @timestamp description here'; // set a custom description - await PageObjects.discover.editField('@timestamp'); + await discover.editField('@timestamp'); await fieldEditor.enableCustomDescription(); await fieldEditor.setCustomDescription(customDescription); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItem('@timestamp'); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItem('@timestamp'); await retry.waitFor('field popover text', async () => { return ( (await testSubjects.getVisibleText('fieldDescription-@timestamp')) === customDescription ); }); - await PageObjects.unifiedFieldList.closeFieldPopover(); + await unifiedFieldList.closeFieldPopover(); // check it in the doc viewer too await dataGrid.clickRowToggle({ rowIndex: 0 }); await dataGrid.expandFieldNameCellInFlyout('@timestamp'); @@ -162,7 +160,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show a validation error when adding a too long custom description to existing fields', async function () { const customDescription = 'custom bytes long description here'.repeat(10); // set a custom description - await PageObjects.discover.editField('bytes'); + await discover.editField('bytes'); await fieldEditor.enableCustomDescription(); await fieldEditor.setCustomDescription(customDescription); await fieldEditor.save(); @@ -176,12 +174,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const field = '_runtimefield'; await createRuntimeField(field); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitForDocTableLoadingComplete(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await discover.waitForDocTableLoadingComplete(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); await retry.waitFor('fieldNames to include runtimefield', async () => { - const fieldNames = await PageObjects.unifiedFieldList.getAllFieldNames(); + const fieldNames = await unifiedFieldList.getAllFieldNames(); return fieldNames.includes(field); }); }); @@ -190,17 +188,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const field = '_runtimefield-before-edit'; await createRuntimeField(field); const newFieldName = '_runtimefield-after-edit'; - await PageObjects.discover.editField(field); + await discover.editField(field); await fieldEditor.setName(newFieldName, true); await fieldEditor.save(); await fieldEditor.confirmSave(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitForDocTableLoadingComplete(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await discover.waitForDocTableLoadingComplete(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); await retry.waitForWithTimeout('fieldNames to include edits', 5000, async () => { - const fieldNames = await PageObjects.unifiedFieldList.getAllFieldNames(); + const fieldNames = await unifiedFieldList.getAllFieldNames(); return fieldNames.includes(newFieldName); }); }); @@ -208,26 +206,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('allows creation of a new field and use it in a saved search', async function () { const fieldName = '_runtimefield-saved-search'; await createRuntimeField(fieldName); - await PageObjects.unifiedFieldList.clickFieldListItemAdd(fieldName); - expect(await PageObjects.discover.getDocHeader()).to.have.string(fieldName); - expect(await PageObjects.discover.saveSearch('Saved Search with runtimefield')); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd(fieldName); + expect(await discover.getDocHeader()).to.have.string(fieldName); + expect(await discover.saveSearch('Saved Search with runtimefield')); + await header.waitUntilLoadingHasFinished(); - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.clickNewSearchButton(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.discover.loadSavedSearch('Saved Search with runtimefield'); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect(await PageObjects.discover.getDocHeader()).to.have.string(fieldName); + await discover.loadSavedSearch('Saved Search with runtimefield'); + await header.waitUntilLoadingHasFinished(); + expect(await discover.getDocHeader()).to.have.string(fieldName); }); it('deletes a runtime field', async function () { const fieldName = '_runtimefield-to-delete'; await createRuntimeField(fieldName); - await PageObjects.discover.removeField(fieldName); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.removeField(fieldName); + await header.waitUntilLoadingHasFinished(); await retry.waitForWithTimeout('fieldNames to include edits', 5000, async () => { - const fieldNames = await PageObjects.unifiedFieldList.getAllFieldNames(); + const fieldNames = await unifiedFieldList.getAllFieldNames(); return !fieldNames.includes(fieldName); }); }); @@ -236,8 +234,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // navigate to doc view const fieldName = '_runtimefield-doc-view'; await createRuntimeField(fieldName); - const table = await PageObjects.discover.getDocTable(); - const useLegacyTable = await PageObjects.discover.useLegacyTable(); + const table = await discover.getDocTable(); + const useLegacyTable = await discover.useLegacyTable(); await table.clickRowToggle(); // click the open action diff --git a/test/functional/apps/discover/group7/_search_on_page_load.ts b/test/functional/apps/discover/group7/_search_on_page_load.ts index 95fcba1fe8499..64784d1cc74a9 100644 --- a/test/functional/apps/discover/group7/_search_on_page_load.ts +++ b/test/functional/apps/discover/group7/_search_on_page_load.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const queryBar = getService('queryBar'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects([ + const { common, discover, header, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', @@ -36,12 +36,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const initSearchOnPageLoad = async (searchOnPageLoad: boolean) => { await kibanaServer.uiSettings.replace({ 'discover:searchOnPageLoad': searchOnPageLoad }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.awaitKibanaChrome(); + await common.navigateToApp('discover'); + await header.awaitKibanaChrome(); }; const waitForFetches = (fetchesNumber: number) => async () => { - const nrOfFetches = await PageObjects.discover.getNrOfFetches(); + const nrOfFetches = await discover.getNrOfFetches(); log.debug('actual number of fetches', nrOfFetches); return nrOfFetches === fetchesNumber; }; @@ -61,7 +61,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); await kibanaServer.uiSettings.replace(defaultSettings); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async () => { @@ -79,88 +79,88 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should not fetch data from ES initially', async function () { expect(await testSubjects.exists(refreshButtonSelector)).to.be(true); await retry.waitFor('number of fetches to be 0', waitForFetches(0)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(false); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(false); }); it('should not fetch on indexPattern change', async function () { expect(await testSubjects.exists(refreshButtonSelector)).to.be(true); await retry.waitFor('number of fetches to be 0', waitForFetches(0)); - await PageObjects.discover.selectIndexPattern('date-nested'); + await discover.selectIndexPattern('date-nested'); expect(await testSubjects.exists(refreshButtonSelector)).to.be(true); await retry.waitFor('number of fetches to be 0', waitForFetches(0)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(false); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(false); }); it('should fetch data from ES after refreshDataButton click', async function () { expect(await testSubjects.exists(refreshButtonSelector)).to.be(true); await retry.waitFor('number of fetches to be 0', waitForFetches(0)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(false); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(false); await testSubjects.click(refreshButtonSelector); await testSubjects.missingOrFail(refreshButtonSelector); await retry.waitFor('number of fetches to be 1', waitForFetches(1)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(true); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(true); }); it('should fetch data from ES after submit query', async function () { expect(await testSubjects.exists(refreshButtonSelector)).to.be(true); await retry.waitFor('number of fetches to be 0', waitForFetches(0)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(false); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(false); await queryBar.submitQuery(); await testSubjects.missingOrFail(refreshButtonSelector); await retry.waitFor('number of fetches to be 1', waitForFetches(1)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(true); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(true); }); it('should fetch data from ES after choosing commonly used time range', async function () { - await PageObjects.discover.selectIndexPattern('logstash-*'); + await discover.selectIndexPattern('logstash-*'); expect(await testSubjects.exists(refreshButtonSelector)).to.be(true); await retry.waitFor('number of fetches to be 0', waitForFetches(0)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(false); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(false); - await PageObjects.timePicker.setCommonlyUsedTime('This_week'); + await timePicker.setCommonlyUsedTime('This_week'); await testSubjects.missingOrFail(refreshButtonSelector); await retry.waitFor('number of fetches to be 1', waitForFetches(1)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(true); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(true); }); it('should fetch data when a search is saved', async function () { - await PageObjects.discover.selectIndexPattern('logstash-*'); + await discover.selectIndexPattern('logstash-*'); await retry.waitFor('number of fetches to be 0', waitForFetches(0)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(false); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(false); - await PageObjects.discover.saveSearch(savedSearchName); + await discover.saveSearch(savedSearchName); await retry.waitFor('number of fetches to be 1', waitForFetches(1)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(true); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(true); }); it('should reset state after opening a saved search and pressing New', async function () { - await PageObjects.discover.loadSavedSearch(savedSearchName); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.loadSavedSearch(savedSearchName); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('number of fetches to be 1', waitForFetches(1)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(true); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(true); await testSubjects.click('discoverNewButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('number of fetches to be 0', waitForFetches(0)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(false); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(false); }); }); it(`when it's true should fetch data from ES initially`, async function () { await initSearchOnPageLoad(true); await retry.waitFor('number of fetches to be 1', waitForFetches(1)); - expect(await PageObjects.unifiedFieldList.doesSidebarShowFields()).to.be(true); + expect(await unifiedFieldList.doesSidebarShowFields()).to.be(true); }); }); } diff --git a/test/functional/apps/discover/group8/_default_route.ts b/test/functional/apps/discover/group8/_default_route.ts index 6c32ce186f0e1..f1529fac1dfec 100644 --- a/test/functional/apps/discover/group8/_default_route.ts +++ b/test/functional/apps/discover/group8/_default_route.ts @@ -12,14 +12,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects([ - 'common', - 'home', - 'settings', - 'discover', - 'timePicker', - 'header', - ]); + const { discover, timePicker, header } = getPageObjects(['discover', 'timePicker', 'header']); const kibanaServer = getService('kibanaServer'); const security = getService('security'); const retry = getService('retry'); @@ -34,7 +27,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); after(async () => { @@ -49,11 +42,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { defaultRoute: '/app/discover#/view/ab12e3c0-f231-11e6-9486-733b1ac9221a', }); await browser.navigateTo(deployment.getHostPort()); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.try(async () => { - expect(await PageObjects.discover.getCurrentQueryName()).to.be('A Saved Search'); - expect(await PageObjects.discover.getHitCount()).to.be('14,004'); + expect(await discover.getCurrentQueryName()).to.be('A Saved Search'); + expect(await discover.getHitCount()).to.be('14,004'); }); }); @@ -63,12 +56,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { "/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:60000),time:(from:'2015-09-19T06:31:44.000Z',to:'2015-09-23T18:31:44.000Z'))&_a=(columns:!(extension,host),dataSource:(dataViewId:'logstash-*',type:dataView),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,field:extension.raw,index:'logstash-*',key:extension.raw,negate:!f,params:(query:jpg),type:phrase),query:(match_phrase:(extension.raw:jpg)))),hideChart:!f,interval:auto,query:(language:lucene,query:media),sort:!(!('@timestamp',desc)))", }); await browser.navigateTo(deployment.getHostPort()); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.try(async () => { expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true); expect(await queryBar.getQueryString()).to.be('media'); - expect(await PageObjects.discover.getHitCount()).to.be('9,109'); + expect(await discover.getHitCount()).to.be('9,109'); }); }); }); diff --git a/test/functional/apps/discover/group8/_hide_announcements.ts b/test/functional/apps/discover/group8/_hide_announcements.ts index 993d0ff74f123..aa1943b687c3f 100644 --- a/test/functional/apps/discover/group8/_hide_announcements.ts +++ b/test/functional/apps/discover/group8/_hide_announcements.ts @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'timePicker']); + const { common, discover, timePicker } = getPageObjects(['common', 'discover', 'timePicker']); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); const browser = getService('browser'); @@ -24,8 +24,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); }); after(async () => { @@ -33,7 +33,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should display take tour button', async function () { - await PageObjects.discover.selectIndexPattern('logstash-*'); + await discover.selectIndexPattern('logstash-*'); const tourButtonExists = await testSubjects.exists('discoverTakeTourButton'); expect(tourButtonExists).to.be(true); }); diff --git a/test/functional/apps/visualize/group1/_chart_types.ts b/test/functional/apps/visualize/group1/_chart_types.ts index 2ac025712f3fc..5b38fb26173b0 100644 --- a/test/functional/apps/visualize/group1/_chart_types.ts +++ b/test/functional/apps/visualize/group1/_chart_types.ts @@ -13,27 +13,27 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); - const PageObjects = getPageObjects(['visualize']); + const { visualize } = getPageObjects(['visualize']); describe('chart types', function () { before(async function () { - await PageObjects.visualize.initTests(); + await visualize.initTests(); log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewVisualization(); + await visualize.navigateToNewVisualization(); }); it('should show the promoted vis types for the first step', async function () { const expectedChartTypes = ['Custom visualization', 'Lens', 'Maps', 'TSVB']; // find all the chart types and make sure there all there - const chartTypes = (await PageObjects.visualize.getPromotedVisTypes()).sort(); + const chartTypes = (await visualize.getPromotedVisTypes()).sort(); log.debug('returned chart types = ' + chartTypes); log.debug('expected chart types = ' + expectedChartTypes); expect(chartTypes).to.eql(expectedChartTypes); }); it('should show the correct agg based chart types', async function () { - await PageObjects.visualize.clickAggBasedVisualizations(); + await visualize.clickAggBasedVisualizations(); const expectedChartTypes = [ 'Area', 'Data table', @@ -50,7 +50,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]; // find all the chart types and make sure there all there - const chartTypes = (await PageObjects.visualize.getChartTypes()).sort(); + const chartTypes = (await visualize.getChartTypes()).sort(); log.debug('returned chart types = ' + chartTypes); log.debug('expected chart types = ' + expectedChartTypes); expect(chartTypes).to.eql(expectedChartTypes); diff --git a/test/functional/apps/visualize/group1/_data_table.ts b/test/functional/apps/visualize/group1/_data_table.ts index debe6a368579c..9bff7e68f8dec 100644 --- a/test/functional/apps/visualize/group1/_data_table.ts +++ b/test/functional/apps/visualize/group1/_data_table.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects([ + const { visualize, timePicker, visEditor, visChart, common } = getPageObjects([ 'visualize', 'timePicker', 'visEditor', @@ -29,48 +29,48 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const vizName1 = 'Visualization DataTable'; before(async function () { - await PageObjects.visualize.initTests(); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await visualize.initTests(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickDataTable'); - await PageObjects.visualize.clickDataTable(); + await visualize.clickDataTable(); log.debug('clickNewSearch'); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickNewSearch(); log.debug('Bucket = Split rows'); - await PageObjects.visEditor.clickBucket('Split rows'); + await visEditor.clickBucket('Split rows'); log.debug('Aggregation = Histogram'); - await PageObjects.visEditor.selectAggregation('Histogram'); + await visEditor.selectAggregation('Histogram'); log.debug('Field = bytes'); - await PageObjects.visEditor.selectField('bytes'); + await visEditor.selectField('bytes'); log.debug('Interval = 2000'); - await PageObjects.visEditor.setInterval('2000', { type: 'numeric' }); - await PageObjects.visEditor.clickGo(); + await visEditor.setInterval('2000', { type: 'numeric' }); + await visEditor.clickGo(); }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('should allow applying changed params', async () => { - await PageObjects.visEditor.setInterval('1', { type: 'numeric', append: true }); - const interval = await PageObjects.visEditor.getNumericInterval(); + await visEditor.setInterval('1', { type: 'numeric', append: true }); + const interval = await visEditor.getNumericInterval(); expect(interval).to.be('20001'); - const isApplyButtonEnabled = await PageObjects.visEditor.isApplyEnabled(); + const isApplyButtonEnabled = await visEditor.isApplyEnabled(); expect(isApplyButtonEnabled).to.be(true); }); it('should allow reseting changed params', async () => { - await PageObjects.visEditor.clickReset(); - const interval = await PageObjects.visEditor.getNumericInterval(); + await visEditor.clickReset(); + const interval = await visEditor.getNumericInterval(); expect(interval).to.be('2000'); }); it('should be able to save and load', async function () { - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); - await PageObjects.visualize.loadSavedVisualization(vizName1); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(vizName1); + await visChart.waitForVisualization(); }); it('should have inspector enabled', async function () { @@ -111,21 +111,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ['15.625KB', '161'], ['17.578KB', '137'], ]; - await PageObjects.visEditor.clickOptionsTab(); - await PageObjects.visEditor.checkSwitch('showPartialRows'); - await PageObjects.visEditor.clickGo(); + await visEditor.clickOptionsTab(); + await visEditor.checkSwitch('showPartialRows'); + await visEditor.clickGo(); return retry.try(async function () { await inspector.open(); await inspector.expectTableData(expectedChartData); await inspector.close(); - await PageObjects.visEditor.uncheckSwitch('showPartialRows'); + await visEditor.uncheckSwitch('showPartialRows'); }); }); it('should show percentage columns', async () => { async function expectValidTableData() { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['≥ 0B and < 1,000B', '1,351', '64.703%'], ['≥ 1,000B and < 1.953KB', '737', '35.297%'], @@ -133,41 +133,38 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } // load a plain table - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Range'); - await PageObjects.visEditor.selectField('bytes'); - await PageObjects.visEditor.clickGo(); - await PageObjects.visEditor.clickOptionsTab(); - await PageObjects.visEditor.setSelectByOptionText( - 'datatableVisualizationPercentageCol', - 'Count' - ); - await PageObjects.visEditor.clickGo(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Range'); + await visEditor.selectField('bytes'); + await visEditor.clickGo(); + await visEditor.clickOptionsTab(); + await visEditor.setSelectByOptionText('datatableVisualizationPercentageCol', 'Count'); + await visEditor.clickGo(); await expectValidTableData(); // check that it works after a save and reload const SAVE_NAME = 'viz w/ percents'; - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(SAVE_NAME); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(SAVE_NAME); - await PageObjects.visualize.loadSavedVisualization(SAVE_NAME); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(SAVE_NAME); + await visChart.waitForVisualization(); await expectValidTableData(); // check that it works after selecting a column that's deleted - await PageObjects.visEditor.clickDataTab(); - await PageObjects.visEditor.clickBucket('Metric', 'metrics'); - await PageObjects.visEditor.selectAggregation('Average', 'metrics'); - await PageObjects.visEditor.selectField('bytes', 'metrics'); - await PageObjects.visEditor.removeDimension(1); - await PageObjects.visEditor.clickGo(); - await PageObjects.visEditor.clickOptionsTab(); - - const data = await PageObjects.visChart.getTableVisContent(); + await visEditor.clickDataTab(); + await visEditor.clickBucket('Metric', 'metrics'); + await visEditor.selectAggregation('Average', 'metrics'); + await visEditor.selectField('bytes', 'metrics'); + await visEditor.removeDimension(1); + await visEditor.clickGo(); + await visEditor.clickOptionsTab(); + + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['≥ 0B and < 1,000B', '344.094B'], ['≥ 1,000B and < 1.953KB', '1.697KB'], @@ -175,28 +172,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show correct data when using average pipeline aggregation', async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickBucket('Metric', 'metrics'); - await PageObjects.visEditor.selectAggregation('Average Bucket', 'metrics'); - await PageObjects.visEditor.selectAggregation('Terms', 'metrics', true); - await PageObjects.visEditor.selectField('geo.src', 'metrics', true); - await PageObjects.visEditor.clickGo(); - const data = await PageObjects.visChart.getTableVisContent(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await visEditor.clickBucket('Metric', 'metrics'); + await visEditor.selectAggregation('Average Bucket', 'metrics'); + await visEditor.selectAggregation('Terms', 'metrics', true); + await visEditor.selectField('geo.src', 'metrics', true); + await visEditor.clickGo(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([['14,004', '1,412.6']]); }); it('should show correct data for a data table with date histogram', async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); - await PageObjects.visEditor.selectField('@timestamp'); - await PageObjects.visEditor.setInterval('Day'); - await PageObjects.visEditor.clickGo(); - const data = await PageObjects.visChart.getTableVisContent(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Date Histogram'); + await visEditor.selectField('@timestamp'); + await visEditor.setInterval('Day'); + await visEditor.clickGo(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['2015-09-20', '4,757'], ['2015-09-21', '4,614'], @@ -205,21 +202,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show correct data when selecting a field by its custom name', async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); - await PageObjects.visEditor.selectField('UTC time'); - await PageObjects.visEditor.setInterval('Day'); - await PageObjects.visEditor.clickGo(); - const data = await PageObjects.visChart.getTableVisContent(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Date Histogram'); + await visEditor.selectField('UTC time'); + await visEditor.setInterval('Day'); + await visEditor.clickGo(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['2015-09-20', '4,757'], ['2015-09-21', '4,614'], ['2015-09-22', '4,633'], ]); - const header = await PageObjects.visChart.getTableVisHeader(); + const header = await visChart.getTableVisHeader(); expect(header).to.contain('UTC time'); }); @@ -229,40 +226,40 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { operation: 'is between', value: { from: '2015-09-19', to: '2015-09-21' }, }); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - const data = await PageObjects.visChart.getTableVisContent(); + await visChart.waitForVisualizationRenderingStabilized(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([['2015-09-20', '4,757']]); }); it('should correctly filter for pinned filters', async () => { await filterBar.toggleFilterPinned('@timestamp'); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - const data = await PageObjects.visChart.getTableVisContent(); + await visChart.waitForVisualizationRenderingStabilized(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([['2015-09-20', '4,757']]); }); it('should show correct data for a data table with top hits', async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickMetricEditor(); - await PageObjects.visEditor.selectAggregation('Top Hit', 'metrics'); - await PageObjects.visEditor.selectField('agent.raw', 'metrics'); - await PageObjects.visEditor.clickGo(); - const data = await PageObjects.visChart.getTableVisContent(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await visEditor.clickMetricEditor(); + await visEditor.selectAggregation('Top Hit', 'metrics'); + await visEditor.selectField('agent.raw', 'metrics'); + await visEditor.clickGo(); + const data = await visChart.getTableVisContent(); log.debug(data); expect(data.length).to.be.greaterThan(0); }); it('should show correct data for a data table with range agg', async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Range'); - await PageObjects.visEditor.selectField('bytes'); - await PageObjects.visEditor.clickGo(); - const data = await PageObjects.visChart.getTableVisContent(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Range'); + await visEditor.selectField('bytes'); + await visEditor.clickGo(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['≥ 0B and < 1,000B', '1,351'], ['≥ 1,000B and < 1.953KB', '737'], @@ -271,22 +268,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('otherBucket', () => { before(async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('extension.raw'); - await PageObjects.visEditor.setSize(2); - await PageObjects.visEditor.clickGo(); - - await PageObjects.visEditor.toggleOtherBucket(); - await PageObjects.visEditor.toggleMissingBucket(); - await PageObjects.visEditor.clickGo(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('extension.raw'); + await visEditor.setSize(2); + await visEditor.clickGo(); + + await visEditor.toggleOtherBucket(); + await visEditor.toggleMissingBucket(); + await visEditor.clickGo(); }); it('should show correct data', async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['jpg', '9,109'], ['css', '2,159'], @@ -295,9 +292,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should apply correct filter', async () => { - await PageObjects.visChart.filterOnTableCell(0, 2); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - const data = await PageObjects.visChart.getTableVisContent(); + await visChart.filterOnTableCell(0, 2); + await visChart.waitForVisualizationRenderingStabilized(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['png', '1,373'], ['gif', '918'], @@ -308,23 +305,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('metricsOnAllLevels', () => { before(async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('extension.raw'); - await PageObjects.visEditor.setSize(2); - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('geo.dest'); - await PageObjects.visEditor.toggleOpenEditor(3, 'false'); - await PageObjects.visEditor.clickGo(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('extension.raw'); + await visEditor.setSize(2); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('geo.dest'); + await visEditor.toggleOpenEditor(3, 'false'); + await visEditor.clickGo(); }); it('should show correct data without showMetricsAtAllLevels', async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['jpg', 'CN', '1,718'], ['jpg', 'IN', '1,511'], @@ -340,10 +337,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show correct data without showMetricsAtAllLevels even if showPartialRows is selected', async () => { - await PageObjects.visEditor.clickOptionsTab(); + await visEditor.clickOptionsTab(); await testSubjects.setCheckbox('showPartialRows', 'check'); - await PageObjects.visEditor.clickGo(); - const data = await PageObjects.visChart.getTableVisContent(); + await visEditor.clickGo(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['jpg', 'CN', '1,718'], ['jpg', 'IN', '1,511'], @@ -359,10 +356,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show metrics on each level', async () => { - await PageObjects.visEditor.clickOptionsTab(); + await visEditor.clickOptionsTab(); await testSubjects.setCheckbox('showMetricsAtAllLevels', 'check'); - await PageObjects.visEditor.clickGo(); - const data = await PageObjects.visChart.getTableVisContent(); + await visEditor.clickGo(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['jpg', '9,109', 'CN', '1,718'], ['jpg', '9,109', 'IN', '1,511'], @@ -378,12 +375,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show metrics other than count on each level', async () => { - await PageObjects.visEditor.clickDataTab(); - await PageObjects.visEditor.clickBucket('Metric', 'metrics'); - await PageObjects.visEditor.selectAggregation('Average', 'metrics'); - await PageObjects.visEditor.selectField('bytes', 'metrics'); - await PageObjects.visEditor.clickGo(); - const data = await PageObjects.visChart.getTableVisContent(); + await visEditor.clickDataTab(); + await visEditor.clickBucket('Metric', 'metrics'); + await visEditor.selectAggregation('Average', 'metrics'); + await visEditor.selectField('bytes', 'metrics'); + await visEditor.clickGo(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['jpg', '9,109', '5.469KB', 'CN', '1,718', '5.477KB'], ['jpg', '9,109', '5.469KB', 'IN', '1,511', '5.456KB'], @@ -401,31 +398,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('split tables', () => { before(async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickBucket('Split table'); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await visEditor.clickBucket('Split table'); // split by column to make all tables rows visible - await PageObjects.visEditor.clickSplitDirection('Columns'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('extension.raw'); - await PageObjects.visEditor.setSize(2); - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('geo.dest'); - await PageObjects.visEditor.setSize(3, 3); - await PageObjects.visEditor.toggleOpenEditor(3, 'false'); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('geo.src'); - await PageObjects.visEditor.setSize(3, 4); - await PageObjects.visEditor.toggleOpenEditor(4, 'false'); - await PageObjects.visEditor.clickGo(); + await visEditor.clickSplitDirection('Columns'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('extension.raw'); + await visEditor.setSize(2); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('geo.dest'); + await visEditor.setSize(3, 3); + await visEditor.toggleOpenEditor(3, 'false'); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('geo.src'); + await visEditor.setSize(3, 4); + await visEditor.toggleOpenEditor(4, 'false'); + await visEditor.clickGo(); }); it('should have a splitted table', async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ [ ['CN', 'CN', '330'], @@ -453,10 +450,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show metrics for split bucket when using showMetricsAtAllLevels', async () => { - await PageObjects.visEditor.clickOptionsTab(); + await visEditor.clickOptionsTab(); await testSubjects.setCheckbox('showMetricsAtAllLevels', 'check'); - await PageObjects.visEditor.clickGo(); - const data = await PageObjects.visChart.getTableVisContent(); + await visEditor.clickGo(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ [ ['CN', '1,718', 'CN', '330'], diff --git a/test/functional/apps/visualize/group1/_data_table_nontimeindex.ts b/test/functional/apps/visualize/group1/_data_table_nontimeindex.ts index 8edb60d74846f..c03219f3d2218 100644 --- a/test/functional/apps/visualize/group1/_data_table_nontimeindex.ts +++ b/test/functional/apps/visualize/group1/_data_table_nontimeindex.ts @@ -17,51 +17,54 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const filterBar = getService('filterBar'); const renderable = getService('renderable'); - const PageObjects = getPageObjects(['visualize', 'visEditor', 'header', 'visChart']); + const { visualize, visEditor, header, visChart } = getPageObjects([ + 'visualize', + 'visEditor', + 'header', + 'visChart', + ]); describe('data table with index without time filter', function indexPatternCreation() { const vizName1 = 'Visualization DataTable without time filter'; before(async function () { - await PageObjects.visualize.initTests(); + await visualize.initTests(); log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickDataTable'); - await PageObjects.visualize.clickDataTable(); + await visualize.clickDataTable(); log.debug('clickNewSearch'); - await PageObjects.visualize.clickNewSearch( - PageObjects.visualize.index.LOGSTASH_NON_TIME_BASED - ); + await visualize.clickNewSearch(visualize.index.LOGSTASH_NON_TIME_BASED); log.debug('Bucket = Split Rows'); - await PageObjects.visEditor.clickBucket('Split rows'); + await visEditor.clickBucket('Split rows'); log.debug('Aggregation = Histogram'); - await PageObjects.visEditor.selectAggregation('Histogram'); + await visEditor.selectAggregation('Histogram'); log.debug('Field = bytes'); - await PageObjects.visEditor.selectField('bytes'); + await visEditor.selectField('bytes'); log.debug('Interval = 2000'); - await PageObjects.visEditor.setInterval('2000', { type: 'numeric' }); - await PageObjects.visEditor.clickGo(); + await visEditor.setInterval('2000', { type: 'numeric' }); + await visEditor.clickGo(); }); it('should allow applying changed params', async () => { - await PageObjects.visEditor.setInterval('1', { type: 'numeric', append: true }); - const interval = await PageObjects.visEditor.getNumericInterval(); + await visEditor.setInterval('1', { type: 'numeric', append: true }); + const interval = await visEditor.getNumericInterval(); expect(interval).to.be('20001'); - const isApplyButtonEnabled = await PageObjects.visEditor.isApplyEnabled(); + const isApplyButtonEnabled = await visEditor.isApplyEnabled(); expect(isApplyButtonEnabled).to.be(true); }); it('should allow reseting changed params', async () => { - await PageObjects.visEditor.clickReset(); - const interval = await PageObjects.visEditor.getNumericInterval(); + await visEditor.clickReset(); + const interval = await visEditor.getNumericInterval(); expect(interval).to.be('2000'); }); it('should be able to save and load', async function () { - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); - await PageObjects.visualize.loadSavedVisualization(vizName1); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(vizName1); + await visChart.waitForVisualization(); }); it('should have inspector enabled', async function () { @@ -90,36 +93,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show correct data when using average pipeline aggregation', async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch( - PageObjects.visualize.index.LOGSTASH_NON_TIME_BASED - ); - await PageObjects.visEditor.clickBucket('Metric', 'metrics'); - await PageObjects.visEditor.selectAggregation('Average Bucket', 'metrics'); - await PageObjects.visEditor.selectAggregation('Terms', 'metrics', true); - await PageObjects.visEditor.selectField('geo.src', 'metrics', true); - await PageObjects.visEditor.clickGo(); - const data = await PageObjects.visChart.getTableVisContent(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(visualize.index.LOGSTASH_NON_TIME_BASED); + await visEditor.clickBucket('Metric', 'metrics'); + await visEditor.selectAggregation('Average Bucket', 'metrics'); + await visEditor.selectAggregation('Terms', 'metrics', true); + await visEditor.selectField('geo.src', 'metrics', true); + await visEditor.clickGo(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([['14,004', '1,412.6']]); }); describe('data table with date histogram', () => { before(async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch( - PageObjects.visualize.index.LOGSTASH_NON_TIME_BASED - ); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); - await PageObjects.visEditor.selectField('@timestamp'); - await PageObjects.visEditor.setInterval('Day'); - await PageObjects.visEditor.clickGo(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(visualize.index.LOGSTASH_NON_TIME_BASED); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Date Histogram'); + await visEditor.selectField('@timestamp'); + await visEditor.setInterval('Day'); + await visEditor.clickGo(); }); it('should show correct data', async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['2015-09-20', '4,757'], ['2015-09-21', '4,614'], @@ -133,17 +132,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { operation: 'is between', value: { from: '2015-09-19', to: '2015-09-21' }, }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([['2015-09-20', '4,757']]); }); it('should correctly filter for pinned filters', async () => { await filterBar.toggleFilterPinned('@timestamp'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([['2015-09-20', '4,757']]); }); }); diff --git a/test/functional/apps/visualize/group1/_data_table_notimeindex_filters.ts b/test/functional/apps/visualize/group1/_data_table_notimeindex_filters.ts index 5d4c642da39a4..92fc6986dc9f8 100644 --- a/test/functional/apps/visualize/group1/_data_table_notimeindex_filters.ts +++ b/test/functional/apps/visualize/group1/_data_table_notimeindex_filters.ts @@ -17,8 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const renderable = getService('renderable'); const retry = getService('retry'); const dashboardAddPanel = getService('dashboardAddPanel'); - const PageObjects = getPageObjects([ - 'common', + const { visualize, header, dashboard, timePicker, visEditor, visChart } = getPageObjects([ 'visualize', 'header', 'dashboard', @@ -31,49 +30,47 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const vizName1 = 'Visualization DataTable w/o time filter'; before(async function () { - await PageObjects.visualize.initTests(); + await visualize.initTests(); log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickDataTable'); - await PageObjects.visualize.clickDataTable(); + await visualize.clickDataTable(); log.debug('clickNewSearch'); - await PageObjects.visualize.clickNewSearch( - PageObjects.visualize.index.LOGSTASH_NON_TIME_BASED - ); + await visualize.clickNewSearch(visualize.index.LOGSTASH_NON_TIME_BASED); log.debug('Bucket = Split Rows'); - await PageObjects.visEditor.clickBucket('Split rows'); + await visEditor.clickBucket('Split rows'); log.debug('Aggregation = Histogram'); - await PageObjects.visEditor.selectAggregation('Histogram'); + await visEditor.selectAggregation('Histogram'); log.debug('Field = bytes'); - await PageObjects.visEditor.selectField('bytes'); + await visEditor.selectField('bytes'); log.debug('Interval = 2000'); - await PageObjects.visEditor.setInterval('2000', { type: 'numeric' }); - await PageObjects.visEditor.clickGo(); + await visEditor.setInterval('2000', { type: 'numeric' }); + await visEditor.clickGo(); }); it('should be able to save and load', async function () { - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); - await PageObjects.visualize.loadSavedVisualization(vizName1); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(vizName1); + await visChart.waitForVisualization(); }); it('timefilter should be disabled', async () => { - const isOff = await PageObjects.timePicker.isOff(); + const isOff = await timePicker.isOff(); expect(isOff).to.be(true); }); // test to cover bug #54548 - add this visualization to a dashboard and filter it('should add to dashboard and allow filtering', async function () { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.addVisualization(vizName1); await retry.try(async () => { // hover and click on cell to filter - await PageObjects.visChart.filterOnTableCell(0, 1); + await visChart.filterOnTableCell(0, 1); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); const filterCount = await filterBar.getFilterCount(); expect(filterCount).to.be(1); diff --git a/test/functional/apps/visualize/group1/_embedding_chart.ts b/test/functional/apps/visualize/group1/_embedding_chart.ts index 76f111a8007b0..8d804a22cc5e5 100644 --- a/test/functional/apps/visualize/group1/_embedding_chart.ts +++ b/test/functional/apps/visualize/group1/_embedding_chart.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const renderable = getService('renderable'); const embedding = getService('embedding'); const retry = getService('retry'); - const PageObjects = getPageObjects([ + const { visualize, visEditor, visChart, header, timePicker } = getPageObjects([ 'visualize', 'visEditor', 'visChart', @@ -27,27 +27,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('embedding', () => { describe('a data table', () => { before(async function () { - await PageObjects.visualize.initTests(); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); - await PageObjects.visEditor.selectField('@timestamp'); - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.clickBucket('Split rows'); - await PageObjects.visEditor.selectAggregation('Histogram'); - await PageObjects.visEditor.selectField('bytes'); - await PageObjects.visEditor.setInterval('2000', { type: 'numeric', aggNth: 3 }); - await PageObjects.visEditor.clickGo(); + await visualize.initTests(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await timePicker.setDefaultAbsoluteRange(); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Date Histogram'); + await visEditor.selectField('@timestamp'); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.clickBucket('Split rows'); + await visEditor.selectAggregation('Histogram'); + await visEditor.selectField('bytes'); + await visEditor.setInterval('2000', { type: 'numeric', aggNth: 3 }); + await visEditor.clickGo(); }); it('should allow opening table vis in embedded mode', async () => { await embedding.openInEmbeddedMode(); await renderable.waitForRender(); - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['2015-09-20 00:00', '0B', '5'], ['2015-09-20 00:00', '1.953KB', '5'], @@ -68,10 +68,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { operation: 'is between', value: { from: '2015-09-21', to: '2015-09-23' }, }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['2015-09-21 00:00', '0B', '7'], ['2015-09-21 00:00', '1.953KB', '9'], @@ -88,11 +88,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should allow to change timerange from the visualization in embedded mode', async () => { await retry.try(async () => { - await PageObjects.visChart.filterOnTableCell(0, 6); - await PageObjects.header.waitUntilLoadingHasFinished(); + await visChart.filterOnTableCell(0, 6); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data).to.be.eql([ ['03:00', '0B', '1'], ['03:00', '1.953KB', '1'], diff --git a/test/functional/apps/visualize/group1/_no_data.ts b/test/functional/apps/visualize/group1/_no_data.ts index 7d6ed2caa59b4..b260cf1c82581 100644 --- a/test/functional/apps/visualize/group1/_no_data.ts +++ b/test/functional/apps/visualize/group1/_no_data.ts @@ -13,7 +13,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['visualize', 'header', 'common']); + const { header, common } = getPageObjects(['header', 'common']); const esArchiver = getService('esArchiver'); const dataViews = getService('dataViews'); const kibanaServer = getService('kibanaServer'); @@ -23,20 +23,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); await esArchiver.unload('test/functional/fixtures/es_archiver/long_window_logstash'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('visualize'); + await header.waitUntilLoadingHasFinished(); const addIntegrations = await testSubjects.find('kbnOverviewAddIntegrations'); await addIntegrations.click(); - await PageObjects.common.waitUntilUrlIncludes('integrations/browse'); + await common.waitUntilUrlIncludes('integrations/browse'); }); it('should show the no dataview component if no dataviews exist', async function () { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/long_window_logstash'); await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] }); - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('visualize'); + await header.waitUntilLoadingHasFinished(); const dataViewToCreate = 'logstash'; await dataViews.createFromPrompt({ name: dataViewToCreate }); diff --git a/test/functional/apps/visualize/group2/_experimental_vis.ts b/test/functional/apps/visualize/group2/_experimental_vis.ts index 89a0a66b7c2be..8f49fba2ac739 100644 --- a/test/functional/apps/visualize/group2/_experimental_vis.ts +++ b/test/functional/apps/visualize/group2/_experimental_vis.ts @@ -13,23 +13,23 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); - const PageObjects = getPageObjects(['visualize']); + const { visualize } = getPageObjects(['visualize']); describe('experimental visualizations in visualize app ', function () { before(async () => { - await PageObjects.visualize.initTests(); + await visualize.initTests(); }); describe('experimental visualizations', () => { beforeEach(async () => { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.waitForVisualizationSelectPage(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.waitForVisualizationSelectPage(); }); it('should show an notification when creating beta visualizations', async () => { // Try to find a beta visualization. - const betaTypes = await PageObjects.visualize.getBetaTypeLinks(); + const betaTypes = await visualize.getBetaTypeLinks(); if (betaTypes.length === 0) { log.info('No beta visualization found. Skipping this test.'); return; @@ -38,15 +38,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Create a new visualization await betaTypes[0].click(); // Select a index-pattern/search if this vis requires it - await PageObjects.visualize.selectVisSourceIfRequired(); + await visualize.selectVisSourceIfRequired(); // Check that the beta banner is there and state that this is beta - const info = await PageObjects.visualize.getExperimentalInfo(); + const info = await visualize.getExperimentalInfo(); expect(await info.getVisibleText()).to.contain('beta'); }); it('should show an notification when creating experimental visualizations', async () => { // Try to find a experimental visualization. - const experimentalTypes = await PageObjects.visualize.getExperimentalTypeLinks(); + const experimentalTypes = await visualize.getExperimentalTypeLinks(); if (experimentalTypes.length === 0) { log.info('No experimental visualization found. Skipping this test.'); return; @@ -55,17 +55,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Create a new visualization await experimentalTypes[0].click(); // Select a index-pattern/search if this vis requires it - await PageObjects.visualize.selectVisSourceIfRequired(); + await visualize.selectVisSourceIfRequired(); // Check that the experimental banner is there and state that this is experimental - const info = await PageObjects.visualize.getExperimentalInfo(); + const info = await visualize.getExperimentalInfo(); expect(await info.getVisibleText()).to.contain('experimental'); }); it('should not show that notification for stable visualizations', async () => { - await PageObjects.visualize.clickAreaChart(); - await PageObjects.visualize.clickNewSearch(); - expect(await PageObjects.visualize.isBetaInfoShown()).to.be(false); - expect(await PageObjects.visualize.isExperimentalInfoShown()).to.be(false); + await visualize.clickAreaChart(); + await visualize.clickNewSearch(); + expect(await visualize.isBetaInfoShown()).to.be(false); + expect(await visualize.isExperimentalInfoShown()).to.be(false); }); }); }); diff --git a/test/functional/apps/visualize/group2/_gauge_chart.ts b/test/functional/apps/visualize/group2/_gauge_chart.ts index 08d63de1e9746..8ff6d31229081 100644 --- a/test/functional/apps/visualize/group2/_gauge_chart.ts +++ b/test/functional/apps/visualize/group2/_gauge_chart.ts @@ -17,20 +17,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const inspector = getService('inspector'); const filterBar = getService('filterBar'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['visualize', 'visEditor', 'visChart', 'timePicker']); + const { visualize, visEditor, visChart, timePicker } = getPageObjects([ + 'visualize', + 'visEditor', + 'visChart', + 'timePicker', + ]); async function initGaugeVis() { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickGauge'); - await PageObjects.visualize.clickGauge(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await visualize.clickGauge(); + await visualize.clickNewSearch(); + await timePicker.setDefaultAbsoluteRange(); } describe('gauge chart', function indexPatternCreation() { before(async () => { - await PageObjects.visualize.initTests(); + await visualize.initTests(); await initGaugeVis(); }); @@ -43,25 +48,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // initial metric of "Count" is selected by default return retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getGaugeValue(); + const metricValue = await visChart.getGaugeValue(); expect(expectedCount).to.eql(metricValue); }); }); it('should format the metric correctly in percentage mode', async function () { - await PageObjects.visEditor.clickMetricEditor(); - await PageObjects.visEditor.selectAggregation('Average', 'metrics'); - await PageObjects.visEditor.selectField('bytes', 'metrics'); - await PageObjects.visEditor.clickOptionsTab(); + await visEditor.clickMetricEditor(); + await visEditor.selectAggregation('Average', 'metrics'); + await visEditor.selectField('bytes', 'metrics'); + await visEditor.clickOptionsTab(); await testSubjects.setValue('gaugeColorRange2__to', '10000'); await testSubjects.click('gaugePercentageMode'); await testSubjects.setValue('gaugePercentageModeFormatPattern', '0.0%'); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - await PageObjects.visEditor.clickGo(false); + await visChart.waitForVisualizationRenderingStabilized(); + await visEditor.clickGo(false); await retry.try(async function tryingForTime() { const expectedTexts = ['57.3%', 'Average bytes']; - const metricValue = await PageObjects.visChart.getGaugeValue(); + const metricValue = await visChart.getGaugeValue(); expect(expectedTexts).to.eql(metricValue); }); }); @@ -70,19 +75,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await initGaugeVis(); log.debug('Bucket = Split Group'); - await PageObjects.visEditor.clickBucket('Split group'); + await visEditor.clickBucket('Split group'); log.debug('Aggregation = Terms'); - await PageObjects.visEditor.selectAggregation('Terms'); + await visEditor.selectAggregation('Terms'); log.debug('Field = machine.os.raw'); - await PageObjects.visEditor.selectField('machine.os.raw'); + await visEditor.selectField('machine.os.raw'); log.debug('Size = 4'); - await PageObjects.visEditor.setSize(4); - await PageObjects.visEditor.clickGo(false); + await visEditor.setSize(4); + await visEditor.clickGo(false); }); it('should show Split Gauges', async () => { await retry.try(async () => { - expect(await PageObjects.visChart.getGaugeValue()).to.eql([ + expect(await visChart.getGaugeValue()).to.eql([ '2,904', 'win 8', '2,858', @@ -96,8 +101,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should add machine.os.raw:win 8 filter by click on the first Gauge', async () => { - await PageObjects.visChart.clickOnGaugeByLabel('win 8'); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); + await visChart.clickOnGaugeByLabel('win 8'); + await visChart.waitForVisualizationRenderingStabilized(); const hasFilter = await filterBar.hasFilter('machine.os.raw', 'win 8'); expect(hasFilter).to.eql(true); @@ -107,16 +112,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await filterBar.removeAllFilters(); const expectedTexts = ['2,904', 'win 8: Count', '0B', 'win 8: Min bytes']; - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('machine.os.raw'); - await PageObjects.visEditor.setSize(1); - await PageObjects.visEditor.clickBucket('Metric', 'metrics'); - await PageObjects.visEditor.selectAggregation('Min', 'metrics'); - await PageObjects.visEditor.selectField('bytes', 'metrics'); - await PageObjects.visEditor.clickGo(false); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('machine.os.raw'); + await visEditor.setSize(1); + await visEditor.clickBucket('Metric', 'metrics'); + await visEditor.selectAggregation('Min', 'metrics'); + await visEditor.selectField('bytes', 'metrics'); + await visEditor.clickGo(false); await retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getGaugeValue(); + const metricValue = await visChart.getGaugeValue(); expect(expectedTexts).to.eql(metricValue); }); }); diff --git a/test/functional/apps/visualize/group2/_heatmap_chart.ts b/test/functional/apps/visualize/group2/_heatmap_chart.ts index a414ea689f799..a8944f1131d06 100644 --- a/test/functional/apps/visualize/group2/_heatmap_chart.ts +++ b/test/functional/apps/visualize/group2/_heatmap_chart.ts @@ -14,38 +14,43 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const inspector = getService('inspector'); - const PageObjects = getPageObjects(['visualize', 'visEditor', 'visChart', 'timePicker']); + const { visualize, visEditor, visChart, timePicker } = getPageObjects([ + 'visualize', + 'visEditor', + 'visChart', + 'timePicker', + ]); describe('heatmap chart', function indexPatternCreation() { const vizName1 = 'Visualization HeatmapChart'; let isNewChartsLibraryEnabled = false; before(async function () { - isNewChartsLibraryEnabled = await PageObjects.visChart.isNewChartsLibraryEnabled( + isNewChartsLibraryEnabled = await visChart.isNewChartsLibraryEnabled( 'visualization:visualize:legacyHeatmapChartsLibrary' ); - await PageObjects.visualize.initTests(isNewChartsLibraryEnabled); + await visualize.initTests(isNewChartsLibraryEnabled); log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickHeatmapChart'); - await PageObjects.visualize.clickHeatmapChart(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await visualize.clickHeatmapChart(); + await visualize.clickNewSearch(); + await timePicker.setDefaultAbsoluteRange(); log.debug('Bucket = X-Axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Aggregation = Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); + await visEditor.selectAggregation('Date Histogram'); log.debug('Field = @timestamp'); - await PageObjects.visEditor.selectField('@timestamp'); + await visEditor.selectField('@timestamp'); // leaving Interval set to Auto - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.clickGo(isNewChartsLibraryEnabled); }); it('should save and load', async function () { - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); - await PageObjects.visualize.loadSavedVisualization(vizName1); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(vizName1); + await visChart.waitForVisualization(); }); it('should have inspector enabled', async function () { @@ -83,7 +88,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show 4 color ranges as default colorNumbers param', async function () { - const legends = await PageObjects.visChart.getLegendEntries(); + const legends = await visChart.getLegendEntries(); let expectedLegends = []; if (isNewChartsLibraryEnabled) { // the bands are different because we always scale to data bounds in the implementation @@ -95,12 +100,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show 6 color ranges if changed on options', async function () { - await PageObjects.visEditor.clickOptionsTab(); - await PageObjects.visEditor.changeHeatmapColorNumbers(6); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); + await visEditor.clickOptionsTab(); + await visEditor.changeHeatmapColorNumbers(6); + await visEditor.clickGo(isNewChartsLibraryEnabled); + await visChart.waitForVisualizationRenderingStabilized(); - const legends = await PageObjects.visChart.getLegendEntries(); + const legends = await visChart.getLegendEntries(); let expectedLegends = []; if (isNewChartsLibraryEnabled) { // the bands are different because we always scale to data bounds in the implementation @@ -125,23 +130,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(legends).to.eql(expectedLegends); }); it('should show 6 custom color ranges', async function () { - await PageObjects.visEditor.clickOptionsTab(); - await PageObjects.visEditor.clickEnableCustomRanges(); - await PageObjects.visEditor.clickAddRange(); - await PageObjects.visEditor.clickAddRange(); - await PageObjects.visEditor.clickAddRange(); - await PageObjects.visEditor.clickAddRange(); - await PageObjects.visEditor.clickAddRange(); - await PageObjects.visEditor.clickAddRange(); - await PageObjects.visEditor.clickAddRange(); + await visEditor.clickOptionsTab(); + await visEditor.clickEnableCustomRanges(); + await visEditor.clickAddRange(); + await visEditor.clickAddRange(); + await visEditor.clickAddRange(); + await visEditor.clickAddRange(); + await visEditor.clickAddRange(); + await visEditor.clickAddRange(); + await visEditor.clickAddRange(); log.debug('customize 2 last ranges'); - await PageObjects.visEditor.setCustomRangeByIndex(6, '650', '720'); - await PageObjects.visEditor.setCustomRangeByIndex(7, '800', '905'); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.setCustomRangeByIndex(6, '650', '720'); + await visEditor.setCustomRangeByIndex(7, '800', '905'); + await visEditor.clickGo(isNewChartsLibraryEnabled); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - const legends = await PageObjects.visChart.getLegendEntries(); + await visChart.waitForVisualizationRenderingStabilized(); + const legends = await visChart.getLegendEntries(); let expectedLegends = []; if (isNewChartsLibraryEnabled) { expectedLegends = [ diff --git a/test/functional/apps/visualize/group2/_histogram_request_start.ts b/test/functional/apps/visualize/group2/_histogram_request_start.ts index cb51240c9be41..8dc3a09854993 100644 --- a/test/functional/apps/visualize/group2/_histogram_request_start.ts +++ b/test/functional/apps/visualize/group2/_histogram_request_start.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects([ + const { common, visualize, visEditor, visChart, timePicker } = getPageObjects([ 'common', 'visualize', 'visEditor', @@ -32,30 +32,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/long_window_logstash'); - await PageObjects.visualize.initTests(); + await visualize.initTests(); log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickDataTable'); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await visualize.clickDataTable(); + await visualize.clickNewSearch(); + await timePicker.setDefaultAbsoluteRange(); log.debug('Bucket = Split Rows'); - await PageObjects.visEditor.clickBucket('Split rows'); + await visEditor.clickBucket('Split rows'); log.debug('Aggregation = Histogram'); - await PageObjects.visEditor.selectAggregation('Histogram'); + await visEditor.selectAggregation('Histogram'); log.debug('Field = machine.ram'); - await PageObjects.visEditor.selectField('machine.ram'); + await visEditor.selectField('machine.ram'); }); describe('interval parameter uses autoBounds', function () { it('should use provided value when number of generated buckets is less than histogram:maxBars', async function () { const providedInterval = '2400000000'; log.debug(`Interval = ${providedInterval}`); - await PageObjects.visEditor.setInterval(providedInterval, { type: 'numeric' }); - await PageObjects.visEditor.clickGo(); + await visEditor.setInterval(providedInterval, { type: 'numeric' }); + await visEditor.clickGo(); await retry.try(async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data.length).to.eql(10); const bucketStart = parseInt((data[0][0] as string).replace(/,/g, ''), 10); const bucketEnd = parseInt((data[1][0] as string).replace(/,/g, ''), 10); @@ -67,11 +67,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should scale value to round number when number of generated buckets is greater than histogram:maxBars', async function () { const providedInterval = '100'; log.debug(`Interval = ${providedInterval}`); - await PageObjects.visEditor.setInterval(providedInterval, { type: 'numeric' }); - await PageObjects.visEditor.clickGo(); - await PageObjects.common.sleep(1000); // fix this + await visEditor.setInterval(providedInterval, { type: 'numeric' }); + await visEditor.clickGo(); + await common.sleep(1000); // fix this await retry.try(async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); expect(data.length).to.eql(10); const bucketStart = parseInt((data[0][0] as string).replace(/,/g, ''), 10); const bucketEnd = parseInt((data[1][0] as string).replace(/,/g, ''), 10); @@ -84,11 +84,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('autoBounds are not set for number_range data', function () { it('should use provided value when number of generated buckets is less than histogram:maxBars', async function () { log.debug('Field = machine.ram_range'); - await PageObjects.visEditor.selectField('machine.ram_range'); + await visEditor.selectField('machine.ram_range'); await retry.waitFor('interval to be set', async () => { - return Boolean(await PageObjects.visEditor.getNumericInterval()); + return Boolean(await visEditor.getNumericInterval()); }); - expect(await PageObjects.visEditor.getNumericInterval()).to.eql(100); + expect(await visEditor.getNumericInterval()).to.eql(100); }); }); }); diff --git a/test/functional/apps/visualize/group2/_inspector.ts b/test/functional/apps/visualize/group2/_inspector.ts index 3baa0c7992b19..f1b2f119a7954 100644 --- a/test/functional/apps/visualize/group2/_inspector.ts +++ b/test/functional/apps/visualize/group2/_inspector.ts @@ -15,29 +15,34 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const inspector = getService('inspector'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['visualize', 'visEditor', 'visChart', 'timePicker']); + const { visualize, visEditor, visChart, timePicker } = getPageObjects([ + 'visualize', + 'visEditor', + 'visChart', + 'timePicker', + ]); describe('inspector', function describeIndexTests() { before(async function () { - await PageObjects.visualize.initTests(); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickVerticalBarChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.initTests(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickVerticalBarChart(); + await visualize.clickNewSearch(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); }); describe('advanced input JSON', () => { it('should have "missing" property with value 10', async () => { log.debug('Add Max Metric on memory field'); - await PageObjects.visEditor.clickBucket('Y-axis', 'metrics'); - await PageObjects.visEditor.selectAggregation('Max', 'metrics'); - await PageObjects.visEditor.selectField('memory', 'metrics'); + await visEditor.clickBucket('Y-axis', 'metrics'); + await visEditor.selectAggregation('Max', 'metrics'); + await visEditor.selectField('memory', 'metrics'); log.debug('Add value to advanced JSON input'); - await PageObjects.visEditor.toggleAdvancedParams('2'); - await PageObjects.visEditor.inputValueInCodeEditor('{ "missing": 10 }'); - await PageObjects.visEditor.clickGo(); + await visEditor.toggleAdvancedParams('2'); + await visEditor.inputValueInCodeEditor('{ "missing": 10 }'); + await visEditor.clickGo(); await inspector.open(); await inspector.openInspectorRequestsView(); @@ -47,8 +52,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await inspector.close(); - await PageObjects.visEditor.removeDimension(2); - await PageObjects.visEditor.clickGo(); + await visEditor.removeDimension(2); + await visEditor.clickGo(); }); }); @@ -59,10 +64,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await inspector.close(); log.debug('Add Average Metric on machine.ram field'); - await PageObjects.visEditor.clickBucket('Y-axis', 'metrics'); - await PageObjects.visEditor.selectAggregation('Average', 'metrics'); - await PageObjects.visEditor.selectField('machine.ram', 'metrics'); - await PageObjects.visEditor.clickGo(); + await visEditor.clickBucket('Y-axis', 'metrics'); + await visEditor.selectAggregation('Average', 'metrics'); + await visEditor.selectField('machine.ram', 'metrics'); + await visEditor.clickGo(); await inspector.open(); await inspector.expectTableHeaders(['Count', 'Average machine.ram', 'All docs']); await inspector.close(); @@ -71,23 +76,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('filtering on inspector table values', function () { before(async function () { log.debug('Add X-axis terms agg on machine.os.raw'); - await PageObjects.visEditor.clickBucket('X-axis'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('machine.os.raw'); - await PageObjects.visEditor.setSize(2); - await PageObjects.visEditor.toggleOtherBucket(3); - await PageObjects.visEditor.clickGo(); + await visEditor.clickBucket('X-axis'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('machine.os.raw'); + await visEditor.setSize(2); + await visEditor.toggleOtherBucket(3); + await visEditor.clickGo(); }); beforeEach(async function () { await inspector.open(); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); + await visChart.waitForVisualizationRenderingStabilized(); }); afterEach(async function () { await inspector.close(); await filterBar.removeFilter('machine.os.raw'); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); + await visChart.waitForVisualizationRenderingStabilized(); }); it('should allow filtering for values', async function () { @@ -98,13 +103,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]); await inspector.filterForTableCell({ column: 1, row: 1, filter: 'in' }); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); await inspector.expectTableData([['win 8', '2,904', '13,031,579,645.108']]); }); it('should allow filtering out values', async function () { await inspector.filterForTableCell({ column: 1, row: 1, filter: 'out' }); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); await inspector.expectTableData([ ['win xp', '2,858', '13,073,190,186.423'], ['win 7', '2,814', '13,186,695,551.251'], @@ -114,7 +119,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should allow filtering for other values', async function () { await inspector.filterForTableCell({ column: 1, row: 3, filter: 'in' }); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); await inspector.expectTableData([ ['win 7', '2,814', '13,186,695,551.251'], ['ios', '2,784', '13,009,497,206.823'], @@ -124,7 +129,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should allow filtering out other values', async function () { await inspector.filterForTableCell({ column: 1, row: 3, filter: 'out' }); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); await inspector.expectTableData([ ['win 8', '2,904', '13,031,579,645.108'], ['win xp', '2,858', '13,073,190,186.423'], diff --git a/test/functional/apps/visualize/group2/_metric_chart.ts b/test/functional/apps/visualize/group2/_metric_chart.ts index 19bd4accf271e..3f97b940c5d29 100644 --- a/test/functional/apps/visualize/group2/_metric_chart.ts +++ b/test/functional/apps/visualize/group2/_metric_chart.ts @@ -16,17 +16,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const filterBar = getService('filterBar'); const inspector = getService('inspector'); - const PageObjects = getPageObjects(['visualize', 'visEditor', 'visChart', 'timePicker']); + const { visualize, visEditor, visChart, timePicker } = getPageObjects([ + 'visualize', + 'visEditor', + 'visChart', + 'timePicker', + ]); describe('metric chart', function () { before(async function () { - await PageObjects.visualize.initTests(); + await visualize.initTests(); log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickMetric'); - await PageObjects.visualize.clickMetric(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await visualize.clickMetric(); + await visualize.clickNewSearch(); + await timePicker.setDefaultAbsoluteRange(); }); it('should have inspector enabled', async function () { @@ -38,21 +43,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // initial metric of "Count" is selected by default await retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getMetric(); + const metricValue = await visChart.getMetric(); expect(expectedCount).to.eql(metricValue); }); }); it('should show Average', async function () { const avgMachineRam = ['13,104,036,080.615', 'Average machine.ram']; - await PageObjects.visEditor.clickMetricEditor(); + await visEditor.clickMetricEditor(); log.debug('Aggregation = Average'); - await PageObjects.visEditor.selectAggregation('Average', 'metrics'); + await visEditor.selectAggregation('Average', 'metrics'); log.debug('Field = machine.ram'); - await PageObjects.visEditor.selectField('machine.ram', 'metrics'); - await PageObjects.visEditor.clickGo(); + await visEditor.selectField('machine.ram', 'metrics'); + await visEditor.clickGo(); await retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getMetric(); + const metricValue = await visChart.getMetric(); expect(avgMachineRam).to.eql(metricValue); }); }); @@ -60,12 +65,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show Sum', async function () { const sumPhpMemory = ['85,865,880', 'Sum of phpmemory']; log.debug('Aggregation = Sum'); - await PageObjects.visEditor.selectAggregation('Sum', 'metrics'); + await visEditor.selectAggregation('Sum', 'metrics'); log.debug('Field = phpmemory'); - await PageObjects.visEditor.selectField('phpmemory', 'metrics'); - await PageObjects.visEditor.clickGo(); + await visEditor.selectField('phpmemory', 'metrics'); + await visEditor.clickGo(); await retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getMetric(); + const metricValue = await visChart.getMetric(); expect(sumPhpMemory).to.eql(metricValue); }); }); @@ -74,12 +79,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const medianBytes = ['5,565.263', 'Median bytes']; // For now, only comparing the text label part of the metric log.debug('Aggregation = Median'); - await PageObjects.visEditor.selectAggregation('Median', 'metrics'); + await visEditor.selectAggregation('Median', 'metrics'); log.debug('Field = bytes'); - await PageObjects.visEditor.selectField('bytes', 'metrics'); - await PageObjects.visEditor.clickGo(); + await visEditor.selectField('bytes', 'metrics'); + await visEditor.clickGo(); await retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getMetric(); + const metricValue = await visChart.getMetric(); // only comparing the text label! expect(medianBytes[1]).to.eql(metricValue[1]); }); @@ -88,12 +93,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show Min', async function () { const minTimestamp = ['Sep 20, 2015 @ 00:00:00.000', 'Min @timestamp']; log.debug('Aggregation = Min'); - await PageObjects.visEditor.selectAggregation('Min', 'metrics'); + await visEditor.selectAggregation('Min', 'metrics'); log.debug('Field = @timestamp'); - await PageObjects.visEditor.selectField('@timestamp', 'metrics'); - await PageObjects.visEditor.clickGo(); + await visEditor.selectField('@timestamp', 'metrics'); + await visEditor.clickGo(); await retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getMetric(); + const metricValue = await visChart.getMetric(); expect(minTimestamp).to.eql(metricValue); }); }); @@ -104,12 +109,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'Max relatedContent.article:modified_time', ]; log.debug('Aggregation = Max'); - await PageObjects.visEditor.selectAggregation('Max', 'metrics'); + await visEditor.selectAggregation('Max', 'metrics'); log.debug('Field = relatedContent.article:modified_time'); - await PageObjects.visEditor.selectField('relatedContent.article:modified_time', 'metrics'); - await PageObjects.visEditor.clickGo(); + await visEditor.selectField('relatedContent.article:modified_time', 'metrics'); + await visEditor.clickGo(); await retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getMetric(); + const metricValue = await visChart.getMetric(); expect(maxRelatedContentArticleModifiedTime).to.eql(metricValue); }); }); @@ -117,12 +122,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show Unique Count', async function () { const uniqueCountClientip = ['1,000', 'Unique count of clientip']; log.debug('Aggregation = Unique Count'); - await PageObjects.visEditor.selectAggregation('Unique Count', 'metrics'); + await visEditor.selectAggregation('Unique Count', 'metrics'); log.debug('Field = clientip'); - await PageObjects.visEditor.selectField('clientip', 'metrics'); - await PageObjects.visEditor.clickGo(); + await visEditor.selectField('clientip', 'metrics'); + await visEditor.clickGo(); await retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getMetric(); + const metricValue = await visChart.getMetric(); expect(uniqueCountClientip).to.eql(metricValue); }); }); @@ -146,14 +151,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]; log.debug('Aggregation = Percentiles'); - await PageObjects.visEditor.selectAggregation('Percentiles', 'metrics'); + await visEditor.selectAggregation('Percentiles', 'metrics'); log.debug('Field = machine.ram'); - await PageObjects.visEditor.selectField('machine.ram', 'metrics'); - await PageObjects.visEditor.toggleAdvancedParams('1'); - await PageObjects.visEditor.inputValueInCodeEditor('{ "tdigest": { "compression": 1000 } }'); - await PageObjects.visEditor.clickGo(); + await visEditor.selectField('machine.ram', 'metrics'); + await visEditor.toggleAdvancedParams('1'); + await visEditor.inputValueInCodeEditor('{ "tdigest": { "compression": 1000 } }'); + await visEditor.clickGo(); await retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getMetric(); + const metricValue = await visChart.getMetric(); expect(percentileMachineRam).to.eql(metricValue); }); }); @@ -161,14 +166,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show Percentile Ranks', async function () { const percentileRankBytes = ['2.036%', 'Percentile rank 99 of "memory"']; log.debug('Aggregation = Percentile Ranks'); - await PageObjects.visEditor.selectAggregation('Percentile Ranks', 'metrics'); + await visEditor.selectAggregation('Percentile Ranks', 'metrics'); log.debug('Field = bytes'); - await PageObjects.visEditor.selectField('memory', 'metrics'); + await visEditor.selectField('memory', 'metrics'); log.debug('Values = 99'); - await PageObjects.visEditor.setValue('99'); - await PageObjects.visEditor.clickGo(); + await visEditor.setValue('99'); + await visEditor.clickGo(); await retry.try(async function tryingForTime() { - const metricValue = await PageObjects.visChart.getMetric(); + const metricValue = await visChart.getMetric(); expect(percentileRankBytes).to.eql(metricValue); }); }); @@ -176,18 +181,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('with filters', function () { it('should allow filtering with buckets', async function () { log.debug('Bucket = Split Group'); - await PageObjects.visEditor.clickBucket('Split group'); + await visEditor.clickBucket('Split group'); log.debug('Aggregation = Terms'); - await PageObjects.visEditor.selectAggregation('Terms'); + await visEditor.selectAggregation('Terms'); log.debug('Field = machine.os.raw'); - await PageObjects.visEditor.selectField('machine.os.raw'); - await PageObjects.visEditor.clickGo(); + await visEditor.selectField('machine.os.raw'); + await visEditor.clickGo(); let filterCount = 0; await retry.try(async function tryingForTime() { // click first metric bucket - await PageObjects.visEditor.clickMetricByIndex(0); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); + await visEditor.clickMetricByIndex(0); + await visChart.waitForVisualizationRenderingStabilized(); filterCount = await filterBar.getFilterCount(); }); await filterBar.removeAllFilters(); diff --git a/test/functional/apps/visualize/group3/_add_to_dashboard.ts b/test/functional/apps/visualize/group3/_add_to_dashboard.ts index abfcbdec4b0a1..77125bc372934 100644 --- a/test/functional/apps/visualize/group3/_add_to_dashboard.ts +++ b/test/functional/apps/visualize/group3/_add_to_dashboard.ts @@ -12,85 +12,79 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardExpect = getService('dashboardExpect'); + const dashboardPanelActions = getService('dashboardPanelActions'); const testSubjects = getService('testSubjects'); const listingTable = getService('listingTable'); - const PageObjects = getPageObjects([ + const { common, dashboard, visualize, timePicker, timeToVisualize } = getPageObjects([ 'common', 'dashboard', - 'header', 'visualize', - 'visEditor', - 'discover', 'timePicker', 'timeToVisualize', ]); describe('Add to Dashboard', function describeIndexTests() { before(async () => { - await PageObjects.visualize.initTests(); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await visualize.initTests(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('adding a new metric to a new dashboard by value', async function () { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickMetric(); - await PageObjects.visualize.clickNewSearch(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickMetric(); + await visualize.clickNewSearch(); await testSubjects.click('visualizeSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('My New Vis 1', { + await timeToVisualize.saveFromModal('My New Vis 1', { addToDashboard: 'new', saveToLibrary: false, }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardExpect.metricValuesExist(['14,004']); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists('My New Vis 1'); - expect(isLinked).to.be(false); + await dashboardPanelActions.expectNotLinkedToLibrary('My New Vis 1'); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('adding a new metric to a new dashboard by reference', async function () { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickMetric(); - await PageObjects.visualize.clickNewSearch(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickMetric(); + await visualize.clickNewSearch(); await testSubjects.click('visualizeSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('My Saved New Vis 1', { + await timeToVisualize.saveFromModal('My Saved New Vis 1', { addToDashboard: 'new', saveToLibrary: true, }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardExpect.metricValuesExist(['14,004']); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'My Saved New Vis 1' - ); - expect(isLinked).to.be(true); + await dashboardPanelActions.expectLinkedToLibrary('My Saved New Vis 1'); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('adding a existing metric to a new dashboard by value', async function () { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickMetric(); - await PageObjects.visualize.clickNewSearch(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickMetric(); + await visualize.clickNewSearch(); await testSubjects.click('visualizeSaveButton'); // Save this new viz to library - await PageObjects.timeToVisualize.saveFromModal('My New Vis 1', { + await timeToVisualize.saveFromModal('My New Vis 1', { addToDashboard: null, saveToLibrary: true, }); @@ -98,37 +92,34 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('visualizeSaveButton'); // All the options should be disabled - await PageObjects.timeToVisualize.ensureDashboardOptionsAreDisabled(); + await timeToVisualize.ensureDashboardOptionsAreDisabled(); // Save a new copy of this viz to a new dashboard - await PageObjects.timeToVisualize.saveFromModal('My New Vis 1 Copy', { + await timeToVisualize.saveFromModal('My New Vis 1 Copy', { addToDashboard: 'new', saveAsNew: true, saveToLibrary: false, }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardExpect.metricValuesExist(['14,004']); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'My New Vis 1 Copy' - ); - expect(isLinked).to.be(false); + await dashboardPanelActions.expectNotLinkedToLibrary('My New Vis 1 Copy'); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('adding a existing metric to a new dashboard by reference', async function () { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickMetric(); - await PageObjects.visualize.clickNewSearch(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickMetric(); + await visualize.clickNewSearch(); await testSubjects.click('visualizeSaveButton'); // Save this new viz to library - await PageObjects.timeToVisualize.saveFromModal('Another New Vis 1', { + await timeToVisualize.saveFromModal('Another New Vis 1', { addToDashboard: null, saveToLibrary: true, }); @@ -136,107 +127,100 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('visualizeSaveButton'); // All the options should be disabled - await PageObjects.timeToVisualize.ensureDashboardOptionsAreDisabled(); + await timeToVisualize.ensureDashboardOptionsAreDisabled(); // Save a new copy of this viz to a new dashboard - await PageObjects.timeToVisualize.saveFromModal('Another New Vis 1 Copy', { + await timeToVisualize.saveFromModal('Another New Vis 1 Copy', { addToDashboard: 'new', saveAsNew: true, saveToLibrary: true, }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardExpect.metricValuesExist(['14,004']); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'Another New Vis 1 Copy' - ); - expect(isLinked).to.be(true); + await dashboardPanelActions.expectLinkedToLibrary('Another New Vis 1 Copy'); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('adding a new metric to an existing dashboard by value', async function () { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.addVisualizations(['Visualization AreaChart']); - await PageObjects.dashboard.saveDashboard('My Excellent Dashboard'); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.addVisualizations(['Visualization AreaChart']); + await dashboard.saveDashboard('My Excellent Dashboard'); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', 'My Excellent Dashboard', 1); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickMetric(); - await PageObjects.visualize.clickNewSearch(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickMetric(); + await visualize.clickNewSearch(); await testSubjects.click('visualizeSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('My New Vis 2', { + await timeToVisualize.saveFromModal('My New Vis 2', { addToDashboard: 'existing', dashboardId: 'My Excellent Dashboard', saveToLibrary: false, }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardExpect.metricValuesExist(['14,004']); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(2); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists('My New Vis 2'); - expect(isLinked).to.be(false); + await dashboardPanelActions.expectNotLinkedToLibrary('My New Vis 2'); }); it('adding a new metric to an existing dashboard by reference', async function () { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.addVisualizations(['Visualization AreaChart']); - await PageObjects.dashboard.saveDashboard('My Wonderful Dashboard'); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.addVisualizations(['Visualization AreaChart']); + await dashboard.saveDashboard('My Wonderful Dashboard'); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', 'My Wonderful Dashboard', 1); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickMetric(); - await PageObjects.visualize.clickNewSearch(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickMetric(); + await visualize.clickNewSearch(); await testSubjects.click('visualizeSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('My Saved New Vis 2', { + await timeToVisualize.saveFromModal('My Saved New Vis 2', { addToDashboard: 'existing', dashboardId: 'My Wonderful Dashboard', saveToLibrary: true, }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardExpect.metricValuesExist(['14,004']); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(2); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'My Saved New Vis 2' - ); - expect(isLinked).to.be(true); + await dashboardPanelActions.expectLinkedToLibrary('My Saved New Vis 2', false); }); it('adding a existing metric to an existing dashboard by value', async function () { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.addVisualizations(['Visualization AreaChart']); - await PageObjects.dashboard.saveDashboard('My Very Cool Dashboard'); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.addVisualizations(['Visualization AreaChart']); + await dashboard.saveDashboard('My Very Cool Dashboard'); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', 'My Very Cool Dashboard', 1); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickMetric(); - await PageObjects.visualize.clickNewSearch(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickMetric(); + await visualize.clickNewSearch(); await testSubjects.click('visualizeSaveButton'); // Save this new viz to library - await PageObjects.timeToVisualize.saveFromModal('My New Vis 2', { + await timeToVisualize.saveFromModal('My New Vis 2', { addToDashboard: null, saveToLibrary: true, }); @@ -244,44 +228,41 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('visualizeSaveButton'); // All the options should be disabled - await PageObjects.timeToVisualize.ensureDashboardOptionsAreDisabled(); + await timeToVisualize.ensureDashboardOptionsAreDisabled(); // Save a new copy of this viz to an existing dashboard - await PageObjects.timeToVisualize.saveFromModal('My New Vis 2 Copy', { + await timeToVisualize.saveFromModal('My New Vis 2 Copy', { addToDashboard: 'existing', dashboardId: 'My Very Cool Dashboard', saveAsNew: true, saveToLibrary: false, }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardExpect.metricValuesExist(['14,004']); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(2); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'My New Vis 2 Copy' - ); - expect(isLinked).to.be(false); + await dashboardPanelActions.expectNotLinkedToLibrary('My New Vis 2 Copy'); }); it('adding a existing metric to an existing dashboard by reference', async function () { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.addVisualizations(['Visualization AreaChart']); - await PageObjects.dashboard.saveDashboard('My Very Neat Dashboard'); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); + await dashboard.addVisualizations(['Visualization AreaChart']); + await dashboard.saveDashboard('My Very Neat Dashboard'); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', 'My Very Neat Dashboard', 1); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickMetric(); - await PageObjects.visualize.clickNewSearch(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickMetric(); + await visualize.clickNewSearch(); await testSubjects.click('visualizeSaveButton'); // Save this new viz to library - await PageObjects.timeToVisualize.saveFromModal('Neat Saved Vis 2', { + await timeToVisualize.saveFromModal('Neat Saved Vis 2', { addToDashboard: null, saveToLibrary: true, }); @@ -289,25 +270,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('visualizeSaveButton'); // All the options should be disabled - await PageObjects.timeToVisualize.ensureDashboardOptionsAreDisabled(); + await timeToVisualize.ensureDashboardOptionsAreDisabled(); // Save a new copy of this viz to an existing dashboard - await PageObjects.timeToVisualize.saveFromModal('Neat Saved Vis 2 Copy', { + await timeToVisualize.saveFromModal('Neat Saved Vis 2 Copy', { addToDashboard: 'existing', dashboardId: 'My Very Neat Dashboard', saveAsNew: true, saveToLibrary: true, }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardExpect.metricValuesExist(['14,004']); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(2); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'Neat Saved Vis 2 Copy' - ); - expect(isLinked).to.be(true); + await dashboardPanelActions.expectLinkedToLibrary('Neat Saved Vis 2 Copy'); }); }); } diff --git a/test/functional/apps/visualize/group3/_annotation_listing.ts b/test/functional/apps/visualize/group3/_annotation_listing.ts index 18c819932d512..a6a1743430092 100644 --- a/test/functional/apps/visualize/group3/_annotation_listing.ts +++ b/test/functional/apps/visualize/group3/_annotation_listing.ts @@ -11,7 +11,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'annotationEditor']); + const { visualize, annotationEditor } = getPageObjects(['visualize', 'annotationEditor']); const listingTable = getService('listingTable'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); @@ -32,8 +32,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { path: `/api/data_views/data_view/data-view-to-delete`, }); - await PageObjects.visualize.gotoVisualizationLandingPage(); - await PageObjects.visualize.selectAnnotationsTab(); + await visualize.gotoVisualizationLandingPage(); + await visualize.selectAnnotationsTab(); await listingTable.waitUntilTableIsLoaded(); }); @@ -111,11 +111,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('edit', function () { it('edits group metadata', async function () { await listingTable.clickItemLink('eventAnnotation', 'group 3'); - await PageObjects.annotationEditor.editGroupMetadata({ + await annotationEditor.editGroupMetadata({ title: 'edited title', description: 'edited description', }); - await PageObjects.annotationEditor.saveGroup(); + await annotationEditor.saveGroup(); await listingTable.searchForItemWithName('edited title'); await listingTable.expectItemsCount('eventAnnotation', 1); @@ -127,10 +127,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('individual annotations', () => { it('edits an existing annotation', async function () { await listingTable.clickItemLink('eventAnnotation', 'edited title'); - expect(await PageObjects.annotationEditor.getAnnotationCount()).to.be(1); + expect(await annotationEditor.getAnnotationCount()).to.be(1); - await PageObjects.annotationEditor.openAnnotation(); - await PageObjects.annotationEditor.configureAnnotation({ + await annotationEditor.openAnnotation(); + await annotationEditor.configureAnnotation({ query: 'my query', lineThickness: 5, color: '#FF0000', @@ -138,25 +138,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('adds a new annotation', async function () { - await PageObjects.annotationEditor.addAnnotation({ + await annotationEditor.addAnnotation({ query: 'other query', lineThickness: 3, color: '#00FF00', }); await retry.try(async () => { - expect(await PageObjects.annotationEditor.getAnnotationCount()).to.be(2); + expect(await annotationEditor.getAnnotationCount()).to.be(2); }); }); it('removes an annotation', async function () { - await PageObjects.annotationEditor.removeAnnotation(); + await annotationEditor.removeAnnotation(); await retry.try(async () => { - expect(await PageObjects.annotationEditor.getAnnotationCount()).to.be(1); + expect(await annotationEditor.getAnnotationCount()).to.be(1); }); - await PageObjects.annotationEditor.saveGroup(); + await annotationEditor.saveGroup(); }); }); @@ -169,18 +169,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await listingTable.clickItemLink('eventAnnotation', 'missing data view'); await retry.try(async () => { - expect(await PageObjects.annotationEditor.showingMissingDataViewPrompt()).to.be(true); + expect(await annotationEditor.showingMissingDataViewPrompt()).to.be(true); }); await retry.try(async () => { - await PageObjects.annotationEditor.editGroupMetadata({ + await annotationEditor.editGroupMetadata({ dataView: 'logs*', }); - expect(await PageObjects.annotationEditor.showingMissingDataViewPrompt()).to.be(false); + expect(await annotationEditor.showingMissingDataViewPrompt()).to.be(false); expect(await find.byCssSelector('canvas')).to.be.ok(); }); - await PageObjects.annotationEditor.saveGroup(); + await annotationEditor.saveGroup(); }); it('recovers from missing field in data view', async () => { @@ -198,7 +198,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await assertShowingMissingFieldError(false); await retry.try(async () => { - await PageObjects.annotationEditor.editGroupMetadata({ + await annotationEditor.editGroupMetadata({ dataView: 'Data view without fields', }); @@ -206,7 +206,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await retry.try(async () => { - await PageObjects.annotationEditor.editGroupMetadata({ + await annotationEditor.editGroupMetadata({ dataView: 'logs*', }); diff --git a/test/functional/apps/visualize/group3/_linked_saved_searches.ts b/test/functional/apps/visualize/group3/_linked_saved_searches.ts index 0277aaa8ad190..d2d1195e78c61 100644 --- a/test/functional/apps/visualize/group3/_linked_saved_searches.ts +++ b/test/functional/apps/visualize/group3/_linked_saved_searches.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const filterBar = getService('filterBar'); const retry = getService('retry'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { common, discover, visualize, header, timePicker, visChart } = getPageObjects([ 'common', 'discover', 'visualize', @@ -31,25 +31,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { let discoverSavedSearchUrlPath: string; before(async () => { - await PageObjects.visualize.initTests(); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await visualize.initTests(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); await filterBar.addFilter({ field: 'extension.raw', operation: 'is', value: 'jpg' }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.saveSearch(savedSearchName); + await header.waitUntilLoadingHasFinished(); + await discover.saveSearch(savedSearchName); discoverSavedSearchUrlPath = (await browser.getCurrentUrl()).split('?')[0]; }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('should create a visualization from a saved search', async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickSavedSearch(savedSearchName); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickSavedSearch(savedSearchName); await retry.waitFor('wait for count to equal 9,109', async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); return data[0][0] === '9,109'; }); }); @@ -57,10 +57,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should have a valid link to the saved search from the visualization', async () => { await testSubjects.click('showUnlinkSavedSearchPopover'); await testSubjects.click('viewSavedSearch'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('wait discover load its breadcrumbs', async () => { - const discoverBreadcrumb = await PageObjects.discover.getCurrentQueryName(); + const discoverBreadcrumb = await discover.getCurrentQueryName(); return discoverBreadcrumb === savedSearchName; }); @@ -69,16 +69,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // go back to visualize await browser.goBack(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); it('should respect the time filter when linked to a saved search', async () => { - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 19, 2015 @ 06:31:44.000', 'Sep 21, 2015 @ 10:00:00.000' ); await retry.waitFor('wait for count to equal 3,950', async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); return data[0][0] === '3,950'; }); }); @@ -89,17 +89,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { operation: 'is between', value: { from: '100', to: '3000' }, }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('wait for count to equal 707', async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); return data[0][0] === '707'; }); }); it('should allow unlinking from a linked search', async () => { - await PageObjects.visualize.clickUnlinkSavedSearch(); + await visualize.clickUnlinkSavedSearch(); await retry.waitFor('wait for count to equal 707', async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); return data[0][0] === '707'; }); // The filter on the saved search should now be in the editor @@ -108,18 +108,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Disabling this filter should now result in different values, since // the visualization should not be linked anymore with the saved search. await filterBar.toggleFilterEnabled('extension.raw'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('wait for count to equal 1,293', async () => { - const unfilteredData = await PageObjects.visChart.getTableVisContent(); + const unfilteredData = await visChart.getTableVisContent(); return unfilteredData[0][0] === '1,293'; }); }); it('should not break when saving after unlinking', async () => { - await PageObjects.visualize.saveVisualizationExpectSuccess('Unlinked before saved'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await visualize.saveVisualizationExpectSuccess('Unlinked before saved'); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('wait for count to equal 1,293', async () => { - const data = await PageObjects.visChart.getTableVisContent(); + const data = await visChart.getTableVisContent(); return data[0][0] === '1,293'; }); }); diff --git a/test/functional/apps/visualize/group3/_pie_chart.ts b/test/functional/apps/visualize/group3/_pie_chart.ts index 33eee96ba9cd2..d42d6e72f232f 100644 --- a/test/functional/apps/visualize/group3/_pie_chart.ts +++ b/test/functional/apps/visualize/group3/_pie_chart.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const pieChart = getService('pieChart'); const inspector = getService('inspector'); - const PageObjects = getPageObjects([ + const { common, visualize, visEditor, visChart, header, timePicker } = getPageObjects([ 'common', 'visualize', 'visEditor', @@ -31,38 +31,38 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { let isNewChartsLibraryEnabled = false; const vizName1 = 'Visualization PieChart'; before(async function () { - isNewChartsLibraryEnabled = await PageObjects.visChart.isNewChartsLibraryEnabled(); - await PageObjects.visualize.initTests(isNewChartsLibraryEnabled); + isNewChartsLibraryEnabled = await visChart.isNewChartsLibraryEnabled(); + await visualize.initTests(isNewChartsLibraryEnabled); log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await visualize.navigateToNewAggBasedVisualization(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); log.debug('clickPieChart'); - await PageObjects.visualize.clickPieChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickPieChart(); + await visualize.clickNewSearch(); log.debug('select bucket Split slices'); - await PageObjects.visEditor.clickBucket('Split slices'); + await visEditor.clickBucket('Split slices'); log.debug('Click aggregation Histogram'); - await PageObjects.visEditor.selectAggregation('Histogram'); + await visEditor.selectAggregation('Histogram'); log.debug('Click field memory'); - await PageObjects.visEditor.selectField('memory'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.common.sleep(1003); + await visEditor.selectField('memory'); + await header.waitUntilLoadingHasFinished(); + await common.sleep(1003); log.debug('setNumericInterval 4000'); - await PageObjects.visEditor.setInterval('40000', { type: 'numeric' }); + await visEditor.setInterval('40000', { type: 'numeric' }); log.debug('clickGo'); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.clickGo(isNewChartsLibraryEnabled); }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('should save and load', async function () { - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); - await PageObjects.visualize.loadSavedVisualization(vizName1); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(vizName1); + await visChart.waitForVisualization(); }); it('should have inspector enabled', async function () { @@ -96,20 +96,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show other and missing bucket', async function () { const expectedTableData = ['Missing', 'Other', 'ios', 'win 7', 'win 8', 'win xp']; - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickPieChart'); - await PageObjects.visualize.clickPieChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickPieChart(); + await visualize.clickNewSearch(); log.debug('select bucket Split slices'); - await PageObjects.visEditor.clickBucket('Split slices'); + await visEditor.clickBucket('Split slices'); log.debug('Click aggregation Terms'); - await PageObjects.visEditor.selectAggregation('Terms'); + await visEditor.selectAggregation('Terms'); log.debug('Click field machine.os.raw'); - await PageObjects.visEditor.selectField('machine.os.raw'); - await PageObjects.visEditor.toggleOtherBucket(2); - await PageObjects.visEditor.toggleMissingBucket(2); + await visEditor.selectField('machine.os.raw'); + await visEditor.toggleOtherBucket(2); + await visEditor.toggleMissingBucket(2); log.debug('clickGo'); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.clickGo(isNewChartsLibraryEnabled); await pieChart.expectPieChartLabels(expectedTableData, isNewChartsLibraryEnabled); }); @@ -117,20 +117,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const expectedTableData = ['Missing', 'osx']; await pieChart.filterOnPieSlice('Other'); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); await pieChart.expectPieChartLabels(expectedTableData, isNewChartsLibraryEnabled); await filterBar.removeFilter('machine.os.raw'); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); }); it('should apply correct filter on other bucket by clicking on a legend', async () => { const expectedTableData = ['Missing', 'osx']; - await PageObjects.visChart.filterLegend('Other'); - await PageObjects.visChart.waitForVisualization(); + await visChart.filterLegend('Other'); + await visChart.waitForVisualization(); await pieChart.expectPieChartLabels(expectedTableData, isNewChartsLibraryEnabled); await filterBar.removeFilter('machine.os.raw'); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); }); it('should show two levels of other buckets', async () => { @@ -179,50 +179,50 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'Other', ].sort(); - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.clickBucket('Split slices'); - await PageObjects.visEditor.selectAggregation('Terms'); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.clickBucket('Split slices'); + await visEditor.selectAggregation('Terms'); log.debug('Click field geo.src'); - await PageObjects.visEditor.selectField('geo.src'); - await PageObjects.visEditor.toggleOtherBucket(3); - await PageObjects.visEditor.toggleMissingBucket(3); + await visEditor.selectField('geo.src'); + await visEditor.toggleOtherBucket(3); + await visEditor.toggleMissingBucket(3); log.debug('clickGo'); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.clickGo(isNewChartsLibraryEnabled); await pieChart.expectPieChartLabels(expectedTableData, isNewChartsLibraryEnabled); }); }); describe('disabled aggs', () => { before(async () => { - await PageObjects.visualize.loadSavedVisualization(vizName1); - await PageObjects.visChart.waitForRenderingCount(); + await visualize.loadSavedVisualization(vizName1); + await visChart.waitForRenderingCount(); }); it('should show correct result with one agg disabled', async () => { const expectedTableData = ['ios', 'osx', 'win 7', 'win 8', 'win xp']; - await PageObjects.visEditor.clickBucket('Split slices'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('machine.os.raw'); - await PageObjects.visEditor.toggleDisabledAgg(2); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.clickBucket('Split slices'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('machine.os.raw'); + await visEditor.toggleDisabledAgg(2); + await visEditor.clickGo(isNewChartsLibraryEnabled); await pieChart.expectPieChartLabels(expectedTableData, isNewChartsLibraryEnabled); }); it('should correctly save disabled agg', async () => { - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); - await PageObjects.visualize.loadSavedVisualization(vizName1); - await PageObjects.visChart.waitForRenderingCount(); + await visualize.loadSavedVisualization(vizName1); + await visChart.waitForRenderingCount(); const expectedTableData = ['ios', 'osx', 'win 7', 'win 8', 'win xp']; await pieChart.expectPieChartLabels(expectedTableData, isNewChartsLibraryEnabled); }); it('should show correct result when agg is re-enabled', async () => { - await PageObjects.visEditor.toggleDisabledAgg(2); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.toggleDisabledAgg(2); + await visEditor.clickGo(isNewChartsLibraryEnabled); const expectedTableData = [ '0', @@ -293,55 +293,55 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('empty time window', () => { it('should show no data message when no data on selected timerange', async function () { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickPieChart'); - await PageObjects.visualize.clickPieChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickPieChart(); + await visualize.clickNewSearch(); log.debug('select bucket Split slices'); - await PageObjects.visEditor.clickBucket('Split slices'); + await visEditor.clickBucket('Split slices'); log.debug('Click aggregation Filters'); - await PageObjects.visEditor.selectAggregation('Filters'); + await visEditor.selectAggregation('Filters'); log.debug('Set the 1st filter value'); - await PageObjects.visEditor.setFilterAggregationValue('geo.dest:"US"'); + await visEditor.setFilterAggregationValue('geo.dest:"US"'); log.debug('Add new filter'); - await PageObjects.visEditor.addNewFilterAggregation(); + await visEditor.addNewFilterAggregation(); log.debug('Set the 2nd filter value'); - await PageObjects.visEditor.setFilterAggregationValue('geo.dest:"CN"', 1); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.setFilterAggregationValue('geo.dest:"CN"', 1); + await visEditor.clickGo(isNewChartsLibraryEnabled); const emptyFromTime = 'Sep 19, 2016 @ 06:31:44.000'; const emptyToTime = 'Sep 23, 2016 @ 18:31:44.000'; log.debug( 'Switch to a different time range from "' + emptyFromTime + '" to "' + emptyToTime + '"' ); - await PageObjects.timePicker.setAbsoluteRange(emptyFromTime, emptyToTime); - await PageObjects.visChart.waitForVisualization(); - await PageObjects.visChart.expectError(); + await timePicker.setAbsoluteRange(emptyFromTime, emptyToTime); + await visChart.waitForVisualization(); + await visChart.expectError(); }); }); describe('multi series slice', () => { before(async () => { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickPieChart'); - await PageObjects.visualize.clickPieChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickPieChart(); + await visualize.clickNewSearch(); log.debug('select bucket Split slices'); - await PageObjects.visEditor.clickBucket('Split slices'); + await visEditor.clickBucket('Split slices'); log.debug('Click aggregation Histogram'); - await PageObjects.visEditor.selectAggregation('Histogram'); + await visEditor.selectAggregation('Histogram'); log.debug('Click field memory'); - await PageObjects.visEditor.selectField('memory'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.common.sleep(1003); + await visEditor.selectField('memory'); + await header.waitUntilLoadingHasFinished(); + await common.sleep(1003); log.debug('setNumericInterval 4000'); - await PageObjects.visEditor.setInterval('40000', { type: 'numeric' }); + await visEditor.setInterval('40000', { type: 'numeric' }); log.debug('Toggle previous editor'); - await PageObjects.visEditor.toggleAggregationEditor(2); + await visEditor.toggleAggregationEditor(2); log.debug('select bucket Split slices'); - await PageObjects.visEditor.clickBucket('Split slices'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('geo.dest'); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.clickBucket('Split slices'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('geo.dest'); + await visEditor.clickGo(isNewChartsLibraryEnabled); }); it('should show correct chart', async () => { @@ -431,17 +431,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'CN', ].sort(); if (isNewChartsLibraryEnabled) { - await PageObjects.visEditor.clickOptionsTab(); - await PageObjects.visEditor.togglePieLegend(); - await PageObjects.visEditor.togglePieNestedLegend(); - await PageObjects.visEditor.clickDataTab(); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.clickOptionsTab(); + await visEditor.togglePieLegend(); + await visEditor.togglePieNestedLegend(); + await visEditor.clickDataTab(); + await visEditor.clickGo(isNewChartsLibraryEnabled); } - await PageObjects.visChart.filterLegend('CN'); - await PageObjects.visChart.waitForVisualization(); + await visChart.filterLegend('CN'); + await visChart.waitForVisualization(); await pieChart.expectPieChartLabels(expectedTableData, isNewChartsLibraryEnabled); await filterBar.removeFilter('geo.dest'); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); }); it('should still showing pie chart when a subseries have zero data', async function () { @@ -450,26 +450,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { return; } - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickPieChart'); - await PageObjects.visualize.clickPieChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickPieChart(); + await visualize.clickNewSearch(); log.debug('select bucket Split slices'); - await PageObjects.visEditor.clickBucket('Split slices'); + await visEditor.clickBucket('Split slices'); log.debug('Click aggregation Filters'); - await PageObjects.visEditor.selectAggregation('Filters'); + await visEditor.selectAggregation('Filters'); log.debug('Set the 1st filter value'); - await PageObjects.visEditor.setFilterAggregationValue('geo.dest:"US"'); + await visEditor.setFilterAggregationValue('geo.dest:"US"'); log.debug('Toggle previous editor'); - await PageObjects.visEditor.toggleAggregationEditor(2); + await visEditor.toggleAggregationEditor(2); log.debug('Add a new series, select bucket Split slices'); - await PageObjects.visEditor.clickBucket('Split slices'); + await visEditor.clickBucket('Split slices'); log.debug('Click aggregation Filters'); - await PageObjects.visEditor.selectAggregation('Filters'); + await visEditor.selectAggregation('Filters'); log.debug('Set the 1st filter value of the aggregation id 3'); - await PageObjects.visEditor.setFilterAggregationValue('geo.dest:"UX"', 0, 3); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); - const legends = await PageObjects.visChart.getLegendEntries(); + await visEditor.setFilterAggregationValue('geo.dest:"UX"', 0, 3); + await visEditor.clickGo(isNewChartsLibraryEnabled); + const legends = await visChart.getLegendEntries(); const expectedLegends = ['geo.dest:"US"', 'geo.dest:"UX"']; expect(legends).to.eql(expectedLegends); }); @@ -477,19 +477,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('split chart', () => { before(async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickPieChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickPieChart(); + await visualize.clickNewSearch(); log.debug('select bucket Split chart'); - await PageObjects.visEditor.clickBucket('Split chart'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('machine.os.raw'); - await PageObjects.visEditor.toggleAggregationEditor(2); + await visEditor.clickBucket('Split chart'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('machine.os.raw'); + await visEditor.toggleAggregationEditor(2); log.debug('Add a new series, select bucket Split slices'); - await PageObjects.visEditor.clickBucket('Split slices'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('geo.src'); - await PageObjects.visEditor.clickGo(isNewChartsLibraryEnabled); + await visEditor.clickBucket('Split slices'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('geo.src'); + await visEditor.clickGo(isNewChartsLibraryEnabled); }); it('shows correct split chart', async () => { @@ -540,8 +540,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // the count of records is not shown for every split level in the new charting library isNewChartsLibraryEnabled ? [row[0], ...row.slice(2)] : row ); - await PageObjects.visChart.filterLegend('CN'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await visChart.filterLegend('CN'); + await header.waitUntilLoadingHasFinished(); await inspector.open(); await inspector.setTablePageSize(50); await inspector.expectTableData(expectedTableData); diff --git a/test/functional/apps/visualize/group3/_shared_item.ts b/test/functional/apps/visualize/group3/_shared_item.ts index 9e2e420317b7c..399fcac84d551 100644 --- a/test/functional/apps/visualize/group3/_shared_item.ts +++ b/test/functional/apps/visualize/group3/_shared_item.ts @@ -14,13 +14,13 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const retry = getService('retry'); - const PageObjects = getPageObjects(['common', 'visualize']); + const { common, visualize } = getPageObjects(['common', 'visualize']); describe('data-shared-item', function indexPatternCreation() { before(async function () { - await PageObjects.visualize.initTests(); + await visualize.initTests(); log.debug('navigateToApp visualize'); - await PageObjects.common.navigateToApp('visualize'); + await common.navigateToApp('visualize'); }); it('should have the correct data-shared-item title and description, and sharedItemContainer should exist', async function () { @@ -29,12 +29,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { description: 'AreaChart', }; - await PageObjects.visualize.openSavedVisualization('Shared-Item Visualization AreaChart'); + await visualize.openSavedVisualization('Shared-Item Visualization AreaChart'); await retry.try(async function () { - const { title, description } = await PageObjects.common.getSharedItemTitleAndDescription(); + const { title, description } = await common.getSharedItemTitleAndDescription(); expect(title).to.eql(expected.title); expect(description).to.eql(expected.description); - const sharedItemContainers = await PageObjects.common.getSharedItemContainers(); + const sharedItemContainers = await common.getSharedItemContainers(); expect(sharedItemContainers.length).to.be(1); }); }); diff --git a/test/functional/apps/visualize/group3/_visualize_listing.ts b/test/functional/apps/visualize/group3/_visualize_listing.ts index 94ac569ab3420..7cb1b7b4b51be 100644 --- a/test/functional/apps/visualize/group3/_visualize_listing.ts +++ b/test/functional/apps/visualize/group3/_visualize_listing.ts @@ -10,7 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'visEditor']); + const { visualize, visEditor } = getPageObjects(['visualize', 'visEditor']); const listingTable = getService('listingTable'); describe('visualize listing page', function describeIndexTests() { @@ -18,28 +18,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('create and delete', function () { before(async function () { - await PageObjects.visualize.initTests(); - await PageObjects.visualize.gotoVisualizationLandingPage(); - await PageObjects.visualize.deleteAllVisualizations(); + await visualize.initTests(); + await visualize.gotoVisualizationLandingPage(); + await visualize.deleteAllVisualizations(); }); it('create new viz', async function () { // type markdown is used for simplicity - await PageObjects.visualize.createSimpleMarkdownViz(vizName); - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.createSimpleMarkdownViz(vizName); + await visualize.gotoVisualizationLandingPage(); await listingTable.expectItemsCount('visualize', 1); }); it('delete all viz', async function () { - await PageObjects.visualize.createSimpleMarkdownViz(vizName + '1'); - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.createSimpleMarkdownViz(vizName + '1'); + await visualize.gotoVisualizationLandingPage(); await listingTable.expectItemsCount('visualize', 2); - await PageObjects.visualize.createSimpleMarkdownViz(vizName + '2'); - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.createSimpleMarkdownViz(vizName + '2'); + await visualize.gotoVisualizationLandingPage(); await listingTable.expectItemsCount('visualize', 3); - await PageObjects.visualize.deleteAllVisualizations(); + await visualize.deleteAllVisualizations(); await listingTable.expectItemsCount('visualize', 0); }); }); @@ -47,12 +47,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('search', function () { before(async function () { // create one new viz - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickMarkdownWidget(); - await PageObjects.visEditor.setMarkdownTxt('HELLO'); - await PageObjects.visEditor.clickGo(); - await PageObjects.visualize.saveVisualization('Hello World'); - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.navigateToNewVisualization(); + await visualize.clickMarkdownWidget(); + await visEditor.setMarkdownTxt('HELLO'); + await visEditor.clickGo(); + await visualize.saveVisualization('Hello World'); + await visualize.gotoVisualizationLandingPage(); }); it('matches on the first word', async function () { @@ -88,7 +88,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Edit', () => { before(async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); }); it('should edit the title and description of a visualization', async () => { diff --git a/test/functional/apps/visualize/group6/_tag_cloud.ts b/test/functional/apps/visualize/group6/_tag_cloud.ts index 7eeb304cfd108..b88647451cac1 100644 --- a/test/functional/apps/visualize/group6/_tag_cloud.ts +++ b/test/functional/apps/visualize/group6/_tag_cloud.ts @@ -19,43 +19,44 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const browser = getService('browser'); const retry = getService('retry'); const find = getService('find'); - const PageObjects = getPageObjects([ - 'common', - 'visualize', - 'visEditor', - 'visChart', - 'header', - 'settings', - 'timePicker', - 'tagCloud', - ]); + const { common, visualize, visEditor, visChart, header, settings, timePicker, tagCloud } = + getPageObjects([ + 'common', + 'visualize', + 'visEditor', + 'visChart', + 'header', + 'settings', + 'timePicker', + 'tagCloud', + ]); describe('tag cloud chart', function () { const vizName1 = 'Visualization tagCloud'; const termsField = 'machine.ram'; before(async function () { - await PageObjects.visualize.initTests(); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await visualize.initTests(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickTagCloud'); - await PageObjects.visualize.clickTagCloud(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickTagCloud(); + await visualize.clickNewSearch(); log.debug('select Tags'); - await PageObjects.visEditor.clickBucket('Tags'); + await visEditor.clickBucket('Tags'); log.debug('Click aggregation Terms'); - await PageObjects.visEditor.selectAggregation('Terms'); + await visEditor.selectAggregation('Terms'); log.debug('Click field machine.ram'); await retry.try(async function tryingForTime() { - await PageObjects.visEditor.selectField(termsField); + await visEditor.selectField(termsField); }); - await PageObjects.visEditor.selectOrderByMetric(2, '_key'); - await PageObjects.visEditor.clickGo(); + await visEditor.selectOrderByMetric(2, '_key'); + await visEditor.clickGo(); }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('should have inspector enabled', async function () { @@ -63,8 +64,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show correct tag cloud data', async function () { - await PageObjects.visChart.waitForVisualization(); - const data = await PageObjects.tagCloud.getTextTag(); + await visChart.waitForVisualization(); + const data = await tagCloud.getTextTag(); log.debug(data); expect(data).to.eql([ '32,212,254,720', @@ -77,23 +78,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should collapse the sidebar', async function () { const editorSidebar = await find.byCssSelector('.visEditorSidebar'); - await PageObjects.visEditor.clickEditorSidebarCollapse(); + await visEditor.clickEditorSidebarCollapse(); // Give d3 tag cloud some time to rearrange tags - await PageObjects.common.sleep(1000); + await common.sleep(1000); const isDisplayed = await editorSidebar.isDisplayed(); expect(isDisplayed).to.be(false); - await PageObjects.visEditor.clickEditorSidebarCollapse(); + await visEditor.clickEditorSidebarCollapse(); }); it('should still show all tags after sidebar has been collapsed', async function () { - await PageObjects.visEditor.clickEditorSidebarCollapse(); + await visEditor.clickEditorSidebarCollapse(); // Give d3 tag cloud some time to rearrange tags - await PageObjects.common.sleep(1000); - await PageObjects.visEditor.clickEditorSidebarCollapse(); + await common.sleep(1000); + await visEditor.clickEditorSidebarCollapse(); // Give d3 tag cloud some time to rearrange tags - await PageObjects.common.sleep(1000); - await PageObjects.visChart.waitForVisualization(); - const data = await PageObjects.tagCloud.getTextTag(); + await common.sleep(1000); + await visChart.waitForVisualization(); + const data = await tagCloud.getTextTag(); log.debug(data); expect(data).to.eql([ '32,212,254,720', @@ -106,11 +107,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should still show all tags after browser was resized very small', async function () { await browser.setWindowSize(200, 200); - await PageObjects.common.sleep(1000); + await common.sleep(1000); await browser.setWindowSize(1200, 800); - await PageObjects.common.sleep(1000); - await PageObjects.visChart.waitForVisualization(); - const data = await PageObjects.tagCloud.getTextTag(); + await common.sleep(1000); + await visChart.waitForVisualization(); + const data = await tagCloud.getTextTag(); expect(data).to.eql([ '32,212,254,720', '21,474,836,480', @@ -121,14 +122,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should save and load', async function () { - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); - await PageObjects.visualize.loadSavedVisualization(vizName1); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(vizName1); + await visChart.waitForVisualization(); }); it('should show the tags and relative size', function () { - return PageObjects.tagCloud.getTextSizes().then(function (results) { + return tagCloud.getTextSizes().then(function (results) { log.debug('results here ' + results); expect(results).to.eql(['72px', '63px', '32px', '25px', '18px']); }); @@ -150,47 +151,47 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('formatted field', function () { before(async function () { - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaIndexPatterns(); - await PageObjects.settings.clickIndexPatternLogstash(); - await PageObjects.settings.openControlsByName(termsField); + await settings.navigateTo(); + await settings.clickKibanaIndexPatterns(); + await settings.clickIndexPatternLogstash(); + await settings.openControlsByName(termsField); await ( await ( await testSubjects.find('formatRow') ).findAllByCssSelector('[data-test-subj="toggle"]') )[0].click(); - await PageObjects.settings.setFieldFormat('bytes'); - await PageObjects.settings.controlChangeSave(); - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.visualize.loadSavedVisualization(vizName1, { + await settings.setFieldFormat('bytes'); + await settings.controlChangeSave(); + await common.navigateToApp('visualize'); + await visualize.loadSavedVisualization(vizName1, { navigateToVisualize: false, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.visChart.waitForVisualization(); + await header.waitUntilLoadingHasFinished(); + await visChart.waitForVisualization(); }); after(async function () { await filterBar.removeFilter(termsField); - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaIndexPatterns(); - await PageObjects.settings.clickIndexPatternLogstash(); - await PageObjects.settings.openControlsByName(termsField); - await PageObjects.settings.setFieldFormat(''); - await PageObjects.settings.controlChangeSave(); + await settings.navigateTo(); + await settings.clickKibanaIndexPatterns(); + await settings.clickIndexPatternLogstash(); + await settings.openControlsByName(termsField); + await settings.setFieldFormat(''); + await settings.controlChangeSave(); }); it('should format tags with field formatter', async function () { - await PageObjects.visChart.waitForVisualization(); - const data = await PageObjects.tagCloud.getTextTag(); + await visChart.waitForVisualization(); + const data = await tagCloud.getTextTag(); log.debug(data); expect(data).to.eql(['30GB', '20GB', '18GB', '19GB', '17GB']); }); it('should apply filter with unformatted value', async function () { - await PageObjects.tagCloud.selectTagCloudTag('30GB'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.visChart.waitForVisualization(); - const data = await PageObjects.tagCloud.getTextTag(); + await tagCloud.selectTagCloudTag('30GB'); + await header.waitUntilLoadingHasFinished(); + await visChart.waitForVisualization(); + const data = await tagCloud.getTextTag(); expect(data).to.eql(['30GB']); }); }); diff --git a/test/functional/apps/visualize/group6/_vega_chart.ts b/test/functional/apps/visualize/group6/_vega_chart.ts index 6e5a1c9dc83ef..e833bf233ca9f 100644 --- a/test/functional/apps/visualize/group6/_vega_chart.ts +++ b/test/functional/apps/visualize/group6/_vega_chart.ts @@ -28,7 +28,7 @@ signals: [ { }]}`; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { timePicker, visualize, visChart, visEditor, vegaChart } = getPageObjects([ 'timePicker', 'visualize', 'visChart', @@ -44,25 +44,25 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('vega chart in visualize app', () => { before(async () => { - await PageObjects.visualize.initTests(); + await visualize.initTests(); log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewVisualization(); + await visualize.navigateToNewVisualization(); log.debug('clickVega'); - await PageObjects.visualize.clickVega(); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); + await visualize.clickVega(); + await visChart.waitForVisualizationRenderingStabilized(); }); describe('vega chart', () => { describe('initial render', () => { it('should have some initial vega spec text', async function () { - const vegaSpec = await PageObjects.vegaChart.getSpec(); + const vegaSpec = await vegaChart.getSpec(); expect(vegaSpec).to.contain('{'); expect(vegaSpec).to.contain('data'); expect(vegaSpec.length).to.be.above(500); }); it('should have view and control containers', async function () { - const view = await PageObjects.vegaChart.getViewContainer(); + const view = await vegaChart.getViewContainer(); expect(view).to.be.ok(); const size = await view.getSize(); expect(size).to.have.property('width'); @@ -70,7 +70,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(size.width).to.be.above(0); expect(size.height).to.be.above(0); - const controls = await PageObjects.vegaChart.getControlContainer(); + const controls = await vegaChart.getControlContainer(); expect(controls).to.be.ok(); }); }); @@ -78,7 +78,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('with filters', () => { before(async () => { log.debug('setAbsoluteRange'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); }); afterEach(async () => { @@ -86,15 +86,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('should render different data in response to filter change', async function () { - await PageObjects.vegaChart.typeInSpec('"config": { "kibana": {"renderer": "svg"} },'); - await PageObjects.visEditor.clickGo(); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - const fullDataLabels = await PageObjects.vegaChart.getYAxisLabels(); + await vegaChart.typeInSpec('"config": { "kibana": {"renderer": "svg"} },'); + await visEditor.clickGo(); + await visChart.waitForVisualizationRenderingStabilized(); + const fullDataLabels = await vegaChart.getYAxisLabels(); expect(fullDataLabels[0]).to.eql('0'); expect(fullDataLabels[fullDataLabels.length - 1]).to.eql('1,600'); await filterBar.addFilter({ field: '@tags.raw', operation: 'is', value: 'error' }); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - const filteredDataLabels = await PageObjects.vegaChart.getYAxisLabels(); + await visChart.waitForVisualizationRenderingStabilized(); + const filteredDataLabels = await vegaChart.getYAxisLabels(); expect(filteredDataLabels[0]).to.eql('0'); expect(filteredDataLabels[filteredDataLabels.length - 1]).to.eql('90'); }); @@ -225,14 +225,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { if (filtersCount > 0) { await filterBar.removeAllFilters(); } - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); + await visChart.waitForVisualizationRenderingStabilized(); }); const fillSpecAndGo = async (newSpec: string) => { - await PageObjects.vegaChart.fillSpec(newSpec); - await PageObjects.visEditor.clickGo(); + await vegaChart.fillSpec(newSpec); + await visEditor.clickGo(); - const viewContainer = await PageObjects.vegaChart.getViewContainer(); + const viewContainer = await vegaChart.getViewContainer(); const textElement = await viewContainer.findByTagName('text'); await textElement.click(); @@ -241,7 +241,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('should update global time range by calling "kibanaSetTimeFilter" expression', async () => { await fillSpecAndGo(getTestSpec('kibanaSetTimeFilter("2019", "2020")')); - const currentTimeRange = await PageObjects.timePicker.getTimeConfig(); + const currentTimeRange = await timePicker.getTimeConfig(); expect(currentTimeRange.start).to.be('Jan 1, 2019 @ 00:00:00.000'); expect(currentTimeRange.end).to.be('Jan 1, 2020 @ 00:00:00.000'); diff --git a/test/functional/apps/visualize/replaced_vislib_chart_types/_area_chart.ts b/test/functional/apps/visualize/replaced_vislib_chart_types/_area_chart.ts index 7cb1f020209b0..cbbdd8f9ffdca 100644 --- a/test/functional/apps/visualize/replaced_vislib_chart_types/_area_chart.ts +++ b/test/functional/apps/visualize/replaced_vislib_chart_types/_area_chart.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); const security = getService('security'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { common, visualize, visEditor, visChart, header, timePicker } = getPageObjects([ 'common', 'visualize', 'visEditor', @@ -33,60 +33,56 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const initAreaChart = async () => { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickAreaChart'); - await PageObjects.visualize.clickAreaChart(); + await visualize.clickAreaChart(); log.debug('clickNewSearch'); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickNewSearch(); log.debug('Click X-axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Click Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); + await visEditor.selectAggregation('Date Histogram'); log.debug('Check field value'); - const fieldValues = await PageObjects.visEditor.getField(); + const fieldValues = await visEditor.getField(); log.debug('fieldValue = ' + fieldValues); expect(fieldValues[0]).to.be('@timestamp'); - const intervalValue = await PageObjects.visEditor.getInterval(); + const intervalValue = await visEditor.getInterval(); log.debug('intervalValue = ' + intervalValue); expect(intervalValue[0]).to.be('Auto'); - await PageObjects.visEditor.clickGo(true); + await visEditor.clickGo(true); }; describe('area charts', function indexPatternCreation() { before(async () => { - await PageObjects.visualize.initTests(); + await visualize.initTests(); await security.testUser.setRoles([ 'kibana_admin', 'long_window_logstash', 'test_logstash_reader', ]); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await initAreaChart(); }); after(async function () { await security.testUser.restoreDefaults(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('should save and load with special characters', async function () { const vizNamewithSpecialChars = vizName + '/?&=%'; - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb( - vizNamewithSpecialChars - ); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizNamewithSpecialChars); }); it('should save and load with non-ascii characters', async function () { const vizNamewithSpecialChars = `${vizName} with Umlaut ä`; - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb( - vizNamewithSpecialChars - ); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizNamewithSpecialChars); }); it('should save and load', async function () { - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName); - await PageObjects.visualize.loadSavedVisualization(vizName); - await PageObjects.visChart.waitForVisualization(); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName); + await visualize.loadSavedVisualization(vizName); + await visChart.waitForVisualization(); }); it('should have inspector enabled', async function () { @@ -107,14 +103,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]; await retry.try(async function tryingForTime() { - const labels = await PageObjects.visChart.getXAxisLabels(xyChartSelector); + const labels = await visChart.getXAxisLabels(xyChartSelector); log.debug('X-Axis labels = ' + labels); expect(labels).to.eql(xAxisLabels); }); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + const labels = await visChart.getYAxisLabels(xyChartSelector); log.debug('Y-Axis labels = ' + labels); expect(labels).to.eql(yAxisLabels); - const paths = await PageObjects.visChart.getAreaChartData('Count', xyChartSelector); + const paths = await visChart.getAreaChartData('Count', xyChartSelector); log.debug('expectedAreaChartData = ' + expectedAreaChartData); log.debug('actual chart data = ' + paths); expect(paths).to.eql(expectedAreaChartData); @@ -179,9 +175,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ['2015-09-20 19:00', '55'], ]; - await PageObjects.visEditor.toggleOpenEditor(2); - await PageObjects.visEditor.setInterval('Second'); - await PageObjects.visEditor.clickGo(true); + await visEditor.toggleOpenEditor(2); + await visEditor.setInterval('Second'); + await visEditor.clickGo(true); await inspector.open(); await inspector.expectTableData(expectedTableData); await inspector.close(); @@ -211,9 +207,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ['2015-09-20 19:00', '0.015'], ]; - await PageObjects.visEditor.toggleAdvancedParams('2'); - await PageObjects.visEditor.toggleScaleMetrics(); - await PageObjects.visEditor.clickGo(true); + await visEditor.toggleAdvancedParams('2'); + await visEditor.toggleScaleMetrics(); + await visEditor.clickGo(true); await inspector.open(); await inspector.expectTableData(expectedTableData); await inspector.close(); @@ -243,11 +239,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ['2015-09-20 19:00', '55', '2.053KB'], ]; - await PageObjects.visEditor.clickBucket('Y-axis', 'metrics'); - await PageObjects.visEditor.selectAggregation('Top Hit', 'metrics'); - await PageObjects.visEditor.selectField('bytes', 'metrics'); - await PageObjects.visEditor.selectAggregateWith('average'); - await PageObjects.visEditor.clickGo(true); + await visEditor.clickBucket('Y-axis', 'metrics'); + await visEditor.selectAggregation('Top Hit', 'metrics'); + await visEditor.selectField('bytes', 'metrics'); + await visEditor.selectAggregateWith('average'); + await visEditor.clickGo(true); await inspector.open(); await inspector.expectTableData(expectedTableData); await inspector.close(); @@ -258,9 +254,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should hide side editor if embed is set to true in url', async () => { const url = await browser.getCurrentUrl(); const embedUrl = url.split('/visualize#').pop() + '&embed=true'; - await PageObjects.common.navigateToUrl('visualize', embedUrl, { useActualUrl: true }); - await PageObjects.header.waitUntilLoadingHasFinished(); - const sideEditorExists = await PageObjects.visualize.getSideEditorExists(); + await common.navigateToUrl('visualize', embedUrl, { useActualUrl: true }); + await header.waitUntilLoadingHasFinished(); + const sideEditorExists = await visualize.getSideEditorExists(); expect(sideEditorExists).to.be(false); }); @@ -268,7 +264,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const url = (await browser.getCurrentUrl()) ?? ''; const lastValue = url.split('/visualize#').pop() ?? ''; const embedUrl = lastValue.replace('embed=true', ''); - await PageObjects.common.navigateToUrl('visualize', embedUrl, { useActualUrl: true }); + await common.navigateToUrl('visualize', embedUrl, { useActualUrl: true }); }); }); @@ -277,12 +273,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const axisId = 'ValueAxis-1'; it('should show ticks on selecting log scale', async () => { - await PageObjects.visEditor.clickMetricsAndAxes(); - await PageObjects.visEditor.clickYAxisOptions(axisId); - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'log'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers(xyChartSelector); + await visEditor.clickMetricsAndAxes(); + await visEditor.clickYAxisOptions(axisId); + await visEditor.selectYAxisScaleType(axisId, 'log'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabelsAsNumbers(xyChartSelector); const minLabel = 1; const maxLabel = 900; const numberOfLabels = 10; @@ -292,9 +288,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show filtered ticks on selecting log scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabelsAsNumbers(xyChartSelector); const minLabel = 1; const maxLabel = 900; const numberOfLabels = 10; @@ -304,36 +300,36 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show ticks on selecting square root scale', async () => { - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'square root'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.selectYAxisScaleType(axisId, 'square root'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); it('should show filtered ticks on selecting square root scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); it('should show ticks on selecting linear scale', async () => { - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'linear'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.selectYAxisScaleType(axisId, 'linear'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); log.debug(labels); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); it('should show filtered ticks on selecting linear scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); @@ -345,47 +341,47 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should render a yearly area with 12 svg paths', async () => { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickAreaChart'); - await PageObjects.visualize.clickAreaChart(); + await visualize.clickAreaChart(); log.debug('clickNewSearch'); - await PageObjects.visualize.clickNewSearch('long-window-logstash-*'); - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await visualize.clickNewSearch('long-window-logstash-*'); + await timePicker.setAbsoluteRange(fromTime, toTime); log.debug('Click X-axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Click Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); - await PageObjects.visEditor.selectField('@timestamp'); - await PageObjects.visEditor.setInterval('Year'); - await PageObjects.visEditor.clickGo(true); + await visEditor.selectAggregation('Date Histogram'); + await visEditor.selectField('@timestamp'); + await visEditor.setInterval('Year'); + await visEditor.clickGo(true); // This svg area is composed by 7 years (2013 - 2019). // 7 points are used to draw the upper line (usually called y1) // 7 points compose the lower line (usually called y0) - const paths = await PageObjects.visChart.getAreaChartPaths('Count', xyChartSelector); + const paths = await visChart.getAreaChartPaths('Count', xyChartSelector); log.debug('actual chart data = ' + paths); const numberOfSegments = 7 * 2; expect(paths.length).to.eql(numberOfSegments); }); it('should render monthly areas with 168 svg paths', async () => { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickAreaChart'); - await PageObjects.visualize.clickAreaChart(); + await visualize.clickAreaChart(); log.debug('clickNewSearch'); - await PageObjects.visualize.clickNewSearch('long-window-logstash-*'); - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await visualize.clickNewSearch('long-window-logstash-*'); + await timePicker.setAbsoluteRange(fromTime, toTime); log.debug('Click X-axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Click Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); - await PageObjects.visEditor.selectField('@timestamp'); - await PageObjects.visEditor.setInterval('Month'); - await PageObjects.visEditor.clickGo(true); + await visEditor.selectAggregation('Date Histogram'); + await visEditor.selectField('@timestamp'); + await visEditor.setInterval('Month'); + await visEditor.clickGo(true); // This svg area is composed by 67 months 3 (2013) + 5 * 12 + 4 (2019) // 67 points are used to draw the upper line (usually called y1) // 67 points compose the lower line (usually called y0) const numberOfSegments = 67 * 2; - const paths = await PageObjects.visChart.getAreaChartPaths('Count', xyChartSelector); + const paths = await visChart.getAreaChartPaths('Count', xyChartSelector); log.debug('actual chart data = ' + paths); expect(paths.length).to.eql(numberOfSegments); }); @@ -393,13 +389,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('date histogram when no date field', () => { before(async () => { - await PageObjects.visualize.loadSavedVisualization('AreaChart [no date field]'); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization('AreaChart [no date field]'); + await visChart.waitForVisualization(); log.debug('Click X-axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Click Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); + await visEditor.selectAggregation('Date Histogram'); }); it('should show error message for field', async () => { @@ -415,17 +411,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('date histogram when no time filter', () => { before(async () => { - await PageObjects.visualize.loadSavedVisualization('AreaChart [no time filter]'); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization('AreaChart [no time filter]'); + await visChart.waitForVisualization(); log.debug('Click X-axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Click Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); + await visEditor.selectAggregation('Date Histogram'); }); it('should not show error message on init when the field is not selected', async () => { - const fieldValues = await PageObjects.visEditor.getField(); + const fieldValues = await visEditor.getField(); expect(fieldValues[0]).to.be(undefined); const isFieldErrorMessageExists = await find.existsByCssSelector( '[data-test-subj="visDefaultEditorField"] + .euiFormErrorText' @@ -442,13 +438,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not fail during changing interval when the field is not selected', async () => { - await PageObjects.visEditor.setInterval('m'); - const intervalValues = await PageObjects.visEditor.getInterval(); + await visEditor.setInterval('m'); + const intervalValues = await visEditor.getInterval(); expect(intervalValues[0]).to.be('Millisecond'); }); it('should not fail during changing custom interval when the field is not selected', async () => { - await PageObjects.visEditor.setInterval('4d', { type: 'custom' }); + await visEditor.setInterval('4d', { type: 'custom' }); const isInvalidIntervalExists = await find.existsByCssSelector( '.euiComboBox-isInvalid[data-test-subj="visEditorInterval"]' ); @@ -456,7 +452,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show error when interval invalid', async () => { - await PageObjects.visEditor.setInterval('xx', { type: 'custom' }); + await visEditor.setInterval('xx', { type: 'custom' }); const isIntervalErrorMessageExists = await find.existsByCssSelector( '[data-test-subj="visEditorInterval"] + .euiFormErrorText' ); @@ -464,14 +460,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show error when calendar interval invalid', async () => { - await PageObjects.visEditor.setInterval('2w', { type: 'custom' }); + await visEditor.setInterval('2w', { type: 'custom' }); const intervalErrorMessage = await find.byCssSelector( '[data-test-subj="visEditorInterval"] + .euiFormErrorText' ); let errorMessage = await intervalErrorMessage.getVisibleText(); expect(errorMessage).to.be('Invalid calendar interval: 2w, value must be 1'); - await PageObjects.visEditor.setInterval('3w', { type: 'custom' }); + await visEditor.setInterval('3w', { type: 'custom' }); errorMessage = await intervalErrorMessage.getVisibleText(); expect(errorMessage).to.be('Invalid calendar interval: 3w, value must be 1'); }); @@ -480,14 +476,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('date histogram interval', () => { before(async () => { - await PageObjects.visualize.loadSavedVisualization('Visualization AreaChart'); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization('Visualization AreaChart'); + await visChart.waitForVisualization(); }); beforeEach(async () => { const fromTime = 'Sep 20, 2015 @ 00:00:00.000'; const toTime = 'Sep 20, 2015 @ 23:30:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await timePicker.setAbsoluteRange(fromTime, toTime); }); it('should update collapsed accordion label when time range is changed', async () => { @@ -498,26 +494,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(accordionLabelText).to.include.string('per 30 minutes'); const fromTime = 'Sep 20, 2015 @ 08:30:00.000'; const toTime = 'Sep 20, 2015 @ 23:30:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await timePicker.setAbsoluteRange(fromTime, toTime); accordionLabelText = await accordionLabel.getVisibleText(); expect(accordionLabelText).to.include.string('per 10 minutes'); }); describe('expanded accordion', () => { - before(async () => await PageObjects.visEditor.toggleAccordion('visEditorAggAccordion2')); + before(async () => await visEditor.toggleAccordion('visEditorAggAccordion2')); it('should update label inside the opened accordion when scaled to milliseconds', async () => { const isHelperScaledLabelExists = await find.existsByCssSelector( '[data-test-subj="currentlyScaledText"]' ); expect(isHelperScaledLabelExists).to.be(false); - await PageObjects.visEditor.setInterval('Millisecond'); + await visEditor.setInterval('Millisecond'); const helperScaledLabelText = await testSubjects.getVisibleText('currentlyScaledText'); expect(helperScaledLabelText).to.include.string('to 10 minutes'); }); it('should display updated scaled label text after time range is changed', async () => { - await PageObjects.visEditor.setInterval('Millisecond'); + await visEditor.setInterval('Millisecond'); // Apply interval await testSubjects.clickWhenNotDisabledWithoutRetry('visualizeEditorRenderButton'); @@ -530,13 +526,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(helperScaledLabelText).to.include.string('to 10 minutes'); const fromTime = 'Sep 20, 2015 @ 22:30:00.000'; const toTime = 'Sep 20, 2015 @ 23:30:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await timePicker.setAbsoluteRange(fromTime, toTime); helperScaledLabelText = await testSubjects.getVisibleText('currentlyScaledText'); expect(helperScaledLabelText).to.include.string('to 30 seconds'); }); it('should update scaled label text after custom interval is set and time range is changed', async () => { - await PageObjects.visEditor.setInterval('10s', { type: 'custom' }); + await visEditor.setInterval('10s', { type: 'custom' }); await testSubjects.clickWhenNotDisabledWithoutRetry('visualizeEditorRenderButton'); const isHelperScaledLabelExists = await find.existsByCssSelector( '[data-test-subj="currentlyScaledText"]' @@ -546,7 +542,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(helperScaledLabelText).to.include.string('to 10 minutes'); const fromTime = 'Sep 20, 2015 @ 21:30:00.000'; const toTime = 'Sep 20, 2015 @ 23:30:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await timePicker.setAbsoluteRange(fromTime, toTime); helperScaledLabelText = await testSubjects.getVisibleText('currentlyScaledText'); expect(helperScaledLabelText).to.include.string('to minute'); }); diff --git a/test/functional/apps/visualize/replaced_vislib_chart_types/_line_chart_split_chart.ts b/test/functional/apps/visualize/replaced_vislib_chart_types/_line_chart_split_chart.ts index cc316f72c47c9..a4a74e499c31d 100644 --- a/test/functional/apps/visualize/replaced_vislib_chart_types/_line_chart_split_chart.ts +++ b/test/functional/apps/visualize/replaced_vislib_chart_types/_line_chart_split_chart.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const inspector = getService('inspector'); const retry = getService('retry'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { common, visualize, visEditor, visChart, timePicker } = getPageObjects([ 'common', 'visualize', 'visEditor', @@ -29,29 +29,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('line charts - split chart', function () { const initLineChart = async function () { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickLineChart'); - await PageObjects.visualize.clickLineChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickLineChart(); + await visualize.clickNewSearch(); log.debug('Bucket = Split chart'); - await PageObjects.visEditor.clickBucket('Split chart'); + await visEditor.clickBucket('Split chart'); log.debug('Aggregation = Terms'); - await PageObjects.visEditor.selectAggregation('Terms'); + await visEditor.selectAggregation('Terms'); log.debug('Field = extension'); - await PageObjects.visEditor.selectField('extension.raw'); + await visEditor.selectField('extension.raw'); log.debug('switch from Rows to Columns'); - await PageObjects.visEditor.clickSplitDirection('Columns'); - await PageObjects.visEditor.clickGo(true); + await visEditor.clickSplitDirection('Columns'); + await visEditor.clickGo(true); }; before(async () => { - await PageObjects.visualize.initTests(); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await visualize.initTests(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await initLineChart(); }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); afterEach(async () => { @@ -64,8 +64,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const expectedChartData = ['jpg 9,109', 'css 2,159', 'png 1,373', 'gif 918', 'php 445']; // sleep a bit before trying to get the chart data - await PageObjects.common.sleep(3000); - const data = await PageObjects.visChart.getLineChartData(xyChartSelector); + await common.sleep(3000); + const data = await visChart.getLineChartData(xyChartSelector); log.debug('data=' + data); const tolerance = 10; // the y-axis scale is 10000 so 10 is 0.1% for (let x = 0; x < data.length; x++) { @@ -95,10 +95,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const expectedChartData = ['png 1,373', 'php 445', 'jpg 9,109', 'gif 918', 'css 2,159']; log.debug('Order By = Term'); - await PageObjects.visEditor.selectOrderByMetric(2, '_key'); - await PageObjects.visEditor.clickGo(true); + await visEditor.selectOrderByMetric(2, '_key'); + await visEditor.clickGo(true); await retry.try(async function () { - const data = await PageObjects.visChart.getLineChartData(xyChartSelector); + const data = await visChart.getLineChartData(xyChartSelector); log.debug('data=' + data); const tolerance = 10; // the y-axis scale is 10000 so 10 is 0.1% for (let x = 0; x < data.length; x++) { @@ -134,7 +134,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should request new data when autofresh is enabled', async () => { const intervalS = 3; - await PageObjects.timePicker.startAutoRefresh(intervalS); + await timePicker.startAutoRefresh(intervalS); // check inspector panel request stats for timestamp await inspector.open(); @@ -145,7 +145,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { )[0][1]; // pause to allow time for autorefresh to fire another request - await PageObjects.common.sleep(intervalS * 1000 * 1.5); + await common.sleep(intervalS * 1000 * 1.5); // get the latest timestamp from request stats const requestStatsAfter = await inspector.getTableData(); @@ -158,7 +158,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // cleanup await inspector.close(); - await PageObjects.timePicker.pauseAutoRefresh(); + await timePicker.pauseAutoRefresh(); // if autorefresh is working, timestamps should be different expect(requestTimestampBefore).not.to.equal(requestTimestampAfter); @@ -166,10 +166,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to save and load', async function () { const vizName = 'Visualization Line split chart - chart library'; - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName); - await PageObjects.visualize.loadSavedVisualization(vizName); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(vizName); + await visChart.waitForVisualization(); }); describe('switch between Y axis scale types', () => { @@ -177,12 +177,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const axisId = 'ValueAxis-1'; it('should show ticks on selecting log scale', async () => { - await PageObjects.visEditor.clickMetricsAndAxes(); - await PageObjects.visEditor.clickYAxisOptions(axisId); - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'log'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers(xyChartSelector); + await visEditor.clickMetricsAndAxes(); + await visEditor.clickYAxisOptions(axisId); + await visEditor.selectYAxisScaleType(axisId, 'log'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabelsAsNumbers(xyChartSelector); const minLabel = 1; const maxLabel = 7000; const numberOfLabels = 10; @@ -192,9 +192,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show filtered ticks on selecting log scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabelsAsNumbers(xyChartSelector); const minLabel = 1; const maxLabel = 7000; const numberOfLabels = 10; @@ -204,37 +204,37 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show ticks on selecting square root scale', async () => { - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'square root'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.selectYAxisScaleType(axisId, 'square root'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '2,000', '4,000', '6,000', '8,000']; expect(labels).to.eql(expectedLabels); }); it('should show filtered ticks on selecting square root scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '2,000', '4,000', '6,000', '8,000']; expect(labels).to.eql(expectedLabels); }); it('should show ticks on selecting linear scale', async () => { - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'linear'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.selectYAxisScaleType(axisId, 'linear'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); log.debug(labels); const expectedLabels = ['0', '2,000', '4,000', '6,000', '8,000']; expect(labels).to.eql(expectedLabels); }); it('should show filtered ticks on selecting linear scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '2,000', '4,000', '6,000', '8,000']; expect(labels).to.eql(expectedLabels); }); @@ -243,35 +243,35 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('pipeline aggregations', () => { before(async () => { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickLineChart'); - await PageObjects.visualize.clickLineChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickLineChart(); + await visualize.clickNewSearch(); }); describe('parent pipeline', () => { it('should have an error if bucket is not selected', async () => { - await PageObjects.visEditor.clickMetricEditor(); + await visEditor.clickMetricEditor(); log.debug('Metrics agg = Serial diff'); - await PageObjects.visEditor.selectAggregation('Serial diff', 'metrics'); + await visEditor.selectAggregation('Serial diff', 'metrics'); await testSubjects.existOrFail('bucketsError'); }); it('should apply with selected bucket', async () => { log.debug('Bucket = X-axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Aggregation = Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.selectAggregation('Date Histogram'); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be('Serial Diff of Count'); }); it('should change y-axis label to custom', async () => { log.debug('set custom label of y-axis to "Custom"'); - await PageObjects.visEditor.setCustomLabel('Custom', 1); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.setCustomLabel('Custom', 1); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be('Custom'); }); @@ -284,25 +284,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('sibling pipeline', () => { it('should apply with selected bucket', async () => { log.debug('Metrics agg = Average Bucket'); - await PageObjects.visEditor.selectAggregation('Average Bucket', 'metrics'); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.selectAggregation('Average Bucket', 'metrics'); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be('Overall Average of Count'); }); it('should change sub metric custom label and calculate y-axis title', async () => { log.debug('set custom label of sub metric to "Cats"'); - await PageObjects.visEditor.setCustomLabel('Cats', '1-metric'); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.setCustomLabel('Cats', '1-metric'); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be('Overall Average of Cats'); }); it('should outer custom label', async () => { log.debug('set custom label to "Custom"'); - await PageObjects.visEditor.setCustomLabel('Custom', 1); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.setCustomLabel('Custom', 1); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be('Custom'); }); diff --git a/test/functional/apps/visualize/replaced_vislib_chart_types/_line_chart_split_series.ts b/test/functional/apps/visualize/replaced_vislib_chart_types/_line_chart_split_series.ts index ecb28acd419f8..3b0ea28b71e41 100644 --- a/test/functional/apps/visualize/replaced_vislib_chart_types/_line_chart_split_series.ts +++ b/test/functional/apps/visualize/replaced_vislib_chart_types/_line_chart_split_series.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const inspector = getService('inspector'); const retry = getService('retry'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { common, visualize, visEditor, visChart, timePicker } = getPageObjects([ 'common', 'visualize', 'visEditor', @@ -29,27 +29,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('line charts - split series', function () { const initLineChart = async function () { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickLineChart'); - await PageObjects.visualize.clickLineChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickLineChart(); + await visualize.clickNewSearch(); log.debug('Bucket = Split chart'); - await PageObjects.visEditor.clickBucket('Split series'); + await visEditor.clickBucket('Split series'); log.debug('Aggregation = Terms'); - await PageObjects.visEditor.selectAggregation('Terms'); + await visEditor.selectAggregation('Terms'); log.debug('Field = extension'); - await PageObjects.visEditor.selectField('extension.raw'); - await PageObjects.visEditor.clickGo(true); + await visEditor.selectField('extension.raw'); + await visEditor.clickGo(true); }; before(async () => { - await PageObjects.visualize.initTests(); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await visualize.initTests(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await initLineChart(); }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); afterEach(async () => { @@ -62,8 +62,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const expectedChartData = ['jpg 9,109', 'css 2,159', 'png 1,373', 'gif 918', 'php 445']; // sleep a bit before trying to get the chart data - await PageObjects.common.sleep(3000); - const data = await PageObjects.visChart.getLineChartData(xyChartSelector); + await common.sleep(3000); + const data = await visChart.getLineChartData(xyChartSelector); log.debug('data=' + data); const tolerance = 10; // the y-axis scale is 10000 so 10 is 0.1% for (let x = 0; x < data.length; x++) { @@ -93,10 +93,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const expectedChartData = ['png 1,373', 'php 445', 'jpg 9,109', 'gif 918', 'css 2,159']; log.debug('Order By = Term'); - await PageObjects.visEditor.selectOrderByMetric(2, '_key'); - await PageObjects.visEditor.clickGo(true); + await visEditor.selectOrderByMetric(2, '_key'); + await visEditor.clickGo(true); await retry.try(async function () { - const data = await PageObjects.visChart.getLineChartData(xyChartSelector); + const data = await visChart.getLineChartData(xyChartSelector); log.debug('data=' + data); const tolerance = 10; // the y-axis scale is 10000 so 10 is 0.1% for (let x = 0; x < data.length; x++) { @@ -132,7 +132,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should request new data when autofresh is enabled', async () => { const intervalS = 3; - await PageObjects.timePicker.startAutoRefresh(intervalS); + await timePicker.startAutoRefresh(intervalS); // check inspector panel request stats for timestamp await inspector.open(); @@ -143,7 +143,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { )[0][1]; // pause to allow time for autorefresh to fire another request - await PageObjects.common.sleep(intervalS * 1000 * 1.5); + await common.sleep(intervalS * 1000 * 1.5); // get the latest timestamp from request stats const requestStatsAfter = await inspector.getTableData(); @@ -156,7 +156,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // cleanup await inspector.close(); - await PageObjects.timePicker.pauseAutoRefresh(); + await timePicker.pauseAutoRefresh(); // if autorefresh is working, timestamps should be different expect(requestTimestampBefore).not.to.equal(requestTimestampAfter); @@ -165,10 +165,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to save and load', async function () { const vizName = 'Visualization Line split series'; - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName); - await PageObjects.visualize.loadSavedVisualization(vizName); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(vizName); + await visChart.waitForVisualization(); }); describe('switch between Y axis scale types', () => { @@ -176,12 +176,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const axisId = 'ValueAxis-1'; it('should show ticks on selecting log scale', async () => { - await PageObjects.visEditor.clickMetricsAndAxes(); - await PageObjects.visEditor.clickYAxisOptions(axisId); - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'log'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers(xyChartSelector); + await visEditor.clickMetricsAndAxes(); + await visEditor.clickYAxisOptions(axisId); + await visEditor.selectYAxisScaleType(axisId, 'log'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabelsAsNumbers(xyChartSelector); const minLabel = 1; const maxLabel = 900; const numberOfLabels = 10; @@ -191,9 +191,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show filtered ticks on selecting log scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabelsAsNumbers(xyChartSelector); const minLabel = 1; const maxLabel = 900; const numberOfLabels = 10; @@ -203,36 +203,36 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show ticks on selecting square root scale', async () => { - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'square root'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.selectYAxisScaleType(axisId, 'square root'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '2,000', '4,000', '6,000', '8,000']; expect(labels).to.eql(expectedLabels); }); it('should show filtered ticks on selecting square root scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '2,000', '4,000', '6,000', '8,000']; expect(labels).to.eql(expectedLabels); }); it('should show ticks on selecting linear scale', async () => { - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'linear'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.selectYAxisScaleType(axisId, 'linear'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); log.debug(labels); const expectedLabels = ['0', '2,000', '4,000', '6,000', '8,000']; expect(labels).to.eql(expectedLabels); }); it('should show filtered ticks on selecting linear scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '2,000', '4,000', '6,000', '8,000']; expect(labels).to.eql(expectedLabels); }); @@ -241,35 +241,35 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('pipeline aggregations', () => { before(async () => { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickLineChart'); - await PageObjects.visualize.clickLineChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickLineChart(); + await visualize.clickNewSearch(); }); describe('parent pipeline', () => { it('should have an error if bucket is not selected', async () => { - await PageObjects.visEditor.clickMetricEditor(); + await visEditor.clickMetricEditor(); log.debug('Metrics agg = Serial diff'); - await PageObjects.visEditor.selectAggregation('Serial diff', 'metrics'); + await visEditor.selectAggregation('Serial diff', 'metrics'); await testSubjects.existOrFail('bucketsError'); }); it('should apply with selected bucket', async () => { log.debug('Bucket = X-axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Aggregation = Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.selectAggregation('Date Histogram'); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be('Serial Diff of Count'); }); it('should change y-axis label to custom', async () => { log.debug('set custom label of y-axis to "Custom"'); - await PageObjects.visEditor.setCustomLabel('Custom', 1); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.setCustomLabel('Custom', 1); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be('Custom'); }); @@ -282,25 +282,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('sibling pipeline', () => { it('should apply with selected bucket', async () => { log.debug('Metrics agg = Average Bucket'); - await PageObjects.visEditor.selectAggregation('Average Bucket', 'metrics'); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.selectAggregation('Average Bucket', 'metrics'); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be('Overall Average of Count'); }); it('should change sub metric custom label and calculate y-axis title', async () => { log.debug('set custom label of sub metric to "Cats"'); - await PageObjects.visEditor.setCustomLabel('Cats', '1-metric'); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.setCustomLabel('Cats', '1-metric'); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be('Overall Average of Cats'); }); it('should outer custom label', async () => { log.debug('set custom label to "Custom"'); - await PageObjects.visEditor.setCustomLabel('Custom', 1); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.setCustomLabel('Custom', 1); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be('Custom'); }); diff --git a/test/functional/apps/visualize/replaced_vislib_chart_types/_point_series_options.ts b/test/functional/apps/visualize/replaced_vislib_chart_types/_point_series_options.ts index 23b249c8abc13..8f55f2f9285fb 100644 --- a/test/functional/apps/visualize/replaced_vislib_chart_types/_point_series_options.ts +++ b/test/functional/apps/visualize/replaced_vislib_chart_types/_point_series_options.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const browser = getService('browser'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { visualize, header, timePicker, visEditor, visChart, common } = getPageObjects([ 'visualize', 'header', 'timePicker', @@ -30,46 +30,46 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { async function initChart() { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickLineChart'); - await PageObjects.visualize.clickLineChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickLineChart(); + await visualize.clickNewSearch(); log.debug('Bucket = X-axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Aggregation = Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); + await visEditor.selectAggregation('Date Histogram'); log.debug('Field = @timestamp'); - await PageObjects.visEditor.selectField('@timestamp'); + await visEditor.selectField('@timestamp'); // add another metrics log.debug('Metric = Value Axis'); - await PageObjects.visEditor.clickBucket('Y-axis', 'metrics'); + await visEditor.clickBucket('Y-axis', 'metrics'); log.debug('Aggregation = Average'); - await PageObjects.visEditor.selectAggregation('Average', 'metrics'); + await visEditor.selectAggregation('Average', 'metrics'); log.debug('Field = memory'); - await PageObjects.visEditor.selectField('machine.ram', 'metrics'); + await visEditor.selectField('machine.ram', 'metrics'); // go to options page log.debug('Going to axis options'); - await PageObjects.visEditor.clickMetricsAndAxes(); + await visEditor.clickMetricsAndAxes(); // add another value axis log.debug('adding axis'); - await PageObjects.visEditor.clickAddAxis(); + await visEditor.clickAddAxis(); // set average count to use second value axis - await PageObjects.visEditor.toggleAccordion('visEditorSeriesAccordion3'); + await visEditor.toggleAccordion('visEditorSeriesAccordion3'); log.debug('Average memory value axis - ValueAxis-2'); - await PageObjects.visEditor.setSeriesAxis(1, 'ValueAxis-2'); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - await PageObjects.visEditor.clickGo(true); + await visEditor.setSeriesAxis(1, 'ValueAxis-2'); + await visChart.waitForVisualizationRenderingStabilized(); + await visEditor.clickGo(true); } describe('point series', function describeIndexTests() { before(async () => { - await PageObjects.visualize.initTests(); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await visualize.initTests(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await initChart(); }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); describe('secondary value axis', function () { @@ -88,14 +88,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]; await retry.try(async () => { - const data = await PageObjects.visChart.getLineChartData(xyChartSelector, 'Count'); + const data = await visChart.getLineChartData(xyChartSelector, 'Count'); log.debug('count data=' + data); log.debug('data.length=' + data.length); expect(data).to.eql(expectedChartValues[0]); }); await retry.try(async () => { - const avgMemoryData = await PageObjects.visChart.getLineChartData( + const avgMemoryData = await visChart.getLineChartData( xyChartSelector, 'Average machine.ram' ); @@ -113,29 +113,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should put secondary axis on the right', async function () { - const length = await PageObjects.visChart.getAxesCountByPosition('right', xyChartSelector); + const length = await visChart.getAxesCountByPosition('right', xyChartSelector); expect(length).to.be(1); }); }); describe('multiple chart types', function () { it('should change average series type to histogram', async function () { - await PageObjects.visEditor.setSeriesType(1, 'histogram'); - await PageObjects.visEditor.clickGo(true); - const length = await PageObjects.visChart.getHistogramSeriesCount(xyChartSelector); + await visEditor.setSeriesType(1, 'histogram'); + await visEditor.clickGo(true); + const length = await visChart.getHistogramSeriesCount(xyChartSelector); expect(length).to.be(1); }); }); describe('grid lines', function () { before(async function () { - await PageObjects.visEditor.clickOptionsTab(); + await visEditor.clickOptionsTab(); }); it('should show category grid lines', async function () { - await PageObjects.visEditor.toggleGridCategoryLines(); - await PageObjects.visEditor.clickGo(true); - const gridLines = await PageObjects.visChart.getGridLines(xyChartSelector); + await visEditor.toggleGridCategoryLines(); + await visEditor.clickGo(true); + const gridLines = await visChart.getGridLines(xyChartSelector); // FLAKY relaxing as depends on chart size/browser size and produce differences between local and CI // The objective here is to check whenever the grid lines are rendered, not the exact quantity expect(gridLines.length).to.be.greaterThan(0); @@ -145,10 +145,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show value axis grid lines', async function () { - await PageObjects.visEditor.setGridValueAxis('ValueAxis-2'); - await PageObjects.visEditor.toggleGridCategoryLines(); - await PageObjects.visEditor.clickGo(true); - const gridLines = await PageObjects.visChart.getGridLines(xyChartSelector); + await visEditor.setGridValueAxis('ValueAxis-2'); + await visEditor.toggleGridCategoryLines(); + await visEditor.clickGo(true); + const gridLines = await visChart.getGridLines(xyChartSelector); // FLAKY relaxing as depends on chart size/browser size and produce differences between local and CI // The objective here is to check whenever the grid lines are rendered, not the exact quantity expect(gridLines.length).to.be.greaterThan(0); @@ -160,31 +160,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('show values on chart', () => { before(async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickVerticalBarChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickVerticalBarChart(); + await visualize.clickNewSearch(); log.debug('Bucket = X-axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Aggregation = Terms'); - await PageObjects.visEditor.selectAggregation('Terms'); + await visEditor.selectAggregation('Terms'); log.debug('Field = geo.src'); - await PageObjects.visEditor.selectField('geo.src'); - await PageObjects.visEditor.clickGo(true); + await visEditor.selectField('geo.src'); + await visEditor.clickGo(true); log.debug('Open Options tab'); - await PageObjects.visEditor.clickOptionsTab(); + await visEditor.clickOptionsTab(); }); it('should show values on bar chart', async () => { - await PageObjects.visEditor.toggleValuesOnChart(); - await PageObjects.visEditor.clickGo(true); - const values = await PageObjects.visChart.getChartValues(xyChartSelector); + await visEditor.toggleValuesOnChart(); + await visEditor.clickGo(true); + const values = await visChart.getChartValues(xyChartSelector); expect(values).to.eql(['2,592', '2,373', '1,194', '489', '415']); }); it('should hide values on bar chart', async () => { - await PageObjects.visEditor.toggleValuesOnChart(); - await PageObjects.visEditor.clickGo(true); - const values = await PageObjects.visChart.getChartValues(xyChartSelector); + await visEditor.toggleValuesOnChart(); + await visEditor.clickGo(true); + const values = await visChart.getChartValues(xyChartSelector); expect(values.length).to.be(0); }); }); @@ -194,39 +194,39 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const customLabel = 'myLabel'; const axisTitle = 'myTitle'; before(async function () { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickLineChart(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.selectYAxisAggregation('Average', 'bytes', customLabel, 1); - await PageObjects.visEditor.clickGo(true); - await PageObjects.visEditor.clickMetricsAndAxes(); - await PageObjects.visEditor.clickYAxisOptions('ValueAxis-1'); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickLineChart(); + await visualize.clickNewSearch(); + await visEditor.selectYAxisAggregation('Average', 'bytes', customLabel, 1); + await visEditor.clickGo(true); + await visEditor.clickMetricsAndAxes(); + await visEditor.clickYAxisOptions('ValueAxis-1'); }); it('should render a custom label when one is set', async function () { - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be(customLabel); }); it('should render a custom axis title when one is set, overriding the custom label', async function () { - await PageObjects.visEditor.setAxisTitle(axisTitle); - await PageObjects.visEditor.clickGo(true); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visEditor.setAxisTitle(axisTitle); + await visEditor.clickGo(true); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be(axisTitle); }); it('should preserve saved axis titles after a vis is saved and reopened', async function () { - await PageObjects.visualize.saveVisualizationExpectSuccess(visName); - await PageObjects.visChart.waitForVisualization(); - await PageObjects.visualize.loadSavedVisualization(visName); - await PageObjects.visChart.waitForRenderingCount(); - await PageObjects.visEditor.clickDataTab(); - await PageObjects.visEditor.toggleOpenEditor(1); - await PageObjects.visEditor.setCustomLabel('test', 1); - await PageObjects.visEditor.clickGo(true); - await PageObjects.visEditor.clickMetricsAndAxes(); - await PageObjects.visEditor.clickYAxisOptions('ValueAxis-1'); - const title = await PageObjects.visChart.getYAxisTitle(xyChartSelector); + await visualize.saveVisualizationExpectSuccess(visName); + await visChart.waitForVisualization(); + await visualize.loadSavedVisualization(visName); + await visChart.waitForRenderingCount(); + await visEditor.clickDataTab(); + await visEditor.toggleOpenEditor(1); + await visEditor.setCustomLabel('test', 1); + await visEditor.clickGo(true); + await visEditor.clickMetricsAndAxes(); + await visEditor.clickYAxisOptions('ValueAxis-1'); + const title = await visChart.getYAxisTitle(xyChartSelector); expect(title).to.be(axisTitle); }); }); @@ -240,7 +240,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '2015-09-23 00:00', ]; await initChart(); - const labels = await PageObjects.visChart.getXAxisLabels(xyChartSelector); + const labels = await visChart.getXAxisLabels(xyChartSelector); expect(labels.join()).to.contain(expectedLabels.join()); }); @@ -254,10 +254,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.update({ 'dateFormat:tz': 'America/Phoenix' }); await browser.refresh(); - await PageObjects.header.awaitKibanaChrome(); + await header.awaitKibanaChrome(); await initChart(); - const labels = await PageObjects.visChart.getXAxisLabels(xyChartSelector); + const labels = await visChart.getXAxisLabels(xyChartSelector); expect(labels.join()).to.contain(expectedLabels.join()); }); @@ -266,14 +266,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const fromTime = 'Sep 22, 2015 @ 09:05:47.415'; const toTime = 'Sep 22, 2015 @ 16:08:34.554'; // note that we're setting the absolute time range while we're in 'America/Phoenix' tz - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); - await PageObjects.visChart.waitForRenderingCount(); + await timePicker.setAbsoluteRange(fromTime, toTime); + await visChart.waitForRenderingCount(); await retry.waitForWithTimeout( 'wait for x-axis labels to match expected for Phoenix', 5000, async () => { - const labels = (await PageObjects.visChart.getXAxisLabels(xyChartSelector)) ?? ''; + const labels = (await visChart.getXAxisLabels(xyChartSelector)) ?? ''; log.debug(`Labels: ${labels}`); const xLabels = [ @@ -330,16 +330,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // the absolute time range so the timepicker is going to shift +7 hours. await browser.refresh(); // wait some time before trying to check for rendering count - await PageObjects.header.awaitKibanaChrome(); - await PageObjects.visualize.clickRefresh(true); - await PageObjects.visChart.waitForRenderingCount(); + await header.awaitKibanaChrome(); + await visualize.clickRefresh(true); + await visChart.waitForRenderingCount(); log.debug('getXAxisLabels'); await retry.waitForWithTimeout( 'wait for x-axis labels to match expected for UTC', 5000, async () => { - const labels2 = (await PageObjects.visChart.getXAxisLabels(xyChartSelector)) ?? ''; + const labels2 = (await visChart.getXAxisLabels(xyChartSelector)) ?? ''; log.debug(`Labels: ${labels2}`); const xLabels2 = [ diff --git a/test/functional/apps/visualize/replaced_vislib_chart_types/_vertical_bar_chart.ts b/test/functional/apps/visualize/replaced_vislib_chart_types/_vertical_bar_chart.ts index 7fd2d67106ab3..3d0f25b7870a6 100644 --- a/test/functional/apps/visualize/replaced_vislib_chart_types/_vertical_bar_chart.ts +++ b/test/functional/apps/visualize/replaced_vislib_chart_types/_vertical_bar_chart.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const inspector = getService('inspector'); const testSubjects = getService('testSubjects'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects([ + const { visualize, visEditor, visChart, timePicker, common } = getPageObjects([ 'visualize', 'visEditor', 'visChart', @@ -29,94 +29,94 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('vertical bar chart', function () { before(async () => { - await PageObjects.visualize.initTests(); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await visualize.initTests(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); const vizName1 = 'Visualization VerticalBarChart'; const initBarChart = async () => { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickVerticalBarChart'); - await PageObjects.visualize.clickVerticalBarChart(); - await PageObjects.visualize.clickNewSearch(); + await visualize.clickVerticalBarChart(); + await visualize.clickNewSearch(); log.debug('Bucket = X-Axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Aggregation = Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); + await visEditor.selectAggregation('Date Histogram'); log.debug('Field = @timestamp'); - await PageObjects.visEditor.selectField('@timestamp'); + await visEditor.selectField('@timestamp'); // leaving Interval set to Auto - await PageObjects.visEditor.clickGo(true); + await visEditor.clickGo(true); }; describe('bar charts x axis tick labels', () => { it('should show tick labels also after rotation of the chart', async function () { await initBarChart(); - const bottomLabels = await PageObjects.visChart.getXAxisLabels(xyChartSelector); + const bottomLabels = await visChart.getXAxisLabels(xyChartSelector); log.debug(`${bottomLabels.length} tick labels on bottom x axis`); - await PageObjects.visEditor.clickMetricsAndAxes(); - await PageObjects.visEditor.selectXAxisPosition('left'); - await PageObjects.visEditor.clickGo(true); + await visEditor.clickMetricsAndAxes(); + await visEditor.selectXAxisPosition('left'); + await visEditor.clickGo(true); // the getYAxisLabels helper always returns the labels on the left axis - const leftLabels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + const leftLabels = await visChart.getYAxisLabels(xyChartSelector); log.debug(`${leftLabels.length} tick labels on left x axis`); expect(leftLabels.length).to.be.greaterThan(bottomLabels.length * (2 / 3)); }); it('should not filter out first label after rotation of the chart', async function () { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickVerticalBarChart(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickBucket('X-axis'); - await PageObjects.visEditor.selectAggregation('Date Range'); - await PageObjects.visEditor.selectField('@timestamp'); - - await PageObjects.visEditor.clickGo(true); - const bottomLabels = await PageObjects.visChart.getXAxisLabels(xyChartSelector); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickVerticalBarChart(); + await visualize.clickNewSearch(); + await visEditor.clickBucket('X-axis'); + await visEditor.selectAggregation('Date Range'); + await visEditor.selectField('@timestamp'); + + await visEditor.clickGo(true); + const bottomLabels = await visChart.getXAxisLabels(xyChartSelector); expect(bottomLabels.length).to.be(1); - await PageObjects.visEditor.clickMetricsAndAxes(); - await PageObjects.visEditor.selectXAxisPosition('left'); - await PageObjects.visEditor.clickGo(true); + await visEditor.clickMetricsAndAxes(); + await visEditor.selectXAxisPosition('left'); + await visEditor.clickGo(true); // the getYAxisLabels helper always returns the labels on the left axis - const leftLabels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + const leftLabels = await visChart.getYAxisLabels(xyChartSelector); expect(leftLabels.length).to.be(1); }); }); describe('bar charts range on x axis', () => { it('should individual bars for each configured range', async function () { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickVerticalBarChart(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.visEditor.clickBucket('X-axis'); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickVerticalBarChart(); + await visualize.clickNewSearch(); + await visEditor.clickBucket('X-axis'); log.debug('Aggregation = Date Range'); - await PageObjects.visEditor.selectAggregation('Date Range'); + await visEditor.selectAggregation('Date Range'); log.debug('Field = @timestamp'); - await PageObjects.visEditor.selectField('@timestamp'); - await PageObjects.visEditor.clickAddDateRange(); - await PageObjects.visEditor.setDateRangeByIndex('1', 'now-2w/w', 'now-1w/w'); - await PageObjects.visEditor.clickGo(true); - const bottomLabels = await PageObjects.visChart.getXAxisLabels(xyChartSelector); + await visEditor.selectField('@timestamp'); + await visEditor.clickAddDateRange(); + await visEditor.setDateRangeByIndex('1', 'now-2w/w', 'now-1w/w'); + await visEditor.clickGo(true); + const bottomLabels = await visChart.getXAxisLabels(xyChartSelector); expect(bottomLabels.length).to.be(2); }); }); it('should save and load', async function () { await initBarChart(); - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); - await PageObjects.visualize.loadSavedVisualization(vizName1); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(vizName1); + await visChart.waitForVisualization(); }); it('should have inspector enabled', async function () { @@ -133,7 +133,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // return arguments[0].getAttribute(arguments[1]);","args":[{"ELEMENT":"592"},"fill"]}] arguments[0].getAttribute is not a function // try sleeping a bit before getting that data await retry.try(async () => { - const data = await PageObjects.visChart.getBarChartData(xyChartSelector); + const data = await visChart.getBarChartData(xyChartSelector); log.debug('data=' + data); log.debug('data.length=' + data.length); expect(data).to.eql(expectedChartValues); @@ -174,7 +174,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const fromTime = 'Sep 20, 2015 @ 06:31:44.000'; const toTime = 'Sep 22, 2015 @ 18:31:44.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await timePicker.setAbsoluteRange(fromTime, toTime); let expectedChartValues = [ 82, 218, 341, 440, 480, 517, 522, 446, 403, 321, 258, 172, 95, 55, 38, 24, 3, 4, 11, 14, 17, @@ -186,15 +186,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // return arguments[0].getAttribute(arguments[1]);","args":[{"ELEMENT":"592"},"fill"]}] arguments[0].getAttribute is not a function // try sleeping a bit before getting that data await retry.try(async () => { - const data = await PageObjects.visChart.getBarChartData(xyChartSelector); + const data = await visChart.getBarChartData(xyChartSelector); log.debug('data=' + data); log.debug('data.length=' + data.length); expect(data).to.eql(expectedChartValues); }); - await PageObjects.visEditor.toggleOpenEditor(2); - await PageObjects.visEditor.clickDropPartialBuckets(); - await PageObjects.visEditor.clickGo(true); + await visEditor.toggleOpenEditor(2); + await visEditor.clickDropPartialBuckets(); + await visEditor.clickGo(true); expectedChartValues = [ 218, 341, 440, 480, 517, 522, 446, 403, 321, 258, 172, 95, 55, 38, 24, 3, 4, 11, 14, 17, 38, @@ -206,7 +206,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // return arguments[0].getAttribute(arguments[1]);","args":[{"ELEMENT":"592"},"fill"]}] arguments[0].getAttribute is not a function // try sleeping a bit before getting that data await retry.try(async () => { - const data = await PageObjects.visChart.getBarChartData(xyChartSelector); + const data = await visChart.getBarChartData(xyChartSelector); log.debug('data=' + data); log.debug('data.length=' + data.length); expect(data).to.eql(expectedChartValues); @@ -218,12 +218,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const axisId = 'ValueAxis-1'; it('should show ticks on selecting log scale', async () => { - await PageObjects.visEditor.clickMetricsAndAxes(); - await PageObjects.visEditor.clickYAxisOptions(axisId); - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'log'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers(xyChartSelector); + await visEditor.clickMetricsAndAxes(); + await visEditor.clickYAxisOptions(axisId); + await visEditor.selectYAxisScaleType(axisId, 'log'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabelsAsNumbers(xyChartSelector); const minLabel = 1; const maxLabel = 900; @@ -234,9 +234,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show filtered ticks on selecting log scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabelsAsNumbers(xyChartSelector); const minLabel = 1; const maxLabel = 900; @@ -247,36 +247,36 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show ticks on selecting square root scale', async () => { - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'square root'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.selectYAxisScaleType(axisId, 'square root'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); it('should show filtered ticks on selecting square root scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); it('should show ticks on selecting linear scale', async () => { - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'linear'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.selectYAxisScaleType(axisId, 'linear'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); log.debug(labels); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); it('should show filtered ticks on selecting linear scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); @@ -285,13 +285,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('vertical bar in percent mode', () => { it('should show ticks with percentage values', async function () { const axisId = 'ValueAxis-1'; - await PageObjects.visEditor.clickMetricsAndAxes(); - await PageObjects.visEditor.clickYAxisOptions(axisId); - await PageObjects.visEditor.selectYAxisMode('percentage'); - await PageObjects.visEditor.changeYAxisShowCheckbox(axisId, true); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.clickMetricsAndAxes(); + await visEditor.clickYAxisOptions(axisId); + await visEditor.selectYAxisMode('percentage'); + await visEditor.changeYAxisShowCheckbox(axisId, true); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); expect(labels[0]).to.eql('0%'); expect(labels[labels.length - 1]).to.eql('100%'); }); @@ -301,36 +301,36 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(initBarChart); it('should show correct series', async function () { - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.clickBucket('Split series'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('response.raw'); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - await PageObjects.visEditor.clickGo(true); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.clickBucket('Split series'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('response.raw'); + await visChart.waitForVisualizationRenderingStabilized(); + await visEditor.clickGo(true); const expectedEntries = ['200', '404', '503']; // sorting order aligned with the reading direction - const legendEntries = await PageObjects.visChart.getLegendEntriesXYCharts(xyChartSelector); + const legendEntries = await visChart.getLegendEntriesXYCharts(xyChartSelector); expect(legendEntries).to.eql(expectedEntries); }); it('should allow custom sorting of series', async () => { - await PageObjects.visEditor.toggleOpenEditor(1, 'false'); - await PageObjects.visEditor.selectCustomSortMetric(3, 'Min', 'bytes'); - await PageObjects.visEditor.clickGo(true); + await visEditor.toggleOpenEditor(1, 'false'); + await visEditor.selectCustomSortMetric(3, 'Min', 'bytes'); + await visEditor.clickGo(true); const expectedEntries = ['404', '200', '503']; - const legendEntries = await PageObjects.visChart.getLegendEntriesXYCharts(xyChartSelector); + const legendEntries = await visChart.getLegendEntriesXYCharts(xyChartSelector); expect(legendEntries).to.eql(expectedEntries); }); it('should correctly filter by legend', async () => { - await PageObjects.visChart.filterLegend('200', true); - await PageObjects.visChart.waitForVisualization(); - const legendEntries = await PageObjects.visChart.getLegendEntriesXYCharts(xyChartSelector); + await visChart.filterLegend('200', true); + await visChart.waitForVisualization(); + const legendEntries = await visChart.getLegendEntriesXYCharts(xyChartSelector); const expectedEntries = ['200']; expect(legendEntries).to.eql(expectedEntries); await filterBar.removeFilter('response.raw'); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); }); }); @@ -338,18 +338,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(initBarChart); it('should show correct series', async function () { - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.clickBucket('Split series'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('response.raw'); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - - await PageObjects.visEditor.toggleOpenEditor(3, 'false'); - await PageObjects.visEditor.clickBucket('Split series'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('machine.os'); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - await PageObjects.visEditor.clickGo(true); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.clickBucket('Split series'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('response.raw'); + await visChart.waitForVisualizationRenderingStabilized(); + + await visEditor.toggleOpenEditor(3, 'false'); + await visEditor.clickBucket('Split series'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('machine.os'); + await visChart.waitForVisualizationRenderingStabilized(); + await visEditor.clickGo(true); const expectedEntries = [ '200 - win 8', @@ -368,18 +368,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '404 - win 8', '404 - win xp', ]; - const legendEntries = await PageObjects.visChart.getLegendEntriesXYCharts(xyChartSelector); + const legendEntries = await visChart.getLegendEntriesXYCharts(xyChartSelector); expect(legendEntries).to.eql(expectedEntries); }); it('should show correct series when disabling first agg', async function () { // this will avoid issues with the play tooltip covering the disable agg button await testSubjects.scrollIntoView('metricsAggGroup'); - await PageObjects.visEditor.toggleDisabledAgg(3); - await PageObjects.visEditor.clickGo(true); + await visEditor.toggleDisabledAgg(3); + await visEditor.clickGo(true); const expectedEntries = ['win 8', 'win xp', 'ios', 'osx', 'win 7']; - const legendEntries = await PageObjects.visChart.getLegendEntriesXYCharts(xyChartSelector); + const legendEntries = await visChart.getLegendEntriesXYCharts(xyChartSelector); expect(legendEntries).to.eql(expectedEntries); }); }); @@ -388,24 +388,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(initBarChart); it('should show correct series', async function () { - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.toggleOpenEditor(1); - await PageObjects.visEditor.selectAggregation('Derivative', 'metrics'); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - await PageObjects.visEditor.clickGo(true); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.toggleOpenEditor(1); + await visEditor.selectAggregation('Derivative', 'metrics'); + await visChart.waitForVisualizationRenderingStabilized(); + await visEditor.clickGo(true); const expectedEntries = ['Derivative of Count']; - const legendEntries = await PageObjects.visChart.getLegendEntriesXYCharts(xyChartSelector); + const legendEntries = await visChart.getLegendEntriesXYCharts(xyChartSelector); expect(legendEntries).to.eql(expectedEntries); }); it('should show an error if last bucket aggregation is terms', async () => { - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.clickBucket('Split series'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('response.raw'); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.clickBucket('Split series'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('response.raw'); - const errorMessage = await PageObjects.visEditor.getBucketErrorMessage(); + const errorMessage = await visEditor.getBucketErrorMessage(); expect(errorMessage).to.contain('Last bucket aggregation must be "Date Histogram"'); }); }); diff --git a/test/functional/apps/visualize/replaced_vislib_chart_types/_vertical_bar_chart_nontimeindex.ts b/test/functional/apps/visualize/replaced_vislib_chart_types/_vertical_bar_chart_nontimeindex.ts index 30aa9e189e6a9..15ff0fc18d8e4 100644 --- a/test/functional/apps/visualize/replaced_vislib_chart_types/_vertical_bar_chart_nontimeindex.ts +++ b/test/functional/apps/visualize/replaced_vislib_chart_types/_vertical_bar_chart_nontimeindex.ts @@ -15,7 +15,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const retry = getService('retry'); const inspector = getService('inspector'); - const PageObjects = getPageObjects(['common', 'visualize', 'header', 'visEditor', 'visChart']); + const { common, visualize, header, visEditor, visChart } = getPageObjects([ + 'common', + 'visualize', + 'header', + 'visEditor', + 'visChart', + ]); const xyChartSelector = 'xyVisChart'; @@ -24,34 +30,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const initBarChart = async () => { log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); log.debug('clickVerticalBarChart'); - await PageObjects.visualize.clickVerticalBarChart(); - await PageObjects.visualize.clickNewSearch( - PageObjects.visualize.index.LOGSTASH_NON_TIME_BASED - ); - await PageObjects.common.sleep(500); + await visualize.clickVerticalBarChart(); + await visualize.clickNewSearch(visualize.index.LOGSTASH_NON_TIME_BASED); + await common.sleep(500); log.debug('Bucket = X-Axis'); - await PageObjects.visEditor.clickBucket('X-axis'); + await visEditor.clickBucket('X-axis'); log.debug('Aggregation = Date Histogram'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); + await visEditor.selectAggregation('Date Histogram'); log.debug('Field = @timestamp'); - await PageObjects.visEditor.selectField('@timestamp'); - await PageObjects.visEditor.setInterval('3h', { type: 'custom' }); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); - await PageObjects.visEditor.clickGo(true); + await visEditor.selectField('@timestamp'); + await visEditor.setInterval('3h', { type: 'custom' }); + await visChart.waitForVisualizationRenderingStabilized(); + await visEditor.clickGo(true); }; before(async () => { - await PageObjects.visualize.initTests(); + await visualize.initTests(); await initBarChart(); }); it('should save and load', async function () { - await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); + await visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1); - await PageObjects.visualize.loadSavedVisualization(vizName1); - await PageObjects.visChart.waitForVisualization(); + await visualize.loadSavedVisualization(vizName1); + await visChart.waitForVisualization(); }); it('should have inspector enabled', async function () { @@ -68,7 +72,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // return arguments[0].getAttribute(arguments[1]);","args":[{"ELEMENT":"592"},"fill"]}] arguments[0].getAttribute is not a function // try sleeping a bit before getting that data await retry.try(async () => { - const data = await PageObjects.visChart.getBarChartData(xyChartSelector); + const data = await visChart.getBarChartData(xyChartSelector); log.debug('data=' + data); log.debug('data.length=' + data.length); expect(data).to.eql(expectedChartValues); @@ -109,12 +113,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const axisId = 'ValueAxis-1'; it('should show ticks on selecting log scale', async () => { - await PageObjects.visEditor.clickMetricsAndAxes(); - await PageObjects.visEditor.clickYAxisOptions(axisId); - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'log'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers(xyChartSelector); + await visEditor.clickMetricsAndAxes(); + await visEditor.clickYAxisOptions(axisId); + await visEditor.selectYAxisScaleType(axisId, 'log'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabelsAsNumbers(xyChartSelector); const minLabel = 1; const maxLabel = 900; const numberOfLabels = 10; @@ -124,9 +128,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show filtered ticks on selecting log scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabelsAsNumbers(xyChartSelector); const minLabel = 1; const maxLabel = 900; const numberOfLabels = 10; @@ -136,36 +140,36 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show ticks on selecting square root scale', async () => { - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'square root'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.selectYAxisScaleType(axisId, 'square root'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); it('should show filtered ticks on selecting square root scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); it('should show ticks on selecting linear scale', async () => { - await PageObjects.visEditor.selectYAxisScaleType(axisId, 'linear'); - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.selectYAxisScaleType(axisId, 'linear'); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, false); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); log.debug(labels); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); it('should show filtered ticks on selecting linear scale', async () => { - await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); - await PageObjects.visEditor.clickGo(true); - const labels = await PageObjects.visChart.getYAxisLabels(xyChartSelector); + await visEditor.changeYAxisFilterLabelsCheckbox(axisId, true); + await visEditor.clickGo(true); + const labels = await visChart.getYAxisLabels(xyChartSelector); const expectedLabels = ['0', '200', '400', '600', '800', '1,000', '1,200', '1,400']; expect(labels).to.eql(expectedLabels); }); @@ -175,19 +179,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(initBarChart); it('should show correct series', async function () { - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.clickBucket('Split series'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('response.raw'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.clickBucket('Split series'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('response.raw'); + await header.waitUntilLoadingHasFinished(); - await PageObjects.common.sleep(1003); - await PageObjects.visEditor.clickGo(true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.sleep(1003); + await visEditor.clickGo(true); + await header.waitUntilLoadingHasFinished(); const expectedEntries = ['200', '404', '503']; // sorting order aligned with reading direction top-bottom - const legendEntries = await PageObjects.visChart.getLegendEntriesXYCharts(xyChartSelector); + const legendEntries = await visChart.getLegendEntriesXYCharts(xyChartSelector); expect(legendEntries).to.eql(expectedEntries); }); }); @@ -196,21 +200,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(initBarChart); it('should show correct series', async function () { - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.clickBucket('Split series'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('response.raw'); - await PageObjects.header.waitUntilLoadingHasFinished(); - - await PageObjects.visEditor.toggleOpenEditor(3, 'false'); - await PageObjects.visEditor.clickBucket('Split series'); - await PageObjects.visEditor.selectAggregation('Terms'); - await PageObjects.visEditor.selectField('machine.os'); - await PageObjects.header.waitUntilLoadingHasFinished(); - - await PageObjects.common.sleep(1003); - await PageObjects.visEditor.clickGo(true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.clickBucket('Split series'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('response.raw'); + await header.waitUntilLoadingHasFinished(); + + await visEditor.toggleOpenEditor(3, 'false'); + await visEditor.clickBucket('Split series'); + await visEditor.selectAggregation('Terms'); + await visEditor.selectField('machine.os'); + await header.waitUntilLoadingHasFinished(); + + await common.sleep(1003); + await visEditor.clickGo(true); + await header.waitUntilLoadingHasFinished(); const expectedEntries = [ '200 - win 8', @@ -229,17 +233,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '404 - win 8', '404 - win xp', ]; - const legendEntries = await PageObjects.visChart.getLegendEntriesXYCharts(xyChartSelector); + const legendEntries = await visChart.getLegendEntriesXYCharts(xyChartSelector); expect(legendEntries).to.eql(expectedEntries); }); it('should show correct series when disabling first agg', async function () { - await PageObjects.visEditor.toggleDisabledAgg(3); - await PageObjects.visEditor.clickGo(true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await visEditor.toggleDisabledAgg(3); + await visEditor.clickGo(true); + await header.waitUntilLoadingHasFinished(); const expectedEntries = ['win 8', 'win xp', 'ios', 'osx', 'win 7']; - const legendEntries = await PageObjects.visChart.getLegendEntriesXYCharts(xyChartSelector); + const legendEntries = await visChart.getLegendEntriesXYCharts(xyChartSelector); expect(legendEntries).to.eql(expectedEntries); }); }); @@ -248,17 +252,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(initBarChart); it('should show correct series', async function () { - await PageObjects.visEditor.toggleOpenEditor(2, 'false'); - await PageObjects.visEditor.toggleOpenEditor(1); - await PageObjects.visEditor.selectAggregation('Derivative', 'metrics'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await visEditor.toggleOpenEditor(2, 'false'); + await visEditor.toggleOpenEditor(1); + await visEditor.selectAggregation('Derivative', 'metrics'); + await header.waitUntilLoadingHasFinished(); - await PageObjects.common.sleep(1003); - await PageObjects.visEditor.clickGo(true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.sleep(1003); + await visEditor.clickGo(true); + await header.waitUntilLoadingHasFinished(); const expectedEntries = ['Derivative of Count']; - const legendEntries = await PageObjects.visChart.getLegendEntriesXYCharts(xyChartSelector); + const legendEntries = await visChart.getLegendEntriesXYCharts(xyChartSelector); expect(legendEntries).to.eql(expectedEntries); }); }); diff --git a/test/functional/page_objects/dashboard_page.ts b/test/functional/page_objects/dashboard_page.ts index c7b93d3ca0e91..c610b417c4323 100644 --- a/test/functional/page_objects/dashboard_page.ts +++ b/test/functional/page_objects/dashboard_page.ts @@ -718,7 +718,7 @@ export class DashboardPageObject extends FtrService { } public async getDashboardPanels() { - return await this.testSubjects.findAll('embeddablePanel'); + return await this.testSubjects.findAll('dashboardPanel'); } public async addVisualizations(visualizations: string[]) { @@ -850,20 +850,6 @@ export class DashboardPageObject extends FtrService { return checkList.filter((viz) => viz.isPresent === false).map((viz) => viz.name); } - public async getPanelDrilldownCount(panelIndex = 0): Promise { - this.log.debug('getPanelDrilldownCount'); - const panel = (await this.getDashboardPanels())[panelIndex]; - try { - const count = await panel.findByTestSubject( - 'embeddablePanelNotification-ACTION_PANEL_NOTIFICATIONS' - ); - return Number.parseInt(await count.getVisibleText(), 10); - } catch (e) { - // if not found then this is 0 (we don't show badge with 0) - return 0; - } - } - public async getPanelChartDebugState(panelIndex: number) { return await this.elasticChart.getChartDebugData(undefined, panelIndex); } diff --git a/test/functional/page_objects/time_to_visualize_page.ts b/test/functional/page_objects/time_to_visualize_page.ts index b579c334ff331..f9da8a16930fd 100644 --- a/test/functional/page_objects/time_to_visualize_page.ts +++ b/test/functional/page_objects/time_to_visualize_page.ts @@ -134,18 +134,6 @@ export class TimeToVisualizePageObject extends FtrService { } } - public async libraryNotificationExists(panelTitle: string) { - this.log.debug('searching for library modal on panel:', panelTitle); - const panel = await this.testSubjects.find( - `embeddablePanelHeading-${panelTitle.replace(/ /g, '')}` - ); - const libraryActionExists = await this.testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - panel - ); - return libraryActionExists; - } - public async saveFromModal( vizName: string, saveModalArgs: SaveModalArgs = { addToDashboard: null } diff --git a/test/functional/services/dashboard/panel_actions.ts b/test/functional/services/dashboard/panel_actions.ts index 9660b96ba3d93..8cb8a9b635c2c 100644 --- a/test/functional/services/dashboard/panel_actions.ts +++ b/test/functional/services/dashboard/panel_actions.ts @@ -41,6 +41,7 @@ export class DashboardPanelActionsService extends FtrService { private readonly dashboard = this.ctx.getPageObject('dashboard'); async findContextMenu(parent?: WebElementWrapper) { + this.log.debug('findContextMenu'); return parent ? await this.testSubjects.findDescendant(OPEN_CONTEXT_MENU_ICON_DATA_TEST_SUBJ, parent) : await this.testSubjects.find(OPEN_CONTEXT_MENU_ICON_DATA_TEST_SUBJ); @@ -75,7 +76,7 @@ export class DashboardPanelActionsService extends FtrService { } async openContextMenu(parent?: WebElementWrapper) { - this.log.debug(`openContextMenu(${parent}`); + this.log.debug(`openContextMenu`); const open = await this.testSubjects.exists('embeddablePanelContextMenuOpen'); if (!open) await this.toggleContextMenu(parent); await this.expectContextMenuToBeOpen(); @@ -89,15 +90,14 @@ export class DashboardPanelActionsService extends FtrService { async hasContextMenuMoreItem() { this.log.debug('hasContextMenuMoreItem'); - return await this.testSubjects.exists('embeddablePanelMore-mainMenu'); + return await this.testSubjects.exists('embeddablePanelMore-mainMenu', { timeout: 500 }); } async clickContextMenuMoreItem() { this.log.debug('clickContextMenuMoreItem'); await this.expectContextMenuToBeOpen(); - const hasMoreSubPanel = await this.hasContextMenuMoreItem(); - if (hasMoreSubPanel) { - await this.testSubjects.click('embeddablePanelMore-mainMenu'); + if (await this.hasContextMenuMoreItem()) { + await this.testSubjects.clickWhenNotDisabledWithoutRetry('embeddablePanelMore-mainMenu'); } } @@ -108,13 +108,13 @@ export class DashboardPanelActionsService extends FtrService { } async clickContextMenuItem(testSubject: string, parent?: WebElementWrapper) { - this.log.debug(`clickContextMenuItem`); + this.log.debug(`clickContextMenuItem(${testSubject})`); await this.openContextMenu(parent); - const exists = await this.testSubjects.exists(testSubject); + const exists = await this.testSubjects.exists(testSubject, { timeout: 500 }); if (!exists) { await this.clickContextMenuMoreItem(); } - await this.testSubjects.click(testSubject); + await this.testSubjects.clickWhenNotDisabledWithoutRetry(testSubject, { timeout: 500 }); } async clickContextMenuItemByTitle(testSubject: string, title = '') { @@ -127,10 +127,12 @@ export class DashboardPanelActionsService extends FtrService { this.log.debug('navigateToEditorFromFlyout'); await this.clickContextMenuItem(INLINE_EDIT_PANEL_DATA_TEST_SUBJ); await this.header.waitUntilLoadingHasFinished(); - await this.testSubjects.click(EDIT_IN_LENS_EDITOR_DATA_TEST_SUBJ); + await this.testSubjects.clickWhenNotDisabledWithoutRetry(EDIT_IN_LENS_EDITOR_DATA_TEST_SUBJ); const isConfirmModalVisible = await this.testSubjects.exists('confirmModalConfirmButton'); if (isConfirmModalVisible) { - await this.testSubjects.click('confirmModalConfirmButton', 20000); + await this.testSubjects.clickWhenNotDisabledWithoutRetry('confirmModalConfirmButton', { + timeout: 20000, + }); } } @@ -193,18 +195,13 @@ export class DashboardPanelActionsService extends FtrService { await this.removePanel(header); } - async customizePanel(parent?: WebElementWrapper) { - this.log.debug('customizePanel'); - await this.clickContextMenuItem(CUSTOMIZE_PANEL_DATA_TEST_SUBJ, parent); - } - - async customizePanelByTitle(title = '') { - this.log.debug('customizePanel'); + async customizePanel(title = '') { + this.log.debug(`customizePanel(${title})`); const header = await this.getPanelHeading(title); await this.clickContextMenuItem(CUSTOMIZE_PANEL_DATA_TEST_SUBJ, header); } - async clonePanelByTitle(title = '') { + async clonePanel(title = '') { this.log.debug(`clonePanel(${title})`); const header = await this.getPanelHeading(title); await this.clickContextMenuItem(CLONE_PANEL_DATA_TEST_SUBJ, header); @@ -248,60 +245,56 @@ export class DashboardPanelActionsService extends FtrService { await this.clickContextMenuItem(OPEN_INSPECTOR_TEST_SUBJ, parent); } - async legacyUnlinkFromLibrary(parent?: WebElementWrapper) { - this.log.debug('legacyUnlinkFromLibrary'); - await this.clickContextMenuItem(LEGACY_UNLINK_FROM_LIBRARY_TEST_SUBJ, parent); - await this.testSubjects.waitForDeleted( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION' - ); + async legacyUnlinkFromLibrary(title = '') { + this.log.debug(`legacyUnlinkFromLibrary(${title}`); + const header = await this.getPanelHeading(title); + await this.clickContextMenuItem(LEGACY_UNLINK_FROM_LIBRARY_TEST_SUBJ, header); + await this.testSubjects.existOrFail('unlinkPanelSuccess'); + await this.expectNotLinkedToLibrary(title, true); } - async unlinkFromLibrary(parent?: WebElementWrapper) { - this.log.debug('unlinkFromLibrary'); - await this.clickContextMenuItem(UNLINK_FROM_LIBRARY_TEST_SUBJ, parent); - await this.testSubjects.waitForDeleted( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION' - ); + async unlinkFromLibrary(title = '') { + this.log.debug(`unlinkFromLibrary(${title})`); + const header = await this.getPanelHeading(title); + await this.clickContextMenuItem(UNLINK_FROM_LIBRARY_TEST_SUBJ, header); + await this.testSubjects.existOrFail('unlinkPanelSuccess'); + await this.expectNotLinkedToLibrary(title); } - async legacySaveToLibrary(newTitle: string, parent?: WebElementWrapper) { - this.log.debug('legacySaveToLibrary'); - await this.clickContextMenuItem(LEGACY_SAVE_TO_LIBRARY_TEST_SUBJ, parent); + async legacySaveToLibrary(newTitle = '', oldTitle = '') { + this.log.debug(`legacySaveToLibrary(${newTitle},${oldTitle})`); + const header = await this.getPanelHeading(oldTitle); + await this.clickContextMenuItem(LEGACY_SAVE_TO_LIBRARY_TEST_SUBJ, header); await this.testSubjects.setValue('savedObjectTitle', newTitle, { clearWithKeyboard: true, }); - await this.testSubjects.click('confirmSaveSavedObjectButton'); - await this.retry.try(async () => { - await this.testSubjects.existOrFail( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION' - ); - }); + await this.testSubjects.clickWhenNotDisabledWithoutRetry('confirmSaveSavedObjectButton'); + await this.testSubjects.existOrFail('addPanelToLibrarySuccess'); + await this.expectLinkedToLibrary(newTitle, true); } - async saveToLibrary(newTitle: string, parent?: WebElementWrapper) { - this.log.debug('saveToLibrary'); - await this.clickContextMenuItem(SAVE_TO_LIBRARY_TEST_SUBJ, parent); + async saveToLibrary(newTitle = '', oldTitle = '') { + this.log.debug(`saveToLibraryByTitle(${newTitle},${oldTitle})`); + const header = await this.getPanelHeading(oldTitle); + await this.clickContextMenuItem(SAVE_TO_LIBRARY_TEST_SUBJ, header); await this.testSubjects.setValue('savedObjectTitle', newTitle, { clearWithKeyboard: true, }); - await this.testSubjects.click('confirmSaveSavedObjectButton'); - await this.retry.try(async () => { - await this.testSubjects.existOrFail( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION' - ); - }); + await this.testSubjects.clickWhenNotDisabledWithoutRetry('confirmSaveSavedObjectButton'); + await this.testSubjects.existOrFail('addPanelToLibrarySuccess'); + await this.expectLinkedToLibrary(newTitle); } async expectExistsPanelAction(testSubject: string, title = '') { this.log.debug('expectExistsPanelAction', testSubject, title); - const panelWrapper = title ? await this.getPanelHeading(title) : undefined; + const panelWrapper = await this.getPanelHeading(title); await this.openContextMenu(panelWrapper); - if (!(await this.testSubjects.exists(testSubject))) { + if (!(await this.testSubjects.exists(testSubject, { timeout: 1000 }))) { if (await this.hasContextMenuMoreItem()) { await this.clickContextMenuMoreItem(); } - await this.testSubjects.existOrFail(testSubject); + await this.testSubjects.existOrFail(testSubject, { timeout: 1000 }); } await this.toggleContextMenu(panelWrapper); } @@ -331,14 +324,15 @@ export class DashboardPanelActionsService extends FtrService { } async expectMissingPanelAction(testSubject: string, title = '') { - this.log.debug('expectMissingPanelAction', testSubject, title); - await this.openContextMenuByTitle(title); + this.log.debug(`expectMissingPanelAction(${title})`, testSubject); + const panelWrapper = await this.getPanelHeading(title); + await this.openContextMenu(panelWrapper); await this.testSubjects.missingOrFail(testSubject); if (await this.hasContextMenuMoreItem()) { await this.clickContextMenuMoreItem(); await this.testSubjects.missingOrFail(testSubject); } - await this.toggleContextMenuByTitle(title); + await this.toggleContextMenu(panelWrapper); } async expectMissingEditPanelAction(title = '') { @@ -381,13 +375,16 @@ export class DashboardPanelActionsService extends FtrService { await this.openContextMenu(parent); const isActionVisible = await this.testSubjects.exists(CONVERT_TO_LENS_TEST_SUBJ); if (!isActionVisible) await this.clickContextMenuMoreItem(); - return await this.testSubjects.exists(CONVERT_TO_LENS_TEST_SUBJ, { timeout: 500 }); + return await this.testSubjects.exists(CONVERT_TO_LENS_TEST_SUBJ, { timeout: 1000 }); } async canConvertToLensByTitle(title = '') { this.log.debug(`canConvertToLens(${title})`); const header = await this.getPanelHeading(title); - return await this.canConvertToLens(header); + await this.openContextMenu(header); + const isActionVisible = await this.testSubjects.exists(CONVERT_TO_LENS_TEST_SUBJ); + if (!isActionVisible) await this.clickContextMenuMoreItem(); + return await this.testSubjects.exists(CONVERT_TO_LENS_TEST_SUBJ, { timeout: 1000 }); } async convertToLens(parent?: WebElementWrapper) { @@ -398,7 +395,7 @@ export class DashboardPanelActionsService extends FtrService { throw new Error('Convert to Lens option not found'); } - await this.testSubjects.click(CONVERT_TO_LENS_TEST_SUBJ); + await this.testSubjects.clickWhenNotDisabledWithoutRetry(CONVERT_TO_LENS_TEST_SUBJ); }); } @@ -407,4 +404,26 @@ export class DashboardPanelActionsService extends FtrService { const header = await this.getPanelHeading(title); return await this.convertToLens(header); } + + public async expectLinkedToLibrary(title = '', legacy?: boolean) { + this.log.debug(`expectLinkedToLibrary(${title})`); + if (legacy) { + await this.expectExistsPanelAction(LEGACY_UNLINK_FROM_LIBRARY_TEST_SUBJ, title); + } else { + await this.expectExistsPanelAction(UNLINK_FROM_LIBRARY_TEST_SUBJ, title); + } + await this.expectMissingPanelAction(LEGACY_SAVE_TO_LIBRARY_TEST_SUBJ, title); + await this.expectMissingPanelAction(SAVE_TO_LIBRARY_TEST_SUBJ, title); + } + + public async expectNotLinkedToLibrary(title = '', legacy?: boolean) { + this.log.debug(`expectNotLinkedToLibrary(${title})`); + if (legacy) { + await this.expectExistsPanelAction(LEGACY_SAVE_TO_LIBRARY_TEST_SUBJ, title); + } else { + await this.expectExistsPanelAction(SAVE_TO_LIBRARY_TEST_SUBJ, title); + } + await this.expectMissingPanelAction(LEGACY_UNLINK_FROM_LIBRARY_TEST_SUBJ, title); + await this.expectMissingPanelAction(UNLINK_FROM_LIBRARY_TEST_SUBJ, title); + } } diff --git a/test/functional/services/dashboard/panel_drilldown_actions.ts b/test/functional/services/dashboard/panel_drilldown_actions.ts index dbff1ddf5b8cf..7c2e0278bc8e9 100644 --- a/test/functional/services/dashboard/panel_drilldown_actions.ts +++ b/test/functional/services/dashboard/panel_drilldown_actions.ts @@ -13,26 +13,25 @@ import { FtrProviderContext } from '../../ftr_provider_context'; const CREATE_DRILLDOWN_DATA_TEST_SUBJ = 'embeddablePanelAction-OPEN_FLYOUT_ADD_DRILLDOWN'; const MANAGE_DRILLDOWNS_DATA_TEST_SUBJ = 'embeddablePanelAction-OPEN_FLYOUT_EDIT_DRILLDOWN'; -export function DashboardDrilldownPanelActionsProvider({ getService }: FtrProviderContext) { +export function DashboardDrilldownPanelActionsProvider({ + getService, + getPageObjects, +}: FtrProviderContext) { const log = getService('log'); const testSubjects = getService('testSubjects'); const dashboardPanelActions = getService('dashboardPanelActions'); + const { dashboard } = getPageObjects(['dashboard']); + return new (class DashboardDrilldownPanelActions { async expectExistsCreateDrilldownAction() { log.debug('expectExistsCreateDrilldownAction'); - await dashboardPanelActions.openContextMenu(); - await dashboardPanelActions.expectContextMenuToBeOpen(); - await dashboardPanelActions.clickContextMenuMoreItem(); - await await testSubjects.existOrFail(CREATE_DRILLDOWN_DATA_TEST_SUBJ); + await dashboardPanelActions.expectExistsPanelAction(CREATE_DRILLDOWN_DATA_TEST_SUBJ); } async expectMissingCreateDrilldownAction() { log.debug('expectMissingCreateDrilldownAction'); - await dashboardPanelActions.openContextMenu(); - await dashboardPanelActions.expectContextMenuToBeOpen(); - await dashboardPanelActions.clickContextMenuMoreItem(); - await testSubjects.existOrFail(MANAGE_DRILLDOWNS_DATA_TEST_SUBJ); + await dashboardPanelActions.expectMissingPanelAction(CREATE_DRILLDOWN_DATA_TEST_SUBJ); } async clickCreateDrilldown() { @@ -43,24 +42,17 @@ export function DashboardDrilldownPanelActionsProvider({ getService }: FtrProvid async expectExistsManageDrilldownsAction() { log.debug('expectExistsCreateDrilldownAction'); - await dashboardPanelActions.openContextMenu(); - await dashboardPanelActions.expectContextMenuToBeOpen(); - await dashboardPanelActions.clickContextMenuMoreItem(); - await testSubjects.existOrFail(CREATE_DRILLDOWN_DATA_TEST_SUBJ); + await dashboardPanelActions.expectExistsPanelAction(MANAGE_DRILLDOWNS_DATA_TEST_SUBJ); } async expectMissingManageDrilldownsAction() { log.debug('expectExistsRemovePanelAction'); - await dashboardPanelActions.openContextMenu(); - await dashboardPanelActions.expectContextMenuToBeOpen(); - await dashboardPanelActions.clickContextMenuMoreItem(); - await testSubjects.existOrFail(MANAGE_DRILLDOWNS_DATA_TEST_SUBJ); + await dashboardPanelActions.expectMissingPanelAction(MANAGE_DRILLDOWNS_DATA_TEST_SUBJ); } async clickManageDrilldowns() { log.debug('clickManageDrilldowns'); - await this.expectExistsManageDrilldownsAction(); - await testSubjects.clickWhenNotDisabledWithoutRetry(MANAGE_DRILLDOWNS_DATA_TEST_SUBJ); + await dashboardPanelActions.clickContextMenuItem(MANAGE_DRILLDOWNS_DATA_TEST_SUBJ); } async expectMultipleActionsMenuOpened() { @@ -97,5 +89,37 @@ export function DashboardDrilldownPanelActionsProvider({ getService }: FtrProvid throw new Error(`No action matching text "${text}"`); } + + async getPanelDrilldownCount(panelIndex = 0): Promise { + log.debug('getPanelDrilldownCount'); + const panel = (await dashboard.getDashboardPanels())[panelIndex]; + await dashboardPanelActions.openContextMenu(panel); + + try { + const exists = await testSubjects.exists(MANAGE_DRILLDOWNS_DATA_TEST_SUBJ, { + timeout: 500, + }); + if (!exists) { + await dashboardPanelActions.clickContextMenuMoreItem(); + if (!(await testSubjects.exists(MANAGE_DRILLDOWNS_DATA_TEST_SUBJ, { timeout: 500 }))) { + return 0; + } + } + const manageDrilldownAction = await testSubjects.find( + MANAGE_DRILLDOWNS_DATA_TEST_SUBJ, + 500 + ); + + const count = await ( + await manageDrilldownAction.findByCssSelector('.euiNotificationBadge') + ).getVisibleText(); + return Number.parseInt(count, 10); + } catch (e) { + log.debug('manage drilldowns action not found'); + return 0; + } finally { + await dashboardPanelActions.toggleContextMenu(panel); + } + } })(); } diff --git a/test/plugin_functional/test_suites/data_plugin/index.ts b/test/plugin_functional/test_suites/data_plugin/index.ts index 14bbe161ffde9..e3e6232c74c32 100644 --- a/test/plugin_functional/test_suites/data_plugin/index.ts +++ b/test/plugin_functional/test_suites/data_plugin/index.ts @@ -15,15 +15,15 @@ export default function ({ loadTestFile, }: PluginFunctionalProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common', 'header', 'settings']); + const { common, settings } = getPageObjects(['common', 'settings']); describe('data plugin', () => { before(async () => { await esArchiver.loadIfNeeded( 'test/functional/fixtures/es_archiver/getting_started/shakespeare' ); - await PageObjects.common.navigateToApp('settings'); - await PageObjects.settings.createIndexPattern('shakespeare', ''); + await common.navigateToApp('settings'); + await settings.createIndexPattern('shakespeare', ''); }); loadTestFile(require.resolve('./search')); diff --git a/test/plugin_functional/test_suites/data_plugin/session.ts b/test/plugin_functional/test_suites/data_plugin/session.ts index 004b47e40fa60..812641e508d2c 100644 --- a/test/plugin_functional/test_suites/data_plugin/session.ts +++ b/test/plugin_functional/test_suites/data_plugin/session.ts @@ -11,12 +11,11 @@ import expect from '@kbn/expect'; import { PluginFunctionalProviderContext } from '../../services'; export default function ({ getService, getPageObjects }: PluginFunctionalProviderContext) { - const PageObjects = getPageObjects([ + const { common, header, dashboard, discover, unifiedFieldList } = getPageObjects([ 'common', 'header', 'dashboard', 'discover', - 'timePicker', 'unifiedFieldList', ]); const filterBar = getService('filterBar'); @@ -36,9 +35,9 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide describe('Session management', function describeSessionManagementTests() { describe('Discover', () => { before(async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await testSubjects.click('clearSessionsButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); afterEach(async () => { @@ -47,8 +46,8 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide }); it('Starts on index pattern select', async () => { - await PageObjects.discover.selectIndexPattern('shakespeare'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectIndexPattern('shakespeare'); + await header.waitUntilLoadingHasFinished(); const sessionIds = await getSessionIds(); expect(sessionIds.length).to.be(1); @@ -56,22 +55,22 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide it('Starts on a refresh', async () => { await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const sessionIds = await getSessionIds(); expect(sessionIds.length).to.be(1); }); it('Starts a new session on sort', async () => { - await PageObjects.unifiedFieldList.clickFieldListItemAdd('speaker'); - await PageObjects.discover.clickFieldSort('speaker', 'Sort A-Z'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('speaker'); + await discover.clickFieldSort('speaker', 'Sort A-Z'); + await header.waitUntilLoadingHasFinished(); const sessionIds = await getSessionIds(); expect(sessionIds.length).to.be(1); }); it('Starts a new session on filter change', async () => { await filterBar.addFilter({ field: 'line_number', operation: 'is', value: '4.3.108' }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const sessionIds = await getSessionIds(); expect(sessionIds.length).to.be(1); }); @@ -86,9 +85,9 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide await kibanaServer.importExport.load( 'test/functional/fixtures/kbn_archiver/dashboard/current/kibana' ); - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('dashboard with filter'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('dashboard'); + await dashboard.loadSavedDashboard('dashboard with filter'); + await header.waitUntilLoadingHasFinished(); }); afterEach(async () => { @@ -108,7 +107,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide it('starts a session on refresh', async () => { await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const sessionIds = await getSessionIds(); expect(sessionIds.length).to.be(1); }); diff --git a/test/plugin_functional/test_suites/panel_actions/index.js b/test/plugin_functional/test_suites/panel_actions/index.ts similarity index 77% rename from test/plugin_functional/test_suites/panel_actions/index.js rename to test/plugin_functional/test_suites/panel_actions/index.ts index 3cc629375ad02..ad4871e961db1 100644 --- a/test/plugin_functional/test_suites/panel_actions/index.js +++ b/test/plugin_functional/test_suites/panel_actions/index.ts @@ -7,11 +7,17 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export default function ({ getService, getPageObjects, loadTestFile }) { +import { PluginFunctionalProviderContext } from '../../services'; + +export default function ({ + getService, + getPageObjects, + loadTestFile, +}: PluginFunctionalProviderContext) { const browser = getService('browser'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'dashboard']); + const { common, dashboard } = getPageObjects(['common', 'dashboard']); describe('pluggable panel actions', function () { before(async () => { @@ -24,12 +30,12 @@ export default function ({ getService, getPageObjects, loadTestFile }) { await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', }); - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.preserveCrossAppState(); + await common.navigateToApp('dashboard'); + await dashboard.preserveCrossAppState(); }); after(async function () { - await PageObjects.dashboard.clearSavedObjectsFromAppLinks(); + await dashboard.clearSavedObjectsFromAppLinks(); await kibanaServer.savedObjects.cleanStandardList(); await esArchiver.unload('test/functional/fixtures/es_archiver/dashboard/current/data'); }); diff --git a/test/plugin_functional/test_suites/panel_actions/panel_actions.js b/test/plugin_functional/test_suites/panel_actions/panel_actions.ts similarity index 89% rename from test/plugin_functional/test_suites/panel_actions/panel_actions.js rename to test/plugin_functional/test_suites/panel_actions/panel_actions.ts index df83a05e14e4d..8db65c13b57b6 100644 --- a/test/plugin_functional/test_suites/panel_actions/panel_actions.js +++ b/test/plugin_functional/test_suites/panel_actions/panel_actions.ts @@ -8,16 +8,17 @@ */ import expect from '@kbn/expect'; +import { PluginFunctionalProviderContext } from '../../services'; -export default function ({ getService, getPageObjects }) { +export default function ({ getService, getPageObjects }: PluginFunctionalProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const retry = getService('retry'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['dashboard']); + const { dashboard } = getPageObjects(['dashboard']); describe('Panel Actions', () => { before(async () => { - await PageObjects.dashboard.loadSavedDashboard('few panels'); + await dashboard.loadSavedDashboard('few panels'); }); it('allows to register links into the context menu', async () => { diff --git a/x-pack/plugins/embeddable_enhanced/public/actions/index.ts b/x-pack/plugins/embeddable_enhanced/public/actions/index.ts index 0973fb30ac175..c351935bbf8bb 100644 --- a/x-pack/plugins/embeddable_enhanced/public/actions/index.ts +++ b/x-pack/plugins/embeddable_enhanced/public/actions/index.ts @@ -5,5 +5,4 @@ * 2.0. */ -export * from './panel_notifications_action'; export * from './drilldown_grouping'; diff --git a/x-pack/plugins/embeddable_enhanced/public/actions/panel_notifications_action.test.ts b/x-pack/plugins/embeddable_enhanced/public/actions/panel_notifications_action.test.ts deleted file mode 100644 index 3d099150115f3..0000000000000 --- a/x-pack/plugins/embeddable_enhanced/public/actions/panel_notifications_action.test.ts +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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 { ViewMode } from '@kbn/embeddable-plugin/public'; -import { EmbeddableApiContext, PublishesWritableViewMode } from '@kbn/presentation-publishing'; -import { - DynamicActionManager, - SerializedEvent, -} from '@kbn/ui-actions-enhanced-plugin/public/dynamic_actions'; -import { BehaviorSubject } from 'rxjs'; -import { DynamicActionsSerializedState } from '../plugin'; -import { - PanelNotificationsAction, - PanelNotificationsActionApi, -} from './panel_notifications_action'; - -const createContext = (events: SerializedEvent[] = []): EmbeddableApiContext => { - const dynamicActionsState$ = new BehaviorSubject({ - dynamicActions: { events }, - }); - const viewMode$ = new BehaviorSubject(ViewMode.VIEW); - - return { - embeddable: { - enhancements: { - dynamicActions: {} as unknown as DynamicActionManager, - }, - setDynamicActions: (value: DynamicActionsSerializedState['enhancements']) => { - dynamicActionsState$.next(value); - }, - dynamicActionsState$, - viewMode: viewMode$, - setViewMode: (value: ViewMode) => viewMode$.next(value), - } as PanelNotificationsActionApi & PublishesWritableViewMode, - } as EmbeddableApiContext; -}; - -describe('PanelNotificationsAction', () => { - describe('getDisplayName', () => { - test('returns "0" if embeddable has no events', async () => { - const context = createContext(); - const action = new PanelNotificationsAction(); - - const name = action.getDisplayName(context); - expect(name).toBe('0'); - }); - - test('returns "2" if embeddable has two events', async () => { - const context = createContext([{}, {}] as SerializedEvent[]); - const action = new PanelNotificationsAction(); - - const name = action.getDisplayName(context); - expect(name).toBe('2'); - }); - - test('updates display name when dynamic actions is updated', async () => { - const context = createContext([{}, {}] as SerializedEvent[]); - const action = new PanelNotificationsAction(); - - (context.embeddable as PanelNotificationsActionApi).setDynamicActions({ - dynamicActions: { events: [{}, {}, {}] as SerializedEvent[] }, - }); - - const name = action.getDisplayName(context); - expect(name).toBe('3'); - }); - }); - - describe('getDisplayNameTooltip', () => { - test('returns empty string if embeddable has no event', async () => { - const context = createContext(); - const action = new PanelNotificationsAction(); - - const name = action.getDisplayNameTooltip(context); - expect(name).toBe(''); - }); - - test('returns "1 drilldown" if embeddable has one event', async () => { - const context = createContext([{} as SerializedEvent]); - const action = new PanelNotificationsAction(); - - const name = action.getDisplayNameTooltip(context); - expect(name).toBe('Panel has 1 drilldown'); - }); - - test('returns "2 drilldowns" if embeddable has two events', async () => { - const context = createContext([{}, {}] as SerializedEvent[]); - const action = new PanelNotificationsAction(); - - const name = action.getDisplayNameTooltip(context); - expect(name).toBe('Panel has 2 drilldowns'); - }); - - test('returns "3 drilldowns" if embeddable has three events', async () => { - const context = createContext([{}, {}, {}] as SerializedEvent[]); - const action = new PanelNotificationsAction(); - - const name = action.getDisplayNameTooltip(context); - expect(name).toBe('Panel has 3 drilldowns'); - }); - - test('updates tooltip when dynamic actions is updated', async () => { - const context = createContext([{}, {}, {}] as SerializedEvent[]); - const action = new PanelNotificationsAction(); - - (context.embeddable as PanelNotificationsActionApi).setDynamicActions({ - dynamicActions: { events: [{}, {}] as SerializedEvent[] }, - }); - - const name = action.getDisplayNameTooltip(context); - expect(name).toBe('Panel has 2 drilldowns'); - }); - }); - - describe('isCompatible', () => { - test('returns false if not in "edit" mode', async () => { - const context = createContext([{} as SerializedEvent]); - const action = new PanelNotificationsAction(); - - const result = await action.isCompatible(context); - expect(result).toBe(false); - }); - - test('returns true when switching to "edit" mode', async () => { - const context = createContext([{} as SerializedEvent]); - - const action = new PanelNotificationsAction(); - (context.embeddable as PublishesWritableViewMode).setViewMode(ViewMode.EDIT); - const result = await action.isCompatible(context); - expect(result).toBe(true); - }); - - test('returns false when in edit mode but embeddable has no events', async () => { - const context = createContext([]); - (context.embeddable as PublishesWritableViewMode).setViewMode(ViewMode.EDIT); - - const action = new PanelNotificationsAction(); - - const result = await action.isCompatible(context); - expect(result).toBe(false); - }); - }); -}); diff --git a/x-pack/plugins/embeddable_enhanced/public/actions/panel_notifications_action.ts b/x-pack/plugins/embeddable_enhanced/public/actions/panel_notifications_action.ts deleted file mode 100644 index d245624117fbf..0000000000000 --- a/x-pack/plugins/embeddable_enhanced/public/actions/panel_notifications_action.ts +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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 { ViewMode } from '@kbn/embeddable-plugin/public'; -import { i18n } from '@kbn/i18n'; -import { - apiCanAccessViewMode, - CanAccessViewMode, - EmbeddableApiContext, - getInheritedViewMode, - getViewModeSubject, -} from '@kbn/presentation-publishing'; -import { UiActionsActionDefinition as ActionDefinition } from '@kbn/ui-actions-plugin/public'; - -import { BehaviorSubject, merge } from 'rxjs'; -import { - apiHasDynamicActions, - HasDynamicActions, -} from '../embeddables/interfaces/has_dynamic_actions'; - -export const txtOneDrilldown = i18n.translate( - 'xpack.embeddableEnhanced.actions.panelNotifications.oneDrilldown', - { - defaultMessage: 'Panel has 1 drilldown', - } -); - -export const txtManyDrilldowns = (count: number) => - i18n.translate('xpack.embeddableEnhanced.actions.panelNotifications.manyDrilldowns', { - defaultMessage: 'Panel has {count} drilldowns', - values: { - count: String(count), - }, - }); - -export const ACTION_PANEL_NOTIFICATIONS = 'ACTION_PANEL_NOTIFICATIONS'; - -export type PanelNotificationsActionApi = CanAccessViewMode & Required; - -const isApiCompatible = (api: unknown | null): api is PanelNotificationsActionApi => - apiHasDynamicActions(api) && apiCanAccessViewMode(api); - -/** - * This action renders in "edit" mode number of events (dynamic action) a panel - * has attached to it. - */ -export class PanelNotificationsAction implements ActionDefinition { - public readonly id = ACTION_PANEL_NOTIFICATIONS; - public type = ACTION_PANEL_NOTIFICATIONS; - - private getEventCount({ embeddable }: EmbeddableApiContext): number { - return isApiCompatible(embeddable) - ? (embeddable.dynamicActionsState$.getValue()?.dynamicActions.events ?? []).length - : 0; - } - - public getIconType = () => ''; - - public readonly getDisplayName = ({ embeddable }: EmbeddableApiContext) => { - return String(this.getEventCount({ embeddable })); - }; - - public couldBecomeCompatible({ embeddable }: EmbeddableApiContext) { - return isApiCompatible(embeddable); - } - - public subscribeToCompatibilityChanges = ( - { embeddable }: EmbeddableApiContext, - onChange: (isCompatible: boolean, action: PanelNotificationsAction) => void - ) => { - if (!isApiCompatible(embeddable)) return; - const viewModeSubject = getViewModeSubject(embeddable) ?? new BehaviorSubject(ViewMode.VIEW); - return merge(embeddable.dynamicActionsState$, viewModeSubject).subscribe(() => { - onChange( - getInheritedViewMode(embeddable) === ViewMode.EDIT && - this.getEventCount({ embeddable }) > 0, - this - ); - }); - }; - - public readonly getDisplayNameTooltip = ({ embeddable }: EmbeddableApiContext) => { - const count = this.getEventCount({ embeddable }); - return !count ? '' : count === 1 ? txtOneDrilldown : txtManyDrilldowns(count); - }; - - public readonly isCompatible = async ({ embeddable }: EmbeddableApiContext) => { - return ( - isApiCompatible(embeddable) && - getInheritedViewMode(embeddable) === ViewMode.EDIT && - this.getEventCount({ embeddable }) > 0 - ); - }; - - public readonly execute = async () => {}; -} diff --git a/x-pack/plugins/embeddable_enhanced/public/plugin.ts b/x-pack/plugins/embeddable_enhanced/public/plugin.ts index e4faf031c3627..f05982af78947 100644 --- a/x-pack/plugins/embeddable_enhanced/public/plugin.ts +++ b/x-pack/plugins/embeddable_enhanced/public/plugin.ts @@ -16,7 +16,6 @@ import { EmbeddableSetup, EmbeddableStart, IEmbeddable, - PANEL_NOTIFICATION_TRIGGER, } from '@kbn/embeddable-plugin/public'; import { apiHasUniqueId, @@ -32,7 +31,6 @@ import { } from '@kbn/ui-actions-enhanced-plugin/public'; import deepEqual from 'react-fast-compare'; import { BehaviorSubject, distinctUntilChanged } from 'rxjs'; -import { PanelNotificationsAction } from './actions'; import { DynamicActionStorage, type DynamicActionStorageApi, @@ -82,9 +80,6 @@ export class EmbeddableEnhancedPlugin public setup(core: CoreSetup, plugins: SetupDependencies): SetupContract { this.setCustomEmbeddableFactoryProvider(plugins); - const panelNotificationAction = new PanelNotificationsAction(); - plugins.uiActionsEnhanced.registerAction(panelNotificationAction); - plugins.uiActionsEnhanced.attachAction(PANEL_NOTIFICATION_TRIGGER, panelNotificationAction.id); return {}; } diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 9fce783335221..60d6ea93354e3 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -15285,8 +15285,6 @@ "xpack.elasticAssistant.prompts.getPromptsError": "Erreur lors de la récupération des invites", "xpack.elasticAssistant.securityAssistant.content.prompts.welcome.enterprisePrompt": "L'assistant d'IA d'Elastic n'est accessible qu'aux entreprises. Veuillez mettre votre licence à niveau pour bénéficier de cette fonctionnalité.", "xpack.elasticAssistantPlugin.server.newChat": "Nouveau chat", - "xpack.embeddableEnhanced.actions.panelNotifications.manyDrilldowns": "Le panneau comporte {count} recherches", - "xpack.embeddableEnhanced.actions.panelNotifications.oneDrilldown": "Le panneau comporte 1 recherche", "xpack.embeddableEnhanced.Drilldowns": "Explorations", "xpack.enterpriseSearch.actions.backButtonLabel": "Retour", "xpack.enterpriseSearch.actions.cancelButtonLabel": "Annuler", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index e503ab2aa9ad5..c3aabb1bf5a13 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -15272,8 +15272,6 @@ "xpack.elasticAssistant.prompts.getPromptsError": "プロンプト取得エラー", "xpack.elasticAssistant.securityAssistant.content.prompts.welcome.enterprisePrompt": "Elastic AI Assistantはエンタープライズユーザーのみご利用いただけます。この機能を使用するには、ライセンスをアップグレードしてください。", "xpack.elasticAssistantPlugin.server.newChat": "新しいチャット", - "xpack.embeddableEnhanced.actions.panelNotifications.manyDrilldowns": "パネルには{count}個のドリルダウンがあります", - "xpack.embeddableEnhanced.actions.panelNotifications.oneDrilldown": "パネルには 1 個のドリルダウンがあります", "xpack.embeddableEnhanced.Drilldowns": "ドリルダウン", "xpack.enterpriseSearch.actions.backButtonLabel": "戻る", "xpack.enterpriseSearch.actions.cancelButtonLabel": "キャンセル", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 87a4e19d9ab4e..b92d8f9697b80 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -15297,8 +15297,6 @@ "xpack.elasticAssistant.prompts.getPromptsError": "提取提示时出错", "xpack.elasticAssistant.securityAssistant.content.prompts.welcome.enterprisePrompt": "Elastic AI 助手仅对企业用户可用。请升级许可证以使用此功能。", "xpack.elasticAssistantPlugin.server.newChat": "新聊天", - "xpack.embeddableEnhanced.actions.panelNotifications.manyDrilldowns": "面板有 {count} 个向下钻取", - "xpack.embeddableEnhanced.actions.panelNotifications.oneDrilldown": "面板有 1 个向下钻取", "xpack.embeddableEnhanced.Drilldowns": "向下钻取", "xpack.enterpriseSearch.actions.backButtonLabel": "返回", "xpack.enterpriseSearch.actions.cancelButtonLabel": "取消", diff --git a/x-pack/test/accessibility/apps/group1/dashboard_controls.ts b/x-pack/test/accessibility/apps/group1/dashboard_controls.ts index dd45b68674343..44f76de3eb5c2 100644 --- a/x-pack/test/accessibility/apps/group1/dashboard_controls.ts +++ b/x-pack/test/accessibility/apps/group1/dashboard_controls.ts @@ -12,26 +12,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'dashboard', 'home', 'dashboardControls']); + const { common, dashboard, home, dashboardControls } = getPageObjects([ + 'common', + 'dashboard', + 'home', + 'dashboardControls', + ]); const browser = getService('browser'); describe('Dashboard controls a11y tests', () => { before(async () => { await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.home.addSampleDataSet('flights'); - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('[Flights] Global Flight Dashboard'); - await PageObjects.dashboard.switchToEditMode(); + await home.addSampleDataSet('flights'); + await common.navigateToApp('dashboard'); + await dashboard.loadSavedDashboard('[Flights] Global Flight Dashboard'); + await dashboard.switchToEditMode(); }); after(async () => { - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.home.removeSampleDataSet('flights'); + await home.removeSampleDataSet('flights'); }); it('Controls main menu panel', async () => { @@ -57,7 +62,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Options control panel & dashboard with options control', async () => { - await PageObjects.dashboardControls.controlsEditorSetfield('OriginCityName'); + await dashboardControls.controlsEditorSetfield('OriginCityName'); await a11y.testAppSnapshot(); await testSubjects.click('control-editor-save'); await a11y.testAppSnapshot(); @@ -83,12 +88,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('Dashboard with options and range control panel popovers', async () => { await testSubjects.click('dashboardQuickSaveMenuItem'); await a11y.testAppSnapshot(); - const optionsControlId = (await PageObjects.dashboardControls.getAllControlIds())[0]; - await PageObjects.dashboardControls.optionsListOpenPopover(optionsControlId); + const optionsControlId = (await dashboardControls.getAllControlIds())[0]; + await dashboardControls.optionsListOpenPopover(optionsControlId); await a11y.testAppSnapshot(); // a11y error on range control https://github.com/elastic/kibana/issues/135266 - uncomment after the fix - // const rangeControlId = (await PageObjects.dashboardControls.getAllControlIds())[1]; - // await PageObjects.dashboardControls.rangeSliderOpenPopover(rangeControlId); + // const rangeControlId = (await dashboardControls.getAllControlIds())[1]; + // await dashboardControls.rangeSliderOpenPopover(rangeControlId); // await a11y.testAppSnapshot(); }); }); diff --git a/x-pack/test/accessibility/apps/group1/dashboard_panel_options.ts b/x-pack/test/accessibility/apps/group1/dashboard_panel_options.ts index 991be3b49bb40..92c558f17dadc 100644 --- a/x-pack/test/accessibility/apps/group1/dashboard_panel_options.ts +++ b/x-pack/test/accessibility/apps/group1/dashboard_panel_options.ts @@ -150,7 +150,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('dashboard panel - save to library', async () => { await dashboardPanelActions.openContextMenuMorePanel(header); - await testSubjects.click('embeddablePanelAction-legacySaveToLibrary'); + await testSubjects.click('embeddablePanelAction-saveToLibrary'); await a11y.testAppSnapshot(); await testSubjects.click('saveCancelButton'); }); diff --git a/x-pack/test/accessibility/apps/group2/lens.ts b/x-pack/test/accessibility/apps/group2/lens.ts index a64ff207bc3f5..75e553227dbad 100644 --- a/x-pack/test/accessibility/apps/group2/lens.ts +++ b/x-pack/test/accessibility/apps/group2/lens.ts @@ -9,7 +9,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'visualize', 'timePicker', 'home', 'lens']); + const { common, visualize, timePicker, lens } = getPageObjects([ + 'common', + 'visualize', + 'timePicker', + 'lens', + ]); const a11y = getService('a11y'); const testSubjects = getService('testSubjects'); const esArchiver = getService('esArchiver'); @@ -40,25 +45,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('lens', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.timePicker.ensureHiddenNoDataPopover(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await timePicker.ensureHiddenNoDataPopover(); await a11y.testAppSnapshot(); }); it('lens XY chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.timePicker.ensureHiddenNoDataPopover(); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await timePicker.ensureHiddenNoDataPopover(); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', @@ -68,74 +73,74 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('lens pie chart', async () => { - await PageObjects.lens.switchToVisualization('pie'); + await lens.switchToVisualization('pie'); await a11y.testAppSnapshot(); }); it('lens datatable', async () => { - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await lens.switchToVisualization('lnsDatatable'); await a11y.testAppSnapshot(); }); it('lens datatable with dynamic cell colouring', async () => { - await PageObjects.lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger'); - await PageObjects.lens.setTableDynamicColoring('cell'); + await lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger'); + await lens.setTableDynamicColoring('cell'); await a11y.testAppSnapshot(); }); it('lens datatable with dynamic text colouring', async () => { - await PageObjects.lens.setTableDynamicColoring('text'); + await lens.setTableDynamicColoring('text'); await a11y.testAppSnapshot(); }); it('lens datatable with palette panel open', async () => { - await PageObjects.lens.openPalettePanel(); + await lens.openPalettePanel(); await a11y.testAppSnapshot(); }); it('lens datatable with custom palette stops', async () => { - await PageObjects.lens.changePaletteTo('custom'); + await lens.changePaletteTo('custom'); await a11y.testAppSnapshot(); - await PageObjects.lens.closePaletteEditor(); - await PageObjects.lens.closeDimensionEditor(); + await lens.closePaletteEditor(); + await lens.closeDimensionEditor(); }); it('lens metric chart', async () => { - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); + await lens.switchToVisualization('lnsLegacyMetric'); await a11y.testAppSnapshot(); }); it('dimension configuration panel', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.timePicker.ensureHiddenNoDataPopover(); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await timePicker.ensureHiddenNoDataPopover(); + await lens.goToTimeRange(); - await PageObjects.lens.openDimensionEditor('lnsXY_xDimensionPanel > lns-empty-dimension'); + await lens.openDimensionEditor('lnsXY_xDimensionPanel > lns-empty-dimension'); await a11y.testAppSnapshot(); - await PageObjects.lens.closeDimensionEditor(); - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-empty-dimension'); + await lens.closeDimensionEditor(); + await lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-empty-dimension'); await a11y.testAppSnapshot(); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('change chart type', async () => { - await PageObjects.lens.openChartSwitchPopover(); - await PageObjects.lens.waitForSearchInputValue('line'); + await lens.openChartSwitchPopover(); + await lens.waitForSearchInputValue('line'); await a11y.testAppSnapshot(); await testSubjects.click('lnsChartSwitchPopover_line'); }); it('change chart type via suggestions', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', @@ -146,16 +151,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('lens XY chart with multiple layers', async () => { - await PageObjects.lens.createLayer(); + await lens.createLayer(); - await PageObjects.lens.switchToVisualization('area'); - await PageObjects.lens.configureDimension({ + await lens.switchToVisualization('area'); + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'median', field: 'bytes', @@ -164,42 +169,42 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('lens XY chart with reference line layer', async () => { - await PageObjects.lens.createLayer('referenceLine'); + await lens.createLayer('referenceLine'); await a11y.testAppSnapshot(); }); it('lens XY chart with annotations layer', async () => { - await PageObjects.lens.createLayer('annotations'); + await lens.createLayer('annotations'); await a11y.testAppSnapshot(); }); it('saves lens chart', async () => { - await PageObjects.lens.save(lensChartName); + await lens.save(lensChartName); await a11y.testAppSnapshot(); // delete newly created Lens - await PageObjects.common.navigateToApp('visualize'); + await common.navigateToApp('visualize'); await listingTable.searchForItemWithName(lensChartName); await listingTable.checkListingSelectAllCheckbox(); await listingTable.clickDeleteSelected(); - await PageObjects.common.clickConfirmOnModal(); + await common.clickConfirmOnModal(); }); describe('focus behavior when adding or removing layers', () => { it('should focus the added layer', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.createLayer(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.createLayer(); expect(await hasFocus('lns-layerPanel-1')).to.be(true); }); it('should focus the remaining layer when the first is removed', async () => { - await PageObjects.lens.removeLayer(0); + await lens.removeLayer(0); expect(await hasFocus('lns-layerPanel-0')).to.be(true); - await PageObjects.lens.createLayer(); - await PageObjects.lens.removeLayer(1); + await lens.createLayer(); + await lens.removeLayer(1); expect(await hasFocus('lns-layerPanel-0')).to.be(true); }); it('should focus the only layer when resetting the layer', async () => { - await PageObjects.lens.removeLayer(); + await lens.removeLayer(); expect(await hasFocus('lns-layerPanel-0')).to.be(true); }); }); diff --git a/x-pack/test/accessibility/apps/group3/graph.ts b/x-pack/test/accessibility/apps/group3/graph.ts index 839ea50ce2779..b79c561837f6b 100644 --- a/x-pack/test/accessibility/apps/group3/graph.ts +++ b/x-pack/test/accessibility/apps/group3/graph.ts @@ -12,24 +12,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); const browser = getService('browser'); - const PageObjects = getPageObjects(['settings', 'common', 'graph', 'header', 'home']); + const { common, header, home } = getPageObjects(['common', 'header', 'home']); describe('Graph app a11y tests', () => { before(async () => { - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.addSampleDataSet('flights'); - await PageObjects.common.navigateToApp('graph'); + await header.waitUntilLoadingHasFinished(); + await home.addSampleDataSet('flights'); + await common.navigateToApp('graph'); }); after(async () => { - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.removeSampleDataSet('flights'); + await header.waitUntilLoadingHasFinished(); + await home.removeSampleDataSet('flights'); }); it('Graph listing page', async function () { diff --git a/x-pack/test/accessibility/apps/group3/maps.ts b/x-pack/test/accessibility/apps/group3/maps.ts index 2f69696b5824f..bb68aeb0d8f06 100644 --- a/x-pack/test/accessibility/apps/group3/maps.ts +++ b/x-pack/test/accessibility/apps/group3/maps.ts @@ -12,28 +12,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); const inspector = getService('inspector'); - const PageObjects = getPageObjects(['common', 'settings', 'header', 'home', 'maps']); + const { common, header, home, maps } = getPageObjects(['common', 'header', 'home', 'maps']); describe('Maps app Accessibility', () => { before(async () => { - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.addSampleDataSet('flights'); - await PageObjects.common.navigateToApp('maps'); + await header.waitUntilLoadingHasFinished(); + await home.addSampleDataSet('flights'); + await common.navigateToApp('maps'); }); after(async () => { - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.removeSampleDataSet('flights'); + await header.waitUntilLoadingHasFinished(); + await home.removeSampleDataSet('flights'); }); it('loads maps workpads', async function () { - await PageObjects.maps.loadSavedMap('[Flights] Origin Time Delayed'); + await maps.loadSavedMap('[Flights] Origin Time Delayed'); await a11y.testAppSnapshot(); }); @@ -68,7 +68,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('map inspector panel - view maps', async function () { - await PageObjects.maps.openInspectorMapView(); + await maps.openInspectorMapView(); await a11y.testAppSnapshot(); }); @@ -78,26 +78,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('full screen button should exist', async () => { - await PageObjects.maps.existFullScreen(); + await maps.existFullScreen(); await a11y.testAppSnapshot(); }); it('displays exit full screen logo button', async () => { - await PageObjects.maps.enterFullScreen(); + await maps.enterFullScreen(); await a11y.testAppSnapshot(); }); it(`allows a map to be created`, async () => { - await PageObjects.maps.openNewMap(); + await maps.openNewMap(); await a11y.testAppSnapshot(); - await PageObjects.maps.expectExistAddLayerButton(); + await maps.expectExistAddLayerButton(); await a11y.testAppSnapshot(); - await PageObjects.maps.saveMap('my test map'); + await maps.saveMap('my test map'); await a11y.testAppSnapshot(); }); it('maps listing page', async function () { - await PageObjects.common.navigateToApp('maps'); + await common.navigateToApp('maps'); await retry.waitFor( 'maps workpads visible', async () => await testSubjects.exists('itemsInMemTable') diff --git a/x-pack/test/accessibility/apps/group3/search_sessions.ts b/x-pack/test/accessibility/apps/group3/search_sessions.ts index c400d17263221..eed2d74a70967 100644 --- a/x-pack/test/accessibility/apps/group3/search_sessions.ts +++ b/x-pack/test/accessibility/apps/group3/search_sessions.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['searchSessionsManagement']); + const { searchSessionsManagement } = getPageObjects(['searchSessionsManagement']); const a11y = getService('a11y'); const testSubjects = getService('testSubjects'); const retry = getService('retry'); @@ -18,7 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Search sessions Accessibility', () => { before(async () => { await esArchiver.load('x-pack/test/functional/es_archives/data/search_sessions'); - await PageObjects.searchSessionsManagement.goTo(); + await searchSessionsManagement.goTo(); }); after(async () => { diff --git a/x-pack/test/functional/apps/canvas/custom_elements.ts b/x-pack/test/functional/apps/canvas/custom_elements.ts index f71cc76d5bcb2..cfeace496eafe 100644 --- a/x-pack/test/functional/apps/canvas/custom_elements.ts +++ b/x-pack/test/functional/apps/canvas/custom_elements.ts @@ -16,7 +16,7 @@ export default function canvasCustomElementTest({ const testSubjects = getService('testSubjects'); const browser = getService('browser'); const retry = getService('retry'); - const PageObjects = getPageObjects(['canvas']); + const { canvas } = getPageObjects(['canvas']); const find = getService('find'); const kibanaServer = getService('kibanaServer'); const archive = 'x-pack/test/functional/fixtures/kbn_archiver/canvas/default'; @@ -27,8 +27,8 @@ export default function canvasCustomElementTest({ before(async () => { await kibanaServer.importExport.load(archive); // load test workpad - await PageObjects.canvas.goToListingPage(); - await PageObjects.canvas.loadFirstWorkpad('Test Workpad'); + await canvas.goToListingPage(); + await canvas.loadFirstWorkpad('Test Workpad'); }); after(async () => { @@ -46,10 +46,7 @@ export default function canvasCustomElementTest({ await testSubjects.click('canvasWorkpadEditMenu__saveElementButton', 20000); // fill out the custom element form and submit it - await PageObjects.canvas.fillOutCustomElementForm( - 'My New Element', - 'An excellent new element' - ); + await canvas.fillOutCustomElementForm('My New Element', 'An excellent new element'); // wait for the custom element success toast notif await testSubjects.exists('canvasCustomElementCreate-success', { @@ -59,7 +56,7 @@ export default function canvasCustomElementTest({ it('adds the custom element to the workpad when prompted', async () => { // open the saved elements modal - await PageObjects.canvas.openSavedElementsModal(); + await canvas.openSavedElementsModal(); // ensure the custom element is the one expected and click it to add to the workpad const customElement = await find.byCssSelector('.canvasElementCard__wrapper'); @@ -94,7 +91,7 @@ export default function canvasCustomElementTest({ it('saves custom element modifications', async () => { // open the saved elements modal - await PageObjects.canvas.openSavedElementsModal(); + await canvas.openSavedElementsModal(); // ensure the correct amount of custom elements exist const customElements = await find.allByCssSelector('.canvasElementCard__wrapper'); @@ -108,10 +105,7 @@ export default function canvasCustomElementTest({ await testSubjects.click('canvasElementCard__editButton', 20000); // fill out the custom element form and submit it - await PageObjects.canvas.fillOutCustomElementForm( - 'My Edited New Element', - 'An excellent edited element' - ); + await canvas.fillOutCustomElementForm('My Edited New Element', 'An excellent edited element'); // ensure the custom element in the modal shows the updated text await retry.try(async () => { @@ -121,12 +115,12 @@ export default function canvasCustomElementTest({ }); // Close the modal - await PageObjects.canvas.closeSavedElementsModal(); + await canvas.closeSavedElementsModal(); }); it('deletes custom element when prompted', async () => { // open the saved elements modal - await PageObjects.canvas.openSavedElementsModal(); + await canvas.openSavedElementsModal(); // ensure the correct amount of custom elements exist const customElements = await find.allByCssSelector('.canvasElementCard__wrapper'); @@ -148,7 +142,7 @@ export default function canvasCustomElementTest({ }); // Close the modal - await PageObjects.canvas.closeSavedElementsModal(); + await canvas.closeSavedElementsModal(); }); }); } diff --git a/x-pack/test/functional/apps/canvas/datasource.ts b/x-pack/test/functional/apps/canvas/datasource.ts index 5afda1a579cd0..480510ede4e78 100644 --- a/x-pack/test/functional/apps/canvas/datasource.ts +++ b/x-pack/test/functional/apps/canvas/datasource.ts @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function canvasExpressionTest({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['canvas']); + const { canvas } = getPageObjects(['canvas']); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const monacoEditor = getService('monacoEditor'); @@ -35,8 +35,8 @@ export default function canvasExpressionTest({ getService, getPageObjects }: Ftr }); // create new test workpad - await PageObjects.canvas.goToListingPage(); - await PageObjects.canvas.createNewWorkpad(); + await canvas.goToListingPage(); + await canvas.createNewWorkpad(); }); after(async () => { @@ -50,16 +50,16 @@ export default function canvasExpressionTest({ getService, getPageObjects }: Ftr describe('esdocs', function () { it('sidebar shows to esdocs datasource settings', async () => { - await PageObjects.canvas.createNewDatatableElement(); + await canvas.createNewDatatableElement(); // find the first workpad element (a markdown element) and click it to select it await testSubjects.click('canvasWorkpadPage > canvasWorkpadPageElementContent', 20000); // open Data tab - await PageObjects.canvas.openDatasourceTab(); + await canvas.openDatasourceTab(); // change datasource to esdocs - await PageObjects.canvas.changeDatasourceTo('esdocs'); + await canvas.changeDatasourceTo('esdocs'); // click data view select await testSubjects.click('canvasDataViewSelect'); @@ -74,9 +74,9 @@ export default function canvasExpressionTest({ getService, getPageObjects }: Ftr it('updates expression to use esdocs', async () => { await testSubjects.click('canvasDataViewSelect__logstash-*'); - await PageObjects.canvas.saveDatasourceChanges(); + await canvas.saveDatasourceChanges(); - await PageObjects.canvas.openExpressionEditor(); + await canvas.openExpressionEditor(); await monacoEditor.waitCodeEditorReady('canvasExpressionInput'); expect(await monacoEditor.getCodeEditorValue()).contain('esdocs index="logstash-*"'); }); diff --git a/x-pack/test/functional/apps/canvas/embeddables/lens.ts b/x-pack/test/functional/apps/canvas/embeddables/lens.ts index 629ab9edc1674..2bd2ec820b6f3 100644 --- a/x-pack/test/functional/apps/canvas/embeddables/lens.ts +++ b/x-pack/test/functional/apps/canvas/embeddables/lens.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function canvasLensTest({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['canvas', 'header', 'lens']); + const { canvas, header, lens } = getPageObjects(['canvas', 'header', 'lens']); const esArchiver = getService('esArchiver'); const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardPanelActions = getService('dashboardPanelActions'); @@ -25,8 +25,8 @@ export default function canvasLensTest({ getService, getPageObjects }: FtrProvid await kibanaServer.savedObjects.cleanStandardList(); await kibanaServer.importExport.load(archives.kbn); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-lens' }); - await PageObjects.canvas.goToListingPage(); - await PageObjects.canvas.createNewWorkpad(); + await canvas.goToListingPage(); + await canvas.createNewWorkpad(); }); after(async () => { @@ -36,63 +36,63 @@ export default function canvasLensTest({ getService, getPageObjects }: FtrProvid describe('by-reference', () => { it('adds existing lens embeddable from the visualize library', async () => { - await PageObjects.canvas.clickAddFromLibrary(); + await canvas.clickAddFromLibrary(); await dashboardAddPanel.addEmbeddable('Artistpreviouslyknownaslens', 'lens'); await testSubjects.existOrFail('embeddablePanelHeading-Artistpreviouslyknownaslens'); }); it('edits lens by-reference embeddable', async () => { await dashboardPanelActions.editPanelByTitle('Artistpreviouslyknownaslens'); - await PageObjects.lens.save('Artistpreviouslyknownaslens v2', false, true); + await lens.save('Artistpreviouslyknownaslens v2', false, true); await testSubjects.existOrFail('embeddablePanelHeading-Artistpreviouslyknownaslensv2'); }); it('renders lens visualization using savedLens expression', async () => { // load test workpad - await PageObjects.canvas.goToListingPage(); - await PageObjects.canvas.loadFirstWorkpad('Test Workpad'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await canvas.goToListingPage(); + await canvas.loadFirstWorkpad('Test Workpad'); + await header.waitUntilLoadingHasFinished(); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '16,788'); + await lens.assertLegacyMetric('Maximum of bytes', '16,788'); }); }); describe('by-value', () => { it('creates new lens embeddable', async () => { - await PageObjects.canvas.addNewPage(); - await PageObjects.canvas.createNewVis('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await canvas.addNewPage(); + await canvas.createNewVis('lens'); + await lens.goToTimeRange(); + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.saveAndReturn(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await lens.saveAndReturn(); + await header.waitUntilLoadingHasFinished(); await testSubjects.exists('xyVisChart'); }); it('edits lens by-value embeddable', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const panelHeader = await testSubjects.find('embeddablePanelHeading-'); await dashboardPanelActions.openContextMenu(panelHeader); await dashboardPanelActions.clickEdit(); - await PageObjects.lens.saveAndReturn(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await lens.saveAndReturn(); + await header.waitUntilLoadingHasFinished(); await testSubjects.exists('xyVisChart'); }); }); describe('switch page smoke test', () => { it('loads embeddables on page change', async () => { - await PageObjects.canvas.goToPreviousPage(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '16,788'); + await canvas.goToPreviousPage(); + await header.waitUntilLoadingHasFinished(); + await lens.assertLegacyMetric('Maximum of bytes', '16,788'); }); }); }); diff --git a/x-pack/test/functional/apps/canvas/embeddables/maps.ts b/x-pack/test/functional/apps/canvas/embeddables/maps.ts index 6cf23726846f1..2a63c4f64b57a 100644 --- a/x-pack/test/functional/apps/canvas/embeddables/maps.ts +++ b/x-pack/test/functional/apps/canvas/embeddables/maps.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['canvas', 'header', 'maps']); + const { canvas, maps } = getPageObjects(['canvas', 'maps']); const dashboardPanelActions = getService('dashboardPanelActions'); const dashboardAddPanel = getService('dashboardAddPanel'); const testSubjects = getService('testSubjects'); @@ -19,44 +19,44 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await kibanaServer.savedObjects.cleanStandardList(); // open canvas home - await PageObjects.canvas.goToListingPage(); + await canvas.goToListingPage(); // create new workpad - await PageObjects.canvas.createNewWorkpad(); - await PageObjects.canvas.setWorkpadName('maps tests'); + await canvas.createNewWorkpad(); + await canvas.setWorkpadName('maps tests'); }); describe('by-value', () => { it('creates new map embeddable', async () => { - const originalEmbeddableCount = await PageObjects.canvas.getEmbeddableCount(); - await PageObjects.canvas.createNewVis('maps'); - await PageObjects.maps.clickSaveAndReturnButton(); - const embeddableCount = await PageObjects.canvas.getEmbeddableCount(); + const originalEmbeddableCount = await canvas.getEmbeddableCount(); + await canvas.createNewVis('maps'); + await maps.clickSaveAndReturnButton(); + const embeddableCount = await canvas.getEmbeddableCount(); expect(embeddableCount).to.eql(originalEmbeddableCount + 1); }); it('edits map by-value embeddable', async () => { - const originalEmbeddableCount = await PageObjects.canvas.getEmbeddableCount(); + const originalEmbeddableCount = await canvas.getEmbeddableCount(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.maps.saveMap('canvas test map'); - const embeddableCount = await PageObjects.canvas.getEmbeddableCount(); + await maps.saveMap('canvas test map'); + const embeddableCount = await canvas.getEmbeddableCount(); expect(embeddableCount).to.eql(originalEmbeddableCount); }); }); describe('by-reference', () => { it('adds existing map embeddable from the visualize library', async () => { - await PageObjects.canvas.deleteSelectedElement(); - await PageObjects.canvas.clickAddFromLibrary(); + await canvas.deleteSelectedElement(); + await canvas.clickAddFromLibrary(); await dashboardAddPanel.addEmbeddable('canvas test map', 'map'); await testSubjects.existOrFail('embeddablePanelHeading-canvastestmap'); }); it('edits map by-reference embeddable', async () => { await dashboardPanelActions.editPanelByTitle('canvas test map'); - await PageObjects.maps.saveMap('canvas test map v2', true, false); + await maps.saveMap('canvas test map v2', true, false); await testSubjects.existOrFail('embeddablePanelHeading-canvastestmapv2'); - await PageObjects.canvas.deleteSelectedElement(); + await canvas.deleteSelectedElement(); }); }); }); diff --git a/x-pack/test/functional/apps/canvas/embeddables/saved_search.ts b/x-pack/test/functional/apps/canvas/embeddables/saved_search.ts index 59285140672c6..f89af8b6a15c1 100644 --- a/x-pack/test/functional/apps/canvas/embeddables/saved_search.ts +++ b/x-pack/test/functional/apps/canvas/embeddables/saved_search.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['canvas', 'header', 'discover']); + const { canvas, discover } = getPageObjects(['canvas', 'discover']); const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); const dashboardAddPanel = getService('dashboardAddPanel'); @@ -21,10 +21,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'test/functional/fixtures/kbn_archiver/dashboard/current/kibana' ); // open canvas home - await PageObjects.canvas.goToListingPage(); + await canvas.goToListingPage(); // create new workpad - await PageObjects.canvas.createNewWorkpad(); - await PageObjects.canvas.setWorkpadName('saved search tests'); + await canvas.createNewWorkpad(); + await canvas.setWorkpadName('saved search tests'); }); after(async () => { @@ -33,16 +33,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('by-reference', () => { it('adds existing saved search embeddable from the visualize library', async () => { - await PageObjects.canvas.clickAddFromLibrary(); + await canvas.clickAddFromLibrary(); await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); await testSubjects.existOrFail('embeddablePanelHeading-RenderingTest:savedsearch'); }); it('edits saved search by-reference embeddable', async () => { await dashboardPanelActions.editPanelByTitle('Rendering Test: saved search'); - await PageObjects.discover.saveSearch('Rendering Test: saved search v2'); - await PageObjects.canvas.goToListingPage(); - await PageObjects.canvas.loadFirstWorkpad('saved search tests'); + await discover.saveSearch('Rendering Test: saved search v2'); + await canvas.goToListingPage(); + await canvas.loadFirstWorkpad('saved search tests'); await testSubjects.existOrFail('embeddablePanelHeading-RenderingTest:savedsearchv2'); }); }); diff --git a/x-pack/test/functional/apps/canvas/embeddables/visualization.ts b/x-pack/test/functional/apps/canvas/embeddables/visualization.ts index 40328cbf3890d..9cb0d55371f72 100644 --- a/x-pack/test/functional/apps/canvas/embeddables/visualization.ts +++ b/x-pack/test/functional/apps/canvas/embeddables/visualization.ts @@ -10,7 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); - const PageObjects = getPageObjects(['canvas', 'header', 'visualize']); + const { canvas, visualize } = getPageObjects(['canvas', 'visualize']); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); const dashboardAddPanel = getService('dashboardAddPanel'); @@ -30,10 +30,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); // open canvas home - await PageObjects.canvas.goToListingPage(); + await canvas.goToListingPage(); // create new workpad - await PageObjects.canvas.createNewWorkpad(); - await PageObjects.canvas.setWorkpadName('visualization tests'); + await canvas.createNewWorkpad(); + await canvas.setWorkpadName('visualization tests'); }); after(async () => { @@ -42,62 +42,62 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('by-reference', () => { it('adds existing visualize embeddable from the visualize library', async () => { - await PageObjects.canvas.clickAddFromLibrary(); + await canvas.clickAddFromLibrary(); await dashboardAddPanel.addVisualization('Rendering-Test: metric'); await testSubjects.existOrFail('embeddablePanelHeading-RenderingTest:metric'); }); it('edits visualize by-reference embeddable', async () => { await dashboardPanelActions.editPanelByTitle('Rendering Test: metric'); - await PageObjects.visualize.saveVisualization('Rendering Test: metric v2', { + await visualize.saveVisualization('Rendering Test: metric v2', { saveAsNew: false, redirectToOrigin: true, }); await testSubjects.existOrFail('embeddablePanelHeading-RenderingTest:metricv2'); - await PageObjects.canvas.deleteSelectedElement(); + await canvas.deleteSelectedElement(); }); }); describe('by-value', () => { it('creates new tsvb embeddable', async () => { - const originalEmbeddableCount = await PageObjects.canvas.getEmbeddableCount(); - await PageObjects.canvas.createNewVis('metrics'); - await PageObjects.visualize.saveVisualizationAndReturn(); + const originalEmbeddableCount = await canvas.getEmbeddableCount(); + await canvas.createNewVis('metrics'); + await visualize.saveVisualizationAndReturn(); await retry.try(async () => { - const embeddableCount = await PageObjects.canvas.getEmbeddableCount(); + const embeddableCount = await canvas.getEmbeddableCount(); expect(embeddableCount).to.eql(originalEmbeddableCount + 1); }); }); it('edits tsvb by-value embeddable', async () => { - const originalEmbeddableCount = await PageObjects.canvas.getEmbeddableCount(); + const originalEmbeddableCount = await canvas.getEmbeddableCount(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.visualize.saveVisualizationAndReturn(); + await visualize.saveVisualizationAndReturn(); await retry.try(async () => { - const embeddableCount = await PageObjects.canvas.getEmbeddableCount(); + const embeddableCount = await canvas.getEmbeddableCount(); expect(embeddableCount).to.eql(originalEmbeddableCount); }); - await PageObjects.canvas.deleteSelectedElement(); + await canvas.deleteSelectedElement(); }); it('creates new vega embeddable', async () => { - const originalEmbeddableCount = await PageObjects.canvas.getEmbeddableCount(); - await PageObjects.canvas.createNewVis('vega'); - await PageObjects.visualize.saveVisualizationAndReturn(); + const originalEmbeddableCount = await canvas.getEmbeddableCount(); + await canvas.createNewVis('vega'); + await visualize.saveVisualizationAndReturn(); await retry.try(async () => { - const embeddableCount = await PageObjects.canvas.getEmbeddableCount(); + const embeddableCount = await canvas.getEmbeddableCount(); expect(embeddableCount).to.eql(originalEmbeddableCount + 1); }); }); it('edits vega by-value embeddable', async () => { - const originalEmbeddableCount = await PageObjects.canvas.getEmbeddableCount(); + const originalEmbeddableCount = await canvas.getEmbeddableCount(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.visualize.saveVisualizationAndReturn(); + await visualize.saveVisualizationAndReturn(); await retry.try(async () => { - const embeddableCount = await PageObjects.canvas.getEmbeddableCount(); + const embeddableCount = await canvas.getEmbeddableCount(); expect(embeddableCount).to.eql(originalEmbeddableCount); }); }); diff --git a/x-pack/test/functional/apps/canvas/expression.ts b/x-pack/test/functional/apps/canvas/expression.ts index 7e6c8720ffc43..9b3096231bba1 100644 --- a/x-pack/test/functional/apps/canvas/expression.ts +++ b/x-pack/test/functional/apps/canvas/expression.ts @@ -15,7 +15,7 @@ export default function canvasExpressionTest({ getService, getPageObjects }: Ftr const find = getService('find'); const kibanaServer = getService('kibanaServer'); const monacoEditor = getService('monacoEditor'); - const PageObjects = getPageObjects(['canvas']); + const { canvas } = getPageObjects(['canvas']); const retry = getService('retry'); const testSubjects = getService('testSubjects'); @@ -27,8 +27,8 @@ export default function canvasExpressionTest({ getService, getPageObjects }: Ftr await kibanaServer.importExport.load(archive); // load test workpad - await PageObjects.canvas.goToListingPage(); - await PageObjects.canvas.loadFirstWorkpad('Test Workpad'); + await canvas.goToListingPage(); + await canvas.loadFirstWorkpad('Test Workpad'); }); after(async () => { @@ -51,7 +51,7 @@ export default function canvasExpressionTest({ getService, getPageObjects }: Ftr await monacoEditor.waitCodeEditorReady(codeEditorSubj); // open the expression editor - await PageObjects.canvas.openExpressionEditor(); + await canvas.openExpressionEditor(); await monacoEditor.waitCodeEditorReady('canvasExpressionInput'); // select markdown content and clear it diff --git a/x-pack/test/functional/apps/canvas/feature_controls/canvas_security.ts b/x-pack/test/functional/apps/canvas/feature_controls/canvas_security.ts index 10328cc9190ae..afcee962374db 100644 --- a/x-pack/test/functional/apps/canvas/feature_controls/canvas_security.ts +++ b/x-pack/test/functional/apps/canvas/feature_controls/canvas_security.ts @@ -9,8 +9,13 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const security = getService('security'); - const PageObjects = getPageObjects(['common', 'canvas', 'error', 'security', 'spaceSelector']); + const securityService = getService('security'); + const { common, canvas, error, security } = getPageObjects([ + 'common', + 'canvas', + 'error', + 'security', + ]); const appsMenu = getService('appsMenu'); const globalNav = getService('globalNav'); const testSubjects = getService('testSubjects'); @@ -26,7 +31,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('global canvas all privileges', () => { before(async () => { - await security.role.create('global_canvas_all_role', { + await securityService.role.create('global_canvas_all_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -40,29 +45,25 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_canvas_all_user', { + await securityService.user.create('global_canvas_all_user', { password: 'global_canvas_all_user-password', roles: ['global_canvas_all_role'], full_name: 'test user', }); - await PageObjects.security.forceLogout(); + await security.forceLogout(); - await PageObjects.security.login( - 'global_canvas_all_user', - 'global_canvas_all_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('global_canvas_all_user', 'global_canvas_all_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); + await security.forceLogout(); await Promise.all([ - security.role.delete('global_canvas_all_role'), - security.user.delete('global_canvas_all_user'), + securityService.role.delete('global_canvas_all_role'), + securityService.user.delete('global_canvas_all_user'), ]); }); @@ -72,11 +73,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page shows "Create new workpad" button`, async () => { - await PageObjects.common.navigateToActualUrl('canvas', '', { + await common.navigateToActualUrl('canvas', '', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.canvas.expectCreateWorkpadButtonEnabled(); + await canvas.expectCreateWorkpadButtonEnabled(); }); it(`doesn't show read-only badge`, async () => { @@ -84,15 +85,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`allows a workpad to be created`, async () => { - await PageObjects.common.navigateToActualUrl('canvas'); + await common.navigateToActualUrl('canvas'); await testSubjects.click('create-workpad-button'); - await PageObjects.canvas.expectAddElementButton(); + await canvas.expectAddElementButton(); }); it(`allows a workpad to be edited`, async () => { - await PageObjects.common.navigateToActualUrl( + await common.navigateToActualUrl( 'canvas', '/workpad/workpad-1705f884-6224-47de-ba49-ca224fe6ec31', { @@ -101,13 +102,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { } ); - await PageObjects.canvas.expectAddElementButton(); + await canvas.expectAddElementButton(); }); }); describe('global canvas read-only privileges', () => { before(async () => { - await security.role.create('global_canvas_read_role', { + await securityService.role.create('global_canvas_read_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -121,24 +122,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_canvas_read_user', { + await securityService.user.create('global_canvas_read_user', { password: 'global_canvas_read_user-password', roles: ['global_canvas_read_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'global_canvas_read_user', - 'global_canvas_read_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('global_canvas_read_user', 'global_canvas_read_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { - await security.role.delete('global_canvas_read_role'); - await security.user.delete('global_canvas_read_user'); + await securityService.role.delete('global_canvas_read_role'); + await securityService.user.delete('global_canvas_read_user'); }); it('shows canvas navlink', async () => { @@ -147,11 +144,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page shows disabled "Create new workpad" button`, async () => { - await PageObjects.common.navigateToActualUrl('canvas', '', { + await common.navigateToActualUrl('canvas', '', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.canvas.expectCreateWorkpadButtonDisabled(); + await canvas.expectCreateWorkpadButtonDisabled(); }); it(`shows read-only badge`, async () => { @@ -159,17 +156,17 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`does not allow a workpad to be created`, async () => { - await PageObjects.common.navigateToActualUrl('canvas', 'workpad/create', { + await common.navigateToActualUrl('canvas', 'workpad/create', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); // expect redirection to canvas landing - await PageObjects.canvas.expectCreateWorkpadButtonDisabled(); + await canvas.expectCreateWorkpadButtonDisabled(); }); it(`does not allow a workpad to be edited`, async () => { - await PageObjects.common.navigateToActualUrl( + await common.navigateToActualUrl( 'canvas', '/workpad/workpad-1705f884-6224-47de-ba49-ca224fe6ec31', { @@ -178,13 +175,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { } ); - await PageObjects.canvas.expectNoAddElementButton(); + await canvas.expectNoAddElementButton(); }); }); describe('no canvas privileges', () => { before(async () => { - await security.role.create('no_canvas_privileges_role', { + await securityService.role.create('no_canvas_privileges_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -198,40 +195,36 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('no_canvas_privileges_user', { + await securityService.user.create('no_canvas_privileges_user', { password: 'no_canvas_privileges_user-password', roles: ['no_canvas_privileges_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'no_canvas_privileges_user', - 'no_canvas_privileges_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('no_canvas_privileges_user', 'no_canvas_privileges_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { - await security.role.delete('no_canvas_privileges_role'); - await security.user.delete('no_canvas_privileges_user'); + await securityService.role.delete('no_canvas_privileges_role'); + await securityService.user.delete('no_canvas_privileges_user'); }); it(`returns a 403`, async () => { - await PageObjects.common.navigateToActualUrl('canvas', '', { + await common.navigateToActualUrl('canvas', '', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.error.expectForbidden(); + await error.expectForbidden(); }); it(`create new workpad returns a 403`, async () => { - await PageObjects.common.navigateToActualUrl('canvas', 'workpad/create', { + await common.navigateToActualUrl('canvas', 'workpad/create', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.error.expectForbidden(); + await error.expectForbidden(); }); }); }); diff --git a/x-pack/test/functional/apps/canvas/feature_controls/canvas_spaces.ts b/x-pack/test/functional/apps/canvas/feature_controls/canvas_spaces.ts index e030cdbf5f624..faf114ad93eef 100644 --- a/x-pack/test/functional/apps/canvas/feature_controls/canvas_spaces.ts +++ b/x-pack/test/functional/apps/canvas/feature_controls/canvas_spaces.ts @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const spacesService = getService('spaces'); - const PageObjects = getPageObjects(['common', 'canvas', 'security', 'spaceSelector']); + const { common, canvas } = getPageObjects(['common', 'canvas']); const appsMenu = getService('appsMenu'); const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); @@ -51,7 +51,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('shows canvas navlink', async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); @@ -59,26 +59,26 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page shows "Create new workpad" button`, async () => { - await PageObjects.common.navigateToActualUrl('canvas', '', { + await common.navigateToActualUrl('canvas', '', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.canvas.expectCreateWorkpadButtonEnabled(); + await canvas.expectCreateWorkpadButtonEnabled(); }); it(`allows a workpad to be created`, async () => { - await PageObjects.common.navigateToActualUrl('canvas', '', { + await common.navigateToActualUrl('canvas', '', { ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); await testSubjects.click('create-workpad-button'); - await PageObjects.canvas.expectAddElementButton(); + await canvas.expectAddElementButton(); }); it(`allows a workpad to be edited`, async () => { - await PageObjects.common.navigateToActualUrl( + await common.navigateToActualUrl( 'canvas', '/workpad/workpad-1705f884-6224-47de-ba49-ca224fe6ec31', { @@ -87,7 +87,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { } ); - await PageObjects.canvas.expectAddElementButton(); + await canvas.expectAddElementButton(); }); }); @@ -112,7 +112,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`doesn't show canvas navlink`, async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); @@ -120,13 +120,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`create new workpad returns a 404`, async () => { - await PageObjects.common.navigateToActualUrl('canvas', '', { + await common.navigateToActualUrl('canvas', '', { basePath: '/s/custom_space', ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - const messageText = await PageObjects.common.getJsonBodyText(); + const messageText = await common.getJsonBodyText(); expect(messageText).to.eql( JSON.stringify({ statusCode: 404, @@ -137,7 +137,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`edit workpad returns a 404`, async () => { - await PageObjects.common.navigateToActualUrl( + await common.navigateToActualUrl( 'canvas', 'workpad/workpad-1705f884-6224-47de-ba49-ca224fe6ec31', { @@ -146,7 +146,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { shouldLoginIfPrompted: false, } ); - const messageText = await PageObjects.common.getJsonBodyText(); + const messageText = await common.getJsonBodyText(); expect(messageText).to.eql( JSON.stringify({ statusCode: 404, diff --git a/x-pack/test/functional/apps/canvas/filters.ts b/x-pack/test/functional/apps/canvas/filters.ts index 50c0935984367..ac3b5673b1fe1 100644 --- a/x-pack/test/functional/apps/canvas/filters.ts +++ b/x-pack/test/functional/apps/canvas/filters.ts @@ -12,7 +12,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function canvasFiltersTest({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); - const PageObjects = getPageObjects(['canvas']); + const { canvas } = getPageObjects(['canvas']); const find = getService('find'); const kibanaServer = getService('kibanaServer'); const archive = 'x-pack/test/functional/fixtures/kbn_archiver/canvas/filter'; @@ -24,8 +24,8 @@ export default function canvasFiltersTest({ getService, getPageObjects }: FtrPro before(async () => { await kibanaServer.importExport.load(archive); // load test workpad - await PageObjects.canvas.goToListingPage(); - await PageObjects.canvas.loadFirstWorkpad('Filter Debug Workpad'); + await canvas.goToListingPage(); + await canvas.loadFirstWorkpad('Filter Debug Workpad'); }); after(async () => { @@ -41,7 +41,7 @@ export default function canvasFiltersTest({ getService, getPageObjects }: FtrPro }); // Double check that the filter has the correct time range and default filter value - const startingMatchFilters = await PageObjects.canvas.getFiltersFromDebug('term'); + const startingMatchFilters = await canvas.getFiltersFromDebug('term'); const projectQuery = startingMatchFilters[0].query.term.project; expect(projectQuery !== null && typeof projectQuery === 'object').to.equal(true); expect(projectQuery?.value).to.equal('apm'); @@ -50,7 +50,7 @@ export default function canvasFiltersTest({ getService, getPageObjects }: FtrPro await testSubjects.selectValue('canvasDropdownFilter__select', 'beats'); await retry.try(async () => { - const matchFilters = await PageObjects.canvas.getFiltersFromDebug('term'); + const matchFilters = await canvas.getFiltersFromDebug('term'); const newProjectQuery = matchFilters[0].query.term.project; expect(newProjectQuery !== null && typeof newProjectQuery === 'object').to.equal(true); expect(newProjectQuery?.value).to.equal('beats'); @@ -66,7 +66,7 @@ export default function canvasFiltersTest({ getService, getPageObjects }: FtrPro expect(elements).to.have.length(3); }); - const startingTimeFilters = await PageObjects.canvas.getFiltersFromDebug('range'); + const startingTimeFilters = await canvas.getFiltersFromDebug('range'); const timestampQuery = startingTimeFilters[0].query.range['@timestamp']; expect(timestampQuery !== null && typeof timestampQuery === 'object').to.equal(true); expect(new Date(timestampQuery.gte).toDateString()).to.equal('Sun Oct 18 2020'); @@ -76,7 +76,7 @@ export default function canvasFiltersTest({ getService, getPageObjects }: FtrPro await find.clickByCssSelector('.react-datepicker [aria-label="day-19"]', 20000); await retry.try(async () => { - const timeFilters = await PageObjects.canvas.getFiltersFromDebug('range'); + const timeFilters = await canvas.getFiltersFromDebug('range'); const newTimestampQuery = timeFilters[0].query.range['@timestamp']; expect(newTimestampQuery !== null && typeof newTimestampQuery === 'object').to.equal(true); expect(new Date(newTimestampQuery.gte).toDateString()).to.equal('Mon Oct 19 2020'); @@ -87,7 +87,7 @@ export default function canvasFiltersTest({ getService, getPageObjects }: FtrPro await find.clickByCssSelector('.react-datepicker [aria-label="day-23"]', 20000); await retry.try(async () => { - const timeFilters = await PageObjects.canvas.getFiltersFromDebug('range'); + const timeFilters = await canvas.getFiltersFromDebug('range'); const newTimestampQuery = timeFilters[0].query.range['@timestamp']; expect(newTimestampQuery !== null && typeof newTimestampQuery === 'object').to.equal(true); expect(new Date(newTimestampQuery.gte).toDateString()).to.equal('Mon Oct 19 2020'); diff --git a/x-pack/test/functional/apps/canvas/migrations_smoke_test.ts b/x-pack/test/functional/apps/canvas/migrations_smoke_test.ts index 54f42e484734d..70d66dcdbd825 100644 --- a/x-pack/test/functional/apps/canvas/migrations_smoke_test.ts +++ b/x-pack/test/functional/apps/canvas/migrations_smoke_test.ts @@ -9,7 +9,7 @@ import path from 'path'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects(['settings', 'savedObjects']); + const { settings, savedObjects } = getPageObjects(['settings', 'savedObjects']); describe('migration smoke test', function () { it('imports an 8.2 workpad', async function () { @@ -22,14 +22,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { This smoke test is intended to import an 8.2 workpad to ensure that we don't hit a similar scenario in the future */ - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSavedObjects(); - await PageObjects.savedObjects.waitTableIsLoaded(); - await PageObjects.savedObjects.importFile( - path.join(__dirname, 'exports', '8.2.workpad.ndjson') - ); - await PageObjects.savedObjects.checkImportSucceeded(); - await PageObjects.savedObjects.clickImportDone(); + await settings.navigateTo(); + await settings.clickKibanaSavedObjects(); + await savedObjects.waitTableIsLoaded(); + await savedObjects.importFile(path.join(__dirname, 'exports', '8.2.workpad.ndjson')); + await savedObjects.checkImportSucceeded(); + await savedObjects.clickImportDone(); }); it('migrates a workpad from 8.1', async function () { @@ -37,14 +35,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { This is a smoke test to make sure migrations don't fail. This workpad from 8.1 has both by-val and by-ref embeddables */ - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSavedObjects(); - await PageObjects.savedObjects.waitTableIsLoaded(); - await PageObjects.savedObjects.importFile( - path.join(__dirname, 'exports', '8.1.embeddable_test.ndjson') - ); - await PageObjects.savedObjects.checkImportSucceeded(); - await PageObjects.savedObjects.clickImportDone(); + await settings.navigateTo(); + await settings.clickKibanaSavedObjects(); + await savedObjects.waitTableIsLoaded(); + await savedObjects.importFile(path.join(__dirname, 'exports', '8.1.embeddable_test.ndjson')); + await savedObjects.checkImportSucceeded(); + await savedObjects.clickImportDone(); }); }); } diff --git a/x-pack/test/functional/apps/canvas/reports.ts b/x-pack/test/functional/apps/canvas/reports.ts index 04d319af477cd..147f9c2b4b91d 100644 --- a/x-pack/test/functional/apps/canvas/reports.ts +++ b/x-pack/test/functional/apps/canvas/reports.ts @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const browser = getService('browser'); const log = getService('log'); const security = getService('security'); - const PageObjects = getPageObjects(['reporting', 'canvas']); + const { reporting, canvas } = getPageObjects(['reporting', 'canvas']); const archive = 'x-pack/test/functional/fixtures/kbn_archiver/canvas/reports'; describe('Canvas PDF Report Generation', () => { @@ -52,14 +52,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Generating and then comparing reports can take longer than the default 60s timeout this.timeout(180000); - await PageObjects.canvas.goToListingPage(); - await PageObjects.canvas.loadFirstWorkpad('The Very Cool Workpad for PDF Tests'); + await canvas.goToListingPage(); + await canvas.loadFirstWorkpad('The Very Cool Workpad for PDF Tests'); - await PageObjects.reporting.openShareMenuItem('PDF Reports'); - await PageObjects.reporting.clickGenerateReportButton(); + await reporting.openShareMenuItem('PDF Reports'); + await reporting.clickGenerateReportButton(); - const url = await PageObjects.reporting.getReportURL(60000); - const res = await PageObjects.reporting.getResponse(url ?? ''); + const url = await reporting.getReportURL(60000); + const res = await reporting.getResponse(url ?? ''); expect(res.status).to.equal(200); expect(res.get('content-type')).to.equal('application/pdf'); diff --git a/x-pack/test/functional/apps/canvas/saved_object_resolve.ts b/x-pack/test/functional/apps/canvas/saved_object_resolve.ts index c9b4074bc029a..f77da5e8a8d86 100644 --- a/x-pack/test/functional/apps/canvas/saved_object_resolve.ts +++ b/x-pack/test/functional/apps/canvas/saved_object_resolve.ts @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function canvasFiltersTest({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); - const PageObjects = getPageObjects(['canvas', 'common']); + const { common } = getPageObjects(['common']); const find = getService('find'); const kibanaServer = getService('kibanaServer'); const spacesService = getService('spaces'); @@ -82,7 +82,7 @@ export default function canvasFiltersTest({ getService, getPageObjects }: FtrPro }); it('redirects an alias match', async () => { - await PageObjects.common.navigateToUrl( + await common.navigateToUrl( 'canvas', 'workpad/workpad-1705f884-6224-47de-ba49-ca224fe6ec31-old-id/page/1', { @@ -115,7 +115,7 @@ export default function canvasFiltersTest({ getService, getPageObjects }: FtrPro }); it('handles a conflict match', async () => { - await PageObjects.common.navigateToUrl( + await common.navigateToUrl( 'canvas', 'workpad/workpad-1705f884-6224-47de-ba49-ca224fe6ec31-conflict-old/page/1', { diff --git a/x-pack/test/functional/apps/canvas/smoke_test.js b/x-pack/test/functional/apps/canvas/smoke_test.js index f251e34e8566d..2d457d7deb8a9 100644 --- a/x-pack/test/functional/apps/canvas/smoke_test.js +++ b/x-pack/test/functional/apps/canvas/smoke_test.js @@ -11,7 +11,7 @@ export default function canvasSmokeTest({ getService, getPageObjects }) { const testSubjects = getService('testSubjects'); const browser = getService('browser'); const retry = getService('retry'); - const PageObjects = getPageObjects(['canvas']); + const { canvas } = getPageObjects(['canvas']); const kibanaServer = getService('kibanaServer'); const config = getService('config'); const archive = { @@ -31,7 +31,7 @@ export default function canvasSmokeTest({ getService, getPageObjects }) { await kibanaServer.importExport.load(archive.local); } - await PageObjects.canvas.goToListingPage(); + await canvas.goToListingPage(); }); after(async () => { diff --git a/x-pack/test/functional/apps/dashboard/group1/created_by.ts b/x-pack/test/functional/apps/dashboard/group1/created_by.ts index ed3798e1b8809..9d257afe3c953 100644 --- a/x-pack/test/functional/apps/dashboard/group1/created_by.ts +++ b/x-pack/test/functional/apps/dashboard/group1/created_by.ts @@ -9,19 +9,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects([ - 'common', - 'dashboard', - 'visualize', - 'lens', - 'timePicker', - 'security', - ]); + const { dashboard, security } = getPageObjects(['dashboard', 'security']); const esArchiver = getService('esArchiver'); const listingTable = getService('listingTable'); const kibanaServer = getService('kibanaServer'); - const security = getService('security'); + const securityService = getService('security'); const testSubjects = getService('testSubjects'); describe('created_by', function () { @@ -40,9 +33,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ); // ensure we're logged out so we can login as the appropriate users - await PageObjects.security.forceLogout(); + await security.forceLogout(); - await security.role.create('global_dashboard_all_role', { + await securityService.role.create('global_dashboard_all_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -57,38 +50,38 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create(USERNAME_1, { + await securityService.user.create(USERNAME_1, { password: 'changeme', roles: ['global_dashboard_all_role'], full_name: 'global dashboard all user 1', }); - await security.user.create(USERNAME_2, { + await securityService.user.create(USERNAME_2, { password: 'changeme', roles: ['global_dashboard_all_role'], full_name: 'global dashboard all user 2', }); - await PageObjects.security.login(USERNAME_1, 'changeme', { + await security.login(USERNAME_1, 'changeme', { expectSpaceSelector: false, }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.saveDashboard(DASHBOARD_NAME, { + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); + await dashboard.saveDashboard(DASHBOARD_NAME, { saveAsNew: true, waitDialogIsClosed: false, exitFromEditMode: false, }); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); }); after(async () => { // logout, so the other tests don't accidentally run as the custom users we're testing below - await PageObjects.security.forceLogout(); - await security.role.delete('global_dashboard_all_role'); - await security.user.delete(USERNAME_1); - await security.user.delete(USERNAME_2); + await security.forceLogout(); + await securityService.role.delete('global_dashboard_all_role'); + await securityService.user.delete(USERNAME_1); + await securityService.user.delete(USERNAME_2); await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.importExport.unload( @@ -120,20 +113,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it("doesn't override creator when editing a dashboard", async () => { - await PageObjects.security.forceLogout(); - await PageObjects.security.login(USERNAME_2, 'changeme', { + await security.forceLogout(); + await security.login(USERNAME_2, 'changeme', { expectSpaceSelector: false, }); - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await testSubjects.existOrFail('tableHeaderCell_createdBy_1'); await testSubjects.existOrFail(`userAvatarTip-${USERNAME_1}`); - await PageObjects.dashboard.gotoDashboardEditMode(DASHBOARD_NAME); - await PageObjects.dashboard.addVisualizations(['A Pie']); - await PageObjects.dashboard.saveDashboard(DASHBOARD_NAME, { + await dashboard.gotoDashboardEditMode(DASHBOARD_NAME); + await dashboard.addVisualizations(['A Pie']); + await dashboard.saveDashboard(DASHBOARD_NAME, { waitDialogIsClosed: false, exitFromEditMode: false, }); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); await testSubjects.existOrFail('tableHeaderCell_createdBy_1'); await testSubjects.missingOrFail(`userAvatarTip-${USERNAME_2}`); }); diff --git a/x-pack/test/functional/apps/dashboard/group1/favorite.ts b/x-pack/test/functional/apps/dashboard/group1/favorite.ts index 873d3365e6da2..3fdc206b1252e 100644 --- a/x-pack/test/functional/apps/dashboard/group1/favorite.ts +++ b/x-pack/test/functional/apps/dashboard/group1/favorite.ts @@ -8,19 +8,12 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects([ - 'common', - 'dashboard', - 'visualize', - 'lens', - 'timePicker', - 'security', - ]); + const { dashboard, security } = getPageObjects(['dashboard', 'security']); const esArchiver = getService('esArchiver'); const listingTable = getService('listingTable'); const kibanaServer = getService('kibanaServer'); - const security = getService('security'); + const securityService = getService('security'); const spaces = getService('spaces'); const testSubjects = getService('testSubjects'); const browser = getService('browser'); @@ -44,9 +37,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ); // ensure we're logged out so we can login as the appropriate users - await PageObjects.security.forceLogout(); + await security.forceLogout(); - await security.role.create(ROLE, { + await securityService.role.create(ROLE, { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -60,17 +53,17 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create(USERNAME, { + await securityService.user.create(USERNAME, { password: 'changeme', roles: [ROLE], full_name: USERNAME, }); - await PageObjects.security.login(USERNAME, 'changeme', { + await security.login(USERNAME, 'changeme', { expectSpaceSelector: true, }); - await PageObjects.dashboard.gotoDashboardListingURL({ + await dashboard.gotoDashboardListingURL({ args: { basePath: '/s/custom_space', ensureCurrentUrl: false, @@ -81,10 +74,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { // logout, so the other tests don't accidentally run as the custom users we're testing below - await PageObjects.security.forceLogout(); + await security.forceLogout(); await spaces.delete(customSpace); - await security.user.delete(USERNAME); - await security.role.delete(ROLE); + await securityService.user.delete(USERNAME); + await securityService.role.delete(ROLE); await kibanaServer.importExport.unload( 'x-pack/test/functional/fixtures/kbn_archiver/dashboard/feature_controls/custom_space', diff --git a/x-pack/test/functional/apps/dashboard/group1/feature_controls/dashboard_security.ts b/x-pack/test/functional/apps/dashboard/group1/feature_controls/dashboard_security.ts index 4dddf0609a269..9a210f3de345c 100644 --- a/x-pack/test/functional/apps/dashboard/group1/feature_controls/dashboard_security.ts +++ b/x-pack/test/functional/apps/dashboard/group1/feature_controls/dashboard_security.ts @@ -10,16 +10,9 @@ import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const security = getService('security'); + const securityService = getService('security'); const config = getService('config'); - const PageObjects = getPageObjects([ - 'common', - 'dashboard', - 'security', - 'spaceSelector', - 'share', - 'error', - ]); + const { dashboard, security, error } = getPageObjects(['dashboard', 'security', 'error']); const appsMenu = getService('appsMenu'); const panelActions = getService('dashboardPanelActions'); const testSubjects = getService('testSubjects'); @@ -46,13 +39,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); // ensure we're logged out so we can login as the appropriate users - await PageObjects.security.forceLogout(); + await security.forceLogout(); }); after(async () => { // logout, so the other tests don't accidentally run as the custom users we're testing below // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); + await security.forceLogout(); await kbnServer.savedObjects.cleanStandardList(); await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); @@ -60,7 +53,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('global dashboard all privileges, no embeddable application privileges', () => { before(async () => { - await security.role.create('global_dashboard_all_role', { + await securityService.role.create('global_dashboard_all_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -74,24 +67,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_dashboard_all_user', { + await securityService.user.create('global_dashboard_all_user', { password: 'global_dashboard_all_user-password', roles: ['global_dashboard_all_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'global_dashboard_all_user', - 'global_dashboard_all_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('global_dashboard_all_user', 'global_dashboard_all_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { - await security.role.delete('global_dashboard_all_role'); - await security.user.delete('global_dashboard_all_user'); + await securityService.role.delete('global_dashboard_all_role'); + await securityService.user.delete('global_dashboard_all_user'); }); it('only shows the dashboard navlink', async () => { @@ -100,7 +89,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page shows "Create new Dashboard" button`, async () => { - await PageObjects.dashboard.gotoDashboardListingURL({ + await dashboard.gotoDashboardListingURL({ args: navigationArgs, }); await testSubjects.existOrFail('dashboardLandingPage', { @@ -114,14 +103,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`create new dashboard shows addNew button`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ args: navigationArgs }); + await dashboard.gotoDashboardURL({ args: navigationArgs }); await testSubjects.existOrFail('emptyDashboardWidget', { timeout: config.get('timeouts.waitFor'), }); }); it(`can view existing Dashboard`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ + await dashboard.gotoDashboardURL({ id: 'i-exist', args: navigationArgs, }); @@ -131,19 +120,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`does not allow a visualization to be edited`, async () => { - await PageObjects.dashboard.gotoDashboardEditMode('A Dashboard'); + await dashboard.gotoDashboardEditMode('A Dashboard'); await panelActions.expectMissingEditPanelAction(); }); it(`does not allow a map to be edited`, async () => { - await PageObjects.dashboard.gotoDashboardEditMode('dashboard with map'); + await dashboard.gotoDashboardEditMode('dashboard with map'); await panelActions.expectMissingEditPanelAction(); }); }); describe('global dashboard & embeddable all privileges', () => { before(async () => { - await security.role.create('global_dashboard_visualize_all_role', { + await securityService.role.create('global_dashboard_visualize_all_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -159,13 +148,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_dashboard_visualize_all_user', { + await securityService.user.create('global_dashboard_visualize_all_user', { password: 'global_dashboard_visualize_all_user-password', roles: ['global_dashboard_visualize_all_role'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'global_dashboard_visualize_all_user', 'global_dashboard_visualize_all_user-password', { @@ -175,19 +164,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); after(async () => { - await security.role.delete('global_dashboard_visualize_all_role'); - await security.user.delete('global_dashboard_visualize_all_user'); + await securityService.role.delete('global_dashboard_visualize_all_role'); + await securityService.user.delete('global_dashboard_visualize_all_user'); }); it(`allows a visualization to be edited`, async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardEditMode('A Dashboard'); + await dashboard.navigateToApp(); + await dashboard.gotoDashboardEditMode('A Dashboard'); await panelActions.expectExistsEditPanelAction(); }); it(`allows a map to be edited`, async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardEditMode('dashboard with map'); + await dashboard.navigateToApp(); + await dashboard.gotoDashboardEditMode('dashboard with map'); await panelActions.expectExistsEditPanelAction(); }); @@ -245,7 +234,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('global dashboard read-only privileges', () => { before(async () => { - await security.role.create('global_dashboard_read_role', { + await securityService.role.create('global_dashboard_read_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -259,24 +248,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_dashboard_read_user', { + await securityService.user.create('global_dashboard_read_user', { password: 'global_dashboard_read_user-password', roles: ['global_dashboard_read_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'global_dashboard_read_user', - 'global_dashboard_read_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('global_dashboard_read_user', 'global_dashboard_read_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { - await security.role.delete('global_dashboard_read_role'); - await security.user.delete('global_dashboard_read_user'); + await securityService.role.delete('global_dashboard_read_role'); + await securityService.user.delete('global_dashboard_read_user'); }); it('shows dashboard navlink', async () => { @@ -285,7 +270,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page doesn't show "Create new Dashboard" button`, async () => { - await PageObjects.dashboard.gotoDashboardListingURL({ + await dashboard.gotoDashboardListingURL({ args: navigationArgs, }); await testSubjects.existOrFail('dashboardLandingPage', { @@ -295,21 +280,21 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`shows read-only badge`, async () => { - await PageObjects.dashboard.gotoDashboardListingURL({ + await dashboard.gotoDashboardListingURL({ args: navigationArgs, }); await globalNav.badgeExistsOrFail('Read only'); }); it(`create new dashboard shows the read only warning`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ + await dashboard.gotoDashboardURL({ args: navigationArgs, }); await testSubjects.existOrFail('dashboardEmptyReadOnly', { timeout: 20000 }); }); it(`can view existing Dashboard`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ + await dashboard.gotoDashboardURL({ id: 'i-exist', args: navigationArgs, }); @@ -350,7 +335,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('global dashboard read-only with url_create privileges', () => { before(async () => { - await security.role.create('global_dashboard_read_url_create_role', { + await securityService.role.create('global_dashboard_read_url_create_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -364,13 +349,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_dashboard_read_url_create_user', { + await securityService.user.create('global_dashboard_read_url_create_user', { password: 'global_dashboard_read_url_create_user-password', roles: ['global_dashboard_read_url_create_role'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'global_dashboard_read_url_create_user', 'global_dashboard_read_url_create_user-password', { @@ -380,8 +365,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); after(async () => { - await security.role.delete('global_dashboard_read_url_create_role'); - await security.user.delete('global_dashboard_read_url_create_user'); + await securityService.role.delete('global_dashboard_read_url_create_role'); + await securityService.user.delete('global_dashboard_read_url_create_user'); }); it('shows dashboard navlink', async () => { @@ -390,7 +375,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page doesn't show "Create new Dashboard" button`, async () => { - await PageObjects.dashboard.gotoDashboardListingURL({ + await dashboard.gotoDashboardListingURL({ args: navigationArgs, }); await testSubjects.existOrFail('dashboardLandingPage', { timeout: 10000 }); @@ -402,14 +387,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`create new dashboard shows the read only warning`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ + await dashboard.gotoDashboardURL({ args: navigationArgs, }); await testSubjects.existOrFail('dashboardEmptyReadOnly', { timeout: 20000 }); }); it(`can view existing Dashboard`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ id: 'i-exist', args: navigationArgs }); + await dashboard.gotoDashboardURL({ id: 'i-exist', args: navigationArgs }); await testSubjects.existOrFail('embeddablePanelHeading-APie', { timeout: 10000 }); }); @@ -441,7 +426,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('no dashboard privileges', () => { before(async () => { - await security.role.create('no_dashboard_privileges_role', { + await securityService.role.create('no_dashboard_privileges_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -455,13 +440,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('no_dashboard_privileges_user', { + await securityService.user.create('no_dashboard_privileges_user', { password: 'no_dashboard_privileges_user-password', roles: ['no_dashboard_privileges_role'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'no_dashboard_privileges_user', 'no_dashboard_privileges_user-password', { @@ -471,8 +456,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); after(async () => { - await security.role.delete('no_dashboard_privileges_role'); - await security.user.delete('no_dashboard_privileges_user'); + await securityService.role.delete('no_dashboard_privileges_role'); + await securityService.user.delete('no_dashboard_privileges_user'); }); it(`doesn't show dashboard navLink`, async () => { @@ -481,25 +466,25 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page shows 403`, async () => { - await PageObjects.dashboard.gotoDashboardListingURL({ + await dashboard.gotoDashboardListingURL({ args: navigationArgs, }); - await PageObjects.error.expectForbidden(); + await error.expectForbidden(); }); it(`create new dashboard shows 403`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ args: navigationArgs }); - await PageObjects.error.expectForbidden(); + await dashboard.gotoDashboardURL({ args: navigationArgs }); + await error.expectForbidden(); }); it(`edit dashboard for object which doesn't exist shows 403`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ id: 'i-dont-exist', args: navigationArgs }); - await PageObjects.error.expectForbidden(); + await dashboard.gotoDashboardURL({ id: 'i-dont-exist', args: navigationArgs }); + await error.expectForbidden(); }); it(`edit dashboard for object which exists shows 403`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ id: 'i-exist', args: navigationArgs }); - await PageObjects.error.expectForbidden(); + await dashboard.gotoDashboardURL({ id: 'i-exist', args: navigationArgs }); + await error.expectForbidden(); }); }); }); diff --git a/x-pack/test/functional/apps/dashboard/group1/feature_controls/dashboard_spaces.ts b/x-pack/test/functional/apps/dashboard/group1/feature_controls/dashboard_spaces.ts index 2f04d12bdac6d..6801d7ad4e467 100644 --- a/x-pack/test/functional/apps/dashboard/group1/feature_controls/dashboard_spaces.ts +++ b/x-pack/test/functional/apps/dashboard/group1/feature_controls/dashboard_spaces.ts @@ -12,7 +12,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const config = getService('config'); const spacesService = getService('spaces'); - const PageObjects = getPageObjects(['common', 'dashboard', 'security', 'spaceSelector', 'error']); + const { common, dashboard, error } = getPageObjects(['common', 'dashboard', 'error']); const appsMenu = getService('appsMenu'); const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); @@ -41,7 +41,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => await spacesService.delete(customSpace)); it('shows dashboard navlink', async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); @@ -49,7 +49,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page shows "Create new Dashboard" button`, async () => { - await PageObjects.dashboard.gotoDashboardListingURL({ + await dashboard.gotoDashboardListingURL({ args: { basePath: '/s/custom_space', ensureCurrentUrl: false, @@ -63,7 +63,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`create new dashboard shows addNew button`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ + await dashboard.gotoDashboardURL({ args: { basePath: '/s/custom_space', ensureCurrentUrl: false, @@ -76,7 +76,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`can view existing Dashboard`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ + await dashboard.gotoDashboardURL({ id: '8fba09d8-df3f-5aa1-83cc-65f7fbcbc0d9', args: { basePath: '/s/custom_space', @@ -108,7 +108,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => await spacesService.delete('custom_space')); it(`doesn't show dashboard navlink`, async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); @@ -116,18 +116,18 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`create new dashboard shows 404`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ + await dashboard.gotoDashboardURL({ args: { basePath: '/s/custom_space', ensureCurrentUrl: false, shouldLoginIfPrompted: false, }, }); - await PageObjects.error.expectNotFound(); + await error.expectNotFound(); }); it(`edit dashboard for object which doesn't exist shows 404`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ + await dashboard.gotoDashboardURL({ id: 'i-dont-exist', args: { basePath: '/s/custom_space', @@ -135,11 +135,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { shouldLoginIfPrompted: false, }, }); - await PageObjects.error.expectNotFound(); + await error.expectNotFound(); }); it(`edit dashboard for object which exists shows 404`, async () => { - await PageObjects.dashboard.gotoDashboardURL({ + await dashboard.gotoDashboardURL({ id: 'i-exist', args: { basePath: '/s/custom_space', @@ -147,7 +147,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { shouldLoginIfPrompted: false, }, }); - await PageObjects.error.expectNotFound(); + await error.expectNotFound(); }); }); }); diff --git a/x-pack/test/functional/apps/dashboard/group1/feature_controls/time_to_visualize_security.ts b/x-pack/test/functional/apps/dashboard/group1/feature_controls/time_to_visualize_security.ts index 07dcf1ac03182..8922bca6d7fdf 100644 --- a/x-pack/test/functional/apps/dashboard/group1/feature_controls/time_to_visualize_security.ts +++ b/x-pack/test/functional/apps/dashboard/group1/feature_controls/time_to_visualize_security.ts @@ -9,24 +9,24 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects([ - 'timeToVisualize', - 'timePicker', - 'dashboard', - 'visEditor', - 'visualize', - 'security', - 'common', - 'header', - 'lens', - ]); + const { timeToVisualize, timePicker, dashboard, visEditor, visualize, security, header, lens } = + getPageObjects([ + 'timeToVisualize', + 'timePicker', + 'dashboard', + 'visEditor', + 'visualize', + 'security', + 'header', + 'lens', + ]); const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardPanelActions = getService('dashboardPanelActions'); const dashboardExpect = getService('dashboardExpect'); const testSubjects = getService('testSubjects'); const esArchiver = getService('esArchiver'); - const security = getService('security'); + const securityService = getService('security'); const find = getService('find'); const kbnServer = getService('kibanaServer'); @@ -42,9 +42,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); // ensure we're logged out so we can login as the appropriate users - await PageObjects.security.forceLogout(); + await security.forceLogout(); - await security.role.create('dashboard_write_vis_read', { + await securityService.role.create('dashboard_write_vis_read', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -59,13 +59,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('dashboard_write_vis_read_user', { + await securityService.user.create('dashboard_write_vis_read_user', { password: 'dashboard_write_vis_read_user-password', roles: ['dashboard_write_vis_read'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'dashboard_write_vis_read_user', 'dashboard_write_vis_read_user-password', { @@ -77,10 +77,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { // logout, so the other tests don't accidentally run as the custom users we're testing below // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); + await security.forceLogout(); - await security.role.delete('dashboard_write_vis_read'); - await security.user.delete('dashboard_write_vis_read_user'); + await securityService.role.delete('dashboard_write_vis_read'); + await securityService.user.delete('dashboard_write_vis_read_user'); await kbnServer.savedObjects.cleanStandardList(); await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional'); @@ -88,79 +88,73 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('lens by value works without library save permissions', () => { before(async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); }); it('can add a lens panel by value', async () => { - await PageObjects.lens.createAndAddLensFromDashboard({}); - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + await lens.createAndAddLensFromDashboard({}); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.eql(1); }); it('edits to a by value lens panel are properly applied', async () => { - await PageObjects.dashboard.waitForRenderComplete(); - await dashboardPanelActions.openContextMenu(); + await dashboard.waitForRenderComplete(); await dashboardPanelActions.clickEdit(); - await PageObjects.lens.switchToVisualization('pie'); - await PageObjects.lens.saveAndReturn(); - await PageObjects.dashboard.waitForRenderComplete(); + await lens.switchToVisualization('pie'); + await lens.saveAndReturn(); + await dashboard.waitForRenderComplete(); const partitionVisExists = await testSubjects.exists('partitionVisChart'); expect(partitionVisExists).to.be(true); }); it('disables save to library button without visualize save permissions', async () => { - await PageObjects.dashboard.waitForRenderComplete(); - await dashboardPanelActions.openContextMenu(); + await dashboard.waitForRenderComplete(); await dashboardPanelActions.clickEdit(); const saveButton = await testSubjects.find('lnsApp_saveButton'); expect(await saveButton.getAttribute('disabled')).to.equal('true'); - await PageObjects.lens.saveAndReturn(); - await PageObjects.timeToVisualize.resetNewDashboard(); + await lens.saveAndReturn(); + await timeToVisualize.resetNewDashboard(); }); it('should allow new lens to be added by value, but not by reference', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); + await lens.switchToVisualization('lnsLegacyMetric'); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); - await PageObjects.lens.assertLegacyMetric('Average of bytes', '5,727.322'); + await lens.waitForVisualization('legacyMtrVis'); + await lens.assertLegacyMetric('Average of bytes', '5,727.322'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('lnsApp_saveButton'); const libraryCheckbox = await find.byCssSelector('#add-to-library-checkbox'); expect(await libraryCheckbox.getAttribute('disabled')).to.equal('true'); - await PageObjects.timeToVisualize.saveFromModal('New Lens from Modal', { + await timeToVisualize.saveFromModal('New Lens from Modal', { addToDashboard: 'new', saveAsNew: true, saveToLibrary: false, }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - await PageObjects.lens.assertLegacyMetric('Average of bytes', '5,727.322'); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'New Lens from Modal' - ); - expect(isLinked).to.be(false); + await lens.assertLegacyMetric('Average of bytes', '5,727.322'); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); }); @@ -169,69 +163,67 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const modifiedMarkdownText = 'Modified markdown text'; before(async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); }); it('can add a markdown panel by value', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + await dashboard.waitForRenderComplete(); await dashboardAddPanel.clickMarkdownQuickButton(); - await PageObjects.visEditor.setMarkdownTxt(originalMarkdownText); - await PageObjects.visEditor.clickGo(); + await visEditor.setMarkdownTxt(originalMarkdownText); + await visEditor.clickGo(); - await PageObjects.visualize.saveVisualizationAndReturn(); - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + await visualize.saveVisualizationAndReturn(); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.eql(1); }); it('edits to a by value visualize panel are properly applied', async () => { - await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.visEditor.setMarkdownTxt(modifiedMarkdownText); - await PageObjects.visEditor.clickGo(); - await PageObjects.visualize.saveVisualizationAndReturn(); + await header.waitUntilLoadingHasFinished(); + await visEditor.setMarkdownTxt(modifiedMarkdownText); + await visEditor.clickGo(); + await visualize.saveVisualizationAndReturn(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); const markdownText = await testSubjects.find('markdownBody'); expect(await markdownText.getVisibleText()).to.eql(modifiedMarkdownText); - const newPanelCount = PageObjects.dashboard.getPanelCount(); + const newPanelCount = dashboard.getPanelCount(); expect(newPanelCount).to.eql(1); }); it('disables save to library button without visualize save permissions', async () => { - await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.missingOrFail('visualizeSaveButton'); - await PageObjects.visualize.saveVisualizationAndReturn(); - await PageObjects.timeToVisualize.resetNewDashboard(); + await visualize.saveVisualizationAndReturn(); + await timeToVisualize.resetNewDashboard(); }); it('should allow new visualization to be added by value, but not by reference', async function () { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickMetric(); - await PageObjects.visualize.clickNewSearch(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickMetric(); + await visualize.clickNewSearch(); + await timePicker.setDefaultAbsoluteRange(); await testSubjects.click('visualizeSaveButton'); - await PageObjects.visualize.ensureSavePanelOpen(); + await visualize.ensureSavePanelOpen(); const libraryCheckbox = await find.byCssSelector('#add-to-library-checkbox'); expect(await libraryCheckbox.getAttribute('disabled')).to.equal('true'); - await PageObjects.timeToVisualize.saveFromModal('My New Vis 1', { + await timeToVisualize.saveFromModal('My New Vis 1', { addToDashboard: 'new', }); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardExpect.metricValuesExist(['14,005']); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); }); }); diff --git a/x-pack/test/functional/apps/dashboard/group1/preserve_url.ts b/x-pack/test/functional/apps/dashboard/group1/preserve_url.ts index cb5713e4d03ee..5265e52bc5e91 100644 --- a/x-pack/test/functional/apps/dashboard/group1/preserve_url.ts +++ b/x-pack/test/functional/apps/dashboard/group1/preserve_url.ts @@ -9,7 +9,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'dashboard', 'spaceSelector', 'header']); + const { common, dashboard, spaceSelector, header } = getPageObjects([ + 'common', + 'dashboard', + 'spaceSelector', + 'header', + ]); const globalNav = getService('globalNav'); const kibanaServer = getService('kibanaServer'); const spacesService = getService('spaces'); @@ -34,46 +39,46 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('goes back to last opened url', async function () { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('A Dashboard'); - await PageObjects.common.navigateToApp('home'); - await PageObjects.dashboard.navigateToAppFromAppsMenu(); - await PageObjects.dashboard.loadSavedDashboard('A Dashboard'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('A Dashboard'); + await common.navigateToApp('home'); + await dashboard.navigateToAppFromAppsMenu(); + await dashboard.loadSavedDashboard('A Dashboard'); + await header.waitUntilLoadingHasFinished(); const activeTitle = await globalNav.getLastBreadcrumb(); expect(activeTitle).to.be('A Dashboard'); }); it('remembers url after switching spaces', async function () { // default space - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('A Dashboard'); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('A Dashboard'); - await PageObjects.spaceSelector.openSpacesNav(); - await PageObjects.spaceSelector.clickSpaceAvatar('another-space'); - await PageObjects.spaceSelector.expectHomePage('another-space'); + await spaceSelector.openSpacesNav(); + await spaceSelector.clickSpaceAvatar('another-space'); + await spaceSelector.expectHomePage('another-space'); // other space - await PageObjects.dashboard.navigateToAppFromAppsMenu(); - await PageObjects.dashboard.loadSavedDashboard('A Dashboard in another space'); + await dashboard.navigateToAppFromAppsMenu(); + await dashboard.loadSavedDashboard('A Dashboard in another space'); - await PageObjects.spaceSelector.openSpacesNav(); - await PageObjects.spaceSelector.clickSpaceAvatar('default'); - await PageObjects.spaceSelector.expectHomePage('default'); + await spaceSelector.openSpacesNav(); + await spaceSelector.clickSpaceAvatar('default'); + await spaceSelector.expectHomePage('default'); // default space - await PageObjects.dashboard.navigateToAppFromAppsMenu(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.navigateToAppFromAppsMenu(); + await dashboard.waitForRenderComplete(); const activeTitleDefaultSpace = await globalNav.getLastBreadcrumb(); expect(activeTitleDefaultSpace).to.be('A Dashboard'); - await PageObjects.spaceSelector.openSpacesNav(); - await PageObjects.spaceSelector.clickSpaceAvatar('another-space'); - await PageObjects.spaceSelector.expectHomePage('another-space'); + await spaceSelector.openSpacesNav(); + await spaceSelector.clickSpaceAvatar('another-space'); + await spaceSelector.expectHomePage('another-space'); // other space - await PageObjects.dashboard.navigateToAppFromAppsMenu(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.navigateToAppFromAppsMenu(); + await dashboard.waitForRenderComplete(); const activeTitleOtherSpace = await globalNav.getLastBreadcrumb(); expect(activeTitleOtherSpace).to.be('A Dashboard in another space'); }); diff --git a/x-pack/test/functional/apps/dashboard/group2/_async_dashboard.ts b/x-pack/test/functional/apps/dashboard/group2/_async_dashboard.ts index 66b31842df00a..caca6dca59c3f 100644 --- a/x-pack/test/functional/apps/dashboard/group2/_async_dashboard.ts +++ b/x-pack/test/functional/apps/dashboard/group2/_async_dashboard.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const renderable = getService('renderable'); const dashboardExpect = getService('dashboardExpect'); const appMenu = getService('appsMenu'); - const PageObjects = getPageObjects([ + const { common, header, home, discover, dashboard, timePicker } = getPageObjects([ 'common', 'header', 'home', @@ -32,14 +32,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('sample data dashboard', function describeIndexTests() { before(async () => { await esArchiver.emptyKibanaIndex(); - await PageObjects.common.sleep(5000); - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.sleep(5000); + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.addSampleDataSet('flights'); + await header.waitUntilLoadingHasFinished(); + await home.addSampleDataSet('flights'); await retry.tryForTime(10000, async () => { - const isInstalled = await PageObjects.home.isSampleDataSetInstalled('flights'); + const isInstalled = await home.isSampleDataSetInstalled('flights'); expect(isInstalled).to.be(true); }); @@ -107,32 +107,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // refresh page to make sure ui settings update is picked up await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await appMenu.clickLink('Discover'); - await PageObjects.discover.selectIndexPattern('Kibana Sample Data Flights'); - await PageObjects.timePicker.setCommonlyUsedTime('sample_data range'); + await discover.selectIndexPattern('Kibana Sample Data Flights'); + await timePicker.setCommonlyUsedTime('sample_data range'); await retry.try(async function () { - const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10); + const hitCount = parseInt(await discover.getHitCount(), 10); expect(hitCount).to.be.greaterThan(0); }); }); after(async () => { - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.removeSampleDataSet('flights'); - const isInstalled = await PageObjects.home.isSampleDataSetInstalled('flights'); + await header.waitUntilLoadingHasFinished(); + await home.removeSampleDataSet('flights'); + const isInstalled = await home.isSampleDataSetInstalled('flights'); expect(isInstalled).to.be(false); }); it('should launch sample flights data set dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('[Flights] Global Flight Dashboard'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.timePicker.setCommonlyUsedTime('sample_data range'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('[Flights] Global Flight Dashboard'); + await header.waitUntilLoadingHasFinished(); + await timePicker.setCommonlyUsedTime('sample_data range'); + await header.waitUntilLoadingHasFinished(); // check at least one visualization await renderable.waitForRender(); @@ -141,14 +141,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await appMenu.clickLink('Discover'); await retry.try(async function () { - const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10); + const hitCount = parseInt(await discover.getHitCount(), 10); expect(hitCount).to.be.greaterThan(0); }); await appMenu.clickLink('Dashboard', { category: 'recentlyViewed', closeCollapsibleNav: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); log.debug('Checking charts rendered'); await elasticChart.waitForRenderComplete('xyVisChart'); @@ -157,14 +157,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('toggle from Discover to Dashboard attempt 1', async () => { await appMenu.clickLink('Discover'); await retry.try(async function () { - const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10); + const hitCount = parseInt(await discover.getHitCount(), 10); expect(hitCount).to.be.greaterThan(0); }); await appMenu.clickLink('Dashboard', { category: 'recentlyViewed', closeCollapsibleNav: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); log.debug('Checking charts rendered'); await elasticChart.waitForRenderComplete('xyVisChart'); @@ -173,14 +173,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('toggle from Discover to Dashboard attempt 2', async () => { await appMenu.clickLink('Discover'); await retry.try(async function () { - const hitCount = parseInt(await PageObjects.discover.getHitCount(), 10); + const hitCount = parseInt(await discover.getHitCount(), 10); expect(hitCount).to.be.greaterThan(0); }); await appMenu.clickLink('Dashboard', { category: 'recentlyViewed', closeCollapsibleNav: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); log.debug('Checking charts rendered'); await elasticChart.waitForRenderComplete('xyVisChart'); diff --git a/x-pack/test/functional/apps/dashboard/group2/dashboard_lens_by_value.ts b/x-pack/test/functional/apps/dashboard/group2/dashboard_lens_by_value.ts index 19d44ba6a6035..3e648f5000945 100644 --- a/x-pack/test/functional/apps/dashboard/group2/dashboard_lens_by_value.ts +++ b/x-pack/test/functional/apps/dashboard/group2/dashboard_lens_by_value.ts @@ -9,7 +9,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'dashboard', 'visualize', 'lens', 'timePicker']); + const { dashboard, visualize, lens, timePicker } = getPageObjects([ + 'dashboard', + 'visualize', + 'lens', + 'timePicker', + ]); const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); @@ -22,9 +27,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await kibanaServer.importExport.load( 'x-pack/test/functional/fixtures/kbn_archiver/lens/lens_basic.json' ); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); }); after(async () => { @@ -35,65 +40,65 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('can add a lens panel by value', async () => { - await PageObjects.lens.createAndAddLensFromDashboard({}); - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + await lens.createAndAddLensFromDashboard({}); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.eql(1); }); it('edits to a by value lens panel are properly applied', async () => { - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.lens.switchToVisualization('pie'); - await PageObjects.lens.saveAndReturn(); - await PageObjects.dashboard.waitForRenderComplete(); + await lens.switchToVisualization('pie'); + await lens.saveAndReturn(); + await dashboard.waitForRenderComplete(); const partitionVisExists = await testSubjects.exists('partitionVisChart'); expect(partitionVisExists).to.be(true); }); it('editing and saving a lens by value panel retains number of panels', async () => { - const originalPanelCount = await PageObjects.dashboard.getPanelCount(); - await PageObjects.dashboard.waitForRenderComplete(); + const originalPanelCount = await dashboard.getPanelCount(); + await dashboard.waitForRenderComplete(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.lens.switchToVisualization('treemap'); - await PageObjects.lens.saveAndReturn(); - await PageObjects.dashboard.waitForRenderComplete(); - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + await lens.switchToVisualization('treemap'); + await lens.saveAndReturn(); + await dashboard.waitForRenderComplete(); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.eql(originalPanelCount); }); it('updates panel on dashboard when a by value panel is saved to library', async () => { const newTitle = 'look out library, here I come!'; - const originalPanelCount = await PageObjects.dashboard.getPanelCount(); - await PageObjects.dashboard.waitForRenderComplete(); + const originalPanelCount = await dashboard.getPanelCount(); + await dashboard.waitForRenderComplete(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.lens.save(newTitle, false, true); - await PageObjects.dashboard.waitForRenderComplete(); - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + await lens.save(newTitle, false, true); + await dashboard.waitForRenderComplete(); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.eql(originalPanelCount); - const titles = await PageObjects.dashboard.getPanelTitles(); + const titles = await dashboard.getPanelTitles(); expect(titles.indexOf(newTitle)).to.not.be(-1); }); it('is no longer linked to a dashboard after visiting the visualize listing page', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickLensWidget(); - await PageObjects.timePicker.ensureHiddenNoDataPopover(); - await PageObjects.lens.configureDimension({ + await visualize.navigateToNewVisualization(); + await visualize.clickLensWidget(); + await timePicker.ensureHiddenNoDataPopover(); + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); - await PageObjects.lens.notLinkedToOriginatingApp(); + await lens.waitForVisualization('xyVisChart'); + await lens.notLinkedToOriginatingApp(); // return to origin should not be present in save modal await testSubjects.click('lnsApp_saveButton'); diff --git a/x-pack/test/functional/apps/dashboard/group2/dashboard_maps_by_value.ts b/x-pack/test/functional/apps/dashboard/group2/dashboard_maps_by_value.ts index 6cfdc7356a4b5..a55c3c3c0433c 100644 --- a/x-pack/test/functional/apps/dashboard/group2/dashboard_maps_by_value.ts +++ b/x-pack/test/functional/apps/dashboard/group2/dashboard_maps_by_value.ts @@ -9,12 +9,10 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects([ - 'common', + const { dashboard, maps, timeToVisualize } = getPageObjects([ 'dashboard', 'maps', 'timeToVisualize', - 'visualize', ]); const log = getService('log'); @@ -28,51 +26,51 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { async function createAndAddMapByValue() { log.debug(`createAndAddMapByValue`); - const inViewMode = await PageObjects.dashboard.getIsInViewMode(); + const inViewMode = await dashboard.getIsInViewMode(); if (inViewMode) { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); } await dashboardAddPanel.clickEditorMenuButton(); await testSubjects.setValue('dashboardPanelSelectionFlyout__searchInput', 'maps'); await dashboardAddPanel.clickVisType('maps'); - await PageObjects.maps.clickSaveAndReturnButton(); + await maps.clickSaveAndReturnButton(); } async function editByValueMap(saveToLibrary = false, saveToDashboard = true) { - const inViewMode = await PageObjects.dashboard.getIsInViewMode(); + const inViewMode = await dashboard.getIsInViewMode(); if (inViewMode) { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); } await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.maps.clickAddLayer(); - await PageObjects.maps.selectLayerGroupCard(); + await maps.clickAddLayer(); + await maps.selectLayerGroupCard(); await testSubjects.click('importFileButton'); if (saveToLibrary) { await testSubjects.click('mapSaveButton'); - await PageObjects.timeToVisualize.ensureSaveModalIsOpen; + await timeToVisualize.ensureSaveModalIsOpen; - await PageObjects.timeToVisualize.saveFromModal(`my map ${mapCounter++}`, { + await timeToVisualize.saveFromModal(`my map ${mapCounter++}`, { redirectToOrigin: saveToDashboard, }); if (!saveToDashboard) { - await PageObjects.dashboard.navigateToAppFromAppsMenu(); + await dashboard.navigateToAppFromAppsMenu(); } } else { - await PageObjects.maps.clickSaveAndReturnButton(); + await maps.clickSaveAndReturnButton(); } - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); } async function createNewDashboard() { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); } describe('dashboard maps by value', function () { @@ -95,7 +93,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('can add a map by value', async () => { await createNewDashboard(); await createAndAddMapByValue(); - const newPanelCount = await PageObjects.dashboard.getPanelCount(); + const newPanelCount = await dashboard.getPanelCount(); expect(newPanelCount).to.eql(1); }); }); @@ -108,12 +106,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('retains the same number of panels', async () => { - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.equal(1); }); it('updates the panel on return', async () => { - const hasLayer = await PageObjects.maps.doesLayerExist('Layer group'); + const hasLayer = await maps.doesLayerExist('Layer group'); expect(hasLayer).to.be(true); }); }); @@ -127,14 +125,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('updates the existing panel when adding to dashboard', async () => { await editByValueMap(true); - const hasLayer = await PageObjects.maps.doesLayerExist('Layer group'); + const hasLayer = await maps.doesLayerExist('Layer group'); expect(hasLayer).to.be(true); }); it('does not update the panel when only saving to library', async () => { await editByValueMap(true, false); - const hasLayer = await PageObjects.maps.doesLayerExist('Layer group'); + const hasLayer = await maps.doesLayerExist('Layer group'); expect(hasLayer).to.be(false); }); }); diff --git a/x-pack/test/functional/apps/dashboard/group2/dashboard_search_by_value.ts b/x-pack/test/functional/apps/dashboard/group2/dashboard_search_by_value.ts index e82c73dddc294..04d7794a00751 100644 --- a/x-pack/test/functional/apps/dashboard/group2/dashboard_search_by_value.ts +++ b/x-pack/test/functional/apps/dashboard/group2/dashboard_search_by_value.ts @@ -15,8 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const filterBar = getService('filterBar'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker', 'discover']); + const { common, dashboard, header } = getPageObjects(['common', 'dashboard', 'header']); describe('saved searches by value', () => { before(async () => { @@ -29,7 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.common.setTime({ + await common.setTime({ from: 'Sep 22, 2015 @ 00:00:00.000', to: 'Sep 23, 2015 @ 00:00:00.000', }); @@ -37,73 +36,47 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); beforeEach(async () => { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await filterBar.ensureFieldEditorModalIsClosed(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); }); const addSearchEmbeddableToDashboard = async () => { await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); const rows = await dataGrid.getDocTableRows(); expect(rows.length).to.be.above(0); }; it('should allow cloning a by ref saved search embeddable to a by value embeddable', async () => { await addSearchEmbeddableToDashboard(); - let panels = await testSubjects.findAll(`embeddablePanel`); - expect(panels.length).to.be(1); - expect( - await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - panels[0] - ) - ).to.be(true); - await dashboardPanelActions.clonePanelByTitle('RenderingTest:savedsearch'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); - panels = await testSubjects.findAll('embeddablePanel'); - expect(panels.length).to.be(2); - expect( - await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - panels[0] - ) - ).to.be(true); - expect( - await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - panels[1] - ) - ).to.be(false); + let titles = await dashboard.getPanelTitles(); + expect(titles.length).to.be(1); + await dashboardPanelActions.expectLinkedToLibrary(titles[0]); + await dashboardPanelActions.clonePanel(titles[0]); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); + titles = await dashboard.getPanelTitles(); + expect(titles.length).to.be(2); + await dashboardPanelActions.expectLinkedToLibrary(titles[0]); + await dashboardPanelActions.expectNotLinkedToLibrary(titles[1]); }); it('should allow unlinking a by ref saved search embeddable from library', async () => { await addSearchEmbeddableToDashboard(); - let panels = await testSubjects.findAll(`embeddablePanel`); - expect(panels.length).to.be(1); - expect( - await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - panels[0] - ) - ).to.be(true); - await dashboardPanelActions.unlinkFromLibrary(panels[0]); - await testSubjects.existOrFail('unlinkPanelSuccess'); - panels = await testSubjects.findAll('embeddablePanel'); - expect(panels.length).to.be(1); - expect( - await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - panels[0] - ) - ).to.be(false); + let titles = await dashboard.getPanelTitles(); + expect(titles.length).to.be(1); + await dashboardPanelActions.expectLinkedToLibrary(titles[0]); + await dashboardPanelActions.unlinkFromLibrary(titles[0]); + titles = await dashboard.getPanelTitles(); + expect(titles.length).to.be(1); + await dashboardPanelActions.expectNotLinkedToLibrary(titles[0]); }); }); } diff --git a/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/lens_migration_smoke_test.ts b/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/lens_migration_smoke_test.ts index 69f4f0e8f4915..81fade0255cf7 100644 --- a/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/lens_migration_smoke_test.ts +++ b/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/lens_migration_smoke_test.ts @@ -18,8 +18,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); const dashboardPanelActions = getService('dashboardPanelActions'); + const dashboardDrilldownPanelActions = getService('dashboardDrilldownPanelActions'); - const PageObjects = getPageObjects(['common', 'settings', 'header', 'savedObjects', 'dashboard']); + const { settings, savedObjects, dashboard } = getPageObjects([ + 'settings', + 'savedObjects', + 'dashboard', + ]); describe('Lens - Export import saved objects between versions', () => { before(async () => { @@ -27,9 +32,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'x-pack/test/functional/es_archives/getting_started/shakespeare' ); await kibanaServer.uiSettings.replace({}); - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSavedObjects(); - await PageObjects.savedObjects.importFile( + await settings.navigateTo(); + await settings.clickKibanaSavedObjects(); + await savedObjects.importFile( path.join(__dirname, 'exports', 'lens_dashboard_migration_test_7_12_1.ndjson') ); }); @@ -41,28 +46,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to import dashboard with various Lens panels from 7.12.1', async () => { // this will catch cases where there is an error in the migrations. - await PageObjects.savedObjects.checkImportSucceeded(); - await PageObjects.savedObjects.clickImportDone(); + await savedObjects.checkImportSucceeded(); + await savedObjects.clickImportDone(); }); it('should render all panels on the dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('[7.12.1] Lens By Value Test Dashboard'); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('[7.12.1] Lens By Value Test Dashboard'); // dashboard should load properly - await PageObjects.dashboard.expectOnDashboard('[7.12.1] Lens By Value Test Dashboard'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.expectOnDashboard('[7.12.1] Lens By Value Test Dashboard'); + await dashboard.waitForRenderComplete(); // There should be 0 error embeddables on the dashboard - const errorEmbeddables = await testSubjects.findAll('embeddableStackError'); + const errorEmbeddables = await testSubjects.findAll('embeddableStackError', 500); expect(errorEmbeddables.length).to.be(0); }); it('should show the edit action for all panels', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); // All panels should be editable. This will catch cases where an error does not create an error embeddable. - const panelTitles = await PageObjects.dashboard.getPanelTitles(); + const panelTitles = await dashboard.getPanelTitles(); for (const title of panelTitles) { await dashboardPanelActions.expectExistsEditPanelAction(title, true); } @@ -70,10 +75,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should retain all panel drilldowns from 7.12.1', async () => { // Both panels configured with drilldowns in 7.12.1 should still have drilldowns. - const totalPanels = await PageObjects.dashboard.getPanelCount(); + const totalPanels = await dashboard.getPanelCount(); let panelsWithDrilldowns = 0; for (let panelIndex = 0; panelIndex < totalPanels; panelIndex++) { - if ((await PageObjects.dashboard.getPanelDrilldownCount(panelIndex)) === 1) { + if ((await dashboardDrilldownPanelActions.getPanelDrilldownCount(panelIndex)) === 1) { panelsWithDrilldowns++; } } diff --git a/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/tsvb_migration_smoke_test.ts b/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/tsvb_migration_smoke_test.ts index 49996231ecb70..4fc81d8c00bf0 100644 --- a/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/tsvb_migration_smoke_test.ts +++ b/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/tsvb_migration_smoke_test.ts @@ -14,34 +14,39 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); const dashboardPanelActions = getService('dashboardPanelActions'); + const dashboardDrilldownPanelActions = getService('dashboardDrilldownPanelActions'); - const PageObjects = getPageObjects(['common', 'settings', 'header', 'savedObjects', 'dashboard']); + const { settings, savedObjects, dashboard } = getPageObjects([ + 'settings', + 'savedObjects', + 'dashboard', + ]); describe('TSVB - Export import saved objects between versions', () => { describe('From 7.12.1', () => { before(async () => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.uiSettings.replace({}); - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSavedObjects(); - await PageObjects.savedObjects.importFile( + await settings.navigateTo(); + await settings.clickKibanaSavedObjects(); + await savedObjects.importFile( path.join(__dirname, 'exports', 'tsvb_dashboard_migration_test_7_12_1.ndjson') ); }); it('should be able to import dashboard with TSVB panels from 7.12.1', async () => { // this will catch cases where there is an error in the migrations. - await PageObjects.savedObjects.checkImportSucceeded(); - await PageObjects.savedObjects.clickImportDone(); + await savedObjects.checkImportSucceeded(); + await savedObjects.clickImportDone(); }); it('should render all panels on the dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('TSVB Index Pattern Smoke Test'); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('TSVB Index Pattern Smoke Test'); // dashboard should load properly - await PageObjects.dashboard.expectOnDashboard('TSVB Index Pattern Smoke Test'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.expectOnDashboard('TSVB Index Pattern Smoke Test'); + await dashboard.waitForRenderComplete(); // There should be 0 error embeddables on the dashboard const errorEmbeddables = await testSubjects.findAll('embeddableStackError'); @@ -49,10 +54,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show the edit action for all panels', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); // All panels should be editable. This will catch cases where an error does not create an error embeddable. - const panelTitles = await PageObjects.dashboard.getPanelTitles(); + const panelTitles = await dashboard.getPanelTitles(); for (const title of panelTitles) { await dashboardPanelActions.expectExistsEditPanelAction(title); } @@ -60,18 +65,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should retain all panel drilldowns from 7.12.1', async () => { // Both panels configured with drilldowns in 7.12.1 should still have drilldowns. - const totalPanels = await PageObjects.dashboard.getPanelCount(); + const totalPanels = await dashboard.getPanelCount(); let panelsWithDrilldowns = 0; let drilldownCount = 0; for (let panelIndex = 0; panelIndex < totalPanels; panelIndex++) { - const panelDrilldownCount = await PageObjects.dashboard.getPanelDrilldownCount( + const panelDrilldownCount = await dashboardDrilldownPanelActions.getPanelDrilldownCount( panelIndex ); if (panelDrilldownCount >= 1) { panelsWithDrilldowns++; } - drilldownCount += await PageObjects.dashboard.getPanelDrilldownCount(panelIndex); + drilldownCount += await dashboardDrilldownPanelActions.getPanelDrilldownCount(panelIndex); } expect(panelsWithDrilldowns).to.be(2); expect(drilldownCount).to.be(3); @@ -87,26 +92,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.uiSettings.replace({}); - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSavedObjects(); - await PageObjects.savedObjects.importFile( + await settings.navigateTo(); + await settings.clickKibanaSavedObjects(); + await savedObjects.importFile( path.join(__dirname, 'exports', 'tsvb_dashboard_migration_test_7_13_3.ndjson') ); }); it('should be able to import dashboard with TSVB panels from 7.13.3', async () => { // this will catch cases where there is an error in the migrations. - await PageObjects.savedObjects.checkImportSucceeded(); - await PageObjects.savedObjects.clickImportDone(); + await savedObjects.checkImportSucceeded(); + await savedObjects.clickImportDone(); }); it('should render all panels on the dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('TSVB 7.13.3'); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('TSVB 7.13.3'); // dashboard should load properly - await PageObjects.dashboard.expectOnDashboard('TSVB 7.13.3'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.expectOnDashboard('TSVB 7.13.3'); + await dashboard.waitForRenderComplete(); // There should be 0 error embeddables on the dashboard const errorEmbeddables = await testSubjects.findAll('embeddableStackError'); @@ -114,10 +119,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show the edit action for all panels', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); // All panels should be editable. This will catch cases where an error does not create an error embeddable. - const panelTitles = await PageObjects.dashboard.getPanelTitles(); + const panelTitles = await dashboard.getPanelTitles(); for (const title of panelTitles) { await dashboardPanelActions.expectExistsEditPanelAction(title); } diff --git a/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/visualize_migration_smoke_test.ts b/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/visualize_migration_smoke_test.ts index 7ba93ff5c2298..b436887b8d8d1 100644 --- a/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/visualize_migration_smoke_test.ts +++ b/x-pack/test/functional/apps/dashboard/group2/migration_smoke_tests/visualize_migration_smoke_test.ts @@ -18,8 +18,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); const dashboardPanelActions = getService('dashboardPanelActions'); + const dashboardDrilldownPanelActions = getService('dashboardDrilldownPanelActions'); - const PageObjects = getPageObjects(['common', 'settings', 'header', 'savedObjects', 'dashboard']); + const { settings, savedObjects, dashboard } = getPageObjects([ + 'settings', + 'savedObjects', + 'dashboard', + ]); describe('Visualize - Export import saved objects between versions', () => { before(async () => { @@ -27,9 +32,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'x-pack/test/functional/es_archives/getting_started/shakespeare' ); await kibanaServer.uiSettings.replace({}); - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSavedObjects(); - await PageObjects.savedObjects.importFile( + await settings.navigateTo(); + await settings.clickKibanaSavedObjects(); + await savedObjects.importFile( path.join(__dirname, 'exports', 'visualize_dashboard_migration_test_7_12_1.ndjson') ); }); @@ -41,17 +46,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should be able to import dashboard with various Visualize panels from 7.12.1', async () => { // this will catch cases where there is an error in the migrations. - await PageObjects.savedObjects.checkImportSucceeded(); - await PageObjects.savedObjects.clickImportDone(); + await savedObjects.checkImportSucceeded(); + await savedObjects.clickImportDone(); }); it('should render all panels on the dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('[7.12.1] Visualize Test Dashboard'); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('[7.12.1] Visualize Test Dashboard'); // dashboard should load properly - await PageObjects.dashboard.expectOnDashboard('[7.12.1] Visualize Test Dashboard'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.expectOnDashboard('[7.12.1] Visualize Test Dashboard'); + await dashboard.waitForRenderComplete(); // There should be 0 error embeddables on the dashboard const errorEmbeddables = await testSubjects.findAll('embeddableStackError'); @@ -59,10 +64,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show the edit action for all panels', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); // All panels should be editable. This will catch cases where an error does not create an error embeddable. - const panelTitles = await PageObjects.dashboard.getPanelTitles(); + const panelTitles = await dashboard.getPanelTitles(); for (const title of panelTitles) { await dashboardPanelActions.expectExistsEditPanelAction(title); } @@ -70,10 +75,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should retain all panel drilldowns from 7.12.1', async () => { // Both panels configured with drilldowns in 7.12.1 should still have drilldowns. - const totalPanels = await PageObjects.dashboard.getPanelCount(); + const totalPanels = await dashboard.getPanelCount(); let panelsWithDrilldowns = 0; for (let panelIndex = 0; panelIndex < totalPanels; panelIndex++) { - if ((await PageObjects.dashboard.getPanelDrilldownCount(panelIndex)) === 1) { + if ((await dashboardDrilldownPanelActions.getPanelDrilldownCount(panelIndex)) === 1) { panelsWithDrilldowns++; } } diff --git a/x-pack/test/functional/apps/dashboard/group2/panel_time_range.ts b/x-pack/test/functional/apps/dashboard/group2/panel_time_range.ts index 06e5485420465..d5070b931b18f 100644 --- a/x-pack/test/functional/apps/dashboard/group2/panel_time_range.ts +++ b/x-pack/test/functional/apps/dashboard/group2/panel_time_range.ts @@ -15,14 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const dashboardBadgeActions = getService('dashboardBadgeActions'); const dashboardCustomizePanel = getService('dashboardCustomizePanel'); - const PageObjects = getPageObjects([ - 'common', - 'dashboard', - 'visualize', - 'visEditor', - 'timePicker', - 'lens', - ]); + const { dashboard, lens } = getPageObjects(['dashboard', 'lens']); const DASHBOARD_NAME = 'Custom panel time range test'; @@ -33,31 +26,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'x-pack/test/functional/fixtures/kbn_archiver/lens/lens_basic.json' ); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.saveDashboard(DASHBOARD_NAME); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); + await dashboard.saveDashboard(DASHBOARD_NAME); }); describe('by value', () => { it('can add a custom time range to a panel', async () => { - await PageObjects.lens.createAndAddLensFromDashboard({}); + await lens.createAndAddLensFromDashboard({}); await dashboardPanelActions.customizePanel(); await dashboardCustomizePanel.enableCustomTimeRange(); await dashboardCustomizePanel.openDatePickerQuickMenu(); await dashboardCustomizePanel.clickCommonlyUsedTimeRange('Last_30 days'); await dashboardCustomizePanel.clickSaveButton(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardBadgeActions.expectExistsTimeRangeBadgeAction(); expect(await testSubjects.exists('emptyPlaceholder')).to.be(true); - await PageObjects.dashboard.clickQuickSave(); + await dashboard.clickQuickSave(); }); it('can remove a custom time range from a panel', async () => { await dashboardBadgeActions.clickTimeRangeBadgeAction(); await dashboardCustomizePanel.disableCustomTimeRange(); await dashboardCustomizePanel.clickSaveButton(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardBadgeActions.expectMissingTimeRangeBadgeAction(); expect(await testSubjects.exists('xyVisChart')).to.be(true); }); @@ -71,17 +64,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardCustomizePanel.openDatePickerQuickMenu(); await dashboardCustomizePanel.clickCommonlyUsedTimeRange('Last_30 days'); await dashboardCustomizePanel.clickSaveButton(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardBadgeActions.expectExistsTimeRangeBadgeAction(); expect(await testSubjects.exists('emptyPlaceholder')).to.be(true); - await PageObjects.dashboard.clickQuickSave(); + await dashboard.clickQuickSave(); }); it('can remove a custom time range from a panel', async () => { await dashboardBadgeActions.clickTimeRangeBadgeAction(); await dashboardCustomizePanel.disableCustomTimeRange(); await dashboardCustomizePanel.clickSaveButton(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardBadgeActions.expectMissingTimeRangeBadgeAction(); expect(await testSubjects.exists('xyVisChart')).to.be(true); }); diff --git a/x-pack/test/functional/apps/dashboard/group2/panel_titles.ts b/x-pack/test/functional/apps/dashboard/group2/panel_titles.ts index 33297ac310630..c3d5bfce6e621 100644 --- a/x-pack/test/functional/apps/dashboard/group2/panel_titles.ts +++ b/x-pack/test/functional/apps/dashboard/group2/panel_titles.ts @@ -15,14 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const dashboardCustomizePanel = getService('dashboardCustomizePanel'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ - 'common', - 'dashboard', - 'visualize', - 'visEditor', - 'timePicker', - 'lens', - ]); + const { dashboard, lens } = getPageObjects(['dashboard', 'lens']); const EMPTY_TITLE = '[No Title]'; @@ -33,11 +26,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'x-pack/test/functional/fixtures/kbn_archiver/lens/lens_basic.json' ); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.dashboard.saveDashboard('Panel Title Test'); - await PageObjects.lens.createAndAddLensFromDashboard({}); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); + await dashboard.saveDashboard('Panel Title Test'); + await lens.createAndAddLensFromDashboard({}); }); beforeEach(async () => { @@ -49,7 +42,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('by value', () => { it('new panel by value has empty title', async () => { - const [newPanelTitle] = await PageObjects.dashboard.getPanelTitles(); + const [newPanelTitle] = await dashboard.getPanelTitles(); expect(newPanelTitle).to.equal(EMPTY_TITLE); }); @@ -57,16 +50,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardPanelActions.customizePanel(); await dashboardCustomizePanel.setCustomPanelTitle(''); await dashboardCustomizePanel.clickSaveButton(); - await PageObjects.dashboard.clearUnsavedChanges(); + await dashboard.clearUnsavedChanges(); }); it('custom title causes unsaved changes and saving clears it', async () => { await dashboardPanelActions.customizePanel(); await dashboardCustomizePanel.setCustomPanelTitle('Custom title'); await dashboardCustomizePanel.clickSaveButton(); - const [panelTitle] = await PageObjects.dashboard.getPanelTitles(); + const [panelTitle] = await dashboard.getPanelTitles(); expect(panelTitle).to.equal('Custom title'); - await PageObjects.dashboard.clearUnsavedChanges(); + await dashboard.clearUnsavedChanges(); }); it('reset title should be hidden on a by value panel', async () => { @@ -102,7 +95,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardPanelActions.legacySaveToLibrary(getVisTitle(true)); await retry.tryForTime(500, async () => { // need to surround in 'retry' due to delays in HTML updates causing the title read to be behind - const [newPanelTitle] = await PageObjects.dashboard.getPanelTitles(); + const [newPanelTitle] = await dashboard.getPanelTitles(); expect(newPanelTitle).to.equal(getVisTitle()); }); }); @@ -122,7 +115,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.navigateToEditorFromFlyout(); // legacySaveToLibrary UI cannot set description - await PageObjects.lens.save( + await lens.save( getVisTitle(true), false, undefined, @@ -150,8 +143,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardPanelActions.customizePanel(); await dashboardCustomizePanel.setCustomPanelTitle('Custom title'); await dashboardCustomizePanel.clickSaveButton(); - await dashboardPanelActions.legacyUnlinkFromLibrary(); - const [newPanelTitle] = await PageObjects.dashboard.getPanelTitles(); + await dashboardPanelActions.legacyUnlinkFromLibrary('Custom title'); + const [newPanelTitle] = await dashboard.getPanelTitles(); expect(newPanelTitle).to.equal('Custom title'); }); @@ -162,14 +155,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardPanelActions.legacySaveToLibrary(getVisTitle(true)); await retry.tryForTime(500, async () => { // need to surround in 'retry' due to delays in HTML updates causing the title read to be behind - const [newPanelTitle] = await PageObjects.dashboard.getPanelTitles(); + const [newPanelTitle] = await dashboard.getPanelTitles(); expect(newPanelTitle).to.equal(getVisTitle()); }); }); it('unlinking a by reference panel without a custom title will keep the library title', async () => { - await dashboardPanelActions.legacyUnlinkFromLibrary(); - const [newPanelTitle] = await PageObjects.dashboard.getPanelTitles(); + await dashboardPanelActions.legacyUnlinkFromLibrary(getVisTitle()); + const [newPanelTitle] = await dashboard.getPanelTitles(); expect(newPanelTitle).to.equal(getVisTitle()); }); }); diff --git a/x-pack/test/functional/apps/dashboard/group2/sync_colors.ts b/x-pack/test/functional/apps/dashboard/group2/sync_colors.ts index ecd5c86d22955..a89f35d917130 100644 --- a/x-pack/test/functional/apps/dashboard/group2/sync_colors.ts +++ b/x-pack/test/functional/apps/dashboard/group2/sync_colors.ts @@ -12,14 +12,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects([ - 'common', - 'dashboard', - 'spaceSelector', - 'header', - 'lens', - 'timePicker', - ]); + const { dashboard, header, lens } = getPageObjects(['dashboard', 'header', 'lens']); const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardSettings = getService('dashboardSettings'); const filterBar = getService('filterBar'); @@ -53,83 +46,83 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should sync colors on dashboard for legacy default palette', async function () { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.dashboard.clickCreateDashboardPrompt(); + await dashboard.clickCreateDashboardPrompt(); // create non-filtered xy chart await dashboardAddPanel.clickCreateNewLink(); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.goToTimeRange(); + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'count', field: 'Records', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', palette: { mode: 'legacy', id: 'default' }, }); - await PageObjects.lens.saveAndReturn(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await lens.saveAndReturn(); + await header.waitUntilLoadingHasFinished(); // create filtered xy chart await dashboardAddPanel.clickCreateNewLink(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'count', field: 'Records', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', palette: { mode: 'legacy', id: 'default' }, }); await filterBar.addFilter({ field: 'geo.src', operation: 'is not', value: 'CN' }); - await PageObjects.lens.saveAndReturn(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await lens.saveAndReturn(); + await header.waitUntilLoadingHasFinished(); // create datatable vis await dashboardAddPanel.clickCreateNewLink(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await lens.switchToVisualization('lnsDatatable'); + await lens.configureDimension({ dimension: 'lnsDatatable_rows > lns-empty-dimension', operation: 'terms', field: 'geo.src', keepOpen: true, }); - await PageObjects.lens.setTermsNumberOfValues(5); - await PageObjects.lens.setTableDynamicColoring('cell'); - await PageObjects.lens.setPalette('default', true); - await PageObjects.lens.closeDimensionEditor(); - await PageObjects.lens.configureDimension({ + await lens.setTermsNumberOfValues(5); + await lens.setTableDynamicColoring('cell'); + await lens.setPalette('default', true); + await lens.closeDimensionEditor(); + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'count', field: 'Records', }); - await PageObjects.lens.saveAndReturn(); + await lens.saveAndReturn(); // Set dashboard to sync colors - await PageObjects.dashboard.openSettingsFlyout(); + await dashboard.openSettingsFlyout(); await dashboardSettings.toggleSyncColors(true); await dashboardSettings.clickApplyButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); const colorMappings1 = Object.entries( - getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(0)) + getColorMapping(await dashboard.getPanelChartDebugState(0)) ); const colorMappings2 = Object.entries( - getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(1)) + getColorMapping(await dashboard.getPanelChartDebugState(1)) ); - const els = await PageObjects.lens.getDatatableCellsByColumn(0); + const els = await lens.getDatatableCellsByColumn(0); const colorMappings3 = await Promise.all( els.map(async (el) => [ await el.getVisibleText(), - chroma((await PageObjects.lens.getStylesFromCell(el))['background-color']).hex(), // eui converts hex to rgb + chroma((await lens.getStylesFromCell(el))['background-color']).hex(), // eui converts hex to rgb ]) ); @@ -154,12 +147,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should be possible to disable color sync', async () => { - await PageObjects.dashboard.openSettingsFlyout(); + await dashboard.openSettingsFlyout(); await dashboardSettings.toggleSyncColors(false); await dashboardSettings.clickApplyButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const colorMapping1 = getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(0)); - const colorMapping2 = getColorMapping(await PageObjects.dashboard.getPanelChartDebugState(1)); + await header.waitUntilLoadingHasFinished(); + const colorMapping1 = getColorMapping(await dashboard.getPanelChartDebugState(0)); + const colorMapping2 = getColorMapping(await dashboard.getPanelChartDebugState(1)); const colorsByOrder1 = Object.values(colorMapping1); const colorsByOrder2 = Object.values(colorMapping2); // colors by order of occurence have to be the same 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 4f3861eb1f2a0..6c67ecf2825f3 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 @@ -17,7 +17,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const dashboardDrilldownPanelActions = getService('dashboardDrilldownPanelActions'); const dashboardDrilldownsManage = getService('dashboardDrilldownsManage'); - const PageObjects = getPageObjects([ + const { + dashboard, + dashboardControls, + common, + header, + timePicker, + settings, + copySavedObjectsToSpace, + } = getPageObjects([ 'dashboard', 'dashboardControls', 'common', @@ -38,9 +46,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const toasts = getService('toasts'); const createDrilldown = async () => { - await PageObjects.dashboard.gotoDashboardEditMode( - dashboardDrilldownsManage.DASHBOARD_WITH_PIE_CHART_NAME - ); + await dashboard.gotoDashboardEditMode(dashboardDrilldownsManage.DASHBOARD_WITH_PIE_CHART_NAME); await toasts.dismissAll(); // toasts get in the way of bottom "Create drilldown" button in flyout // create drilldown @@ -55,18 +61,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardDrilldownsManage.closeFlyout(); // check that drilldown notification badge is shown - expect(await PageObjects.dashboard.getPanelDrilldownCount()).to.be(1); + expect(await dashboardDrilldownPanelActions.getPanelDrilldownCount()).to.be(1); // save dashboard, navigate to view mode await testSubjects.existOrFail('dashboardUnsavedChangesBadge'); - await PageObjects.dashboard.saveDashboard( - dashboardDrilldownsManage.DASHBOARD_WITH_PIE_CHART_NAME, - { - saveAsNew: false, - waitDialogIsClosed: true, - exitFromEditMode: true, - } - ); + await dashboard.saveDashboard(dashboardDrilldownsManage.DASHBOARD_WITH_PIE_CHART_NAME, { + saveAsNew: false, + waitDialogIsClosed: true, + exitFromEditMode: true, + }); await testSubjects.missingOrFail('dashboardUnsavedChangesBadge'); }; @@ -74,17 +77,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { dashboardName: string, controls: Array<{ field: string; type: string }> ) => { - await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); + await dashboard.gotoDashboardEditMode(dashboardName); await toasts.dismissAll(); // toasts get in the way of bottom "Save and close" button in create control flyout for (const control of controls) { - await PageObjects.dashboardControls.createControl({ + await dashboardControls.createControl({ controlType: control.type, dataViewTitle: 'logstash-*', fieldName: control.field, }); } - await PageObjects.dashboard.clickQuickSave(); + await dashboard.clickQuickSave(); }; const brushAreaChart = async () => { @@ -110,16 +113,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const navigateAndEnsureIDChange = async (navigationTrigger: () => Promise) => { // before executing action which would trigger navigation: remember current dashboard id in url - const oldDashboardId = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); + const oldDashboardId = await dashboard.getDashboardIdFromCurrentUrl(); // execute navigation action await navigationTrigger(); // wait until dashboard navigates to a new dashboard with area chart await retry.waitFor('navigate to different dashboard', async () => { - const newDashboardId = await PageObjects.dashboard.getDashboardIdFromCurrentUrl(); + const newDashboardId = await dashboard.getDashboardIdFromCurrentUrl(); return typeof newDashboardId === 'string' && oldDashboardId !== newDashboardId; }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); }; describe('Dashboard to dashboard drilldown', function () { @@ -127,8 +130,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { log.debug('Dashboard Drilldowns:initTests'); await security.testUser.setRoles(['test_logstash_reader', 'global_dashboard_all']); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); await elasticChart.setNewChartUiDebugFlag(); await createDrilldown(); @@ -147,7 +150,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('test dashboard to dashboard drilldown', () => { beforeEach(async () => { - await PageObjects.dashboard.gotoDashboardEditMode( + await dashboard.gotoDashboardEditMode( dashboardDrilldownsManage.DASHBOARD_WITH_PIE_CHART_NAME ); }); @@ -166,7 +169,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // ensure that we ended up on the correct destination dashboard. - await PageObjects.dashboard.expectOnDashboard( + await dashboard.expectOnDashboard( dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME ); @@ -181,19 +184,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { DRILLDOWN_TO_AREA_CHART_NAME ); expect(typeof href).to.be('string'); // checking that action has a href - const dashboardIdFromHref = PageObjects.dashboard.getDashboardIdFromUrl(href); + const dashboardIdFromHref = dashboard.getDashboardIdFromUrl(href); await navigateAndEnsureIDChange(async () => { await dashboardDrilldownPanelActions.openHrefByText(DRILLDOWN_TO_AREA_CHART_NAME); }); // checking that href points to the dashboard id that we have navigated to. - expect(dashboardIdFromHref).to.be( - await PageObjects.dashboard.getDashboardIdFromCurrentUrl() - ); + expect(dashboardIdFromHref).to.be(await dashboard.getDashboardIdFromCurrentUrl()); // ensure that we ended up on the correct destination dashboard. - await PageObjects.dashboard.expectOnDashboard( + await dashboard.expectOnDashboard( dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME ); @@ -213,7 +214,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // ensure that we ended up on the correct destination dashboard. - await PageObjects.dashboard.expectOnDashboard( + await dashboard.expectOnDashboard( dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME ); @@ -224,7 +225,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('carries over time range from source dashboard', async () => { const startTime = 'Sep 22, 2015 @ 06:31:44.000'; const endTime = 'Sep 23, 2015 @ 06:31:44.000'; - await PageObjects.timePicker.setAbsoluteRange(startTime, endTime); + await timePicker.setAbsoluteRange(startTime, endTime); // Navigate via drilldown, ensuring that the ID changes. await openContextMenuFromPieSlice(); @@ -233,15 +234,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // ensure that we ended up on the correct destination dashboard. - await PageObjects.dashboard.expectOnDashboard( + await dashboard.expectOnDashboard( dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME ); // ensure that the time range has been carried over. - expect(await PageObjects.timePicker.getTimeDurationInHours()).to.be(24); + expect(await timePicker.getTimeDurationInHours()).to.be(24); // reset time range - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); }); it('browser back navigation works after drilldown navigation', async () => { @@ -253,7 +254,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // ensure that we ended up on the correct destination dashboard. - await PageObjects.dashboard.expectOnDashboard( + await dashboard.expectOnDashboard( dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME ); @@ -262,18 +263,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // ensure that we have returned to the origin dashboard. - await PageObjects.dashboard.clickCancelOutOfEditMode(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.clickCancelOutOfEditMode(); + await dashboard.waitForRenderComplete(); - await PageObjects.dashboard.expectOnDashboard( + await dashboard.expectOnDashboard( dashboardDrilldownsManage.DASHBOARD_WITH_PIE_CHART_NAME ); }); it('delete dashboard to dashboard drilldown', async () => { // delete drilldown - await PageObjects.dashboard.switchToEditMode(); - await dashboardDrilldownPanelActions.expectExistsManageDrilldownsAction(); + await dashboard.switchToEditMode(); await dashboardDrilldownPanelActions.clickManageDrilldowns(); await dashboardDrilldownsManage.expectsManageDrilldownsFlyoutOpen(); @@ -281,7 +281,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardDrilldownsManage.closeFlyout(); // check that drilldown notification badge is not shown - expect(await PageObjects.dashboard.getPanelDrilldownCount()).to.be(0); + expect(await dashboardDrilldownPanelActions.getPanelDrilldownCount()).to.be(0); // this drilldown will be available again in the next test because the session storage is cleared. }); @@ -289,10 +289,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('test dashboard to dashboard drilldown with controls', () => { const cleanFiltersAndControls = async (dashboardName: string) => { - await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); + await dashboard.gotoDashboardEditMode(dashboardName); await filterBar.removeAllFilters(); - await PageObjects.dashboardControls.deleteAllControls(); - await PageObjects.dashboard.clickQuickSave(); + await dashboardControls.deleteAllControls(); + await dashboard.clickQuickSave(); }; before('add controls and make selections', async () => { @@ -301,17 +301,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { { field: 'geo.src', type: OPTIONS_LIST_CONTROL }, { field: 'bytes', type: RANGE_SLIDER_CONTROL }, ]); - const controlIds = await PageObjects.dashboardControls.getAllControlIds(); + const controlIds = await dashboardControls.getAllControlIds(); const [optionsListControl, rangeSliderControl] = controlIds; - await PageObjects.dashboardControls.optionsListOpenPopover(optionsListControl); - await PageObjects.dashboardControls.optionsListPopoverSelectOption('CN'); - await PageObjects.dashboardControls.optionsListPopoverSelectOption('US'); - await PageObjects.dashboardControls.rangeSliderWaitForLoading(rangeSliderControl); // wait for range slider to respond to options list selections before proceeding - await PageObjects.dashboardControls.rangeSliderSetLowerBound(rangeSliderControl, '1000'); - await PageObjects.dashboardControls.rangeSliderSetUpperBound(rangeSliderControl, '15000'); - await PageObjects.dashboard.waitForRenderComplete(); - await PageObjects.dashboard.clickQuickSave(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboardControls.optionsListOpenPopover(optionsListControl); + await dashboardControls.optionsListPopoverSelectOption('CN'); + await dashboardControls.optionsListPopoverSelectOption('US'); + await dashboardControls.rangeSliderWaitForLoading(rangeSliderControl); // wait for range slider to respond to options list selections before proceeding + await dashboardControls.rangeSliderSetLowerBound(rangeSliderControl, '1000'); + await dashboardControls.rangeSliderSetUpperBound(rangeSliderControl, '15000'); + await dashboard.waitForRenderComplete(); + await dashboard.clickQuickSave(); + await header.waitUntilLoadingHasFinished(); /** Destination Dashboard */ await createControls(dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME, [ @@ -325,7 +325,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('creates filter pills representing controls selections', async () => { - await PageObjects.dashboard.gotoDashboardEditMode( + await dashboard.gotoDashboardEditMode( dashboardDrilldownsManage.DASHBOARD_WITH_PIE_CHART_NAME ); @@ -343,13 +343,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await filterBar.hasFilter('bytes', '1,000 to 15,000')).to.be(true); // control filter pills impact destination dashboard controls - const controlIds = await PageObjects.dashboardControls.getAllControlIds(); + const controlIds = await dashboardControls.getAllControlIds(); const optionsListControl = controlIds[0]; - await PageObjects.dashboardControls.optionsListOpenPopover(optionsListControl); - expect( - await PageObjects.dashboardControls.optionsListPopoverGetAvailableOptionsCount() - ).to.equal(2); - await PageObjects.dashboardControls.optionsListEnsurePopoverIsClosed(optionsListControl); + await dashboardControls.optionsListOpenPopover(optionsListControl); + expect(await dashboardControls.optionsListPopoverGetAvailableOptionsCount()).to.equal(2); + await dashboardControls.optionsListEnsurePopoverIsClosed(optionsListControl); }); }); }); @@ -363,8 +361,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { name: 'custom_space', disabledFeatures: [], }); - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSavedObjects(); + await settings.navigateTo(); + await settings.clickKibanaSavedObjects(); }); after(async () => { @@ -372,19 +370,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Dashboards linked by a drilldown are both copied to a space', async () => { - await PageObjects.copySavedObjectsToSpace.openCopyToSpaceFlyoutForObject( + await copySavedObjectsToSpace.openCopyToSpaceFlyoutForObject( dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME ); - await PageObjects.copySavedObjectsToSpace.setupForm({ + await copySavedObjectsToSpace.setupForm({ destinationSpaceId, }); - await PageObjects.copySavedObjectsToSpace.startCopy(); + await copySavedObjectsToSpace.startCopy(); // Wait for successful copy await testSubjects.waitForDeleted(`cts-summary-indicator-loading-${destinationSpaceId}`); await testSubjects.existOrFail(`cts-summary-indicator-success-${destinationSpaceId}`); - const summaryCounts = await PageObjects.copySavedObjectsToSpace.getSummaryCounts(); + const summaryCounts = await copySavedObjectsToSpace.getSummaryCounts(); expect(summaryCounts).to.eql({ success: 5, // 2 dashboards (linked by a drilldown) + 2 visualizations + 1 index pattern @@ -393,19 +391,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { errors: 0, }); - await PageObjects.copySavedObjectsToSpace.finishCopy(); + await copySavedObjectsToSpace.finishCopy(); // Actually use copied dashboards in a new space: - await PageObjects.common.navigateToApp('dashboards', { + await common.navigateToApp('dashboards', { basePath: `/s/${destinationSpaceId}`, }); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard( + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard( dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME ); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); // brush area chart and drilldown back to pie chat dashboard await brushAreaChart(); 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 2e15f19e702ac..3a28182c9f552 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 @@ -13,7 +13,11 @@ const DRILLDOWN_TO_DISCOVER_URL = 'Go to discover'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardDrilldownPanelActions = getService('dashboardDrilldownPanelActions'); const dashboardDrilldownsManage = getService('dashboardDrilldownsManage'); - const PageObjects = getPageObjects(['dashboard', 'common', 'header', 'timePicker', 'discover']); + const { dashboard, timePicker, discover } = getPageObjects([ + 'dashboard', + 'timePicker', + 'discover', + ]); const log = getService('log'); const browser = getService('browser'); const testSubjects = getService('testSubjects'); @@ -21,12 +25,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Dashboard to URL drilldown', function () { before(async () => { log.debug('Dashboard to URL:initTests'); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); }); it('should create dashboard to URL drilldown and use it to navigate to discover', async () => { - await PageObjects.dashboard.gotoDashboardEditMode( + await dashboard.gotoDashboardEditMode( dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME ); @@ -51,27 +55,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardDrilldownsManage.closeFlyout(); // check that drilldown notification badge is shown - expect(await PageObjects.dashboard.getPanelDrilldownCount()).to.be(2); + expect(await dashboardDrilldownPanelActions.getPanelDrilldownCount()).to.be(2); // save dashboard, navigate to view mode - await PageObjects.dashboard.saveDashboard( - dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME, - { - saveAsNew: false, - waitDialogIsClosed: true, - exitFromEditMode: true, - } - ); + await dashboard.saveDashboard(dashboardDrilldownsManage.DASHBOARD_WITH_AREA_CHART_NAME, { + saveAsNew: false, + waitDialogIsClosed: true, + exitFromEditMode: true, + }); - const originalTimeRangeDurationHours = await PageObjects.timePicker.getTimeDurationInHours(); + const originalTimeRangeDurationHours = await timePicker.getTimeDurationInHours(); await brushAreaChart(); await dashboardDrilldownPanelActions.expectMultipleActionsMenuOpened(); await dashboardDrilldownPanelActions.clickActionByText(DRILLDOWN_TO_DISCOVER_URL); - await PageObjects.discover.waitForDiscoverAppOnScreen(); + await discover.waitForDiscoverAppOnScreen(); // check that new time range duration was applied - const newTimeRangeDurationHours = await PageObjects.timePicker.getTimeDurationInHours(); + const newTimeRangeDurationHours = await timePicker.getTimeDurationInHours(); expect(newTimeRangeDurationHours).to.be.lessThan(originalTimeRangeDurationHours); // check that hours duration is more than 1 hour (meaning that the default time range of last 15 minutes has not been applied) expect(newTimeRangeDurationHours).to.be.greaterThan(1); 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 9e834b80a2130..2cf3f91c6a38e 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 @@ -14,32 +14,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const log = getService('log'); const testSubjects = getService('testSubjects'); - const reporting = getService('reporting'); + const reportingService = getService('reporting'); const dashboardAddPanel = getService('dashboardAddPanel'); const filterBar = getService('filterBar'); const find = getService('find'); const retry = getService('retry'); const toasts = getService('toasts'); - const PageObjects = getPageObjects([ + const { reporting, common, dashboard, timePicker } = getPageObjects([ 'reporting', 'common', 'dashboard', 'timePicker', - 'discover', ]); const navigateToDashboardApp = async () => { log.debug('in navigateToDashboardApp'); - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await retry.tryForTime(10000, async () => { - expect(await PageObjects.dashboard.onDashboardLandingPage()).to.be(true); + expect(await dashboard.onDashboardLandingPage()).to.be(true); }); }; const getCsvReportData = async () => { await toasts.dismissAll(); - const url = await PageObjects.reporting.getReportURL(60000); - const res = await PageObjects.reporting.getResponse(url ?? ''); + const url = await reporting.getReportURL(60000); + const res = await reporting.getResponse(url ?? ''); expect(res.status).to.equal(200); expect(res.get('content-type')).to.equal('text/csv; charset=utf-8'); @@ -69,7 +68,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Default Saved Search Data', () => { before(async () => { await esArchiver.emptyKibanaIndex(); - await reporting.initEcommerce(); + await reportingService.initEcommerce(); await kibanaServer.uiSettings.update({ 'dateFormat:tz': 'UTC' }); }); @@ -78,11 +77,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await reporting.teardownEcommerce(); + await reportingService.teardownEcommerce(); }); it('Generate CSV export of a saved search panel', async function () { - await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard - 3 Day Period'); + await dashboard.loadSavedDashboard('Ecom Dashboard - 3 Day Period'); await clickActionsMenu('EcommerceData'); await clickDownloadCsv(); @@ -92,7 +91,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Downloads a filtered CSV export of a saved search panel', async function () { - await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard - 3 Day Period'); + await dashboard.loadSavedDashboard('Ecom Dashboard - 3 Day Period'); // add a filter await filterBar.addFilter({ field: 'category', operation: 'is', value: `Men's Shoes` }); @@ -106,9 +105,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Downloads a saved search panel with a custom time range that does not intersect with dashboard time range', async function () { - await PageObjects.dashboard.loadSavedDashboard( - 'Ecom Dashboard - 3 Day Period - custom time range' - ); + await dashboard.loadSavedDashboard('Ecom Dashboard - 3 Day Period - custom time range'); await clickActionsMenu('EcommerceData'); await clickDownloadCsv(); @@ -119,7 +116,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Gets the correct filename if panel titles are hidden', async () => { - await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard Hidden Panel Titles'); + await dashboard.loadSavedDashboard('Ecom Dashboard Hidden Panel Titles'); const savedSearchPanel = await find.byCssSelector( '[data-test-embeddable-id="94eab06f-60ac-4a85-b771-3a8ed475c9bb"]' ); // panel title is hidden @@ -141,23 +138,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await esArchiver.emptyKibanaIndex(); - await reporting.initEcommerce(); + await reportingService.initEcommerce(); await kibanaServer.uiSettings.update({ 'dateFormat:tz': 'UTC' }); }); beforeEach(async () => { await navigateToDashboardApp(); log.info(`Creating empty dashboard`); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setAbsoluteRange(from, to); + await dashboard.clickNewDashboard(); + await timePicker.setAbsoluteRange(from, to); log.info(`Adding "${TEST_SEARCH_TITLE}" to dashboard`); await dashboardAddPanel.addSavedSearch(TEST_SEARCH_TITLE); - await PageObjects.dashboard.saveDashboard(TEST_DASHBOARD_TITLE); + await dashboard.saveDashboard(TEST_DASHBOARD_TITLE); }); after(async () => { - await reporting.teardownEcommerce(); - await PageObjects.common.unsetTime(); + await reportingService.teardownEcommerce(); + await common.unsetTime(); }); it('Downloads filtered Discover saved search report', async () => { @@ -175,26 +172,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await esArchiver.emptyKibanaIndex(); - await reporting.initLogs(); + await reportingService.initLogs(); await esArchiver.load('x-pack/test/functional/es_archives/reporting/hugedata'); await kibanaServer.uiSettings.update({ 'dateFormat:tz': 'UTC' }); }); beforeEach(async () => { await navigateToDashboardApp(); - await PageObjects.dashboard.loadSavedDashboard(dashboardWithScriptedFieldsSearch); - await PageObjects.timePicker.setAbsoluteRange( + await dashboard.loadSavedDashboard(dashboardWithScriptedFieldsSearch); + await timePicker.setAbsoluteRange( 'Nov 26, 1981 @ 21:54:15.526', 'Mar 5, 1982 @ 18:17:44.821' ); - await PageObjects.common.sleep(1000); + await common.sleep(1000); await filterBar.addFilter({ field: 'name.keyword', operation: 'is', value: 'Fethany' }); - await PageObjects.common.sleep(1000); + await common.sleep(1000); }); after(async () => { - await reporting.teardownLogs(); + await reportingService.teardownLogs(); await esArchiver.unload('x-pack/test/functional/es_archives/reporting/hugedata'); }); diff --git a/x-pack/test/functional/apps/dashboard/group3/reporting/screenshots.ts b/x-pack/test/functional/apps/dashboard/group3/reporting/screenshots.ts index 39420d619a91f..3f0bf511075c2 100644 --- a/x-pack/test/functional/apps/dashboard/group3/reporting/screenshots.ts +++ b/x-pack/test/functional/apps/dashboard/group3/reporting/screenshots.ts @@ -16,7 +16,7 @@ export default function ({ getService, updateBaselines, }: FtrProviderContext & { updateBaselines: boolean }) { - const PageObjects = getPageObjects(['reporting', 'common', 'dashboard', 'share']); + const { reporting, dashboard, share } = getPageObjects(['reporting', 'dashboard', 'share']); const esArchiver = getService('esArchiver'); const security = getService('security'); const browser = getService('browser'); @@ -73,7 +73,7 @@ export default function ({ ]); }); after('clean up archives', async () => { - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); await unloadEcommerce(); await es.deleteByQuery({ index: '.reporting-*', @@ -85,20 +85,20 @@ export default function ({ describe('Print PDF button', () => { afterEach(async () => { - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); }); it('is available if new', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.reporting.openExportTab(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + await reporting.openExportTab(); + expect(await reporting.isGenerateReportButtonDisabled()).to.be(null); }); it('is available when saved', async () => { - await PageObjects.dashboard.saveDashboard('My PDF Dashboard'); - await PageObjects.reporting.openExportTab(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await dashboard.saveDashboard('My PDF Dashboard'); + await reporting.openExportTab(); + expect(await reporting.isGenerateReportButtonDisabled()).to.be(null); }); }); @@ -114,18 +114,18 @@ export default function ({ // Generating and then comparing reports can take longer than the default 60s timeout because the comparePngs // function is taking about 15 seconds per comparison in jenkins. this.timeout(300000); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); - await PageObjects.reporting.openExportTab(); - await PageObjects.reporting.checkUsePrintLayout(); - await PageObjects.reporting.clickGenerateReportButton(); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('Ecom Dashboard'); + await reporting.openExportTab(); + await reporting.checkUsePrintLayout(); + await reporting.clickGenerateReportButton(); - const url = await PageObjects.reporting.getReportURL(60000); - const res = await PageObjects.reporting.getResponse(url ?? ''); + const url = await reporting.getReportURL(60000); + const res = await reporting.getResponse(url ?? ''); expect(res.status).to.equal(200); expect(res.get('content-type')).to.equal('application/pdf'); - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); }); }); @@ -138,19 +138,19 @@ export default function ({ }); it('is available if new', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.reporting.openExportTab(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + await reporting.openExportTab(); await testSubjects.click('pngV2-radioOption'); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); - await PageObjects.share.closeShareModal(); + expect(await reporting.isGenerateReportButtonDisabled()).to.be(null); + await share.closeShareModal(); }); it('is available when saved', async () => { - await PageObjects.dashboard.saveDashboard('My PNG Dash'); - await PageObjects.reporting.openExportTab(); + await dashboard.saveDashboard('My PNG Dash'); + await reporting.openExportTab(); await testSubjects.click('pngV2-radioOption'); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + expect(await reporting.isGenerateReportButtonDisabled()).to.be(null); await (await testSubjects.find('kibanaChrome')).clickMouseButton(); // close popover }); }); @@ -167,14 +167,14 @@ export default function ({ it('downloads a PDF file with saved search given EuiDataGrid enabled', async function () { await kibanaServer.uiSettings.update({ 'doc_table:legacy': false }); this.timeout(300000); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); - await PageObjects.reporting.openExportTab(); - await PageObjects.reporting.clickGenerateReportButton(); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('Ecom Dashboard'); + await reporting.openExportTab(); + await reporting.clickGenerateReportButton(); - const url = await PageObjects.reporting.getReportURL(60000); - const res = await PageObjects.reporting.getResponse(url ?? ''); - await PageObjects.share.closeShareModal(); + const url = await reporting.getReportURL(60000); + const res = await reporting.getResponse(url ?? ''); + await share.closeShareModal(); expect(res.status).to.equal(200); expect(res.get('content-type')).to.equal('application/pdf'); @@ -197,28 +197,24 @@ export default function ({ 'x-pack/test/functional/fixtures/kbn_archiver/reporting/ecommerce_76.json' ); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('[K7.6-eCommerce] Revenue Dashboard'); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('[K7.6-eCommerce] Revenue Dashboard'); - await PageObjects.reporting.openExportTab(); + await reporting.openExportTab(); await testSubjects.click('pngV2-radioOption'); - await PageObjects.reporting.forceSharedItemsContainerSize({ width: 1405 }); - await PageObjects.reporting.clickGenerateReportButton(); - await PageObjects.reporting.removeForceSharedItemsContainerSize(); + await reporting.forceSharedItemsContainerSize({ width: 1405 }); + await reporting.clickGenerateReportButton(); + await reporting.removeForceSharedItemsContainerSize(); - const url = await PageObjects.reporting.getReportURL(60000); - const reportData = await PageObjects.reporting.getRawReportData(url ?? ''); - sessionReportPath = await PageObjects.reporting.writeSessionReport( + const url = await reporting.getReportURL(60000); + const reportData = await reporting.getRawReportData(url ?? ''); + sessionReportPath = await reporting.writeSessionReport( reportFileName, 'png', reportData, REPORTS_FOLDER ); - baselinePath = PageObjects.reporting.getBaselineReportPath( - reportFileName, - 'png', - REPORTS_FOLDER - ); + baselinePath = reporting.getBaselineReportPath(reportFileName, 'png', REPORTS_FOLDER); }); after(async () => { diff --git a/x-pack/test/functional/apps/data_views/feature_controls/security.ts b/x-pack/test/functional/apps/data_views/feature_controls/security.ts index aa76093e14939..1cc62baf0abba 100644 --- a/x-pack/test/functional/apps/data_views/feature_controls/security.ts +++ b/x-pack/test/functional/apps/data_views/feature_controls/security.ts @@ -11,8 +11,8 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const security = getService('security'); - const PageObjects = getPageObjects(['common', 'settings', 'security']); + const securityService = getService('security'); + const { common, settings, security } = getPageObjects(['common', 'settings', 'security']); const appsMenu = getService('appsMenu'); const testSubjects = getService('testSubjects'); const globalNav = getService('globalNav'); @@ -29,7 +29,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('global data views all privileges', () => { before(async () => { - await security.role.create('global_index_patterns_all_role', { + await securityService.role.create('global_index_patterns_all_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -43,15 +43,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_index_patterns_all_user', { + await securityService.user.create('global_index_patterns_all_user', { password: 'global_index_patterns_all_user-password', roles: ['global_index_patterns_all_role'], full_name: 'test user', }); - await PageObjects.security.forceLogout(); + await security.forceLogout(); - await PageObjects.security.login( + await security.login( 'global_index_patterns_all_user', 'global_index_patterns_all_user-password', { @@ -60,15 +60,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ); await kibanaServer.uiSettings.replace({}); - await PageObjects.settings.navigateTo(); + await settings.navigateTo(); }); after(async () => { // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); + await security.forceLogout(); await Promise.all([ - security.role.delete('global_index_patterns_all_role'), - security.user.delete('global_index_patterns_all_user'), + securityService.role.delete('global_index_patterns_all_role'), + securityService.user.delete('global_index_patterns_all_user'), ]); }); @@ -78,7 +78,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`index pattern listing shows create button`, async () => { - await PageObjects.settings.clickKibanaIndexPatterns(); + await settings.clickKibanaIndexPatterns(); await testSubjects.existOrFail('createDataViewButton'); }); @@ -89,7 +89,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('global data views read-only privileges', () => { before(async () => { - await security.role.create('global_index_patterns_read_role', { + await securityService.role.create('global_index_patterns_read_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -103,13 +103,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_index_patterns_read_user', { + await securityService.user.create('global_index_patterns_read_user', { password: 'global_index_patterns_read_user-password', roles: ['global_index_patterns_read_role'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'global_index_patterns_read_user', 'global_index_patterns_read_user-password', { @@ -118,12 +118,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ); await kibanaServer.uiSettings.replace({}); - await PageObjects.settings.navigateTo(); + await settings.navigateTo(); }); after(async () => { - await security.role.delete('global_index_patterns_read_role'); - await security.user.delete('global_index_patterns_read_user'); + await securityService.role.delete('global_index_patterns_read_role'); + await securityService.user.delete('global_index_patterns_read_user'); }); it('shows management navlink', async () => { @@ -132,7 +132,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`index pattern listing doesn't show create button`, async () => { - await PageObjects.settings.clickKibanaIndexPatterns(); + await settings.clickKibanaIndexPatterns(); await testSubjects.existOrFail('noDataViewsPrompt'); await testSubjects.missingOrFail('createDataViewButton'); }); @@ -144,7 +144,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('no data views privileges', () => { before(async () => { - await security.role.create('no_index_patterns_privileges_role', { + await securityService.role.create('no_index_patterns_privileges_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -158,13 +158,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('no_index_patterns_privileges_user', { + await securityService.user.create('no_index_patterns_privileges_user', { password: 'no_index_patterns_privileges_user-password', roles: ['no_index_patterns_privileges_role'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'no_index_patterns_privileges_user', 'no_index_patterns_privileges_user-password', { @@ -174,8 +174,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); after(async () => { - await security.role.delete('no_index_patterns_privileges_role'); - await security.user.delete('no_index_patterns_privileges_user'); + await securityService.role.delete('no_index_patterns_privileges_role'); + await securityService.user.delete('no_index_patterns_privileges_user'); }); it('does not show Management navlink', async () => { @@ -184,7 +184,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`doesn't show Data Views in management side-nav`, async () => { - await PageObjects.common.navigateToActualUrl('management', '', { + await common.navigateToActualUrl('management', '', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); diff --git a/x-pack/test/functional/apps/data_views/feature_controls/spaces.ts b/x-pack/test/functional/apps/data_views/feature_controls/spaces.ts index 847b639370723..d1ac998f5e46a 100644 --- a/x-pack/test/functional/apps/data_views/feature_controls/spaces.ts +++ b/x-pack/test/functional/apps/data_views/feature_controls/spaces.ts @@ -12,7 +12,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const config = getService('config'); const spacesService = getService('spaces'); - const PageObjects = getPageObjects(['common', 'settings', 'security']); + const { common, settings } = getPageObjects(['common', 'settings', 'security']); const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); const kibanaServer = getService('kibanaServer'); @@ -41,7 +41,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('shows Management navlink', async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); @@ -49,8 +49,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`data views listing shows create button`, async () => { - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaIndexPatterns(); + await settings.navigateTo(); + await settings.clickKibanaIndexPatterns(); await testSubjects.existOrFail('createDataViewButton'); }); }); @@ -73,7 +73,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`redirects to management home`, async () => { - await PageObjects.common.navigateToUrl('management', 'kibana/indexPatterns', { + await common.navigateToUrl('management', 'kibana/indexPatterns', { basePath: `/s/custom_space`, ensureCurrentUrl: false, shouldLoginIfPrompted: false, diff --git a/x-pack/test/functional/apps/data_views/spaces/index.ts b/x-pack/test/functional/apps/data_views/spaces/index.ts index fa2b954c47cc6..8f9172fbe0c3b 100644 --- a/x-pack/test/functional/apps/data_views/spaces/index.ts +++ b/x-pack/test/functional/apps/data_views/spaces/index.ts @@ -8,14 +8,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ - 'common', - 'spaceSelector', - 'home', - 'header', - 'security', - 'settings', - ]); + const { settings } = getPageObjects(['settings']); const spacesService = getService('spaces'); const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); @@ -36,11 +29,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { disabledFeatures: [], }); - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaIndexPatterns(); - await PageObjects.settings.createIndexPattern('log*'); + await settings.navigateTo(); + await settings.clickKibanaIndexPatterns(); + await settings.createIndexPattern('log*'); - await PageObjects.settings.clickKibanaIndexPatterns(); + await settings.clickKibanaIndexPatterns(); // click manage spaces on first entry // first avatar is in header, so we want the second one diff --git a/x-pack/test/functional/apps/discover/async_scripted_fields.js b/x-pack/test/functional/apps/discover/async_scripted_fields.ts similarity index 71% rename from x-pack/test/functional/apps/discover/async_scripted_fields.js rename to x-pack/test/functional/apps/discover/async_scripted_fields.ts index f3ae63dd427aa..454f99f231435 100644 --- a/x-pack/test/functional/apps/discover/async_scripted_fields.js +++ b/x-pack/test/functional/apps/discover/async_scripted_fields.ts @@ -7,19 +7,19 @@ // Tests for scripted field in default distribution where async search is used import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService, getPageObjects }) { +export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); // const log = getService('log'); const retry = getService('retry'); const esArchiver = getService('esArchiver'); const log = getService('log'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { common, settings, discover, header, dashboard } = getPageObjects([ 'common', 'settings', 'discover', - 'timePicker', 'header', 'dashboard', ]); @@ -55,12 +55,12 @@ export default function ({ getService, getPageObjects }) { if (false) { /* If you had to modify the scripted fields, you could un-comment all this, run it, use es_archiver to update 'kibana_scripted_fields_on_logstash' */ - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaIndexPatterns(); - await PageObjects.settings.createIndexPattern('logsta'); - await PageObjects.settings.clickScriptedFieldsTab(); + await settings.navigateTo(); + await settings.clickKibanaIndexPatterns(); + await settings.createIndexPattern('logsta'); + await settings.clickScriptedFieldsTab(); await log.debug('add scripted field'); - await PageObjects.settings.addScriptedField( + await settings.addScriptedField( 'sharedFail', 'painless', 'string', @@ -72,8 +72,8 @@ export default function ({ getService, getPageObjects }) { ); } - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('logsta*'); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('logsta*'); await retry.try(async function () { await testSubjects.existOrFail('searchResponseWarningsEmptyPrompt'); @@ -86,18 +86,18 @@ export default function ({ getService, getPageObjects }) { 'global_discover_all', 'global_dashboard_all', ]); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('logsta*'); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('logsta*'); - await PageObjects.discover.saveSearch('search with warning'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.saveSearch('search with warning'); + await header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.addSavedSearch('search with warning'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async function () { await testSubjects.existOrFail('searchResponseWarningsBadgeToogleButton'); @@ -110,13 +110,13 @@ export default function ({ getService, getPageObjects }) { which are now saved in the esArchive. */ - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaIndexPatterns(); - await PageObjects.settings.clickIndexPatternLogstash(); - const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount()); - await PageObjects.settings.clickScriptedFieldsTab(); + await settings.navigateTo(); + await settings.clickKibanaIndexPatterns(); + await settings.clickIndexPatternLogstash(); + const startingCount = parseInt(await settings.getScriptedFieldsTabCount(), 10); + await settings.clickScriptedFieldsTab(); await log.debug('add scripted field'); - await PageObjects.settings.addScriptedField( + await settings.addScriptedField( 'goodScript', 'painless', 'string', @@ -126,12 +126,10 @@ export default function ({ getService, getPageObjects }) { "if (doc['response.raw'].value == '200') { if (doc['url.raw'].size() > 0) { return 'good ' + doc['url.raw'].value } else { return 'good' } } else { if (doc['machine.os.raw'].size() > 0) { return 'bad ' + doc['machine.os.raw'].value } else { return 'bad' } }" ); await retry.try(async function () { - expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be( - startingCount + 1 - ); + expect(parseInt(await settings.getScriptedFieldsTabCount(), 10)).to.be(startingCount + 1); }); - await PageObjects.settings.addScriptedField( + await settings.addScriptedField( 'goodScript2', 'painless', 'string', @@ -141,18 +139,16 @@ export default function ({ getService, getPageObjects }) { "if (doc['url.raw'].size() > 0) { String tempString = \"\"; for ( int i = (doc['url.raw'].value.length() - 1); i >= 0 ; i--) { tempString = tempString + (doc['url.raw'].value).charAt(i); } return tempString; } else { return \"emptyUrl\"; }" ); await retry.try(async function () { - expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be( - startingCount + 2 - ); + expect(parseInt(await settings.getScriptedFieldsTabCount(), 10)).to.be(startingCount + 2); }); } - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('logstash-*'); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('logstash-*'); await queryBar.setQuery('php* OR *jpg OR *css*'); await testSubjects.click('querySubmitButton'); await retry.tryForTime(30000, async function () { - expect(await PageObjects.discover.getHitCount()).to.be('13,301'); + expect(await discover.getHitCount()).to.be('13,301'); }); }); }); diff --git a/x-pack/test/functional/apps/discover/error_handling.ts b/x-pack/test/functional/apps/discover/error_handling.ts index cf362e8a12475..e27900064911c 100644 --- a/x-pack/test/functional/apps/discover/error_handling.ts +++ b/x-pack/test/functional/apps/discover/error_handling.ts @@ -12,7 +12,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); + const { common, discover, timePicker } = getPageObjects(['common', 'discover', 'timePicker']); describe('errors', function describeIndexTests() { before(async function () { @@ -20,8 +20,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'test/functional/fixtures/kbn_archiver/invalid_scripted_field' ); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await common.navigateToApp('discover'); }); after(async function () { @@ -31,7 +31,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // this is the same test as in OSS but it catches different error message issue in different licences describe('invalid scripted field error', () => { it('is rendered', async () => { - await PageObjects.discover.showsErrorCallout(); + await discover.showsErrorCallout(); const painlessStackTrace = await testSubjects.find('painlessStackTrace'); expect(painlessStackTrace).not.to.be(undefined); }); diff --git a/x-pack/test/functional/apps/discover/feature_controls/discover_security.ts b/x-pack/test/functional/apps/discover/feature_controls/discover_security.ts index 2d6b56c6d375f..b7496a500c386 100644 --- a/x-pack/test/functional/apps/discover/feature_controls/discover_security.ts +++ b/x-pack/test/functional/apps/discover/feature_controls/discover_security.ts @@ -20,19 +20,19 @@ export default function (ctx: FtrProviderContext) { const indexPatterns = getService('indexPatterns'); const retry = getService('retry'); const monacoEditor = getService('monacoEditor'); - const security = getService('security'); + const securityService = getService('security'); const globalNav = getService('globalNav'); - const PageObjects = getPageObjects([ - 'common', - 'error', - 'discover', - 'timePicker', - 'security', - 'share', - 'spaceSelector', - 'header', - 'unifiedFieldList', - ]); + const { common, error, discover, timePicker, security, share, header, unifiedFieldList } = + getPageObjects([ + 'common', + 'error', + 'discover', + 'timePicker', + 'security', + 'share', + 'header', + 'unifiedFieldList', + ]); const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); const kibanaServer = getService('kibanaServer'); @@ -40,7 +40,7 @@ export default function (ctx: FtrProviderContext) { const logstashIndexName = 'logstash-2015.09.22'; async function setDiscoverTimeRange() { - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); } // more tests are in x-pack/test/functional/apps/saved_query_management/feature_controls/security.ts @@ -53,13 +53,13 @@ export default function (ctx: FtrProviderContext) { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); // ensure we're logged out so we can login as the appropriate users - await PageObjects.security.forceLogout(); + await security.forceLogout(); }); after(async () => { // logout, so the other tests don't accidentally run as the custom users we're testing below // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); + await security.forceLogout(); await kibanaServer.importExport.unload( 'x-pack/test/functional/fixtures/kbn_archiver/discover/feature_controls/security' @@ -69,7 +69,7 @@ export default function (ctx: FtrProviderContext) { describe('global discover all privileges', () => { before(async () => { - await security.role.create('global_discover_all_role', { + await securityService.role.create('global_discover_all_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -83,26 +83,22 @@ export default function (ctx: FtrProviderContext) { ], }); - await security.user.create('global_discover_all_user', { + await securityService.user.create('global_discover_all_user', { password: 'global_discover_all_user-password', roles: ['global_discover_all_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'global_discover_all_user', - 'global_discover_all_user-password', - { - expectSpaceSelector: false, - } - ); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('logstash-*'); + await security.login('global_discover_all_user', 'global_discover_all_user-password', { + expectSpaceSelector: false, + }); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('logstash-*'); }); after(async () => { - await security.role.delete('global_discover_all_role'); - await security.user.delete('global_discover_all_user'); + await securityService.role.delete('global_discover_all_role'); + await securityService.user.delete('global_discover_all_user'); }); it('shows discover navlink', async () => { @@ -123,22 +119,22 @@ export default function (ctx: FtrProviderContext) { it('Shows short urls for users with the right privileges', async () => { let actualUrl: string = ''; - await PageObjects.share.clickShareTopNavButton(); + await share.clickShareTopNavButton(); const re = new RegExp( deployment.getHostPort().replace(':80', '').replace(':443', '') + '/app/r.*$' ); await retry.try(async () => { - actualUrl = await PageObjects.share.getSharedUrl(); + actualUrl = await share.getSharedUrl(); expect(actualUrl).to.match(re); - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); }); }); it('shows CSV reports', async () => { - await PageObjects.share.clickShareTopNavButton(); - await PageObjects.share.clickTab('Export'); + await share.clickShareTopNavButton(); + await share.clickTab('Export'); await testSubjects.existOrFail('generateReportButton'); - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); }); savedQuerySecurityUtils.shouldAllowSavingQueries(); @@ -146,7 +142,7 @@ export default function (ctx: FtrProviderContext) { describe('global discover read-only privileges', () => { before(async () => { - await security.role.create('global_discover_read_role', { + await securityService.role.create('global_discover_read_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -160,24 +156,20 @@ export default function (ctx: FtrProviderContext) { ], }); - await security.user.create('global_discover_read_user', { + await securityService.user.create('global_discover_read_user', { password: 'global_discover_read_user-password', roles: ['global_discover_read_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'global_discover_read_user', - 'global_discover_read_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('global_discover_read_user', 'global_discover_read_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { - await security.role.delete('global_discover_read_role'); - await security.user.delete('global_discover_read_user'); + await securityService.role.delete('global_discover_read_role'); + await securityService.user.delete('global_discover_read_user'); }); it('shows discover navlink', async () => { @@ -186,8 +178,8 @@ export default function (ctx: FtrProviderContext) { }); it(`doesn't show save button`, async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.common.waitForTopNavToBeVisible(); + await common.navigateToApp('discover'); + await common.waitForTopNavToBeVisible(); await testSubjects.existOrFail('discoverNewButton', { timeout: 10000 }); await testSubjects.missingOrFail('discoverSaveButton'); }); @@ -197,17 +189,17 @@ export default function (ctx: FtrProviderContext) { }); it(`doesn't show visualize button`, async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.common.waitForTopNavToBeVisible(); - await PageObjects.discover.selectIndexPattern('logstash-*'); + await common.navigateToApp('discover'); + await common.waitForTopNavToBeVisible(); + await discover.selectIndexPattern('logstash-*'); await setDiscoverTimeRange(); - await PageObjects.unifiedFieldList.clickFieldListItem('bytes'); - await PageObjects.unifiedFieldList.expectMissingFieldListItemVisualize('bytes'); + await unifiedFieldList.clickFieldListItem('bytes'); + await unifiedFieldList.expectMissingFieldListItemVisualize('bytes'); }); it('should allow for copying the snapshot URL', async function () { - await PageObjects.share.clickShareTopNavButton(); - const actualUrl = await PageObjects.share.getSharedUrl(); + await share.clickShareTopNavButton(); + const actualUrl = await share.getSharedUrl(); expect(actualUrl).to.contain(`?l=${DISCOVER_APP_LOCATOR}`); const urlSearchParams = new URLSearchParams(actualUrl); expect(JSON.parse(decompressFromBase64(urlSearchParams.get('lz')!)!)).to.eql({ @@ -229,18 +221,18 @@ export default function (ctx: FtrProviderContext) { pause: true, }, }); - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); }); it(`Doesn't show short urls for users without those privileges`, async () => { - await PageObjects.share.clickShareTopNavButton(); + await share.clickShareTopNavButton(); let actualUrl: string = ''; await retry.try(async () => { - actualUrl = await PageObjects.share.getSharedUrl(); + actualUrl = await share.getSharedUrl(); // only shows in long urls expect(actualUrl).to.contain(DISCOVER_APP_LOCATOR); - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); }); }); savedQuerySecurityUtils.shouldDisallowSavingButAllowLoadingSavedQueries(); @@ -248,7 +240,7 @@ export default function (ctx: FtrProviderContext) { describe('discover read-only privileges with url_create', () => { before(async () => { - await security.role.create('global_discover_read_url_create_role', { + await securityService.role.create('global_discover_read_url_create_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -262,13 +254,13 @@ export default function (ctx: FtrProviderContext) { ], }); - await security.user.create('global_discover_read_url_create_user', { + await securityService.user.create('global_discover_read_url_create_user', { password: 'global_discover_read_url_create_user-password', roles: ['global_discover_read_url_create_role'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'global_discover_read_url_create_user', 'global_discover_read_url_create_user-password', { @@ -278,8 +270,8 @@ export default function (ctx: FtrProviderContext) { }); after(async () => { - await security.user.delete('global_discover_read_url_create_user'); - await security.role.delete('global_discover_read_url_create_role'); + await securityService.user.delete('global_discover_read_url_create_user'); + await securityService.role.delete('global_discover_read_url_create_role'); }); it('shows discover navlink', async () => { @@ -288,8 +280,8 @@ export default function (ctx: FtrProviderContext) { }); it(`doesn't show save button`, async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.common.waitForTopNavToBeVisible(); + await common.navigateToApp('discover'); + await common.waitForTopNavToBeVisible(); await testSubjects.existOrFail('discoverNewButton', { timeout: 10000 }); await testSubjects.missingOrFail('discoverSaveButton'); }); @@ -299,23 +291,23 @@ export default function (ctx: FtrProviderContext) { }); it(`doesn't show visualize button`, async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.common.waitForTopNavToBeVisible(); + await common.navigateToApp('discover'); + await common.waitForTopNavToBeVisible(); await setDiscoverTimeRange(); - await PageObjects.unifiedFieldList.clickFieldListItem('bytes'); - await PageObjects.unifiedFieldList.expectMissingFieldListItemVisualize('bytes'); + await unifiedFieldList.clickFieldListItem('bytes'); + await unifiedFieldList.expectMissingFieldListItemVisualize('bytes'); }); it('Shows short urls for users with the right privileges', async () => { - await PageObjects.share.clickShareTopNavButton(); + await share.clickShareTopNavButton(); let actualUrl: string = ''; const re = new RegExp( deployment.getHostPort().replace(':80', '').replace(':443', '') + '/app/r.*$' ); await retry.try(async () => { - actualUrl = await PageObjects.share.getSharedUrl(); + actualUrl = await share.getSharedUrl(); expect(actualUrl).to.match(re); - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); }); }); @@ -324,7 +316,7 @@ export default function (ctx: FtrProviderContext) { describe('discover and visualize privileges', () => { before(async () => { - await security.role.create('global_discover_visualize_read_role', { + await securityService.role.create('global_discover_visualize_read_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -339,13 +331,13 @@ export default function (ctx: FtrProviderContext) { ], }); - await security.user.create('global_discover_visualize_read_user', { + await securityService.user.create('global_discover_visualize_read_user', { password: 'global_discover_visualize_read_user-password', roles: ['global_discover_visualize_read_role'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'global_discover_visualize_read_user', 'global_discover_visualize_read_user-password', { @@ -355,22 +347,22 @@ export default function (ctx: FtrProviderContext) { }); after(async () => { - await security.role.delete('global_discover_visualize_read_role'); - await security.user.delete('global_discover_visualize_read_user'); + await securityService.role.delete('global_discover_visualize_read_role'); + await securityService.user.delete('global_discover_visualize_read_user'); }); it(`shows the visualize button`, async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.common.waitForTopNavToBeVisible(); + await common.navigateToApp('discover'); + await common.waitForTopNavToBeVisible(); await setDiscoverTimeRange(); - await PageObjects.unifiedFieldList.clickFieldListItem('bytes'); - await PageObjects.unifiedFieldList.expectFieldListItemVisualize('bytes'); + await unifiedFieldList.clickFieldListItem('bytes'); + await unifiedFieldList.expectFieldListItemVisualize('bytes'); }); }); describe('no discover privileges', () => { before(async () => { - await security.role.create('no_discover_privileges_role', { + await securityService.role.create('no_discover_privileges_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -384,7 +376,7 @@ export default function (ctx: FtrProviderContext) { ], }); - await security.user.create('no_discover_privileges_user', { + await securityService.user.create('no_discover_privileges_user', { password: 'no_discover_privileges_user-password', roles: ['no_discover_privileges_role'], full_name: 'test user', @@ -392,13 +384,13 @@ export default function (ctx: FtrProviderContext) { // Navigate home before attempting to login or we may get redirected to // Discover with a forbidden error, which hides the chrome and causes - // PageObjects.security.login to fail when checking for the logout button - await PageObjects.common.navigateToUrl('home', '', { + // security.login to fail when checking for the logout button + await common.navigateToUrl('home', '', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.security.login( + await security.login( 'no_discover_privileges_user', 'no_discover_privileges_user-password', { @@ -408,17 +400,17 @@ export default function (ctx: FtrProviderContext) { }); after(async () => { - await security.role.delete('no_discover_privileges_role'); - await security.user.delete('no_discover_privileges_user'); + await securityService.role.delete('no_discover_privileges_role'); + await securityService.user.delete('no_discover_privileges_user'); }); it('shows 403', async () => { - await PageObjects.common.navigateToUrl('discover', '', { + await common.navigateToUrl('discover', '', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); await retry.try(async () => { - await PageObjects.error.expectForbidden(); + await error.expectForbidden(); }); }); }); @@ -441,7 +433,7 @@ export default function (ctx: FtrProviderContext) { { override: true } ); - await security.role.create('discover_only_data_views_role', { + await securityService.role.create('discover_only_data_views_role', { elasticsearch: { indices: [ { names: ['alias-logstash-discover'], privileges: ['read', 'view_index_metadata'] }, @@ -457,13 +449,13 @@ export default function (ctx: FtrProviderContext) { ], }); - await security.user.create('discover_only_data_views_user', { + await securityService.user.create('discover_only_data_views_user', { password: 'discover_only_data_views_user-password', roles: ['discover_only_data_views_role'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'discover_only_data_views_user', 'discover_only_data_views_user-password', { @@ -471,7 +463,7 @@ export default function (ctx: FtrProviderContext) { } ); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); after(async () => { @@ -487,25 +479,25 @@ export default function (ctx: FtrProviderContext) { }) .expect(200); - await security.role.delete('discover_only_data_views_role'); - await security.user.delete('discover_only_data_views_user'); + await securityService.role.delete('discover_only_data_views_role'); + await securityService.user.delete('discover_only_data_views_user'); }); it('allows to access only via a permitted index alias', async () => { await globalNav.badgeExistsOrFail('Read only'); // can't access logstash index directly - await PageObjects.discover.selectIndexPattern('logstash-*'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectIndexPattern('logstash-*'); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('discoverNoResultsCheckIndices'); // but can access via a permitted alias for the logstash index - await PageObjects.discover.selectIndexPattern('alias-logstash-discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectIndexPattern('alias-logstash-discover'); + await header.waitUntilLoadingHasFinished(); await setDiscoverTimeRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.missingOrFail('discoverNoResultsCheckIndices'); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await discover.waitForDocTableLoadingComplete(); // expand a row await dataGrid.clickRowToggle(); diff --git a/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts b/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts index af10d98352128..0c0b11616e94b 100644 --- a/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts +++ b/x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts @@ -12,13 +12,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const config = getService('config'); const spacesService = getService('spaces'); - const PageObjects = getPageObjects([ + const { common, error, timePicker, unifiedFieldList } = getPageObjects([ 'common', 'error', - 'discover', 'timePicker', - 'security', - 'spaceSelector', 'unifiedFieldList', ]); const testSubjects = getService('testSubjects'); @@ -26,7 +23,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); async function setDiscoverTimeRange() { - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); } describe('spaces', () => { @@ -64,7 +61,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('shows discover navlink', async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); @@ -72,7 +69,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('shows save button', async () => { - await PageObjects.common.navigateToApp('discover', { + await common.navigateToApp('discover', { basePath: '/s/custom_space', }); await testSubjects.existOrFail('discoverSaveButton', { @@ -81,12 +78,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('shows "visualize" field button', async () => { - await PageObjects.common.navigateToApp('discover', { + await common.navigateToApp('discover', { basePath: '/s/custom_space', }); await setDiscoverTimeRange(); - await PageObjects.unifiedFieldList.clickFieldListItem('bytes'); - await PageObjects.unifiedFieldList.expectFieldListItemVisualize('bytes'); + await unifiedFieldList.clickFieldListItem('bytes'); + await unifiedFieldList.expectFieldListItemVisualize('bytes'); }); }); @@ -112,7 +109,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`doesn't show discover navlink`, async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); @@ -120,13 +117,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`shows 404`, async () => { - await PageObjects.common.navigateToUrl('discover', '', { + await common.navigateToUrl('discover', '', { basePath: '/s/custom_space', shouldLoginIfPrompted: false, ensureCurrentUrl: false, useActualUrl: true, }); - await PageObjects.error.expectNotFound(); + await error.expectNotFound(); }); }); @@ -151,12 +148,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('Does not show the "visualize" field button', async () => { - await PageObjects.common.navigateToApp('discover', { + await common.navigateToApp('discover', { basePath: '/s/custom_space', }); await setDiscoverTimeRange(); - await PageObjects.unifiedFieldList.clickFieldListItem('bytes'); - await PageObjects.unifiedFieldList.expectMissingFieldListItemVisualize('bytes'); + await unifiedFieldList.clickFieldListItem('bytes'); + await unifiedFieldList.expectMissingFieldListItemVisualize('bytes'); }); }); @@ -177,7 +174,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('shows empty prompt when no data views exist', async () => { - await PageObjects.common.navigateToUrl('discover', '', { + await common.navigateToUrl('discover', '', { basePath: '/s/custom_space_no_index_patterns', ensureCurrentUrl: false, shouldUseHashForSubUrl: false, diff --git a/x-pack/test/functional/apps/discover/preserve_url.ts b/x-pack/test/functional/apps/discover/preserve_url.ts index 278f1928335ec..f7a5623d01220 100644 --- a/x-pack/test/functional/apps/discover/preserve_url.ts +++ b/x-pack/test/functional/apps/discover/preserve_url.ts @@ -9,7 +9,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'discover', 'spaceSelector', 'header']); + const { common, discover, spaceSelector, header } = getPageObjects([ + 'common', + 'discover', + 'spaceSelector', + 'header', + ]); const globalNav = getService('globalNav'); const kibanaServer = getService('kibanaServer'); const spacesService = getService('spaces'); @@ -33,44 +38,44 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('goes back to last opened url', async function () { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.saveSearch('A Search'); - await PageObjects.common.navigateToApp('home'); - await PageObjects.header.clickDiscover(); + await common.navigateToApp('discover'); + await discover.saveSearch('A Search'); + await common.navigateToApp('home'); + await header.clickDiscover(); const activeTitle = await globalNav.getLastBreadcrumb(); expect(activeTitle).to.be('A Search'); }); it('remembers url after switching spaces', async function () { // default space - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.loadSavedSearch('A Search'); + await common.navigateToApp('discover'); + await discover.loadSavedSearch('A Search'); - await PageObjects.spaceSelector.openSpacesNav(); - await PageObjects.spaceSelector.clickSpaceAvatar('another-space'); - await PageObjects.spaceSelector.expectHomePage('another-space'); + await spaceSelector.openSpacesNav(); + await spaceSelector.clickSpaceAvatar('another-space'); + await spaceSelector.expectHomePage('another-space'); // other space - await PageObjects.header.clickDiscover(); - await PageObjects.discover.saveSearch('A Search in another space'); + await header.clickDiscover(); + await discover.saveSearch('A Search in another space'); - await PageObjects.spaceSelector.openSpacesNav(); - await PageObjects.spaceSelector.clickSpaceAvatar('default'); - await PageObjects.spaceSelector.expectHomePage('default'); + await spaceSelector.openSpacesNav(); + await spaceSelector.clickSpaceAvatar('default'); + await spaceSelector.expectHomePage('default'); // default space - await PageObjects.header.clickDiscover(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.clickDiscover(); + await discover.waitUntilSearchingHasFinished(); const activeTitleDefaultSpace = await globalNav.getLastBreadcrumb(); expect(activeTitleDefaultSpace).to.be('A Search'); - await PageObjects.spaceSelector.openSpacesNav(); - await PageObjects.spaceSelector.clickSpaceAvatar('another-space'); - await PageObjects.spaceSelector.expectHomePage('another-space'); + await spaceSelector.openSpacesNav(); + await spaceSelector.clickSpaceAvatar('another-space'); + await spaceSelector.expectHomePage('another-space'); // other space - await PageObjects.header.clickDiscover(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.clickDiscover(); + await discover.waitUntilSearchingHasFinished(); const activeTitleOtherSpace = await globalNav.getLastBreadcrumb(); expect(activeTitleOtherSpace).to.be('A Search in another space'); }); diff --git a/x-pack/test/functional/apps/discover/reporting.ts b/x-pack/test/functional/apps/discover/reporting.ts index 41882ef130790..b86d30efe984f 100644 --- a/x-pack/test/functional/apps/discover/reporting.ts +++ b/x-pack/test/functional/apps/discover/reporting.ts @@ -18,7 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const browser = getService('browser'); const retry = getService('retry'); - const PageObjects = getPageObjects([ + const { reporting, common, discover, timePicker, share, header } = getPageObjects([ 'reporting', 'common', 'discover', @@ -40,11 +40,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // close any open notification toasts await toasts.dismissAll(); - await PageObjects.reporting.openExportTab(); - await PageObjects.reporting.clickGenerateReportButton(); + await reporting.openExportTab(); + await reporting.clickGenerateReportButton(); - const url = await PageObjects.reporting.getReportURL(timeout); - const res = await PageObjects.reporting.getResponse(url ?? ''); + const url = await reporting.getReportURL(timeout); + const res = await reporting.getResponse(url ?? ''); expect(res.status).to.equal(200); expect(res.get('content-type')).to.equal('text/csv; charset=utf-8'); @@ -56,8 +56,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => { await esArchiver.emptyKibanaIndex(); await reportingAPI.initEcommerce(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('ecommerce'); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('ecommerce'); }); after(async () => { @@ -66,16 +66,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('is available if new', async () => { - await PageObjects.reporting.openExportTab(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); - await PageObjects.share.closeShareModal(); + await reporting.openExportTab(); + expect(await reporting.isGenerateReportButtonDisabled()).to.be(null); + await share.closeShareModal(); }); it('becomes available when saved', async () => { - await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton'); - await PageObjects.reporting.openExportTab(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); - await PageObjects.share.closeShareModal(); + await discover.saveSearch('my search - expectEnabledGenerateReportButton'); + await reporting.openExportTab(); + expect(await reporting.isGenerateReportButtonDisabled()).to.be(null); + await share.closeShareModal(); }); }); @@ -99,21 +99,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('ecommerce'); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('ecommerce'); }); it('generates a report with single timefilter', async () => { - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.timePicker.setCommonlyUsedTime('Last_24 hours'); - await PageObjects.discover.saveSearch('single-timefilter-search'); + await discover.clickNewSearchButton(); + await timePicker.setCommonlyUsedTime('Last_24 hours'); + await discover.saveSearch('single-timefilter-search'); // get shared URL value const sharedURL = await browser.getCurrentUrl(); // click 'Copy POST URL' - await PageObjects.share.clickShareTopNavButton(); - await PageObjects.reporting.openExportTab(); + await share.clickShareTopNavButton(); + await reporting.openExportTab(); const copyButton = await testSubjects.find('shareReportingCopyURL'); const reportURL = decodeURIComponent( (await copyButton.getAttribute('data-share-url')) ?? '' @@ -141,10 +141,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('generates a report from a new search with data: default', async () => { - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.reporting.setTimepickerInEcommerceDataRange(); + await discover.clickNewSearchButton(); + await reporting.setTimepickerInEcommerceDataRange(); - await PageObjects.discover.saveSearch('my search - with data - expectReportCanBeCreated'); + await discover.saveSearch('my search - with data - expectReportCanBeCreated'); const res = await getReport(); expect(res.status).to.equal(200); @@ -155,8 +155,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('generates a report with no data', async () => { - await PageObjects.reporting.setTimepickerInEcommerceNoDataRange(); - await PageObjects.discover.saveSearch('my search - no data - expectReportCanBeCreated'); + await reporting.setTimepickerInEcommerceNoDataRange(); + await discover.saveSearch('my search - no data - expectReportCanBeCreated'); const res = await getReport(); expect(res.text).to.be(`\n`); @@ -165,12 +165,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('generates a large export', async () => { const fromTime = 'Apr 27, 2019 @ 23:56:51.374'; const toTime = 'Aug 23, 2019 @ 16:18:51.821'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); - await PageObjects.discover.clickNewSearchButton(); + await timePicker.setAbsoluteRange(fromTime, toTime); + await discover.clickNewSearchButton(); await retry.try(async () => { - expect(await PageObjects.discover.getHitCount()).to.equal('4,675'); + expect(await discover.getHitCount()).to.equal('4,675'); }); - await PageObjects.discover.saveSearch('large export'); + await discover.saveSearch('large export'); // match file length, the beginning and the end of the csv file contents const { text: csvFile } = await getReport({ timeout: 80 * 1000 }); @@ -180,12 +180,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('generate a report using ES|QL', async () => { - await PageObjects.discover.selectTextBaseLang(); + await discover.selectTextBaseLang(); const testQuery = `from ecommerce | STATS total_sales = SUM(taxful_total_price) BY day_of_week | SORT total_sales DESC`; await monacoEditor.setCodeEditorValue(testQuery); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const res = await getReport(); expect(res.status).to.equal(200); @@ -249,8 +249,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await reset(); await createDocs(); await reportingAPI.initLogs(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.loadSavedSearch('Sparse Columns'); + await common.navigateToApp('discover'); + await discover.loadSavedSearch('Sparse Columns'); }); after(async () => { @@ -261,9 +261,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { beforeEach(async () => { const fromTime = 'Jan 10, 2005 @ 00:00:00.000'; const toTime = 'Dec 23, 2006 @ 00:00:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await timePicker.setAbsoluteRange(fromTime, toTime); await retry.try(async () => { - expect(await PageObjects.discover.getHitCount()).to.equal(TEST_DOC_COUNT.toString()); + expect(await discover.getHitCount()).to.equal(TEST_DOC_COUNT.toString()); }); }); @@ -281,13 +281,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const setupPage = async () => { const fromTime = 'Jun 22, 2019 @ 00:00:00.000'; const toTime = 'Jun 26, 2019 @ 23:30:00.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await timePicker.setAbsoluteRange(fromTime, toTime); }; before(async () => { await reportingAPI.initEcommerce(); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('ecommerce'); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('ecommerce'); }); after(async () => { @@ -299,13 +299,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); afterEach(async () => { - await PageObjects.reporting.checkForReportingToasts(); + await reporting.checkForReportingToasts(); }); it('generates a report with data', async () => { - await PageObjects.discover.loadSavedSearch('Ecommerce Data'); + await discover.loadSavedSearch('Ecommerce Data'); await retry.try(async () => { - expect(await PageObjects.discover.getHitCount()).to.equal('740'); + expect(await discover.getHitCount()).to.equal('740'); }); const { text: csvFile } = await getReport(); @@ -313,15 +313,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('generates a report with filtered data', async () => { - await PageObjects.discover.loadSavedSearch('Ecommerce Data'); + await discover.loadSavedSearch('Ecommerce Data'); await retry.try(async () => { - expect(await PageObjects.discover.getHitCount()).to.equal('740'); + expect(await discover.getHitCount()).to.equal('740'); }); // filter await filterBar.addFilter({ field: 'category', operation: 'is', value: `Men's Shoes` }); await retry.try(async () => { - expect(await PageObjects.discover.getHitCount()).to.equal('154'); + expect(await discover.getHitCount()).to.equal('154'); }); const { text: csvFile } = await getReport(); @@ -329,10 +329,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('generates a report with discover:searchFieldsFromSource = true', async () => { - await PageObjects.discover.loadSavedSearch('Ecommerce Data'); + await discover.loadSavedSearch('Ecommerce Data'); await retry.try(async () => { - expect(await PageObjects.discover.getHitCount()).to.equal('740'); + expect(await discover.getHitCount()).to.equal('740'); }); await setFieldsFromSource(true); diff --git a/x-pack/test/functional/apps/discover/saved_queries.ts b/x-pack/test/functional/apps/discover/saved_queries.ts index 3daf70e3f560c..5f7df1348e6e2 100644 --- a/x-pack/test/functional/apps/discover/saved_queries.ts +++ b/x-pack/test/functional/apps/discover/saved_queries.ts @@ -12,9 +12,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const spaces = getService('spaces'); - const PageObjects = getPageObjects([ + const { common, settings, shareSavedObjectsToSpace } = getPageObjects([ 'common', - 'discover', 'settings', 'shareSavedObjectsToSpace', ]); @@ -48,7 +47,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Manage saved queries', () => { it('delete saved query shared in multiple spaces', async () => { // Navigate to Discover & create a saved query - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await queryBar.setQuery('response:200'); await queryBar.submitQuery(); await savedQueryManagementComponent.saveNewQuery(savedQueryName, '', true, false); @@ -56,16 +55,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await savedQueryManagementComponent.closeSavedQueryManagementComponent(); // Navigate to settings & share the saved query between multiple spaces - await PageObjects.common.navigateToApp('settings'); - await PageObjects.settings.clickKibanaSavedObjects(); - await PageObjects.shareSavedObjectsToSpace.openShareToSpaceFlyoutForObject(savedQueryName); - await PageObjects.shareSavedObjectsToSpace.setupForm({ + await common.navigateToApp('settings'); + await settings.clickKibanaSavedObjects(); + await shareSavedObjectsToSpace.openShareToSpaceFlyoutForObject(savedQueryName); + await shareSavedObjectsToSpace.setupForm({ destinationSpaceId, }); - await PageObjects.shareSavedObjectsToSpace.saveShare(); + await shareSavedObjectsToSpace.saveShare(); // Navigate back to Discover and delete the query - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await savedQueryManagementComponent.deleteSavedQuery(savedQueryName); // Refresh to ensure the object is actually deleted @@ -77,7 +76,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const name = `${savedQueryName}-update`; // Navigate to Discover & create a saved query - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await queryBar.setQuery('response:200'); await queryBar.submitQuery(); await savedQueryManagementComponent.saveNewQuery(name, '', true, false); @@ -90,7 +89,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await savedQueryManagementComponent.updateCurrentlyLoadedQuery('', true, false); // Navigate to Discover ensure updated query exists - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await savedQueryManagementComponent.savedQueryExistOrFail(name); await savedQueryManagementComponent.closeSavedQueryManagementComponent(); await savedQueryManagementComponent.deleteSavedQuery(name); diff --git a/x-pack/test/functional/apps/discover/saved_search_embeddable.ts b/x-pack/test/functional/apps/discover/saved_search_embeddable.ts index 3f3f58dcdaf16..ea00343628258 100644 --- a/x-pack/test/functional/apps/discover/saved_search_embeddable.ts +++ b/x-pack/test/functional/apps/discover/saved_search_embeddable.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker', 'discover']); + const { common, dashboard, header } = getPageObjects(['common', 'dashboard', 'header']); describe('discover saved search embeddable', () => { before(async () => { @@ -30,7 +30,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.common.setTime({ + await common.setTime({ from: 'Sep 22, 2015 @ 00:00:00.000', to: 'Sep 23, 2015 @ 00:00:00.000', }); @@ -38,29 +38,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); beforeEach(async () => { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await filterBar.ensureFieldEditorModalIsClosed(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); }); const addSearchEmbeddableToDashboard = async (title = 'Rendering-Test:-saved-search') => { await dashboardAddPanel.addSavedSearch(title); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); const rows = await dataGrid.getDocTableRows(); expect(rows.length).to.be.above(0); }; const refreshDashboardPage = async (requireRenderComplete = false) => { await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); if (requireRenderComplete) { - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); } }; @@ -90,7 +90,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ], }); await addSearchEmbeddableToDashboard(searchTitle); - await PageObjects.dashboard.saveDashboard('Dashboard with deleted saved search', { + await dashboard.saveDashboard('Dashboard with deleted saved search', { waitDialogIsClosed: true, exitFromEditMode: false, saveAsNew: true, @@ -101,9 +101,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await refreshDashboardPage(); await testSubjects.existOrFail('embeddableError'); - const panels = await PageObjects.dashboard.getDashboardPanels(); + const panels = await dashboard.getDashboardPanels(); await dashboardPanelActions.removePanel(panels[0]); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.missingOrFail('embeddableError'); }); }); diff --git a/x-pack/test/functional/apps/discover/saved_searches.ts b/x-pack/test/functional/apps/discover/saved_searches.ts index ef4d3890d3145..3b039c8da9eee 100644 --- a/x-pack/test/functional/apps/discover/saved_searches.ts +++ b/x-pack/test/functional/apps/discover/saved_searches.ts @@ -11,7 +11,12 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'header', 'discover', 'timePicker', 'dashboard']); + const { common, header, discover, dashboard } = getPageObjects([ + 'common', + 'header', + 'discover', + 'dashboard', + ]); const dashboardAddPanel = getService('dashboardAddPanel'); const dataGrid = getService('dataGrid'); const panelActions = getService('dashboardPanelActions'); @@ -35,7 +40,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.importExport.load(ecommerceSOPath); await kibanaServer.uiSettings.update(defaultSettings); - await PageObjects.common.setTime({ from, to }); + await common.setTime({ from, to }); }); after('clean up archives', async () => { @@ -43,13 +48,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover'); await kibanaServer.importExport.unload(ecommerceSOPath); await kibanaServer.uiSettings.unset('doc_table:legacy'); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); describe('Customize time range', () => { it('should be possible to customize time range for saved searches on dashboards', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.addSavedSearch('Ecommerce Data'); expect(await dataGrid.getDocCount()).to.be(500); @@ -63,41 +68,41 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardCustomizePanel.clickCommonlyUsedTimeRange('Last_90 days'); await dashboardCustomizePanel.clickSaveButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect(await dataGrid.hasNoResults()).to.be(true); }); }); it(`should unselect saved search when navigating to a 'new'`, async function () { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('ecommerce'); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('ecommerce'); await filterBar.addFilter({ field: 'category', operation: 'is', value: `Men's Shoes` }); await queryBar.setQuery('customer_gender:MALE'); await queryBar.submitQuery(); - await PageObjects.discover.saveSearch('test-unselect-saved-search'); + await discover.saveSearch('test-unselect-saved-search'); expect(await filterBar.hasFilter('category', `Men's Shoes`)).to.be(true); expect(await queryBar.getQueryString()).to.eql('customer_gender:MALE'); - await PageObjects.discover.clickNewSearchButton(); + await discover.clickNewSearchButton(); expect(await testSubjects.getVisibleText('discover-dataView-switch-link')).to.be('ecommerce'); expect(await filterBar.hasFilter('category', `Men's Shoes`)).to.be(false); expect(await queryBar.getQueryString()).to.eql(''); - await PageObjects.discover.selectIndexPattern('logstash-*'); + await discover.selectIndexPattern('logstash-*'); expect(await filterBar.hasFilter('category', `Men's Shoes`)).to.be(false); expect(await queryBar.getQueryString()).to.eql(''); - await PageObjects.discover.selectIndexPattern('ecommerce'); + await discover.selectIndexPattern('ecommerce'); expect(await filterBar.hasFilter('category', `Men's Shoes`)).to.be(false); expect(await queryBar.getQueryString()).to.eql(''); - await PageObjects.discover.clickNewSearchButton(); + await discover.clickNewSearchButton(); expect(await testSubjects.getVisibleText('discover-dataView-switch-link')).to.be('ecommerce'); }); }); diff --git a/x-pack/test/functional/apps/discover/value_suggestions.ts b/x-pack/test/functional/apps/discover/value_suggestions.ts index 8d0c0ac5a969a..f949a890d90c2 100644 --- a/x-pack/test/functional/apps/discover/value_suggestions.ts +++ b/x-pack/test/functional/apps/discover/value_suggestions.ts @@ -14,15 +14,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const queryBar = getService('queryBar'); const filterBar = getService('filterBar'); const dataGrid = getService('dataGrid'); - const PageObjects = getPageObjects(['common', 'timePicker', 'settings', 'context']); + const { common, timePicker, settings, context } = getPageObjects([ + 'common', + 'timePicker', + 'settings', + 'context', + ]); async function setAutocompleteUseTimeRange(value: boolean) { - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSettings(); - await PageObjects.settings.toggleAdvancedSettingCheckbox( - UI_SETTINGS.AUTOCOMPLETE_USE_TIMERANGE, - value - ); + await settings.navigateTo(); + await settings.clickKibanaSettings(); + await settings.toggleAdvancedSettingCheckbox(UI_SETTINGS.AUTOCOMPLETE_USE_TIMERANGE, value); } describe('value suggestions', function describeIndexTests() { @@ -36,12 +38,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.update({ 'doc_table:legacy': false, }); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); after(async () => { await kibanaServer.uiSettings.unset('doc_table:legacy'); - await PageObjects.common.unsetTime(); + await common.unsetTime(); await kibanaServer.savedObjects.cleanStandardList(); }); @@ -51,7 +53,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); describe('discover', () => { @@ -60,7 +62,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('dont show up if outside of range', async () => { - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Mar 1, 2020 @ 00:00:00.000', 'Nov 1, 2020 @ 00:00:00.000' ); @@ -70,13 +72,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('show up if in range', async () => { - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); await queryBar.setQuery('extension.raw : '); await queryBar.expectSuggestions({ count: 5, contains: '"jpg"' }); }); it('also displays descriptions for operators', async () => { - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); await queryBar.setQuery('extension.raw'); await queryBar.expectSuggestionsDescription({ count: 2 }); }); @@ -89,13 +91,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('shows all autosuggest options for a filter in discover context app', async () => { // Set a good time range - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); // navigate to context await dataGrid.clickRowToggle({ rowIndex: 0 }); const rowActions = await dataGrid.getRowActions({ rowIndex: 0 }); await rowActions[1].click(); - await PageObjects.context.waitUntilContextLoadingHasFinished(); + await context.waitUntilContextLoadingHasFinished(); // Apply filter in context view await filterBar.addFilter({ field: 'geo.dest', operation: 'is', value: 'US' }); @@ -109,7 +111,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); }); afterEach(async () => { @@ -117,13 +119,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSettings(); - await PageObjects.settings.clearAdvancedSettings(UI_SETTINGS.AUTOCOMPLETE_USE_TIMERANGE); + await settings.navigateTo(); + await settings.clickKibanaSettings(); + await settings.clearAdvancedSettings(UI_SETTINGS.AUTOCOMPLETE_USE_TIMERANGE); }); it('DO show up if outside of range', async () => { - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Mar 1, 2020 @ 00:00:00.000', 'Nov 1, 2020 @ 00:00:00.000' ); @@ -133,7 +135,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('show up', async () => { - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); await queryBar.setQuery('extension.raw : '); await queryBar.expectSuggestions({ count: 5, contains: '"jpg"' }); }); diff --git a/x-pack/test/functional/apps/discover/value_suggestions_non_timebased.ts b/x-pack/test/functional/apps/discover/value_suggestions_non_timebased.ts index 7d8f8a302b05c..b40c74bf06e41 100644 --- a/x-pack/test/functional/apps/discover/value_suggestions_non_timebased.ts +++ b/x-pack/test/functional/apps/discover/value_suggestions_non_timebased.ts @@ -11,7 +11,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const queryBar = getService('queryBar'); - const PageObjects = getPageObjects(['common', 'settings', 'context', 'header']); + const { common } = getPageObjects(['common']); describe('value suggestions non time based', function describeIndexTests() { before(async function () { @@ -38,7 +38,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('shows all autosuggest options for a filter in discover context app', async () => { - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await queryBar.setQuery('type.keyword : '); await queryBar.expectSuggestions({ count: 1, contains: '"apache"' }); }); diff --git a/x-pack/test/functional/apps/discover/visualize_field.ts b/x-pack/test/functional/apps/discover/visualize_field.ts index eca02426e06d1..1b7e3dd1eb566 100644 --- a/x-pack/test/functional/apps/discover/visualize_field.ts +++ b/x-pack/test/functional/apps/discover/visualize_field.ts @@ -18,11 +18,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const retry = getService('retry'); const kibanaServer = getService('kibanaServer'); const dataViews = getService('dataViews'); - const PageObjects = getPageObjects([ + const { common, discover, timePicker, lens, header, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'timePicker', - 'unifiedSearch', 'lens', 'header', 'unifiedFieldList', @@ -36,7 +35,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }; async function setDiscoverTimeRange() { - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await timePicker.setDefaultAbsoluteRange(); } function assertMatchesExpectedData(state: DebugState) { @@ -58,7 +57,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await kibanaServer.importExport.load( 'x-pack/test/functional/fixtures/kbn_archiver/lens/lens_basic.json' ); - await PageObjects.common.navigateToApp('discover'); + await common.navigateToApp('discover'); await setDiscoverTimeRange(); }); @@ -70,14 +69,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('shows "visualize" field button', async () => { - await PageObjects.unifiedFieldList.clickFieldListItem('bytes'); - await PageObjects.unifiedFieldList.expectFieldListItemVisualize('bytes'); + await unifiedFieldList.clickFieldListItem('bytes'); + await unifiedFieldList.expectFieldListItemVisualize('bytes'); }); it('visualizes field to Lens and loads fields to the dimesion editor', async () => { - await PageObjects.unifiedFieldList.findFieldByName('bytes'); - await PageObjects.unifiedFieldList.clickFieldListItemVisualize('bytes'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.findFieldByName('bytes'); + await unifiedFieldList.clickFieldListItemVisualize('bytes'); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { const dimensions = await testSubjects.findAll('lns-dimensionTrigger'); expect(dimensions).to.have.length(2); @@ -91,9 +90,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { operation: 'is between', value: { from: '3500', to: '4000' }, }); - await PageObjects.unifiedFieldList.findFieldByName('geo.src'); - await PageObjects.unifiedFieldList.clickFieldListItemVisualize('geo.src'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.findFieldByName('geo.src'); + await unifiedFieldList.clickFieldListItemVisualize('geo.src'); + await header.waitUntilLoadingHasFinished(); expect(await filterBar.hasFilter('bytes', '3,500 to 4,000')).to.be(true); }); @@ -101,18 +100,18 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('should preserve query in lens', async () => { await queryBar.setQuery('machine.os : ios'); await queryBar.submitQuery(); - await PageObjects.unifiedFieldList.findFieldByName('geo.dest'); - await PageObjects.unifiedFieldList.clickFieldListItemVisualize('geo.dest'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedFieldList.findFieldByName('geo.dest'); + await unifiedFieldList.clickFieldListItemVisualize('geo.dest'); + await header.waitUntilLoadingHasFinished(); expect(await queryBar.getQueryString()).to.equal('machine.os : ios'); }); it('should visualize correctly using breakdown field', async () => { - await PageObjects.discover.chooseBreakdownField('extension.raw'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.chooseBreakdownField('extension.raw'); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('unifiedHistogramEditVisualization'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.try(async () => { const breakdownLabel = await testSubjects.find( 'lnsDragDrop_domDraggable_Top 3 values of extension.raw' @@ -137,62 +136,62 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); await testSubjects.click('unifiedHistogramEditVisualization'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dataViews.waitForSwitcherToBe('logst*'); }); it('should visualize correctly ES|QL queries in Discover', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); await monacoEditor.setCodeEditorValue( 'from logstash-* | stats averageB = avg(bytes) by extension' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect(await testSubjects.exists('unifiedHistogramChart')).to.be(true); expect(await testSubjects.exists('xyVisChart')).to.be(true); - await PageObjects.discover.chooseLensSuggestion('pie'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.chooseLensSuggestion('pie'); + await header.waitUntilLoadingHasFinished(); expect(await testSubjects.exists('partitionVisChart')).to.be(true); }); it('should allow changing dimensions', async () => { await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); await monacoEditor.setCodeEditorValue( 'from logstash-* | stats averageB = avg(bytes) by extension' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('unifiedHistogramEditFlyoutVisualization'); expect(await testSubjects.exists('xyVisChart')).to.be(true); - expect(await PageObjects.lens.canRemoveDimension('lnsXY_xDimensionPanel')).to.equal(true); - await PageObjects.lens.removeDimension('lnsXY_xDimensionPanel'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.configureTextBasedLanguagesDimension({ + expect(await lens.canRemoveDimension('lnsXY_xDimensionPanel')).to.equal(true); + await lens.removeDimension('lnsXY_xDimensionPanel'); + await header.waitUntilLoadingHasFinished(); + await lens.configureTextBasedLanguagesDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', field: 'extension', }); - await PageObjects.header.waitUntilLoadingHasFinished(); - const data = await PageObjects.lens.getCurrentChartDebugStateForVizType('xyVisChart'); + await header.waitUntilLoadingHasFinished(); + const data = await lens.getCurrentChartDebugStateForVizType('xyVisChart'); assertMatchesExpectedData(data!); }); it('should visualize correctly ES|QL queries in Lens', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); await monacoEditor.setCodeEditorValue( 'from logstash-* | stats averageB = avg(bytes) by extension' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('unifiedHistogramEditFlyoutVisualization'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('lens flyout', async () => { const dimensions = await testSubjects.findAll('lns-dimensionTrigger-textBased'); @@ -201,16 +200,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('should visualize correctly ES|QL queries based on index patterns', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); await monacoEditor.setCodeEditorValue( 'from logstash* | stats averageB = avg(bytes) by extension' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('unifiedHistogramEditFlyoutVisualization'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('lens flyout', async () => { const dimensions = await testSubjects.findAll('lns-dimensionTrigger-textBased'); @@ -219,70 +218,70 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('should save and edit chart in the dashboard on the fly', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); await monacoEditor.setCodeEditorValue( 'from logstash-* | stats averageB = avg(bytes) by extension' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('unifiedHistogramSaveVisualization'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.lens.saveModal('TextBasedChart', false, false, false, 'new'); + await lens.saveModal('TextBasedChart', false, false, false, 'new'); await testSubjects.existOrFail('embeddablePanelHeading-TextBasedChart'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dashboardPanelActions.clickInlineEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect(await PageObjects.lens.canRemoveDimension('lnsXY_xDimensionPanel')).to.equal(true); - await PageObjects.lens.removeDimension('lnsXY_xDimensionPanel'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.configureTextBasedLanguagesDimension({ + await header.waitUntilLoadingHasFinished(); + expect(await lens.canRemoveDimension('lnsXY_xDimensionPanel')).to.equal(true); + await lens.removeDimension('lnsXY_xDimensionPanel'); + await header.waitUntilLoadingHasFinished(); + await lens.configureTextBasedLanguagesDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', field: 'extension', }); - await PageObjects.header.waitUntilLoadingHasFinished(); - const data = await PageObjects.lens.getCurrentChartDebugStateForVizType('xyVisChart'); + await header.waitUntilLoadingHasFinished(); + const data = await lens.getCurrentChartDebugStateForVizType('xyVisChart'); assertMatchesExpectedData(data!); }); it('should allow editing the query in the dashboard', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); await monacoEditor.setCodeEditorValue('from logstash-* | limit 10'); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // save the visualization await testSubjects.click('unifiedHistogramSaveVisualization'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.saveModal('TextBasedChart1', false, false, false, 'new'); + await header.waitUntilLoadingHasFinished(); + await lens.saveModal('TextBasedChart1', false, false, false, 'new'); await testSubjects.existOrFail('embeddablePanelHeading-TextBasedChart1'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // open the inline editing flyout await dashboardPanelActions.clickInlineEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // change the query await monacoEditor.setCodeEditorValue('from logstash-* | stats maxB = max(bytes)'); await testSubjects.click('TextBasedLangEditor-run-query-button'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - expect((await PageObjects.lens.getMetricVisualizationData()).length).to.be.equal(1); + expect((await lens.getMetricVisualizationData()).length).to.be.equal(1); // change the query to display a datatabler await monacoEditor.setCodeEditorValue('from logstash-* | limit 10'); await testSubjects.click('TextBasedLangEditor-run-query-button'); - await PageObjects.lens.waitForVisualization(); + await lens.waitForVisualization(); expect(await testSubjects.exists('lnsDataTable')).to.be(true); - await PageObjects.lens.removeDimension('lnsDatatable_metrics'); - await PageObjects.lens.removeDimension('lnsDatatable_metrics'); - await PageObjects.lens.removeDimension('lnsDatatable_metrics'); - await PageObjects.lens.removeDimension('lnsDatatable_metrics'); + await lens.removeDimension('lnsDatatable_metrics'); + await lens.removeDimension('lnsDatatable_metrics'); + await lens.removeDimension('lnsDatatable_metrics'); + await lens.removeDimension('lnsDatatable_metrics'); - await PageObjects.lens.configureTextBasedLanguagesDimension({ + await lens.configureTextBasedLanguagesDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', field: 'bytes', keepOpen: true, @@ -295,21 +294,21 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('should default title when saving chart in Discover (even when modal is closed and reopened)', async () => { - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); await monacoEditor.setCodeEditorValue( 'from logstash-* | stats averageB = avg(bytes) by extension' ); await testSubjects.click('querySubmitButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('unifiedHistogramSaveVisualization'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); let title = await testSubjects.getAttribute('savedObjectTitle', 'value'); expect(title).to.equal('Bar vertical stacked'); await testSubjects.click('saveCancelButton'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('unifiedHistogramSaveVisualization'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); title = await testSubjects.getAttribute('savedObjectTitle', 'value'); expect(title).to.equal('Bar vertical stacked'); }); diff --git a/x-pack/test/functional/apps/graph/feature_controls/graph_security.ts b/x-pack/test/functional/apps/graph/feature_controls/graph_security.ts index ca1060c2249e9..1f2c2643fb8d1 100644 --- a/x-pack/test/functional/apps/graph/feature_controls/graph_security.ts +++ b/x-pack/test/functional/apps/graph/feature_controls/graph_security.ts @@ -10,8 +10,13 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); - const security = getService('security'); - const PageObjects = getPageObjects(['common', 'graph', 'security', 'error', 'header']); + const securityService = getService('security'); + const { common, security, error, header } = getPageObjects([ + 'common', + 'security', + 'error', + 'header', + ]); const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); const globalNav = getService('globalNav'); @@ -20,18 +25,18 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { await kibanaServer.savedObjects.cleanStandardList(); // ensure we're logged out so we can login as the appropriate users - await PageObjects.security.forceLogout(); + await security.forceLogout(); }); after(async () => { // logout, so the other tests don't accidentally run as the custom users we're testing below // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); + await security.forceLogout(); }); describe('global graph all privileges', () => { before(async () => { - await security.role.create('global_graph_all_role', { + await securityService.role.create('global_graph_all_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -45,24 +50,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_graph_all_user', { + await securityService.user.create('global_graph_all_user', { password: 'global_graph_all_user-password', roles: ['global_graph_all_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'global_graph_all_user', - 'global_graph_all_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('global_graph_all_user', 'global_graph_all_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { - await security.role.delete('global_graph_all_role'); - await security.user.delete('global_graph_all_user'); + await securityService.role.delete('global_graph_all_role'); + await securityService.user.delete('global_graph_all_user'); }); it('shows graph navlink', async () => { @@ -71,8 +72,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('landing page shows "Create new graph" button', async () => { - await PageObjects.common.navigateToApp('graph'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('graph'); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('graphLandingPage', { timeout: 10000 }); await testSubjects.existOrFail('graphCreateGraphPromptButton'); }); @@ -82,8 +83,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('allows creating a new workspace', async () => { - await PageObjects.common.navigateToApp('graph'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('graph'); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('graphCreateGraphPromptButton'); const breadcrumb = await testSubjects.find('~graphCurrentGraphBreadcrumb'); expect(await breadcrumb.getVisibleText()).to.equal('Unsaved graph'); @@ -96,7 +97,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('global graph read-only privileges', () => { before(async () => { - await security.role.create('global_graph_read_role', { + await securityService.role.create('global_graph_read_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -110,24 +111,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_graph_read_user', { + await securityService.user.create('global_graph_read_user', { password: 'global_graph_read_user-password', roles: ['global_graph_read_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'global_graph_read_user', - 'global_graph_read_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('global_graph_read_user', 'global_graph_read_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { - await security.role.delete('global_graph_read_role'); - await security.user.delete('global_graph_read_user'); + await securityService.role.delete('global_graph_read_role'); + await securityService.user.delete('global_graph_read_user'); }); it('shows graph navlink', async () => { @@ -136,8 +133,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('does not show a "Create new Workspace" button', async () => { - await PageObjects.common.navigateToApp('graph'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('graph'); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('graphLandingPage', { timeout: 10000 }); await testSubjects.missingOrFail('newItemButton'); }); @@ -149,7 +146,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('no graph privileges', () => { before(async () => { - await security.role.create('no_graph_privileges_role', { + await securityService.role.create('no_graph_privileges_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -163,24 +160,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('no_graph_privileges_user', { + await securityService.user.create('no_graph_privileges_user', { password: 'no_graph_privileges_user-password', roles: ['no_graph_privileges_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'no_graph_privileges_user', - 'no_graph_privileges_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('no_graph_privileges_user', 'no_graph_privileges_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { - await security.role.delete('no_graph_privileges_role'); - await security.user.delete('no_graph_privileges_user'); + await securityService.role.delete('no_graph_privileges_role'); + await securityService.user.delete('no_graph_privileges_user'); }); it(`doesn't show graph navlink`, async () => { @@ -189,12 +182,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`navigating to app displays a 403`, async () => { - await PageObjects.common.navigateToUrl('graph', '', { + await common.navigateToUrl('graph', '', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.error.expectForbidden(); + await error.expectForbidden(); }); }); }); diff --git a/x-pack/test/functional/apps/graph/feature_controls/graph_spaces.ts b/x-pack/test/functional/apps/graph/feature_controls/graph_spaces.ts index af03a827a43e8..68be7e653b872 100644 --- a/x-pack/test/functional/apps/graph/feature_controls/graph_spaces.ts +++ b/x-pack/test/functional/apps/graph/feature_controls/graph_spaces.ts @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const spacesService = getService('spaces'); - const PageObjects = getPageObjects(['common', 'graph', 'security', 'error', 'header']); + const { common, header, error } = getPageObjects(['common', 'error', 'header']); const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); @@ -33,28 +33,28 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('shows graph navlink', async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); expect(navLinks).to.contain('Graph'); }); it('landing page shows "Create new graph" button', async () => { - await PageObjects.common.navigateToApp('graph', { + await common.navigateToApp('graph', { basePath: '/s/custom_space', }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('graphLandingPage', { timeout: 10000 }); await testSubjects.existOrFail('graphCreateGraphPromptButton'); }); it('allows creating a new graph', async () => { - await PageObjects.common.navigateToApp('graph', { + await common.navigateToApp('graph', { basePath: '/s/custom_space', }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('graphCreateGraphPromptButton'); const breadcrumb = await testSubjects.find('~graphCurrentGraphBreadcrumb'); expect(await breadcrumb.getVisibleText()).to.equal('Unsaved graph'); @@ -75,21 +75,21 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`doesn't show graph navlink`, async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); expect(navLinks).not.to.contain('Graph'); }); it(`navigating to app shows 404`, async () => { - await PageObjects.common.navigateToUrl('graph', '', { + await common.navigateToUrl('graph', '', { basePath: '/s/custom_space', shouldLoginIfPrompted: false, ensureCurrentUrl: false, }); - await PageObjects.error.expectNotFound(); + await error.expectNotFound(); }); }); }); diff --git a/x-pack/test/functional/apps/graph/graph.ts b/x-pack/test/functional/apps/graph/graph.ts index b3ee528237002..32684342b2201 100644 --- a/x-pack/test/functional/apps/graph/graph.ts +++ b/x-pack/test/functional/apps/graph/graph.ts @@ -9,7 +9,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['settings', 'common', 'graph', 'header']); + const { settings, common, graph, header } = getPageObjects([ + 'settings', + 'common', + 'graph', + 'header', + ]); const kibanaServer = getService('kibanaServer'); const log = getService('log'); const esArchiver = getService('esArchiver'); @@ -21,13 +26,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('load graph/secrepo data'); await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/graph/secrepo'); await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.common.navigateToApp('settings'); + await common.navigateToApp('settings'); log.debug('create secrepo index pattern'); - await PageObjects.settings.createIndexPattern('secrepo', '@timestamp'); + await settings.createIndexPattern('secrepo', '@timestamp'); log.debug('navigateTo graph'); - await PageObjects.common.navigateToApp('graph'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.graph.createWorkspace(); + await common.navigateToApp('graph'); + await header.waitUntilLoadingHasFinished(); + await graph.createWorkspace(); }); after(async () => { @@ -80,16 +85,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { async function buildGraph() { // select fields url.parts, url, params and src - await PageObjects.graph.addFields(['url.parts', 'url', 'params', 'src']); - await PageObjects.graph.query('admin'); - await PageObjects.common.sleep(8000); + await graph.addFields(['url.parts', 'url', 'params', 'src']); + await graph.query('admin'); + await common.sleep(8000); } it('should show correct node labels', async function () { - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.graph.selectIndexPattern('secrepo'); + await header.waitUntilLoadingHasFinished(); + await graph.selectIndexPattern('secrepo'); await buildGraph(); - const { nodes } = await PageObjects.graph.getGraphObjects(); + const { nodes } = await graph.getGraphObjects(); const circlesText = nodes.map(({ label }) => label); expect(circlesText.length).to.equal(expectedNodes.length); const unexpectedCircleTexts = circlesText.filter((t) => !expectedNodes.includes(t)); @@ -103,7 +108,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const expectedConnectionCount = Object.values(expectedConnections) .map((connections) => Object.values(connections).length) .reduce((acc, n) => acc + n, 0); - const { edges } = await PageObjects.graph.getGraphObjects(); + const { edges } = await graph.getGraphObjects(); expect(edges.length).to.be(expectedConnectionCount); edges.forEach((edge) => { const from = edge.sourceNode.label!; @@ -113,14 +118,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should save Graph workspace', async function () { - const graphExists = await PageObjects.graph.saveGraph(graphName); + const graphExists = await graph.saveGraph(graphName); expect(graphExists).to.eql(true); }); // open the same graph workspace again and make sure the results are the same it('should open Graph workspace', async function () { - await PageObjects.graph.openGraph(graphName); - const { nodes } = await PageObjects.graph.getGraphObjects(); + await graph.openGraph(graphName); + const { nodes } = await graph.getGraphObjects(); const circlesText = nodes.map(({ label }) => label); expect(circlesText.length).to.equal(expectedNodes.length); circlesText.forEach((circleText) => { @@ -130,9 +135,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should create new Graph workspace', async function () { - await PageObjects.graph.newGraph(); - await PageObjects.graph.selectIndexPattern('secrepo'); - const { nodes, edges } = await PageObjects.graph.getGraphObjects(); + await graph.newGraph(); + await graph.selectIndexPattern('secrepo'); + const { nodes, edges } = await graph.getGraphObjects(); expect(nodes).to.be.empty(); expect(edges).to.be.empty(); }); @@ -140,31 +145,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show venn when clicking a line', async function () { await buildGraph(); - await PageObjects.graph.isolateEdge('test', '/test/wp-admin/'); + await graph.isolateEdge('test', '/test/wp-admin/'); - await PageObjects.graph.stopLayout(); - await PageObjects.common.sleep(1000); + await graph.stopLayout(); + await common.sleep(1000); await browser.execute(() => { const event = document.createEvent('SVGEvents'); event.initEvent('click', true, true); return document.getElementsByClassName('gphEdge--clickable')[0].dispatchEvent(event); }); - await PageObjects.common.sleep(1000); - await PageObjects.graph.startLayout(); + await common.sleep(1000); + await graph.startLayout(); - const vennTerm1 = await PageObjects.graph.getVennTerm1(); + const vennTerm1 = await graph.getVennTerm1(); log.debug('vennTerm1 = ' + vennTerm1); - const vennTerm2 = await PageObjects.graph.getVennTerm2(); + const vennTerm2 = await graph.getVennTerm2(); log.debug('vennTerm2 = ' + vennTerm2); - const smallVennTerm1 = await PageObjects.graph.getSmallVennTerm1(); + const smallVennTerm1 = await graph.getSmallVennTerm1(); log.debug('smallVennTerm1 = ' + smallVennTerm1); - const smallVennTerm12 = await PageObjects.graph.getSmallVennTerm12(); + const smallVennTerm12 = await graph.getSmallVennTerm12(); log.debug('smallVennTerm12 = ' + smallVennTerm12); - const smallVennTerm2 = await PageObjects.graph.getSmallVennTerm2(); + const smallVennTerm2 = await graph.getSmallVennTerm2(); log.debug('smallVennTerm2 = ' + smallVennTerm2); expect(vennTerm1).to.be('/test/wp-admin/'); @@ -175,10 +180,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should delete graph', async function () { - await PageObjects.graph.goToListingPage(); - expect(await PageObjects.graph.getWorkspaceCount()).to.equal(1); - await PageObjects.graph.deleteGraph(graphName); - expect(await PageObjects.graph.getWorkspaceCount()).to.equal(0); + await graph.goToListingPage(); + expect(await graph.getWorkspaceCount()).to.equal(1); + await graph.deleteGraph(graphName); + expect(await graph.getWorkspaceCount()).to.equal(0); }); }); } 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 685d01d0ec6f1..38f66db31dc92 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 @@ -10,18 +10,16 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ - 'visualize', - 'lens', - 'header', - 'unifiedSearch', - 'dashboard', - 'timeToVisualize', - 'common', - 'discover', - 'unifiedFieldList', - 'share', - ]); + const { visualize, lens, header, dashboard, timeToVisualize, discover, unifiedFieldList } = + getPageObjects([ + 'visualize', + 'lens', + 'header', + 'dashboard', + 'timeToVisualize', + 'discover', + 'unifiedFieldList', + ]); const elasticChart = getService('elasticChart'); const fieldEditor = getService('fieldEditor'); const retry = getService('retry'); @@ -48,8 +46,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } async function setupAdHocDataView() { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); await dataViews.createFromSearchBar({ name: '*stash*', adHoc: true }); await dataViews.waitForSwitcherToBe('*stash*'); @@ -62,7 +60,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const [, discoverHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const actualIndexPattern = await ( await testSubjects.find('discover-dataView-switch-link') @@ -75,7 +73,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; const waitForPageReady = async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('page ready after refresh', async () => { const queryBarVisible = await testSubjects.exists('globalQueryBar'); return queryBarVisible; @@ -85,123 +83,121 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens ad hoc data view tests', () => { it('should allow building a chart based on ad hoc data view', async () => { await setupAdHocDataView(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); assertMatchesExpectedData(data!); - await PageObjects.lens.removeLayer(); + await lens.removeLayer(); }); it('should allow adding and using a field', async () => { - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await lens.switchToVisualization('lnsDatatable'); await retry.try(async () => { await dataViews.clickAddFieldFromSearchBar(); await fieldEditor.setName('runtimefield'); await fieldEditor.enableValue(); await fieldEditor.typeScript("emit('abc')"); await fieldEditor.save(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.searchField('runtime'); - await PageObjects.lens.waitForField('runtimefield'); - await PageObjects.lens.dragFieldToWorkspace('runtimefield'); + await header.waitUntilLoadingHasFinished(); + await lens.searchField('runtime'); + await lens.waitForField('runtimefield'); + await lens.dragFieldToWorkspace('runtimefield'); }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal( - 'Top 5 values of runtimefield' - ); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('abc'); - await PageObjects.lens.removeLayer(); + await lens.waitForVisualization(); + expect(await lens.getDatatableHeaderText(0)).to.equal('Top 5 values of runtimefield'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('abc'); + await lens.removeLayer(); }); it('should allow switching to another data view and back', async () => { await dataViews.switchTo('logstash-*'); - await PageObjects.lens.waitForFieldMissing('runtimefield'); + await lens.waitForFieldMissing('runtimefield'); await dataViews.switchTo('*stash*'); - await PageObjects.lens.waitForField('runtimefield'); + await lens.waitForField('runtimefield'); }); it('should allow removing a field', async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.removeField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.removeField('runtimefield'); await fieldEditor.confirmDelete(); - await PageObjects.lens.waitForFieldMissing('runtimefield'); + await lens.waitForFieldMissing('runtimefield'); }); it('should allow adding an ad-hoc chart to a dashboard', async () => { - await PageObjects.lens.switchToVisualization('lnsMetric'); + await lens.switchToVisualization('lnsMetric'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsMetric_primaryMetricDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.waitForVisualization('mtrVis'); - const metricData = await PageObjects.lens.getMetricVisualizationData(); + await lens.waitForVisualization('mtrVis'); + const metricData = await lens.getMetricVisualizationData(); expect(metricData[0].value).to.eql('5,727.322'); expect(metricData[0].title).to.eql('Average of bytes'); - await PageObjects.lens.save('New Lens from Modal', false, false, false, 'new'); + await lens.save('New Lens from Modal', false, false, false, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); expect(metricData[0].value).to.eql('5,727.322'); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('should allow saving the ad-hoc chart into a saved object', async () => { await setupAdHocDataView(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.switchToVisualization('lnsMetric'); + await lens.switchToVisualization('lnsMetric'); - await PageObjects.lens.waitForVisualization('mtrVis'); - await PageObjects.lens.save('Lens with adhoc data view'); - await PageObjects.lens.waitForVisualization('mtrVis'); - const metricData = await PageObjects.lens.getMetricVisualizationData(); + await lens.waitForVisualization('mtrVis'); + await lens.save('Lens with adhoc data view'); + await lens.waitForVisualization('mtrVis'); + const metricData = await lens.getMetricVisualizationData(); expect(metricData[0].value).to.eql('5,727.322'); expect(metricData[0].title).to.eql('Average of bytes'); }); it('should be possible to share a URL of a visualization with adhoc dataViews', async () => { - const url = await PageObjects.lens.getUrl(); + const url = await lens.getUrl(); await browser.openNewTab(); const [lensWindowHandler] = await browser.getAllWindowHandles(); await browser.navigateTo(url); // check that it's the same configuration in the new URL when ready - await PageObjects.header.waitUntilLoadingHasFinished(); - expect( - await PageObjects.lens.getDimensionTriggerText('lnsMetric_primaryMetricDimensionPanel') - ).to.eql('Average of bytes'); + await header.waitUntilLoadingHasFinished(); + expect(await lens.getDimensionTriggerText('lnsMetric_primaryMetricDimensionPanel')).to.eql( + 'Average of bytes' + ); await browser.closeCurrentWindow(); await browser.switchToWindow(lensWindowHandler); }); it('should be possible to download a visualization with adhoc dataViews', async () => { - await PageObjects.lens.setCSVDownloadDebugFlag(true); - await PageObjects.lens.openCSVDownloadShare(); + await lens.setCSVDownloadDebugFlag(true); + await lens.openCSVDownloadShare(); - const csv = await PageObjects.lens.getCSVContent(); + const csv = await lens.getCSVContent(); expect(csv).to.be.ok(); expect(Object.keys(csv!)).to.have.length(1); - await PageObjects.lens.setCSVDownloadDebugFlag(false); + await lens.setCSVDownloadDebugFlag(false); }); it('should navigate to discover correctly', async () => { @@ -209,7 +205,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const [, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const actualIndexPattern = await ( await testSubjects.find('discover-dataView-switch-link') @@ -219,14 +215,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const actualDiscoverQueryHits = await testSubjects.getVisibleText('discoverQueryHits'); expect(actualDiscoverQueryHits).to.be('14,005'); - const prevDataViewId = await PageObjects.discover.getCurrentDataViewId(); + const prevDataViewId = await discover.getCurrentDataViewId(); - await PageObjects.discover.addRuntimeField( - '_bytes-runtimefield', - `emit(doc["bytes"].value.toString())` - ); - await PageObjects.unifiedFieldList.clickFieldListItemToggle('_bytes-runtimefield'); - const newDataViewId = await PageObjects.discover.getCurrentDataViewId(); + await discover.addRuntimeField('_bytes-runtimefield', `emit(doc["bytes"].value.toString())`); + await unifiedFieldList.clickFieldListItemToggle('_bytes-runtimefield'); + const newDataViewId = await discover.getCurrentDataViewId(); expect(newDataViewId).not.to.equal(prevDataViewId); expect(await dataViews.isAdHoc()).to.be(true); @@ -237,30 +230,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should navigate to discover from embeddable correctly', async () => { const [lensHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(lensHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await setupAdHocDataView(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.save( - 'embeddable-test-with-adhoc-data-view', - false, - false, - false, - 'new' - ); + await lens.save('embeddable-test-with-adhoc-data-view', false, false, false, 'new'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await checkDiscoverNavigationResult(); await browser.closeCurrentWindow(); const [daashboardHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(daashboardHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // adhoc data view should be persisted after refresh await browser.refresh(); diff --git a/x-pack/test/functional/apps/lens/group1/index.ts b/x-pack/test/functional/apps/lens/group1/index.ts index 1f02923816c64..fa95e898e8e90 100644 --- a/x-pack/test/functional/apps/lens/group1/index.ts +++ b/x-pack/test/functional/apps/lens/group1/index.ts @@ -13,7 +13,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['timePicker']); + const { timePicker } = getPageObjects(['timePicker']); const config = getService('config'); let remoteEsArchiver; @@ -54,7 +54,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext await esNode.load(esArchive); // changing the timepicker default here saves us from having to set it in Discover (~8s) - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: indexPatternString, 'dateFormat:tz': 'UTC', @@ -65,7 +65,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext after(async () => { await esNode.unload(esArchive); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.importExport.unload(fixtureDirs.lensBasic); await kibanaServer.importExport.unload(fixtureDirs.lensDefault); await kibanaServer.savedObjects.cleanStandardList(); diff --git a/x-pack/test/functional/apps/lens/group1/multiple_data_views.ts b/x-pack/test/functional/apps/lens/group1/multiple_data_views.ts index 75d3d7ca6caf1..84bf66c26191d 100644 --- a/x-pack/test/functional/apps/lens/group1/multiple_data_views.ts +++ b/x-pack/test/functional/apps/lens/group1/multiple_data_views.ts @@ -10,7 +10,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'visualize', 'lens']); + const { common, visualize, lens } = getPageObjects(['common', 'visualize', 'lens']); const filterBar = getService('filterBar'); const elasticChart = getService('elasticChart'); const testSubjects = getService('testSubjects'); @@ -49,7 +49,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const visTitle = 'xyChart with multiple data views'; before(async () => { - await PageObjects.common.setTime({ + await common.setTime({ from: 'Oct 23, 2018 @ 07:00:00.000', to: 'Oct 23, 2018 @ 08:00:00.000', }); @@ -65,7 +65,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'test/functional/fixtures/kbn_archiver/long_window_logstash_index_pattern' ); - await PageObjects.common.navigateToApp('lens'); + await common.navigateToApp('lens'); }); after(async () => { @@ -84,32 +84,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await elasticChart.setNewChartUiDebugFlag(true); // Logstash layer - await PageObjects.lens.switchDataPanelIndexPattern('long-window-logstash-*'); + await lens.switchDataPanelIndexPattern('long-window-logstash-*'); await testSubjects.click('fieldToggle-bytes'); // Flights layer - await PageObjects.lens.switchDataPanelIndexPattern('kibana_sample_data_flights'); - await PageObjects.lens.createLayer('data'); + await lens.switchDataPanelIndexPattern('kibana_sample_data_flights'); + await lens.createLayer('data'); await testSubjects.click('fieldToggle-DistanceKilometers'); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); assertMatchesExpectedData(data, [expectedLogstashData, expectedFlightsData]); }); it('ignores global filters on layers using a data view without the filter field', async () => { await filterBar.addFilter({ field: 'Carrier', operation: 'exists' }); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); assertMatchesExpectedData(data, [expectedLogstashData, expectedFlightsData]); - await PageObjects.lens.save(visTitle); + await lens.save(visTitle); }); it('applies global filters on layers using data view a without the filter field', async () => { await kibanaServer.uiSettings.update({ 'courier:ignoreFilterIfFieldNotInIndex': false }); - await PageObjects.common.navigateToApp('visualize'); + await common.navigateToApp('visualize'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.visualize.openSavedVisualization(visTitle); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await visualize.openSavedVisualization(visTitle); + const data = await lens.getCurrentChartDebugState('xyVisChart'); assertMatchesExpectedData(data, [expectedFlightsData]); }); }); diff --git a/x-pack/test/functional/apps/lens/group1/smokescreen.ts b/x-pack/test/functional/apps/lens/group1/smokescreen.ts index bf02959b08b8f..dbe48cdd395da 100644 --- a/x-pack/test/functional/apps/lens/group1/smokescreen.ts +++ b/x-pack/test/functional/apps/lens/group1/smokescreen.ts @@ -10,7 +10,7 @@ import { range } from 'lodash'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const find = getService('find'); const listingTable = getService('listingTable'); const testSubjects = getService('testSubjects'); @@ -21,49 +21,49 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens smokescreen tests', () => { it('should allow creation of lens xy chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: '@message.raw', }); - await PageObjects.lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.removeDimension('lnsDatatable_rows'); - await PageObjects.lens.switchToVisualization('area'); + await lens.switchToVisualization('lnsDatatable'); + await lens.removeDimension('lnsDatatable_rows'); + await lens.switchToVisualization('area'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.lens.save('Afancilenstest'); + await lens.save('Afancilenstest'); // Ensure the visualization shows up in the visualize list, and takes // us back to the visualization as we configured it. - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('Afancilenstest'); - await PageObjects.lens.clickVisualizeListItemTitle('Afancilenstest'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.clickVisualizeListItemTitle('Afancilenstest'); + await lens.goToTimeRange(); + await lens.waitForVisualization('xyVisChart'); - expect(await PageObjects.lens.getTitle()).to.eql('Afancilenstest'); + expect(await lens.getTitle()).to.eql('Afancilenstest'); // .echLegendItem__title is the only viable way of getting the xy chart's // legend item(s), so we're using a class selector here. @@ -72,487 +72,476 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should create an xy visualization with filters aggregation', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); // Change the IP field to filters - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-dimensionTrigger', operation: 'filters', keepOpen: true, }); - await PageObjects.lens.addFilterToAgg(`geo.src : CN`); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.addFilterToAgg(`geo.src : CN`); + await lens.waitForVisualization('xyVisChart'); // Verify that the field was persisted from the transition - expect(await PageObjects.lens.getFiltersAggLabels()).to.eql([`"ip" : *`, `geo.src : CN`]); + expect(await lens.getFiltersAggLabels()).to.eql([`"ip" : *`, `geo.src : CN`]); expect(await find.allByCssSelector('.echLegendItem')).to.have.length(2); }); it('should transition from metric to table to metric', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('Artistpreviouslyknownaslens'); - await PageObjects.lens.clickVisualizeListItemTitle('Artistpreviouslyknownaslens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '19,986'); - await PageObjects.lens.switchToVisualization('lnsDatatable'); - expect(await PageObjects.lens.getDatatableHeaderText()).to.eql('Maximum of bytes'); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('19,986'); - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '19,986'); + await lens.clickVisualizeListItemTitle('Artistpreviouslyknownaslens'); + await lens.goToTimeRange(); + await lens.assertLegacyMetric('Maximum of bytes', '19,986'); + await lens.switchToVisualization('lnsDatatable'); + expect(await lens.getDatatableHeaderText()).to.eql('Maximum of bytes'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('19,986'); + await lens.switchToVisualization('lnsLegacyMetric'); + await lens.assertLegacyMetric('Maximum of bytes', '19,986'); }); it('should transition from a multi-layer stacked bar to a multi-layer line chart and correctly remove all layers', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.createLayer(); + await lens.createLayer(); - expect(await PageObjects.lens.hasChartSwitchWarning('line')).to.eql(false); + expect(await lens.hasChartSwitchWarning('line')).to.eql(false); - await PageObjects.lens.switchToVisualization('line'); + await lens.switchToVisualization('line'); - expect(await PageObjects.lens.getLayerType(0)).to.eql('Line'); + expect(await lens.getLayerType(0)).to.eql('Line'); // expect first layer to be line, second layer to be bar chart - expect(await PageObjects.lens.getLayerType(1)).to.eql('Bar'); - await PageObjects.lens.configureDimension({ + expect(await lens.getLayerType(1)).to.eql('Bar'); + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'machine.ram', }); - expect(await PageObjects.lens.getLayerCount()).to.eql(2); - await PageObjects.lens.removeLayer(); - await PageObjects.lens.removeLayer(); + expect(await lens.getLayerCount()).to.eql(2); + await lens.removeLayer(); + await lens.removeLayer(); await testSubjects.existOrFail('workspace-drag-drop-prompt'); }); it('should transition selected layer in a multi layer bar using layer chart switch', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.createLayer('data', undefined, 'bar'); - expect(await PageObjects.lens.getLayerType(1)).to.eql('Bar'); + await lens.createLayer('data', undefined, 'bar'); + expect(await lens.getLayerType(1)).to.eql('Bar'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'machine.ram', }); // only changes one layer for compatible chart - await PageObjects.lens.switchToVisualization('line', undefined, 1); - expect(await PageObjects.lens.getLayerType(0)).to.eql('Bar'); - expect(await PageObjects.lens.getLayerType(1)).to.eql('Line'); + await lens.switchToVisualization('line', undefined, 1); + expect(await lens.getLayerType(0)).to.eql('Bar'); + expect(await lens.getLayerType(1)).to.eql('Line'); // generates new one layer chart based on selected layer - await PageObjects.lens.switchToVisualization('pie', undefined, 1); - expect(await PageObjects.lens.getLayerType(0)).to.eql('Pie'); - const sliceByText = await PageObjects.lens.getDimensionTriggerText( - 'lnsPie_sliceByDimensionPanel' - ); - const sizeByText = await PageObjects.lens.getDimensionTriggerText( - 'lnsPie_sizeByDimensionPanel' - ); + await lens.switchToVisualization('pie', undefined, 1); + expect(await lens.getLayerType(0)).to.eql('Pie'); + const sliceByText = await lens.getDimensionTriggerText('lnsPie_sliceByDimensionPanel'); + const sizeByText = await lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel'); expect(sliceByText).to.be('Top 5 values of geo.src'); expect(sizeByText).to.be('Average of machine.ram'); }); it('should edit settings of xy line chart', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.removeDimension('lnsXY_splitDimensionPanel'); - await PageObjects.lens.switchToVisualization('line'); - await PageObjects.lens.configureDimension({ + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + await lens.removeDimension('lnsXY_splitDimensionPanel'); + await lens.switchToVisualization('line'); + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'max', field: 'memory', keepOpen: true, }); - await PageObjects.lens.editDimensionLabel('Test of label'); - await PageObjects.lens.editDimensionFormat('Percent'); - await PageObjects.lens.editDimensionColor('#ff0000'); - await PageObjects.lens.openVisualOptions(); + await lens.editDimensionLabel('Test of label'); + await lens.editDimensionFormat('Percent'); + await lens.editDimensionColor('#ff0000'); + await lens.openVisualOptions(); - await PageObjects.lens.setCurvedLines('CURVE_MONOTONE_X'); - await PageObjects.lens.editMissingValues('Linear'); + await lens.setCurvedLines('CURVE_MONOTONE_X'); + await lens.editMissingValues('Linear'); - await PageObjects.lens.assertMissingValues('Linear'); + await lens.assertMissingValues('Linear'); - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); - await PageObjects.lens.assertColor('#ff0000'); + await lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); + await lens.assertColor('#ff0000'); await testSubjects.existOrFail('indexPattern-dimension-formatDecimals'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( - 'Test of label' - ); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql('Test of label'); }); it('should not show static value tab for data layers', async () => { - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); + await lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); // Quick functions and Formula tabs should be visible expect(await testSubjects.exists('lens-dimensionTabs-quickFunctions')).to.eql(true); expect(await testSubjects.exists('lens-dimensionTabs-formula')).to.eql(true); // Static value tab should not be visible expect(await testSubjects.exists('lens-dimensionTabs-static_value')).to.eql(false); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should be able to add very long labels and still be able to remove a dimension', async () => { - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); + await lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); const longLabel = 'Veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryvery long label wrapping multiple lines'; - await PageObjects.lens.editDimensionLabel(longLabel); - await PageObjects.lens.waitForVisualization('xyVisChart'); - await PageObjects.lens.closeDimensionEditor(); + await lens.editDimensionLabel(longLabel); + await lens.waitForVisualization('xyVisChart'); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( - longLabel - ); - expect(await PageObjects.lens.canRemoveDimension('lnsXY_yDimensionPanel')).to.equal(true); - await PageObjects.lens.removeDimension('lnsXY_yDimensionPanel'); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql(longLabel); + expect(await lens.canRemoveDimension('lnsXY_yDimensionPanel')).to.equal(true); + await lens.removeDimension('lnsXY_yDimensionPanel'); await testSubjects.missingOrFail('lnsXY_yDimensionPanel > lns-dimensionTrigger'); }); it('should allow creation of a multi-axis chart and switching multiple times', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('bar'); + await lens.goToTimeRange(); + await lens.switchToVisualization('bar'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.dest', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'unique_count', field: 'bytes', keepOpen: true, }); - await PageObjects.lens.changeAxisSide('right'); - let data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await lens.changeAxisSide('right'); + let data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.axes?.y.length).to.eql(2); expect(data?.axes?.y.some(({ position }) => position === 'right')).to.eql(true); - await PageObjects.lens.changeAxisSide('left'); - data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await lens.changeAxisSide('left'); + data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.axes?.y.length).to.eql(1); expect(data?.axes?.y.some(({ position }) => position === 'right')).to.eql(false); - await PageObjects.lens.changeAxisSide('right'); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.changeAxisSide('right'); + await lens.waitForVisualization('xyVisChart'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should show value labels on bar charts when enabled', async () => { // enable value labels - await PageObjects.lens.openTextOptions(); + await lens.openTextOptions(); await testSubjects.click('lns_valueLabels_inside'); // check for value labels - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.bars?.[0].labels).not.to.eql(0); }); it('should override axis title', async () => { const axisTitle = 'overridden axis'; - await PageObjects.lens.toggleToolbarPopover('lnsLeftAxisButton'); + await lens.toggleToolbarPopover('lnsLeftAxisButton'); await testSubjects.setValue('lnsyLeftAxisTitle', axisTitle, { clearWithKeyboard: true, }); - let data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + let data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.axes?.y?.[1].title).to.eql(axisTitle); // hide the gridlines await testSubjects.click('lnsshowyLeftAxisGridlines'); - data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.axes?.y?.[1].gridlines.length).to.eql(0); }); it('should transition from a multi-layer stacked bar to treemap chart using suggestions', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.dest', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.createLayer(); + await lens.createLayer(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.save('twolayerchart'); + await lens.save('twolayerchart'); await testSubjects.click('lnsSuggestion-treemap > lnsSuggestion'); - expect(await PageObjects.lens.getLayerCount()).to.eql(1); - expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_groupByDimensionPanel')).to.eql( + expect(await lens.getLayerCount()).to.eql(1); + expect(await lens.getDimensionTriggerText('lnsPie_groupByDimensionPanel')).to.eql( 'Top 5 values of geo.dest' ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( 'Average of bytes' ); }); it('should transition from line chart to pie chart and to bar chart', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - expect(await PageObjects.lens.hasChartSwitchWarning('pie')).to.eql(true); - await PageObjects.lens.switchToVisualization('pie'); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + expect(await lens.hasChartSwitchWarning('pie')).to.eql(true); + await lens.switchToVisualization('pie'); - expect(await PageObjects.lens.getTitle()).to.eql('lnsXYvis'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sliceByDimensionPanel')).to.eql( + expect(await lens.getTitle()).to.eql('lnsXYvis'); + expect(await lens.getDimensionTriggerText('lnsPie_sliceByDimensionPanel')).to.eql( 'Top 3 values of ip' ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( 'Average of bytes' ); - expect(await PageObjects.lens.hasChartSwitchWarning('bar')).to.eql(false); - await PageObjects.lens.switchToVisualization('bar'); - expect(await PageObjects.lens.getTitle()).to.eql('lnsXYvis'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( + expect(await lens.hasChartSwitchWarning('bar')).to.eql(false); + await lens.switchToVisualization('bar'); + expect(await lens.getTitle()).to.eql('lnsXYvis'); + expect(await lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( 'Top 3 values of ip' ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Average of bytes' ); }); it('should transition from bar chart to line chart', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('line'); - expect(await PageObjects.lens.getTitle()).to.eql('lnsXYvis'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( - '@timestamp' - ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + await lens.switchToVisualization('line'); + expect(await lens.getTitle()).to.eql('lnsXYvis'); + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql('@timestamp'); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Average of bytes' ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( 'Top 3 values of ip' ); }); it('should transition from pie chart to treemap chart', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsPieVis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsPieVis'); - await PageObjects.lens.goToTimeRange(); - expect(await PageObjects.lens.hasChartSwitchWarning('treemap')).to.eql(false); - await PageObjects.lens.switchToVisualization('treemap'); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsPie_groupByDimensionPanel') - ).to.eql(['Top 7 values of geo.dest', 'Top 3 values of geo.src']); - expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( + await lens.clickVisualizeListItemTitle('lnsPieVis'); + await lens.goToTimeRange(); + expect(await lens.hasChartSwitchWarning('treemap')).to.eql(false); + await lens.switchToVisualization('treemap'); + expect(await lens.getDimensionTriggersTexts('lnsPie_groupByDimensionPanel')).to.eql([ + 'Top 7 values of geo.dest', + 'Top 3 values of geo.src', + ]); + expect(await lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( 'Average of bytes' ); }); it('should create a pie chart and switch to datatable', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('pie'); - await PageObjects.lens.configureDimension({ + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('pie'); + await lens.configureDimension({ dimension: 'lnsPie_sliceByDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', disableEmptyRows: true, }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsPie_sizeByDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - expect(await PageObjects.lens.hasChartSwitchWarning('lnsDatatable')).to.eql(false); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + expect(await lens.hasChartSwitchWarning('lnsDatatable')).to.eql(false); + await lens.switchToVisualization('lnsDatatable'); - expect(await PageObjects.lens.getDatatableHeaderText()).to.eql('@timestamp per 3 hours'); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('2015-09-20 00:00'); - expect(await PageObjects.lens.getDatatableHeaderText(1)).to.eql('Average of bytes'); - expect(await PageObjects.lens.getDatatableCellText(0, 1)).to.eql('6,011.351'); + expect(await lens.getDatatableHeaderText()).to.eql('@timestamp per 3 hours'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('2015-09-20 00:00'); + expect(await lens.getDatatableHeaderText(1)).to.eql('Average of bytes'); + expect(await lens.getDatatableCellText(0, 1)).to.eql('6,011.351'); }); it('should create a heatmap chart and transition to barchart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('heatmap', 'heat'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('heatmap', 'heat'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsHeatmap_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsHeatmap_yDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.dest', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsHeatmap_cellPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - expect(await PageObjects.lens.hasChartSwitchWarning('bar')).to.eql(false); - await PageObjects.lens.switchToVisualization('bar'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( - '@timestamp' - ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + expect(await lens.hasChartSwitchWarning('bar')).to.eql(false); + await lens.switchToVisualization('bar'); + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql('@timestamp'); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Average of bytes' ); }); it('should create a valid XY chart with references', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'moving_average', keepOpen: true, }); - await PageObjects.lens.configureReference({ + await lens.configureReference({ operation: 'sum', field: 'bytes', }); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'cumulative_sum', keepOpen: true, }); - await PageObjects.lens.configureReference({ + await lens.configureReference({ field: 'Records', }); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); // Two Y axes that are both valid expect(await find.allByCssSelector('.echLegendItem')).to.have.length(2); }); it('should allow formatting on references', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_rows > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', disableEmptyRows: true, }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'moving_average', keepOpen: true, }); - await PageObjects.lens.configureReference({ + await lens.configureReference({ operation: 'sum', field: 'bytes', }); - await PageObjects.lens.editDimensionFormat('Number'); - await PageObjects.lens.closeDimensionEditor(); + await lens.editDimensionFormat('Number'); + await lens.closeDimensionEditor(); - await PageObjects.lens.waitForVisualization(); + await lens.waitForVisualization(); const values = await Promise.all( - range(0, 6).map((index) => PageObjects.lens.getDatatableCellText(index, 1)) + range(0, 6).map((index) => lens.getDatatableCellText(index, 1)) ); expect(values).to.eql([ '-', @@ -572,144 +561,142 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { * 3. Being able to switch charts while in partial config */ it('should handle edge cases in reference-based operations', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'cumulative_sum', }); - expect(await PageObjects.lens.getWorkspaceErrorCount()).to.eql(1); + expect(await lens.getWorkspaceErrorCount()).to.eql(1); - await PageObjects.lens.removeDimension('lnsXY_xDimensionPanel'); - expect(await PageObjects.lens.getWorkspaceErrorCount()).to.eql(2); + await lens.removeDimension('lnsXY_xDimensionPanel'); + expect(await lens.getWorkspaceErrorCount()).to.eql(2); - await PageObjects.lens.dragFieldToDimensionTrigger( + await lens.dragFieldToDimensionTrigger( '@timestamp', 'lnsXY_xDimensionPanel > lns-empty-dimension' ); - expect(await PageObjects.lens.getWorkspaceErrorCount()).to.eql(1); + expect(await lens.getWorkspaceErrorCount()).to.eql(1); - expect(await PageObjects.lens.hasChartSwitchWarning('lnsDatatable')).to.eql(false); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + expect(await lens.hasChartSwitchWarning('lnsDatatable')).to.eql(false); + await lens.switchToVisualization('lnsDatatable'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_metrics')).to.eql( + expect(await lens.getDimensionTriggerText('lnsDatatable_metrics')).to.eql( 'Cumulative sum of (incomplete)' ); }); it('should keep the field selection while transitioning to every reference-based operation', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'counter_rate', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'cumulative_sum', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'differences', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'moving_average', }); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Moving average of Sum of bytes' ); }); it('should not leave an incomplete column in the visualization config with field-based operation', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'min', }); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( - undefined - ); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql(undefined); }); it('should revert to previous configuration and not leave an incomplete column in the visualization config with reference-based operations', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'moving_average', field: 'Records', }); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Moving average of Count of records' ); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'median', isPreviousIncompatible: true, keepOpen: true, }); - expect(await PageObjects.lens.isDimensionEditorOpen()).to.eql(true); + expect(await lens.isDimensionEditorOpen()).to.eql(true); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Moving average of Count of records' ); }); it('should transition from unique count to last value', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'unique_count', field: 'ip', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'last_value', field: 'bytes', isPreviousIncompatible: true, }); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Last value of bytes' ); }); @@ -721,34 +708,34 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } else { indexPatternString = 'log*'; } - await PageObjects.lens.switchFirstLayerIndexPattern(indexPatternString); - expect(await PageObjects.lens.getFirstLayerIndexPattern()).to.equal(indexPatternString); + await lens.switchFirstLayerIndexPattern(indexPatternString); + expect(await lens.getFirstLayerIndexPattern()).to.equal(indexPatternString); }); it('should allow filtering by legend on an xy chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'extension.raw', }); - await PageObjects.lens.filterLegend('jpg'); + await lens.filterLegend('jpg'); const hasExtensionFilter = await filterBar.hasFilter('extension.raw', 'jpg'); expect(hasExtensionFilter).to.be(true); @@ -756,30 +743,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should allow filtering by legend on a pie chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('pie'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('pie'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsPie_sliceByDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'extension.raw', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsPie_sliceByDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'agent.raw', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsPie_sizeByDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.filterLegend('jpg'); + await lens.filterLegend('jpg'); const hasExtensionFilter = await filterBar.hasFilter('extension.raw', 'jpg'); expect(hasExtensionFilter).to.be(true); @@ -787,21 +774,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show visual options button group for a pie chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.switchToVisualization('pie'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.switchToVisualization('pie'); - const hasVisualOptionsButton = await PageObjects.lens.hasVisualOptionsButton(); + const hasVisualOptionsButton = await lens.hasVisualOptionsButton(); expect(hasVisualOptionsButton).to.be(true); - await PageObjects.lens.openVisualOptions(); + await lens.openVisualOptions(); await retry.try(async () => { - expect(await PageObjects.lens.hasEmptySizeRatioButtonGroup()).to.be(true); + expect(await lens.hasEmptySizeRatioButtonGroup()).to.be(true); }); }); it('should allow edit meta-data for Lens chart on listing page', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('Afancilenstest'); await listingTable.inspectVisualization(); await listingTable.editVisualizationDetails({ @@ -813,10 +800,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should correctly optimize multiple percentile metrics', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); for (const percentileValue of [90, 95.5, 99.9]) { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'percentile', field: 'bytes', @@ -826,7 +813,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.try(async () => { const value = `${percentileValue}`; // Can not use testSubjects because data-test-subj is placed range input and number input - const percentileInput = await PageObjects.lens.getNumericFieldReady( + const percentileInput = await lens.getNumericFieldReady( 'lns-indexPattern-percentile-input' ); await percentileInput.type(value); @@ -837,10 +824,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } }); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); } - await PageObjects.lens.waitForVisualization('xyVisChart'); - expect(await PageObjects.lens.getWorkspaceErrorCount()).to.eql(0); + await lens.waitForVisualization('xyVisChart'); + expect(await lens.getWorkspaceErrorCount()).to.eql(0); }); }); } diff --git a/x-pack/test/functional/apps/lens/group2/field_formatters.ts b/x-pack/test/functional/apps/lens/group2/field_formatters.ts index 5c52f2bd03acc..33c2c02e7b372 100644 --- a/x-pack/test/functional/apps/lens/group2/field_formatters.ts +++ b/x-pack/test/functional/apps/lens/group2/field_formatters.ts @@ -10,7 +10,7 @@ import { FIELD_FORMAT_IDS } from '@kbn/field-formats-plugin/common'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'header']); + const { visualize, lens, header } = getPageObjects(['visualize', 'lens', 'header']); const retry = getService('retry'); const fieldEditor = getService('fieldEditor'); const dataViews = getService('dataViews'); @@ -18,17 +18,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens fields formatters tests', () => { describe('keyword formatters', () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); }); after(async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.removeField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.removeField('runtimefield'); await fieldEditor.confirmDelete(); - await PageObjects.lens.waitForFieldMissing('runtimefield'); + await lens.waitForFieldMissing('runtimefield'); }); it('should display url formatter correctly', async () => { await retry.try(async () => { @@ -40,94 +40,90 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await fieldEditor.setUrlFieldFormat('https://www.elastic.co?{{value}}'); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.searchField('runtime'); - await PageObjects.lens.waitForField('runtimefield'); - await PageObjects.lens.dragFieldToWorkspace('runtimefield'); + await header.waitUntilLoadingHasFinished(); + await lens.searchField('runtime'); + await lens.waitForField('runtimefield'); + await lens.dragFieldToWorkspace('runtimefield'); }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal( - 'Top 5 values of runtimefield' - ); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql( - 'https://www.elastic.co?CN' - ); + await lens.waitForVisualization(); + expect(await lens.getDatatableHeaderText(0)).to.equal('Top 5 values of runtimefield'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('https://www.elastic.co?CN'); }); it('should display static lookup formatter correctly', async () => { await retry.try(async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.editField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.editField('runtimefield'); await fieldEditor.setFormat(FIELD_FORMAT_IDS.STATIC_LOOKUP); await fieldEditor.setStaticLookupFormat('CN', 'China'); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('China'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('China'); }); it('should display color formatter correctly', async () => { await retry.try(async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.editField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.editField('runtimefield'); await fieldEditor.setFormat(FIELD_FORMAT_IDS.COLOR); await fieldEditor.setColorFormat('CN', '#ffffff', '#ff0000'); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); - await PageObjects.lens.waitForVisualization(); - const styleObj = await PageObjects.lens.getDatatableCellSpanStyle(0, 0); + await lens.waitForVisualization(); + const styleObj = await lens.getDatatableCellSpanStyle(0, 0); expect(styleObj['background-color']).to.be('rgb(255, 0, 0)'); expect(styleObj.color).to.be('rgb(255, 255, 255)'); }); it('should display string formatter correctly', async () => { await retry.try(async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.editField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.editField('runtimefield'); await fieldEditor.setFormat(FIELD_FORMAT_IDS.STRING); await fieldEditor.setStringFormat('lower'); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('cn'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('cn'); }); it('should display truncate string formatter correctly', async () => { await retry.try(async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.editField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.editField('runtimefield'); await fieldEditor.clearScript(); await fieldEditor.typeScript("emit(doc['links.raw'].value)"); await fieldEditor.setFormat(FIELD_FORMAT_IDS.TRUNCATE); await fieldEditor.setTruncateFormatLength('3'); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('dal...'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('dal...'); }); }); describe('number formatters', () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); }); after(async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.removeField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.removeField('runtimefield'); await fieldEditor.confirmDelete(); - await PageObjects.lens.waitForFieldMissing('runtimefield'); + await lens.waitForFieldMissing('runtimefield'); }); it('should display bytes number formatter correctly', async () => { await retry.try(async () => { @@ -139,69 +135,69 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await fieldEditor.setFormat(FIELD_FORMAT_IDS.BYTES); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.configureDimension({ + await header.waitUntilLoadingHasFinished(); + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'average', field: 'runtimefield', }); }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('5.6KB'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('5.6KB'); }); it('should display currency number formatter correctly', async () => { await retry.try(async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.editField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.editField('runtimefield'); await fieldEditor.setFormat(FIELD_FORMAT_IDS.CURRENCY); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('$5,727.32'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('$5,727.32'); }); it('should display duration number formatter correctly', async () => { await retry.try(async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.editField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.editField('runtimefield'); await fieldEditor.setFormat(FIELD_FORMAT_IDS.DURATION); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('2 hours'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('2 hours'); }); it('should display percentage number formatter correctly', async () => { await retry.try(async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.editField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.editField('runtimefield'); await fieldEditor.setFormat(FIELD_FORMAT_IDS.PERCENT); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('572,732.21%'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('572,732.21%'); }); }); describe('formatter order', () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); }); after(async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.removeField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.removeField('runtimefield'); await fieldEditor.confirmDelete(); - await PageObjects.lens.waitForFieldMissing('runtimefield'); + await lens.waitForFieldMissing('runtimefield'); }); it('should be overridden by Lens formatter', async () => { await retry.try(async () => { @@ -213,18 +209,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await fieldEditor.setFormat(FIELD_FORMAT_IDS.BYTES); await fieldEditor.save(); await fieldEditor.waitUntilClosed(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'average', field: 'runtimefield', keepOpen: true, }); - await PageObjects.lens.editDimensionFormat('Bits (1000)', { decimals: 3, prefix: 'blah' }); - await PageObjects.lens.closeDimensionEditor(); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('5.727kbitblah'); + await lens.editDimensionFormat('Bits (1000)', { decimals: 3, prefix: 'blah' }); + await lens.closeDimensionEditor(); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('5.727kbitblah'); }); }); }); diff --git a/x-pack/test/functional/apps/lens/group2/fields_list.ts b/x-pack/test/functional/apps/lens/group2/fields_list.ts index dff265f0c4a40..b08538829b13f 100644 --- a/x-pack/test/functional/apps/lens/group2/fields_list.ts +++ b/x-pack/test/functional/apps/lens/group2/fields_list.ts @@ -9,7 +9,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'timePicker', 'header']); + const { visualize, lens, timePicker, header } = getPageObjects([ + 'visualize', + 'lens', + 'timePicker', + 'header', + ]); const find = getService('find'); const log = getService('log'); const testSubjects = getService('testSubjects'); @@ -24,8 +29,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { for (const datasourceType of ['form-based', 'ad-hoc', 'ad-hoc-no-timefield']) { describe(`${datasourceType} datasource`, () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); if (datasourceType !== 'form-based') { await dataViews.createFromSearchBar({ @@ -37,7 +42,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } if (datasourceType !== 'ad-hoc-no-timefield') { - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); } await retry.try(async () => { @@ -46,7 +51,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await fieldEditor.enableValue(); await fieldEditor.typeScript("emit('abc')"); await fieldEditor.save(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.missingOrFail('fieldEditor'); }); }); @@ -57,7 +62,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show a histogram and top values popover for numeric field', async () => { - const [fieldId] = await PageObjects.lens.findFieldIdsByType('number'); + const [fieldId] = await lens.findFieldIdsByType('number'); await log.debug(`Opening field stats for ${fieldId}`); await testSubjects.click(fieldId); // check for popover @@ -79,7 +84,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show a top values popover for a keyword field', async () => { - const [fieldId] = await PageObjects.lens.findFieldIdsByType('keyword'); + const [fieldId] = await lens.findFieldIdsByType('keyword'); await log.debug(`Opening field stats for ${fieldId}`); await testSubjects.click(fieldId); // check for popover @@ -99,7 +104,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show a date histogram popover for a date field', async () => { - const [fieldId] = await PageObjects.lens.findFieldIdsByType('date'); + const [fieldId] = await lens.findFieldIdsByType('date'); await log.debug(`Opening field stats for ${fieldId}`); await testSubjects.click(fieldId); // check for popover @@ -115,7 +120,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show examples for geo points field', async () => { - const [fieldId] = await PageObjects.lens.findFieldIdsByType('geo_point'); + const [fieldId] = await lens.findFieldIdsByType('geo_point'); await log.debug(`Opening field stats for ${fieldId}`); await testSubjects.click(fieldId); // check for top values chart @@ -125,10 +130,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show stats for a numeric runtime field', async () => { - await PageObjects.lens.searchField('runtime'); - await PageObjects.lens.waitForMissingField('Records'); - await PageObjects.lens.waitForField('runtime_number'); - const [fieldId] = await PageObjects.lens.findFieldIdsByType('number'); + await lens.searchField('runtime'); + await lens.waitForMissingField('Records'); + await lens.waitForField('runtime_number'); + const [fieldId] = await lens.findFieldIdsByType('number'); await log.debug(`Opening field stats for ${fieldId}`); await testSubjects.click(fieldId); // check for popover @@ -151,9 +156,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show stats for a keyword runtime field', async () => { - await PageObjects.lens.searchField('runtime'); - await PageObjects.lens.waitForField('runtime_string'); - const [fieldId] = await PageObjects.lens.findFieldIdsByType('keyword'); + await lens.searchField('runtime'); + await lens.waitForField('runtime_string'); + const [fieldId] = await lens.findFieldIdsByType('keyword'); await log.debug(`Opening field stats for ${fieldId}`); await testSubjects.click(fieldId); // check for popover @@ -166,12 +171,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '[data-test-subj="lnsFieldListPanelFieldContent"] .echChart' ) ).to.eql(false); - await PageObjects.lens.searchField(''); + await lens.searchField(''); }); it('should change popover content if user defines a filter that affects field values', async () => { // check the current records count for stats - const [fieldId] = await PageObjects.lens.findFieldIdsByType('keyword'); + const [fieldId] = await lens.findFieldIdsByType('keyword'); await log.debug(`Opening field stats for ${fieldId}`); await testSubjects.click(fieldId); const valuesCount = parseInt( @@ -200,7 +205,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await filterBar.removeAllFilters(); await filterBar.addFilter({ field: 'bytes', operation: 'is', value: '-1' }); // check via popup fields have no data - const [fieldId] = await PageObjects.lens.findFieldIdsByType('keyword'); + const [fieldId] = await lens.findFieldIdsByType('keyword'); await log.debug(`Opening field stats for ${fieldId}`); await retry.try(async () => { await testSubjects.click(fieldId); @@ -215,10 +220,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // remove the filter await filterBar.removeAllFilters(); // tweak the time range to 17 Sept 2015 to 18 Sept 2015 - await PageObjects.lens.goToTimeRange( - 'Sep 17, 2015 @ 06:31:44.000', - 'Sep 18, 2015 @ 06:31:44.000' - ); + await lens.goToTimeRange('Sep 17, 2015 @ 06:31:44.000', 'Sep 18, 2015 @ 06:31:44.000'); // check all fields are empty now expect( await (await testSubjects.find('lnsIndexPatternEmptyFields-count')).getVisibleText() @@ -244,9 +246,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { oldField: 10, }, }); - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.timePicker.setCommonlyUsedTime('This_week'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await timePicker.setCommonlyUsedTime('This_week'); await dataViews.createFromSearchBar({ name: 'field-update-test', @@ -273,11 +275,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }, }); - await PageObjects.lens.waitForField('oldField'); + await lens.waitForField('oldField'); await queryBar.setQuery('oldField: 20'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.waitForField('newField'); + await header.waitUntilLoadingHasFinished(); + await lens.waitForField('newField'); }); }); }); diff --git a/x-pack/test/functional/apps/lens/group2/index.ts b/x-pack/test/functional/apps/lens/group2/index.ts index 33266513323c9..8d74dd4930b89 100644 --- a/x-pack/test/functional/apps/lens/group2/index.ts +++ b/x-pack/test/functional/apps/lens/group2/index.ts @@ -13,7 +13,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['timePicker']); + const { timePicker } = getPageObjects(['timePicker']); describe('lens app - group 2', () => { const esArchive = 'x-pack/test/functional/es_archives/logstash_functional'; @@ -37,7 +37,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext indexPatternString = localIndexPatternString; await esNode.load(esArchive); // changing the timepicker default here saves us from having to set it in Discover (~8s) - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: indexPatternString, 'dateFormat:tz': 'UTC', @@ -48,7 +48,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext after(async () => { await esNode.unload(esArchive); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.importExport.unload(fixtureDirs.lensBasic); await kibanaServer.importExport.unload(fixtureDirs.lensDefault); await kibanaServer.savedObjects.cleanStandardList(); diff --git a/x-pack/test/functional/apps/lens/group2/layer_actions.ts b/x-pack/test/functional/apps/lens/group2/layer_actions.ts index 77d36603c0252..cc301c2dd57e5 100644 --- a/x-pack/test/functional/apps/lens/group2/layer_actions.ts +++ b/x-pack/test/functional/apps/lens/group2/layer_actions.ts @@ -9,21 +9,21 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const find = getService('find'); const testSubjects = getService('testSubjects'); const retry = getService('retry'); describe('lens layer actions tests', () => { it('should allow creation of lens xy chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); // check that no sampling info is shown in the dataView picker expect(await testSubjects.exists('lnsChangeIndexPatternSamplingInfo')).to.be(false); - await PageObjects.lens.openLayerContextMenu(); + await lens.openLayerContextMenu(); // should be 3 actions available expect( @@ -37,11 +37,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // random sampling available await testSubjects.existOrFail('lns-indexPattern-random-sampling-row'); // tweak the value - await PageObjects.lens.dragRangeInput('lns-indexPattern-random-sampling-slider', 2, 'left'); + await lens.dragRangeInput('lns-indexPattern-random-sampling-slider', 2, 'left'); - expect( - await PageObjects.lens.getRangeInputValue('lns-indexPattern-random-sampling-slider') - ).to.eql( + expect(await lens.getRangeInputValue('lns-indexPattern-random-sampling-slider')).to.eql( 3 // 1% ); await testSubjects.click('lns-indexPattern-dimensionContainerBack'); @@ -52,7 +50,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should expose the ignore global filters control for a data layer', async () => { - await PageObjects.lens.openLayerContextMenu(); + await lens.openLayerContextMenu(); expect( await testSubjects.exists('lns-layerPanel-0 > lnsChangeIndexPatternIgnoringFilters') ).to.be(false); @@ -68,25 +66,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should add an annotation layer and settings shoud be available with ignore filters', async () => { // configure a date histogram - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); // add annotation layer - await PageObjects.lens.createLayer('annotations'); + await lens.createLayer('annotations'); expect( await testSubjects.exists('lns-layerPanel-1 > lnsChangeIndexPatternIgnoringFilters') ).to.be(true); - await PageObjects.lens.openLayerContextMenu(1); + await lens.openLayerContextMenu(1); await testSubjects.click('lnsLayerSettings'); // annotations settings have only ignore filters await testSubjects.click('lns-layerSettings-ignoreGlobalFilters'); @@ -98,24 +96,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should add a new visualization layer and disable the sampling if max operation is chosen', async () => { - await PageObjects.lens.createLayer('data'); + await lens.createLayer('data'); - await PageObjects.lens.openLayerContextMenu(2); + await lens.openLayerContextMenu(2); // click on open layer settings await testSubjects.click('lnsLayerSettings'); // tweak the value - await PageObjects.lens.dragRangeInput('lns-indexPattern-random-sampling-slider', 2, 'left'); + await lens.dragRangeInput('lns-indexPattern-random-sampling-slider', 2, 'left'); await testSubjects.click('lns-indexPattern-dimensionContainerBack'); // check the sampling is shown await testSubjects.existOrFail('lns-layerPanel-2 > lnsChangeIndexPatternSamplingInfo'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-2 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); // now configure a max operation - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-2 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'max', field: 'bytes', @@ -129,7 +127,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // check that sampling info is hidden as disabled now the dataView picker await testSubjects.missingOrFail('lns-layerPanel-2 > lnsChangeIndexPatternSamplingInfo'); // open the layer settings and check that the slider is disabled - await PageObjects.lens.openLayerContextMenu(2); + await lens.openLayerContextMenu(2); // click on open layer settings await testSubjects.click('lnsLayerSettings'); expect( @@ -139,15 +137,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should expose sampling and ignore filters settings for reference lines layer', async () => { - await PageObjects.lens.createLayer('referenceLine'); + await lens.createLayer('referenceLine'); - await PageObjects.lens.openLayerContextMenu(3); + await lens.openLayerContextMenu(3); // click on open layer settings await testSubjects.click('lnsLayerSettings'); // random sampling available await testSubjects.existOrFail('lns-indexPattern-random-sampling-row'); // tweak the value - await PageObjects.lens.dragRangeInput('lns-indexPattern-random-sampling-slider', 2, 'left'); + await lens.dragRangeInput('lns-indexPattern-random-sampling-slider', 2, 'left'); // annotations settings have only ignore filters await testSubjects.click('lns-layerSettings-ignoreGlobalFilters'); await testSubjects.click('lns-indexPattern-dimensionContainerBack'); @@ -162,75 +160,71 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should switch to pie chart and have layer settings available', async () => { - await PageObjects.lens.switchToVisualization('pie'); - await PageObjects.lens.openLayerContextMenu(); + await lens.switchToVisualization('pie'); + await lens.openLayerContextMenu(); // layer settings still available // open the panel await testSubjects.click('lnsLayerSettings'); // check the sampling value - expect( - await PageObjects.lens.getRangeInputValue('lns-indexPattern-random-sampling-slider') - ).to.eql( + expect(await lens.getRangeInputValue('lns-indexPattern-random-sampling-slider')).to.eql( 3 // 1% ); await testSubjects.click('lns-indexPattern-dimensionContainerBack'); }); it('should switch to table and still have layer settings', async () => { - await PageObjects.lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.openLayerContextMenu(); + await lens.switchToVisualization('lnsDatatable'); + await lens.openLayerContextMenu(); // layer settings still available // open the panel await testSubjects.click('lnsLayerSettings'); // check the sampling value - expect( - await PageObjects.lens.getRangeInputValue('lns-indexPattern-random-sampling-slider') - ).to.eql( + expect(await lens.getRangeInputValue('lns-indexPattern-random-sampling-slider')).to.eql( 3 // 1% ); await testSubjects.click('lns-indexPattern-dimensionContainerBack'); }); it('should show visualization modifiers for layer settings when embedded in a dashboard', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); // click on open layer settings - await PageObjects.lens.openLayerContextMenu(); + await lens.openLayerContextMenu(); await testSubjects.click('lnsLayerSettings'); // tweak the value - await PageObjects.lens.dragRangeInput('lns-indexPattern-random-sampling-slider', 2, 'left'); + await lens.dragRangeInput('lns-indexPattern-random-sampling-slider', 2, 'left'); await testSubjects.click('lns-indexPattern-dimensionContainerBack'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); // add another layer with a different sampling rate - await PageObjects.lens.createLayer('data'); + await lens.createLayer('data'); - await PageObjects.lens.openLayerContextMenu(1); + await lens.openLayerContextMenu(1); // click on open layer settings await testSubjects.click('lnsLayerSettings'); // tweak the value - await PageObjects.lens.dragRangeInput('lns-indexPattern-random-sampling-slider', 3, 'left'); + await lens.dragRangeInput('lns-indexPattern-random-sampling-slider', 3, 'left'); await testSubjects.click('lns-indexPattern-dimensionContainerBack'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', @@ -238,7 +232,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // add annotation layer // by default annotations ignore global filters - await PageObjects.lens.createLayer('annotations'); + await lens.createLayer('annotations'); await testSubjects.click('lns-layerPanel-2 > lnsXY_xAnnotationsPanel > lns-dimensionTrigger'); @@ -253,9 +247,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } }); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - await PageObjects.lens.save('sampledVisualization', false, true, false, 'new'); + await lens.save('sampledVisualization', false, true, false, 'new'); // now check for the bottom-left badge await testSubjects.existOrFail('lns-feature-badges-trigger'); diff --git a/x-pack/test/functional/apps/lens/group2/partition.ts b/x-pack/test/functional/apps/lens/group2/partition.ts index cb4894866c23f..f828c65eab284 100644 --- a/x-pack/test/functional/apps/lens/group2/partition.ts +++ b/x-pack/test/functional/apps/lens/group2/partition.ts @@ -9,27 +9,27 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const testSubjects = getService('testSubjects'); describe('lens partition charts', () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); }); it('should be able to nest up to 3 levels for Pie charts', async () => { - await PageObjects.lens.switchToVisualization('pie'); + await lens.switchToVisualization('pie'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsPie_sizeByDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); for (const field of ['ip', 'extension.raw', 'geo.dest']) { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsPie_sliceByDimensionPanel > lns-empty-dimension', operation: 'terms', field, @@ -38,18 +38,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not expose the grouping switch in Pie', async () => { - await PageObjects.lens.openDimensionEditor( - 'lnsPie_sliceByDimensionPanel > lns-dimensionTrigger' - ); + await lens.openDimensionEditor('lnsPie_sliceByDimensionPanel > lns-dimensionTrigger'); expect(await testSubjects.exists('indexPattern-nesting-switch')).to.eql(false); expect(await testSubjects.exists('indexPattern-nesting-select')).to.eql(false); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should switch to donut charts keeping all dimensions', async () => { - await PageObjects.lens.setDonutHoleSize('Large'); + await lens.setDonutHoleSize('Large'); expect( await testSubjects.exists('lnsPie_sliceByDimensionPanel > lns-empty-dimension') @@ -61,18 +59,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not expose the grouping switch in Donut', async () => { - await PageObjects.lens.openDimensionEditor( - 'lnsPie_sliceByDimensionPanel > lns-dimensionTrigger' - ); + await lens.openDimensionEditor('lnsPie_sliceByDimensionPanel > lns-dimensionTrigger'); expect(await testSubjects.exists('indexPattern-nesting-switch')).to.eql(false); expect(await testSubjects.exists('indexPattern-nesting-select')).to.eql(false); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should switch to treemap chart and keep only the first 2 dimensions', async () => { - await PageObjects.lens.switchToVisualization('treemap'); + await lens.switchToVisualization('treemap'); expect( await testSubjects.exists('lnsPie_groupByDimensionPanel > lns-empty-dimension') @@ -84,18 +80,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not expose the grouping switch in Treemap', async () => { - await PageObjects.lens.openDimensionEditor( - 'lnsPie_groupByDimensionPanel > lns-dimensionTrigger' - ); + await lens.openDimensionEditor('lnsPie_groupByDimensionPanel > lns-dimensionTrigger'); expect(await testSubjects.exists('indexPattern-nesting-switch')).to.eql(false); expect(await testSubjects.exists('indexPattern-nesting-select')).to.eql(false); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should switch to Mosaic chart and distribute dimensions as vertical and horizontal', async () => { - await PageObjects.lens.switchToVisualization('mosaic'); + await lens.switchToVisualization('mosaic'); expect( await testSubjects.exists('lnsPie_sliceByDimensionPanel > lns-empty-dimension') @@ -113,17 +107,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should expose the grouping switch in Mosaic', async () => { - await PageObjects.lens.openDimensionEditor( - 'lnsPie_verticalAxisDimensionPanel > lns-dimensionTrigger' - ); + await lens.openDimensionEditor('lnsPie_verticalAxisDimensionPanel > lns-dimensionTrigger'); expect(await testSubjects.exists('indexPattern-nesting-switch')).to.eql(true); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should switch to Waffle chart', async () => { - await PageObjects.lens.switchToVisualization('waffle'); + await lens.switchToVisualization('waffle'); expect( await testSubjects.exists('lnsPie_groupByDimensionPanel > lns-empty-dimension') @@ -135,14 +127,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should expose the grouping switch in Waffle', async () => { - await PageObjects.lens.openDimensionEditor( - 'lnsPie_groupByDimensionPanel > lns-dimensionTrigger' - ); + await lens.openDimensionEditor('lnsPie_groupByDimensionPanel > lns-dimensionTrigger'); expect(await testSubjects.exists('indexPattern-nesting-switch')).to.eql(false); expect(await testSubjects.exists('indexPattern-nesting-select')).to.eql(false); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); }); } diff --git a/x-pack/test/functional/apps/lens/group2/persistent_context.ts b/x-pack/test/functional/apps/lens/group2/persistent_context.ts index 5f82c0aab22a4..0d34b0f68564d 100644 --- a/x-pack/test/functional/apps/lens/group2/persistent_context.ts +++ b/x-pack/test/functional/apps/lens/group2/persistent_context.ts @@ -9,12 +9,11 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { visualize, lens, header, timePicker, navigationalSearch } = getPageObjects([ 'visualize', 'lens', 'header', 'timePicker', - 'common', 'navigationalSearch', ]); const browser = getService('browser'); @@ -41,28 +40,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Navigation search', () => { describe('when opening from empty visualization to existing one', () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.navigationalSearch.focus(); - await PageObjects.navigationalSearch.searchFor('type:lens lnsTableVis'); - await PageObjects.navigationalSearch.clickOnOption(0); - await PageObjects.lens.waitForWorkspaceWithVisualization(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await navigationalSearch.focus(); + await navigationalSearch.searchFor('type:lens lnsTableVis'); + await navigationalSearch.clickOnOption(0); + await lens.waitForWorkspaceWithVisualization(); }); it('filters, time and query reflect the visualization state', async () => { - expect(await PageObjects.lens.getDatatableHeaderText(1)).to.equal( - '404 › Median of bytes' - ); - expect(await PageObjects.lens.getDatatableHeaderText(2)).to.equal( - '503 › Median of bytes' - ); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('TG'); - expect(await PageObjects.lens.getDatatableCellText(0, 1)).to.eql('9,931'); + expect(await lens.getDatatableHeaderText(1)).to.equal('404 › Median of bytes'); + expect(await lens.getDatatableHeaderText(2)).to.equal('503 › Median of bytes'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('TG'); + expect(await lens.getDatatableCellText(0, 1)).to.eql('9,931'); }); it('preserves time range', async () => { - const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); - expect(timePickerValues.start).to.eql(PageObjects.timePicker.defaultStartTime); - expect(timePickerValues.end).to.eql(PageObjects.timePicker.defaultEndTime); + const timePickerValues = await timePicker.getTimeConfigAsAbsoluteTimes(); + expect(timePickerValues.start).to.eql(timePicker.defaultStartTime); + expect(timePickerValues.end).to.eql(timePicker.defaultEndTime); // data is correct and top nav is correct }); it('loads filters', async () => { @@ -76,23 +71,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); describe('when opening from existing visualization to empty one', () => { before(async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsTableVis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsTableVis'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.navigationalSearch.focus(); - await PageObjects.navigationalSearch.searchFor('type:application lens'); - await PageObjects.navigationalSearch.clickOnOption(0); - await PageObjects.lens.waitForEmptyWorkspace(); - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); - await PageObjects.lens.dragFieldToWorkspace('@timestamp', 'legacyMtrVis'); + await lens.clickVisualizeListItemTitle('lnsTableVis'); + await lens.goToTimeRange(); + await navigationalSearch.focus(); + await navigationalSearch.searchFor('type:application lens'); + await navigationalSearch.clickOnOption(0); + await lens.waitForEmptyWorkspace(); + await lens.switchToVisualization('lnsLegacyMetric'); + await lens.dragFieldToWorkspace('@timestamp', 'legacyMtrVis'); }); it('preserves time range', async () => { // fill the navigation search and select empty // see the time - const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); - expect(timePickerValues.start).to.eql(PageObjects.timePicker.defaultStartTime); - expect(timePickerValues.end).to.eql(PageObjects.timePicker.defaultEndTime); + const timePickerValues = await timePicker.getTimeConfigAsAbsoluteTimes(); + expect(timePickerValues.start).to.eql(timePicker.defaultStartTime); + expect(timePickerValues.end).to.eql(timePicker.defaultEndTime); }); it('cleans filters', async () => { const filterCount = await filterBar.getFilterCount(); @@ -103,7 +98,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(query).to.equal(''); }); it('filters, time and query reflect the visualization state', async () => { - await PageObjects.lens.assertLegacyMetric('Unique count of @timestamp', '14,181'); + await lens.assertLegacyMetric('Unique count of @timestamp', '14,181'); }); }); }); @@ -111,42 +106,42 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Switching in Visualize App', () => { it('when moving from existing to empty workspace, preserves time range, cleans filters and query', async () => { // go to existing vis - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsTableVis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsTableVis'); - await PageObjects.lens.goToTimeRange(); + await lens.clickVisualizeListItemTitle('lnsTableVis'); + await lens.goToTimeRange(); // go to empty vis - await PageObjects.lens.goToListingPageViaBreadcrumbs(); - await PageObjects.visualize.clickNewVisualization(); - await PageObjects.visualize.waitForGroupsSelectPage(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.waitForEmptyWorkspace(); - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); - await PageObjects.lens.dragFieldToWorkspace('@timestamp', 'legacyMtrVis'); + await lens.goToListingPageViaBreadcrumbs(); + await visualize.clickNewVisualization(); + await visualize.waitForGroupsSelectPage(); + await visualize.clickVisType('lens'); + await lens.waitForEmptyWorkspace(); + await lens.switchToVisualization('lnsLegacyMetric'); + await lens.dragFieldToWorkspace('@timestamp', 'legacyMtrVis'); - const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); - expect(timePickerValues.start).to.eql(PageObjects.timePicker.defaultStartTime); - expect(timePickerValues.end).to.eql(PageObjects.timePicker.defaultEndTime); + const timePickerValues = await timePicker.getTimeConfigAsAbsoluteTimes(); + expect(timePickerValues.start).to.eql(timePicker.defaultStartTime); + expect(timePickerValues.end).to.eql(timePicker.defaultEndTime); const filterCount = await filterBar.getFilterCount(); expect(filterCount).to.equal(0); const query = await queryBar.getQueryString(); expect(query).to.equal(''); - await PageObjects.lens.assertLegacyMetric('Unique count of @timestamp', '14,181'); + await lens.assertLegacyMetric('Unique count of @timestamp', '14,181'); }); it('when moving from empty to existing workspace, preserves time range and loads filters and query', async () => { // go to existing vis - await PageObjects.lens.goToListingPageViaBreadcrumbs(); + await lens.goToListingPageViaBreadcrumbs(); await listingTable.searchForItemWithName('lnsTableVis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsTableVis'); + await lens.clickVisualizeListItemTitle('lnsTableVis'); - expect(await PageObjects.lens.getDatatableHeaderText(1)).to.equal('404 › Median of bytes'); - expect(await PageObjects.lens.getDatatableHeaderText(2)).to.equal('503 › Median of bytes'); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('TG'); - expect(await PageObjects.lens.getDatatableCellText(0, 1)).to.eql('9,931'); + expect(await lens.getDatatableHeaderText(1)).to.equal('404 › Median of bytes'); + expect(await lens.getDatatableHeaderText(2)).to.equal('503 › Median of bytes'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('TG'); + expect(await lens.getDatatableCellText(0, 1)).to.eql('9,931'); - const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); - expect(timePickerValues.start).to.eql(PageObjects.timePicker.defaultStartTime); - expect(timePickerValues.end).to.eql(PageObjects.timePicker.defaultEndTime); + const timePickerValues = await timePicker.getTimeConfigAsAbsoluteTimes(); + expect(timePickerValues.start).to.eql(timePicker.defaultStartTime); + expect(timePickerValues.end).to.eql(timePicker.defaultEndTime); const filterCount = await filterBar.getFilterCount(); expect(filterCount).to.equal(1); const query = await queryBar.getQueryString(); @@ -155,32 +150,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should carry over time range and pinned filters to discover', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange( - 'Sep 6, 2015 @ 06:31:44.000', - 'Sep 18, 2025 @ 06:31:44.000' - ); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange('Sep 6, 2015 @ 06:31:44.000', 'Sep 18, 2025 @ 06:31:44.000'); await filterBar.addFilter({ field: 'ip', operation: 'is', value: '97.220.3.248' }); await filterBar.toggleFilterPinned('ip'); - await PageObjects.header.clickDiscover(); - const timeRange = await PageObjects.timePicker.getTimeConfig(); + await header.clickDiscover(); + const timeRange = await timePicker.getTimeConfig(); expect(timeRange.start).to.equal('Sep 6, 2015 @ 06:31:44.000'); expect(timeRange.end).to.equal('Sep 18, 2025 @ 06:31:44.000'); await filterBar.hasFilter('ip', '97.220.3.248', true, true); }); it('should remember time range and pinned filters from discover', async () => { - await PageObjects.lens.goToTimeRange( - 'Sep 7, 2015 @ 06:31:44.000', - 'Sep 19, 2025 @ 06:31:44.000' - ); + await lens.goToTimeRange('Sep 7, 2015 @ 06:31:44.000', 'Sep 19, 2025 @ 06:31:44.000'); await filterBar.toggleFilterEnabled('ip'); await appsMenu.clickLink('Visualize Library', { category: 'kibana' }); - await PageObjects.visualize.clickNewVisualization(); - await PageObjects.visualize.waitForGroupsSelectPage(); - await PageObjects.visualize.clickVisType('lens'); - const timeRange = await PageObjects.timePicker.getTimeConfig(); + await visualize.clickNewVisualization(); + await visualize.waitForGroupsSelectPage(); + await visualize.clickVisType('lens'); + const timeRange = await timePicker.getTimeConfig(); expect(timeRange.start).to.equal('Sep 7, 2015 @ 06:31:44.000'); expect(timeRange.end).to.equal('Sep 19, 2025 @ 06:31:44.000'); await filterBar.hasFilter('ip', '97.220.3.248', false, true); @@ -190,7 +179,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.refresh(); // Lens app can take a while to be fully functional after refresh, retry assertion await retry.try(async () => { - const timeRange = await PageObjects.timePicker.getTimeConfig(); + const timeRange = await timePicker.getTimeConfig(); expect(timeRange.start).to.equal('Sep 7, 2015 @ 06:31:44.000'); expect(timeRange.end).to.equal('Sep 19, 2025 @ 06:31:44.000'); await filterBar.hasFilter('ip', '97.220.3.248', false, true); @@ -198,7 +187,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('keeps selected index pattern after refresh', async () => { - await PageObjects.lens.switchDataPanelIndexPattern('log*'); + await lens.switchDataPanelIndexPattern('log*'); await browser.refresh(); // Lens app can take a while to be fully functional after refresh, retry assertion await dataViews.waitForSwitcherToBe('log*'); @@ -207,22 +196,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('keeps time range and pinned filters after refreshing directly after saving', async () => { // restore defaults so visualization becomes saveable await security.testUser.restoreDefaults(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.save('persistentcontext'); + await lens.save('persistentcontext'); await browser.refresh(); // Lens app can take a while to be fully functional after refresh, retry assertion await retry.try(async () => { - const timeRange = await PageObjects.timePicker.getTimeConfig(); + const timeRange = await timePicker.getTimeConfig(); expect(timeRange.start).to.equal('Sep 7, 2015 @ 06:31:44.000'); expect(timeRange.end).to.equal('Sep 19, 2025 @ 06:31:44.000'); await filterBar.hasFilter('ip', '97.220.3.248', false, true); diff --git a/x-pack/test/functional/apps/lens/group2/table.ts b/x-pack/test/functional/apps/lens/group2/table.ts index 61e8b5f25554c..f98bb6328c3f9 100644 --- a/x-pack/test/functional/apps/lens/group2/table.ts +++ b/x-pack/test/functional/apps/lens/group2/table.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const listingTable = getService('listingTable'); const find = getService('find'); const retry = getService('retry'); @@ -17,72 +17,72 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens datatable', () => { it('should able to sort a table by a column', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); // Sort by number - await PageObjects.lens.changeTableSortingBy(2, 'ascending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 2)).to.eql('17,246'); + await lens.changeTableSortingBy(2, 'ascending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 2)).to.eql('17,246'); // Now sort by IP - await PageObjects.lens.changeTableSortingBy(0, 'ascending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('78.83.247.30'); + await lens.changeTableSortingBy(0, 'ascending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('78.83.247.30'); // Change the sorting - await PageObjects.lens.changeTableSortingBy(0, 'descending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('169.228.188.120'); + await lens.changeTableSortingBy(0, 'descending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('169.228.188.120'); // Remove the sorting await retry.try(async () => { - await PageObjects.lens.changeTableSortingBy(0, 'none'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.isDatatableHeaderSorted(0)).to.eql(false); + await lens.changeTableSortingBy(0, 'none'); + await lens.waitForVisualization(); + expect(await lens.isDatatableHeaderSorted(0)).to.eql(false); }); }); it('should able to sort a last_value column correctly in a table', async () => { // configure last_value with a keyword field - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'last_value', field: 'geo.dest', }); - await PageObjects.lens.changeTableSortingBy(3, 'ascending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 3)).to.eql('CN'); + await lens.changeTableSortingBy(3, 'ascending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 3)).to.eql('CN'); - await PageObjects.lens.changeTableSortingBy(3, 'descending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 3)).to.eql('PH'); + await lens.changeTableSortingBy(3, 'descending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 3)).to.eql('PH'); // now configure a new one with an ip field - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'last_value', field: 'ip', }); - await PageObjects.lens.changeTableSortingBy(4, 'ascending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 4)).to.eql('78.83.247.30'); + await lens.changeTableSortingBy(4, 'ascending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 4)).to.eql('78.83.247.30'); // Change the sorting - await PageObjects.lens.changeTableSortingBy(4, 'descending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('169.228.188.120'); + await lens.changeTableSortingBy(4, 'descending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('169.228.188.120'); await retry.try(async () => { - await PageObjects.lens.changeTableSortingBy(4, 'none'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.isDatatableHeaderSorted(0)).to.eql(false); + await lens.changeTableSortingBy(4, 'none'); + await lens.waitForVisualization(); + expect(await lens.isDatatableHeaderSorted(0)).to.eql(false); }); // clear all metrics and reconfigure the default - await PageObjects.lens.removeDimension('lnsDatatable_metrics'); - await PageObjects.lens.removeDimension('lnsDatatable_metrics'); - await PageObjects.lens.removeDimension('lnsDatatable_metrics'); - await PageObjects.lens.configureDimension({ + await lens.removeDimension('lnsDatatable_metrics'); + await lens.removeDimension('lnsDatatable_metrics'); + await lens.removeDimension('lnsDatatable_metrics'); + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'average', field: 'bytes', @@ -90,10 +90,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should able to use filters cell actions in table', async () => { - const firstCellContent = await PageObjects.lens.getDatatableCellText(0, 0); + const firstCellContent = await lens.getDatatableCellText(0, 0); await retry.try(async () => { - await PageObjects.lens.clickTableCellAction(0, 0, 'lensDatatableFilterOut'); - await PageObjects.lens.waitForVisualization(); + await lens.clickTableCellAction(0, 0, 'lensDatatableFilterOut'); + await lens.waitForVisualization(); expect( await find.existsByCssSelector( `[data-test-subj*="filter-value-${firstCellContent}"][data-test-subj*="filter-negated"]` @@ -103,93 +103,87 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should allow to configure column visibility', async () => { - expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal('Top 3 values of ip'); - expect(await PageObjects.lens.getDatatableHeaderText(1)).to.equal('@timestamp per 3 hours'); - expect(await PageObjects.lens.getDatatableHeaderText(2)).to.equal('Average of bytes'); + expect(await lens.getDatatableHeaderText(0)).to.equal('Top 3 values of ip'); + expect(await lens.getDatatableHeaderText(1)).to.equal('@timestamp per 3 hours'); + expect(await lens.getDatatableHeaderText(2)).to.equal('Average of bytes'); - await PageObjects.lens.toggleColumnVisibility('lnsDatatable_rows > lns-dimensionTrigger', 1); + await lens.toggleColumnVisibility('lnsDatatable_rows > lns-dimensionTrigger', 1); - expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal('@timestamp per 3 hours'); - expect(await PageObjects.lens.getDatatableHeaderText(1)).to.equal('Average of bytes'); + expect(await lens.getDatatableHeaderText(0)).to.equal('@timestamp per 3 hours'); + expect(await lens.getDatatableHeaderText(1)).to.equal('Average of bytes'); - await PageObjects.lens.toggleColumnVisibility('lnsDatatable_rows > lns-dimensionTrigger', 4); + await lens.toggleColumnVisibility('lnsDatatable_rows > lns-dimensionTrigger', 4); - expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal('Top 3 values of ip'); - expect(await PageObjects.lens.getDatatableHeaderText(1)).to.equal('@timestamp per 3 hours'); - expect(await PageObjects.lens.getDatatableHeaderText(2)).to.equal('Average of bytes'); + expect(await lens.getDatatableHeaderText(0)).to.equal('Top 3 values of ip'); + expect(await lens.getDatatableHeaderText(1)).to.equal('@timestamp per 3 hours'); + expect(await lens.getDatatableHeaderText(2)).to.equal('Average of bytes'); }); it('should allow to transpose columns', async () => { - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lnsDatatable_rows > lns-dimensionTrigger', to: 'lnsDatatable_columns > lns-empty-dimension', }); - // await PageObjects.common.sleep(100000); - expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal('@timestamp per 3 hours'); - expect(await PageObjects.lens.getDatatableHeaderText(1)).to.equal( - '169.228.188.120 › Average of bytes' - ); - expect(await PageObjects.lens.getDatatableHeaderText(2)).to.equal( - '78.83.247.30 › Average of bytes' - ); - expect(await PageObjects.lens.getDatatableHeaderText(3)).to.equal( - '226.82.228.233 › Average of bytes' - ); + // await common.sleep(100000); + expect(await lens.getDatatableHeaderText(0)).to.equal('@timestamp per 3 hours'); + expect(await lens.getDatatableHeaderText(1)).to.equal('169.228.188.120 › Average of bytes'); + expect(await lens.getDatatableHeaderText(2)).to.equal('78.83.247.30 › Average of bytes'); + expect(await lens.getDatatableHeaderText(3)).to.equal('226.82.228.233 › Average of bytes'); }); it('should allow to sort by transposed columns', async () => { - await PageObjects.lens.changeTableSortingBy(2, 'ascending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 2)).to.eql('17,246'); + await lens.changeTableSortingBy(2, 'ascending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 2)).to.eql('17,246'); }); it('should show dynamic coloring feature for numeric columns', async () => { - await PageObjects.lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger'); - await PageObjects.lens.setTableDynamicColoring('text'); - await PageObjects.lens.waitForVisualization(); - const styleObj = await PageObjects.lens.getDatatableCellStyle(0, 2); + await lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger'); + await lens.setTableDynamicColoring('text'); + await lens.waitForVisualization(); + const styleObj = await lens.getDatatableCellStyle(0, 2); expect(styleObj['background-color']).to.be(undefined); expect(styleObj.color).to.be('rgb(133, 189, 177)'); }); it('should allow to color cell background rather than text', async () => { - await PageObjects.lens.setTableDynamicColoring('cell'); - await PageObjects.lens.waitForVisualization(); - const styleObj = await PageObjects.lens.getDatatableCellStyle(0, 2); + await lens.setTableDynamicColoring('cell'); + await lens.waitForVisualization(); + const styleObj = await lens.getDatatableCellStyle(0, 2); expect(styleObj['background-color']).to.be('rgb(133, 189, 177)'); // should also set text color when in cell mode expect(styleObj.color).to.be('rgb(0, 0, 0)'); }); it('should open the palette panel to customize the palette look', async () => { - await PageObjects.lens.openPalettePanel(); - await PageObjects.lens.waitForVisualization(); - await PageObjects.lens.changePaletteTo('temperature'); - await PageObjects.lens.waitForVisualization(); - const styleObj = await PageObjects.lens.getDatatableCellStyle(0, 2); + await lens.openPalettePanel(); + await lens.waitForVisualization(); + await lens.changePaletteTo('temperature'); + await lens.waitForVisualization(); + const styleObj = await lens.getDatatableCellStyle(0, 2); expect(styleObj['background-color']).to.be('rgb(235, 239, 245)'); }); it('should keep the coloring consistent when changing mode', async () => { // Change mode from percent to number await testSubjects.click('lnsPalettePanel_dynamicColoring_rangeType_groups_number'); - await PageObjects.lens.waitForVisualization(); + await lens.waitForVisualization(); // check that all remained the same - const styleObj = await PageObjects.lens.getDatatableCellStyle(0, 2); + const styleObj = await lens.getDatatableCellStyle(0, 2); expect(styleObj['background-color']).to.be('rgb(235, 239, 245)'); }); it('should keep the coloring consistent when moving to custom palette from default', async () => { - await PageObjects.lens.changePaletteTo('custom'); - await PageObjects.lens.waitForVisualization(); + await lens.changePaletteTo('custom'); + await lens.waitForVisualization(); // check that all remained the same - const styleObj = await PageObjects.lens.getDatatableCellStyle(0, 2); + const styleObj = await lens.getDatatableCellStyle(0, 2); expect(styleObj['background-color']).to.be('rgb(235, 239, 245)'); }); it('tweak the color stops numeric value', async () => { // restore default palette and percent mode - await PageObjects.lens.changePaletteTo('temperature'); + await lens.changePaletteTo('temperature'); await testSubjects.click('lnsPalettePanel_dynamicColoring_rangeType_groups_percent'); // now tweak the value await testSubjects.setValue('lnsPalettePanel_dynamicColoring_range_value_0', '30', { @@ -197,9 +191,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // when clicking on another row will trigger a sorting + update await testSubjects.click('lnsPalettePanel_dynamicColoring_range_value_1'); - await PageObjects.lens.waitForVisualization(); + await lens.waitForVisualization(); // pick a cell without color as is below the range - const styleObj = await PageObjects.lens.getDatatableCellStyle(3, 3); + const styleObj = await lens.getDatatableCellStyle(3, 3); expect(styleObj['background-color']).to.be(undefined); // should also set text color when in cell mode expect(styleObj.color).to.be(undefined); @@ -207,18 +201,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should allow the user to reverse the palette', async () => { await testSubjects.click('lnsPalettePanel_dynamicColoring_reverseColors'); - await PageObjects.lens.waitForVisualization(); - const styleObj = await PageObjects.lens.getDatatableCellStyle(1, 1); + await lens.waitForVisualization(); + const styleObj = await lens.getDatatableCellStyle(1, 1); expect(styleObj['background-color']).to.be('rgb(168, 191, 218)'); // should also set text color when in cell mode expect(styleObj.color).to.be('rgb(0, 0, 0)'); - await PageObjects.lens.closePalettePanel(); + await lens.closePalettePanel(); }); it('should allow to show a summary table for metric columns', async () => { - await PageObjects.lens.setTableSummaryRowFunction('sum'); - await PageObjects.lens.waitForVisualization(); - await PageObjects.lens.assertExactText( + await lens.setTableSummaryRowFunction('sum'); + await lens.waitForVisualization(); + await lens.assertExactText( '[data-test-subj="lnsDataTable-footer-169.228.188.120-›-Average-of-bytes"]', 'Sum: 18,994' ); diff --git a/x-pack/test/functional/apps/lens/group2/table_dashboard.ts b/x-pack/test/functional/apps/lens/group2/table_dashboard.ts index 136f1903420de..ddbe8d4a1ff40 100644 --- a/x-pack/test/functional/apps/lens/group2/table_dashboard.ts +++ b/x-pack/test/functional/apps/lens/group2/table_dashboard.ts @@ -9,45 +9,45 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['lens', 'visualize', 'dashboard']); + const { lens, visualize, dashboard } = getPageObjects(['lens', 'visualize', 'dashboard']); const listingTable = getService('listingTable'); const retry = getService('retry'); const checkTableSorting = async () => { // Sort by number - await PageObjects.lens.changeTableSortingBy(2, 'ascending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 2)).to.eql('17,246'); + await lens.changeTableSortingBy(2, 'ascending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 2)).to.eql('17,246'); // Now sort by IP - await PageObjects.lens.changeTableSortingBy(0, 'ascending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('78.83.247.30'); + await lens.changeTableSortingBy(0, 'ascending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('78.83.247.30'); // Change the sorting - await PageObjects.lens.changeTableSortingBy(0, 'descending'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('169.228.188.120'); + await lens.changeTableSortingBy(0, 'descending'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('169.228.188.120'); // Remove the sorting await retry.try(async () => { - await PageObjects.lens.changeTableSortingBy(0, 'none'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.isDatatableHeaderSorted(0)).to.eql(false); + await lens.changeTableSortingBy(0, 'none'); + await lens.waitForVisualization(); + expect(await lens.isDatatableHeaderSorted(0)).to.eql(false); }); }; describe('lens table on dashboard', () => { it('should sort a table by column in dashboard edit mode', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.save('New Table', true, false, false, 'new'); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); + await lens.save('New Table', true, false, false, 'new'); await checkTableSorting(); }); it('should sort a table by column in dashboard view mode', async () => { - await PageObjects.dashboard.saveDashboard('Dashboard with a Lens Table'); + await dashboard.saveDashboard('Dashboard with a Lens Table'); await checkTableSorting(); }); diff --git a/x-pack/test/functional/apps/lens/group3/add_to_dashboard.ts b/x-pack/test/functional/apps/lens/group3/add_to_dashboard.ts index 6723ebcb3c8e9..570463092678f 100644 --- a/x-pack/test/functional/apps/lens/group3/add_to_dashboard.ts +++ b/x-pack/test/functional/apps/lens/group3/add_to_dashboard.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { dashboard, visualize, lens, timeToVisualize, common, header } = getPageObjects([ 'dashboard', 'visualize', 'lens', @@ -20,91 +20,89 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const find = getService('find'); const listingTable = getService('listingTable'); const dashboardAddPanel = getService('dashboardAddPanel'); + const dashboardPanelActions = getService('dashboardPanelActions'); const testSubjects = getService('testSubjects'); const security = getService('security'); const createNewLens = async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); + await lens.switchToVisualization('lnsLegacyMetric'); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); - await PageObjects.lens.assertLegacyMetric('Average of bytes', '5,727.322'); + await lens.waitForVisualization('legacyMtrVis'); + await lens.assertLegacyMetric('Average of bytes', '5,727.322'); }; const createAndSaveDashboard = async (dashboardName: string) => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames('lnsXYvis'); await find.clickByButtonText('lnsXYvis'); await dashboardAddPanel.closeAddPanel(); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); - await PageObjects.dashboard.saveDashboard(dashboardName); - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.saveDashboard(dashboardName); + await dashboard.gotoDashboardLandingPage(); await listingTable.searchAndExpectItemsCount('dashboard', dashboardName, 1); }; const loadExistingLens = async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('Artistpreviouslyknownaslens'); - await PageObjects.lens.clickVisualizeListItemTitle('Artistpreviouslyknownaslens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '19,986'); + await lens.clickVisualizeListItemTitle('Artistpreviouslyknownaslens'); + await lens.goToTimeRange(); + await lens.waitForVisualization('legacyMtrVis'); + await lens.assertLegacyMetric('Maximum of bytes', '19,986'); }; describe('lens add-to-dashboards tests', () => { it('should allow new lens to be added by value to a new dashboard', async () => { await createNewLens(); - await PageObjects.lens.save('New Lens from Modal', false, false, false, 'new'); + await lens.save('New Lens from Modal', false, false, false, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - await PageObjects.lens.assertLegacyMetric('Average of bytes', '5,727.322'); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'New Lens from Modal' - ); - expect(isLinked).to.be(false); + await lens.assertLegacyMetric('Average of bytes', '5,727.322'); + await dashboardPanelActions.expectNotLinkedToLibrary('New Lens from Modal', true); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('should allow existing lens be added by value to a new dashboard', async () => { await loadExistingLens(); - await PageObjects.lens.save('Artistpreviouslyknownaslens Copy', true, false, false, 'new'); + await lens.save('Artistpreviouslyknownaslens Copy', true, false, false, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '19,986'); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'Artistpreviouslyknownaslens Copy' + await lens.assertLegacyMetric('Maximum of bytes', '19,986'); + await dashboardPanelActions.expectNotLinkedToLibrary( + 'Artistpreviouslyknownaslens Copy', + true ); - expect(isLinked).to.be(false); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('should allow new lens be added by value to an existing dashboard', async () => { await createAndSaveDashboard('My Very Cool Dashboard'); await createNewLens(); - await PageObjects.lens.save( + await lens.save( 'New Lens from Modal', false, false, @@ -113,15 +111,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'My Very Cool Dashboard' ); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - await PageObjects.lens.assertLegacyMetric('Average of bytes', '5,727.322'); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'New Lens from Modal' - ); - expect(isLinked).to.be(false); + await lens.assertLegacyMetric('Average of bytes', '5,727.322'); + await dashboardPanelActions.expectNotLinkedToLibrary('New Lens from Modal', true); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(2); }); @@ -129,7 +124,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await createAndSaveDashboard('My Wonderful Dashboard'); await loadExistingLens(); - await PageObjects.lens.save( + await lens.save( 'Artistpreviouslyknownaslens Copy', true, false, @@ -138,59 +133,53 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'My Wonderful Dashboard' ); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '19,986'); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'Artistpreviouslyknownaslens Copy' + await lens.assertLegacyMetric('Maximum of bytes', '19,986'); + await dashboardPanelActions.expectNotLinkedToLibrary( + 'Artistpreviouslyknownaslens Copy', + true ); - expect(isLinked).to.be(false); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(2); }); it('should allow new lens to be added by reference to a new dashboard', async () => { await createNewLens(); - await PageObjects.lens.save('New by ref Lens from Modal', false, false, true, 'new'); + await lens.save('New by ref Lens from Modal', false, false, true, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - await PageObjects.lens.assertLegacyMetric('Average of bytes', '5,727.322'); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'New by ref Lens from Modal' - ); - expect(isLinked).to.be(true); + await lens.assertLegacyMetric('Average of bytes', '5,727.322'); + await dashboardPanelActions.expectLinkedToLibrary('New by ref Lens from Modal', true); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('should allow existing lens be added by reference to a new dashboard', async () => { await loadExistingLens(); - await PageObjects.lens.save('Artistpreviouslyknownaslens by ref', true, false, true, 'new'); + await lens.save('Artistpreviouslyknownaslens by ref', true, false, true, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '19,986'); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'Artistpreviouslyknownaslens by ref' - ); - expect(isLinked).to.be(true); + await lens.assertLegacyMetric('Maximum of bytes', '19,986'); + await dashboardPanelActions.expectLinkedToLibrary('Artistpreviouslyknownaslens by ref', true); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('should allow new lens be added by reference to an existing dashboard', async () => { await createAndSaveDashboard('My Very Cool Dashboard 2'); await createNewLens(); - await PageObjects.lens.save( + await lens.save( 'New Lens by ref from Modal', false, false, @@ -199,15 +188,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'My Very Cool Dashboard 2' ); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - await PageObjects.lens.assertLegacyMetric('Average of bytes', '5,727.322'); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'New Lens by ref from Modal' - ); - expect(isLinked).to.be(true); + await lens.assertLegacyMetric('Average of bytes', '5,727.322'); + await dashboardPanelActions.expectLinkedToLibrary('New Lens by ref from Modal', true); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(2); }); @@ -215,7 +201,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await createAndSaveDashboard('My Wonderful Dashboard 2'); await loadExistingLens(); - await PageObjects.lens.save( + await lens.save( 'Artistpreviouslyknownaslens by ref 2', true, false, @@ -224,56 +210,56 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'My Wonderful Dashboard 2' ); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '19,986'); - const isLinked = await PageObjects.timeToVisualize.libraryNotificationExists( - 'Artistpreviouslyknownaslens by ref 2' + await lens.assertLegacyMetric('Maximum of bytes', '19,986'); + await dashboardPanelActions.expectLinkedToLibrary( + 'Artistpreviouslyknownaslens by ref 2', + true ); - expect(isLinked).to.be(true); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(2); }); // issue #111104 it('should add a Lens heatmap to the dashboard', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.switchToVisualization('heatmap', 'heat'); + await lens.switchToVisualization('heatmap', 'heat'); - await PageObjects.lens.waitForVisualization('heatmapChart'); - await PageObjects.lens.openDimensionEditor('lnsHeatmap_cellPanel > lns-dimensionTrigger'); - await PageObjects.lens.openPalettePanel(); + await lens.waitForVisualization('heatmapChart'); + await lens.openDimensionEditor('lnsHeatmap_cellPanel > lns-dimensionTrigger'); + await lens.openPalettePanel(); await testSubjects.click('lnsPalettePanel_dynamicColoring_rangeType_groups_number'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.lens.save('New Lens Heatmap', false, false, true, 'new'); + await lens.save('New Lens Heatmap', false, false, true, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.eql(1); }); describe('Capabilities', function capabilitiesTests() { describe('dashboard no-access privileges', () => { before(async () => { - await PageObjects.common.navigateToApp('visualize'); + await common.navigateToApp('visualize'); await security.testUser.setRoles(['test_logstash_reader', 'global_visualize_all']); }); @@ -282,31 +268,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not display dashboard flow prompt', async () => { - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.visualize.gotoLandingPage(); + await common.navigateToApp('visualize'); + await header.waitUntilLoadingHasFinished(); + await visualize.gotoLandingPage(); const hasPrompt = await testSubjects.exists('visualize-dashboard-flow-prompt'); expect(hasPrompt).to.eql(false); }); it('should not display add-to-dashboard options', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); + await lens.switchToVisualization('lnsLegacyMetric'); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); - await PageObjects.lens.assertLegacyMetric('Average of bytes', '5,727.322'); + await lens.waitForVisualization('legacyMtrVis'); + await lens.assertLegacyMetric('Average of bytes', '5,727.322'); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); + await lens.waitForVisualization('legacyMtrVis'); await testSubjects.click('lnsApp_saveButton'); const hasOptions = await testSubjects.exists('add-to-dashboard-options'); @@ -328,31 +314,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not display dashboard flow prompt', async () => { - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.visualize.gotoLandingPage(); + await common.navigateToApp('visualize'); + await header.waitUntilLoadingHasFinished(); + await visualize.gotoLandingPage(); const hasPrompt = await testSubjects.exists('visualize-dashboard-flow-prompt'); expect(hasPrompt).to.eql(false); }); it('should not display add-to-dashboard options', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); + await lens.switchToVisualization('lnsLegacyMetric'); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); - await PageObjects.lens.assertLegacyMetric('Average of bytes', '5,727.322'); + await lens.waitForVisualization('legacyMtrVis'); + await lens.assertLegacyMetric('Average of bytes', '5,727.322'); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); + await lens.waitForVisualization('legacyMtrVis'); await testSubjects.click('lnsApp_saveButton'); const hasOptions = await testSubjects.exists('add-to-dashboard-options'); diff --git a/x-pack/test/functional/apps/lens/group3/dashboard_inline_editing.ts b/x-pack/test/functional/apps/lens/group3/dashboard_inline_editing.ts index 8ef5c8993a8ee..2d92d98dc3606 100644 --- a/x-pack/test/functional/apps/lens/group3/dashboard_inline_editing.ts +++ b/x-pack/test/functional/apps/lens/group3/dashboard_inline_editing.ts @@ -7,13 +7,11 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { dashboard, visualize, lens, timeToVisualize } = getPageObjects([ 'dashboard', 'visualize', 'lens', 'timeToVisualize', - 'common', - 'header', ]); const find = getService('find'); const log = getService('log'); @@ -23,47 +21,47 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const elasticChart = getService('elasticChart'); const createNewLens = async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.switchToVisualization('lnsMetric'); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.switchToVisualization('lnsMetric'); + await lens.waitForVisualization('mtrVis'); }; const loadExistingLens = async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + await lens.waitForVisualization('xyVisChart'); }; describe('lens inline editing tests', () => { it('should allow inline editing of a by value visualization', async () => { await createNewLens(); - await PageObjects.lens.save('New Lens from Modal', false, false, false, 'new'); + await lens.save('New Lens from Modal', false, false, false, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickInlineEdit(); log.debug('Adds a secondary dimension'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsMetric_secondaryMetricDimensionPanel > lns-empty-dimension', operation: 'max', field: 'bytes', }); await testSubjects.click('applyFlyoutButton'); - await PageObjects.dashboard.waitForRenderComplete(); - const data = await PageObjects.lens.getMetricVisualizationData(); + await dashboard.waitForRenderComplete(); + const data = await lens.getMetricVisualizationData(); const expectedData = [ { title: 'Average of bytes', @@ -80,14 +78,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug(data); expect(data).to.eql(expectedData); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('should allow inline editing of a by reference visualization', async () => { await loadExistingLens(); - await PageObjects.lens.save('xyVisChart Copy', true, false, false, 'new'); + await lens.save('xyVisChart Copy', true, false, false, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await elasticChart.setNewChartUiDebugFlag(true); await dashboardPanelActions.legacySaveToLibrary('My by reference visualization'); @@ -97,27 +95,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('Removes breakdown dimension'); - await PageObjects.lens.removeDimension('lnsXY_splitDimensionPanel'); + await lens.removeDimension('lnsXY_splitDimensionPanel'); await testSubjects.click('applyFlyoutButton'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - const data = await PageObjects.lens.getCurrentChartDebugStateForVizType('xyVisChart'); + const data = await lens.getCurrentChartDebugStateForVizType('xyVisChart'); expect(data?.axes?.y.length).to.eql(1); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('should reset changes made to the previous state', async () => { await createNewLens(); - await PageObjects.lens.save('New Lens from Modal', false, false, false, 'new'); + await lens.save('New Lens from Modal', false, false, false, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickInlineEdit(); log.debug('Adds a secondary dimension'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsMetric_secondaryMetricDimensionPanel > lns-empty-dimension', operation: 'max', field: 'bytes', @@ -125,9 +123,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('Cancels the changes'); await testSubjects.click('cancelFlyoutButton'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); - const data = await PageObjects.lens.getMetricVisualizationData(); + const data = await lens.getMetricVisualizationData(); const expectedData = [ { title: 'Average of bytes', @@ -142,14 +140,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]; expect(data).to.eql(expectedData); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('should allow adding an annotation', async () => { await loadExistingLens(); - await PageObjects.lens.save('xyVisChart Copy', true, false, false, 'new'); + await lens.save('xyVisChart Copy', true, false, false, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await elasticChart.setNewChartUiDebugFlag(true); await dashboardPanelActions.openContextMenu(); @@ -157,7 +155,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('Adds annotation'); - await PageObjects.lens.createLayer('annotations'); + await lens.createLayer('annotations'); expect((await find.allByCssSelector(`[data-test-subj^="lns-layerPanel-"]`)).length).to.eql(2); expect( @@ -167,16 +165,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ).to.eql('Event'); await testSubjects.click('applyFlyoutButton'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await testSubjects.existOrFail('xyVisAnnotationIcon'); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); it('should allow adding a reference line', async () => { await loadExistingLens(); - await PageObjects.lens.save('xyVisChart Copy', true, false, false, 'new'); + await lens.save('xyVisChart Copy', true, false, false, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await elasticChart.setNewChartUiDebugFlag(true); await dashboardPanelActions.openContextMenu(); @@ -184,23 +182,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('Adds reference line'); - await PageObjects.lens.createLayer('referenceLine'); + await lens.createLayer('referenceLine'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yReferenceLineLeftPanel > lns-dimensionTrigger', operation: 'formula', formula: `count()`, keepOpen: true, }); - await PageObjects.lens.selectOptionFromComboBox('lns-icon-select', 'bell'); - await PageObjects.lens.closeDimensionEditor(); + await lens.selectOptionFromComboBox('lns-icon-select', 'bell'); + await lens.closeDimensionEditor(); await testSubjects.click('applyFlyoutButton'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await testSubjects.existOrFail('xyVisAnnotationIcon'); - await PageObjects.timeToVisualize.resetNewDashboard(); + await timeToVisualize.resetNewDashboard(); }); }); } diff --git a/x-pack/test/functional/apps/lens/group3/epoch_millis.ts b/x-pack/test/functional/apps/lens/group3/epoch_millis.ts index c13f31c97dc60..30f3ffddfcff1 100644 --- a/x-pack/test/functional/apps/lens/group3/epoch_millis.ts +++ b/x-pack/test/functional/apps/lens/group3/epoch_millis.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); @@ -28,32 +28,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); }); it('should show field list', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.switchDataPanelIndexPattern('epoch-millis*'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); - const fieldList = await PageObjects.lens.findAllFields(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.switchDataPanelIndexPattern('epoch-millis*'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); + const fieldList = await lens.findAllFields(); expect(fieldList).to.contain('@timestamp'); }); it('should able to configure a regular metric', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'count', field: 'Records', }); - await PageObjects.lens.waitForVisualization('lnsSuggestion-countOfRecords'); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('1'); + await lens.waitForVisualization('lnsSuggestion-countOfRecords'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('1'); }); it('should able to configure a shifted metric', async () => { - await PageObjects.lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger'); - await PageObjects.lens.enableTimeShift(); - await PageObjects.lens.setTimeShift('3d'); + await lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger'); + await lens.enableTimeShift(); + await lens.setTimeShift('3d'); - await PageObjects.lens.waitForVisualization('lnsSuggestion-countOfRecords3D'); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('2'); + await lens.waitForVisualization('lnsSuggestion-countOfRecords3D'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('2'); }); }); } diff --git a/x-pack/test/functional/apps/lens/group3/index.ts b/x-pack/test/functional/apps/lens/group3/index.ts index f82b409b7ba58..49cc8ed32eec6 100644 --- a/x-pack/test/functional/apps/lens/group3/index.ts +++ b/x-pack/test/functional/apps/lens/group3/index.ts @@ -13,7 +13,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['timePicker']); + const { timePicker } = getPageObjects(['timePicker']); const config = getService('config'); let remoteEsArchiver; @@ -54,7 +54,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext await esNode.load(esArchive); // changing the timepicker default here saves us from having to set it in Discover (~8s) - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: indexPatternString, 'dateFormat:tz': 'UTC', @@ -65,7 +65,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext after(async () => { await esArchiver.unload(esArchive); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.importExport.unload(fixtureDirs.lensBasic); await kibanaServer.importExport.unload(fixtureDirs.lensDefault); await kibanaServer.savedObjects.cleanStandardList(); diff --git a/x-pack/test/functional/apps/lens/group3/runtime_fields.ts b/x-pack/test/functional/apps/lens/group3/runtime_fields.ts index 8803a14ea34fe..e04a00a64c81a 100644 --- a/x-pack/test/functional/apps/lens/group3/runtime_fields.ts +++ b/x-pack/test/functional/apps/lens/group3/runtime_fields.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'header']); + const { visualize, lens, header } = getPageObjects(['visualize', 'lens', 'header']); const filterBar = getService('filterBar'); const fieldEditor = getService('fieldEditor'); const retry = getService('retry'); @@ -17,62 +17,58 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens runtime fields', () => { it('should be able to add runtime field and use it', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); await retry.try(async () => { await dataViews.clickAddFieldFromSearchBar(); await fieldEditor.setName('runtimefield'); await fieldEditor.enableValue(); await fieldEditor.typeScript("emit('abc')"); await fieldEditor.save(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.searchField('runtime'); - await PageObjects.lens.waitForField('runtimefield'); - await PageObjects.lens.dragFieldToWorkspace('runtimefield'); + await header.waitUntilLoadingHasFinished(); + await lens.searchField('runtime'); + await lens.waitForField('runtimefield'); + await lens.dragFieldToWorkspace('runtimefield'); }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal( - 'Top 5 values of runtimefield' - ); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('abc'); + await lens.waitForVisualization(); + expect(await lens.getDatatableHeaderText(0)).to.equal('Top 5 values of runtimefield'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('abc'); }); it('should able to filter runtime fields', async () => { await retry.try(async () => { - await PageObjects.lens.clickTableCellAction(0, 0, 'lensDatatableFilterOut'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.isShowingNoResults()).to.equal(true); + await lens.clickTableCellAction(0, 0, 'lensDatatableFilterOut'); + await lens.waitForVisualization(); + expect(await lens.isShowingNoResults()).to.equal(true); }); await filterBar.removeAllFilters(); - await PageObjects.lens.waitForVisualization(); + await lens.waitForVisualization(); }); it('should able to edit field', async () => { - await PageObjects.lens.clickField('runtimefield'); - await PageObjects.lens.editField('runtimefield'); + await lens.clickField('runtimefield'); + await lens.editField('runtimefield'); await fieldEditor.setName('runtimefield2', true, true); await fieldEditor.save(); await fieldEditor.confirmSave(); - await PageObjects.lens.searchField('runtime'); - await PageObjects.lens.waitForField('runtimefield2'); - await PageObjects.lens.dragFieldToDimensionTrigger( + await lens.searchField('runtime'); + await lens.waitForField('runtimefield2'); + await lens.dragFieldToDimensionTrigger( 'runtimefield2', 'lnsDatatable_rows > lns-dimensionTrigger' ); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal( - 'Top 5 values of runtimefield2' - ); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('abc'); + await lens.waitForVisualization(); + expect(await lens.getDatatableHeaderText(0)).to.equal('Top 5 values of runtimefield2'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('abc'); }); it('should able to remove field', async () => { - await PageObjects.lens.clickField('runtimefield2'); - await PageObjects.lens.removeField('runtimefield2'); + await lens.clickField('runtimefield2'); + await lens.removeField('runtimefield2'); await fieldEditor.confirmDelete(); - await PageObjects.lens.waitForFieldMissing('runtimefield2'); + await lens.waitForFieldMissing('runtimefield2'); }); }); } diff --git a/x-pack/test/functional/apps/lens/group3/terms.ts b/x-pack/test/functional/apps/lens/group3/terms.ts index 13b8492371405..86c43a7549e0e 100644 --- a/x-pack/test/functional/apps/lens/group3/terms.ts +++ b/x-pack/test/functional/apps/lens/group3/terms.ts @@ -10,7 +10,7 @@ import moment from 'moment'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens, common } = getPageObjects(['visualize', 'lens', 'common']); const elasticChart = getService('elasticChart'); const testSubjects = getService('testSubjects'); const comboBox = getService('comboBox'); @@ -23,92 +23,92 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens terms', () => { describe('lens multi terms suite', () => { it('should allow creation of lens xy chart with multi terms categories', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', keepOpen: true, }); - await PageObjects.lens.addTermToAgg('geo.dest'); + await lens.addTermToAgg('geo.dest'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel', 0)).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel', 0)).to.eql( 'Top values of geo.src + 1 other' ); - await PageObjects.lens.openDimensionEditor('lnsXY_xDimensionPanel'); + await lens.openDimensionEditor('lnsXY_xDimensionPanel'); - await PageObjects.lens.addTermToAgg('bytes'); + await lens.addTermToAgg('bytes'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel', 0)).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel', 0)).to.eql( 'Top values of geo.src + 2 others' ); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data!.bars![0].bars[0].x).to.eql('PE › US › 19,986'); }); it('should allow creation of lens xy chart with multi terms categories split', async () => { - await PageObjects.lens.removeDimension('lnsXY_xDimensionPanel'); + await lens.removeDimension('lnsXY_xDimensionPanel'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', keepOpen: true, }); - await PageObjects.lens.addTermToAgg('geo.dest'); - await PageObjects.lens.addTermToAgg('bytes'); + await lens.addTermToAgg('geo.dest'); + await lens.addTermToAgg('bytes'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.bars?.[0]?.name).to.eql('PE › US › 19,986'); }); it('should not show existing defined fields for new term', async () => { - await PageObjects.lens.openDimensionEditor('lnsXY_splitDimensionPanel'); + await lens.openDimensionEditor('lnsXY_splitDimensionPanel'); - await PageObjects.lens.checkTermsAreNotAvailableToAgg(['bytes', 'geo.src', 'geo.dest']); + await lens.checkTermsAreNotAvailableToAgg(['bytes', 'geo.src', 'geo.dest']); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); }); describe('rank by', () => { describe('reset rank on metric change', () => { it('should reset the ranking when using decimals on percentile', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'percentile', field: 'bytes', @@ -118,7 +118,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.try(async () => { const value = '60.5'; // Can not use testSubjects because data-test-subj is placed range input and number input - const percentileInput = await PageObjects.lens.getNumericFieldReady( + const percentileInput = await lens.getNumericFieldReady( 'lns-indexPattern-percentile-input' ); await percentileInput.clearValueWithKeyboard(); @@ -136,11 +136,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // note: this has also the side effect to close the dimension editor await testSubjects.click('toastCloseButton'); - await PageObjects.lens.openDimensionEditor( - 'lnsXY_yDimensionPanel > lns-dimensionTrigger' - ); + await lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); - await PageObjects.lens.selectOperation('percentile_rank'); + await lens.selectOperation('percentile_rank'); await retry.try(async () => { const value = '600.5'; @@ -163,18 +161,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); describe('sorting by custom metric', () => { it('should allow sort by custom metric', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', @@ -196,7 +194,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await retry.try(async () => { // Can not use testSubjects because data-test-subj is placed range input and number input - const percentileInput = await PageObjects.lens.getNumericFieldReady( + const percentileInput = await lens.getNumericFieldReady( 'lns-indexPattern-percentile-input' ); await percentileInput.type('60'); @@ -207,14 +205,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } }); - await PageObjects.lens.waitForVisualization('xyVisChart'); - await PageObjects.lens.closeDimensionEditor(); + await lens.waitForVisualization('xyVisChart'); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel', 0)).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel', 0)).to.eql( 'Top 5 values of geo.src' ); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data!.bars![0].bars[0].x).to.eql('BN'); expect(data!.bars![0].bars[0].y).to.eql(19265); }); @@ -281,88 +279,88 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); }); it('should work with empty string values as buckets', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchDataPanelIndexPattern(esIndexPrefix); + await lens.goToTimeRange(); + await lens.switchDataPanelIndexPattern(esIndexPrefix); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'count', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'a', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); const seriesBar = data!.bars![0].bars; expect(seriesBar[0].x).to.eql('(empty)'); expect(seriesBar[seriesBar.length - 1].x).to.eql('Other'); }); it('should work with empty string as breakdown', async () => { - await PageObjects.lens.removeDimension('lnsXY_xDimensionPanel'); + await lens.removeDimension('lnsXY_xDimensionPanel'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'a', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data!.bars![0].name).to.eql('(empty)'); expect(data!.bars![data!.bars!.length - 1].name).to.eql('Other'); }); it('should work with nested empty string values', async () => { - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.removeLayer(); + await lens.removeLayer(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_rows > lns-empty-dimension', operation: 'terms', field: 'a', keepOpen: true, }); - await PageObjects.lens.setTermsNumberOfValues(4); - await PageObjects.lens.closeDimensionEditor(); + await lens.setTermsNumberOfValues(4); + await lens.closeDimensionEditor(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_rows > lns-empty-dimension', operation: 'terms', field: 'b', keepOpen: true, }); - await PageObjects.lens.setTermsNumberOfValues(1); - await PageObjects.lens.closeDimensionEditor(); + await lens.setTermsNumberOfValues(1); + await lens.closeDimensionEditor(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'count', }); - await PageObjects.lens.waitForVisualization(); - await PageObjects.common.sleep(20000); + await lens.waitForVisualization(); + await common.sleep(20000); // a empty value - expect(await PageObjects.lens.getDatatableCellText(1, 0)).to.eql('(empty)'); + expect(await lens.getDatatableCellText(1, 0)).to.eql('(empty)'); // b Other value - expect(await PageObjects.lens.getDatatableCellText(1, 1)).to.eql('Other'); + expect(await lens.getDatatableCellText(1, 1)).to.eql('Other'); // a Other value - expect(await PageObjects.lens.getDatatableCellText(5, 0)).to.eql('Other'); + expect(await lens.getDatatableCellText(5, 0)).to.eql('Other'); // b empty value - expect(await PageObjects.lens.getDatatableCellText(5, 1)).to.eql('(empty)'); + expect(await lens.getDatatableCellText(5, 1)).to.eql('(empty)'); }); }); }); diff --git a/x-pack/test/functional/apps/lens/group4/chart_data.ts b/x-pack/test/functional/apps/lens/group4/chart_data.ts index 2b15d11b1125e..512f820e7ed75 100644 --- a/x-pack/test/functional/apps/lens/group4/chart_data.ts +++ b/x-pack/test/functional/apps/lens/group4/chart_data.ts @@ -11,23 +11,23 @@ import { range } from 'lodash'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const elasticChart = getService('elasticChart'); describe('lens chart data', () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', @@ -73,31 +73,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } it('should render xy chart', async () => { - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); assertMatchesExpectedData(data); }); it('should render pie chart', async () => { - await PageObjects.lens.switchToVisualization('pie'); - const data = await PageObjects.lens.getCurrentChartDebugState('partitionVisChart'); + await lens.switchToVisualization('pie'); + const data = await lens.getCurrentChartDebugState('partitionVisChart'); assertMatchesExpectedPieData(data); }); it('should render donut chart', async () => { - await PageObjects.lens.setDonutHoleSize('Large'); - const data = await PageObjects.lens.getCurrentChartDebugState('partitionVisChart'); + await lens.setDonutHoleSize('Large'); + const data = await lens.getCurrentChartDebugState('partitionVisChart'); assertMatchesExpectedPieData(data); }); it('should render treemap chart', async () => { - await PageObjects.lens.switchToVisualization('treemap', 'treemap'); - const data = await PageObjects.lens.getCurrentChartDebugState('partitionVisChart'); + await lens.switchToVisualization('treemap', 'treemap'); + const data = await lens.getCurrentChartDebugState('partitionVisChart'); assertMatchesExpectedPieData(data); }); it('should render heatmap chart', async () => { - await PageObjects.lens.switchToVisualization('heatmap', 'heat'); - const debugState = await PageObjects.lens.getCurrentChartDebugState('heatmapChart'); + await lens.switchToVisualization('heatmap', 'heat'); + const debugState = await lens.getCurrentChartDebugState('heatmapChart'); // assert axes expect(debugState?.axes!.x[0].labels).to.eql([ @@ -124,13 +124,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render datatable', async () => { - await PageObjects.lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.waitForVisualization(); + await lens.switchToVisualization('lnsDatatable'); + await lens.waitForVisualization(); const terms = await Promise.all( - range(0, 6).map((index) => PageObjects.lens.getDatatableCellText(index, 0)) + range(0, 6).map((index) => lens.getDatatableCellText(index, 0)) ); const values = await Promise.all( - range(0, 6).map((index) => PageObjects.lens.getDatatableCellText(index, 1)) + range(0, 6).map((index) => lens.getDatatableCellText(index, 1)) ); expect(terms).to.eql(expectedData.map(({ x }) => x)); expect(values.map((value) => Math.floor(100 * Number(value.replace(',', ''))) / 100)).to.eql( @@ -139,9 +139,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render metric', async () => { - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); - await PageObjects.lens.assertLegacyMetric('Average of bytes', '5,727.322'); + await lens.switchToVisualization('lnsLegacyMetric'); + await lens.waitForVisualization('legacyMtrVis'); + await lens.assertLegacyMetric('Average of bytes', '5,727.322'); }); }); } diff --git a/x-pack/test/functional/apps/lens/group4/color_mapping.ts b/x-pack/test/functional/apps/lens/group4/color_mapping.ts index 0fc9f79afec79..932c628a09afa 100644 --- a/x-pack/test/functional/apps/lens/group4/color_mapping.ts +++ b/x-pack/test/functional/apps/lens/group4/color_mapping.ts @@ -15,23 +15,23 @@ import { import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const elasticChart = getService('elasticChart'); describe('lens color mapping', () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'extension.raw', @@ -41,18 +41,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should render correct color mapping', async () => { - const chart = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const chart = await lens.getCurrentChartDebugState('xyVisChart'); const legendColors = chart?.legend?.items?.map((item) => item.color.toLowerCase()) ?? []; expect(legendColors).to.eql( ELASTIC_BRAND_PALETTE_COLORS.slice(0, 5).map((c) => c.toLowerCase()) ); }); it('should allow switching color mapping palette', async () => { - await PageObjects.lens.changeColorMappingPalette( + await lens.changeColorMappingPalette( 'lnsXY_splitDimensionPanel > lnsLayerPanel-dimensionLink', EUIAmsterdamColorBlindPalette.id ); - const chart = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const chart = await lens.getCurrentChartDebugState('xyVisChart'); const legendColors = chart?.legend?.items?.map((item) => item.color.toLowerCase()) ?? []; expect(legendColors).to.eql( EUI_AMSTERDAM_PALETTE_COLORS.slice(0, 5).map((c) => c.toLowerCase()) @@ -60,12 +60,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should change categorical color', async () => { - await PageObjects.lens.changeColorMappingCategoricalColors( + await lens.changeColorMappingCategoricalColors( 'lnsXY_splitDimensionPanel > lnsLayerPanel-dimensionLink', 0, 3 ); - const chart = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + const chart = await lens.getCurrentChartDebugState('xyVisChart'); const firstLegendItemColor = chart?.legend?.items?.[0]?.color?.toLowerCase() ?? 'NONE'; expect(firstLegendItemColor).to.eql(EUI_AMSTERDAM_PALETTE_COLORS[3].toLowerCase()); }); diff --git a/x-pack/test/functional/apps/lens/group4/colors.ts b/x-pack/test/functional/apps/lens/group4/colors.ts index 5faf6e05bbcd5..96e1866250da2 100644 --- a/x-pack/test/functional/apps/lens/group4/colors.ts +++ b/x-pack/test/functional/apps/lens/group4/colors.ts @@ -7,28 +7,28 @@ import { ElasticBrandPalette } from '@kbn/coloring'; import { FtrProviderContext } from '../../../ftr_provider_context'; -export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common']); +export default function ({ getPageObjects }: FtrProviderContext) { + const { visualize, lens } = getPageObjects(['visualize', 'lens']); describe('lens color palette tests', () => { it('should allow to pick legacy color palette in xy chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: '@message.raw', @@ -36,26 +36,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { keepOpen: true, }); - await PageObjects.lens.assertPalette('negative', true); + await lens.assertPalette('negative', true); }); it('should allow to pick color mapping palette in xy chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: '@message.raw', @@ -63,25 +63,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { keepOpen: true, }); - await PageObjects.lens.assertPalette(ElasticBrandPalette.id, false); - await PageObjects.lens.closeDimensionEditor(); + await lens.assertPalette(ElasticBrandPalette.id, false); + await lens.closeDimensionEditor(); }); it('should carry over palette to the pie chart', async () => { - await PageObjects.lens.switchToVisualization('pie'); - await PageObjects.lens.openDimensionEditor( - 'lnsPie_sliceByDimensionPanel > lns-dimensionTrigger' - ); - await PageObjects.lens.assertPalette(ElasticBrandPalette.id, false); - await PageObjects.lens.closeDimensionEditor(); + await lens.switchToVisualization('pie'); + await lens.openDimensionEditor('lnsPie_sliceByDimensionPanel > lns-dimensionTrigger'); + await lens.assertPalette(ElasticBrandPalette.id, false); + await lens.closeDimensionEditor(); }); it('should carry palette back to the bar chart', async () => { - await PageObjects.lens.switchToVisualization('bar'); - await PageObjects.lens.openDimensionEditor( - 'lnsXY_splitDimensionPanel > lns-dimensionTrigger' - ); - await PageObjects.lens.assertPalette(ElasticBrandPalette.id, false); + await lens.switchToVisualization('bar'); + await lens.openDimensionEditor('lnsXY_splitDimensionPanel > lns-dimensionTrigger'); + await lens.assertPalette(ElasticBrandPalette.id, false); }); }); } diff --git a/x-pack/test/functional/apps/lens/group4/dashboard.ts b/x-pack/test/functional/apps/lens/group4/dashboard.ts index cfa46167b7860..563023a6d2ee0 100644 --- a/x-pack/test/functional/apps/lens/group4/dashboard.ts +++ b/x-pack/test/functional/apps/lens/group4/dashboard.ts @@ -9,13 +9,11 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { header, dashboard, timePicker, lens } = getPageObjects([ 'header', - 'common', 'dashboard', 'timePicker', 'lens', - 'discover', ]); const find = getService('find'); @@ -42,7 +40,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens dashboard tests', () => { before(async () => { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await security.testUser.setRoles( [ 'global_dashboard_all', @@ -58,23 +56,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('metric should be embeddable', async () => { - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames('Artistpreviouslyknownaslens'); await find.clickByButtonText('Artistpreviouslyknownaslens'); await dashboardAddPanel.closeAddPanel(); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '19,986'); + await lens.goToTimeRange(); + await lens.assertLegacyMetric('Maximum of bytes', '19,986'); }); it('should be able to add filters/timerange by clicking in XYChart', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames('lnsXYvis'); await find.clickByButtonText('lnsXYvis'); await dashboardAddPanel.closeAddPanel(); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); await retry.try(async () => { await clickInChart(30, 5); // hardcoded position of bar, depends heavy on data and charts implementation await testSubjects.existOrFail('applyFiltersPopoverButton', { timeout: 2500 }); @@ -85,11 +83,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.missingOrFail('applyFiltersPopoverButton'); }); - await PageObjects.lens.assertExactText( - '[data-test-subj="embeddablePanelHeading-lnsXYvis"]', - 'lnsXYvis' - ); - const time = await PageObjects.timePicker.getTimeConfig(); + await lens.assertExactText('[data-test-subj="embeddablePanelHeading-lnsXYvis"]', 'lnsXYvis'); + const time = await timePicker.getTimeConfig(); expect(time.start).to.equal('Sep 21, 2015 @ 09:00:00.000'); expect(time.end).to.equal('Sep 21, 2015 @ 12:00:00.000'); const hasIpFilter = await filterBar.hasFilter('ip', '97.220.3.248'); @@ -97,13 +92,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should be able to add filters by right clicking in XYChart', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames('lnsXYvis'); await find.clickByButtonText('lnsXYvis'); await dashboardAddPanel.closeAddPanel(); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); await retry.try(async () => { // show the tooltip actions await rightClickInChart(30, 5); // hardcoded position of bar, depends heavy on data and charts implementation @@ -112,7 +107,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(hasIpFilter).to.be(true); await rightClickInChart(35, 5); // hardcoded position of bar, depends heavy on data and charts implementation await (await find.allByCssSelector('.echTooltipActions__action'))[0].click(); - const time = await PageObjects.timePicker.getTimeConfig(); + const time = await timePicker.getTimeConfig(); expect(time.start).to.equal('Sep 21, 2015 @ 09:00:00.000'); expect(time.end).to.equal('Sep 21, 2015 @ 12:00:00.000'); }); @@ -121,31 +116,33 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Requires xpack.discoverEnhanced.actions.exploreDataInContextMenu.enabled // setting set in kibana.yml to test (not enabled by default) it('should hide old "explore underlying data" action', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames('lnsXYvis'); await find.clickByButtonText('lnsXYvis'); await dashboardAddPanel.closeAddPanel(); - await PageObjects.lens.goToTimeRange(); - await PageObjects.dashboard.saveDashboard('lnsDrilldown'); - await panelActions.openContextMenu(); + await lens.goToTimeRange(); + await dashboard.saveDashboard('lnsDrilldown'); - expect(await testSubjects.exists('embeddablePanelAction-ACTION_EXPLORE_DATA')).not.to.be.ok(); + await panelActions.expectMissingPanelAction( + 'embeddablePanelAction-ACTION_EXPLORE_DATA', + 'lnsXYvis' + ); }); it('should be able to add filters by clicking in pie chart', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames('lnsPieVis'); await find.clickByButtonText('lnsPieVis'); await dashboardAddPanel.closeAddPanel(); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); await clickInChart(5, 5); // hardcoded position of the slice, depends heavy on data and charts implementation - await PageObjects.lens.assertExactText( + await lens.assertExactText( '[data-test-subj="embeddablePanelHeading-lnsPieVis"]', 'lnsPieVis' ); @@ -156,15 +153,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not carry over filters if creating a new lens visualization from within dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.timePicker.setDefaultAbsoluteRange(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + await timePicker.setDefaultAbsoluteRange(); await filterBar.addFilter({ field: 'geo.src', operation: 'is', value: 'US' }); await filterBar.toggleFilterPinned('geo.src'); await filterBar.addFilter({ field: 'geo.dest', operation: 'is', value: 'LS' }); await dashboardAddPanel.clickCreateNewLink(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const hasGeoDestFilter = await filterBar.hasFilter('geo.dest', 'LS'); expect(hasGeoDestFilter).to.be(false); const hasGeoSrcFilter = await filterBar.hasFilter('geo.src', 'US', true, true); @@ -174,12 +171,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('CSV export action exists in panel context menu', async () => { const ACTION_ID = 'ACTION_EXPORT_CSV'; const ACTION_TEST_SUBJ = `embeddablePanelAction-${ACTION_ID}`; - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames('lnsPieVis'); await find.clickByButtonText('lnsPieVis'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await dashboardAddPanel.closeAddPanel(); await retry.try(async () => { @@ -188,40 +185,40 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show all data from all layers in the inspector', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickCreateNewLink(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await header.waitUntilLoadingHasFinished(); + await lens.goToTimeRange(); + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.createLayer(); + await lens.createLayer(); - expect(await PageObjects.lens.hasChartSwitchWarning('line')).to.eql(false); + expect(await lens.hasChartSwitchWarning('line')).to.eql(false); - await PageObjects.lens.switchToVisualization('line'); - await PageObjects.lens.configureDimension({ + await lens.switchToVisualization('line'); + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'median', field: 'bytes', }); - await PageObjects.lens.saveAndReturn(); + await lens.saveAndReturn(); await panelActions.openInspector(); await inspector.openInspectorRequestsView(); @@ -230,35 +227,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('unlink lens panel from embeddable library', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames('lnsPieVis'); await find.clickByButtonText('lnsPieVis'); await dashboardAddPanel.closeAddPanel(); - const originalPanel = await testSubjects.find('embeddablePanelHeading-lnsPieVis'); - await panelActions.legacyUnlinkFromLibrary(originalPanel); - await testSubjects.existOrFail('unlinkPanelSuccess'); - - const updatedPanel = await testSubjects.find('embeddablePanelHeading-lnsPieVis'); - const libraryActionExists = await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - updatedPanel - ); - expect(libraryActionExists).to.be(false); + await panelActions.legacyUnlinkFromLibrary('lnsPieVis'); }); it('save lens panel to embeddable library', async () => { - const originalPanel = await testSubjects.find('embeddablePanelHeading-lnsPieVis'); - await panelActions.legacySaveToLibrary('lnsPieVis - copy', originalPanel); - - const updatedPanel = await testSubjects.find('embeddablePanelHeading-lnsPieVis-copy'); - const libraryActionExists = await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - updatedPanel - ); - expect(libraryActionExists).to.be(true); + await panelActions.legacySaveToLibrary('lnsPieVis - copy', 'lnsPieVis'); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames('lnsPieVis'); @@ -266,80 +246,80 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show validation messages if any error appears', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickCreateNewLink(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.goToTimeRange(); + await header.waitUntilLoadingHasFinished(); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'moving_average', keepOpen: true, }); - await PageObjects.lens.configureReference({ + await lens.configureReference({ operation: 'sum', field: 'bytes', }); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); // remove the x dimension to trigger the validation error - await PageObjects.lens.removeDimension('lnsXY_xDimensionPanel'); - await PageObjects.lens.expectSaveAndReturnButtonDisabled(); + await lens.removeDimension('lnsXY_xDimensionPanel'); + await lens.expectSaveAndReturnButtonDisabled(); }); it('should recover lens panel in an error state when fixing search query', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames('lnsXYvis'); await find.clickByButtonText('lnsXYvis'); await dashboardAddPanel.closeAddPanel(); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); // type an invalid search query, hit refresh await queryBar.setQuery('this is > not valid'); await queryBar.submitQuery(); // check the error state - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const errors = await testSubjects.findAll('embeddableStackError'); expect(errors.length).to.be(1); // now remove the query await queryBar.setQuery(''); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // check the success state - await PageObjects.dashboard.verifyNoRenderErrors(); + await dashboard.verifyNoRenderErrors(); }); it('should work in lens with by-value charts', async () => { // create a new dashboard, then a new visualization in Lens. - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await testSubjects.click('dashboardEditorMenuButton'); await testSubjects.click('visType-lens'); // Configure it and save to return to the dashboard. - await PageObjects.lens.waitForField('@timestamp'); - await PageObjects.lens.configureDimension({ + await lens.waitForField('@timestamp'); + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.save('test', true); + await lens.save('test', true); // Edit the visualization now and get back to Lens editor await panelActions.clickInlineEdit(); await testSubjects.click('navigateToLensEditorLink'); // Click on Share, then Copy link and paste the link in a new tab. - const url = await PageObjects.lens.getUrl(); + const url = await lens.getUrl(); await browser.openNewTab(); await browser.navigateTo(url); - expect(await PageObjects.lens.getTitle()).to.be('test'); + expect(await lens.getTitle()).to.be('test'); // need to make sure there aren't extra tabs or it will impact future test suites // close any new tabs that were opened const windowHandlers = await browser.getAllWindowHandles(); diff --git a/x-pack/test/functional/apps/lens/group4/index.ts b/x-pack/test/functional/apps/lens/group4/index.ts index 9627b744300ba..51b3bac4c519f 100644 --- a/x-pack/test/functional/apps/lens/group4/index.ts +++ b/x-pack/test/functional/apps/lens/group4/index.ts @@ -13,7 +13,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['timePicker']); + const { timePicker } = getPageObjects(['timePicker']); const config = getService('config'); let remoteEsArchiver; @@ -54,7 +54,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext await esNode.load(esArchive); // changing the timepicker default here saves us from having to set it in Discover (~8s) - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: indexPatternString, 'dateFormat:tz': 'UTC', @@ -65,7 +65,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext after(async () => { await esArchiver.unload(esArchive); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.importExport.unload(fixtureDirs.lensBasic); await kibanaServer.importExport.unload(fixtureDirs.lensDefault); await kibanaServer.savedObjects.cleanStandardList(); diff --git a/x-pack/test/functional/apps/lens/group4/share.ts b/x-pack/test/functional/apps/lens/group4/share.ts index ac3c4a3b22b78..4d01b3cf65c91 100644 --- a/x-pack/test/functional/apps/lens/group4/share.ts +++ b/x-pack/test/functional/apps/lens/group4/share.ts @@ -9,72 +9,72 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const browser = getService('browser'); const filterBarService = getService('filterBar'); const queryBar = getService('queryBar'); describe('lens share tests', () => { before(async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); }); afterEach(async () => { - await PageObjects.lens.closeShareModal(); + await lens.closeShareModal(); }); after(async () => { - await PageObjects.lens.setCSVDownloadDebugFlag(false); + await lens.setCSVDownloadDebugFlag(false); }); it('should disable the share button if no request is made', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - expect(await PageObjects.lens.isShareable()).to.eql(false); + expect(await lens.isShareable()).to.eql(false); }); it('should keep the button disabled for incomplete configuration', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - expect(await PageObjects.lens.isShareable()).to.eql(false); + expect(await lens.isShareable()).to.eql(false); }); it('should make the share button available as soon as a valid configuration is generated', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - expect(await PageObjects.lens.isShareable()).to.eql(true); + expect(await lens.isShareable()).to.eql(true); }); it('should enable both download and URL sharing for valid configuration', async () => { - await PageObjects.lens.clickShareModal(); + await lens.clickShareModal(); - expect(await PageObjects.lens.isShareActionEnabled('export')); - expect(await PageObjects.lens.isShareActionEnabled('link')); + expect(await lens.isShareActionEnabled('export')); + expect(await lens.isShareActionEnabled('link')); }); it('should preserve filter and query when sharing', async () => { await filterBarService.addFilter({ field: 'bytes', operation: 'is', value: '1' }); await queryBar.setQuery('host.keyword www.elastic.co'); await queryBar.submitQuery(); - await PageObjects.lens.save('new'); - const url = await PageObjects.lens.getUrl(); - await PageObjects.lens.closeShareModal(); + await lens.save('new'); + const url = await lens.getUrl(); + await lens.closeShareModal(); await browser.openNewTab(); const [lensWindowHandler] = await browser.getAllWindowHandles(); await browser.navigateTo(url); // check that it's the same configuration in the new URL when ready - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); expect(await filterBarService.getFiltersLabel()).to.eql(['bytes: 1']); expect(await queryBar.getQueryString()).to.be('host.keyword www.elastic.co'); await browser.closeCurrentWindow(); @@ -82,32 +82,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should be able to download CSV data of the current visualization', async () => { - await PageObjects.lens.setCSVDownloadDebugFlag(true); - await PageObjects.lens.openCSVDownloadShare(); + await lens.setCSVDownloadDebugFlag(true); + await lens.openCSVDownloadShare(); - const csv = await PageObjects.lens.getCSVContent(); + const csv = await lens.getCSVContent(); expect(csv).to.be.ok(); expect(Object.keys(csv!)).to.have.length(1); }); it('should be able to download CSV of multi layer visualization', async () => { - await PageObjects.lens.createLayer(); + await lens.createLayer(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'median', field: 'bytes', }); - await PageObjects.lens.openCSVDownloadShare(); + await lens.openCSVDownloadShare(); - const csv = await PageObjects.lens.getCSVContent(); + const csv = await lens.getCSVContent(); expect(csv).to.be.ok(); expect(Object.keys(csv!)).to.have.length(2); }); diff --git a/x-pack/test/functional/apps/lens/group4/show_underlying_data.ts b/x-pack/test/functional/apps/lens/group4/show_underlying_data.ts index 2d9035238452f..5caf47a41847d 100644 --- a/x-pack/test/functional/apps/lens/group4/show_underlying_data.ts +++ b/x-pack/test/functional/apps/lens/group4/show_underlying_data.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { visualize, lens, common, header, discover, unifiedFieldList } = getPageObjects([ 'visualize', 'lens', 'common', @@ -25,20 +25,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('show underlying data', () => { it('should show the open button for a compatible saved visualization', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-dimensionTrigger', operation: 'terms', field: 'extension.raw', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); // expect the button is shown and enabled @@ -47,85 +47,83 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const [lensWindowHandler, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await testSubjects.existOrFail('unifiedDataTableToolbar'); // check the table columns - const columns = await PageObjects.discover.getColumnHeaders(); + const columns = await discover.getColumnHeaders(); expect(columns).to.eql(['@timestamp', 'extension.raw', 'bytes']); await browser.closeCurrentWindow(); await browser.switchToWindow(lensWindowHandler); }); it('should show the open button if visualization has an annotation layer', async () => { - await PageObjects.lens.createLayer('annotations'); + await lens.createLayer('annotations'); await testSubjects.clickWhenNotDisabledWithoutRetry(`lnsApp_openInDiscover`); const [lensWindowHandler, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('unifiedHistogramChart'); - const columns = await PageObjects.discover.getColumnHeaders(); + const columns = await discover.getColumnHeaders(); expect(columns).to.eql(['@timestamp', 'extension.raw', 'bytes']); await browser.closeCurrentWindow(); await browser.switchToWindow(lensWindowHandler); }); it('should show the open button if visualization has a reference line layer', async () => { - await PageObjects.lens.createLayer('referenceLine'); + await lens.createLayer('referenceLine'); await testSubjects.clickWhenNotDisabledWithoutRetry(`lnsApp_openInDiscover`); const [lensWindowHandler, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('unifiedHistogramChart'); - const columns = await PageObjects.discover.getColumnHeaders(); + const columns = await discover.getColumnHeaders(); expect(columns).to.eql(['@timestamp', 'extension.raw', 'bytes']); await browser.closeCurrentWindow(); await browser.switchToWindow(lensWindowHandler); }); it('should not show the open button if visualization has multiple data layers', async () => { - await PageObjects.lens.createLayer(); - await PageObjects.lens.configureDimension({ + await lens.createLayer(); + await lens.configureDimension({ dimension: 'lns-layerPanel-3 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-3 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'median', field: 'bytes', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); expect(await testSubjects.isEnabled(`lnsApp_openInDiscover`)).to.be(false); for (const index of [3, 2, 1]) { - await PageObjects.lens.removeLayer(index); + await lens.removeLayer(index); } }); it('should ignore the top values column if other category is enabled', async () => { // Make the breakdown dimention be ignored - await PageObjects.lens.openDimensionEditor( - 'lnsXY_splitDimensionPanel > lns-dimensionTrigger' - ); + await lens.openDimensionEditor('lnsXY_splitDimensionPanel > lns-dimensionTrigger'); await testSubjects.click('indexPattern-terms-advanced'); await testSubjects.click('indexPattern-terms-other-bucket'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); // expect the button is shown and enabled await testSubjects.clickWhenNotDisabledWithoutRetry(`lnsApp_openInDiscover`); const [lensWindowHandler, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('unifiedHistogramChart'); expect(await queryBar.getQueryString()).be.eql(''); await browser.closeCurrentWindow(); @@ -134,35 +132,33 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show the open button for a compatible saved visualization with a lucene query', async () => { // Make the breakdown dimension contribute to filters again - await PageObjects.lens.openDimensionEditor( - 'lnsXY_splitDimensionPanel > lns-dimensionTrigger' - ); + await lens.openDimensionEditor('lnsXY_splitDimensionPanel > lns-dimensionTrigger'); await testSubjects.click('indexPattern-terms-advanced'); await testSubjects.click('indexPattern-terms-other-bucket'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); // add a lucene query to the yDimension - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); - await PageObjects.lens.enableFilter(); + await lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); + await lens.enableFilter(); // turn off the KQL switch to change the language to lucene await testSubjects.click('indexPattern-filter-by-input > switchQueryLanguageButton'); await testSubjects.click('luceneLanguageMenuItem'); await testSubjects.click('indexPattern-filter-by-input > switchQueryLanguageButton'); // apparently setting a filter requires some time before and after typing to work properly - await PageObjects.common.sleep(1000); - await PageObjects.lens.setFilterBy('machine.ram:*'); - await PageObjects.common.sleep(1000); + await common.sleep(1000); + await lens.setFilterBy('machine.ram:*'); + await common.sleep(1000); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); await testSubjects.clickWhenNotDisabledWithoutRetry(`lnsApp_openInDiscover`); const [lensWindowHandler, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.waitUntilSidebarHasLoaded(); + await header.waitUntilLoadingHasFinished(); + await unifiedFieldList.waitUntilSidebarHasLoaded(); await testSubjects.existOrFail('unifiedHistogramChart'); // check the query expect(await queryBar.getQueryString()).be.eql( @@ -176,9 +172,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show the underlying data extracting all filters and columns from a formula', async () => { - await PageObjects.lens.removeDimension('lnsXY_yDimensionPanel'); + await lens.removeDimension('lnsXY_yDimensionPanel'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'formula', formula: `average(memory, kql=`, @@ -190,18 +186,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // the tooltip seems to be there as long as the focus is in the query string await input.pressKeys(browser.keys.RIGHT); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); // expect the button is shown and enabled await testSubjects.clickWhenNotDisabledWithoutRetry(`lnsApp_openInDiscover`); const [lensWindowHandler, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('unifiedHistogramChart'); // check the columns - const columns = await PageObjects.discover.getColumnHeaders(); + const columns = await discover.getColumnHeaders(); expect(columns).to.eql(['@timestamp', 'extension.raw', 'memory']); // check the query expect(await queryBar.getQueryString()).be.eql( @@ -212,28 +208,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should extract a filter from a formula global filter', async () => { - await PageObjects.lens.removeDimension('lnsXY_yDimensionPanel'); + await lens.removeDimension('lnsXY_yDimensionPanel'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'formula', formula: `count()`, keepOpen: true, }); - await PageObjects.lens.enableFilter(); + await lens.enableFilter(); // apparently setting a filter requires some time before and after typing to work properly - await PageObjects.common.sleep(1000); - await PageObjects.lens.setFilterBy('bytes > 4000'); - await PageObjects.common.sleep(1000); + await common.sleep(1000); + await lens.setFilterBy('bytes > 4000'); + await common.sleep(1000); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); // expect the button is shown and enabled await testSubjects.clickWhenNotDisabledWithoutRetry(`lnsApp_openInDiscover`); const [lensWindowHandler, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('unifiedHistogramChart'); // check the query expect(await queryBar.getQueryString()).be.eql( diff --git a/x-pack/test/functional/apps/lens/group4/show_underlying_data_dashboard.ts b/x-pack/test/functional/apps/lens/group4/show_underlying_data_dashboard.ts index 1f6b3efd9d014..70625ecafaa75 100644 --- a/x-pack/test/functional/apps/lens/group4/show_underlying_data_dashboard.ts +++ b/x-pack/test/functional/apps/lens/group4/show_underlying_data_dashboard.ts @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; const OPEN_IN_DISCOVER_DATA_TEST_SUBJ = 'embeddablePanelAction-ACTION_OPEN_IN_DISCOVER'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { visualize, lens, dashboard, header, discover, common } = getPageObjects([ 'visualize', 'lens', 'dashboard', @@ -31,13 +31,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens show underlying data from dashboard', () => { it('should show the open button for a compatible saved visualization', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.save('Embedded Visualization', true, false, false, 'new'); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + await lens.save('Embedded Visualization', true, false, false, 'new'); - await PageObjects.dashboard.saveDashboard(`Open in Discover Testing ${uuidv4()}`, { + await dashboard.saveDashboard(`Open in Discover Testing ${uuidv4()}`, { saveAsNew: true, exitFromEditMode: true, }); @@ -47,10 +47,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const [dashboardWindowHandle, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('unifiedHistogramChart'); // check the table columns - const columns = await PageObjects.discover.getColumnHeaders(); + const columns = await discover.getColumnHeaders(); expect(columns).to.eql(['@timestamp', 'ip', 'bytes']); await browser.closeCurrentWindow(); @@ -58,17 +58,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show the open button for a compatible saved visualization with annotations and reference line', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.createLayer('annotations'); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await header.waitUntilLoadingHasFinished(); + await lens.createLayer('annotations'); + await lens.waitForVisualization('xyVisChart'); - await PageObjects.lens.createLayer('referenceLine'); - await PageObjects.lens.save('Embedded Visualization', false); + await lens.createLayer('referenceLine'); + await lens.save('Embedded Visualization', false); - await PageObjects.dashboard.saveDashboard(`Open in Discover Testing ${uuidv4()}`, { + await dashboard.saveDashboard(`Open in Discover Testing ${uuidv4()}`, { saveAsNew: false, exitFromEditMode: true, }); @@ -78,10 +78,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const [dashboardWindowHandle, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('unifiedHistogramChart'); // check the table columns - const columns = await PageObjects.discover.getColumnHeaders(); + const columns = await discover.getColumnHeaders(); expect(columns).to.eql(['@timestamp', 'ip', 'bytes']); await browser.closeCurrentWindow(); @@ -89,7 +89,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should bring both dashboard context and visualization context to discover', async () => { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); await savedQueryManagementComponent.openSavedQueryManagementComponent(); @@ -99,9 +99,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await queryBar.submitQuery(); await filterBarService.addFilter({ field: 'geo.src', operation: 'is', value: 'AF' }); // the filter bar seems to need a moment to settle before saving and returning - await PageObjects.common.sleep(1000); + await common.sleep(1000); - await PageObjects.lens.saveAndReturn(); + await lens.saveAndReturn(); await savedQueryManagementComponent.openSavedQueryManagementComponent(); await queryBar.switchQueryLanguage('kql'); await savedQueryManagementComponent.closeSavedQueryManagementComponent(); @@ -113,19 +113,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { value: 'cdn.theacademyofperformingartsandscience.org', }); - await PageObjects.dashboard.clickQuickSave(); + await dashboard.clickQuickSave(); // make sure Open in Discover is also available in edit mode await dashboardPanelActions.expectExistsPanelAction(OPEN_IN_DISCOVER_DATA_TEST_SUBJ); - await PageObjects.dashboard.clickCancelOutOfEditMode(); + await dashboard.clickCancelOutOfEditMode(); await dashboardPanelActions.clickContextMenuItem(OPEN_IN_DISCOVER_DATA_TEST_SUBJ); const [dashboardWindowHandle, discoverWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(discoverWindowHandle); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await discover.waitUntilSearchingHasFinished(); await retry.waitFor('filter count to be correct', async () => { const filterCount = await filterBarService.getFilterCount(); diff --git a/x-pack/test/functional/apps/lens/group4/time_shift.ts b/x-pack/test/functional/apps/lens/group4/time_shift.ts index de8405c62e4cc..9cbe84f033ff2 100644 --- a/x-pack/test/functional/apps/lens/group4/time_shift.ts +++ b/x-pack/test/functional/apps/lens/group4/time_shift.ts @@ -9,79 +9,79 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); describe('time shift', () => { it('should able to configure a shifted metric', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); + await lens.configureDimension({ dimension: 'lnsDatatable_rows > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', disableEmptyRows: true, }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'median', field: 'bytes', }); - await PageObjects.lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger'); - await PageObjects.lens.enableTimeShift(); - await PageObjects.lens.setTimeShift('6h'); + await lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger'); + await lens.enableTimeShift(); + await lens.setTimeShift('6h'); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 1)).to.eql('5,994'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 1)).to.eql('5,994'); }); it('should able to configure a regular metric next to a shifted metric', async () => { - await PageObjects.lens.closeDimensionEditor(); - await PageObjects.lens.configureDimension({ + await lens.closeDimensionEditor(); + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.waitForVisualization(); + await lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(2, 1)).to.eql('5,994'); - expect(await PageObjects.lens.getDatatableCellText(2, 2)).to.eql('5,722.622'); + expect(await lens.getDatatableCellText(2, 1)).to.eql('5,994'); + expect(await lens.getDatatableCellText(2, 2)).to.eql('5,722.622'); }); it('should show an error if terms is used and provide a fix action', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_rows > lns-empty-dimension', operation: 'terms', field: 'ip', }); - expect(await PageObjects.lens.hasFixAction()).to.be(true); - await PageObjects.lens.useFixAction(); + expect(await lens.hasFixAction()).to.be(true); + await lens.useFixAction(); - expect(await PageObjects.lens.getDatatableCellText(2, 2)).to.eql('6,976'); - expect(await PageObjects.lens.getDatatableCellText(2, 3)).to.eql('4,182.5'); + expect(await lens.getDatatableCellText(2, 2)).to.eql('6,976'); + expect(await lens.getDatatableCellText(2, 3)).to.eql('4,182.5'); - expect(await PageObjects.lens.getDatatableHeaderText(0)).to.eql('Filters of ip'); + expect(await lens.getDatatableHeaderText(0)).to.eql('Filters of ip'); }); it('should show an error if multi terms is used and provide a fix action', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_rows > lns-empty-dimension', operation: 'terms', field: 'ip', keepOpen: true, }); - await PageObjects.lens.addTermToAgg('geo.src'); + await lens.addTermToAgg('geo.src'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.hasFixAction()).to.be(true); - await PageObjects.lens.useFixAction(); + expect(await lens.hasFixAction()).to.be(true); + await lens.useFixAction(); - expect(await PageObjects.lens.getDatatableHeaderText(1)).to.eql('Filters of ip › geo.src'); + expect(await lens.getDatatableHeaderText(1)).to.eql('Filters of ip › geo.src'); }); }); } diff --git a/x-pack/test/functional/apps/lens/group4/tsdb.ts b/x-pack/test/functional/apps/lens/group4/tsdb.ts index 730318f33db97..bbe1eef8a442c 100644 --- a/x-pack/test/functional/apps/lens/group4/tsdb.ts +++ b/x-pack/test/functional/apps/lens/group4/tsdb.ts @@ -238,7 +238,7 @@ function sumFirstNValues(n: number, bars: Array<{ y: number }> | undefined): num } export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'timePicker', 'lens', 'dashboard']); + const { common, lens, dashboard } = getPageObjects(['common', 'lens', 'dashboard']); const testSubjects = getService('testSubjects'); const find = getService('find'); const kibanaServer = getService('kibanaServer'); @@ -368,47 +368,47 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('for regular metric', () => { it('defaults to median for non-rolled up metric', async () => { - await PageObjects.common.navigateToApp('lens'); - await PageObjects.lens.waitForField('bytes_gauge'); - await PageObjects.lens.dragFieldToWorkspace('bytes_gauge', 'xyVisChart'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + await common.navigateToApp('lens'); + await lens.waitForField('bytes_gauge'); + await lens.dragFieldToWorkspace('bytes_gauge', 'xyVisChart'); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Median of bytes_gauge' ); }); it('does not show a warning', async () => { - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel'); + await lens.openDimensionEditor('lnsXY_yDimensionPanel'); await testSubjects.missingOrFail('median-partial-warning'); - await PageObjects.lens.assertNoEditorWarning(); - await PageObjects.lens.closeDimensionEditor(); + await lens.assertNoEditorWarning(); + await lens.closeDimensionEditor(); }); }); describe('for rolled up metric (downsampled)', () => { it('defaults to average for rolled up metric', async () => { - await PageObjects.lens.switchDataPanelIndexPattern(downsampleDataView.dataView); - await PageObjects.lens.removeLayer(); - await PageObjects.lens.waitForField('bytes_gauge'); - await PageObjects.lens.dragFieldToWorkspace('bytes_gauge', 'xyVisChart'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + await lens.switchDataPanelIndexPattern(downsampleDataView.dataView); + await lens.removeLayer(); + await lens.waitForField('bytes_gauge'); + await lens.dragFieldToWorkspace('bytes_gauge', 'xyVisChart'); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Average of bytes_gauge' ); }); it('shows warnings in editor when using median', async () => { - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel'); + await lens.openDimensionEditor('lnsXY_yDimensionPanel'); await testSubjects.existOrFail('median-partial-warning'); await testSubjects.click('lns-indexPatternDimension-median'); - await PageObjects.lens.waitForVisualization('xyVisChart'); - await PageObjects.lens.assertMessageListContains( + await lens.waitForVisualization('xyVisChart'); + await lens.assertMessageListContains( 'Median of bytes_gauge uses a function that is unsupported by rolled up data. Select a different function or change the time range.', 'warning' ); }); it('shows warnings in dashboards as well', async () => { - await PageObjects.lens.save('New', false, false, false, 'new'); + await lens.save('New', false, false, false, 'new'); - await PageObjects.dashboard.waitForRenderComplete(); - await PageObjects.lens.assertMessageListContains( + await dashboard.waitForRenderComplete(); + await lens.assertMessageListContains( 'Median of bytes_gauge uses a function that is unsupported by rolled up data. Select a different function or change the time range.', 'warning' ); @@ -418,13 +418,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('time series special field types support', () => { before(async () => { - await PageObjects.common.navigateToApp('lens'); - await PageObjects.lens.switchDataPanelIndexPattern(tsdbDataView); - await PageObjects.lens.goToTimeRange(); + await common.navigateToApp('lens'); + await lens.switchDataPanelIndexPattern(tsdbDataView); + await lens.goToTimeRange(); }); afterEach(async () => { - await PageObjects.lens.removeLayer(); + await lens.removeLayer(); }); // skip count for now as it's a special function and will @@ -459,14 +459,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { if (supportedOperations.length) { it(`should allow operations when supported by ${fieldType} field type`, async () => { // Counter rate requires a date histogram dimension configured to work - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); // minimum supports all tsdb field types - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'min', field: `bytes_${fieldType}`, @@ -484,7 +484,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { for (const supportedOp of supportedOperations) { // try to change to the provided function and check all is ok - await PageObjects.lens.selectOperation(supportedOp.name); + await lens.selectOperation(supportedOp.name); expect( await find.existsByCssSelector( @@ -493,22 +493,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ).to.be(false); // return in a clean state before checking the next operation - await PageObjects.lens.selectOperation('min'); + await lens.selectOperation('min'); } - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); } if (unsupportedOperatons.length) { it(`should notify the incompatibility of unsupported operations for the ${fieldType} field type`, async () => { // Counter rate requires a date histogram dimension configured to work - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); // minimum supports all tsdb field types - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'min', field: `bytes_${fieldType}`, @@ -529,7 +529,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { for (const unsupportedOp of unsupportedOperatons) { // try to change to the provided function and check if it's in an incompatibility state - await PageObjects.lens.selectOperation(unsupportedOp.name, true); + await lens.selectOperation(unsupportedOp.name, true); const fieldSelectErrorEl = await find.byCssSelector( '[data-test-subj="indexPattern-field-selection-row"] .euiFormErrorText' @@ -540,28 +540,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); // return in a clean state before checking the next operation - await PageObjects.lens.selectOperation('min'); + await lens.selectOperation('min'); } - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); } } describe('show time series dimension groups within breakdown', () => { it('should show the time series dimension group on field picker when configuring a breakdown', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'min', field: 'bytes_counter', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', keepOpen: true, @@ -569,24 +569,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const list = await comboBox.getOptionsList('indexPattern-dimension-field'); expect(list).to.contain('Time series dimensions'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it("should not show the time series dimension group on field picker if it's not a breakdown", async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'min', field: 'bytes_counter', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', keepOpen: true, }); const list = await comboBox.getOptionsList('indexPattern-dimension-field'); expect(list).to.not.contain('Time series dimensions'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); }); }); @@ -701,10 +701,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }, { override: true } ); - await PageObjects.common.navigateToApp('lens'); + await common.navigateToApp('lens'); await elasticChart.setNewChartUiDebugFlag(true); // go to the - await PageObjects.lens.goToTimeRange( + await lens.goToTimeRange( fromTimeForScenarios, moment .utc(toTimeForScenarios, TIME_PICKER_FORMAT) @@ -731,8 +731,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async () => { - await PageObjects.lens.switchDataPanelIndexPattern(dataViewName); - await PageObjects.lens.removeLayer(); + await lens.switchDataPanelIndexPattern(dataViewName); + await lens.removeLayer(); }); testingFn(indexes); @@ -774,13 +774,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { runTestsForEachScenario(streamConvertedToTsdbIndex, (indexes) => { it('should detect the data stream has now been upgraded to TSDB', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'min', field: `bytes_counter`, @@ -792,30 +792,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { timeout: 500, }) ).to.eql(false); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it(`should visualize a date histogram chart for counter field`, async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); // check the counter field works - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'min', field: `bytes_counter`, }); // and also that the count of documents should be "indexes.length" times overall - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'count', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); const counterBars = data?.bars![0].bars; const countBars = data?.bars![1].bars; @@ -876,13 +876,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { runTestsForEachScenario(tsdbConvertedToStream, (indexes) => { it('should keep TSDB restrictions only if a tsdb stream is in the dataView mix', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'min', field: `bytes_counter`, @@ -894,23 +894,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { timeout: 500, }) ).to.eql(indexes.some(({ tsdb }) => tsdb)); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it(`should visualize a date histogram chart for counter field`, async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); // just check the data is shown - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'count', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); + const data = await lens.getCurrentChartDebugState('xyVisChart'); const bars = data?.bars![0].bars; const columnsToCheck = bars ? bars.length / 2 : 0; // due to the flaky nature of exact check here, we're going to relax it @@ -929,7 +929,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should visualize data when moving the time window around the downgrade moment', async () => { // check after the downgrade - await PageObjects.lens.goToTimeRange( + await lens.goToTimeRange( moment .utc(fromTimeForScenarios, TIME_PICKER_FORMAT) .subtract(1, 'hour') @@ -940,23 +940,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { .format(TIME_PICKER_FORMAT) // consider only new documents ); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'count', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); - const dataBefore = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); + const dataBefore = await lens.getCurrentChartDebugState('xyVisChart'); const barsBefore = dataBefore?.bars![0].bars; expect(barsBefore?.some(({ y }) => y)).to.eql(true); // check after the downgrade - await PageObjects.lens.goToTimeRange( + await lens.goToTimeRange( moment .utc(toTimeForScenarios, TIME_PICKER_FORMAT) .add(1, 'second') @@ -967,8 +967,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { .format(TIME_PICKER_FORMAT) // consider also new documents ); - await PageObjects.lens.waitForVisualization('xyVisChart'); - const dataAfter = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); + const dataAfter = await lens.getCurrentChartDebugState('xyVisChart'); const barsAfter = dataAfter?.bars![0].bars; expect(barsAfter?.some(({ y }) => y)).to.eql(true); }); diff --git a/x-pack/test/functional/apps/lens/group5/drag_and_drop.ts b/x-pack/test/functional/apps/lens/group5/drag_and_drop.ts index d1a449a6fa30b..144c9f0b8995f 100644 --- a/x-pack/test/functional/apps/lens/group5/drag_and_drop.ts +++ b/x-pack/test/functional/apps/lens/group5/drag_and_drop.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens, header } = getPageObjects(['visualize', 'lens', 'header']); const listingTable = getService('listingTable'); const xyChartContainer = 'xyVisChart'; @@ -17,48 +17,41 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens drag and drop tests', () => { describe('basic drag and drop', () => { it('should construct the basic split xy chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.dragFieldToWorkspace('@timestamp', xyChartContainer); - - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( - '@timestamp' - ); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await header.waitUntilLoadingHasFinished(); + await lens.dragFieldToWorkspace('@timestamp', xyChartContainer); + + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql('@timestamp'); }); it('should allow dropping fields to existing and empty dimension triggers', async () => { - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.dragFieldToDimensionTrigger( + await lens.dragFieldToDimensionTrigger( 'clientip', 'lnsDatatable_rows > lns-dimensionTrigger' ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_rows')).to.eql( + expect(await lens.getDimensionTriggerText('lnsDatatable_rows')).to.eql( 'Top 3 values of clientip' ); - await PageObjects.lens.dragFieldToDimensionTrigger( - 'bytes', - 'lnsDatatable_rows > lns-empty-dimension' - ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_rows', 1)).to.eql( - 'bytes' - ); - await PageObjects.lens.dragFieldToDimensionTrigger( + await lens.dragFieldToDimensionTrigger('bytes', 'lnsDatatable_rows > lns-empty-dimension'); + expect(await lens.getDimensionTriggerText('lnsDatatable_rows', 1)).to.eql('bytes'); + await lens.dragFieldToDimensionTrigger( '@message.raw', 'lnsDatatable_rows > lns-empty-dimension' ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_rows', 2)).to.eql( + expect(await lens.getDimensionTriggerText('lnsDatatable_rows', 2)).to.eql( 'Top 3 values of @message.raw' ); }); it('should reorder the elements for the table', async () => { - await PageObjects.lens.reorderDimensions('lnsDatatable_rows', 3, 1); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsDatatable_rows')).to.eql([ + await lens.reorderDimensions('lnsDatatable_rows', 3, 1); + await lens.waitForVisualization(); + expect(await lens.getDimensionTriggersTexts('lnsDatatable_rows')).to.eql([ 'Top 3 values of @message.raw', 'Top 3 values of clientip', 'bytes', @@ -66,168 +59,162 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should move the column to compatible dimension group', async () => { - await PageObjects.lens.switchToVisualization('bar'); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([ + await lens.switchToVisualization('bar'); + expect(await lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([ 'Top 3 values of @message.raw', ]); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql(['Top 3 values of clientip']); + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([ + 'Top 3 values of clientip', + ]); - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lns-layerPanel-0 > lnsXY_xDimensionPanel > lns-dimensionTrigger', to: 'lns-layerPanel-0 > lnsXY_splitDimensionPanel > lns-dimensionTrigger', }); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql( - [] - ); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql(['Top 3 values of @message.raw']); + expect(await lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([]); + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([ + 'Top 3 values of @message.raw', + ]); }); it('should move the column to non-compatible dimension group', async () => { - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql(['Top 3 values of @message.raw']); + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([ + 'Top 3 values of @message.raw', + ]); - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lnsXY_splitDimensionPanel > lns-dimensionTrigger', to: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', }); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql([]); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql([]); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([]); + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([]); + expect(await lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ 'Count of @message.raw', ]); }); it('should duplicate the column when dragging to empty dimension in the same group', async () => { - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', to: 'lnsXY_yDimensionPanel > lns-empty-dimension', }); - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', to: 'lnsXY_yDimensionPanel > lns-empty-dimension', }); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ 'Count of @message.raw', 'Count of @message.raw [1]', 'Count of @message.raw [2]', ]); }); it('should move duplicated column to non-compatible dimension group', async () => { - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', to: 'lnsXY_xDimensionPanel > lns-empty-dimension', }); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ 'Count of @message.raw', 'Count of @message.raw [1]', ]); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([ 'Top 5 values of @message.raw', ]); }); it('Should duplicate and swap elements when dragging over secondary drop targets', async () => { - await PageObjects.lens.removeLayer(); - await PageObjects.lens.switchToVisualization('bar'); - await PageObjects.lens.dragFieldToWorkspace('@timestamp', xyChartContainer); + await lens.removeLayer(); + await lens.switchToVisualization('bar'); + await lens.dragFieldToWorkspace('@timestamp', xyChartContainer); - await PageObjects.lens.dragDimensionToExtraDropType( + await lens.dragDimensionToExtraDropType( 'lnsXY_xDimensionPanel > lns-dimensionTrigger', 'lnsXY_splitDimensionPanel', 'duplicate', xyChartContainer ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( '@timestamp [1]' ); - await PageObjects.lens.dragFieldToDimensionTrigger( + await lens.dragFieldToDimensionTrigger( '@message.raw', 'lnsXY_yDimensionPanel > lns-dimensionTrigger' ); - await PageObjects.lens.dragDimensionToExtraDropType( + await lens.dragDimensionToExtraDropType( 'lnsXY_splitDimensionPanel > lns-dimensionTrigger', 'lnsXY_yDimensionPanel', 'swap', xyChartContainer ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Count of @timestamp' ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( 'Top 3 values of @message.raw' ); }); it('should combine breakdown dimension with the horizontal one', async () => { - await PageObjects.lens.removeLayer(); - await PageObjects.lens.dragFieldToWorkspace('clientip', xyChartContainer); - await PageObjects.lens.dragFieldToWorkspace('@message.raw', xyChartContainer); + await lens.removeLayer(); + await lens.dragFieldToWorkspace('clientip', xyChartContainer); + await lens.dragFieldToWorkspace('@message.raw', xyChartContainer); - await PageObjects.lens.dragDimensionToExtraDropType( + await lens.dragDimensionToExtraDropType( 'lnsXY_splitDimensionPanel > lns-dimensionTrigger', 'lnsXY_xDimensionPanel', 'combine', xyChartContainer ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( 'Top values of clientip + 1 other' ); }); it('should combine field to existing horizontal dimension', async () => { - await PageObjects.lens.removeLayer(); - await PageObjects.lens.dragFieldToWorkspace('clientip', xyChartContainer); + await lens.removeLayer(); + await lens.dragFieldToWorkspace('clientip', xyChartContainer); - await PageObjects.lens.dragFieldToExtraDropType( + await lens.dragFieldToExtraDropType( '@message.raw', 'lnsXY_xDimensionPanel', 'combine', xyChartContainer ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( 'Top values of clientip + 1 other' ); }); it('should combine two multi terms dimensions', async () => { - await PageObjects.lens.removeLayer(); - await PageObjects.lens.dragFieldToWorkspace('clientip', xyChartContainer); + await lens.removeLayer(); + await lens.dragFieldToWorkspace('clientip', xyChartContainer); - await PageObjects.lens.dragFieldToExtraDropType( + await lens.dragFieldToExtraDropType( '@message.raw', 'lnsXY_xDimensionPanel', 'combine', xyChartContainer ); - await PageObjects.lens.dragFieldToDimensionTrigger( + await lens.dragFieldToDimensionTrigger( '@message.raw', 'lnsXY_splitDimensionPanel > lns-empty-dimension' ); - await PageObjects.lens.dragFieldToExtraDropType( + await lens.dragFieldToExtraDropType( 'geo.src', 'lnsXY_splitDimensionPanel', 'combine', xyChartContainer ); - await PageObjects.lens.dragDimensionToExtraDropType( + await lens.dragDimensionToExtraDropType( 'lnsXY_splitDimensionPanel > lns-dimensionTrigger', 'lnsXY_xDimensionPanel', 'combine', xyChartContainer ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( 'Top values of clientip + 2 others' ); }); @@ -235,251 +222,239 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('keyboard drag and drop', () => { it('should drop a field to workspace', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.dragFieldWithKeyboard('@timestamp'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( - '@timestamp' - ); - await PageObjects.lens.assertFocusedField('@timestamp'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await header.waitUntilLoadingHasFinished(); + await lens.dragFieldWithKeyboard('@timestamp'); + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql('@timestamp'); + await lens.assertFocusedField('@timestamp'); }); it('should drop a field to empty dimension', async () => { - await PageObjects.lens.dragFieldWithKeyboard('bytes', 4); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ + await lens.dragFieldWithKeyboard('bytes', 4); + expect(await lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ 'Count of records', 'Median of bytes', ]); - await PageObjects.lens.dragFieldWithKeyboard('@message.raw', 1, true); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql(['Top 3 values of @message.raw']); - await PageObjects.lens.assertFocusedField('@message.raw'); + await lens.dragFieldWithKeyboard('@message.raw', 1, true); + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([ + 'Top 3 values of @message.raw', + ]); + await lens.assertFocusedField('@message.raw'); }); it('should drop a field to an existing dimension replacing the old one', async () => { - await PageObjects.lens.dragFieldWithKeyboard('clientip', 1, true); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql(['Top 3 values of clientip']); + await lens.dragFieldWithKeyboard('clientip', 1, true); + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([ + 'Top 3 values of clientip', + ]); - await PageObjects.lens.assertFocusedField('clientip'); + await lens.assertFocusedField('clientip'); }); it('should duplicate an element in a group', async () => { - await PageObjects.lens.dimensionKeyboardDragDrop('lnsXY_yDimensionPanel', 0, 1); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ + await lens.dimensionKeyboardDragDrop('lnsXY_yDimensionPanel', 0, 1); + expect(await lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ 'Count of records', 'Median of bytes', 'Count of records [1]', ]); - await PageObjects.lens.assertFocusedDimension('Count of records [1]'); + await lens.assertFocusedDimension('Count of records [1]'); }); it('should move dimension to compatible dimension', async () => { - await PageObjects.lens.dimensionKeyboardDragDrop('lnsXY_xDimensionPanel', 0, 5); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql( - [] - ); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql(['@timestamp']); + await lens.dimensionKeyboardDragDrop('lnsXY_xDimensionPanel', 0, 5); + expect(await lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([]); + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([ + '@timestamp', + ]); - await PageObjects.lens.dimensionKeyboardDragDrop('lnsXY_splitDimensionPanel', 0, 5, true); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([ + await lens.dimensionKeyboardDragDrop('lnsXY_splitDimensionPanel', 0, 5, true); + expect(await lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([ '@timestamp', ]); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql([]); - await PageObjects.lens.assertFocusedDimension('@timestamp'); + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([]); + await lens.assertFocusedDimension('@timestamp'); }); it('should move dimension to incompatible dimension', async () => { - await PageObjects.lens.dimensionKeyboardDragDrop('lnsXY_yDimensionPanel', 1, 2); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql(['bytes']); + await lens.dimensionKeyboardDragDrop('lnsXY_yDimensionPanel', 1, 2); + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql(['bytes']); - await PageObjects.lens.dimensionKeyboardDragDrop('lnsXY_xDimensionPanel', 0, 2); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ + await lens.dimensionKeyboardDragDrop('lnsXY_xDimensionPanel', 0, 2); + expect(await lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ 'Count of records', 'Count of @timestamp', ]); - await PageObjects.lens.assertFocusedDimension('Count of @timestamp'); + await lens.assertFocusedDimension('Count of @timestamp'); }); it('should reorder elements with keyboard', async () => { - await PageObjects.lens.dimensionKeyboardReorder('lnsXY_yDimensionPanel', 0, 1); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ + await lens.dimensionKeyboardReorder('lnsXY_yDimensionPanel', 0, 1); + expect(await lens.getDimensionTriggersTexts('lnsXY_yDimensionPanel')).to.eql([ 'Count of @timestamp', 'Count of records', ]); - await PageObjects.lens.assertFocusedDimension('Count of records'); + await lens.assertFocusedDimension('Count of records'); }); }); describe('workspace drop', () => { it('should always nest time dimension in categorical dimension', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.dragFieldToWorkspace('@timestamp', xyChartContainer); - await PageObjects.lens.waitForVisualization(xyChartContainer); - await PageObjects.lens.dragFieldToWorkspace('clientip', xyChartContainer); - await PageObjects.lens.waitForVisualization(xyChartContainer); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel') - ).to.eql(['Top 3 values of clientip']); - await PageObjects.lens.openDimensionEditor( - 'lnsXY_splitDimensionPanel > lns-dimensionTrigger' - ); - expect(await PageObjects.lens.isTopLevelAggregation()).to.be(true); - await PageObjects.lens.closeDimensionEditor(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await header.waitUntilLoadingHasFinished(); + await lens.dragFieldToWorkspace('@timestamp', xyChartContainer); + await lens.waitForVisualization(xyChartContainer); + await lens.dragFieldToWorkspace('clientip', xyChartContainer); + await lens.waitForVisualization(xyChartContainer); + expect(await lens.getDimensionTriggersTexts('lnsXY_splitDimensionPanel')).to.eql([ + 'Top 3 values of clientip', + ]); + await lens.openDimensionEditor('lnsXY_splitDimensionPanel > lns-dimensionTrigger'); + expect(await lens.isTopLevelAggregation()).to.be(true); + await lens.closeDimensionEditor(); }); it('overwrite existing time dimension if one exists already', async () => { - await PageObjects.lens.searchField('utc'); - await PageObjects.lens.dragFieldToWorkspace('utc_time', xyChartContainer); - await PageObjects.lens.waitForVisualization(xyChartContainer); - await PageObjects.lens.searchField('client'); - await PageObjects.lens.dragFieldToWorkspace('clientip', xyChartContainer); - await PageObjects.lens.waitForVisualization(xyChartContainer); - expect(await PageObjects.lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql([ - 'utc_time', - ]); + await lens.searchField('utc'); + await lens.dragFieldToWorkspace('utc_time', xyChartContainer); + await lens.waitForVisualization(xyChartContainer); + await lens.searchField('client'); + await lens.dragFieldToWorkspace('clientip', xyChartContainer); + await lens.waitForVisualization(xyChartContainer); + expect(await lens.getDimensionTriggersTexts('lnsXY_xDimensionPanel')).to.eql(['utc_time']); }); }); describe('dropping between layers', () => { it('should move the column', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); - await PageObjects.lens.createLayer('data'); + await lens.createLayer('data'); // here the editor will error out as the mandatory vertical axis is missing - await PageObjects.lens.dragDimensionToExtraDropType( + await lens.dragDimensionToExtraDropType( 'lns-layerPanel-0 > lnsXY_xDimensionPanel > lns-dimensionTrigger', 'lns-layerPanel-1 > lnsXY_xDimensionPanel', 'duplicate', 'workspace-error-message' ); - await PageObjects.lens.assertFocusedDimension('@timestamp [1]'); + await lens.assertFocusedDimension('@timestamp [1]'); - await PageObjects.lens.dragDimensionToExtraDropType( + await lens.dragDimensionToExtraDropType( 'lns-layerPanel-0 > lnsXY_yDimensionPanel > lns-dimensionTrigger', 'lns-layerPanel-1 > lnsXY_yDimensionPanel', 'duplicate', xyChartContainer ); - await PageObjects.lens.assertFocusedDimension('Average of bytes [1]'); - expect(await PageObjects.lens.getDimensionTriggersTexts('lns-layerPanel-0')).to.eql([ + await lens.assertFocusedDimension('Average of bytes [1]'); + expect(await lens.getDimensionTriggersTexts('lns-layerPanel-0')).to.eql([ '@timestamp', 'Average of bytes', 'Top 3 values of ip', ]); - expect(await PageObjects.lens.getDimensionTriggersTexts('lns-layerPanel-1')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lns-layerPanel-1')).to.eql([ '@timestamp [1]', 'Average of bytes [1]', ]); }); it('should move formula to empty dimension', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'formula', formula: `moving_average(average(bytes), window=5`, }); - await PageObjects.lens.dragDimensionToExtraDropType( + await lens.dragDimensionToExtraDropType( 'lns-layerPanel-0 > lnsXY_yDimensionPanel > lns-dimensionTrigger', 'lns-layerPanel-1 > lnsXY_yDimensionPanel', 'duplicate', xyChartContainer ); - expect(await PageObjects.lens.getDimensionTriggersTexts('lns-layerPanel-0')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lns-layerPanel-0')).to.eql([ '@timestamp', 'moving_average(average(bytes), window=5)', 'Top 3 values of ip', ]); - expect(await PageObjects.lens.getDimensionTriggersTexts('lns-layerPanel-1')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lns-layerPanel-1')).to.eql([ '@timestamp [1]', 'moving_average(average(bytes), window=5) [1]', ]); }); it('should replace formula with another formula', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'formula', formula: `sum(bytes) + 5`, }); - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lns-layerPanel-0 > lnsXY_yDimensionPanel > lns-dimensionTrigger', to: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-dimensionTrigger', }); - expect(await PageObjects.lens.getDimensionTriggersTexts('lns-layerPanel-0')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lns-layerPanel-0')).to.eql([ '@timestamp', 'Top 3 values of ip', ]); - expect(await PageObjects.lens.getDimensionTriggersTexts('lns-layerPanel-1')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lns-layerPanel-1')).to.eql([ '@timestamp [1]', 'moving_average(average(bytes), window=5)', ]); }); it('swaps dimensions', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); - await PageObjects.lens.createLayer('data'); - await PageObjects.lens.dragFieldToDimensionTrigger( + await lens.createLayer('data'); + await lens.dragFieldToDimensionTrigger( 'bytes', 'lns-layerPanel-0 > lnsXY_yDimensionPanel > lns-empty-dimension' ); - await PageObjects.lens.dragFieldToDimensionTrigger( + await lens.dragFieldToDimensionTrigger( 'bytes', 'lns-layerPanel-1 > lnsXY_splitDimensionPanel > lns-empty-dimension' ); // here the editor will error out as the mandatory vertical axis is missing - await PageObjects.lens.dragDimensionToExtraDropType( + await lens.dragDimensionToExtraDropType( 'lns-layerPanel-1 > lnsXY_splitDimensionPanel > lns-dimensionTrigger', 'lns-layerPanel-0 > lnsXY_splitDimensionPanel', 'swap', 'workspace-error-message' ); - expect(await PageObjects.lens.getDimensionTriggersTexts('lns-layerPanel-0')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lns-layerPanel-0')).to.eql([ '@timestamp', 'Average of bytes', 'Median of bytes', 'bytes', ]); - expect(await PageObjects.lens.getDimensionTriggersTexts('lns-layerPanel-1')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lns-layerPanel-1')).to.eql([ 'Top 3 values of ip', ]); }); it('can combine dimensions', async () => { // here the editor will error out as the mandatory vertical axis is missing - await PageObjects.lens.dragDimensionToExtraDropType( + await lens.dragDimensionToExtraDropType( 'lns-layerPanel-0 > lnsXY_splitDimensionPanel > lns-dimensionTrigger', 'lns-layerPanel-1 > lnsXY_splitDimensionPanel', 'combine', 'workspace-error-message' ); - expect(await PageObjects.lens.getDimensionTriggersTexts('lns-layerPanel-0')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lns-layerPanel-0')).to.eql([ '@timestamp', 'Average of bytes', 'Median of bytes', ]); - expect(await PageObjects.lens.getDimensionTriggersTexts('lns-layerPanel-1')).to.eql([ + expect(await lens.getDimensionTriggersTexts('lns-layerPanel-1')).to.eql([ 'Top values of ip + 1 other', ]); }); diff --git a/x-pack/test/functional/apps/lens/group5/formula.ts b/x-pack/test/functional/apps/lens/group5/formula.ts index e02548d7108ca..95404faf5a99d 100644 --- a/x-pack/test/functional/apps/lens/group5/formula.ts +++ b/x-pack/test/functional/apps/lens/group5/formula.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common']); + const { visualize, lens, common } = getPageObjects(['visualize', 'lens', 'common']); const find = getService('find'); const listingTable = getService('listingTable'); const browser = getService('browser'); @@ -20,20 +20,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens formula', () => { it('should transition from count to formula', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'average', field: 'bytes', keepOpen: true, }); - await PageObjects.lens.switchToFormula(); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.switchToFormula(); + await lens.waitForVisualization('xyVisChart'); // .echLegendItem__title is the only viable way of getting the xy chart's // legend item(s), so we're using a class selector here. // 4th item is the other bucket @@ -41,12 +41,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should update and delete a formula', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'formula', formula: `count(kql=`, @@ -57,17 +57,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await input.type('*'); await retry.try(async () => { - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('14,005'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('14,005'); }); }); it('should insert single quotes and escape when needed to create valid KQL', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'formula', formula: `count(kql=`, @@ -79,222 +79,220 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await input.pressKeys(browser.keys.ARROW_LEFT); await input.type(`Men's Clothing`); - await PageObjects.common.sleep(100); + await common.sleep(100); - await PageObjects.lens.expectFormulaText(`count(kql='Men\\'s Clothing ')`); + await lens.expectFormulaText(`count(kql='Men\\'s Clothing ')`); - await PageObjects.lens.typeFormula('count(kql='); + await lens.typeFormula('count(kql='); input = await find.activeElement(); await input.type(`Men\'s Clothing`); - await PageObjects.common.sleep(100); + await common.sleep(100); - await PageObjects.lens.expectFormulaText(`count(kql='Men\\'s Clothing')`); + await lens.expectFormulaText(`count(kql='Men\\'s Clothing')`); }); it('should insert single quotes and escape when needed to create valid field name', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); await dataViews.clickAddFieldFromSearchBar(); await fieldEditor.setName(`ab' "'`, true, true); await fieldEditor.enableValue(); await fieldEditor.typeScript("emit('abc')"); await fieldEditor.save(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'unique_count', field: `ab`, keepOpen: true, }); - await PageObjects.lens.switchToFormula(); - await PageObjects.lens.expectFormulaText(`unique_count('ab\\' "\\'')`); + await lens.switchToFormula(); + await lens.expectFormulaText(`unique_count('ab\\' "\\'')`); - await PageObjects.lens.typeFormula('unique_count('); + await lens.typeFormula('unique_count('); const input = await find.activeElement(); await input.type('ab'); await input.pressKeys(browser.keys.ENTER); - await PageObjects.common.sleep(100); + await common.sleep(100); - await PageObjects.lens.expectFormulaText(`unique_count('ab\\' "\\'')`); + await lens.expectFormulaText(`unique_count('ab\\' "\\'')`); }); it('should persist a broken formula on close', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); // Close immediately - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'formula', formula: `asdf`, }); - expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_metrics')).to.eql('asdf'); + expect(await lens.getDimensionTriggerText('lnsDatatable_metrics')).to.eql('asdf'); - await PageObjects.lens.assertMessageListContains('Field asdf was not found.', 'error'); + await lens.assertMessageListContains('Field asdf was not found.', 'error'); }); it('should keep the formula when entering expanded mode', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'formula', formula: `count()`, keepOpen: true, }); - await PageObjects.lens.toggleFullscreen(); + await lens.toggleFullscreen(); const element = await find.byCssSelector('.monaco-editor'); expect(await element.getVisibleText()).to.equal('count()'); }); it('should allow an empty formula combined with a valid formula', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'formula', formula: `count()`, }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'formula', }); - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getWorkspaceErrorCount()).to.eql(0); + await lens.waitForVisualization(); + expect(await lens.getWorkspaceErrorCount()).to.eql(0); }); it('should duplicate a moving average formula and be a valid table with conditional coloring', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_rows > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', disableEmptyRows: true, }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'formula', formula: `moving_average(sum(bytes), window=5`, keepOpen: true, }); - await PageObjects.lens.setTableDynamicColoring('text'); - await PageObjects.lens.waitForVisualization(); - const styleObj = await PageObjects.lens.getDatatableCellStyle(1, 1); + await lens.setTableDynamicColoring('text'); + await lens.waitForVisualization(); + const styleObj = await lens.getDatatableCellStyle(1, 1); expect(styleObj['background-color']).to.be(undefined); expect(styleObj.color).not.to.be(undefined); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lnsDatatable_metrics > lns-dimensionTrigger', to: 'lnsDatatable_metrics > lns-empty-dimension', }); - expect(await PageObjects.lens.getDatatableCellText(1, 1)).to.eql('222,420'); - expect(await PageObjects.lens.getDatatableCellText(1, 2)).to.eql('222,420'); + expect(await lens.getDatatableCellText(1, 1)).to.eql('222,420'); + expect(await lens.getDatatableCellText(1, 2)).to.eql('222,420'); }); it('should keep the formula if the user does not fully transition to a quick function', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'formula', formula: `count()`, keepOpen: true, }); - await PageObjects.lens.switchToQuickFunctions(); + await lens.switchToQuickFunctions(); await testSubjects.click(`lns-indexPatternDimension-min incompatible`); - await PageObjects.common.sleep(1000); - await PageObjects.lens.closeDimensionEditor(); + await common.sleep(1000); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_metrics', 0)).to.eql( - 'count()' - ); + expect(await lens.getDimensionTriggerText('lnsDatatable_metrics', 0)).to.eql('count()'); }); it('should keep the formula if the user does not fully transition to a static value', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.createLayer('referenceLine'); + await lens.createLayer('referenceLine'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yReferenceLineLeftPanel > lns-dimensionTrigger', operation: 'formula', formula: `count()`, keepOpen: true, }); - await PageObjects.lens.switchToStaticValue(); - await PageObjects.lens.closeDimensionEditor(); - await PageObjects.common.sleep(1000); + await lens.switchToStaticValue(); + await lens.closeDimensionEditor(); + await common.sleep(1000); - expect( - await PageObjects.lens.getDimensionTriggerText('lnsXY_yReferenceLineLeftPanel', 0) - ).to.eql('count()'); + expect(await lens.getDimensionTriggerText('lnsXY_yReferenceLineLeftPanel', 0)).to.eql( + 'count()' + ); }); it('should allow numeric only formulas', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'formula', formula: `0`, }); - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lnsDatatable_metrics > lns-dimensionTrigger', to: 'lnsDatatable_metrics > lns-empty-dimension', }); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('0'); - expect(await PageObjects.lens.getDatatableCellText(0, 1)).to.eql('0'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('0'); + expect(await lens.getDatatableCellText(0, 1)).to.eql('0'); }); it('should apply a global filter to the current formula', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'formula', formula: `count()`, @@ -302,28 +300,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // check the numbers - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('14,005'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('14,005'); // add an advanced filter by filter - await PageObjects.lens.enableFilter(); - await PageObjects.lens.setFilterBy('bytes > 4000'); + await lens.enableFilter(); + await lens.setFilterBy('bytes > 4000'); // check that numbers changed - await PageObjects.lens.waitForVisualization(); + await lens.waitForVisualization(); await retry.try(async () => { - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('9,169'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('9,169'); }); // now change the formula to add an inner filter to count - await PageObjects.lens.typeFormula(`count(kql=`); + await lens.typeFormula(`count(kql=`); const input = await find.activeElement(); await input.type(`bytes > 600000`); // the autocomplete will add quotes and closing brakets, so do not worry about that - await PageObjects.lens.waitForVisualization(); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('0'); + await lens.waitForVisualization(); + expect(await lens.getDatatableCellText(0, 0)).to.eql('0'); }); }); } diff --git a/x-pack/test/functional/apps/lens/group5/gauge.ts b/x-pack/test/functional/apps/lens/group5/gauge.ts index 20980857f9d1a..eea38d486833d 100644 --- a/x-pack/test/functional/apps/lens/group5/gauge.ts +++ b/x-pack/test/functional/apps/lens/group5/gauge.ts @@ -10,34 +10,34 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header', 'timePicker']); + const { visualize, lens, timePicker } = getPageObjects(['visualize', 'lens', 'timePicker']); const elasticChart = getService('elasticChart'); const testSubjects = getService('testSubjects'); describe('lens gauge', () => { before(async () => { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); }); it('should switch to gauge and render a gauge with default values', async () => { - await PageObjects.lens.switchToVisualization('lnsGauge', 'gauge'); - await PageObjects.lens.waitForVisualization('gaugeChart'); + await lens.switchToVisualization('lnsGauge', 'gauge'); + await lens.waitForVisualization('gaugeChart'); const { bullet } = await elasticChart.getChartDebugData(); const debugData = bullet?.rows[0][0]; expect(debugData?.subtype).to.be(BulletSubtype.horizontal); @@ -47,9 +47,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should reflect edits for gauge', async () => { - await PageObjects.lens.switchToVisualization('lnsGauge', 'gauge'); - await PageObjects.lens.waitForVisualization('gaugeChart'); - await PageObjects.lens.configureDimension({ + await lens.switchToVisualization('lnsGauge', 'gauge'); + await lens.waitForVisualization('gaugeChart'); + await lens.configureDimension({ dimension: 'lnsGauge_metricDimensionPanel > lns-dimensionTrigger', operation: 'count', field: 'Records', @@ -58,33 +58,31 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await testSubjects.setEuiSwitch('lnsDynamicColoringGaugeSwitch', 'check'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - await PageObjects.lens.openTextOptions(); - await PageObjects.lens.retrySetValue('lnsToolbarGaugeLabelMajor', 'custom title'); - await PageObjects.lens.retrySetValue('lnsToolbarGaugeLabelMinor-select', 'custom', {}); - await PageObjects.lens.retrySetValue('lnsToolbarGaugeLabelMinor', 'custom subtitle'); + await lens.openTextOptions(); + await lens.retrySetValue('lnsToolbarGaugeLabelMajor', 'custom title'); + await lens.retrySetValue('lnsToolbarGaugeLabelMinor-select', 'custom', {}); + await lens.retrySetValue('lnsToolbarGaugeLabelMinor', 'custom subtitle'); - await PageObjects.lens.waitForVisualization('gaugeChart'); - await PageObjects.lens.openDimensionEditor( - 'lnsGauge_goalDimensionPanel > lns-empty-dimension' - ); + await lens.waitForVisualization('gaugeChart'); + await lens.openDimensionEditor('lnsGauge_goalDimensionPanel > lns-empty-dimension'); - await PageObjects.lens.waitForVisualization('gaugeChart'); - await PageObjects.lens.closeDimensionEditor(); - await PageObjects.lens.openDimensionEditor( + await lens.waitForVisualization('gaugeChart'); + await lens.closeDimensionEditor(); + await lens.openDimensionEditor( 'lnsGauge_minDimensionPanel > lns-empty-dimension-suggested-value' ); - await PageObjects.lens.retrySetValue('lns-indexPattern-static_value-input', '1000'); - await PageObjects.lens.waitForVisualization('gaugeChart'); - await PageObjects.lens.closeDimensionEditor(); + await lens.retrySetValue('lns-indexPattern-static_value-input', '1000'); + await lens.waitForVisualization('gaugeChart'); + await lens.closeDimensionEditor(); - await PageObjects.lens.openDimensionEditor( + await lens.openDimensionEditor( 'lnsGauge_maxDimensionPanel > lns-empty-dimension-suggested-value' ); - await PageObjects.lens.retrySetValue('lns-indexPattern-static_value-input', '25000'); - await PageObjects.lens.waitForVisualization('gaugeChart'); - await PageObjects.lens.closeDimensionEditor(); + await lens.retrySetValue('lns-indexPattern-static_value-input', '25000'); + await lens.waitForVisualization('gaugeChart'); + await lens.closeDimensionEditor(); const { bullet } = await elasticChart.getChartDebugData(); const debugData = bullet?.rows[0][0]; @@ -96,7 +94,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(debugData?.domain).to.eql([1000, 25000]); }); it('should seamlessly switch to vertical bullet chart without losing configuration', async () => { - await PageObjects.lens.openVisualOptions(); + await lens.openVisualOptions(); await testSubjects.click('lns_gaugeOrientation_verticalBullet'); const { bullet } = await elasticChart.getChartDebugData(); const debugData = bullet?.rows[0][0]; @@ -108,8 +106,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(debugData?.domain).to.eql([1000, 25000]); }); it('should seamlessly switch to minor arc gauge chart without losing configuration', async () => { - await PageObjects.lens.openVisualOptions(); - await PageObjects.lens.setGaugeShape('Minor arc'); + await lens.openVisualOptions(); + await lens.setGaugeShape('Minor arc'); const { bullet } = await elasticChart.getChartDebugData(); const debugData = bullet?.rows[0][0]; expect(debugData?.subtype).to.be(BulletSubtype.halfCircle); @@ -120,8 +118,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(debugData?.domain).to.eql([1000, 25000]); }); it('should seamlessly switch to arc gauge chart without losing configuration', async () => { - await PageObjects.lens.openVisualOptions(); - await PageObjects.lens.setGaugeShape('Major arc'); + await lens.openVisualOptions(); + await lens.setGaugeShape('Major arc'); const { bullet } = await elasticChart.getChartDebugData(); const debugData = bullet?.rows[0][0]; expect(debugData?.subtype).to.be(BulletSubtype.twoThirdsCircle); @@ -132,8 +130,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(debugData?.domain).to.eql([1000, 25000]); }); it('should seamlessly switch to circular gauge chart without losing configuration', async () => { - await PageObjects.lens.openVisualOptions(); - await PageObjects.lens.setGaugeShape('Circle'); + await lens.openVisualOptions(); + await lens.setGaugeShape('Circle'); const { bullet } = await elasticChart.getChartDebugData(); const debugData = bullet?.rows[0][0]; expect(debugData?.subtype).to.be(BulletSubtype.circle); @@ -144,10 +142,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(debugData?.domain).to.eql([1000, 25000]); }); it('should switch to table chart and filter not supported static values', async () => { - await PageObjects.lens.switchToVisualization('lnsDatatable'); - const columnsCount = await PageObjects.lens.getCountOfDatatableColumns(); + await lens.switchToVisualization('lnsDatatable'); + const columnsCount = await lens.getCountOfDatatableColumns(); expect(columnsCount).to.eql(1); - expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal('Count of records'); + expect(await lens.getDatatableHeaderText(0)).to.equal('Count of records'); }); }); } diff --git a/x-pack/test/functional/apps/lens/group5/geo_field.ts b/x-pack/test/functional/apps/lens/group5/geo_field.ts index 98008e3b7bb12..a5851263fae89 100644 --- a/x-pack/test/functional/apps/lens/group5/geo_field.ts +++ b/x-pack/test/functional/apps/lens/group5/geo_field.ts @@ -8,13 +8,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; -export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ +export default function ({ getPageObjects }: FtrProviderContext) { + const { visualize, lens, header, maps, common } = getPageObjects([ 'visualize', 'lens', 'header', 'maps', - 'timePicker', 'common', ]); const from = 'Sep 22, 2015 @ 00:00:00.000'; @@ -22,30 +21,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens visualize geo field tests', () => { before(async () => { - await PageObjects.common.setTime({ from, to }); + await common.setTime({ from, to }); }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('should visualize geo fields in maps', async () => { // as navigation does not happen via URL refresh by default, force a reset via URL navigation - await PageObjects.visualize.navigateToNewVisualization({ forceRefresh: true }); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.switchDataPanelIndexPattern('logstash-*'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.dragFieldToGeoFieldWorkspace('geo.coordinates'); + await visualize.navigateToNewVisualization({ forceRefresh: true }); + await visualize.clickVisType('lens'); + await lens.switchDataPanelIndexPattern('logstash-*'); + await header.waitUntilLoadingHasFinished(); + await lens.dragFieldToGeoFieldWorkspace('geo.coordinates'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - const doesLayerExist = await PageObjects.maps.doesLayerExist('logstash-*'); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + const doesLayerExist = await maps.doesLayerExist('logstash-*'); expect(doesLayerExist).to.equal(true); - const tooltipText = await PageObjects.maps.getLayerTocTooltipMsg('logstash-*'); + const tooltipText = await maps.getLayerTocTooltipMsg('logstash-*'); expect(tooltipText).to.equal( 'logstash-*\nFound 66 documents.\nResults narrowed by global time' ); - await PageObjects.maps.refreshAndClearUnsavedChangesWarning(); + await maps.refreshAndClearUnsavedChangesWarning(); }); }); } diff --git a/x-pack/test/functional/apps/lens/group5/heatmap.ts b/x-pack/test/functional/apps/lens/group5/heatmap.ts index 746aa33e244f9..7597b0448433d 100644 --- a/x-pack/test/functional/apps/lens/group5/heatmap.ts +++ b/x-pack/test/functional/apps/lens/group5/heatmap.ts @@ -9,36 +9,36 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common']); + const { visualize, lens, common } = getPageObjects(['visualize', 'lens', 'common']); const elasticChart = getService('elasticChart'); const testSubjects = getService('testSubjects'); const retry = getService('retry'); describe('lens heatmap', () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); }); it('should render heatmap chart with the temperature palette', async () => { - await PageObjects.lens.switchToVisualization('heatmap', 'heat'); - const debugState = await PageObjects.lens.getCurrentChartDebugState('heatmapChart'); + await lens.switchToVisualization('heatmap', 'heat'); + const debugState = await lens.getCurrentChartDebugState('heatmapChart'); // assert axes expect(debugState?.axes!.x[0].labels).to.eql([ @@ -65,16 +65,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should reflect stop colors change on the chart', async () => { - await PageObjects.lens.openDimensionEditor('lnsHeatmap_cellPanel > lns-dimensionTrigger'); - await PageObjects.lens.openPalettePanel(); - await PageObjects.common.sleep(1000); + await lens.openDimensionEditor('lnsHeatmap_cellPanel > lns-dimensionTrigger'); + await lens.openPalettePanel(); + await common.sleep(1000); await retry.try(async () => { await testSubjects.setValue('lnsPalettePanel_dynamicColoring_range_value_0', '10', { clearWithKeyboard: true, typeCharByChar: true, }); }); - const debugState = await PageObjects.lens.getCurrentChartDebugState('heatmapChart'); + const debugState = await lens.getCurrentChartDebugState('heatmapChart'); // assert legend has changed expect(debugState?.legend!.items).to.eql([ @@ -88,7 +88,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should not change when passing from percentage to number', async () => { await testSubjects.click('lnsPalettePanel_dynamicColoring_rangeType_groups_number'); - const debugState = await PageObjects.lens.getCurrentChartDebugState('heatmapChart'); + const debugState = await lens.getCurrentChartDebugState('heatmapChart'); // assert legend has changed expect(debugState?.legend!.items).to.eql([ @@ -109,7 +109,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { clearWithKeyboard: true, }); - const debugState = await PageObjects.lens.getCurrentChartDebugState('heatmapChart'); + const debugState = await lens.getCurrentChartDebugState('heatmapChart'); // assert legend has changed expect(debugState?.legend!.items).to.eql([ @@ -127,7 +127,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.setValue('lnsPalettePanel_dynamicColoring_range_value_0', '5722.7747', { clearWithKeyboard: true, }); - const debugState = await PageObjects.lens.getCurrentChartDebugState('heatmapChart'); + const debugState = await lens.getCurrentChartDebugState('heatmapChart'); // assert legend has a rounded value expect(debugState?.legend!.items).to.eql([ @@ -144,9 +144,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should reset stop numbers when changing palette', async () => { - await PageObjects.lens.changePaletteTo('status'); + await lens.changePaletteTo('status'); - const debugState = await PageObjects.lens.getCurrentChartDebugState('heatmapChart'); + const debugState = await lens.getCurrentChartDebugState('heatmapChart'); // assert legend has changed expect(debugState?.legend!.items).to.eql([ @@ -161,7 +161,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should not change when passing from number to percent', async () => { await testSubjects.click('lnsPalettePanel_dynamicColoring_rangeType_groups_percent'); - const debugState = await PageObjects.lens.getCurrentChartDebugState('heatmapChart'); + const debugState = await lens.getCurrentChartDebugState('heatmapChart'); // assert legend has not changed expect(debugState?.legend!.items).to.eql([ @@ -175,12 +175,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Skip for now as EC is not reporting title it.skip('should display axis values when setting axis title mode to Auto', async () => { - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - await PageObjects.lens.toggleToolbarPopover('lnsLeftAxisButton'); + await lens.toggleToolbarPopover('lnsLeftAxisButton'); await testSubjects.selectValue('lnsLeftAxisTitle-select', 'Auto'); - const debugState = await PageObjects.lens.getCurrentChartDebugState('heatmapChart'); + const debugState = await lens.getCurrentChartDebugState('heatmapChart'); expect(debugState?.axes?.y?.[0].title).to.eql('Average of bytes'); }); diff --git a/x-pack/test/functional/apps/lens/group5/index.ts b/x-pack/test/functional/apps/lens/group5/index.ts index e995a67c6e466..e0740ab4d4962 100644 --- a/x-pack/test/functional/apps/lens/group5/index.ts +++ b/x-pack/test/functional/apps/lens/group5/index.ts @@ -13,7 +13,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['timePicker']); + const { timePicker } = getPageObjects(['timePicker']); const config = getService('config'); let remoteEsArchiver; @@ -54,7 +54,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext await esNode.load(esArchive); // changing the timepicker default here saves us from having to set it in Discover (~8s) - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: indexPatternString, 'dateFormat:tz': 'UTC', @@ -65,7 +65,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext after(async () => { await esArchiver.unload(esArchive); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.importExport.unload(fixtureDirs.lensBasic); await kibanaServer.importExport.unload(fixtureDirs.lensDefault); await kibanaServer.savedObjects.cleanStandardList(); diff --git a/x-pack/test/functional/apps/lens/group5/tagcloud.ts b/x-pack/test/functional/apps/lens/group5/tagcloud.ts index c33ffc67d556f..dd718a476a489 100644 --- a/x-pack/test/functional/apps/lens/group5/tagcloud.ts +++ b/x-pack/test/functional/apps/lens/group5/tagcloud.ts @@ -9,38 +9,43 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header', 'tagCloud']); + const { visualize, lens, header, tagCloud } = getPageObjects([ + 'visualize', + 'lens', + 'header', + 'tagCloud', + ]); const elasticChart = getService('elasticChart'); const filterBar = getService('filterBar'); describe('lens tagcloud', () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsTagcloud', 'Tag cloud'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsTagcloud', 'Tag cloud'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsTagcloud_tagDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsTagcloud_valueDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.waitForVisualization('tagCloudVisualization'); + await header.waitUntilLoadingHasFinished(); + await lens.waitForVisualization('tagCloudVisualization'); // avoid picking up tags in suggestion panel by closing panel - await PageObjects.lens.closeSuggestionPanel(); + await lens.closeSuggestionPanel(); }); it('should render tagcloud', async () => { - const tags = await PageObjects.tagCloud.getTextTag(); + const tags = await tagCloud.getTextTag(); expect(tags).to.eql([ '97.220.3.248', '78.83.247.30', @@ -51,14 +56,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should add filter from clicking on tag', async () => { - await PageObjects.tagCloud.selectTagCloudTag('97.220.3.248'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await tagCloud.selectTagCloudTag('97.220.3.248'); + await header.waitUntilLoadingHasFinished(); const hasTagFilter = await filterBar.hasFilter('ip', '97.220.3.248'); expect(hasTagFilter).to.be(true); }); it('should filter results by filter bar', async () => { - const tags = await PageObjects.tagCloud.getTextTag(); + const tags = await tagCloud.getTextTag(); expect(tags).to.eql(['97.220.3.248']); }); }); diff --git a/x-pack/test/functional/apps/lens/group6/annotations.ts b/x-pack/test/functional/apps/lens/group6/annotations.ts index b5f498b209178..7556440eeb3bb 100644 --- a/x-pack/test/functional/apps/lens/group6/annotations.ts +++ b/x-pack/test/functional/apps/lens/group6/annotations.ts @@ -9,14 +9,11 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { visualize, lens, common, tagManagement } = getPageObjects([ 'visualize', 'lens', 'common', - 'header', 'tagManagement', - 'settings', - 'savedObjects', ]); const find = getService('find'); const retry = getService('retry'); @@ -28,16 +25,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens annotations tests', () => { before(async () => { - await PageObjects.common.setTime({ from, to }); + await common.setTime({ from, to }); }); after(async () => { - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('should show a disabled annotation layer button if there is no date histogram in data layer', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.dragFieldToWorkspace('geo.src', 'xyVisChart'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.dragFieldToWorkspace('geo.src', 'xyVisChart'); await testSubjects.click('lnsLayerAddButton'); await retry.waitFor('wait for layer popup to appear', async () => testSubjects.exists(`lnsLayerAddButton-annotations`) @@ -48,11 +45,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should add manual annotation layer with static date and allow edition', async () => { - await PageObjects.lens.removeLayer(); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.dragFieldToWorkspace('@timestamp', 'xyVisChart'); + await lens.removeLayer(); + await lens.goToTimeRange(); + await lens.dragFieldToWorkspace('@timestamp', 'xyVisChart'); - await PageObjects.lens.createLayer('annotations'); + await lens.createLayer('annotations'); expect((await find.allByCssSelector(`[data-test-subj^="lns-layerPanel-"]`)).length).to.eql(2); expect( @@ -62,7 +59,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ).to.eql('Event'); await testSubjects.click('lnsXY_xAnnotationsPanel > lns-dimensionTrigger'); await testSubjects.click('lnsXY_textVisibility_name'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); await testSubjects.existOrFail('xyVisAnnotationIcon'); await testSubjects.existOrFail('xyVisAnnotationText'); @@ -70,7 +67,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should duplicate the style when duplicating an annotation and group them in the chart', async () => { // drag and drop to the empty field to generate a duplicate - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lnsXY_xAnnotationsPanel > lns-dimensionTrigger', to: 'lnsXY_xAnnotationsPanel > lns-empty-dimension', }); @@ -85,13 +82,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '[data-test-subj="lnsXY_textVisibility_name"][class*="euiButtonGroupButton-isSelected"]' ) ).to.be(true); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); await testSubjects.existOrFail('xyVisGroupedAnnotationIcon'); }); it('should add query annotation layer and allow edition', async () => { - await PageObjects.lens.removeLayer(1); - await PageObjects.lens.createLayer('annotations'); + await lens.removeLayer(1); + await lens.createLayer('annotations'); expect((await find.allByCssSelector(`[data-test-subj^="lns-layerPanel-"]`)).length).to.eql(2); expect( @@ -101,13 +98,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ).to.eql('Event'); await testSubjects.click('lnsXY_xAnnotationsPanel > lns-dimensionTrigger'); await testSubjects.click('lnsXY_annotation_query'); - await PageObjects.lens.configureQueryAnnotation({ + await lens.configureQueryAnnotation({ queryString: '*', timeField: 'utc_time', textDecoration: { type: 'name' }, extraFields: ['clientip'], }); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); await testSubjects.existOrFail('xyVisGroupedAnnotationIcon'); }); @@ -118,24 +115,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const SECOND_VIS_TITLE = 'second visualization'; it('should save annotation group to library', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.dragFieldToWorkspace('@timestamp', 'xyVisChart'); + await lens.goToTimeRange(); + await lens.dragFieldToWorkspace('@timestamp', 'xyVisChart'); - await PageObjects.lens.createLayer('annotations'); + await lens.createLayer('annotations'); - await PageObjects.lens.performLayerAction('lnsXY_annotationLayer_saveToLibrary', 1); + await lens.performLayerAction('lnsXY_annotationLayer_saveToLibrary', 1); - await PageObjects.visualize.setSaveModalValues(ANNOTATION_GROUP_TITLE, { + await visualize.setSaveModalValues(ANNOTATION_GROUP_TITLE, { description: 'my description', }); await testSubjects.click('savedObjectTagSelector'); await testSubjects.click(`tagSelectorOption-action__create`); - const { tagModal } = PageObjects.tagManagement; + const { tagModal } = tagManagement; expect(await tagModal.isOpened()).to.be(true); @@ -161,38 +158,38 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { `Saved "${ANNOTATION_GROUP_TITLE}"\nView or manage in the annotation library.` ); - await PageObjects.lens.save(FIRST_VIS_TITLE); + await lens.save(FIRST_VIS_TITLE); // TODO test that saved object info gets populated on subsequent save }); it('should add annotation group from library', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.dragFieldToWorkspace('@timestamp', 'xyVisChart'); + await lens.goToTimeRange(); + await lens.dragFieldToWorkspace('@timestamp', 'xyVisChart'); - await PageObjects.lens.createLayer('annotations', ANNOTATION_GROUP_TITLE); + await lens.createLayer('annotations', ANNOTATION_GROUP_TITLE); await retry.try(async () => { - expect(await PageObjects.lens.getLayerCount()).to.be(2); + expect(await lens.getLayerCount()).to.be(2); }); - await PageObjects.lens.save(SECOND_VIS_TITLE); + await lens.save(SECOND_VIS_TITLE); }); it('should remove layer for deleted annotation group', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); - await PageObjects.visualize.selectAnnotationsTab(); + await visualize.gotoVisualizationLandingPage(); + await visualize.selectAnnotationsTab(); await listingTable.deleteItem(ANNOTATION_GROUP_TITLE); - await PageObjects.visualize.selectVisualizationsTab(); - await PageObjects.visualize.loadSavedVisualization(FIRST_VIS_TITLE, { + await visualize.selectVisualizationsTab(); + await visualize.loadSavedVisualization(FIRST_VIS_TITLE, { navigateToVisualize: false, }); await retry.try(async () => { - expect(await PageObjects.lens.getLayerCount()).to.be(1); + expect(await lens.getLayerCount()).to.be(1); }); }); diff --git a/x-pack/test/functional/apps/lens/group6/disable_auto_apply.ts b/x-pack/test/functional/apps/lens/group6/disable_auto_apply.ts index c70c0f60b02d3..8cccfd759450d 100644 --- a/x-pack/test/functional/apps/lens/group6/disable_auto_apply.ts +++ b/x-pack/test/functional/apps/lens/group6/disable_auto_apply.ts @@ -9,63 +9,63 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['lens', 'visualize']); + const { lens, visualize } = getPageObjects(['lens', 'visualize']); const browser = getService('browser'); const testSubjects = getService('testSubjects'); const retry = getService('retry'); describe('lens disable auto-apply tests', () => { it('should persist auto-apply setting across page refresh', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); - expect(await PageObjects.lens.getAutoApplyEnabled()).to.be.ok(); + expect(await lens.getAutoApplyEnabled()).to.be.ok(); - await PageObjects.lens.disableAutoApply(); + await lens.disableAutoApply(); - expect(await PageObjects.lens.getAutoApplyEnabled()).not.to.be.ok(); + expect(await lens.getAutoApplyEnabled()).not.to.be.ok(); await browser.refresh(); - await PageObjects.lens.waitForEmptyWorkspace(); + await lens.waitForEmptyWorkspace(); - expect(await PageObjects.lens.getAutoApplyEnabled()).not.to.be.ok(); + expect(await lens.getAutoApplyEnabled()).not.to.be.ok(); - await PageObjects.lens.enableAutoApply(); + await lens.enableAutoApply(); - expect(await PageObjects.lens.getAutoApplyEnabled()).to.be.ok(); + expect(await lens.getAutoApplyEnabled()).to.be.ok(); await browser.refresh(); - await PageObjects.lens.waitForEmptyWorkspace(); + await lens.waitForEmptyWorkspace(); - expect(await PageObjects.lens.getAutoApplyEnabled()).to.be.ok(); + expect(await lens.getAutoApplyEnabled()).to.be.ok(); - await PageObjects.lens.disableAutoApply(); + await lens.disableAutoApply(); - expect(await PageObjects.lens.getAutoApplyEnabled()).not.to.be.ok(); + expect(await lens.getAutoApplyEnabled()).not.to.be.ok(); - await PageObjects.lens.closeSettingsMenu(); + await lens.closeSettingsMenu(); }); it('should preserve apply-changes button with full-screen datasource', async () => { - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); - await PageObjects.lens.disableAutoApply(); - await PageObjects.lens.closeSettingsMenu(); + await lens.disableAutoApply(); + await lens.closeSettingsMenu(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'formula', formula: `count()`, keepOpen: true, }); - await PageObjects.lens.toggleFullscreen(); + await lens.toggleFullscreen(); - expect(await PageObjects.lens.applyChangesExists('toolbar')).to.be.ok(); + expect(await lens.applyChangesExists('toolbar')).to.be.ok(); - await PageObjects.lens.toggleFullscreen(); + await lens.toggleFullscreen(); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should apply changes when "Apply" is clicked', async () => { @@ -77,28 +77,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); // configureDimension - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); // assert that changes haven't been applied - await PageObjects.lens.waitForWorkspaceWithApplyChangesPrompt(); + await lens.waitForWorkspaceWithApplyChangesPrompt(); - await PageObjects.lens.applyChanges('workspace'); + await lens.applyChanges('workspace'); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); }); it('should hide suggestions when a change is made', async () => { - await PageObjects.lens.switchToVisualization('lnsDatatable'); + await lens.switchToVisualization('lnsDatatable'); - expect(await PageObjects.lens.applyChangesExists('suggestions')).to.be.ok(); + expect(await lens.applyChangesExists('suggestions')).to.be.ok(); - await PageObjects.lens.applyChanges('suggestions'); + await lens.applyChanges('suggestions'); - expect(await PageObjects.lens.applyChangesExists('suggestions')).not.to.be.ok(); + expect(await lens.applyChangesExists('suggestions')).not.to.be.ok(); }); }); } diff --git a/x-pack/test/functional/apps/lens/group6/error_handling.ts b/x-pack/test/functional/apps/lens/group6/error_handling.ts index 8bc7432601bd1..1b035fab63979 100644 --- a/x-pack/test/functional/apps/lens/group6/error_handling.ts +++ b/x-pack/test/functional/apps/lens/group6/error_handling.ts @@ -10,14 +10,11 @@ import { intersection, uniq } from 'lodash'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { visualize, lens, dashboard, timePicker } = getPageObjects([ 'visualize', 'lens', 'dashboard', - 'header', 'timePicker', - 'common', - 'navigationalSearch', ]); const security = getService('security'); const listingTable = getService('listingTable'); @@ -49,36 +46,36 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('the warning is shown and user can fix the state', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsMetricWithNonExistingDataView'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsMetricWithNonExistingDataView'); - await PageObjects.lens.waitForMissingDataViewWarning(); - await PageObjects.lens.switchToVisualization('lnsDatatable'); - await PageObjects.lens.waitForMissingDataViewWarning(); - await PageObjects.lens.switchToVisualization('pie'); - await PageObjects.lens.waitForMissingDataViewWarning(); - await PageObjects.lens.switchToVisualization('line'); - await PageObjects.lens.waitForMissingDataViewWarning(); - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); - await PageObjects.lens.closeDimensionEditor(); - await PageObjects.lens.dragDimensionToDimension({ + await lens.clickVisualizeListItemTitle('lnsMetricWithNonExistingDataView'); + await lens.waitForMissingDataViewWarning(); + await lens.switchToVisualization('lnsDatatable'); + await lens.waitForMissingDataViewWarning(); + await lens.switchToVisualization('pie'); + await lens.waitForMissingDataViewWarning(); + await lens.switchToVisualization('line'); + await lens.waitForMissingDataViewWarning(); + await lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); + await lens.closeDimensionEditor(); + await lens.dragDimensionToDimension({ from: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', to: 'lnsXY_yDimensionPanel > lns-empty-dimension', }); - await PageObjects.lens.switchFirstLayerIndexPattern('log*'); - await PageObjects.lens.waitForMissingDataViewWarningDisappear(); - await PageObjects.lens.waitForEmptyWorkspace(); + await lens.switchFirstLayerIndexPattern('log*'); + await lens.waitForMissingDataViewWarningDisappear(); + await lens.waitForEmptyWorkspace(); }); it('works fine when the dataViews is missing for referenceLines and annotations', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName( 'lnsXYWithReferenceLinesAndAnnotationsWithNonExistingDataView' ); - await PageObjects.lens.clickVisualizeListItemTitle( + await lens.clickVisualizeListItemTitle( 'lnsXYWithReferenceLinesAndAnnotationsWithNonExistingDataView' ); - await PageObjects.lens.waitForMissingDataViewWarning(); + await lens.waitForMissingDataViewWarning(); }); }); @@ -87,10 +84,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'x-pack/test/functional/fixtures/kbn_archiver/lens/missing_fields' ); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard( - 'dashboard containing vis with missing fields' - ); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('dashboard containing vis with missing fields'); const expectedMessages = [ 'Field @timestamp was not found.', @@ -102,7 +97,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'Field kubernetes.container.name was not found.', ]; - const dashboardMessageList = await PageObjects.lens.getMessageListTexts('error'); + const dashboardMessageList = await lens.getMessageListTexts('error'); // make sure all the expected messages are there expect(intersection(expectedMessages, dashboardMessageList).length).to.be( @@ -112,12 +107,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // make sure the visualization is rendering await testSubjects.find('emptyPlaceholder'); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await dashboardPanelActions.clickEdit(); - await PageObjects.timePicker.waitForNoDataPopover(); - await PageObjects.timePicker.ensureHiddenNoDataPopover(); + await timePicker.waitForNoDataPopover(); + await timePicker.ensureHiddenNoDataPopover(); - const editorMessageList = await PageObjects.lens.getMessageListTexts('error'); + const editorMessageList = await lens.getMessageListTexts('error'); expect(intersection(expectedMessages, editorMessageList).length).to.be( uniq(expectedMessages).length @@ -135,8 +130,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'x-pack/test/functional/fixtures/kbn_archiver/lens/fundamental_config_errors_on_dashboard' ); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('lens fundamental config errors dash'); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('lens fundamental config errors dash'); const failureElements = await testSubjects.findAll('errorMessageMarkdown'); const errorMessages = await Promise.all(failureElements.map((el) => el.getVisibleText())); diff --git a/x-pack/test/functional/apps/lens/group6/index.ts b/x-pack/test/functional/apps/lens/group6/index.ts index 470aeb89b66f0..1cad50f778ef4 100644 --- a/x-pack/test/functional/apps/lens/group6/index.ts +++ b/x-pack/test/functional/apps/lens/group6/index.ts @@ -13,7 +13,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['timePicker']); + const { timePicker } = getPageObjects(['timePicker']); const config = getService('config'); let remoteEsArchiver; @@ -58,7 +58,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext await esNode.load(esArchive); // changing the timepicker default here saves us from having to set it in Discover (~8s) - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: indexPatternString, 'dateFormat:tz': 'UTC', @@ -69,7 +69,7 @@ export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext after(async () => { await esArchiver.unload(esArchive); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.importExport.unload(fixtureDirs.lensBasic); await kibanaServer.importExport.unload(fixtureDirs.lensDefault); await kibanaServer.savedObjects.cleanStandardList(); diff --git a/x-pack/test/functional/apps/lens/group6/inspector.ts b/x-pack/test/functional/apps/lens/group6/inspector.ts index 9f52d783011c4..56d8fd3cdd7b1 100644 --- a/x-pack/test/functional/apps/lens/group6/inspector.ts +++ b/x-pack/test/functional/apps/lens/group6/inspector.ts @@ -8,31 +8,31 @@ import expect from '@kbn/expect'; import type { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const elasticChart = getService('elasticChart'); const inspector = getService('inspector'); const testSubjects = getService('testSubjects'); describe('lens inspector', () => { before(async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'clientip', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'max', field: 'bytes', }); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.waitForVisualization('xyVisChart'); await inspector.open('lnsApp_inspectButton'); }); @@ -58,7 +58,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should close the inspector when navigating away from Lens', async () => { - await PageObjects.visualize.navigateToNewVisualization(); + await visualize.navigateToNewVisualization(); expect(await testSubjects.exists('inspectorPanel')).to.be(false); }); }); diff --git a/x-pack/test/functional/apps/lens/group6/legacy_metric.ts b/x-pack/test/functional/apps/lens/group6/legacy_metric.ts index 379ab15fecb29..9b404e7f8e531 100644 --- a/x-pack/test/functional/apps/lens/group6/legacy_metric.ts +++ b/x-pack/test/functional/apps/lens/group6/legacy_metric.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens, header } = getPageObjects(['visualize', 'lens', 'header']); const listingTable = getService('listingTable'); const retry = getService('retry'); const filterBar = getService('filterBar'); @@ -17,18 +17,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens legacy metric', () => { it('should render a numeric metric', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('Artistpreviouslyknownaslens'); - await PageObjects.lens.clickVisualizeListItemTitle('Artistpreviouslyknownaslens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.assertLegacyMetric('Maximum of bytes', '19,986'); + await lens.clickVisualizeListItemTitle('Artistpreviouslyknownaslens'); + await lens.goToTimeRange(); + await lens.assertLegacyMetric('Maximum of bytes', '19,986'); }); it('should allow to filter metric', async () => { let filterCount = 0; await retry.try(async function tryingForTime() { // click first metric bucket - await PageObjects.lens.clickLegacyMetric(); + await lens.clickLegacyMetric(); filterCount = await filterBar.getFilterCount(); await filterBar.removeAllFilters(); expect(filterCount).to.equal(1); @@ -36,36 +36,36 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should color the metric text based on value', async () => { - await PageObjects.lens.openDimensionEditor('lns-dimensionTrigger'); - await PageObjects.lens.setLegacyMetricDynamicColoring('labels'); - await PageObjects.header.waitUntilLoadingHasFinished(); - const styleObj = await PageObjects.lens.getLegacyMetricStyle(); + await lens.openDimensionEditor('lns-dimensionTrigger'); + await lens.setLegacyMetricDynamicColoring('labels'); + await header.waitUntilLoadingHasFinished(); + const styleObj = await lens.getLegacyMetricStyle(); expect(styleObj['background-color']).to.be(undefined); expect(styleObj.color).to.be('rgb(214, 191, 87)'); }); it('should change the color of the metric when tweaking the values in the panel', async () => { - await PageObjects.lens.openPalettePanel(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await lens.openPalettePanel(); + await header.waitUntilLoadingHasFinished(); await testSubjects.setValue('lnsPalettePanel_dynamicColoring_range_value_1', '21000', { clearWithKeyboard: true, }); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); - const styleObj = await PageObjects.lens.getLegacyMetricStyle(); + await lens.waitForVisualization('legacyMtrVis'); + const styleObj = await lens.getLegacyMetricStyle(); expect(styleObj.color).to.be('rgb(32, 146, 128)'); }); it('should change the color when reverting the palette', async () => { await testSubjects.click('lnsPalettePanel_dynamicColoring_reverseColors'); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); - const styleObj = await PageObjects.lens.getLegacyMetricStyle(); + await lens.waitForVisualization('legacyMtrVis'); + const styleObj = await lens.getLegacyMetricStyle(); expect(styleObj.color).to.be('rgb(204, 86, 66)'); }); it('should reset the color stops when changing palette to a predefined one', async () => { - await PageObjects.lens.changePaletteTo('temperature'); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); - const styleObj = await PageObjects.lens.getLegacyMetricStyle(); + await lens.changePaletteTo('temperature'); + await lens.waitForVisualization('legacyMtrVis'); + const styleObj = await lens.getLegacyMetricStyle(); expect(styleObj.color).to.be('rgb(235, 239, 245)'); }); }); diff --git a/x-pack/test/functional/apps/lens/group6/legend_statistics.ts b/x-pack/test/functional/apps/lens/group6/legend_statistics.ts index a6e8cf8a86510..d810a622f2199 100644 --- a/x-pack/test/functional/apps/lens/group6/legend_statistics.ts +++ b/x-pack/test/functional/apps/lens/group6/legend_statistics.ts @@ -9,15 +9,15 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const find = getService('find'); const listingTable = getService('listingTable'); const kibanaServer = getService('kibanaServer'); async function loadSavedLens(title: string) { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName(title); - await PageObjects.lens.clickVisualizeListItemTitle(title); + await lens.clickVisualizeListItemTitle(title); } async function expectLegendOneItem(name: string, value?: string) { @@ -47,15 +47,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'timepicker:timeDefaults': '{ "from": "2015-09-18T19:37:13.000Z", "to": "2015-09-22T23:30:30.000Z"}', }); - await PageObjects.visualize.gotoVisualizationLandingPage({ forceRefresh: true }); + await visualize.gotoVisualizationLandingPage({ forceRefresh: true }); }); describe('xy chart legend statistics', () => { it('shows table with legend statistics', async () => { await loadSavedLens('lnsXYvis'); - await PageObjects.lens.toggleToolbarPopover('lnsLegendButton'); - await PageObjects.lens.selectOptionFromComboBox('lnsLegendStatisticsSelect', [ + await lens.toggleToolbarPopover('lnsLegendButton'); + await lens.selectOptionFromComboBox('lnsLegendStatisticsSelect', [ 'average', 'minimum', 'maximum', @@ -89,7 +89,7 @@ Max const title = 'xyValuesInLegendTrue'; await loadSavedLens(title); await expectLegendOneItem('Count of records', '2'); - await PageObjects.lens.save(title); + await lens.save(title); await loadSavedLens(title); await expectLegendOneItem('Count of records', '2'); }); diff --git a/x-pack/test/functional/apps/lens/group6/lens_reporting.ts b/x-pack/test/functional/apps/lens/group6/lens_reporting.ts index 5b9063cf6cf54..4b2a182df741a 100644 --- a/x-pack/test/functional/apps/lens/group6/lens_reporting.ts +++ b/x-pack/test/functional/apps/lens/group6/lens_reporting.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects([ + const { common, dashboard, lens, reporting, timePicker, visualize } = getPageObjects([ 'common', 'dashboard', 'lens', @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'x-pack/test/functional/fixtures/kbn_archiver/lens/reporting' ); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await security.testUser.setRoles( [ 'test_logstash_reader', @@ -43,7 +43,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await es.deleteByQuery({ index: '.reporting-*', refresh: true, @@ -54,66 +54,66 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { afterEach(async () => { if (await testSubjects.exists('shareContextModal')) { - await PageObjects.lens.closeShareModal(); + await lens.closeShareModal(); } }); it('should not cause PDF reports to fail', async () => { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await listingTable.clickItemLink('dashboard', 'Lens reportz'); - await PageObjects.reporting.openExportTab(); - await PageObjects.reporting.clickGenerateReportButton(); - await PageObjects.lens.closeShareModal(); - const url = await PageObjects.reporting.getReportURL(60000); + await reporting.openExportTab(); + await reporting.clickGenerateReportButton(); + await lens.closeShareModal(); + const url = await reporting.getReportURL(60000); expect(url).to.be.ok(); if (await testSubjects.exists('toastCloseButton')) { await testSubjects.click('toastCloseButton'); } - await PageObjects.lens.closeShareModal(); + await lens.closeShareModal(); }); for (const type of ['PNG', 'PDF'] as const) { describe(`${type} report`, () => { it(`should not allow to download reports for incomplete visualization`, async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.gotoVisualizationLandingPage(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); // now remove a dimension to make it incomplete - await PageObjects.lens.removeDimension('lnsXY_yDimensionPanel'); + await lens.removeDimension('lnsXY_yDimensionPanel'); // open the share menu and check that reporting is disabled - await PageObjects.lens.clickShareModal(); + await lens.clickShareModal(); expect(await testSubjects.exists('export')).to.be(false); - await PageObjects.lens.closeShareModal(); + await lens.closeShareModal(); }); it(`should be able to download report of the current visualization`, async () => { // make the configuration complete - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.openReportingShare(type); - await PageObjects.reporting.clickGenerateReportButton(); + await lens.openReportingShare(type); + await reporting.clickGenerateReportButton(); - const url = await PageObjects.reporting.getReportURL(60000); + const url = await reporting.getReportURL(60000); - await PageObjects.lens.closeShareModal(); + await lens.closeShareModal(); expect(url).to.be.ok(); if (await testSubjects.exists('toastCloseButton')) { @@ -122,25 +122,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it(`should enable curl reporting if the visualization is saved`, async () => { - await PageObjects.lens.save(`ASavedVisualizationToShareIn${type}`); + await lens.save(`ASavedVisualizationToShareIn${type}`); - await PageObjects.lens.openReportingShare(type); + await lens.openReportingShare(type); await testSubjects.existOrFail('shareReportingCopyURL'); expect(await testSubjects.getVisibleText('shareReportingCopyURL')).to.eql( 'Copy Post URL' ); - await PageObjects.lens.closeShareModal(); + await lens.closeShareModal(); }); it(`should produce a valid URL for reporting`, async () => { - await PageObjects.lens.openReportingShare(type); - await PageObjects.reporting.clickGenerateReportButton(); - await PageObjects.reporting.getReportURL(60000); + await lens.openReportingShare(type); + await reporting.clickGenerateReportButton(); + await reporting.getReportURL(60000); if (await testSubjects.exists('toastCloseButton')) { await testSubjects.click('toastCloseButton'); } // navigate to the reporting page - await PageObjects.common.navigateToUrl('management', '/insightsAndAlerting'); + await common.navigateToUrl('management', '/insightsAndAlerting'); await testSubjects.click('reporting'); // find the latest Lens report await testSubjects.click('reportJobRow > euiCollapsedItemActionsButton'); @@ -150,7 +150,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const [reportingWindowHandler, lensWindowHandle] = await browser.getAllWindowHandles(); await browser.switchToWindow(lensWindowHandle); // verify some configuration - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( 'Average of bytes' ); await browser.closeCurrentWindow(); diff --git a/x-pack/test/functional/apps/lens/group6/lens_tagging.ts b/x-pack/test/functional/apps/lens/group6/lens_tagging.ts index 1734858f83bc7..7c3c14150d2b2 100644 --- a/x-pack/test/functional/apps/lens/group6/lens_tagging.ts +++ b/x-pack/test/functional/apps/lens/group6/lens_tagging.ts @@ -16,8 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const find = getService('find'); const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardPanelActions = getService('dashboardPanelActions'); - const PageObjects = getPageObjects([ - 'common', + const { tagManagement, header, dashboard, visualize, lens, timePicker } = getPageObjects([ 'tagManagement', 'header', 'dashboard', @@ -32,50 +31,50 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens tagging', () => { before(async () => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.clickNewDashboard(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.clickNewDashboard(); }); after(async () => { - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); it('adds a new tag to a Lens visualization', async () => { // create lens await dashboardAddPanel.clickCreateNewLink(); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.goToTimeRange(); + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('lnsApp_saveButton'); - await PageObjects.visualize.setSaveModalValues(lensTitle, { + await visualize.setSaveModalValues(lensTitle, { saveAsNew: false, redirectToOrigin: true, }); await testSubjects.click('savedObjectTagSelector'); await testSubjects.click(`tagSelectorOption-action__create`); - expect(await PageObjects.tagManagement.tagModal.isOpened()).to.be(true); + expect(await tagManagement.tagModal.isOpened()).to.be(true); - await PageObjects.tagManagement.tagModal.fillForm( + await tagManagement.tagModal.fillForm( { name: lensTag, color: '#FFCC33', @@ -87,7 +86,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } ); - expect(await PageObjects.tagManagement.tagModal.isOpened()).to.be(false); + expect(await tagManagement.tagModal.isOpened()).to.be(false); await testSubjects.click('confirmSaveSavedObjectButton'); await retry.waitForWithTimeout('Save modal to disappear', 1000, () => testSubjects @@ -100,10 +99,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('retains its saved object tags after save and return', async () => { await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.lens.saveAndReturn(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await lens.saveAndReturn(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.waitUntilTableIsLoaded(); // open the filter dropdown @@ -111,9 +110,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '.euiFilterGroup .euiPopover:nth-child(2) .euiFilterButton' ); await filterButton.click(); - await testSubjects.click( - `tag-searchbar-option-${PageObjects.tagManagement.testSubjFriendly(lensTag)}` - ); + await testSubjects.click(`tag-searchbar-option-${tagManagement.testSubjFriendly(lensTag)}`); // click elsewhere to close the filter dropdown const searchFilter = await find.byCssSelector('.euiPageTemplate .euiFieldSearch'); await searchFilter.click(); diff --git a/x-pack/test/functional/apps/lens/group6/metric.ts b/x-pack/test/functional/apps/lens/group6/metric.ts index 108f9edcba044..7415dd80d5999 100644 --- a/x-pack/test/functional/apps/lens/group6/metric.ts +++ b/x-pack/test/functional/apps/lens/group6/metric.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens, common } = getPageObjects(['visualize', 'lens', 'common']); const testSubjects = getService('testSubjects'); const filterBar = getService('filterBar'); const retry = getService('retry'); @@ -62,9 +62,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]; const clickMetric = async (title: string) => { - const tiles = await PageObjects.lens.getMetricTiles(); + const tiles = await lens.getMetricTiles(); for (const tile of tiles) { - const datum = await PageObjects.lens.getMetricDatum(tile); + const datum = await lens.getMetricDatum(tile); if (datum.title === title) { await tile.click(); return; @@ -74,34 +74,34 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('lens metric', () => { it('should render a metric', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsMetric', 'Metric'); + await lens.switchToVisualization('lnsMetric', 'Metric'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsMetric_primaryMetricDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsMetric_secondaryMetricDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - expect((await PageObjects.lens.getMetricVisualizationData()).length).to.be.equal(1); + expect((await lens.getMetricVisualizationData()).length).to.be.equal(1); }); it('should enable trendlines', async () => { // trendline data without the breakdown - await PageObjects.lens.openDimensionEditor( + await lens.openDimensionEditor( 'lnsMetric_primaryMetricDimensionPanel > lns-dimensionTrigger' ); await testSubjects.click('lnsMetric_supporting_visualization_trendline'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); await inspector.open('lnsApp_inspectButton'); @@ -112,14 +112,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should enable metric with breakdown', async () => { // trendline data without the breakdown - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsMetric_breakdownByDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.lens.waitForVisualization('mtrVis'); - const data = await PageObjects.lens.getMetricVisualizationData(); + await lens.waitForVisualization('mtrVis'); + const data = await lens.getMetricVisualizationData(); const expectedData = [ { @@ -185,44 +185,40 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ]; expect(data).to.eql(expectedData); - await PageObjects.lens.openDimensionEditor( + await lens.openDimensionEditor( 'lnsMetric_primaryMetricDimensionPanel > lns-dimensionTrigger' ); await testSubjects.click('lnsMetric_supporting_visualization_none'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.waitForVisualization('mtrVis'); }); it('should enable bar with max dimension', async () => { - await PageObjects.lens.openDimensionEditor( - 'lnsMetric_maxDimensionPanel > lns-empty-dimension' - ); + await lens.openDimensionEditor('lnsMetric_maxDimensionPanel > lns-empty-dimension'); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.waitForVisualization('mtrVis'); - expect((await PageObjects.lens.getMetricVisualizationData())[0].showingBar).to.be(true); + expect((await lens.getMetricVisualizationData())[0].showingBar).to.be(true); - await PageObjects.lens.closeDimensionEditor(); - await PageObjects.lens.removeDimension('lnsMetric_maxDimensionPanel'); + await lens.closeDimensionEditor(); + await lens.removeDimension('lnsMetric_maxDimensionPanel'); }); it('should enable trendlines with breakdown', async () => { - await PageObjects.lens.openDimensionEditor( + await lens.openDimensionEditor( 'lnsMetric_primaryMetricDimensionPanel > lns-dimensionTrigger' ); await testSubjects.click('lnsMetric_supporting_visualization_trendline'); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.waitForVisualization('mtrVis'); expect( - (await PageObjects.lens.getMetricVisualizationData()).some( - (datum) => datum.showingTrendline - ) + (await lens.getMetricVisualizationData()).some((datum) => datum.showingTrendline) ).to.be(true); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); await inspector.open('lnsApp_inspectButton'); @@ -230,21 +226,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(trendLineData).to.eql(inspectorExpectedTrenlineDataWithBreakdown); await inspector.close(); - await PageObjects.lens.openDimensionEditor( + await lens.openDimensionEditor( 'lnsMetric_primaryMetricDimensionPanel > lns-dimensionTrigger' ); await testSubjects.click('lnsMetric_supporting_visualization_none'); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.waitForVisualization('mtrVis'); expect( - (await PageObjects.lens.getMetricVisualizationData()).some( - (datum) => datum.showingTrendline - ) + (await lens.getMetricVisualizationData()).some((datum) => datum.showingTrendline) ).to.be(false); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should filter by click', async () => { @@ -259,11 +253,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await filterBar.removeAllFilters(); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.waitForVisualization('mtrVis'); }); it('applies static color', async () => { - await PageObjects.lens.openDimensionEditor( + await lens.openDimensionEditor( 'lnsMetric_primaryMetricDimensionPanel > lns-dimensionTrigger' ); @@ -272,9 +266,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await colorPicker.clearValue(); await colorPicker.type('#000000'); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.waitForVisualization('mtrVis'); - const data = await PageObjects.lens.getMetricVisualizationData(); + const data = await lens.getMetricVisualizationData(); expect(data.map(({ color }) => color)).to.be.eql(new Array(6).fill('rgba(0, 0, 0, 1)')); }); @@ -291,35 +285,35 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('applies dynamic color', async () => { await testSubjects.click('lnsMetric_color_mode_dynamic'); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.waitForVisualization('mtrVis'); - const data = await PageObjects.lens.getMetricVisualizationData(); + const data = await lens.getMetricVisualizationData(); expect(data.map(({ color }) => color)).to.eql(expectedDynamicColors); }); it('converts color stops to number', async () => { - await PageObjects.lens.openPalettePanel(); - await PageObjects.common.sleep(1000); + await lens.openPalettePanel(); + await common.sleep(1000); await testSubjects.click('lnsPalettePanel_dynamicColoring_rangeType_groups_number'); expect([ await testSubjects.getAttribute('lnsPalettePanel_dynamicColoring_range_value_1', 'value'), await testSubjects.getAttribute('lnsPalettePanel_dynamicColoring_range_value_2', 'value'), ]).to.be.eql(['10400.18', '15077.59']); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.waitForVisualization('mtrVis'); - expect( - (await PageObjects.lens.getMetricVisualizationData()).map(({ color }) => color) - ).to.eql(expectedDynamicColors); // colors shouldn't change + expect((await lens.getMetricVisualizationData()).map(({ color }) => color)).to.eql( + expectedDynamicColors + ); // colors shouldn't change - await PageObjects.lens.closePaletteEditor(); - await PageObjects.lens.closeDimensionEditor(); + await lens.closePaletteEditor(); + await lens.closeDimensionEditor(); }); it('makes visualization scrollable if too tall', async () => { - await PageObjects.lens.removeDimension('lnsMetric_breakdownByDimensionPanel'); + await lens.removeDimension('lnsMetric_breakdownByDimensionPanel'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsMetric_breakdownByDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', @@ -328,11 +322,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.setValue('lnsMetric_max_cols', '1'); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.waitForVisualization('mtrVis'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - const tiles = await await PageObjects.lens.getMetricTiles(); + const tiles = await await lens.getMetricTiles(); const lastTile = tiles[tiles.length - 1]; const initialPosition = await lastTile.getPosition(); @@ -342,35 +336,35 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it("doesn't error with empty formula", async () => { - await PageObjects.lens.openDimensionEditor( + await lens.openDimensionEditor( 'lnsMetric_primaryMetricDimensionPanel > lns-dimensionTrigger' ); - await PageObjects.lens.switchToFormula(); - await PageObjects.lens.typeFormula(''); + await lens.switchToFormula(); + await lens.typeFormula(''); - await PageObjects.lens.waitForVisualization('mtrVis'); + await lens.waitForVisualization('mtrVis'); }); it('does carry custom formatting when transitioning from other visualization', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); - // await PageObjects.lens.clickLegacyMetric(); - await PageObjects.lens.configureDimension({ + await lens.switchToVisualization('lnsLegacyMetric'); + // await lens.clickLegacyMetric(); + await lens.configureDimension({ dimension: 'lns-empty-dimension', operation: 'average', field: 'bytes', keepOpen: true, }); - await PageObjects.lens.editDimensionFormat('Number', { decimals: 3, prefix: ' blah' }); - await PageObjects.lens.closeDimensionEditor(); + await lens.editDimensionFormat('Number', { decimals: 3, prefix: ' blah' }); + await lens.closeDimensionEditor(); - await PageObjects.lens.switchToVisualization('lnsMetric', 'Metric'); - await PageObjects.lens.waitForVisualization('mtrVis'); - const [{ value }] = await PageObjects.lens.getMetricVisualizationData(); + await lens.switchToVisualization('lnsMetric', 'Metric'); + await lens.waitForVisualization('mtrVis'); + const [{ value }] = await lens.getMetricVisualizationData(); expect(value).contain('blah'); // Extract the numeric decimals from the value without any compact suffix like k or m diff --git a/x-pack/test/functional/apps/lens/group6/no_data.ts b/x-pack/test/functional/apps/lens/group6/no_data.ts index 04d7967985da3..acedf9903db71 100644 --- a/x-pack/test/functional/apps/lens/group6/no_data.ts +++ b/x-pack/test/functional/apps/lens/group6/no_data.ts @@ -13,7 +13,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const es = getService('es'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'lens', 'header', 'timePicker']); + const { common, header } = getPageObjects(['common', 'header']); describe('lens no data', () => { before(async function () { @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const indices = Object.keys(await es.indices.get({ index: '*' })); await Promise.all(indices.map(async (index) => await es.indices.delete({ index }))); await kibanaServer.savedObjects.clean({ types: ['index-pattern'] }); - await PageObjects.common.navigateToApp('lens'); + await common.navigateToApp('lens'); }); after(async () => { @@ -30,17 +30,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('when no data opens integrations', async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const addIntegrations = await testSubjects.find('kbnOverviewAddIntegrations'); await addIntegrations.click(); - await PageObjects.common.waitUntilUrlIncludes('integrations/browse'); + await common.waitUntilUrlIncludes('integrations/browse'); }); it('adds a new data view when no data views', async () => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.savedObjects.clean({ types: ['index-pattern'] }); - await PageObjects.common.navigateToApp('lens'); + await common.navigateToApp('lens'); const dataViewToCreate = 'logstash'; await dataViews.createFromPrompt({ name: dataViewToCreate }); diff --git a/x-pack/test/functional/apps/lens/group6/reference_lines.ts b/x-pack/test/functional/apps/lens/group6/reference_lines.ts index cee3ad357614e..245162b5e4742 100644 --- a/x-pack/test/functional/apps/lens/group6/reference_lines.ts +++ b/x-pack/test/functional/apps/lens/group6/reference_lines.ts @@ -9,15 +9,15 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const find = getService('find'); const retry = getService('retry'); const testSubjects = getService('testSubjects'); describe('lens reference lines tests', () => { it('should show a disabled reference layer button if no data dimension is defined', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await testSubjects.click('lnsLayerAddButton'); await retry.waitFor('wait for layer popup to appear', async () => @@ -29,21 +29,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should add a reference layer with a static value in it', async () => { - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.createLayer('referenceLine'); + await lens.createLayer('referenceLine'); expect((await find.allByCssSelector(`[data-test-subj^="lns-layerPanel-"]`)).length).to.eql(2); expect( @@ -54,27 +54,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should create a dynamic referenceLine when dragging a field to a referenceLine dimension group', async () => { - await PageObjects.lens.dragFieldToDimensionTrigger( + await lens.dragFieldToDimensionTrigger( 'bytes', 'lnsXY_yReferenceLineLeftPanel > lns-empty-dimension' ); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsXY_yReferenceLineLeftPanel') - ).to.eql(['Static value: 4992.44', 'Median of bytes']); + expect(await lens.getDimensionTriggersTexts('lnsXY_yReferenceLineLeftPanel')).to.eql([ + 'Static value: 4992.44', + 'Median of bytes', + ]); }); it('should add a new group to the reference layer when a right axis is enabled', async () => { - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', keepOpen: true, }); - await PageObjects.lens.changeAxisSide('right'); + await lens.changeAxisSide('right'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); await testSubjects.existOrFail('lnsXY_yReferenceLineRightPanel > lns-empty-dimension'); }); @@ -83,10 +84,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // style it enabling the fill await testSubjects.click('lnsXY_yReferenceLineLeftPanel > lns-dimensionTrigger'); await testSubjects.click('lnsXY_fill_below'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); // drag and drop it to the left axis - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lnsXY_yReferenceLineLeftPanel > lns-dimensionTrigger', to: 'lnsXY_yReferenceLineRightPanel > lns-empty-dimension', }); @@ -98,12 +99,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ) ).to.be(true); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should duplicate also the original style when duplicating a reference line', async () => { // drag and drop to the empty field to generate a duplicate - await PageObjects.lens.dragDimensionToDimension({ + await lens.dragDimensionToDimension({ from: 'lnsXY_yReferenceLineRightPanel > lns-dimensionTrigger', to: 'lnsXY_yReferenceLineRightPanel > lns-empty-dimension', }); @@ -118,7 +119,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '[data-test-subj="lnsXY_fill_below"][class*="euiButtonGroupButton-isSelected"]' ) ).to.be(true); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); }); } diff --git a/x-pack/test/functional/apps/lens/group6/rollup.ts b/x-pack/test/functional/apps/lens/group6/rollup.ts index a8f8aae10ce5c..c1d3c343350d7 100644 --- a/x-pack/test/functional/apps/lens/group6/rollup.ts +++ b/x-pack/test/functional/apps/lens/group6/rollup.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'header', 'timePicker']); + const { visualize, lens, timePicker } = getPageObjects(['visualize', 'lens', 'timePicker']); const find = getService('find'); const listingTable = getService('listingTable'); const esArchiver = getService('esArchiver'); @@ -22,49 +22,49 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'x-pack/test/functional/fixtures/kbn_archiver/rollup/config.json' ); - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); }); after(async () => { await esArchiver.unload('x-pack/test/functional/es_archives/lens/rollup/data'); await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); }); it('should allow creation of lens xy chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'sum', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', }); expect(await find.allByCssSelector('.echLegendItem')).to.have.length(2); - await PageObjects.lens.save('Afancilenstest'); + await lens.save('Afancilenstest'); // Ensure the visualization shows up in the visualize list, and takes // us back to the visualization as we configured it. - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('Afancilenstest'); - await PageObjects.lens.clickVisualizeListItemTitle('Afancilenstest'); - await PageObjects.lens.goToTimeRange(); + await lens.clickVisualizeListItemTitle('Afancilenstest'); + await lens.goToTimeRange(); - expect(await PageObjects.lens.getTitle()).to.eql('Afancilenstest'); + expect(await lens.getTitle()).to.eql('Afancilenstest'); // .echLegendItem__title is the only viable way of getting the xy chart's // legend item(s), so we're using a class selector here. @@ -72,32 +72,32 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should allow seamless transition to and from table view', async () => { - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); - await PageObjects.lens.assertLegacyMetric('Sum of bytes', '16,788'); - await PageObjects.lens.switchToVisualization('lnsDatatable'); - expect(await PageObjects.lens.getDatatableHeaderText()).to.eql('Sum of bytes'); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('16,788'); + await lens.switchToVisualization('lnsLegacyMetric'); + await lens.assertLegacyMetric('Sum of bytes', '16,788'); + await lens.switchToVisualization('lnsDatatable'); + expect(await lens.getDatatableHeaderText()).to.eql('Sum of bytes'); + expect(await lens.getDatatableCellText(0, 0)).to.eql('16,788'); }); it('should allow to switch from regular index to rollup index retaining config', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchDataPanelIndexPattern('lens_regular_data'); - await PageObjects.lens.switchToVisualization('lnsLegacyMetric'); - await PageObjects.lens.configureDimension({ + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchDataPanelIndexPattern('lens_regular_data'); + await lens.switchToVisualization('lnsLegacyMetric'); + await lens.configureDimension({ dimension: 'lns-empty-dimension', operation: 'sum', field: 'bytes', }); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); + await lens.waitForVisualization('legacyMtrVis'); - await PageObjects.lens.assertLegacyMetric('Sum of bytes', '16,788'); + await lens.assertLegacyMetric('Sum of bytes', '16,788'); - await PageObjects.lens.switchFirstLayerIndexPattern('lens_rolled_up_data'); - await PageObjects.lens.waitForVisualization('legacyMtrVis'); + await lens.switchFirstLayerIndexPattern('lens_rolled_up_data'); + await lens.waitForVisualization('legacyMtrVis'); - await PageObjects.lens.assertLegacyMetric('Sum of bytes', '16,788'); + await lens.assertLegacyMetric('Sum of bytes', '16,788'); }); }); } diff --git a/x-pack/test/functional/apps/lens/group6/workspace_size.ts b/x-pack/test/functional/apps/lens/group6/workspace_size.ts index e7b9c7831b3af..cda1631873033 100644 --- a/x-pack/test/functional/apps/lens/group6/workspace_size.ts +++ b/x-pack/test/functional/apps/lens/group6/workspace_size.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const browser = getService('browser'); const testSubjects = getService('testSubjects'); const retry = getService('retry'); @@ -42,13 +42,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const { width, height } = await browser.getWindowSize(); log.debug(`Current browser window size set to ${width}x${height}`); - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); // Detect here if the Chrome bug is present, and adjust the aspect ratio accordingly if not if (!within(width, DEFAULT_WINDOW_SIZE[0]) || !within(height, DEFAULT_WINDOW_SIZE[1])) { const { width: containerWidth, height: containerHeight } = - await PageObjects.lens.getWorkspaceVisContainerDimensions(); + await lens.getWorkspaceVisContainerDimensions(); const newRatio = pxToN(containerWidth) / pxToN(containerHeight); log.debug( @@ -57,7 +57,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { UNCONSTRAINED = newRatio; } - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', @@ -87,7 +87,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const tolerance = 1; await retry.tryForTime(2000, async () => { - const { width, height } = await PageObjects.lens.getWorkspaceVisContainerDimensions(); + const { width, height } = await lens.getWorkspaceVisContainerDimensions(); log.debug( `Checking workspace dimensions: ${width} x ${height} against ${expectedMaxWidth}x${expectedMaxHeight}` ); @@ -115,7 +115,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const tolerance = 0.07; await retry.try(async () => { - const { width, height } = await PageObjects.lens.getWorkspaceVisContainerDimensions(); + const { width, height } = await lens.getWorkspaceVisContainerDimensions(); log.debug( `Checking workspace dimensions: ${pxToN(width)} x ${pxToN(height)} with ratio ${ pxToN(width) / pxToN(height) @@ -136,7 +136,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { maxHeight: string; maxWidth: string; }) => { - const actualStyles = await PageObjects.lens.getWorkspaceVisContainerStyles(); + const actualStyles = await lens.getWorkspaceVisContainerStyles(); expect(actualStyles).to.eql(expectedStyles); }; @@ -200,7 +200,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { while (visTypes.length) { const vis = visTypes.pop()!; await retry.try(async () => { - await PageObjects.lens.switchToVisualization(vis.id, vis.searchText); + await lens.switchToVisualization(vis.id, vis.searchText); }); log.debug( @@ -221,12 +221,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('metric size (absolute pixels)', async () => { await retry.try(async () => { - await PageObjects.lens.switchToVisualization('lnsMetric'); + await lens.switchToVisualization('lnsMetric'); }); await assertWorkspaceDimensions('300px', '300px'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsMetric_breakdownByDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', @@ -234,24 +234,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await assertWorkspaceDimensions('600px', '430px'); - await PageObjects.lens.openDimensionEditor('lnsMetric_breakdownByDimensionPanel'); + await lens.openDimensionEditor('lnsMetric_breakdownByDimensionPanel'); await testSubjects.setValue('lnsMetric_max_cols', '2'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); await assertWorkspaceDimensions('430px', '430px'); }); it('gauge size (absolute pixels) - horizontal', async () => { await retry.try(async () => { - await PageObjects.lens.switchToVisualization('lnsGauge', 'gauge'); - await PageObjects.lens.waitForVisualization('gaugeChart'); + await lens.switchToVisualization('lnsGauge', 'gauge'); + await lens.waitForVisualization('gaugeChart'); }); await assertWorkspaceDimensions('600px', '200px'); }); it('gauge size (absolute pixels) - vertical', async () => { - await PageObjects.lens.openVisualOptions(); + await lens.openVisualOptions(); await testSubjects.click('lns_gaugeOrientation_verticalBullet'); // this height is below the requested 600px @@ -263,20 +263,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('gauge size (absolute pixels) - arc', async () => { - await PageObjects.lens.openVisualOptions(); - await PageObjects.lens.setGaugeShape('Minor arc'); + await lens.openVisualOptions(); + await lens.setGaugeShape('Minor arc'); await assertWorkspaceDimensions('600px', '375px'); }); it('gauge size (absolute pixels) - major arc', async () => { - await PageObjects.lens.openVisualOptions(); - await PageObjects.lens.setGaugeShape('Major arc'); + await lens.openVisualOptions(); + await lens.setGaugeShape('Major arc'); await assertWorkspaceDimensions('600px', '430px'); }); it('gauge size (absolute pixels) - circle', async () => { - await PageObjects.lens.openVisualOptions(); - await PageObjects.lens.setGaugeShape('Circle'); + await lens.openVisualOptions(); + await lens.setGaugeShape('Circle'); await assertWorkspaceDimensions('600px', '430px'); }); @@ -284,7 +284,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // XY charts should have 100% width and 100% height unless they are a vertical chart with a time dimension await retry.try(async () => { // not important that this is specifically a line chart - await PageObjects.lens.switchToVisualization('line'); + await lens.switchToVisualization('line'); }); await assertWorkspaceStyles({ @@ -295,7 +295,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { maxWidth: '100%', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', @@ -312,7 +312,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await assertWorkspaceAspectRatio(VERTICAL_16_9); await retry.try(async () => { - await PageObjects.lens.switchToVisualization('bar'); + await lens.switchToVisualization('bar'); }); await assertWorkspaceAspectRatio(UNCONSTRAINED); diff --git a/x-pack/test/functional/apps/lens/open_in_lens/agg_based/index.ts b/x-pack/test/functional/apps/lens/open_in_lens/agg_based/index.ts index 787b7bf986b8f..e0e5eca1a0ffc 100644 --- a/x-pack/test/functional/apps/lens/open_in_lens/agg_based/index.ts +++ b/x-pack/test/functional/apps/lens/open_in_lens/agg_based/index.ts @@ -13,7 +13,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['timePicker']); + const { timePicker } = getPageObjects(['timePicker']); const config = getService('config'); let remoteEsArchiver; @@ -53,7 +53,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid await esNode.load(esArchive); // changing the timepicker default here saves us from having to set it in Discover (~8s) - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: indexPatternString, 'dateFormat:tz': 'UTC', @@ -64,7 +64,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid after(async () => { await esArchiver.unload(esArchive); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.importExport.unload(fixtureDirs.lensBasic); await kibanaServer.importExport.unload(fixtureDirs.lensDefault); }); diff --git a/x-pack/test/functional/apps/lens/open_in_lens/dashboard/index.ts b/x-pack/test/functional/apps/lens/open_in_lens/dashboard/index.ts index 3d9e8e53c6e4e..0c424142fcf03 100644 --- a/x-pack/test/functional/apps/lens/open_in_lens/dashboard/index.ts +++ b/x-pack/test/functional/apps/lens/open_in_lens/dashboard/index.ts @@ -13,8 +13,9 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['timePicker']); const config = getService('config'); + const { timePicker } = getPageObjects(['timePicker']); + let remoteEsArchiver; describe('lens app - TSVB Open in Lens', () => { @@ -53,7 +54,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid await esNode.load(esArchive); // changing the timepicker default here saves us from having to set it in Discover (~8s) - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: indexPatternString, 'dateFormat:tz': 'UTC', @@ -64,7 +65,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid after(async () => { await esArchiver.unload(esArchive); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.importExport.unload(fixtureDirs.lensBasic); await kibanaServer.importExport.unload(fixtureDirs.lensDefault); }); diff --git a/x-pack/test/functional/apps/lens/open_in_lens/tsvb/dashboard.ts b/x-pack/test/functional/apps/lens/open_in_lens/tsvb/dashboard.ts index ca53fd388301f..593f42c14db4a 100644 --- a/x-pack/test/functional/apps/lens/open_in_lens/tsvb/dashboard.ts +++ b/x-pack/test/functional/apps/lens/open_in_lens/tsvb/dashboard.ts @@ -21,7 +21,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ]); const dashboardCustomizePanel = getService('dashboardCustomizePanel'); const dashboardBadgeActions = getService('dashboardBadgeActions'); - const dashboardPanelActions = getService('dashboardPanelActions'); const testSubjects = getService('testSubjects'); const retry = getService('retry'); const panelActions = getService('dashboardPanelActions'); @@ -47,7 +46,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await dashboard.waitForRenderComplete(); const originalEmbeddableCount = await canvas.getEmbeddableCount(); - await dashboardPanelActions.customizePanel(); + await panelActions.customizePanel(); await dashboardCustomizePanel.enableCustomTimeRange(); await dashboardCustomizePanel.openDatePickerQuickMenu(); await dashboardCustomizePanel.clickCommonlyUsedTimeRange('Last_30 days'); @@ -83,14 +82,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('should convert a by reference TSVB viz to a Lens viz', async () => { + const visTitle = 'My TSVB to Lens viz 2'; await dashboard.navigateToApp(); await dashboard.clickNewDashboard(); await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickVisType('metrics'); await testSubjects.click('visualizesaveAndReturnButton'); - // save it to library - const originalPanel = await testSubjects.find('embeddablePanelHeading-'); - await panelActions.saveToLibrary('My TSVB to Lens viz 2', originalPanel); + await panelActions.saveToLibrary(visTitle); await dashboard.waitForRenderComplete(); const originalEmbeddableCount = await canvas.getEmbeddableCount(); @@ -108,7 +106,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await dashboard.waitForRenderComplete(); await dashboardBadgeActions.expectExistsTimeRangeBadgeAction(); - await panelActions.openContextMenu(); await panelActions.clickEdit(); await visualize.navigateToLensFromAnotherVisualization(); @@ -124,14 +121,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const embeddableCount = await canvas.getEmbeddableCount(); expect(embeddableCount).to.eql(originalEmbeddableCount); }); - const panel = await testSubjects.find(`embeddablePanelHeading-MyTSVBtoLensviz2(converted)`); - const descendants = await testSubjects.findAllDescendant( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - panel - ); - expect(descendants.length).to.equal(0); const titles = await dashboard.getPanelTitles(); - expect(titles[0]).to.be('My TSVB to Lens viz 2 (converted)'); + expect(titles[0]).to.be(`${visTitle} (converted)`); + + await panelActions.expectNotLinkedToLibrary(titles[0], true); await dashboardBadgeActions.expectExistsTimeRangeBadgeAction(); await panelActions.removePanel(); }); diff --git a/x-pack/test/functional/apps/lens/open_in_lens/tsvb/index.ts b/x-pack/test/functional/apps/lens/open_in_lens/tsvb/index.ts index 0844d6201af78..54ea1f5e4b912 100644 --- a/x-pack/test/functional/apps/lens/open_in_lens/tsvb/index.ts +++ b/x-pack/test/functional/apps/lens/open_in_lens/tsvb/index.ts @@ -13,7 +13,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid const log = getService('log'); const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['timePicker']); + const { timePicker } = getPageObjects(['timePicker']); const config = getService('config'); let remoteEsArchiver; @@ -57,7 +57,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid 'dateFormat:tz': 'UTC', // changing the timepicker default here saves us from having to set it in Discover (~8s) // The TSVB tests are using a slightly difference end date, so it needs to be set manually here - 'timepicker:timeDefaults': `{ "from": "${PageObjects.timePicker.defaultStartTime}", "to": "Sep 22, 2015 @ 18:31:44.000" }`, + 'timepicker:timeDefaults': `{ "from": "${timePicker.defaultStartTime}", "to": "Sep 22, 2015 @ 18:31:44.000" }`, }); await kibanaServer.importExport.load(fixtureDirs.lensBasic); await kibanaServer.importExport.load(fixtureDirs.lensDefault); @@ -65,7 +65,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid after(async () => { await esArchiver.unload(esArchive); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.importExport.unload(fixtureDirs.lensBasic); await kibanaServer.importExport.unload(fixtureDirs.lensDefault); }); diff --git a/x-pack/test/functional/apps/maps/group1/auto_fit_to_bounds.js b/x-pack/test/functional/apps/maps/group1/auto_fit_to_bounds.js index 1fe78ec17f1ce..10155cc647feb 100644 --- a/x-pack/test/functional/apps/maps/group1/auto_fit_to_bounds.js +++ b/x-pack/test/functional/apps/maps/group1/auto_fit_to_bounds.js @@ -8,16 +8,14 @@ import expect from '@kbn/expect'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const security = getService('security'); describe('auto fit map to bounds', () => { describe('initial location', () => { before(async () => { await security.testUser.setRoles(['global_maps_all', 'test_logstash_reader']); - await PageObjects.maps.loadSavedMap( - 'document example - auto fit to bounds for initial location' - ); + await maps.loadSavedMap('document example - auto fit to bounds for initial location'); }); after(async () => { @@ -25,10 +23,10 @@ export default function ({ getPageObjects, getService }) { }); it('should automatically fit to bounds on initial map load', async () => { - const hits = await PageObjects.maps.getHits(); + const hits = await maps.getHits(); expect(hits).to.equal('6'); - const { lat, lon } = await PageObjects.maps.getView(); + const { lat, lon } = await maps.getView(); expect(Math.round(lat)).to.be.within(41, 43); expect(Math.round(lon)).to.equal(-99); }); @@ -36,51 +34,51 @@ export default function ({ getPageObjects, getService }) { describe('without joins', () => { before(async () => { - await PageObjects.maps.loadSavedMap('document example'); - await PageObjects.maps.enableAutoFitToBounds(); + await maps.loadSavedMap('document example'); + await maps.enableAutoFitToBounds(); }); it('should automatically fit to bounds when query is applied', async () => { // Set view to other side of world so no matching results - await PageObjects.maps.setView(-15, -100, 6); + await maps.setView(-15, -100, 6); // Setting query should trigger fit to bounds and move map - const origView = await PageObjects.maps.getView(); - await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "ios"'); - await PageObjects.maps.waitForMapPanAndZoom(origView); + const origView = await maps.getView(); + await maps.setAndSubmitQuery('machine.os.raw : "ios"'); + await maps.waitForMapPanAndZoom(origView); - const hits = await PageObjects.maps.getHits(); + const hits = await maps.getHits(); expect(hits).to.equal('2'); - const { lat, lon } = await PageObjects.maps.getView(); + const { lat, lon } = await maps.getView(); expect(Math.round(lat)).to.equal(43); expect(Math.round(lon)).to.equal(-102); }); it('should sync layers even when there is not data', async () => { - await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "fake_os_with_no_matches"'); + await maps.setAndSubmitQuery('machine.os.raw : "fake_os_with_no_matches"'); - const hits = await PageObjects.maps.getHits(); + const hits = await maps.getHits(); expect(hits).to.equal('0'); }); }); describe('with joins', () => { before(async () => { - await PageObjects.maps.loadSavedMap('join example'); - await PageObjects.maps.enableAutoFitToBounds(); + await maps.loadSavedMap('join example'); + await maps.enableAutoFitToBounds(); }); it('should automatically fit to bounds when query is applied', async () => { // Set view to other side of world so no matching results - await PageObjects.maps.setView(0, 0, 6); + await maps.setView(0, 0, 6); // Setting query should trigger fit to bounds and move map - const origView = await PageObjects.maps.getView(); - await PageObjects.maps.setAndSubmitQuery('prop1 >= 11'); - await PageObjects.maps.waitForMapPanAndZoom(origView); + const origView = await maps.getView(); + await maps.setAndSubmitQuery('prop1 >= 11'); + await maps.waitForMapPanAndZoom(origView); - const { lat, lon } = await PageObjects.maps.getView(); + const { lat, lon } = await maps.getView(); expect(Math.round(lat)).to.equal(0); expect(Math.round(lon)).to.equal(60); }); diff --git a/x-pack/test/functional/apps/maps/group1/blended_vector_layer.js b/x-pack/test/functional/apps/maps/group1/blended_vector_layer.js index d142513dfd4a9..413ab879eb12f 100644 --- a/x-pack/test/functional/apps/maps/group1/blended_vector_layer.js +++ b/x-pack/test/functional/apps/maps/group1/blended_vector_layer.js @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const inspector = getService('inspector'); const security = getService('security'); @@ -18,7 +18,7 @@ export default function ({ getPageObjects, getService }) { before(async () => { await security.testUser.setRoles(['test_logstash_reader', 'global_maps_all']); - await PageObjects.maps.loadSavedMap('blended document example'); + await maps.loadSavedMap('blended document example'); }); afterEach(async () => { @@ -30,26 +30,20 @@ export default function ({ getPageObjects, getService }) { }); it('should request documents when zoomed to smaller regions showing less data', async () => { - const { rawResponse: response } = await PageObjects.maps.getResponse( - LOAD_DOCUMENTS_REQUEST_NAME - ); + const { rawResponse: response } = await maps.getResponse(LOAD_DOCUMENTS_REQUEST_NAME); // Allow a range of hits to account for variances in browser window size. expect(response.hits.hits.length).to.be.within(5, 12); }); it('should request clusters when zoomed to larger regions showing lots of data', async () => { - await PageObjects.maps.setView(20, -90, 2); - const { rawResponse: response } = await PageObjects.maps.getResponse( - LOAD_CLUSTERS_REQUEST_NAME - ); + await maps.setView(20, -90, 2); + const { rawResponse: response } = await maps.getResponse(LOAD_CLUSTERS_REQUEST_NAME); expect(response.aggregations.gridSplit.buckets.length).to.equal(15); }); it('should request documents when query narrows data', async () => { - await PageObjects.maps.setAndSubmitQuery('bytes > 19000'); - const { rawResponse: response } = await PageObjects.maps.getResponse( - LOAD_DOCUMENTS_REQUEST_NAME - ); + await maps.setAndSubmitQuery('bytes > 19000'); + const { rawResponse: response } = await maps.getResponse(LOAD_DOCUMENTS_REQUEST_NAME); expect(response.hits.hits.length).to.equal(75); }); }); diff --git a/x-pack/test/functional/apps/maps/group1/documents_source/docvalue_fields.js b/x-pack/test/functional/apps/maps/group1/documents_source/docvalue_fields.js index 1daf4703c59fe..bef0bf64c9c1f 100644 --- a/x-pack/test/functional/apps/maps/group1/documents_source/docvalue_fields.js +++ b/x-pack/test/functional/apps/maps/group1/documents_source/docvalue_fields.js @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const security = getService('security'); describe('docvalue_fields', () => { @@ -23,16 +23,16 @@ export default function ({ getPageObjects, getService }) { }); it('should only fetch geo_point field and time field and nothing else when source does not have data driven styling', async () => { - await PageObjects.maps.loadSavedMap('document example'); - const { rawResponse: response } = await PageObjects.maps.getResponse(); + await maps.loadSavedMap('document example'); + const { rawResponse: response } = await maps.getResponse(); const firstHit = response.hits.hits[0]; expect(firstHit).to.only.have.keys(['_id', '_index', '_score', 'fields']); expect(firstHit.fields).to.only.have.keys(['@timestamp', 'geo.coordinates']); }); it('should only fetch geo_point field and data driven styling fields', async () => { - await PageObjects.maps.loadSavedMap('document example with data driven styles'); - const { rawResponse: response } = await PageObjects.maps.getResponse(); + await maps.loadSavedMap('document example with data driven styles'); + const { rawResponse: response } = await maps.getResponse(); const firstHit = response.hits.hits[0]; expect(firstHit).to.only.have.keys(['_id', '_index', '_score', 'fields']); expect(firstHit.fields).to.only.have.keys([ @@ -44,8 +44,8 @@ export default function ({ getPageObjects, getService }) { }); it('should format date fields as epoch_millis when data driven styling is applied to a date field', async () => { - await PageObjects.maps.loadSavedMap('document example with data driven styles on date field'); - const { rawResponse: response } = await PageObjects.maps.getResponse(); + await maps.loadSavedMap('document example with data driven styles on date field'); + const { rawResponse: response } = await maps.getResponse(); const targetHit = response.hits.hits.find((hit) => { return hit._id === 'AU_x3_g4GFA8no6QjkSR'; }); diff --git a/x-pack/test/functional/apps/maps/group1/documents_source/search_hits.js b/x-pack/test/functional/apps/maps/group1/documents_source/search_hits.js index 75649a23f68bf..488f9e3ab9e5a 100644 --- a/x-pack/test/functional/apps/maps/group1/documents_source/search_hits.js +++ b/x-pack/test/functional/apps/maps/group1/documents_source/search_hits.js @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const inspector = getService('inspector'); const security = getService('security'); @@ -23,7 +23,7 @@ export default function ({ getPageObjects, getService }) { ], { skipBrowserRefresh: true } ); - await PageObjects.maps.loadSavedMap('document example'); + await maps.loadSavedMap('document example'); }); after(async () => { @@ -34,10 +34,7 @@ export default function ({ getPageObjects, getService }) { await inspector.open(); await inspector.openInspectorRequestsView(); const requestStats = await inspector.getTableData(); - const requestTimestamp = PageObjects.maps.getInspectorStatRowHit( - requestStats, - 'Request timestamp' - ); + const requestTimestamp = maps.getInspectorStatRowHit(requestStats, 'Request timestamp'); await inspector.close(); return requestTimestamp; } @@ -45,50 +42,48 @@ export default function ({ getPageObjects, getService }) { it('should re-fetch documents with refresh timer', async () => { const beforeRefreshTimerTimestamp = await getRequestTimestamp(); expect(beforeRefreshTimerTimestamp.length).to.be(24); - await PageObjects.maps.triggerSingleRefresh(1000); + await maps.triggerSingleRefresh(1000); const afterRefreshTimerTimestamp = await getRequestTimestamp(); expect(beforeRefreshTimerTimestamp).not.to.equal(afterRefreshTimerTimestamp); }); describe('inspector', () => { it('should register elasticsearch request in inspector', async () => { - const hits = await PageObjects.maps.getHits(); + const hits = await maps.getHits(); expect(hits).to.equal('5'); }); }); describe('query bar', () => { before(async () => { - await PageObjects.maps.setAndSubmitQuery( - 'machine.os.raw : "win 8" OR machine.os.raw : "ios"' - ); + await maps.setAndSubmitQuery('machine.os.raw : "win 8" OR machine.os.raw : "ios"'); }); after(async () => { - await PageObjects.maps.setAndSubmitQuery(''); + await maps.setAndSubmitQuery(''); }); it('should apply query to search request', async () => { await inspector.open(); await inspector.openInspectorRequestsView(); const requestStats = await inspector.getTableData(); - const hits = PageObjects.maps.getInspectorStatRowHit(requestStats, 'Hits'); + const hits = maps.getInspectorStatRowHit(requestStats, 'Hits'); await inspector.close(); expect(hits).to.equal('2'); }); it('should re-fetch query when "refresh" is clicked', async () => { const beforeQueryRefreshTimestamp = await getRequestTimestamp(); - await PageObjects.maps.refreshQuery(); + await maps.refreshQuery(); const afterQueryRefreshTimestamp = await getRequestTimestamp(); expect(beforeQueryRefreshTimestamp).not.to.equal(afterQueryRefreshTimestamp); }); it('should apply query to fit to bounds', async () => { // Set view to other side of world so no matching results - await PageObjects.maps.setView(-15, -100, 6); - await PageObjects.maps.clickFitToBounds('logstash'); - const { lat, lon, zoom } = await PageObjects.maps.getView(); + await maps.setView(-15, -100, 6); + await maps.clickFitToBounds('logstash'); + const { lat, lon, zoom } = await maps.getView(); expect(Math.round(lat)).to.equal(41); expect(Math.round(lon)).to.equal(-102); @@ -101,23 +96,23 @@ export default function ({ getPageObjects, getService }) { describe('layer query', () => { before(async () => { - await PageObjects.maps.setLayerQuery('logstash', 'machine.os.raw : "ios"'); + await maps.setLayerQuery('logstash', 'machine.os.raw : "ios"'); }); it('should apply layer query to search request', async () => { await inspector.open(); await inspector.openInspectorRequestsView(); const requestStats = await inspector.getTableData(); - const hits = PageObjects.maps.getInspectorStatRowHit(requestStats, 'Hits'); + const hits = maps.getInspectorStatRowHit(requestStats, 'Hits'); await inspector.close(); expect(hits).to.equal('2'); }); it('should apply layer query to fit to bounds', async () => { // Set view to other side of world so no matching results - await PageObjects.maps.setView(-15, -100, 6); - await PageObjects.maps.clickFitToBounds('logstash'); - const { lat, lon, zoom } = await PageObjects.maps.getView(); + await maps.setView(-15, -100, 6); + await maps.clickFitToBounds('logstash'); + const { lat, lon, zoom } = await maps.getView(); expect(Math.round(lat)).to.equal(43); expect(Math.round(lon)).to.equal(-102); expect(Math.round(zoom)).to.equal(5); @@ -126,14 +121,14 @@ export default function ({ getPageObjects, getService }) { describe('filter by extent', () => { it('should handle geo_point filtering with extents that cross antimeridian', async () => { - await PageObjects.maps.loadSavedMap('antimeridian points example'); - const hits = await PageObjects.maps.getHits(); + await maps.loadSavedMap('antimeridian points example'); + const hits = await maps.getHits(); expect(hits).to.equal('2'); }); it('should handle geo_shape filtering with extents that cross antimeridian', async () => { - await PageObjects.maps.loadSavedMap('antimeridian shapes example'); - const hits = await PageObjects.maps.getHits(); + await maps.loadSavedMap('antimeridian shapes example'); + const hits = await maps.getHits(); expect(hits).to.equal('2'); }); }); diff --git a/x-pack/test/functional/apps/maps/group1/documents_source/top_hits.js b/x-pack/test/functional/apps/maps/group1/documents_source/top_hits.js index ac587549179f9..204ce117f690f 100644 --- a/x-pack/test/functional/apps/maps/group1/documents_source/top_hits.js +++ b/x-pack/test/functional/apps/maps/group1/documents_source/top_hits.js @@ -10,7 +10,7 @@ import expect from '@kbn/expect'; const VECTOR_SOURCE_ID = 'z52lq'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps', 'common']); + const { maps } = getPageObjects(['maps']); const inspector = getService('inspector'); const find = getService('find'); const security = getService('security'); @@ -22,7 +22,7 @@ export default function ({ getPageObjects, getService }) { await security.testUser.setRoles(['global_maps_all', 'test_logstash_reader'], { skipBrowserRefresh: true, }); - await PageObjects.maps.loadSavedMap('document example top hits'); + await maps.loadSavedMap('document example top hits'); }); after(async () => { @@ -33,18 +33,18 @@ export default function ({ getPageObjects, getService }) { await inspector.open(); await inspector.openInspectorRequestsView(); const requestStats = await inspector.getTableData(); - const hits = PageObjects.maps.getInspectorStatRowHit(requestStats, 'Hits'); + const hits = maps.getInspectorStatRowHit(requestStats, 'Hits'); expect(hits).to.equal('0'); // aggregation requests do not return any documents }); it('should display top hits per entity', async () => { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + const mapboxStyle = await maps.getMapboxStyle(); expect(mapboxStyle.sources[VECTOR_SOURCE_ID].data.features.length).to.equal(10); }); describe('configuration', () => { before(async () => { - await PageObjects.maps.openLayerPanel('logstash'); + await maps.openLayerPanel('logstash'); await retry.try(async () => { // Can not use testSubjects because data-test-subj is placed range input and number input @@ -61,31 +61,31 @@ export default function ({ getPageObjects, getService }) { } }); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); }); after(async () => { - await PageObjects.maps.closeLayerPanel(); + await maps.closeLayerPanel(); }); it('should update top hits when configation changes', async () => { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + const mapboxStyle = await maps.getMapboxStyle(); expect(mapboxStyle.sources[VECTOR_SOURCE_ID].data.features.length).to.equal(15); }); }); describe('query', () => { before(async () => { - await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "win 8"'); + await maps.setAndSubmitQuery('machine.os.raw : "win 8"'); }); after(async () => { - await PageObjects.maps.setAndSubmitQuery(''); + await maps.setAndSubmitQuery(''); }); it('should apply query to top hits request', async () => { - await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "win 8"'); - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + await maps.setAndSubmitQuery('machine.os.raw : "win 8"'); + const mapboxStyle = await maps.getMapboxStyle(); expect(mapboxStyle.sources[VECTOR_SOURCE_ID].data.features.length).to.equal(2); }); }); @@ -93,11 +93,11 @@ export default function ({ getPageObjects, getService }) { describe('split on scripted field', () => { before(async () => { - await PageObjects.maps.loadSavedMap('document example top hits split with scripted field'); + await maps.loadSavedMap('document example top hits split with scripted field'); }); it('should display top hits per entity', async () => { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + const mapboxStyle = await maps.getMapboxStyle(); expect(mapboxStyle.sources[VECTOR_SOURCE_ID].data.features.length).to.equal(24); }); }); diff --git a/x-pack/test/functional/apps/maps/group1/esql_source.ts b/x-pack/test/functional/apps/maps/group1/esql_source.ts index 8bedf59e3f6b4..37a36bee44492 100644 --- a/x-pack/test/functional/apps/maps/group1/esql_source.ts +++ b/x-pack/test/functional/apps/maps/group1/esql_source.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const security = getService('security'); describe('esql', () => { @@ -17,7 +17,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await security.testUser.setRoles(['global_maps_all', 'test_logstash_reader'], { skipBrowserRefresh: true, }); - await PageObjects.maps.loadSavedMap('esql example'); + await maps.loadSavedMap('esql example'); }); after(async () => { @@ -25,7 +25,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('should display ES|QL statement results on map', async () => { - const tooltipText = await PageObjects.maps.getLayerTocTooltipMsg('logstash-*'); + const tooltipText = await maps.getLayerTocTooltipMsg('logstash-*'); expect(tooltipText).to.equal( 'logstash-*\nFound 5 rows.\nResults narrowed by global time\nResults narrowed by visible map area' ); diff --git a/x-pack/test/functional/apps/maps/group1/feature_controls/maps_security.ts b/x-pack/test/functional/apps/maps/group1/feature_controls/maps_security.ts index 02a0be746f6ad..92d73b524ca8b 100644 --- a/x-pack/test/functional/apps/maps/group1/feature_controls/maps_security.ts +++ b/x-pack/test/functional/apps/maps/group1/feature_controls/maps_security.ts @@ -9,8 +9,8 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const security = getService('security'); - const PageObjects = getPageObjects(['common', 'error', 'maps', 'settings', 'security']); + const securityService = getService('security'); + const { common, error, maps, security } = getPageObjects(['common', 'error', 'maps', 'security']); const appsMenu = getService('appsMenu'); const testSubjects = getService('testSubjects'); const globalNav = getService('globalNav'); @@ -23,12 +23,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { // logout, so the other tests don't accidentally run as the custom users we're testing below // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); + await security.forceLogout(); }); describe('global maps all privileges', () => { before(async () => { - await security.role.create('global_maps_all_role', { + await securityService.role.create('global_maps_all_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -42,25 +42,25 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_maps_all_user', { + await securityService.user.create('global_maps_all_user', { password: 'global_maps_all_user-password', roles: ['global_maps_all_role'], full_name: 'test user', }); - await PageObjects.security.forceLogout(); + await security.forceLogout(); - await PageObjects.security.login('global_maps_all_user', 'global_maps_all_user-password', { + await security.login('global_maps_all_user', 'global_maps_all_user-password', { expectSpaceSelector: false, }); }); after(async () => { // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); + await security.forceLogout(); await Promise.all([ - security.role.delete('global_maps_all_role'), - security.user.delete('global_maps_all_user'), + securityService.role.delete('global_maps_all_role'), + securityService.user.delete('global_maps_all_user'), ]); }); @@ -70,13 +70,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`allows a map to be created`, async () => { - await PageObjects.maps.openNewMap(); - await PageObjects.maps.expectExistAddLayerButton(); - await PageObjects.maps.saveMap('my test map'); + await maps.openNewMap(); + await maps.expectExistAddLayerButton(); + await maps.saveMap('my test map'); }); it(`allows a map to be deleted`, async () => { - await PageObjects.maps.deleteSavedMaps('my test map'); + await maps.deleteSavedMaps('my test map'); }); it(`doesn't show read-only badge`, async () => { @@ -84,7 +84,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('allows saving via the saved query management component popover with no saved query loaded', async () => { - await PageObjects.maps.openNewMap(); + await maps.openNewMap(); await queryBar.setQuery('response:200'); await savedQueryManagementComponent.saveNewQuery('foo', 'bar', true, false); await savedQueryManagementComponent.savedQueryExistOrFail('foo'); @@ -119,7 +119,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('global maps read-only privileges', () => { before(async () => { - await security.role.create('global_maps_read_role', { + await securityService.role.create('global_maps_read_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -133,26 +133,22 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_maps_read_user', { + await securityService.user.create('global_maps_read_user', { password: 'global_maps_read_user-password', roles: ['global_maps_read_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'global_maps_read_user', - 'global_maps_read_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('global_maps_read_user', 'global_maps_read_user-password', { + expectSpaceSelector: false, + }); - await PageObjects.maps.gotoMapListingPage(); + await maps.gotoMapListingPage(); }); after(async () => { - await security.role.delete('global_maps_read_role'); - await security.user.delete('global_maps_read_user'); + await securityService.role.delete('global_maps_read_role'); + await securityService.user.delete('global_maps_read_user'); }); it('shows Maps navlink', async () => { @@ -161,7 +157,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`does not show create new button`, async () => { - await PageObjects.maps.expectMissingCreateNewButton(); + await maps.expectMissingCreateNewButton(); }); it(`does not allow a map to be deleted`, async () => { @@ -174,15 +170,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('existing map', () => { before(async () => { - await PageObjects.maps.loadSavedMap('document example'); + await maps.loadSavedMap('document example'); }); it(`can't save`, async () => { - await PageObjects.maps.expectMissingSaveButton(); + await maps.expectMissingSaveButton(); }); it(`can't add layer`, async () => { - await PageObjects.maps.expectMissingAddLayerButton(); + await maps.expectMissingAddLayerButton(); }); it('allows loading a saved query via the saved query management component', async () => { @@ -214,7 +210,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('no maps privileges', () => { before(async () => { - await security.role.create('no_maps_privileges_role', { + await securityService.role.create('no_maps_privileges_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -228,24 +224,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('no_maps_privileges_user', { + await securityService.user.create('no_maps_privileges_user', { password: 'no_maps_privileges_user-password', roles: ['no_maps_privileges_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'no_maps_privileges_user', - 'no_maps_privileges_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('no_maps_privileges_user', 'no_maps_privileges_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { - await security.role.delete('no_maps_privileges_role'); - await security.user.delete('no_maps_privileges_user'); + await securityService.role.delete('no_maps_privileges_role'); + await securityService.user.delete('no_maps_privileges_user'); }); it('does not show Maps navlink', async () => { @@ -254,11 +246,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`returns a 403`, async () => { - await PageObjects.common.navigateToActualUrl('maps', '', { + await common.navigateToActualUrl('maps', '', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.error.expectForbidden(); + await error.expectForbidden(); }); }); }); diff --git a/x-pack/test/functional/apps/maps/group1/feature_controls/maps_spaces.ts b/x-pack/test/functional/apps/maps/group1/feature_controls/maps_spaces.ts index a306c15bfbdb2..4f83b6a49aa8a 100644 --- a/x-pack/test/functional/apps/maps/group1/feature_controls/maps_spaces.ts +++ b/x-pack/test/functional/apps/maps/group1/feature_controls/maps_spaces.ts @@ -11,19 +11,24 @@ import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const spacesService = getService('spaces'); - const PageObjects = getPageObjects(['common', 'maps', 'security', 'header']); + const { common, maps, security, header } = getPageObjects([ + 'common', + 'maps', + 'security', + 'header', + ]); const listingTable = getService('listingTable'); const appsMenu = getService('appsMenu'); describe('spaces feature controls', () => { before(async () => { - PageObjects.maps.setBasePath('/s/custom_space'); + maps.setBasePath('/s/custom_space'); }); after(async () => { // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); - PageObjects.maps.setBasePath(''); + await security.forceLogout(); + maps.setBasePath(''); }); describe('space with no features disabled', () => { @@ -40,7 +45,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('shows Maps navlink', async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); @@ -48,17 +53,17 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`allows a map to be created`, async () => { - await PageObjects.common.navigateToActualUrl(APP_ID, '/map', { + await common.navigateToActualUrl(APP_ID, '/map', { basePath: `/s/custom_space`, ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); - await PageObjects.maps.waitForLayersToLoad(); - await PageObjects.maps.saveMap('my test map'); + await maps.waitForLayersToLoad(); + await maps.saveMap('my test map'); }); it(`allows a map to be deleted`, async () => { - await PageObjects.common.navigateToActualUrl(APP_ID, '/', { + await common.navigateToActualUrl(APP_ID, '/', { basePath: `/s/custom_space`, ensureCurrentUrl: true, shouldLoginIfPrompted: false, @@ -67,11 +72,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { // Can not use maps.deleteSavedMaps because maps.deleteSavedMaps will // navigate to default space if on list page check fails await listingTable.searchForItemWithName('my test map'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await listingTable.checkListingSelectAllCheckbox(); await listingTable.clickDeleteSelected(); - await PageObjects.common.clickConfirmOnModal(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.clickConfirmOnModal(); + await header.waitUntilLoadingHasFinished(); await listingTable.expectItemsCount('map', 0); }); }); @@ -90,12 +95,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`returns a 404`, async () => { - await PageObjects.common.navigateToActualUrl(APP_ID, '/', { + await common.navigateToActualUrl(APP_ID, '/', { basePath: '/s/custom_space', ensureCurrentUrl: true, shouldLoginIfPrompted: false, }); - const messageText = await PageObjects.common.getJsonBodyText(); + const messageText = await common.getJsonBodyText(); expect(messageText).to.eql( JSON.stringify({ statusCode: 404, diff --git a/x-pack/test/functional/apps/maps/group1/full_screen_mode.js b/x-pack/test/functional/apps/maps/group1/full_screen_mode.js index b0ed1311d439a..d0d5e048387cd 100644 --- a/x-pack/test/functional/apps/maps/group1/full_screen_mode.js +++ b/x-pack/test/functional/apps/maps/group1/full_screen_mode.js @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { - const PageObjects = getPageObjects(['maps', 'common']); + const { maps, common } = getPageObjects(['maps', 'common']); const retry = getService('retry'); const security = getService('security'); const testSubjects = getService('testSubjects'); @@ -16,25 +16,25 @@ export default function ({ getService, getPageObjects }) { describe('maps full screen mode', () => { before(async () => { await security.testUser.setRoles(['global_maps_all']); - await PageObjects.maps.openNewMap(); + await maps.openNewMap(); }); after(async () => { await security.testUser.restoreDefaults(); }); it('full screen button should exist', async () => { - const exists = await PageObjects.maps.fullScreenModeMenuItemExists(); + const exists = await maps.fullScreenModeMenuItemExists(); expect(exists).to.be(true); }); it('hides the chrome', async () => { - const isChromeVisible = await PageObjects.common.isChromeVisible(); + const isChromeVisible = await common.isChromeVisible(); expect(isChromeVisible).to.be(true); - await PageObjects.maps.clickFullScreenMode(); + await maps.clickFullScreenMode(); await retry.try(async () => { - const isChromeHidden = await PageObjects.common.isChromeHidden(); + const isChromeHidden = await common.isChromeHidden(); expect(isChromeHidden).to.be(true); }); }); @@ -44,17 +44,17 @@ export default function ({ getService, getPageObjects }) { }); it('displays exit full screen logo button', async () => { - const exists = await PageObjects.maps.exitFullScreenLogoButtonExists(); + const exists = await maps.exitFullScreenLogoButtonExists(); expect(exists).to.be(true); }); it('exits when the text button is clicked on', async () => { - const logoButton = await PageObjects.maps.getExitFullScreenLogoButton(); + const logoButton = await maps.getExitFullScreenLogoButton(); await logoButton.moveMouseTo(); - await PageObjects.maps.clickExitFullScreenTextButton(); + await maps.clickExitFullScreenTextButton(); await retry.try(async () => { - const isChromeVisible = await PageObjects.common.isChromeVisible(); + const isChromeVisible = await common.isChromeVisible(); expect(isChromeVisible).to.be(true); }); }); diff --git a/x-pack/test/functional/apps/maps/group1/layer_visibility.js b/x-pack/test/functional/apps/maps/group1/layer_visibility.js index cf6051cde8be7..52770e6cbf3d3 100644 --- a/x-pack/test/functional/apps/maps/group1/layer_visibility.js +++ b/x-pack/test/functional/apps/maps/group1/layer_visibility.js @@ -8,30 +8,30 @@ import expect from '@kbn/expect'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const inspector = getService('inspector'); const security = getService('security'); describe('layer visibility', () => { before(async () => { await security.testUser.setRoles(['test_logstash_reader', 'global_maps_all']); - await PageObjects.maps.loadSavedMap('document example hidden'); + await maps.loadSavedMap('document example hidden'); }); afterEach(async () => { await inspector.close(); - await PageObjects.maps.refreshAndClearUnsavedChangesWarning(); + await maps.refreshAndClearUnsavedChangesWarning(); await security.testUser.restoreDefaults(); }); it('should not make any requests when layer is hidden', async () => { - const noRequests = await PageObjects.maps.doesInspectorHaveRequests(); + const noRequests = await maps.doesInspectorHaveRequests(); expect(noRequests).to.equal(true); }); it('should fetch layer data when layer is made visible', async () => { - await PageObjects.maps.toggleLayerVisibility('logstash'); - const hits = await PageObjects.maps.getHits(); + await maps.toggleLayerVisibility('logstash'); + const hits = await maps.getHits(); expect(hits).to.equal('5'); }); }); diff --git a/x-pack/test/functional/apps/maps/group1/sample_data.js b/x-pack/test/functional/apps/maps/group1/sample_data.js index 377d80a63999b..01d0ce3a8e97a 100644 --- a/x-pack/test/functional/apps/maps/group1/sample_data.js +++ b/x-pack/test/functional/apps/maps/group1/sample_data.js @@ -9,7 +9,13 @@ import expect from '@kbn/expect'; import { UI_SETTINGS } from '@kbn/data-plugin/common'; export default function ({ getPageObjects, getService, updateBaselines }) { - const PageObjects = getPageObjects(['common', 'maps', 'header', 'home', 'timePicker']); + const { common, maps, header, home, timePicker } = getPageObjects([ + 'common', + 'maps', + 'header', + 'home', + 'timePicker', + ]); const screenshot = getService('screenshots'); const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); @@ -22,13 +28,13 @@ export default function ({ getPageObjects, getService, updateBaselines }) { before(async () => { //installing the sample data with test user with super user role and then switching roles with limited privileges await security.testUser.setRoles(['superuser'], { skipBrowserRefresh: true }); - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.addSampleDataSet('ecommerce'); - await PageObjects.home.addSampleDataSet('flights'); - await PageObjects.home.addSampleDataSet('logs'); + await header.waitUntilLoadingHasFinished(); + await home.addSampleDataSet('ecommerce'); + await home.addSampleDataSet('flights'); + await home.addSampleDataSet('logs'); // Sample data is shifted to be relative to current time // This means that a static timerange will return different documents @@ -56,32 +62,32 @@ export default function ({ getPageObjects, getService, updateBaselines }) { after(async () => { await security.testUser.restoreDefaults(); - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.removeSampleDataSet('ecommerce'); - await PageObjects.home.removeSampleDataSet('flights'); - await PageObjects.home.removeSampleDataSet('logs'); + await header.waitUntilLoadingHasFinished(); + await home.removeSampleDataSet('ecommerce'); + await home.removeSampleDataSet('flights'); + await home.removeSampleDataSet('logs'); }); describe('ecommerce', () => { before(async () => { - await PageObjects.maps.loadSavedMap('[eCommerce] Orders by Country'); - await PageObjects.maps.toggleEmsBasemapLayerVisibility(); - await PageObjects.maps.toggleLayerVisibility('United Kingdom'); - await PageObjects.maps.toggleLayerVisibility('France'); - await PageObjects.maps.toggleLayerVisibility('United States'); - await PageObjects.maps.toggleLayerVisibility('World Countries'); - await PageObjects.timePicker.setCommonlyUsedTime('sample_data range'); - await PageObjects.maps.enterFullScreen(); - await PageObjects.maps.closeLegend(); + await maps.loadSavedMap('[eCommerce] Orders by Country'); + await maps.toggleEmsBasemapLayerVisibility(); + await maps.toggleLayerVisibility('United Kingdom'); + await maps.toggleLayerVisibility('France'); + await maps.toggleLayerVisibility('United States'); + await maps.toggleLayerVisibility('World Countries'); + await timePicker.setCommonlyUsedTime('sample_data range'); + await maps.enterFullScreen(); + await maps.closeLegend(); const mapContainerElement = await testSubjects.find('mapContainer'); await mapContainerElement.moveMouseTo({ xOffset: 0, yOffset: 0 }); }); after(async () => { - await PageObjects.maps.existFullScreen(); + await maps.existFullScreen(); }); it('should load layers', async () => { @@ -95,17 +101,17 @@ export default function ({ getPageObjects, getService, updateBaselines }) { describe('flights', () => { before(async () => { - await PageObjects.maps.loadSavedMap('[Flights] Origin Time Delayed'); - await PageObjects.maps.toggleEmsBasemapLayerVisibility(); - await PageObjects.timePicker.setCommonlyUsedTime('sample_data range'); - await PageObjects.maps.enterFullScreen(); - await PageObjects.maps.closeLegend(); + await maps.loadSavedMap('[Flights] Origin Time Delayed'); + await maps.toggleEmsBasemapLayerVisibility(); + await timePicker.setCommonlyUsedTime('sample_data range'); + await maps.enterFullScreen(); + await maps.closeLegend(); const mapContainerElement = await testSubjects.find('mapContainer'); await mapContainerElement.moveMouseTo({ xOffset: 0, yOffset: 0 }); }); after(async () => { - await PageObjects.maps.existFullScreen(); + await maps.existFullScreen(); }); it('should load saved object and display layers', async () => { @@ -119,18 +125,18 @@ export default function ({ getPageObjects, getService, updateBaselines }) { describe('web logs', () => { before(async () => { - await PageObjects.maps.loadSavedMap('[Logs] Total Requests and Bytes'); - await PageObjects.maps.toggleLayerVisibility('Total Requests by Destination'); - await PageObjects.maps.toggleEmsBasemapLayerVisibility(); - await PageObjects.timePicker.setCommonlyUsedTime('sample_data range'); - await PageObjects.maps.enterFullScreen(); - await PageObjects.maps.closeLegend(); + await maps.loadSavedMap('[Logs] Total Requests and Bytes'); + await maps.toggleLayerVisibility('Total Requests by Destination'); + await maps.toggleEmsBasemapLayerVisibility(); + await timePicker.setCommonlyUsedTime('sample_data range'); + await maps.enterFullScreen(); + await maps.closeLegend(); const mapContainerElement = await testSubjects.find('mapContainer'); await mapContainerElement.moveMouseTo({ xOffset: 0, yOffset: 0 }); }); after(async () => { - await PageObjects.maps.existFullScreen(); + await maps.existFullScreen(); }); it('should load saved object and display layers', async () => { diff --git a/x-pack/test/functional/apps/maps/group1/saved_object_management.js b/x-pack/test/functional/apps/maps/group1/saved_object_management.js index c2971397f0171..7439bfb75c702 100644 --- a/x-pack/test/functional/apps/maps/group1/saved_object_management.js +++ b/x-pack/test/functional/apps/maps/group1/saved_object_management.js @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps', 'header', 'timePicker']); + const { maps, timePicker } = getPageObjects(['maps', 'timePicker']); const queryBar = getService('queryBar'); const filterBar = getService('filterBar'); const browser = getService('browser'); @@ -29,7 +29,7 @@ export default function ({ getPageObjects, getService }) { 'meta_for_geoshape_data_reader', 'test_logstash_reader', ]); - await PageObjects.maps.loadSavedMap('join example'); + await maps.loadSavedMap('join example'); joinMapUrl = await browser.getCurrentUrl(); }); after(async () => { @@ -37,27 +37,27 @@ export default function ({ getPageObjects, getService }) { }); it('should update global Kibana time to value stored with map', async () => { - const timeConfig = await PageObjects.timePicker.getTimeConfig(); + const timeConfig = await timePicker.getTimeConfig(); expect(timeConfig.start).to.equal('~ 17 minutes ago'); expect(timeConfig.end).to.equal('now'); }); it('should update global Kibana refresh config to value stored with map', async () => { - const kibanaRefreshConfig = await PageObjects.timePicker.getRefreshConfig(); + const kibanaRefreshConfig = await timePicker.getRefreshConfig(); expect(kibanaRefreshConfig.interval).to.equal('1'); expect(kibanaRefreshConfig.units).to.equal('Seconds'); expect(kibanaRefreshConfig.isPaused).to.equal(true); }); it('should set map location to value stored with map', async () => { - const { lat, lon, zoom } = await PageObjects.maps.getView(); + const { lat, lon, zoom } = await maps.getView(); expect(lat).to.equal(-0.04647); expect(lon).to.equal(77.33426); expect(zoom).to.equal(3.02); }); it('should load map layers stored with map', async () => { - const layerExists = await PageObjects.maps.doesLayerExist('geo_shapes*'); + const layerExists = await maps.doesLayerExist('geo_shapes*'); expect(layerExists).to.equal(true); }); @@ -65,16 +65,16 @@ export default function ({ getPageObjects, getService }) { const urlSplit = joinMapUrl.split('?'); const globalState = `_g=(time:(from:now-36m,to:now))`; await browser.get(`${urlSplit[0]}?${globalState}`, true); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); - const timeConfig = await PageObjects.timePicker.getTimeConfig(); + const timeConfig = await timePicker.getTimeConfig(); expect(timeConfig.start).to.equal('~ 36 minutes ago'); expect(timeConfig.end).to.equal('now'); }); describe('mapState contains query', () => { before(async () => { - await PageObjects.maps.loadSavedMap('document example with query'); + await maps.loadSavedMap('document example with query'); }); it('should update query bar with query stored with map', async () => { @@ -94,7 +94,7 @@ export default function ({ getPageObjects, getService }) { await inspector.open(); await inspector.openInspectorRequestsView(); const requestStats = await inspector.getTableData(); - const hits = PageObjects.maps.getInspectorStatRowHit(requestStats, 'Hits'); + const hits = maps.getInspectorStatRowHit(requestStats, 'Hits'); await inspector.close(); expect(hits).to.equal('1'); }); @@ -106,7 +106,7 @@ export default function ({ getPageObjects, getService }) { const urlWithQueryInAppState = `${kibanaBaseUrl}/maps/map/8eabdab0-144f-11e9-809f-ad25bb78262c#?${appState}`; await browser.get(urlWithQueryInAppState, true); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); const query = await queryBar.getQueryString(); expect(query).to.equal('machine.os.raw : "win 8"'); @@ -115,14 +115,14 @@ export default function ({ getPageObjects, getService }) { await inspector.openInspectorRequestsView(); const requestStats = await inspector.getTableData(); await inspector.close(); - const hits = PageObjects.maps.getInspectorStatRowHit(requestStats, 'Hits'); + const hits = maps.getInspectorStatRowHit(requestStats, 'Hits'); expect(hits).to.equal('1'); }); }); describe('mapState contains filters', () => { before(async () => { - await PageObjects.maps.loadSavedMap('document example with filter'); + await maps.loadSavedMap('document example with filter'); }); it('should update filter bar with filters stored with map', async () => { @@ -142,7 +142,7 @@ export default function ({ getPageObjects, getService }) { await inspector.open(); await inspector.openInspectorRequestsView(); const requestStats = await inspector.getTableData(); - const hits = PageObjects.maps.getInspectorStatRowHit(requestStats, 'Hits'); + const hits = maps.getInspectorStatRowHit(requestStats, 'Hits'); await inspector.close(); expect(hits).to.equal('1'); }); @@ -151,30 +151,30 @@ export default function ({ getPageObjects, getService }) { describe('create', () => { it('should allow saving map', async () => { - await PageObjects.maps.openNewMap(); + await maps.openNewMap(); - await PageObjects.maps.saveMap(MAP1_NAME); + await maps.saveMap(MAP1_NAME); - await PageObjects.maps.searchAndExpectItemsCount(MAP1_NAME, 1); + await maps.searchAndExpectItemsCount(MAP1_NAME, 1); }); it('should allow saving map that crosses dateline', async () => { - await PageObjects.maps.openNewMap(); - await PageObjects.maps.setView('64', '179', '5'); + await maps.openNewMap(); + await maps.setView('64', '179', '5'); - await PageObjects.maps.saveMap(MAP2_NAME); + await maps.saveMap(MAP2_NAME); - await PageObjects.maps.searchAndExpectItemsCount(MAP2_NAME, 1); + await maps.searchAndExpectItemsCount(MAP2_NAME, 1); }); }); describe('delete', () => { it('should delete selected saved objects', async () => { - await PageObjects.maps.deleteSavedMaps(MAP_NAME_PREFIX); + await maps.deleteSavedMaps(MAP_NAME_PREFIX); - await PageObjects.maps.searchAndExpectItemsCount(MAP1_NAME, 0); + await maps.searchAndExpectItemsCount(MAP1_NAME, 0); - await PageObjects.maps.searchAndExpectItemsCount(MAP2_NAME, 0); + await maps.searchAndExpectItemsCount(MAP2_NAME, 0); }); }); }); diff --git a/x-pack/test/functional/apps/maps/group1/vector_styling.js b/x-pack/test/functional/apps/maps/group1/vector_styling.js index d87ac548c85a0..bc7b3f3af975e 100644 --- a/x-pack/test/functional/apps/maps/group1/vector_styling.js +++ b/x-pack/test/functional/apps/maps/group1/vector_styling.js @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { - const PageObjects = getPageObjects(['common', 'maps', 'timePicker']); + const { common, maps } = getPageObjects(['common', 'maps']); const security = getService('security'); const from = 'Mar 1, 2015 @ 00:00:00.000'; const to = 'Mar 1, 2016 @ 00:00:00.000'; @@ -16,25 +16,25 @@ export default function ({ getService, getPageObjects }) { describe('vector styling', () => { before(async () => { await security.testUser.setRoles(['test_logstash_reader', 'global_maps_all']); - await PageObjects.maps.loadSavedMap('document example'); - await PageObjects.common.setTime({ from, to }); + await maps.loadSavedMap('document example'); + await common.setTime({ from, to }); }); after(async () => { - await PageObjects.maps.refreshAndClearUnsavedChangesWarning(); + await maps.refreshAndClearUnsavedChangesWarning(); await security.testUser.restoreDefaults(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); describe('categorical styling', () => { before(async () => { - await PageObjects.maps.openLayerPanel('logstash'); + await maps.openLayerPanel('logstash'); }); it('should provide auto complete suggestions', async () => { - await PageObjects.maps.setStyleByValue('fillColor', 'machine.os.raw'); - await PageObjects.maps.selectCustomColorRamp('fillColor'); - const suggestions = await PageObjects.maps.getCategorySuggestions(); + await maps.setStyleByValue('fillColor', 'machine.os.raw'); + await maps.selectCustomColorRamp('fillColor'); + const suggestions = await maps.getCategorySuggestions(); expect(suggestions.trim().split('\n').join()).to.equal('ios,osx,win 7,win 8,win xp'); }); }); diff --git a/x-pack/test/functional/apps/maps/group2/adhoc_data_view.ts b/x-pack/test/functional/apps/maps/group2/adhoc_data_view.ts index 15824a1beb63f..4e5d3a7692734 100644 --- a/x-pack/test/functional/apps/maps/group2/adhoc_data_view.ts +++ b/x-pack/test/functional/apps/maps/group2/adhoc_data_view.ts @@ -10,18 +10,18 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const security = getService('security'); - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); describe('maps adhoc data view', () => { before(async () => { await security.testUser.setRoles(['global_maps_all', 'test_logstash_reader'], { skipBrowserRefresh: true, }); - await PageObjects.maps.loadSavedMap('adhoc data view'); + await maps.loadSavedMap('adhoc data view'); }); it('should render saved map with adhoc data view', async () => { - const tooltipText = await PageObjects.maps.getLayerTocTooltipMsg('adhocDataView'); + const tooltipText = await maps.getLayerTocTooltipMsg('adhocDataView'); expect(tooltipText).to.equal( 'adhocDataView\nFound 908 documents.\nResults narrowed by global search\nResults narrowed by global time' ); diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard.js b/x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard.js deleted file mode 100644 index fcd3d06115508..0000000000000 --- a/x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard.js +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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'; - -export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects([ - 'common', - 'dashboard', - 'header', - 'maps', - 'timeToVisualize', - 'visualize', - ]); - - const listingTable = getService('listingTable'); - const testSubjects = getService('testSubjects'); - const security = getService('security'); - - describe('maps add-to-dashboard save flow', () => { - before(async () => { - await security.testUser.setRoles( - [ - 'test_logstash_reader', - 'global_maps_all', - 'geoshape_data_reader', - 'global_dashboard_all', - 'meta_for_geoshape_data_reader', - ], - { skipBrowserRefresh: true } - ); - }); - - after(async () => { - await security.testUser.restoreDefaults(); - }); - - it('should allow new map be added by value to a new dashboard', async () => { - await PageObjects.maps.openNewMap(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - - await testSubjects.click('mapSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('map 1', { - addToDashboard: 'new', - saveToLibrary: false, - }); - - await PageObjects.dashboard.waitForRenderComplete(); - - const panelCount = await PageObjects.dashboard.getPanelCount(); - expect(panelCount).to.eql(1); - - const isInLibrary = await PageObjects.timeToVisualize.libraryNotificationExists('map 1'); - expect(isInLibrary).to.be(false); - await PageObjects.timeToVisualize.resetNewDashboard(); - }); - - it('should allow existing maps be added by value to a new dashboard', async () => { - await PageObjects.maps.loadSavedMap('document example'); - - await testSubjects.click('mapSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('document example copy', { - saveToLibrary: false, - addToDashboard: 'new', - saveAsNew: true, - }); - - await PageObjects.dashboard.waitForRenderComplete(); - - const panelCount = await PageObjects.dashboard.getPanelCount(); - expect(panelCount).to.eql(1); - - const isInLibrary = await PageObjects.timeToVisualize.libraryNotificationExists( - 'document example copy' - ); - expect(isInLibrary).to.be(false); - await PageObjects.timeToVisualize.resetNewDashboard(); - }); - - it('should allow new map be added by value to an existing dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - - await PageObjects.dashboard.saveDashboard('My Very Cool Dashboard'); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await listingTable.searchAndExpectItemsCount('dashboard', 'My Very Cool Dashboard', 1); - - await PageObjects.maps.openNewMap(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - - await testSubjects.click('mapSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('My New Map 2', { - saveToLibrary: false, - addToDashboard: 'existing', - dashboardId: 'My Very Cool Dashboard', - }); - - await PageObjects.dashboard.waitForRenderComplete(); - - const panelCount = await PageObjects.dashboard.getPanelCount(); - expect(panelCount).to.eql(1); - - const isInLibrary = await PageObjects.timeToVisualize.libraryNotificationExists( - 'My New Map 2' - ); - expect(isInLibrary).to.be(false); - }); - - it('should allow existing maps be added by value to an existing dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - - await PageObjects.dashboard.saveDashboard('My Wonderful Dashboard'); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await listingTable.searchAndExpectItemsCount('dashboard', 'My Wonderful Dashboard', 1); - - await PageObjects.maps.loadSavedMap('document example'); - - await testSubjects.click('mapSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('document example copy 2', { - saveToLibrary: false, - addToDashboard: 'existing', - dashboardId: 'My Wonderful Dashboard', - saveAsNew: true, - }); - - await PageObjects.dashboard.waitForRenderComplete(); - - const panelCount = await PageObjects.dashboard.getPanelCount(); - expect(panelCount).to.eql(1); - - const isInLibrary = await PageObjects.timeToVisualize.libraryNotificationExists( - 'document example copy 2' - ); - expect(isInLibrary).to.be(false); - }); - - it('should allow new map be added by reference to a new dashboard', async () => { - await PageObjects.maps.openNewMap(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - - await testSubjects.click('mapSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('map 1', { - addToDashboard: 'new', - saveToLibrary: true, - }); - - await PageObjects.dashboard.waitForRenderComplete(); - - const panelCount = await PageObjects.dashboard.getPanelCount(); - expect(panelCount).to.eql(1); - - const isInLibrary = await PageObjects.timeToVisualize.libraryNotificationExists('map 1'); - expect(isInLibrary).to.be(true); - await PageObjects.timeToVisualize.resetNewDashboard(); - }); - - it('should allow existing maps be added by reference to a new dashboard', async () => { - await PageObjects.maps.loadSavedMap('document example'); - - await testSubjects.click('mapSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('document example copy', { - saveToLibrary: true, - addToDashboard: 'new', - saveAsNew: true, - }); - - await PageObjects.dashboard.waitForRenderComplete(); - - const panelCount = await PageObjects.dashboard.getPanelCount(); - expect(panelCount).to.eql(1); - - const isInLibrary = await PageObjects.timeToVisualize.libraryNotificationExists( - 'document example copy' - ); - expect(isInLibrary).to.be(true); - await PageObjects.timeToVisualize.resetNewDashboard(); - }); - - it('should allow new map be added by reference to an existing dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - - await PageObjects.dashboard.saveDashboard('My Super Cool Dashboard'); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await listingTable.searchAndExpectItemsCount('dashboard', 'My Super Cool Dashboard', 1); - - await PageObjects.maps.openNewMap(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - - await testSubjects.click('mapSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('My New Map 2', { - saveToLibrary: true, - addToDashboard: 'existing', - dashboardId: 'My Super Cool Dashboard', - }); - - await PageObjects.dashboard.waitForRenderComplete(); - - const panelCount = await PageObjects.dashboard.getPanelCount(); - expect(panelCount).to.eql(1); - - const isInLibrary = await PageObjects.timeToVisualize.libraryNotificationExists( - 'My New Map 2' - ); - expect(isInLibrary).to.be(true); - }); - - it('should allow existing maps be added by reference to an existing dashboard', async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - - await PageObjects.dashboard.saveDashboard('My Amazing Dashboard'); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await listingTable.searchAndExpectItemsCount('dashboard', 'My Amazing Dashboard', 1); - - await PageObjects.maps.loadSavedMap('document example'); - - await testSubjects.click('mapSaveButton'); - await PageObjects.timeToVisualize.saveFromModal('document example copy 2', { - saveToLibrary: true, - addToDashboard: 'existing', - dashboardId: 'My Amazing Dashboard', - saveAsNew: true, - }); - - await PageObjects.dashboard.waitForRenderComplete(); - - const panelCount = await PageObjects.dashboard.getPanelCount(); - expect(panelCount).to.eql(1); - - const isInLibrary = await PageObjects.timeToVisualize.libraryNotificationExists( - 'document example copy 2' - ); - expect(isInLibrary).to.be(true); - }); - }); -} diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard.ts b/x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard.ts new file mode 100644 index 0000000000000..f4059de17edfb --- /dev/null +++ b/x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard.ts @@ -0,0 +1,227 @@ +/* + * 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 ({ getPageObjects, getService }: FtrProviderContext) { + const { dashboard, header, maps, timeToVisualize } = getPageObjects([ + 'dashboard', + 'header', + 'maps', + 'timeToVisualize', + ]); + + const dashboardPanelActions = getService('dashboardPanelActions'); + const listingTable = getService('listingTable'); + const testSubjects = getService('testSubjects'); + const security = getService('security'); + + describe('maps add-to-dashboard save flow', () => { + before(async () => { + await security.testUser.setRoles( + [ + 'test_logstash_reader', + 'global_maps_all', + 'geoshape_data_reader', + 'global_dashboard_all', + 'meta_for_geoshape_data_reader', + ], + { skipBrowserRefresh: true } + ); + }); + + after(async () => { + await security.testUser.restoreDefaults(); + }); + + it('should allow new map be added by value to a new dashboard', async () => { + await maps.openNewMap(); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + + await testSubjects.click('mapSaveButton'); + await timeToVisualize.saveFromModal('map 1', { + addToDashboard: 'new', + saveToLibrary: false, + }); + + await dashboard.waitForRenderComplete(); + + const panelCount = await dashboard.getPanelCount(); + expect(panelCount).to.eql(1); + + await dashboardPanelActions.expectNotLinkedToLibrary('map 1'); + await timeToVisualize.resetNewDashboard(); + }); + + it('should allow existing maps be added by value to a new dashboard', async () => { + await maps.loadSavedMap('document example'); + + await testSubjects.click('mapSaveButton'); + await timeToVisualize.saveFromModal('document example copy', { + saveToLibrary: false, + addToDashboard: 'new', + saveAsNew: true, + }); + + await dashboard.waitForRenderComplete(); + + const panelCount = await dashboard.getPanelCount(); + expect(panelCount).to.eql(1); + + await dashboardPanelActions.expectNotLinkedToLibrary('document example copy'); + await timeToVisualize.resetNewDashboard(); + }); + + it('should allow new map be added by value to an existing dashboard', async () => { + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + + await dashboard.saveDashboard('My Very Cool Dashboard'); + await dashboard.gotoDashboardLandingPage(); + await listingTable.searchAndExpectItemsCount('dashboard', 'My Very Cool Dashboard', 1); + + await maps.openNewMap(); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + + await testSubjects.click('mapSaveButton'); + await timeToVisualize.saveFromModal('My New Map 2', { + saveToLibrary: false, + addToDashboard: 'existing', + dashboardId: 'My Very Cool Dashboard', + }); + + await dashboard.waitForRenderComplete(); + + const panelCount = await dashboard.getPanelCount(); + expect(panelCount).to.eql(1); + + await dashboardPanelActions.expectNotLinkedToLibrary('My New Map 2'); + }); + + it('should allow existing maps be added by value to an existing dashboard', async () => { + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + + await dashboard.saveDashboard('My Wonderful Dashboard'); + await dashboard.gotoDashboardLandingPage(); + await listingTable.searchAndExpectItemsCount('dashboard', 'My Wonderful Dashboard', 1); + + await maps.loadSavedMap('document example'); + + await testSubjects.click('mapSaveButton'); + await timeToVisualize.saveFromModal('document example copy 2', { + saveToLibrary: false, + addToDashboard: 'existing', + dashboardId: 'My Wonderful Dashboard', + saveAsNew: true, + }); + + await dashboard.waitForRenderComplete(); + + const panelCount = await dashboard.getPanelCount(); + expect(panelCount).to.eql(1); + + await dashboardPanelActions.expectNotLinkedToLibrary('document example copy 2'); + }); + + it('should allow new map be added by reference to a new dashboard', async () => { + await maps.openNewMap(); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + + await testSubjects.click('mapSaveButton'); + await timeToVisualize.saveFromModal('map 1', { + addToDashboard: 'new', + saveToLibrary: true, + }); + + await dashboard.waitForRenderComplete(); + + const panelCount = await dashboard.getPanelCount(); + expect(panelCount).to.eql(1); + + await dashboardPanelActions.expectLinkedToLibrary('map 1'); + + await timeToVisualize.resetNewDashboard(); + }); + + it('should allow existing maps be added by reference to a new dashboard', async () => { + await maps.loadSavedMap('document example'); + + await testSubjects.click('mapSaveButton'); + await timeToVisualize.saveFromModal('document example copy', { + saveToLibrary: true, + addToDashboard: 'new', + saveAsNew: true, + }); + + await dashboard.waitForRenderComplete(); + + const panelCount = await dashboard.getPanelCount(); + expect(panelCount).to.eql(1); + + await dashboardPanelActions.expectLinkedToLibrary('document example copy'); + await timeToVisualize.resetNewDashboard(); + }); + + it('should allow new map be added by reference to an existing dashboard', async () => { + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + + await dashboard.saveDashboard('My Super Cool Dashboard'); + await dashboard.gotoDashboardLandingPage(); + await listingTable.searchAndExpectItemsCount('dashboard', 'My Super Cool Dashboard', 1); + + await maps.openNewMap(); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + + await testSubjects.click('mapSaveButton'); + await timeToVisualize.saveFromModal('My New Map 2', { + saveToLibrary: true, + addToDashboard: 'existing', + dashboardId: 'My Super Cool Dashboard', + }); + + await dashboard.waitForRenderComplete(); + + const panelCount = await dashboard.getPanelCount(); + expect(panelCount).to.eql(1); + + await dashboardPanelActions.expectLinkedToLibrary('My New Map 2'); + }); + + it('should allow existing maps be added by reference to an existing dashboard', async () => { + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + + await dashboard.saveDashboard('My Amazing Dashboard'); + await dashboard.gotoDashboardLandingPage(); + await listingTable.searchAndExpectItemsCount('dashboard', 'My Amazing Dashboard', 1); + + await maps.loadSavedMap('document example'); + + await testSubjects.click('mapSaveButton'); + await timeToVisualize.saveFromModal('document example copy 2', { + saveToLibrary: true, + addToDashboard: 'existing', + dashboardId: 'My Amazing Dashboard', + saveAsNew: true, + }); + + await dashboard.waitForRenderComplete(); + + const panelCount = await dashboard.getPanelCount(); + expect(panelCount).to.eql(1); + + await dashboardPanelActions.expectLinkedToLibrary('document example copy 2'); + }); + }); +} diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/canvas.ts b/x-pack/test/functional/apps/maps/group2/embeddable/canvas.ts index 8adab9fa86bb4..ddcbdbea93b65 100644 --- a/x-pack/test/functional/apps/maps/group2/embeddable/canvas.ts +++ b/x-pack/test/functional/apps/maps/group2/embeddable/canvas.ts @@ -9,26 +9,26 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects(['canvas', 'common', 'maps']); + const { canvas, maps } = getPageObjects(['canvas', 'maps']); const retry = getService('retry'); describe('Map embeddable in canvas', () => { before(async () => { - await PageObjects.canvas.goToListingPage(); - await PageObjects.canvas.loadFirstWorkpad('Canvas with map'); + await canvas.goToListingPage(); + await canvas.loadFirstWorkpad('Canvas with map'); }); it('should render map embeddable', async () => { await retry.try(async () => { - const embeddableCount = await PageObjects.canvas.getEmbeddableCount(); + const embeddableCount = await canvas.getEmbeddableCount(); expect(embeddableCount).to.eql(1); }); - await PageObjects.maps.waitForLayersToLoad(); - expect(await PageObjects.maps.doesLayerExist('geo_shapes*')).to.equal(true); + await maps.waitForLayersToLoad(); + expect(await maps.doesLayerExist('geo_shapes*')).to.equal(true); }); it('should not show draw controls', async () => { - await PageObjects.maps.expectMissingToolsControl(); + await maps.expectMissingToolsControl(); }); }); } diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/dashboard.js b/x-pack/test/functional/apps/maps/group2/embeddable/dashboard.ts similarity index 77% rename from x-pack/test/functional/apps/maps/group2/embeddable/dashboard.js rename to x-pack/test/functional/apps/maps/group2/embeddable/dashboard.ts index bdc681e06eece..22065d1d94951 100644 --- a/x-pack/test/functional/apps/maps/group2/embeddable/dashboard.js +++ b/x-pack/test/functional/apps/maps/group2/embeddable/dashboard.ts @@ -7,9 +7,10 @@ import expect from '@kbn/expect'; import { UI_SETTINGS } from '@kbn/data-plugin/common'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; -export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['common', 'dashboard', 'maps']); +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const { dashboard, maps } = getPageObjects(['dashboard', 'maps']); const kibanaServer = getService('kibanaServer'); const filterBar = getService('filterBar'); const dashboardPanelActions = getService('dashboardPanelActions'); @@ -35,9 +36,9 @@ export default function ({ getPageObjects, getService }) { defaultIndex: 'c698b940-e149-11e8-a35a-370a8516603a', [UI_SETTINGS.COURIER_IGNORE_FILTER_IF_FIELD_NOT_IN_INDEX]: true, }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('map embeddable example'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('map embeddable example'); + await dashboard.waitForRenderComplete(); }); after(async () => { @@ -50,21 +51,18 @@ export default function ({ getPageObjects, getService }) { async function getRequestTimestamp() { await inspector.openInspectorRequestsView(); const requestStats = await inspector.getTableData(); - const requestTimestamp = PageObjects.maps.getInspectorStatRowHit( - requestStats, - 'Request timestamp' - ); + const requestTimestamp = maps.getInspectorStatRowHit(requestStats, 'Request timestamp'); await inspector.close(); return requestTimestamp; } it('should set "data-title" attribute', async () => { - const [{ title }] = await PageObjects.dashboard.getPanelSharedItemData(); + const [{ title }] = await dashboard.getPanelSharedItemData(); expect(title).to.be('join example'); }); it('should display tools control', async () => { - await PageObjects.maps.expectExistsToolsControl(); + await maps.expectExistsToolsControl(); }); it('should pass index patterns to container', async () => { @@ -92,7 +90,7 @@ export default function ({ getPageObjects, getService }) { }); it('should apply container state (time, query, filters) to embeddable when loaded', async () => { - const { rawResponse: response } = await PageObjects.maps.getResponseFromDashboardPanel( + const { rawResponse: response } = await maps.getResponseFromDashboardPanel( 'geo grid vector grid example' ); expect(response.aggregations.gridSplit.buckets.length).to.equal(6); @@ -104,21 +102,21 @@ export default function ({ getPageObjects, getService }) { operation: 'is', value: 'win 8', }); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); await filterBar.addFilterAndSelectDataView('meta_for_geo_shapes*', { field: 'shape_name', operation: 'is', value: 'alpha', }); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); - const { rawResponse: gridResponse } = await PageObjects.maps.getResponseFromDashboardPanel( + const { rawResponse: gridResponse } = await maps.getResponseFromDashboardPanel( 'geo grid vector grid example' ); expect(gridResponse.aggregations.gridSplit.buckets.length).to.equal(1); - const { rawResponse: joinResponse } = await PageObjects.maps.getResponseFromDashboardPanel( + const { rawResponse: joinResponse } = await maps.getResponseFromDashboardPanel( 'join example', 'load join metrics (geo_shapes*)' ); @@ -129,15 +127,15 @@ export default function ({ getPageObjects, getService }) { // clear filters from previous test await filterBar.removeAllFilters(); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await dashboardPanelActions.editPanelByTitle('geo grid vector grid example'); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); await filterBar.addFilter({ field: 'machine.os', operation: 'is', value: 'ios' }); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); await testSubjects.click('mapSaveAndReturnButton'); - const { rawResponse: gridResponse } = await PageObjects.maps.getResponseFromDashboardPanel( + const { rawResponse: gridResponse } = await maps.getResponseFromDashboardPanel( 'geo grid vector grid example' ); expect(gridResponse.aggregations.gridSplit.buckets.length).to.equal(2); @@ -146,7 +144,7 @@ export default function ({ getPageObjects, getService }) { it('should re-fetch query when "refresh" is clicked', async () => { await dashboardPanelActions.openInspectorByTitle('geo grid vector grid example'); const beforeQueryRefreshTimestamp = await getRequestTimestamp(); - await PageObjects.maps.refreshQuery(); + await maps.refreshQuery(); await dashboardPanelActions.openInspectorByTitle('geo grid vector grid example'); const afterQueryRefreshTimestamp = await getRequestTimestamp(); expect(beforeQueryRefreshTimestamp).not.to.equal(afterQueryRefreshTimestamp); @@ -156,7 +154,7 @@ export default function ({ getPageObjects, getService }) { await dashboardPanelActions.openInspectorByTitle('geo grid vector grid example'); const beforeRefreshTimerTimestamp = await getRequestTimestamp(); expect(beforeRefreshTimerTimestamp.length).to.be(24); - await PageObjects.maps.triggerSingleRefresh(1000); + await maps.triggerSingleRefresh(1000); await dashboardPanelActions.openInspectorByTitle('geo grid vector grid example'); const afterRefreshTimerTimestamp = await getRequestTimestamp(); expect(beforeRefreshTimerTimestamp).not.to.equal(afterRefreshTimerTimestamp); @@ -164,12 +162,12 @@ export default function ({ getPageObjects, getService }) { // see https://github.com/elastic/kibana/issues/61596 on why it is specific to maps it("dashboard's back button should navigate to previous page", async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('map embeddable example'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('map embeddable example'); + await dashboard.waitForRenderComplete(); await browser.goBack(); - expect(await PageObjects.dashboard.onDashboardLandingPage()).to.be(true); + expect(await dashboard.onDashboardLandingPage()).to.be(true); }); }); } diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/embeddable_library.js b/x-pack/test/functional/apps/maps/group2/embeddable/embeddable_library.js deleted file mode 100644 index a14d80bd080ec..0000000000000 --- a/x-pack/test/functional/apps/maps/group2/embeddable/embeddable_library.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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'; - -export default function ({ getPageObjects, getService }) { - const find = getService('find'); - const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'maps', 'visualize']); - const kibanaServer = getService('kibanaServer'); - const security = getService('security'); - const dashboardAddPanel = getService('dashboardAddPanel'); - const dashboardPanelActions = getService('dashboardPanelActions'); - - describe('maps in embeddable library', () => { - before(async () => { - await security.testUser.setRoles( - [ - 'test_logstash_reader', - 'global_maps_all', - 'geoshape_data_reader', - 'global_dashboard_all', - 'meta_for_geoshape_data_reader', - ], - { skipBrowserRefresh: true } - ); - await kibanaServer.uiSettings.replace({ - defaultIndex: 'c698b940-e149-11e8-a35a-370a8516603a', - }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); - await dashboardAddPanel.clickEditorMenuButton(); - await PageObjects.visualize.clickMapsApp(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - await PageObjects.maps.clickSaveAndReturnButton(); - await PageObjects.dashboard.waitForRenderComplete(); - }); - - after(async () => { - await security.testUser.restoreDefaults(); - }); - - it('save map panel to embeddable library', async () => { - await dashboardPanelActions.saveToLibrary('embeddable library map'); - await testSubjects.existOrFail('addPanelToLibrarySuccess'); - - const mapPanel = await testSubjects.find('embeddablePanelHeading-embeddablelibrarymap'); - const libraryActionExists = await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - mapPanel - ); - expect(libraryActionExists).to.be(true); - }); - - it('unlink map panel from embeddable library', async () => { - const originalPanel = await testSubjects.find('embeddablePanelHeading-embeddablelibrarymap'); - await dashboardPanelActions.unlinkFromLibrary(originalPanel); - await testSubjects.existOrFail('unlinkPanelSuccess'); - - const updatedPanel = await testSubjects.find('embeddablePanelHeading-embeddablelibrarymap'); - const libraryActionExists = await testSubjects.descendantExists( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - updatedPanel - ); - expect(libraryActionExists).to.be(false); - - await dashboardAddPanel.clickOpenAddPanel(); - await dashboardAddPanel.filterEmbeddableNames('embeddable library map'); - await find.existsByLinkText('embeddable library map'); - await dashboardAddPanel.closeAddPanel(); - }); - }); -} diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/embeddable_library.ts b/x-pack/test/functional/apps/maps/group2/embeddable/embeddable_library.ts new file mode 100644 index 0000000000000..94a1974fd2c6a --- /dev/null +++ b/x-pack/test/functional/apps/maps/group2/embeddable/embeddable_library.ts @@ -0,0 +1,68 @@ +/* + * 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 { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const find = getService('find'); + const { dashboard, header, maps, visualize } = getPageObjects([ + 'dashboard', + 'header', + 'maps', + 'visualize', + ]); + const kibanaServer = getService('kibanaServer'); + const security = getService('security'); + const dashboardAddPanel = getService('dashboardAddPanel'); + const dashboardPanelActions = getService('dashboardPanelActions'); + const mapTitle = 'embeddable library map'; + + describe('maps in embeddable library', () => { + before(async () => { + await security.testUser.setRoles( + [ + 'test_logstash_reader', + 'global_maps_all', + 'geoshape_data_reader', + 'global_dashboard_all', + 'meta_for_geoshape_data_reader', + ], + { skipBrowserRefresh: true } + ); + await kibanaServer.uiSettings.replace({ + defaultIndex: 'c698b940-e149-11e8-a35a-370a8516603a', + }); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); + await dashboardAddPanel.clickEditorMenuButton(); + await visualize.clickMapsApp(); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + await maps.clickSaveAndReturnButton(); + await dashboard.waitForRenderComplete(); + }); + + after(async () => { + await security.testUser.restoreDefaults(); + }); + + it('save map panel to embeddable library', async () => { + await dashboardPanelActions.saveToLibrary(mapTitle); + await dashboardPanelActions.expectLinkedToLibrary(mapTitle); + }); + + it('unlink map panel from embeddable library', async () => { + await dashboardPanelActions.unlinkFromLibrary(mapTitle); + await dashboardPanelActions.expectNotLinkedToLibrary(mapTitle); + + await dashboardAddPanel.clickOpenAddPanel(); + await dashboardAddPanel.filterEmbeddableNames(mapTitle); + await find.existsByLinkText(mapTitle); + await dashboardAddPanel.closeAddPanel(); + }); + }); +} diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/embeddable_state.js b/x-pack/test/functional/apps/maps/group2/embeddable/embeddable_state.ts similarity index 69% rename from x-pack/test/functional/apps/maps/group2/embeddable/embeddable_state.js rename to x-pack/test/functional/apps/maps/group2/embeddable/embeddable_state.ts index 036edc77df796..bca237bc99b1a 100644 --- a/x-pack/test/functional/apps/maps/group2/embeddable/embeddable_state.js +++ b/x-pack/test/functional/apps/maps/group2/embeddable/embeddable_state.ts @@ -6,9 +6,10 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; -export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['common', 'dashboard', 'maps']); +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const { dashboard, maps } = getPageObjects(['dashboard', 'maps']); const kibanaServer = getService('kibanaServer'); const security = getService('security'); const dashboardAddPanel = getService('dashboardAddPanel'); @@ -21,13 +22,13 @@ export default function ({ getPageObjects, getService }) { await kibanaServer.uiSettings.replace({ defaultIndex: 'c698b940-e149-11e8-a35a-370a8516603a', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.addEmbeddable('document example', 'map'); - await PageObjects.maps.setView(0.0, 0.0, 10); - await PageObjects.dashboard.saveDashboard(DASHBOARD_NAME); - await PageObjects.dashboard.loadSavedDashboard(DASHBOARD_NAME); + await maps.setView(0.0, 0.0, 10); + await dashboard.saveDashboard(DASHBOARD_NAME); + await dashboard.loadSavedDashboard(DASHBOARD_NAME); }); after(async () => { @@ -35,7 +36,7 @@ export default function ({ getPageObjects, getService }) { }); it('should render map with center and zoom from embeddable state', async () => { - const { lat, lon, zoom } = await PageObjects.maps.getView(); + const { lat, lon, zoom } = await maps.getView(); expect(Math.round(lat)).to.equal(0); expect(Math.round(lon)).to.equal(0); expect(Math.round(zoom)).to.equal(10); diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/filter_by_map_extent.js b/x-pack/test/functional/apps/maps/group2/embeddable/filter_by_map_extent.ts similarity index 67% rename from x-pack/test/functional/apps/maps/group2/embeddable/filter_by_map_extent.js rename to x-pack/test/functional/apps/maps/group2/embeddable/filter_by_map_extent.ts index 45fb47b0eee7c..60ef9b8799d3c 100644 --- a/x-pack/test/functional/apps/maps/group2/embeddable/filter_by_map_extent.js +++ b/x-pack/test/functional/apps/maps/group2/embeddable/filter_by_map_extent.ts @@ -5,10 +5,12 @@ * 2.0. */ +import { FtrProviderContext } from '../../../../ftr_provider_context'; + const FILTER_BY_MAP_EXTENT_DATA_TEST_SUBJ = 'embeddablePanelAction-FILTER_BY_MAP_EXTENT'; -export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'lens', 'maps']); +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const { dashboard, header, lens, maps } = getPageObjects(['dashboard', 'header', 'lens', 'maps']); const browser = getService('browser'); const testSubjects = getService('testSubjects'); @@ -21,10 +23,10 @@ export default function ({ getPageObjects, getService }) { ['test_logstash_reader', 'global_maps_all', 'global_dashboard_all'], { skipBrowserRefresh: true } ); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardEditMode('filter by map extent dashboard'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.navigateToApp(); + await dashboard.gotoDashboardEditMode('filter by map extent dashboard'); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); }); after(async () => { @@ -32,7 +34,7 @@ export default function ({ getPageObjects, getService }) { }); it('should not filter dashboard by map extent before "filter by map extent" is enabled', async () => { - await PageObjects.lens.assertLegacyMetric('Count of records', '6'); + await lens.assertLegacyMetric('Count of records', '6'); }); it('should filter dashboard by map extent when "filter by map extent" is enabled', async () => { @@ -45,15 +47,15 @@ export default function ({ getPageObjects, getService }) { 'check' ); await browser.pressKeys(browser.keys.ESCAPE); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.lens.assertLegacyMetric('Count of records', '1'); + await lens.assertLegacyMetric('Count of records', '1'); }); it('should filter dashboard by new map extent when map is moved', async () => { - await PageObjects.maps.setView(32.95539, -93.93054, 5); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.assertLegacyMetric('Count of records', '2'); + await maps.setView(32.95539, -93.93054, 5); + await header.waitUntilLoadingHasFinished(); + await lens.assertLegacyMetric('Count of records', '2'); }); it('should remove map extent filter dashboard when "filter by map extent" is disabled', async () => { @@ -67,8 +69,8 @@ export default function ({ getPageObjects, getService }) { 'uncheck' ); await browser.pressKeys(browser.keys.ESCAPE); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.lens.assertLegacyMetric('Count of records', '6'); + await header.waitUntilLoadingHasFinished(); + await lens.assertLegacyMetric('Count of records', '6'); }); }); } diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/index.js b/x-pack/test/functional/apps/maps/group2/embeddable/index.ts similarity index 84% rename from x-pack/test/functional/apps/maps/group2/embeddable/index.js rename to x-pack/test/functional/apps/maps/group2/embeddable/index.ts index d07d253943b85..cdfd6cd26697b 100644 --- a/x-pack/test/functional/apps/maps/group2/embeddable/index.js +++ b/x-pack/test/functional/apps/maps/group2/embeddable/index.ts @@ -5,7 +5,9 @@ * 2.0. */ -export default function ({ loadTestFile }) { +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ loadTestFile }: FtrProviderContext) { describe('embeddable', function () { loadTestFile(require.resolve('./canvas')); loadTestFile(require.resolve('./add_to_dashboard')); diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/save_and_return.js b/x-pack/test/functional/apps/maps/group2/embeddable/save_and_return.ts similarity index 65% rename from x-pack/test/functional/apps/maps/group2/embeddable/save_and_return.js rename to x-pack/test/functional/apps/maps/group2/embeddable/save_and_return.ts index 14ff01e4da46f..cf736d53dbe68 100644 --- a/x-pack/test/functional/apps/maps/group2/embeddable/save_and_return.js +++ b/x-pack/test/functional/apps/maps/group2/embeddable/save_and_return.ts @@ -6,15 +6,14 @@ */ import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../ftr_provider_context'; -export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects([ - 'common', +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const { dashboard, header, maps, timePicker } = getPageObjects([ 'dashboard', 'header', 'maps', 'timePicker', - 'visualize', ]); const dashboardAddPanel = getService('dashboardAddPanel'); const dashboardPanelActions = getService('dashboardPanelActions'); @@ -41,30 +40,30 @@ export default function ({ getPageObjects, getService }) { describe('new map', () => { beforeEach(async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.navigateToApp(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickEditorMenuButton(); await dashboardAddPanel.clickVisType('maps'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); }); describe('save', () => { it('should return to dashboard and add new panel', async () => { - await PageObjects.maps.saveMap('map created from dashboard save and return'); - await PageObjects.dashboard.waitForRenderComplete(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + await maps.saveMap('map created from dashboard save and return'); + await dashboard.waitForRenderComplete(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.equal(1); }); }); describe('save and uncheck return to origin switch', () => { it('should cut the originator and stay in maps application', async () => { - await PageObjects.maps.saveMap( + await maps.saveMap( 'map created from dashboard save and return with originator app cut', false ); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); await testSubjects.missingOrFail('mapSaveAndReturnButton'); await testSubjects.existOrFail('mapSaveButton'); }); @@ -73,34 +72,34 @@ export default function ({ getPageObjects, getService }) { describe('edit existing map', () => { beforeEach(async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('map embeddable example'); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('map embeddable example'); + await dashboard.switchToEditMode(); await dashboardPanelActions.editPanelByTitle('join example'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); }); describe('save and return', () => { it('should use dashboard instead of time stored in map state', async () => { // join example map's time is "last 17 minutes" // ensure map has dashboard time - const timeConfig = await PageObjects.timePicker.getTimeConfig(); + const timeConfig = await timePicker.getTimeConfig(); expect(timeConfig.start).to.equal('Sep 20, 2015 @ 00:00:00.000'); expect(timeConfig.end).to.equal('Sep 20, 2015 @ 01:00:00.000'); }); it('should return to dashboard', async () => { - await PageObjects.maps.clickSaveAndReturnButton(); - await PageObjects.dashboard.waitForRenderComplete(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + await maps.clickSaveAndReturnButton(); + await dashboard.waitForRenderComplete(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.equal(2); }); it('should lose its connection to the dashboard when creating new map', async () => { - await PageObjects.maps.gotoMapListingPage(); - await PageObjects.maps.openNewMap(); - await PageObjects.maps.expectMissingSaveAndReturnButton(); + await maps.gotoMapListingPage(); + await maps.openNewMap(); + await maps.expectMissingSaveAndReturnButton(); // return to origin should not be present in save modal await testSubjects.click('mapSaveButton'); @@ -113,17 +112,17 @@ export default function ({ getPageObjects, getService }) { describe('save as', () => { it('should return to dashboard and add new panel', async () => { - await PageObjects.maps.saveMap('Clone of map embeddable example'); - await PageObjects.header.waitUntilLoadingHasFinished(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + await maps.saveMap('Clone of map embeddable example'); + await header.waitUntilLoadingHasFinished(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.equal(3); }); }); describe('save as and uncheck return to origin switch', () => { it('should cut the originator and stay in maps application', async () => { - await PageObjects.maps.saveMap('Clone 2 of map embeddable example', false); - await PageObjects.maps.waitForLayersToLoad(); + await maps.saveMap('Clone 2 of map embeddable example', false); + await maps.waitForLayersToLoad(); await testSubjects.missingOrFail('mapSaveAndReturnButton'); await testSubjects.existOrFail('mapSaveButton'); }); diff --git a/x-pack/test/functional/apps/maps/group2/embeddable/tooltip_filter_actions.js b/x-pack/test/functional/apps/maps/group2/embeddable/tooltip_filter_actions.ts similarity index 78% rename from x-pack/test/functional/apps/maps/group2/embeddable/tooltip_filter_actions.js rename to x-pack/test/functional/apps/maps/group2/embeddable/tooltip_filter_actions.ts index e7265f4d7883d..88866082510cf 100644 --- a/x-pack/test/functional/apps/maps/group2/embeddable/tooltip_filter_actions.js +++ b/x-pack/test/functional/apps/maps/group2/embeddable/tooltip_filter_actions.ts @@ -6,9 +6,15 @@ */ import expect from '@kbn/expect'; - -export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['common', 'dashboard', 'discover', 'header', 'maps']); +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const { dashboard, discover, header, maps } = getPageObjects([ + 'dashboard', + 'discover', + 'header', + 'maps', + ]); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); const filterBar = getService('filterBar'); @@ -30,11 +36,11 @@ export default function ({ getPageObjects, getService }) { defaultIndex: 'c698b940-e149-11e8-a35a-370a8516603a', }); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.dashboard.loadSavedDashboard('dash for tooltip filter action test'); + await dashboard.navigateToApp(); + await dashboard.preserveCrossAppState(); + await dashboard.loadSavedDashboard('dash for tooltip filter action test'); - await PageObjects.maps.lockTooltipAtPosition(200, -200); + await maps.lockTooltipAtPosition(200, -200); } after(async () => { @@ -53,8 +59,8 @@ export default function ({ getPageObjects, getService }) { it('should create filters when create filter button is clicked', async () => { await testSubjects.click('mapTooltipCreateFilterButton'); - await PageObjects.header.awaitGlobalLoadingIndicatorHidden(); - await PageObjects.maps.waitForLayersToLoadMinimizedLayerControl(); + await header.awaitGlobalLoadingIndicatorHidden(); + await maps.waitForLayersToLoadMinimizedLayerControl(); const numFilters = await filterBar.getFilterCount(); expect(numFilters).to.be(1); @@ -74,8 +80,8 @@ export default function ({ getPageObjects, getService }) { await testSubjects.click('mapFilterActionButton__drilldown1'); // Assert on new dashboard with filter from action - await PageObjects.dashboard.waitForRenderComplete(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + await dashboard.waitForRenderComplete(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.equal(2); const hasJoinFilter = await filterBar.hasFilter('runtime_shape_name', 'charlie'); @@ -87,7 +93,7 @@ export default function ({ getPageObjects, getService }) { await testSubjects.click('mapFilterActionButton__urlDrilldownToDiscover'); // Assert on discover with filter from action - await PageObjects.discover.waitForDiscoverAppOnScreen(); + await discover.waitForDiscoverAppOnScreen(); const hasFilter = await filterBar.hasFilter('name', 'charlie'); expect(hasFilter).to.be(true); }); diff --git a/x-pack/test/functional/apps/maps/group2/es_geo_grid_source.js b/x-pack/test/functional/apps/maps/group2/es_geo_grid_source.ts similarity index 63% rename from x-pack/test/functional/apps/maps/group2/es_geo_grid_source.js rename to x-pack/test/functional/apps/maps/group2/es_geo_grid_source.ts index d2440a5dd706b..b76c7031e3dd0 100644 --- a/x-pack/test/functional/apps/maps/group2/es_geo_grid_source.js +++ b/x-pack/test/functional/apps/maps/group2/es_geo_grid_source.ts @@ -6,9 +6,11 @@ */ import expect from '@kbn/expect'; +import { Feature } from 'geojson'; +import { FtrProviderContext } from '../../../ftr_provider_context'; -export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const { maps } = getPageObjects(['maps']); const inspector = getService('inspector'); const DOC_COUNT_PROP_NAME = 'doc_count'; const security = getService('security'); @@ -32,42 +34,39 @@ export default function ({ getPageObjects, getService }) { await inspector.open(); await inspector.openInspectorRequestsView(); const requestStats = await inspector.getTableData(); - const requestTimestamp = PageObjects.maps.getInspectorStatRowHit( - requestStats, - 'Request timestamp' - ); + const requestTimestamp = maps.getInspectorStatRowHit(requestStats, 'Request timestamp'); await inspector.close(); return requestTimestamp; } function makeRequestTestsForGeoPrecision( - LAYER_ID, - expectedNumFeaturesZoomedOut, - expectedNumPartialFeatures + layerID: string, + expectedNumFeaturesZoomedOut: number, + expectedNumPartialFeatures: number ) { describe('geoprecision - requests', () => { - let beforeTimestamp; + let beforeTimestamp = ''; beforeEach(async () => { - await PageObjects.maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 1); + await maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 1); beforeTimestamp = await getRequestTimestamp(); }); it('should not rerequest when pan changes do not move map view area outside of buffer', async () => { - await PageObjects.maps.setView(DATA_CENTER_LAT + 1, DATA_CENTER_LON + 1, 1); + await maps.setView(DATA_CENTER_LAT + 1, DATA_CENTER_LON + 1, 1); const afterTimestamp = await getRequestTimestamp(); expect(afterTimestamp).to.equal(beforeTimestamp); }); it('should not rerequest when zoom changes do not cause geotile_grid precision to change', async () => { - await PageObjects.maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 1.4); + await maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 1.4); const beforeSameZoom = await getRequestTimestamp(); - await PageObjects.maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 1.6); + await maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 1.6); const afterTimestamp = await getRequestTimestamp(); expect(afterTimestamp).to.equal(beforeSameZoom); }); it('should rerequest when zoom changes causes the geotile_grid precision to change', async () => { - await PageObjects.maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 4); + await maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 4); const afterTimestamp = await getRequestTimestamp(); expect(afterTimestamp).not.to.equal(beforeTimestamp); }); @@ -75,27 +74,27 @@ export default function ({ getPageObjects, getService }) { describe('geotile grid precision - data', () => { beforeEach(async () => { - await PageObjects.maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 1); + await maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 1); }); it('should not return any data when the extent does not cover the data bounds', async () => { - await PageObjects.maps.setView(64, 179, 5); - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); - expect(mapboxStyle.sources[LAYER_ID].data.features.length).to.equal(0); + await maps.setView(64, 179, 5); + const mapboxStyle = await maps.getMapboxStyle(); + expect(mapboxStyle.sources[layerID].data.features.length).to.equal(0); }); it('should request the data when the map covers the databounds', async () => { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); - expect(mapboxStyle.sources[LAYER_ID].data.features.length).to.equal( + const mapboxStyle = await maps.getMapboxStyle(); + expect(mapboxStyle.sources[layerID].data.features.length).to.equal( expectedNumFeaturesZoomedOut ); }); it('should request only partial data when the map only covers part of the databounds', async () => { - //todo this verifies the extent-filtering behavior (not really the correct application of geotile_grid-precision), and should ideally be moved to its own section - await PageObjects.maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 6); - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); - expect(mapboxStyle.sources[LAYER_ID].data.features.length).to.equal( + // todo this verifies the extent-filtering behavior (not really the correct application of geotile_grid-precision), and should ideally be moved to its own section + await maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 6); + const mapboxStyle = await maps.getMapboxStyle(); + expect(mapboxStyle.sources[layerID].data.features.length).to.equal( expectedNumPartialFeatures ); }); @@ -104,7 +103,7 @@ export default function ({ getPageObjects, getService }) { describe('geo_point', () => { before(async () => { - await PageObjects.maps.loadSavedMap('geo grid vector grid example'); + await maps.loadSavedMap('geo grid vector grid example'); }); const LAYER_ID = 'g1xkv'; @@ -114,35 +113,37 @@ export default function ({ getPageObjects, getService }) { it('should re-fetch geotile_grid aggregation with refresh timer', async () => { const beforeRefreshTimerTimestamp = await getRequestTimestamp(); expect(beforeRefreshTimerTimestamp.length).to.be(24); - await PageObjects.maps.triggerSingleRefresh(1000); + await maps.triggerSingleRefresh(1000); const afterRefreshTimerTimestamp = await getRequestTimestamp(); expect(beforeRefreshTimerTimestamp).not.to.equal(afterRefreshTimerTimestamp); }); it('should decorate feature properties with metrics properterties', async () => { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + const mapboxStyle = await maps.getMapboxStyle(); expect(mapboxStyle.sources[LAYER_ID].data.features.length).to.equal(12); - mapboxStyle.sources[LAYER_ID].data.features.forEach(({ properties }) => { - expect(Object.hasOwn(properties, MAX_OF_BYTES_PROP_NAME)).to.be(true); - expect(Object.hasOwn(properties, DOC_COUNT_PROP_NAME)).to.be(true); - }); + mapboxStyle.sources[LAYER_ID].data.features.forEach( + ({ properties }: Feature) => { + expect(Object.hasOwn(properties, MAX_OF_BYTES_PROP_NAME)).to.be(true); + expect(Object.hasOwn(properties, DOC_COUNT_PROP_NAME)).to.be(true); + } + ); }); makeRequestTestsForGeoPrecision(LAYER_ID, 8, 4); describe('query bar', () => { before(async () => { - await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "win 8"'); - await PageObjects.maps.setView(0, 0, 0); + await maps.setAndSubmitQuery('machine.os.raw : "win 8"'); + await maps.setView(0, 0, 0); }); after(async () => { - await PageObjects.maps.setAndSubmitQuery(''); + await maps.setAndSubmitQuery(''); }); it('should apply query to geotile_grid aggregation request', async () => { - const { rawResponse: response } = await PageObjects.maps.getResponse(); + const { rawResponse: response } = await maps.getResponse(); expect(response.aggregations.gridSplit.buckets.length).to.equal(1); }); }); @@ -153,13 +154,13 @@ export default function ({ getPageObjects, getService }) { }); it('should contain geotile_grid aggregation elasticsearch request', async () => { - const { rawResponse: response } = await PageObjects.maps.getResponse(); + const { rawResponse: response } = await maps.getResponse(); expect(response.aggregations.gridSplit.buckets.length).to.equal(4); }); it('should not contain any elasticsearch request after layer is deleted', async () => { - await PageObjects.maps.removeLayer('logstash-*'); - const noRequests = await PageObjects.maps.doesInspectorHaveRequests(); + await maps.removeLayer('logstash-*'); + const noRequests = await maps.doesInspectorHaveRequests(); expect(noRequests).to.equal(true); }); }); @@ -167,12 +168,12 @@ export default function ({ getPageObjects, getService }) { describe('geo_shape', () => { before(async () => { - await PageObjects.maps.loadSavedMap('geo grid vector grid example with shape'); + await maps.loadSavedMap('geo grid vector grid example with shape'); }); const LAYER_ID = 'g1xkv'; it('should get expected number of grid cells', async () => { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + const mapboxStyle = await maps.getMapboxStyle(); expect(mapboxStyle.sources[LAYER_ID].data.features.length).to.equal(26); }); @@ -182,7 +183,7 @@ export default function ({ getPageObjects, getService }) { }); it('should contain geotile_grid aggregation elasticsearch request', async () => { - const { rawResponse: response } = await PageObjects.maps.getResponse(); + const { rawResponse: response } = await maps.getResponse(); expect(response.aggregations.gridSplit.buckets.length).to.equal(13); }); }); diff --git a/x-pack/test/functional/apps/maps/group2/index.js b/x-pack/test/functional/apps/maps/group2/index.ts similarity index 94% rename from x-pack/test/functional/apps/maps/group2/index.js rename to x-pack/test/functional/apps/maps/group2/index.ts index c2130f4587041..fc4543aa756f6 100644 --- a/x-pack/test/functional/apps/maps/group2/index.js +++ b/x-pack/test/functional/apps/maps/group2/index.ts @@ -5,7 +5,9 @@ * 2.0. */ -export default function ({ loadTestFile, getService }) { +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ loadTestFile, getService }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const esArchiver = getService('esArchiver'); const browser = getService('browser'); diff --git a/x-pack/test/functional/apps/maps/group2/multiple_data_views.ts b/x-pack/test/functional/apps/maps/group2/multiple_data_views.ts index facc97a0b46cd..6dc54085bf8cf 100644 --- a/x-pack/test/functional/apps/maps/group2/multiple_data_views.ts +++ b/x-pack/test/functional/apps/maps/group2/multiple_data_views.ts @@ -13,21 +13,21 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const filterBar = getService('filterBar'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'maps']); + const { common, maps } = getPageObjects(['common', 'maps']); describe('maps with multiple data views', () => { const mapTitle = 'map with multiple data views'; const createLayerForDataView = async (dataView: string) => { - await PageObjects.maps.clickAddLayer(); + await maps.clickAddLayer(); await testSubjects.click('documents'); - await PageObjects.maps.selectGeoIndexPatternLayer(dataView); + await maps.selectGeoIndexPatternLayer(dataView); await testSubjects.click('importFileButton'); await testSubjects.click('layerPanelCancelButton'); }; before(async () => { - await PageObjects.common.setTime({ + await common.setTime({ from: 'Oct 23, 2018 @ 07:00:00.000', to: 'Oct 23, 2018 @ 08:00:00.000', }); @@ -43,7 +43,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ); await kibanaServer.uiSettings.update({ 'courier:ignoreFilterIfFieldNotInIndex': true }); - await PageObjects.maps.openNewMap(); + await maps.openNewMap(); }); after(async () => { @@ -65,34 +65,34 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { // Flights layer await createLayerForDataView('kibana_sample_data_flights'); - expect(await PageObjects.maps.getNumberOfLayers()).to.be(3); - expect(await PageObjects.maps.getLayerTocTooltipMsg('kibana_sample_data_flights')).to.equal( + expect(await maps.getNumberOfLayers()).to.be(3); + expect(await maps.getLayerTocTooltipMsg('kibana_sample_data_flights')).to.equal( 'kibana_sample_data_flights\nFound 9 documents.\nResults narrowed by global time' ); - expect(await PageObjects.maps.getLayerTocTooltipMsg('long-window-logstash-*')).to.equal( + expect(await maps.getLayerTocTooltipMsg('long-window-logstash-*')).to.equal( 'long-window-logstash-*\nFound 2 documents.\nResults narrowed by global time' ); }); it('ignores global filters on layers using a data view without the filter field by default', async () => { await filterBar.addFilter({ field: '@message', operation: 'exists' }); - expect(await PageObjects.maps.getLayerTocTooltipMsg('kibana_sample_data_flights')).to.equal( + expect(await maps.getLayerTocTooltipMsg('kibana_sample_data_flights')).to.equal( 'kibana_sample_data_flights\nFound 9 documents.\nResults narrowed by global search\nResults narrowed by global time' ); - expect(await PageObjects.maps.getLayerTocTooltipMsg('long-window-logstash-*')).to.equal( + expect(await maps.getLayerTocTooltipMsg('long-window-logstash-*')).to.equal( 'long-window-logstash-*\nFound 2 documents.\nResults narrowed by global search\nResults narrowed by global time' ); - await PageObjects.maps.saveMap(mapTitle); + await maps.saveMap(mapTitle); }); it('applies global filters on layers using data view a without the filter field', async () => { await kibanaServer.uiSettings.update({ 'courier:ignoreFilterIfFieldNotInIndex': false }); - await PageObjects.maps.loadSavedMap(mapTitle); - expect(await PageObjects.maps.getLayerTocTooltipMsg('kibana_sample_data_flights')).to.equal( + await maps.loadSavedMap(mapTitle); + expect(await maps.getLayerTocTooltipMsg('kibana_sample_data_flights')).to.equal( 'kibana_sample_data_flights\nNo results found.\nResults narrowed by global search\nResults narrowed by global time' ); - expect(await PageObjects.maps.getLayerTocTooltipMsg('long-window-logstash-*')).to.equal( + expect(await maps.getLayerTocTooltipMsg('long-window-logstash-*')).to.equal( 'long-window-logstash-*\nFound 2 documents.\nResults narrowed by global search\nResults narrowed by global time' ); }); diff --git a/x-pack/test/functional/apps/maps/group3/reports/index.ts b/x-pack/test/functional/apps/maps/group3/reports/index.ts index 172a9cfba1add..dbef00501aa70 100644 --- a/x-pack/test/functional/apps/maps/group3/reports/index.ts +++ b/x-pack/test/functional/apps/maps/group3/reports/index.ts @@ -11,12 +11,12 @@ import { FtrProviderContext } from '../../../../ftr_provider_context'; const REPORTS_FOLDER = __dirname; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects(['reporting', 'common', 'dashboard']); + const { reporting, dashboard } = getPageObjects(['reporting', 'dashboard']); const testSubjects = getService('testSubjects'); const browser = getService('browser'); const config = getService('config'); const log = getService('log'); - const reporting = getService('reporting'); + const reportingService = getService('reporting'); const png = getService('png'); // NOTE: Occasionally, you may need to run the test and copy the "session" image file and replace the @@ -25,10 +25,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('dashboard reporting: creates a map report', () => { // helper function to check the difference between the new image and the baseline const measurePngDifference = async (fileName: string) => { - const url = await PageObjects.reporting.getReportURL(60000); - const reportData = await PageObjects.reporting.getRawReportData(url ?? ''); + const url = await reporting.getReportURL(60000); + const reportData = await reporting.getRawReportData(url ?? ''); - const sessionReportPath = await PageObjects.reporting.writeSessionReport( + const sessionReportPath = await reporting.writeSessionReport( fileName, 'png', reportData, @@ -36,11 +36,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ); expect(sessionReportPath).not.to.be(null); - const baselineReportPath = PageObjects.reporting.getBaselineReportPath( - fileName, - 'png', - REPORTS_FOLDER - ); + const baselineReportPath = reporting.getBaselineReportPath(fileName, 'png', REPORTS_FOLDER); log.debug(`session report path: ${sessionReportPath}`); log.debug(`baseline report path: ${baselineReportPath}`); @@ -56,30 +52,30 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); after(async () => { - await reporting.deleteAllReports(); + await reportingService.deleteAllReports(); }); it('PNG file matches the baseline image, using sample geo data', async function () { - await reporting.initEcommerce(); + await reportingService.initEcommerce(); - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('Ecommerce Map'); - await PageObjects.reporting.openExportTab(); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('Ecommerce Map'); + await reporting.openExportTab(); await testSubjects.click('pngV2-radioOption'); - await PageObjects.reporting.clickGenerateReportButton(); + await reporting.clickGenerateReportButton(); const percentDiff = await measurePngDifference('geo_map_report'); expect(percentDiff).to.be.lessThan(0.03); - await reporting.teardownEcommerce(); + await reportingService.teardownEcommerce(); }); it('PNG file matches the baseline image, using embeddable example', async function () { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('map embeddable example'); - await PageObjects.reporting.openExportTab(); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('map embeddable example'); + await reporting.openExportTab(); await testSubjects.click('pngV2-radioOption'); - await PageObjects.reporting.clickGenerateReportButton(); + await reporting.clickGenerateReportButton(); const percentDiff = await measurePngDifference('example_map_report'); expect(percentDiff).to.be.lessThan(0.03); diff --git a/x-pack/test/functional/apps/maps/group4/add_layer_panel.js b/x-pack/test/functional/apps/maps/group4/add_layer_panel.js index b11694679e172..a85857180187c 100644 --- a/x-pack/test/functional/apps/maps/group4/add_layer_panel.js +++ b/x-pack/test/functional/apps/maps/group4/add_layer_panel.js @@ -9,16 +9,16 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const security = getService('security'); describe('Add layer panel', () => { before(async () => { await security.testUser.setRoles(['global_maps_all', 'test_logstash_reader']); - await PageObjects.maps.openNewMap(); - await PageObjects.maps.clickAddLayer(); - await PageObjects.maps.selectDocumentsSource(); - await PageObjects.maps.selectGeoIndexPatternLayer('logstash-*'); + await maps.openNewMap(); + await maps.clickAddLayer(); + await maps.selectDocumentsSource(); + await maps.selectGeoIndexPatternLayer('logstash-*'); }); after(async () => { @@ -26,7 +26,7 @@ export default function ({ getService, getPageObjects }) { }); it('should show unsaved layer in layer TOC', async () => { - const vectorLayerExists = await PageObjects.maps.doesLayerExist('logstash-*'); + const vectorLayerExists = await maps.doesLayerExist('logstash-*'); expect(vectorLayerExists).to.be(true); }); @@ -37,9 +37,9 @@ export default function ({ getService, getPageObjects }) { }); it('should remove layer on cancel', async () => { - await PageObjects.maps.cancelLayerAdd('logstash-*'); + await maps.cancelLayerAdd('logstash-*'); - const vectorLayerExists = await PageObjects.maps.doesLayerExist('logstash-*'); + const vectorLayerExists = await maps.doesLayerExist('logstash-*'); expect(vectorLayerExists).to.be(false); }); }); diff --git a/x-pack/test/functional/apps/maps/group4/discover.js b/x-pack/test/functional/apps/maps/group4/discover.js index 94515e2feb87f..5eddaabaffe42 100644 --- a/x-pack/test/functional/apps/maps/group4/discover.js +++ b/x-pack/test/functional/apps/maps/group4/discover.js @@ -9,12 +9,11 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { const queryBar = getService('queryBar'); - const PageObjects = getPageObjects([ + const { common, discover, header, maps, unifiedFieldList } = getPageObjects([ 'common', 'discover', 'header', 'maps', - 'timePicker', 'unifiedFieldList', ]); const security = getService('security'); @@ -30,44 +29,44 @@ export default function ({ getService, getPageObjects }) { 'global_discover_read', 'global_visualize_read', ]); - await PageObjects.common.setTime({ from, to }); - await PageObjects.common.navigateToApp('discover'); + await common.setTime({ from, to }); + await common.navigateToApp('discover'); }); after(async () => { await security.testUser.restoreDefaults(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('should link geo_shape fields to Maps application', async () => { - await PageObjects.discover.selectIndexPattern('geo_shapes*'); - await PageObjects.unifiedFieldList.clickFieldListItemVisualize('geometry'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - const doesLayerExist = await PageObjects.maps.doesLayerExist('geo_shapes*'); + await discover.selectIndexPattern('geo_shapes*'); + await unifiedFieldList.clickFieldListItemVisualize('geometry'); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + const doesLayerExist = await maps.doesLayerExist('geo_shapes*'); expect(doesLayerExist).to.equal(true); - const tooltipText = await PageObjects.maps.getLayerTocTooltipMsg('geo_shapes*'); + const tooltipText = await maps.getLayerTocTooltipMsg('geo_shapes*'); expect(tooltipText).to.equal('geo_shapes*\nFound ~8 documents. This count is approximate.'); - await PageObjects.maps.refreshAndClearUnsavedChangesWarning(); + await maps.refreshAndClearUnsavedChangesWarning(); }); it('should link geo_point fields to Maps application with time and query context', async () => { - await PageObjects.discover.selectIndexPattern('logstash-*'); + await discover.selectIndexPattern('logstash-*'); await queryBar.setQuery('machine.os.raw : "ios"'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemVisualize('geo.coordinates'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - const doesLayerExist = await PageObjects.maps.doesLayerExist('logstash-*'); + await unifiedFieldList.clickFieldListItemVisualize('geo.coordinates'); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + const doesLayerExist = await maps.doesLayerExist('logstash-*'); expect(doesLayerExist).to.equal(true); - const tooltipText = await PageObjects.maps.getLayerTocTooltipMsg('logstash-*'); + const tooltipText = await maps.getLayerTocTooltipMsg('logstash-*'); expect(tooltipText).to.equal( 'logstash-*\nFound 7 documents.\nResults narrowed by global search\nResults narrowed by global time' ); - await PageObjects.maps.refreshAndClearUnsavedChangesWarning(); + await maps.refreshAndClearUnsavedChangesWarning(); }); }); } diff --git a/x-pack/test/functional/apps/maps/group4/es_pew_pew_source.js b/x-pack/test/functional/apps/maps/group4/es_pew_pew_source.js index ea94ee3bc67d8..2350eca7c7ea6 100644 --- a/x-pack/test/functional/apps/maps/group4/es_pew_pew_source.js +++ b/x-pack/test/functional/apps/maps/group4/es_pew_pew_source.js @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const security = getService('security'); const VECTOR_SOURCE_ID = '67c1de2c-2fc5-4425-8983-094b589afe61'; @@ -16,7 +16,7 @@ export default function ({ getPageObjects, getService }) { describe('point to point source', () => { before(async () => { await security.testUser.setRoles(['global_maps_all', 'geoconnections_data_reader']); - await PageObjects.maps.loadSavedMap('pew pew demo'); + await maps.loadSavedMap('pew pew demo'); }); after(async () => { @@ -24,12 +24,12 @@ export default function ({ getPageObjects, getService }) { }); it('should request source clusters for destination locations', async () => { - const { rawResponse: response } = await PageObjects.maps.getResponse(); + const { rawResponse: response } = await maps.getResponse(); expect(response.aggregations.destSplit.buckets.length).to.equal(2); }); it('should render lines', async () => { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + const mapboxStyle = await maps.getMapboxStyle(); const features = mapboxStyle.sources[VECTOR_SOURCE_ID].data.features; expect(features.length).to.equal(4); expect(features[0].geometry.type).to.equal('LineString'); @@ -37,9 +37,9 @@ export default function ({ getPageObjects, getService }) { it('should fit to bounds', async () => { // Set view to other side of world so no matching results - await PageObjects.maps.setView(-70, 0, 6); - await PageObjects.maps.clickFitToBounds('connections'); - const { lat, lon } = await PageObjects.maps.getView(); + await maps.setView(-70, 0, 6); + await maps.clickFitToBounds('connections'); + const { lat, lon } = await maps.getView(); expect(Math.round(lat)).to.equal(41); expect(Math.round(lon)).to.equal(-70); }); diff --git a/x-pack/test/functional/apps/maps/group4/file_upload/geojson.js b/x-pack/test/functional/apps/maps/group4/file_upload/geojson.js index 744235a023d3c..5b722444ceb89 100644 --- a/x-pack/test/functional/apps/maps/group4/file_upload/geojson.js +++ b/x-pack/test/functional/apps/maps/group4/file_upload/geojson.js @@ -10,7 +10,7 @@ import path from 'path'; import { v4 as uuidv4 } from 'uuid'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['geoFileUpload', 'maps']); + const { geoFileUpload, maps } = getPageObjects(['geoFileUpload', 'maps']); const security = getService('security'); const retry = getService('retry'); @@ -22,7 +22,7 @@ export default function ({ getPageObjects, getService }) { 'geoall_data_writer', 'global_index_pattern_management_all', ]); - await PageObjects.maps.openNewMap(); + await maps.openNewMap(); }); after(async () => { @@ -30,39 +30,39 @@ export default function ({ getPageObjects, getService }) { }); it('should preview part of geojson file', async () => { - await PageObjects.maps.clickAddLayer(); - await PageObjects.maps.selectFileUploadCard(); - await PageObjects.geoFileUpload.previewGeoJsonFile( + await maps.clickAddLayer(); + await maps.selectFileUploadCard(); + await geoFileUpload.previewGeoJsonFile( path.join(__dirname, 'files', 'world_countries_v7.geo.json') ); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); - const numberOfLayers = await PageObjects.maps.getNumberOfLayers(); + const numberOfLayers = await maps.getNumberOfLayers(); expect(numberOfLayers).to.be(2); - const tooltipText = await PageObjects.maps.getLayerTocTooltipMsg('world_countries_v7'); + const tooltipText = await maps.getLayerTocTooltipMsg('world_countries_v7'); expect(tooltipText).to.be('world_countries_v7\nResults limited to 76 features, 41% of file.'); }); it('should import geojson', async () => { indexName = uuidv4(); - await PageObjects.geoFileUpload.setIndexName(indexName); - await PageObjects.geoFileUpload.uploadFile(); + await geoFileUpload.setIndexName(indexName); + await geoFileUpload.uploadFile(); - const statusText = await PageObjects.geoFileUpload.getFileUploadStatusCalloutMsg(); + const statusText = await geoFileUpload.getFileUploadStatusCalloutMsg(); expect(statusText).to.be('File upload complete\nIndexed 250 features.'); }); it('should add as document layer', async () => { - await PageObjects.geoFileUpload.addFileAsDocumentLayer(); - await PageObjects.maps.waitForLayersToLoad(); + await geoFileUpload.addFileAsDocumentLayer(); + await maps.waitForLayersToLoad(); - const numberOfLayers = await PageObjects.maps.getNumberOfLayers(); + const numberOfLayers = await maps.getNumberOfLayers(); expect(numberOfLayers).to.be(2); await retry.try(async () => { - await PageObjects.maps.waitForLayersToLoad(); - const tooltipText = await PageObjects.maps.getLayerTocTooltipMsg(indexName); + await maps.waitForLayersToLoad(); + const tooltipText = await maps.getLayerTocTooltipMsg(indexName); expect(tooltipText).to.be(`${indexName}\nFound ~281 documents. This count is approximate.`); }); }); diff --git a/x-pack/test/functional/apps/maps/group4/file_upload/shapefile.js b/x-pack/test/functional/apps/maps/group4/file_upload/shapefile.js index c57a4ad69b9b5..c1d40776df94f 100644 --- a/x-pack/test/functional/apps/maps/group4/file_upload/shapefile.js +++ b/x-pack/test/functional/apps/maps/group4/file_upload/shapefile.js @@ -10,7 +10,7 @@ import path from 'path'; import { v4 as uuidv4 } from 'uuid'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['geoFileUpload', 'maps']); + const { geoFileUpload, maps } = getPageObjects(['geoFileUpload', 'maps']); const security = getService('security'); const retry = getService('retry'); @@ -22,7 +22,7 @@ export default function ({ getPageObjects, getService }) { 'geoall_data_writer', 'global_index_pattern_management_all', ]); - await PageObjects.maps.openNewMap(); + await maps.openNewMap(); }); after(async () => { @@ -30,20 +30,20 @@ export default function ({ getPageObjects, getService }) { }); it('should preview part of shapefile', async () => { - await PageObjects.maps.clickAddLayer(); - await PageObjects.maps.selectFileUploadCard(); - await PageObjects.geoFileUpload.previewShapefile( + await maps.clickAddLayer(); + await maps.selectFileUploadCard(); + await geoFileUpload.previewShapefile( path.join(__dirname, 'files', 'cb_2018_us_csa_500k.shp') ); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); - const numberOfLayers = await PageObjects.maps.getNumberOfLayers(); + const numberOfLayers = await maps.getNumberOfLayers(); expect(numberOfLayers).to.be(2); // preview text is inconsistent. Skip expect for now // https://github.com/elastic/kibana/issues/124334 /* - const tooltipText = await PageObjects.maps.getLayerTocTooltipMsg('cb_2018_us_csa_500k'); + const tooltipText = await maps.getLayerTocTooltipMsg('cb_2018_us_csa_500k'); expect(tooltipText).to.be( 'cb_2018_us_csa_500k\nResults limited to 141 features, 81% of file.' ); @@ -52,23 +52,23 @@ export default function ({ getPageObjects, getService }) { it('should import shapefile', async () => { indexName = uuidv4(); - await PageObjects.geoFileUpload.setIndexName(indexName); - await PageObjects.geoFileUpload.uploadFile(); + await geoFileUpload.setIndexName(indexName); + await geoFileUpload.uploadFile(); - const statusText = await PageObjects.geoFileUpload.getFileUploadStatusCalloutMsg(); + const statusText = await geoFileUpload.getFileUploadStatusCalloutMsg(); expect(statusText).to.be('File upload complete\nIndexed 174 features.'); }); it('should add as document layer', async () => { - await PageObjects.geoFileUpload.addFileAsDocumentLayer(); - await PageObjects.maps.waitForLayersToLoad(); + await geoFileUpload.addFileAsDocumentLayer(); + await maps.waitForLayersToLoad(); - const numberOfLayers = await PageObjects.maps.getNumberOfLayers(); + const numberOfLayers = await maps.getNumberOfLayers(); expect(numberOfLayers).to.be(2); await retry.try(async () => { - await PageObjects.maps.waitForLayersToLoad(); - const tooltipText = await PageObjects.maps.getLayerTocTooltipMsg(indexName); + await maps.waitForLayersToLoad(); + const tooltipText = await maps.getLayerTocTooltipMsg(indexName); expect(tooltipText).to.be(`${indexName}\nFound 174 documents.`); }); }); diff --git a/x-pack/test/functional/apps/maps/group4/file_upload/wizard.js b/x-pack/test/functional/apps/maps/group4/file_upload/wizard.js index 4ce63e9721d31..69c0741865c5d 100644 --- a/x-pack/test/functional/apps/maps/group4/file_upload/wizard.js +++ b/x-pack/test/functional/apps/maps/group4/file_upload/wizard.js @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import path from 'path'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['geoFileUpload', 'maps']); + const { geoFileUpload, maps } = getPageObjects(['geoFileUpload', 'maps']); const security = getService('security'); const retry = getService('retry'); @@ -29,60 +29,56 @@ export default function ({ getPageObjects, getService }) { // describe block is testing a workflow and individual tests are not designed to be run out of order describe('preview layer workflow', () => { before(async () => { - await PageObjects.maps.openNewMap(); - await PageObjects.maps.clickAddLayer(); - await PageObjects.maps.selectFileUploadCard(); - await PageObjects.geoFileUpload.previewGeoJsonFile( - path.join(__dirname, 'files', 'point.json') - ); - await PageObjects.maps.waitForLayersToLoad(); + await maps.openNewMap(); + await maps.clickAddLayer(); + await maps.selectFileUploadCard(); + await geoFileUpload.previewGeoJsonFile(path.join(__dirname, 'files', 'point.json')); + await maps.waitForLayersToLoad(); }); it('should add preview layer to map', async () => { - const numberOfLayers = await PageObjects.maps.getNumberOfLayers(); + const numberOfLayers = await maps.getNumberOfLayers(); expect(numberOfLayers).to.be(2); - const hasLayer = await PageObjects.maps.doesLayerExist('point'); + const hasLayer = await maps.doesLayerExist('point'); expect(hasLayer).to.be(true); }); it('should replace preivew layer on file change', async () => { - await PageObjects.geoFileUpload.previewGeoJsonFile( - path.join(__dirname, 'files', 'polygon.json') - ); - await PageObjects.maps.waitForLayersToLoad(); + await geoFileUpload.previewGeoJsonFile(path.join(__dirname, 'files', 'polygon.json')); + await maps.waitForLayersToLoad(); - const numberOfLayers = await PageObjects.maps.getNumberOfLayers(); + const numberOfLayers = await maps.getNumberOfLayers(); expect(numberOfLayers).to.be(2); - const hasLayer = await PageObjects.maps.doesLayerExist('polygon'); + const hasLayer = await maps.doesLayerExist('polygon'); expect(hasLayer).to.be(true); }); it('should disable next button when index already exists', async () => { await retry.try(async () => { - expect(await PageObjects.geoFileUpload.isNextButtonEnabled()).to.be(true); + expect(await geoFileUpload.isNextButtonEnabled()).to.be(true); }); // "geo_shapes" index already exists, its added by es_archive - await PageObjects.geoFileUpload.setIndexName('geo_shapes'); + await geoFileUpload.setIndexName('geo_shapes'); await retry.try(async () => { - expect(await PageObjects.geoFileUpload.isNextButtonEnabled()).to.be(false); + expect(await geoFileUpload.isNextButtonEnabled()).to.be(false); }); }); it('should enable next button when index name is changed', async () => { - await PageObjects.geoFileUpload.setIndexName('polygon'); + await geoFileUpload.setIndexName('polygon'); await retry.try(async () => { - expect(await PageObjects.geoFileUpload.isNextButtonEnabled()).to.be(true); + expect(await geoFileUpload.isNextButtonEnabled()).to.be(true); }); }); it('should remove preview layer on cancel', async () => { - await PageObjects.maps.cancelLayerAdd(); + await maps.cancelLayerAdd(); - await PageObjects.maps.waitForLayerDeleted('polygon'); - const numberOfLayers = await PageObjects.maps.getNumberOfLayers(); + await maps.waitForLayerDeleted('polygon'); + const numberOfLayers = await maps.getNumberOfLayers(); expect(numberOfLayers).to.be(1); }); }); diff --git a/x-pack/test/functional/apps/maps/group4/geofile_wizard_auto_open.ts b/x-pack/test/functional/apps/maps/group4/geofile_wizard_auto_open.ts index ad9cb7a5ae3b1..6c42d9f7a8da7 100644 --- a/x-pack/test/functional/apps/maps/group4/geofile_wizard_auto_open.ts +++ b/x-pack/test/functional/apps/maps/group4/geofile_wizard_auto_open.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'maps']); + const { common, maps } = getPageObjects(['common', 'maps']); const find = getService('find'); const browser = getService('browser'); const retry = getService('retry'); @@ -18,7 +18,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { // Failing: See https://github.com/elastic/kibana/issues/173095 describe.skip('Auto open file upload wizard in maps app', () => { before(async () => { - await PageObjects.common.navigateToUrl('integrations', 'browse', { + await common.navigateToUrl('integrations', 'browse', { useActualUrl: true, }); const searchInput = await find.byCssSelector('[data-test-subj="epmList.searchBar"]'); @@ -37,7 +37,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('should upload form exist', async () => { await retry.waitFor( `Add layer panel to be visible`, - async () => await PageObjects.maps.isLayerAddPanelOpen() + async () => await maps.isLayerAddPanelOpen() ); }); }); diff --git a/x-pack/test/functional/apps/maps/group4/joins.js b/x-pack/test/functional/apps/maps/group4/joins.js index b4846533b6a05..3ef94ffac86a9 100644 --- a/x-pack/test/functional/apps/maps/group4/joins.js +++ b/x-pack/test/functional/apps/maps/group4/joins.js @@ -18,7 +18,7 @@ const EXPECTED_JOIN_VALUES = { const VECTOR_SOURCE_ID = 'n1t6f'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const inspector = getService('inspector'); const security = getService('security'); @@ -28,36 +28,33 @@ export default function ({ getPageObjects, getService }) { ['global_maps_all', 'geoshape_data_reader', 'meta_for_geoshape_data_reader'], { skipBrowserRefresh: true } ); - await PageObjects.maps.loadSavedMap('join example'); + await maps.loadSavedMap('join example'); }); after(async () => { await inspector.close(); - await PageObjects.maps.refreshAndClearUnsavedChangesWarning(); + await maps.refreshAndClearUnsavedChangesWarning(); await security.testUser.restoreDefaults(); }); it('should re-fetch join with refresh timer', async () => { async function getRequestTimestamp() { - await PageObjects.maps.openInspectorRequest('load join metrics (geo_shapes*)'); + await maps.openInspectorRequest('load join metrics (geo_shapes*)'); const requestStats = await inspector.getTableData(); - const requestTimestamp = PageObjects.maps.getInspectorStatRowHit( - requestStats, - 'Request timestamp' - ); + const requestTimestamp = maps.getInspectorStatRowHit(requestStats, 'Request timestamp'); await inspector.close(); return requestTimestamp; } const beforeRefreshTimerTimestamp = await getRequestTimestamp(); expect(beforeRefreshTimerTimestamp.length).to.be(24); - await PageObjects.maps.triggerSingleRefresh(1000); + await maps.triggerSingleRefresh(1000); const afterRefreshTimerTimestamp = await getRequestTimestamp(); expect(beforeRefreshTimerTimestamp).not.to.equal(afterRefreshTimerTimestamp); }); it('should show dynamic data range in legend', async () => { - const layerTOCDetails = await PageObjects.maps.getLayerTOCDetails('geo_shapes*'); + const layerTOCDetails = await maps.getLayerTOCDetails('geo_shapes*'); const split = layerTOCDetails.trim().split('\n'); //field display name @@ -75,7 +72,7 @@ export default function ({ getPageObjects, getService }) { }); it('should decorate feature properties with join property', async () => { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + const mapboxStyle = await maps.getMapboxStyle(); expect(mapboxStyle.sources[VECTOR_SOURCE_ID].data.features.length).to.equal(8); mapboxStyle.sources.n1t6f.data.features.forEach(({ properties }) => { @@ -90,7 +87,7 @@ export default function ({ getPageObjects, getService }) { }); it('should flag only the joined features as visible', async () => { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + const mapboxStyle = await maps.getMapboxStyle(); const vectorSource = mapboxStyle.sources[VECTOR_SOURCE_ID]; const visibilitiesOfFeatures = vectorSource.data.features.map((feature) => { @@ -112,16 +109,16 @@ export default function ({ getPageObjects, getService }) { describe('query bar', () => { before(async () => { - await PageObjects.maps.setAndSubmitQuery('prop1 < 10'); + await maps.setAndSubmitQuery('prop1 < 10'); }); after(async () => { await inspector.close(); - await PageObjects.maps.setAndSubmitQuery(''); + await maps.setAndSubmitQuery(''); }); it('should not apply query to source and apply query to join', async () => { - const { rawResponse: joinResponse } = await PageObjects.maps.getResponse( + const { rawResponse: joinResponse } = await maps.getResponse( 'load join metrics (geo_shapes*)' ); expect(joinResponse.aggregations.join.buckets.length).to.equal(2); @@ -130,22 +127,22 @@ export default function ({ getPageObjects, getService }) { describe('where clause', () => { before(async () => { - await PageObjects.maps.setJoinWhereQuery('geo_shapes*', 'prop1 >= 11'); + await maps.setJoinWhereQuery('geo_shapes*', 'prop1 >= 11'); }); after(async () => { - await PageObjects.maps.closeLayerPanel(); + await maps.closeLayerPanel(); }); it('should apply query to join request', async () => { - const { rawResponse: joinResponse } = await PageObjects.maps.getResponse( + const { rawResponse: joinResponse } = await maps.getResponse( 'load join metrics (geo_shapes*)' ); expect(joinResponse.aggregations.join.buckets.length).to.equal(1); }); it('should update dynamic data range in legend with new results', async () => { - const layerTOCDetails = await PageObjects.maps.getLayerTOCDetails('geo_shapes*'); + const layerTOCDetails = await maps.getLayerTOCDetails('geo_shapes*'); const split = layerTOCDetails.trim().split('\n'); const min = split[0]; @@ -156,7 +153,7 @@ export default function ({ getPageObjects, getService }) { }); it('should flag only the joined features as visible', async () => { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + const mapboxStyle = await maps.getMapboxStyle(); const vectorSource = mapboxStyle.sources[VECTOR_SOURCE_ID]; const visibilitiesOfFeatures = vectorSource.data.features.map((feature) => { @@ -183,8 +180,8 @@ export default function ({ getPageObjects, getService }) { }); it('should not contain any elasticsearch request after layer is deleted', async () => { - await PageObjects.maps.removeLayer('geo_shapes*'); - const noRequests = await PageObjects.maps.doesInspectorHaveRequests(); + await maps.removeLayer('geo_shapes*'); + const noRequests = await maps.doesInspectorHaveRequests(); expect(noRequests).to.equal(true); }); }); diff --git a/x-pack/test/functional/apps/maps/group4/layer_errors.js b/x-pack/test/functional/apps/maps/group4/layer_errors.js index 9f8a570a46d96..049893b174f16 100644 --- a/x-pack/test/functional/apps/maps/group4/layer_errors.js +++ b/x-pack/test/functional/apps/maps/group4/layer_errors.js @@ -8,26 +8,26 @@ import expect from '@kbn/expect'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps', 'header']); + const { maps } = getPageObjects(['maps', 'header']); const inspector = getService('inspector'); const testSubjects = getService('testSubjects'); const comboBox = getService('comboBox'); describe('layer errors', () => { before(async () => { - await PageObjects.maps.loadSavedMap('layer with errors'); + await maps.loadSavedMap('layer with errors'); }); describe('Layer with invalid descriptor', () => { const INVALID_LAYER_NAME = 'fff76ebb-57a6-4067-a373-1d191b9bd1a3'; it('should diplay error icon in legend', async () => { - await PageObjects.maps.hasErrorIconExistsOrFail(INVALID_LAYER_NAME); + await maps.hasErrorIconExistsOrFail(INVALID_LAYER_NAME); }); it('should allow deletion of layer', async () => { - await PageObjects.maps.removeLayer(INVALID_LAYER_NAME); - const exists = await PageObjects.maps.doesLayerExist(INVALID_LAYER_NAME); + await maps.removeLayer(INVALID_LAYER_NAME); + const exists = await maps.doesLayerExist(INVALID_LAYER_NAME); expect(exists).to.be(false); }); }); @@ -38,7 +38,7 @@ export default function ({ getPageObjects, getService }) { }); it('should diplay error icon in legend', async () => { - await PageObjects.maps.hasErrorIconExistsOrFail('connections'); + await maps.hasErrorIconExistsOrFail('connections'); }); it('should display "View details" button', async () => { @@ -58,12 +58,12 @@ export default function ({ getPageObjects, getService }) { const LAYER_NAME = 'idThatDoesNotExitForESSearchSource'; it('should diplay error icon in legend', async () => { - await PageObjects.maps.hasErrorIconExistsOrFail(LAYER_NAME); + await maps.hasErrorIconExistsOrFail(LAYER_NAME); }); it('should allow deletion of layer', async () => { - await PageObjects.maps.removeLayer(LAYER_NAME); - const exists = await PageObjects.maps.doesLayerExist(LAYER_NAME); + await maps.removeLayer(LAYER_NAME); + const exists = await maps.doesLayerExist(LAYER_NAME); expect(exists).to.be(false); }); }); @@ -72,12 +72,12 @@ export default function ({ getPageObjects, getService }) { const LAYER_NAME = 'idThatDoesNotExitForESGeoGridSource'; it('should diplay error icon in legend', async () => { - await PageObjects.maps.hasErrorIconExistsOrFail(LAYER_NAME); + await maps.hasErrorIconExistsOrFail(LAYER_NAME); }); it('should allow deletion of layer', async () => { - await PageObjects.maps.removeLayer(LAYER_NAME); - const exists = await PageObjects.maps.doesLayerExist(LAYER_NAME); + await maps.removeLayer(LAYER_NAME); + const exists = await maps.doesLayerExist(LAYER_NAME); expect(exists).to.be(false); }); }); @@ -86,12 +86,12 @@ export default function ({ getPageObjects, getService }) { const LAYER_NAME = 'geo_shapes*'; it('should diplay error icon in legend', async () => { - await PageObjects.maps.hasErrorIconExistsOrFail(LAYER_NAME); + await maps.hasErrorIconExistsOrFail(LAYER_NAME); }); it('should allow deletion of layer', async () => { - await PageObjects.maps.removeLayer(LAYER_NAME); - const exists = await PageObjects.maps.doesLayerExist(LAYER_NAME); + await maps.removeLayer(LAYER_NAME); + const exists = await maps.doesLayerExist(LAYER_NAME); expect(exists).to.be(false); }); }); @@ -100,12 +100,12 @@ export default function ({ getPageObjects, getService }) { const LAYER_NAME = 'EMS_vector_shapes'; it('should diplay error icon in legend', async () => { - await PageObjects.maps.hasErrorIconExistsOrFail(LAYER_NAME); + await maps.hasErrorIconExistsOrFail(LAYER_NAME); }); it('should allow deletion of layer', async () => { - await PageObjects.maps.removeLayer(LAYER_NAME); - const exists = await PageObjects.maps.doesLayerExist(LAYER_NAME); + await maps.removeLayer(LAYER_NAME); + const exists = await maps.doesLayerExist(LAYER_NAME); expect(exists).to.be(false); }); }); @@ -114,12 +114,12 @@ export default function ({ getPageObjects, getService }) { const LAYER_NAME = 'EMS_tiles'; it('should diplay error icon in legend', async () => { - await PageObjects.maps.hasErrorIconExistsOrFail(LAYER_NAME); + await maps.hasErrorIconExistsOrFail(LAYER_NAME); }); it('should allow deletion of layer', async () => { - await PageObjects.maps.removeLayer(LAYER_NAME); - const exists = await PageObjects.maps.doesLayerExist(LAYER_NAME); + await maps.removeLayer(LAYER_NAME); + const exists = await maps.doesLayerExist(LAYER_NAME); expect(exists).to.be(false); }); }); @@ -128,12 +128,12 @@ export default function ({ getPageObjects, getService }) { const LAYER_NAME = 'Custom_TMS'; it('should diplay error icon in legend', async () => { - await PageObjects.maps.hasErrorIconExistsOrFail(LAYER_NAME); + await maps.hasErrorIconExistsOrFail(LAYER_NAME); }); it('should allow deletion of layer', async () => { - await PageObjects.maps.removeLayer(LAYER_NAME); - const exists = await PageObjects.maps.doesLayerExist(LAYER_NAME); + await maps.removeLayer(LAYER_NAME); + const exists = await maps.doesLayerExist(LAYER_NAME); expect(exists).to.be(false); }); }); diff --git a/x-pack/test/functional/apps/maps/group4/lens/choropleth_chart.ts b/x-pack/test/functional/apps/maps/group4/lens/choropleth_chart.ts index ba7f50befe844..a9487c8a84fc5 100644 --- a/x-pack/test/functional/apps/maps/group4/lens/choropleth_chart.ts +++ b/x-pack/test/functional/apps/maps/group4/lens/choropleth_chart.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'maps']); + const { visualize, lens, maps } = getPageObjects(['visualize', 'lens', 'maps']); const testSubjects = getService('testSubjects'); const filterBar = getService('filterBar'); @@ -17,43 +17,41 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Do not skip test if failure is "Test requires access to Elastic Maps Service (EMS). EMS is not available" describe('choropleth chart', () => { before('', async () => { - await PageObjects.maps.expectEmsToBeAvailable(); + await maps.expectEmsToBeAvailable(); }); it('should allow creation of choropleth chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsChoropleth', 'Region map'); + await lens.switchToVisualization('lnsChoropleth', 'Region map'); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsChoropleth_regionKeyDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.dest', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsChoropleth_valueDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.maps.openLegend(); - await PageObjects.maps.waitForLayersToLoad(); + await maps.openLegend(); + await maps.waitForLayersToLoad(); - expect(await PageObjects.maps.getNumberOfLayers()).to.eql(2); - expect(await PageObjects.maps.doesLayerExist('World Countries by Average of bytes')).to.be( - true - ); + expect(await maps.getNumberOfLayers()).to.eql(2); + expect(await maps.doesLayerExist('World Countries by Average of bytes')).to.be(true); }); it('should create choropleth chart from suggestion', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.dragFieldToWorkspace('geo.dest', 'xyVisChart'); + await lens.dragFieldToWorkspace('geo.dest', 'xyVisChart'); // add filter to force data fetch to set activeData await filterBar.addFilter({ @@ -64,13 +62,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('lnsSuggestion-worldCountriesByCountOfRecords > lnsSuggestion'); - await PageObjects.maps.openLegend(); - await PageObjects.maps.waitForLayersToLoad(); + await maps.openLegend(); + await maps.waitForLayersToLoad(); - expect(await PageObjects.maps.getNumberOfLayers()).to.eql(2); - expect(await PageObjects.maps.doesLayerExist('World Countries by Count of records')).to.be( - true - ); + expect(await maps.getNumberOfLayers()).to.eql(2); + expect(await maps.doesLayerExist('World Countries by Count of records')).to.be(true); }); }); } diff --git a/x-pack/test/functional/apps/maps/group4/mapbox_styles.js b/x-pack/test/functional/apps/maps/group4/mapbox_styles.js index 72b8c5d502971..023e4a8f18959 100644 --- a/x-pack/test/functional/apps/maps/group4/mapbox_styles.js +++ b/x-pack/test/functional/apps/maps/group4/mapbox_styles.js @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const inspector = getService('inspector'); const security = getService('security'); @@ -19,8 +19,8 @@ export default function ({ getPageObjects, getService }) { ['global_maps_all', 'geoshape_data_reader', 'meta_for_geoshape_data_reader'], { skipBrowserRefresh: true } ); - await PageObjects.maps.loadSavedMap('join example'); - mapboxStyle = await PageObjects.maps.getMapboxStyle(); + await maps.loadSavedMap('join example'); + mapboxStyle = await maps.getMapboxStyle(); }); after(async () => { diff --git a/x-pack/test/functional/apps/maps/group4/mvt_geotile_grid.js b/x-pack/test/functional/apps/maps/group4/mvt_geotile_grid.js index e19b4332789f5..c7387662d9b7d 100644 --- a/x-pack/test/functional/apps/maps/group4/mvt_geotile_grid.js +++ b/x-pack/test/functional/apps/maps/group4/mvt_geotile_grid.js @@ -10,7 +10,7 @@ import expect from '@kbn/expect'; const MB_VECTOR_SOURCE_ID = 'g1xkv'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const inspector = getService('inspector'); const security = getService('security'); @@ -28,8 +28,8 @@ export default function ({ getPageObjects, getService }) { }); it('should render with mvt-source (style meta from ES)', async () => { - await PageObjects.maps.loadSavedMap('MVT geotile grid (style meta from ES)'); - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + await maps.loadSavedMap('MVT geotile grid (style meta from ES)'); + const mapboxStyle = await maps.getMapboxStyle(); const tileUrl = new URL( mapboxStyle.sources[MB_VECTOR_SOURCE_ID].tiles[0], @@ -99,8 +99,8 @@ export default function ({ getPageObjects, getService }) { }); it('should render with mvt-source (style meta from local - count)', async () => { - await PageObjects.maps.loadSavedMap('MVT geotile grid (style meta from local - count)'); - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + await maps.loadSavedMap('MVT geotile grid (style meta from local - count)'); + const mapboxStyle = await maps.getMapboxStyle(); const fillLayer = mapboxStyle.layers.find( (layer) => layer.id === MB_VECTOR_SOURCE_ID + '_fill' @@ -144,8 +144,8 @@ export default function ({ getPageObjects, getService }) { }); it('should render with mvt-source (style meta from local - metric)', async () => { - await PageObjects.maps.loadSavedMap('MVT geotile grid (style meta from local - metric)'); - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + await maps.loadSavedMap('MVT geotile grid (style meta from local - metric)'); + const mapboxStyle = await maps.getMapboxStyle(); const fillLayer = mapboxStyle.layers.find( (layer) => layer.id === MB_VECTOR_SOURCE_ID + '_fill' @@ -189,8 +189,8 @@ export default function ({ getPageObjects, getService }) { }); it('should render heatmap layer', async () => { - await PageObjects.maps.loadSavedMap('geo grid heatmap example'); - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + await maps.loadSavedMap('geo grid heatmap example'); + const mapboxStyle = await maps.getMapboxStyle(); const heatmapLayer = mapboxStyle.layers.find((layer) => layer.id === '3xlvm_heatmap'); diff --git a/x-pack/test/functional/apps/maps/group4/mvt_joins.ts b/x-pack/test/functional/apps/maps/group4/mvt_joins.ts index c6567c84b2165..44f0e799a25da 100644 --- a/x-pack/test/functional/apps/maps/group4/mvt_joins.ts +++ b/x-pack/test/functional/apps/maps/group4/mvt_joins.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const security = getService('security'); const find = getService('find'); @@ -19,7 +19,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ['global_maps_all', 'geoshape_data_reader', 'meta_for_geoshape_data_reader'], { skipBrowserRefresh: true } ); - await PageObjects.maps.loadSavedMap('mvt join example'); + await maps.loadSavedMap('mvt join example'); }); after(async () => { @@ -27,7 +27,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('should show dynamic data range in legend', async () => { - const layerTOCDetails = await PageObjects.maps.getLayerTOCDetails('geo_shapes*'); + const layerTOCDetails = await maps.getLayerTOCDetails('geo_shapes*'); const split = layerTOCDetails.trim().split('\n'); // field display name @@ -46,8 +46,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('should show join metrics in tooltip', async () => { // zoom in on feature so tooltip click can not miss - await PageObjects.maps.setView(-1, 60, 9); - await PageObjects.maps.lockTooltipAtPosition(200, -200); + await maps.setView(-1, 60, 9); + await maps.lockTooltipAtPosition(200, -200); const tooltipRows = await find.allByCssSelector(`tr[class='mapFeatureTooltip_row']`); expect(tooltipRows.length).to.equal(2); @@ -57,15 +57,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('query bar', () => { before(async () => { - await PageObjects.maps.setAndSubmitQuery('prop1 < 10'); + await maps.setAndSubmitQuery('prop1 < 10'); }); after(async () => { - await PageObjects.maps.setAndSubmitQuery(''); + await maps.setAndSubmitQuery(''); }); it('should update dynamic data range in legend', async () => { - const layerTOCDetails = await PageObjects.maps.getLayerTOCDetails('geo_shapes*'); + const layerTOCDetails = await maps.getLayerTOCDetails('geo_shapes*'); const split = layerTOCDetails.trim().split('\n'); // field display name @@ -83,9 +83,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('fit to bounds should exclude source features without join matches', async () => { - await PageObjects.maps.clickFitToData(); + await maps.clickFitToData(); - const { lat, lon, zoom } = await PageObjects.maps.getView(); + const { lat, lon, zoom } = await maps.getView(); expect(Math.round(lat)).to.equal(0); expect(Math.round(lon)).to.equal(90); expect(Math.ceil(zoom)).to.equal(5); diff --git a/x-pack/test/functional/apps/maps/group4/mvt_scaling.js b/x-pack/test/functional/apps/maps/group4/mvt_scaling.js index e624ab39dee12..ced85cbc97319 100644 --- a/x-pack/test/functional/apps/maps/group4/mvt_scaling.js +++ b/x-pack/test/functional/apps/maps/group4/mvt_scaling.js @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; export default function ({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['maps']); + const { maps } = getPageObjects(['maps']); const inspector = getService('inspector'); const security = getService('security'); const testSubjects = getService('testSubjects'); @@ -31,8 +31,8 @@ export default function ({ getPageObjects, getService }) { let mapboxStyle; before(async () => { - await PageObjects.maps.loadSavedMap('geo_shape_mvt'); - mapboxStyle = await PageObjects.maps.getMapboxStyle(); + await maps.loadSavedMap('geo_shape_mvt'); + mapboxStyle = await maps.getMapboxStyle(); }); it('should request tiles from /internal/maps/mvt/getTile', async () => { @@ -135,43 +135,37 @@ export default function ({ getPageObjects, getService }) { describe('filtering', () => { before(async () => { - await PageObjects.maps.loadSavedMap('MVT documents'); + await maps.loadSavedMap('MVT documents'); }); async function getTileUrl() { - const mapboxStyle = await PageObjects.maps.getMapboxStyle(); + const mapboxStyle = await maps.getMapboxStyle(); return mapboxStyle.sources['a7ab2e06-145b-48c5-bd86-b633849017ad'].tiles[0]; } describe('applyGlobalQuery: true, applyGlobalTime: true, applyForceRefresh: true', () => { after(async () => { - await PageObjects.maps.setAbsoluteRange( - 'Sep 20, 2015 @ 00:00:00.000', - 'Sep 20, 2015 @ 01:00:00.000' - ); - await PageObjects.maps.setAndSubmitQuery(''); + await maps.setAbsoluteRange('Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 01:00:00.000'); + await maps.setAndSubmitQuery(''); }); it('should update MVT URL when query changes', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "win 8"'); + await maps.setAndSubmitQuery('machine.os.raw : "win 8"'); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.not.eql(nextTileUrl); }); it('should update MVT URL when time changes', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.setAbsoluteRange( - 'Sep 20, 2015 @ 00:00:00.000', - 'Sep 20, 2015 @ 03:00:00.000' - ); + await maps.setAbsoluteRange('Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 03:00:00.000'); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.not.eql(nextTileUrl); }); it('should update MVT URL when refresh clicked', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.refreshQuery(); + await maps.refreshQuery(); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.not.eql(nextTileUrl); }); @@ -179,40 +173,34 @@ export default function ({ getPageObjects, getService }) { describe('applyGlobalQuery: false, applyGlobalTime: true, applyForceRefresh: true', () => { before(async () => { - await PageObjects.maps.openLayerPanel('logstash-*'); + await maps.openLayerPanel('logstash-*'); await testSubjects.click('mapLayerPanelApplyGlobalQueryCheckbox'); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); }); after(async () => { - await PageObjects.maps.closeLayerPanel(); - await PageObjects.maps.setAbsoluteRange( - 'Sep 20, 2015 @ 00:00:00.000', - 'Sep 20, 2015 @ 01:00:00.000' - ); - await PageObjects.maps.setAndSubmitQuery(''); + await maps.closeLayerPanel(); + await maps.setAbsoluteRange('Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 01:00:00.000'); + await maps.setAndSubmitQuery(''); }); it('should not update MVT URL when query changes', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "win 8"'); + await maps.setAndSubmitQuery('machine.os.raw : "win 8"'); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.eql(nextTileUrl); }); it('should update MVT URL when time changes', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.setAbsoluteRange( - 'Sep 20, 2015 @ 00:00:00.000', - 'Sep 20, 2015 @ 03:00:00.000' - ); + await maps.setAbsoluteRange('Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 03:00:00.000'); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.not.eql(nextTileUrl); }); it('should update MVT URL when refresh clicked', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.refreshQuery(); + await maps.refreshQuery(); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.not.eql(nextTileUrl); }); @@ -220,40 +208,34 @@ export default function ({ getPageObjects, getService }) { describe('applyGlobalQuery: true, applyGlobalTime: false, applyForceRefresh: true', () => { before(async () => { - await PageObjects.maps.openLayerPanel('logstash-*'); + await maps.openLayerPanel('logstash-*'); await testSubjects.click('mapLayerPanelApplyGlobalTimeCheckbox'); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); }); after(async () => { - await PageObjects.maps.closeLayerPanel(); - await PageObjects.maps.setAbsoluteRange( - 'Sep 20, 2015 @ 00:00:00.000', - 'Sep 20, 2015 @ 01:00:00.000' - ); - await PageObjects.maps.setAndSubmitQuery(''); + await maps.closeLayerPanel(); + await maps.setAbsoluteRange('Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 01:00:00.000'); + await maps.setAndSubmitQuery(''); }); it('should update MVT URL when query changes', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "win 8"'); + await maps.setAndSubmitQuery('machine.os.raw : "win 8"'); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.not.eql(nextTileUrl); }); it('should not update MVT URL when time changes', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.setAbsoluteRange( - 'Sep 20, 2015 @ 00:00:00.000', - 'Sep 20, 2015 @ 03:00:00.000' - ); + await maps.setAbsoluteRange('Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 03:00:00.000'); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.eql(nextTileUrl); }); it('should update MVT URL when refresh clicked', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.refreshQuery(); + await maps.refreshQuery(); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.not.eql(nextTileUrl); }); @@ -261,40 +243,34 @@ export default function ({ getPageObjects, getService }) { describe('applyGlobalQuery: true, applyGlobalTime: true, applyForceRefresh: false', () => { before(async () => { - await PageObjects.maps.openLayerPanel('logstash-*'); + await maps.openLayerPanel('logstash-*'); await testSubjects.click('mapLayerPanelRespondToForceRefreshCheckbox'); - await PageObjects.maps.waitForLayersToLoad(); + await maps.waitForLayersToLoad(); }); after(async () => { - await PageObjects.maps.closeLayerPanel(); - await PageObjects.maps.setAbsoluteRange( - 'Sep 20, 2015 @ 00:00:00.000', - 'Sep 20, 2015 @ 01:00:00.000' - ); - await PageObjects.maps.setAndSubmitQuery(''); + await maps.closeLayerPanel(); + await maps.setAbsoluteRange('Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 01:00:00.000'); + await maps.setAndSubmitQuery(''); }); it('should update MVT URL when query changes', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.setAndSubmitQuery('machine.os.raw : "win 8"'); + await maps.setAndSubmitQuery('machine.os.raw : "win 8"'); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.not.eql(nextTileUrl); }); it('should update MVT URL when time changes', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.setAbsoluteRange( - 'Sep 20, 2015 @ 00:00:00.000', - 'Sep 20, 2015 @ 03:00:00.000' - ); + await maps.setAbsoluteRange('Sep 20, 2015 @ 00:00:00.000', 'Sep 20, 2015 @ 03:00:00.000'); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.not.eql(nextTileUrl); }); it('should not update MVT URL when refresh clicked', async () => { const prevTileUrl = await getTileUrl(); - await PageObjects.maps.refreshQuery(); + await maps.refreshQuery(); const nextTileUrl = await getTileUrl(); expect(prevTileUrl).to.eql(nextTileUrl); }); diff --git a/x-pack/test/functional/apps/maps/group4/tile_map.ts b/x-pack/test/functional/apps/maps/group4/tile_map.ts index 27cd25eb9893d..dd4062925a601 100644 --- a/x-pack/test/functional/apps/maps/group4/tile_map.ts +++ b/x-pack/test/functional/apps/maps/group4/tile_map.ts @@ -9,27 +9,29 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'visualize', 'lens', 'maps', 'timePicker']); + const { common, visualize, maps, timePicker } = getPageObjects([ + 'common', + 'visualize', + 'maps', + 'timePicker', + ]); describe('tile_map visualization', () => { before(async () => { - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.visualize.loadSavedVisualization('Visualization TileMap', { + await common.navigateToApp('visualize'); + await visualize.loadSavedVisualization('Visualization TileMap', { navigateToVisualize: false, }); - await PageObjects.timePicker.setAbsoluteRange( - PageObjects.timePicker.defaultStartTime, - PageObjects.timePicker.defaultEndTime - ); - await PageObjects.maps.waitForLayersToLoad(); + await timePicker.setAbsoluteRange(timePicker.defaultStartTime, timePicker.defaultEndTime); + await maps.waitForLayersToLoad(); }); it('should render tile_map with map embeddable', async () => { - await PageObjects.maps.openLegend(); - await PageObjects.maps.waitForLayersToLoad(); + await maps.openLegend(); + await maps.waitForLayersToLoad(); - expect(await PageObjects.maps.getNumberOfLayers()).to.eql(2); - expect(await PageObjects.maps.doesLayerExist('Visualization TileMap')).to.be(true); + expect(await maps.getNumberOfLayers()).to.eql(2); + expect(await maps.doesLayerExist('Visualization TileMap')).to.be(true); }); }); } diff --git a/x-pack/test/functional/apps/maps/group4/visualize_create_menu.js b/x-pack/test/functional/apps/maps/group4/visualize_create_menu.js index d9b37b4aca240..37eedfb1e8ad2 100644 --- a/x-pack/test/functional/apps/maps/group4/visualize_create_menu.js +++ b/x-pack/test/functional/apps/maps/group4/visualize_create_menu.js @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { - const PageObjects = getPageObjects(['visualize', 'header', 'maps']); + const { visualize, header, maps } = getPageObjects(['visualize', 'header', 'maps']); const listingTable = getService('listingTable'); const security = getService('security'); @@ -23,18 +23,18 @@ export default function ({ getService, getPageObjects }) { } ); - await PageObjects.visualize.navigateToNewVisualization(); + await visualize.navigateToNewVisualization(); }); it('should show maps application in create menu', async () => { - const hasMapsApp = await PageObjects.visualize.hasMapsApp(); + const hasMapsApp = await visualize.hasMapsApp(); expect(hasMapsApp).to.equal(true); }); it('should take users to Maps application when Maps is clicked', async () => { - await PageObjects.visualize.clickMapsApp(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const onMapPage = await PageObjects.maps.onMapPage(); + await visualize.clickMapsApp(); + await header.waitUntilLoadingHasFinished(); + const onMapPage = await maps.onMapPage(); expect(onMapPage).to.equal(true); }); }); @@ -48,7 +48,7 @@ export default function ({ getService, getPageObjects }) { } ); - await PageObjects.visualize.navigateToNewVisualization(); + await visualize.navigateToNewVisualization(); }); after(async () => { @@ -56,7 +56,7 @@ export default function ({ getService, getPageObjects }) { }); it('should not show maps application in create menu', async () => { - const hasMapsApp = await PageObjects.visualize.hasMapsApp(); + const hasMapsApp = await visualize.hasMapsApp(); expect(hasMapsApp).to.equal(false); }); }); @@ -68,7 +68,7 @@ export default function ({ getService, getPageObjects }) { skipBrowserRefresh: true, }); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); }); after(async () => { @@ -76,12 +76,12 @@ export default function ({ getService, getPageObjects }) { }); it('should not show legacy region map visualizion in create menu', async () => { - const hasLegecyViz = await PageObjects.visualize.hasVisType('region_map'); + const hasLegecyViz = await visualize.hasVisType('region_map'); expect(hasLegecyViz).to.equal(false); }); it('should not show legacy tilemap map visualizion in create menu', async () => { - const hasLegecyViz = await PageObjects.visualize.hasVisType('tile_map'); + const hasLegecyViz = await visualize.hasVisType('tile_map'); expect(hasLegecyViz).to.equal(false); }); }); @@ -94,7 +94,7 @@ export default function ({ getService, getPageObjects }) { } ); - await PageObjects.visualize.navigateToNewAggBasedVisualization(); + await visualize.navigateToNewAggBasedVisualization(); }); after(async () => { @@ -102,11 +102,11 @@ export default function ({ getService, getPageObjects }) { }); it('should allow to change meta-data on a map visualization', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickMapsApp(); - await PageObjects.maps.waitForLayersToLoad(); - await PageObjects.maps.saveMap('myTestMap'); - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.navigateToNewVisualization(); + await visualize.clickMapsApp(); + await maps.waitForLayersToLoad(); + await maps.saveMap('myTestMap'); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('myTestMap'); await listingTable.inspectVisualization(); await listingTable.editVisualizationDetails({ diff --git a/x-pack/test/functional/apps/saved_query_management/feature_controls/security.ts b/x-pack/test/functional/apps/saved_query_management/feature_controls/security.ts index 911b8675adf14..6c57295a0c353 100644 --- a/x-pack/test/functional/apps/saved_query_management/feature_controls/security.ts +++ b/x-pack/test/functional/apps/saved_query_management/feature_controls/security.ts @@ -16,9 +16,9 @@ export default function (ctx: FtrProviderContext) { const { getPageObjects, getService } = ctx; const savedQuerySecurityUtils = getSavedQuerySecurityUtils(ctx); const esArchiver = getService('esArchiver'); - const security = getService('security'); + const securityService = getService('security'); const globalNav = getService('globalNav'); - const PageObjects = getPageObjects([ + const { common, discover, security, dashboard, maps, visualize } = getPageObjects([ 'common', 'discover', 'security', @@ -36,7 +36,7 @@ export default function (ctx: FtrProviderContext) { const name = `global_saved_query_${appName}`; const password = `password_${name}_${appPrivilege}_${globalPrivilege}`; - await security.role.create(name, { + await securityService.role.create(name, { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -51,40 +51,40 @@ export default function (ctx: FtrProviderContext) { ], }); - await security.user.create(`${name}-user`, { + await securityService.user.create(`${name}-user`, { password, roles: [name], full_name: 'test user', }); - await PageObjects.security.login(`${name}-user`, password, { + await security.login(`${name}-user`, password, { expectSpaceSelector: false, }); } async function logout(appName: AppName) { const name = `global_saved_query_${appName}`; - await PageObjects.security.forceLogout(); - await security.role.delete(name); - await security.user.delete(`${name}-user`); + await security.forceLogout(); + await securityService.role.delete(name); + await securityService.user.delete(`${name}-user`); } async function navigateToApp(appName: AppName) { switch (appName) { case 'discover': - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.selectIndexPattern('logstash-*'); + await common.navigateToApp('discover'); + await discover.selectIndexPattern('logstash-*'); break; case 'dashboard': - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.gotoDashboardEditMode('A Dashboard'); + await dashboard.navigateToApp(); + await dashboard.gotoDashboardEditMode('A Dashboard'); break; case 'maps': - await PageObjects.maps.openNewMap(); + await maps.openNewMap(); break; case 'visualize': - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); break; default: break; @@ -103,13 +103,13 @@ export default function (ctx: FtrProviderContext) { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); // ensure we're logged out, so we can log in as the appropriate users - await PageObjects.security.forceLogout(); + await security.forceLogout(); }); after(async () => { // logout, so the other tests don't accidentally run as the custom users we're testing below // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); + await security.forceLogout(); await kibanaServer.importExport.unload( 'x-pack/test/functional/fixtures/kbn_archiver/dashboard/feature_controls/security/security.json' @@ -122,7 +122,7 @@ export default function (ctx: FtrProviderContext) { before(async () => { await login(appName, 'read', 'all'); await navigateToApp(appName); - await PageObjects.common.waitForTopNavToBeVisible(); + await common.waitForTopNavToBeVisible(); }); after(async () => { diff --git a/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts b/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts index 97ae448d66b1d..e3f7de552dbc4 100644 --- a/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts +++ b/x-pack/test/functional/apps/visualize/feature_controls/visualize_security.ts @@ -11,17 +11,14 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); - const security = getService('security'); + const securityService = getService('security'); const config = getService('config'); - const PageObjects = getPageObjects([ + const { common, error, visualize, header, security } = getPageObjects([ 'common', 'error', 'visualize', 'header', 'security', - 'share', - 'spaceSelector', - 'timePicker', ]); const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); @@ -39,19 +36,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ); await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); // ensure we're logged out so we can login as the appropriate users - await PageObjects.security.forceLogout(); + await security.forceLogout(); }); after(async () => { // logout, so the other tests don't accidentally run as the custom users we're testing below // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); + await security.forceLogout(); await kibanaServer.savedObjects.cleanStandardList(); }); describe('global visualize all privileges', () => { before(async () => { - await security.role.create('global_visualize_all_role', { + await securityService.role.create('global_visualize_all_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -65,28 +62,24 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_visualize_all_user', { + await securityService.user.create('global_visualize_all_user', { password: 'global_visualize_all_user-password', roles: ['global_visualize_all_role'], full_name: 'test user', }); - await PageObjects.security.forceLogout(); + await security.forceLogout(); - await PageObjects.security.login( - 'global_visualize_all_user', - 'global_visualize_all_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('global_visualize_all_user', 'global_visualize_all_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); - await security.role.delete('global_visualize_all_role'); - await security.user.delete('global_visualize_all_user'); + await security.forceLogout(); + await securityService.role.delete('global_visualize_all_role'); + await securityService.user.delete('global_visualize_all_user'); }); it('shows visualize navlink', async () => { @@ -95,7 +88,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page shows "Create new Visualization" button`, async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await testSubjects.existOrFail('visualizationLandingPage', { timeout: config.get('timeouts.waitFor'), }); @@ -107,7 +100,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`can view existing Visualization`, async () => { - await PageObjects.common.navigateToActualUrl('visualize', '/edit/i-exist', { + await common.navigateToActualUrl('visualize', '/edit/i-exist', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); @@ -117,7 +110,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('can save existing Visualization', async () => { - await PageObjects.common.navigateToActualUrl('visualize', '/edit/i-exist', { + await common.navigateToActualUrl('visualize', '/edit/i-exist', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); @@ -131,7 +124,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await queryBar.clickQuerySubmitButton(); await testSubjects.click('showQueryBarMenu'); await savedQueryManagementComponent.saveNewQuery('foo', 'bar', true, false); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await savedQueryManagementComponent.savedQueryExistOrFail('foo'); await savedQueryManagementComponent.closeSavedQueryManagementComponent(); await testSubjects.click('showQueryBarMenu'); @@ -170,7 +163,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { true, false ); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await savedQueryManagementComponent.savedQueryExistOrFail('ok2'); await savedQueryManagementComponent.closeSavedQueryManagementComponent(); await testSubjects.click('showQueryBarMenu'); @@ -180,7 +173,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('global visualize read-only privileges', () => { before(async () => { - await security.role.create('global_visualize_read_role', { + await securityService.role.create('global_visualize_read_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -194,26 +187,22 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_visualize_read_user', { + await securityService.user.create('global_visualize_read_user', { password: 'global_visualize_read_user-password', roles: ['global_visualize_read_role'], full_name: 'test user', }); - await PageObjects.security.login( - 'global_visualize_read_user', - 'global_visualize_read_user-password', - { - expectSpaceSelector: false, - } - ); + await security.login('global_visualize_read_user', 'global_visualize_read_user-password', { + expectSpaceSelector: false, + }); }); after(async () => { // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); - await security.role.delete('global_visualize_read_role'); - await security.user.delete('global_visualize_read_user'); + await security.forceLogout(); + await securityService.role.delete('global_visualize_read_role'); + await securityService.user.delete('global_visualize_read_user'); }); it('shows visualize navlink', async () => { @@ -222,7 +211,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page shows "Create new Visualization" button`, async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await testSubjects.existOrFail('visualizationLandingPage', { timeout: config.get('timeouts.waitFor'), }); @@ -234,7 +223,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`can view existing Visualization`, async () => { - await PageObjects.common.navigateToActualUrl('visualize', '/edit/i-exist', { + await common.navigateToActualUrl('visualize', '/edit/i-exist', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); @@ -244,7 +233,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`can't save existing Visualization`, async () => { - await PageObjects.common.navigateToActualUrl('visualize', '/edit/i-exist', { + await common.navigateToActualUrl('visualize', '/edit/i-exist', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); @@ -284,7 +273,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('global visualize read-only with url_create privileges', () => { before(async () => { - await security.role.create('global_visualize_read_url_create_role', { + await securityService.role.create('global_visualize_read_url_create_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -298,13 +287,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('global_visualize_read_url_create_user', { + await securityService.user.create('global_visualize_read_url_create_user', { password: 'global_visualize_read_url_create_user-password', roles: ['global_visualize_read_url_create_role'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'global_visualize_read_url_create_user', 'global_visualize_read_url_create_user-password', { @@ -315,9 +304,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); - await security.role.delete('global_visualize_read_url_create_role'); - await security.user.delete('global_visualize_read_url_create_user'); + await security.forceLogout(); + await securityService.role.delete('global_visualize_read_url_create_role'); + await securityService.user.delete('global_visualize_read_url_create_user'); }); it('shows visualize navlink', async () => { @@ -326,7 +315,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`landing page shows "Create new Visualization" button`, async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await testSubjects.existOrFail('visualizationLandingPage', { timeout: 10000 }); await testSubjects.existOrFail('newItemButton'); }); @@ -336,7 +325,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`can view existing Visualization`, async () => { - await PageObjects.common.navigateToActualUrl('visualize', '/edit/i-exist', { + await common.navigateToActualUrl('visualize', '/edit/i-exist', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); @@ -344,7 +333,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`can't save existing Visualization`, async () => { - await PageObjects.common.navigateToActualUrl('visualize', '/edit/i-exist', { + await common.navigateToActualUrl('visualize', '/edit/i-exist', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); @@ -380,7 +369,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('no visualize privileges', () => { before(async () => { - await security.role.create('no_visualize_privileges_role', { + await securityService.role.create('no_visualize_privileges_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -394,13 +383,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ], }); - await security.user.create('no_visualize_privileges_user', { + await securityService.user.create('no_visualize_privileges_user', { password: 'no_visualize_privileges_user-password', roles: ['no_visualize_privileges_role'], full_name: 'test user', }); - await PageObjects.security.login( + await security.login( 'no_visualize_privileges_user', 'no_visualize_privileges_user-password', { expectSpaceSelector: false } @@ -409,25 +398,25 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { after(async () => { // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); - await security.role.delete('no_visualize_privileges_role'); - await security.user.delete('no_visualize_privileges_user'); + await security.forceLogout(); + await securityService.role.delete('no_visualize_privileges_role'); + await securityService.user.delete('no_visualize_privileges_user'); }); it(`landing page shows 403`, async () => { - await PageObjects.common.navigateToActualUrl('visualize', '', { + await common.navigateToActualUrl('visualize', '', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.error.expectForbidden(); + await error.expectForbidden(); }); it(`edit page shows 403`, async () => { - await PageObjects.common.navigateToActualUrl('visualize', '/edit/i-exist', { + await common.navigateToActualUrl('visualize', '/edit/i-exist', { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.error.expectForbidden(); + await error.expectForbidden(); }); }); }); diff --git a/x-pack/test/functional/apps/visualize/feature_controls/visualize_spaces.ts b/x-pack/test/functional/apps/visualize/feature_controls/visualize_spaces.ts index 1c57b71e0689b..8c806d6350ec8 100644 --- a/x-pack/test/functional/apps/visualize/feature_controls/visualize_spaces.ts +++ b/x-pack/test/functional/apps/visualize/feature_controls/visualize_spaces.ts @@ -14,7 +14,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const config = getService('config'); const spacesService = getService('spaces'); - const PageObjects = getPageObjects(['common', 'visualize', 'security', 'spaceSelector', 'error']); + const { common, error } = getPageObjects(['common', 'error']); const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); @@ -49,7 +49,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it('shows visualize navlink', async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); @@ -57,7 +57,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`can view existing Visualization`, async () => { - await PageObjects.common.navigateToActualUrl( + await common.navigateToActualUrl( 'visualize', `${VisualizeConstants.EDIT_PATH}/custom_i-exist`, { @@ -93,7 +93,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`doesn't show visualize navlink`, async () => { - await PageObjects.common.navigateToApp('home', { + await common.navigateToApp('home', { basePath: '/s/custom_space', }); const navLinks = (await appsMenu.readLinks()).map((link) => link.text); @@ -101,16 +101,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it(`create new visualization shows 404`, async () => { - await PageObjects.common.navigateToActualUrl('visualize', VisualizeConstants.CREATE_PATH, { + await common.navigateToActualUrl('visualize', VisualizeConstants.CREATE_PATH, { basePath: '/s/custom_space', ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await PageObjects.error.expectNotFound(); + await error.expectNotFound(); }); it(`edit visualization for object which doesn't exist shows 404`, async () => { - await PageObjects.common.navigateToActualUrl( + await common.navigateToActualUrl( 'visualize', `${VisualizeConstants.EDIT_PATH}/i-dont-exist`, { @@ -119,20 +119,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { shouldLoginIfPrompted: false, } ); - await PageObjects.error.expectNotFound(); + await error.expectNotFound(); }); it(`edit visualization for object which exists shows 404`, async () => { - await PageObjects.common.navigateToActualUrl( - 'visualize', - `${VisualizeConstants.EDIT_PATH}/i-exist`, - { - basePath: '/s/custom_space', - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - } - ); - await PageObjects.error.expectNotFound(); + await common.navigateToActualUrl('visualize', `${VisualizeConstants.EDIT_PATH}/i-exist`, { + basePath: '/s/custom_space', + ensureCurrentUrl: false, + shouldLoginIfPrompted: false, + }); + await error.expectNotFound(); }); }); }); diff --git a/x-pack/test/functional/apps/visualize/hybrid_visualization.ts b/x-pack/test/functional/apps/visualize/hybrid_visualization.ts index 223d4cd571dc1..3d5878689d48c 100644 --- a/x-pack/test/functional/apps/visualize/hybrid_visualization.ts +++ b/x-pack/test/functional/apps/visualize/hybrid_visualization.ts @@ -9,7 +9,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common', 'visualize', 'timePicker', 'visChart']); + const { common, visualize, visChart } = getPageObjects(['common', 'visualize', 'visChart']); const inspector = getService('inspector'); const kibanaServer = getService('kibanaServer'); @@ -30,7 +30,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await esArchiver.unload('x-pack/test/functional/es_archives/hybrid/logstash'); await esArchiver.unload('x-pack/test/functional/es_archives/hybrid/rollup'); await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); it('should render histogram line chart', async () => { @@ -88,10 +88,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const from = 'Aug 19, 2019 @ 01:55:07.240'; const to = 'Aug 22, 2019 @ 23:09:36.205'; - await PageObjects.common.setTime({ from, to }); - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.visualize.openSavedVisualization('hybrid_histogram_line_chart'); - await PageObjects.visChart.waitForVisualizationRenderingStabilized(); + await common.setTime({ from, to }); + await common.navigateToApp('visualize'); + await visualize.openSavedVisualization('hybrid_histogram_line_chart'); + await visChart.waitForVisualizationRenderingStabilized(); await inspector.open(); await inspector.setTablePageSize(50); await inspector.expectTableData(expectedData); diff --git a/x-pack/test/functional/apps/visualize/precalculated_histogram.ts b/x-pack/test/functional/apps/visualize/precalculated_histogram.ts index e757df5eb54c7..cb38a0f7dd66a 100644 --- a/x-pack/test/functional/apps/visualize/precalculated_histogram.ts +++ b/x-pack/test/functional/apps/visualize/precalculated_histogram.ts @@ -10,7 +10,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects([ + const { common, visualize, discover, visChart, visEditor, unifiedFieldList } = getPageObjects([ 'common', 'visualize', 'discover', @@ -33,28 +33,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('appears correctly in discover', async function () { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - await PageObjects.unifiedFieldList.clickFieldListItemAdd('histogram-content'); - const rowData = await PageObjects.discover.getDocTableIndex(1); + await common.navigateToApp('discover'); + await discover.waitUntilSearchingHasFinished(); + await unifiedFieldList.clickFieldListItemAdd('histogram-content'); + const rowData = await discover.getDocTableIndex(1); expect(rowData).to.contain('"values":[0.3,1,3,4.2,4.8]'); }); describe('works in visualizations', () => { before(async () => { - await PageObjects.visualize.navigateToNewAggBasedVisualization(); - await PageObjects.visualize.clickDataTable(); - await PageObjects.visualize.clickNewSearch('histogram-test'); - await PageObjects.visChart.waitForVisualization(); - await PageObjects.visEditor.clickMetricEditor(); + await visualize.navigateToNewAggBasedVisualization(); + await visualize.clickDataTable(); + await visualize.clickNewSearch('histogram-test'); + await visChart.waitForVisualization(); + await visEditor.clickMetricEditor(); }); const renderTableForAggregation = async (aggregation: string) => { - await PageObjects.visEditor.selectAggregation(aggregation, 'metrics'); - await PageObjects.visEditor.selectField('histogram-content', 'metrics'); - await PageObjects.visEditor.clickGo(); + await visEditor.selectAggregation(aggregation, 'metrics'); + await visEditor.selectField('histogram-content', 'metrics'); + await visEditor.clickGo(); - return PageObjects.visChart.getTableVisContent(); + return visChart.getTableVisContent(); }; it('with percentiles aggregation', async () => { diff --git a/x-pack/test/functional/apps/visualize/preserve_url.ts b/x-pack/test/functional/apps/visualize/preserve_url.ts index a19459ebfd8b7..aa4e9ee1dfe16 100644 --- a/x-pack/test/functional/apps/visualize/preserve_url.ts +++ b/x-pack/test/functional/apps/visualize/preserve_url.ts @@ -9,7 +9,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'visualize', 'spaceSelector', 'visChart']); + const { common, visualize, spaceSelector, visChart } = getPageObjects([ + 'common', + 'visualize', + 'spaceSelector', + 'visChart', + ]); const appsMenu = getService('appsMenu'); const globalNav = getService('globalNav'); const kibanaServer = getService('kibanaServer'); @@ -35,45 +40,45 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('goes back to last opened url', async () => { - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.visualize.openSavedVisualization('A Pie'); - await PageObjects.common.navigateToApp('home'); + await common.navigateToApp('visualize'); + await visualize.openSavedVisualization('A Pie'); + await common.navigateToApp('home'); await appsMenu.clickLink('Visualize Library'); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); const activeTitle = await globalNav.getLastBreadcrumb(); expect(activeTitle).to.be('A Pie'); }); it('remembers url after switching spaces', async function () { // default space - await PageObjects.common.navigateToApp('visualize'); - await PageObjects.visualize.openSavedVisualization('A Pie'); + await common.navigateToApp('visualize'); + await visualize.openSavedVisualization('A Pie'); - await PageObjects.spaceSelector.openSpacesNav(); - await PageObjects.spaceSelector.clickSpaceAvatar('another-space'); - await PageObjects.spaceSelector.expectHomePage('another-space'); + await spaceSelector.openSpacesNav(); + await spaceSelector.clickSpaceAvatar('another-space'); + await spaceSelector.expectHomePage('another-space'); // other space await appsMenu.clickLink('Visualize Library'); - await PageObjects.visualize.openSavedVisualization('A Pie in another space'); + await visualize.openSavedVisualization('A Pie in another space'); - await PageObjects.spaceSelector.openSpacesNav(); - await PageObjects.spaceSelector.clickSpaceAvatar('default'); - await PageObjects.spaceSelector.expectHomePage('default'); + await spaceSelector.openSpacesNav(); + await spaceSelector.clickSpaceAvatar('default'); + await spaceSelector.expectHomePage('default'); // default space await appsMenu.clickLink('Visualize Library'); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); const activeTitleDefaultSpace = await globalNav.getLastBreadcrumb(); expect(activeTitleDefaultSpace).to.be('A Pie'); - await PageObjects.spaceSelector.openSpacesNav(); - await PageObjects.spaceSelector.clickSpaceAvatar('another-space'); - await PageObjects.spaceSelector.expectHomePage('another-space'); + await spaceSelector.openSpacesNav(); + await spaceSelector.clickSpaceAvatar('another-space'); + await spaceSelector.expectHomePage('another-space'); // other space await appsMenu.clickLink('Visualize Library'); - await PageObjects.visChart.waitForVisualization(); + await visChart.waitForVisualization(); const activeTitleOtherSpace = await globalNav.getLastBreadcrumb(); expect(activeTitleOtherSpace).to.be('A Pie in another space'); }); diff --git a/x-pack/test/functional/apps/visualize/reporting.ts b/x-pack/test/functional/apps/visualize/reporting.ts index d6cdb5fedd728..0e08bea2990d7 100644 --- a/x-pack/test/functional/apps/visualize/reporting.ts +++ b/x-pack/test/functional/apps/visualize/reporting.ts @@ -21,11 +21,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const png = getService('png'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { reporting, common, visualize, visEditor, share } = getPageObjects([ 'reporting', 'common', - 'dashboard', - 'timePicker', 'visualize', 'visEditor', 'share', @@ -70,26 +68,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); afterEach(async () => { - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); }); it('is available if new', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); - await PageObjects.visualize.clickNewVisualization(); - await PageObjects.visualize.clickAggBasedVisualizations(); - await PageObjects.visualize.clickAreaChart(); - await PageObjects.visualize.clickNewSearch('ecommerce'); - await PageObjects.reporting.openExportTab(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await visualize.gotoVisualizationLandingPage(); + await visualize.clickNewVisualization(); + await visualize.clickAggBasedVisualizations(); + await visualize.clickAreaChart(); + await visualize.clickNewSearch('ecommerce'); + await reporting.openExportTab(); + expect(await reporting.isGenerateReportButtonDisabled()).to.be(null); }); it('becomes available when saved', async () => { - await PageObjects.visEditor.clickBucket('X-axis'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); - await PageObjects.visEditor.clickGo(); - await PageObjects.visualize.saveVisualization('my viz'); - await PageObjects.reporting.openExportTab(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await visEditor.clickBucket('X-axis'); + await visEditor.selectAggregation('Date Histogram'); + await visEditor.clickGo(); + await visualize.saveVisualization('my viz'); + await reporting.openExportTab(); + expect(await reporting.isGenerateReportButtonDisabled()).to.be(null); }); }); @@ -109,7 +107,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); log.debug('navigate to visualize'); - await PageObjects.common.navigateToApp('visualize'); + await common.navigateToApp('visualize'); }); after(async () => { @@ -120,28 +118,27 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); afterEach(async () => { - await PageObjects.share.closeShareModal(); + await share.closeShareModal(); }); // FAILING ARTIFACTS SNAPSHOT: https://github.com/elastic/kibana/issues/189590 it.skip('TSVB Gauge: PNG file matches the baseline image', async function () { log.debug('load saved visualization'); - await PageObjects.visualize.loadSavedVisualization( - '[K7.6-eCommerce] Sold Products per Day', - { navigateToVisualize: false } - ); + await visualize.loadSavedVisualization('[K7.6-eCommerce] Sold Products per Day', { + navigateToVisualize: false, + }); log.debug('open png reporting panel'); - await PageObjects.reporting.openExportTab(); + await reporting.openExportTab(); await testSubjects.click('pngV2-radioOption'); log.debug('click generate report button'); - await PageObjects.reporting.clickGenerateReportButton(); + await reporting.clickGenerateReportButton(); log.debug('get the report download URL'); - const url = await PageObjects.reporting.getReportURL(120000); + const url = await reporting.getReportURL(120000); log.debug('download the report'); - const reportData = await PageObjects.reporting.getRawReportData(url ?? ''); - const sessionReportPath = await PageObjects.reporting.writeSessionReport( + const reportData = await reporting.getRawReportData(url ?? ''); + const sessionReportPath = await reporting.writeSessionReport( reportFileName, 'png', reportData, @@ -151,7 +148,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // check the file const percentDiff = await png.checkIfPngsMatch( sessionReportPath, - PageObjects.reporting.getBaselineReportPath(reportFileName, 'png', REPORTS_FOLDER), + reporting.getBaselineReportPath(reportFileName, 'png', REPORTS_FOLDER), config.get('screenshots.directory') ); diff --git a/x-pack/test/functional/apps/visualize/telemetry.ts b/x-pack/test/functional/apps/visualize/telemetry.ts index 7fd176fdbb8a2..19c4ad83ce906 100644 --- a/x-pack/test/functional/apps/visualize/telemetry.ts +++ b/x-pack/test/functional/apps/visualize/telemetry.ts @@ -14,7 +14,7 @@ interface UiCounterEvent { } export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'dashboard', 'timePicker']); + const { dashboard, timePicker } = getPageObjects(['dashboard', 'timePicker']); const kibanaServer = getService('kibanaServer'); const esArchiver = getService('esArchiver'); @@ -38,10 +38,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await retry.try(async () => { - await PageObjects.dashboard.navigateToApp(); - await PageObjects.dashboard.loadSavedDashboard('visualizations'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.navigateToApp(); + await dashboard.loadSavedDashboard('visualizations'); + await timePicker.setDefaultAbsoluteRange(); + await dashboard.waitForRenderComplete(); uiCounterEvents = await usageCollection.getUICounterEvents(); @@ -86,11 +86,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { let afterRefreshRenderCountMap: Record = {}; before(async function () { - const sharedItemsCount = Number(await PageObjects.dashboard.getSharedItemsCount()); + const sharedItemsCount = Number(await dashboard.getSharedItemsCount()); initialRenderCountMap = await renderable.getRenderCount(sharedItemsCount); await queryBar.clickQuerySubmitButton(); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); afterRefreshRenderCountMap = await renderable.getRenderCount(sharedItemsCount); }); diff --git a/x-pack/test/functional/page_objects/canvas_page.ts b/x-pack/test/functional/page_objects/canvas_page.ts index a31148711e2ac..645808b603726 100644 --- a/x-pack/test/functional/page_objects/canvas_page.ts +++ b/x-pack/test/functional/page_objects/canvas_page.ts @@ -14,7 +14,7 @@ export function CanvasPageProvider({ getService, getPageObjects }: FtrProviderCo const testSubjects = getService('testSubjects'); const find = getService('find'); const browser = getService('browser'); - const PageObjects = getPageObjects(['common']); + const { common } = getPageObjects(['common']); return { async goToListingPage() { @@ -22,7 +22,7 @@ export function CanvasPageProvider({ getService, getPageObjects }: FtrProviderCo // disabling the current url check because canvas moved away from // hash router and redirects from /app/canvas#/ to /app/canvas/ // but navigateToUrl includes hash in the url which causes test flakiness - await PageObjects.common.navigateToUrl('canvas', '', { + await common.navigateToUrl('canvas', '', { ensureCurrentUrl: false, shouldUseHashForSubUrl: false, }); @@ -119,7 +119,7 @@ export function CanvasPageProvider({ getService, getPageObjects }: FtrProviderCo await testSubjects.click('add-element-button'); await testSubjects.click('saved-elements-menu-option'); - await PageObjects.common.sleep(1000); // give time for modal animation to complete + await common.sleep(1000); // give time for modal animation to complete }, async closeSavedElementsModal() { diff --git a/x-pack/test/functional/page_objects/gis_page.ts b/x-pack/test/functional/page_objects/gis_page.ts index 5d0fd7cd14947..3e067db7c3b09 100644 --- a/x-pack/test/functional/page_objects/gis_page.ts +++ b/x-pack/test/functional/page_objects/gis_page.ts @@ -630,7 +630,7 @@ export class GisPageObject extends FtrService { return mapboxStyle; } - async getResponse(requestName: string) { + async getResponse(requestName?: string) { await this.inspector.open(); const response = await this._getResponse(requestName); await this.inspector.close(); diff --git a/x-pack/test/functional/page_objects/lens_page.ts b/x-pack/test/functional/page_objects/lens_page.ts index 5c54fc99128f6..bf38c4e1bdebe 100644 --- a/x-pack/test/functional/page_objects/lens_page.ts +++ b/x-pack/test/functional/page_objects/lens_page.ts @@ -35,17 +35,16 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont const dashboardAddPanel = getService('dashboardAddPanel'); const queryBar = getService('queryBar'); - const PageObjects = getPageObjects([ - 'common', - 'header', - 'timePicker', - 'common', - 'visualize', - 'dashboard', - 'timeToVisualize', - 'unifiedSearch', - 'share', - ]); + const { common, header, timePicker, dashboard, timeToVisualize, unifiedSearch, share } = + getPageObjects([ + 'common', + 'header', + 'timePicker', + 'dashboard', + 'timeToVisualize', + 'unifiedSearch', + 'share', + ]); return logWrapper('lensPage', log, { /** @@ -69,13 +68,13 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont * a range that has data in our dataset. */ async goToTimeRange(fromTime?: string, toTime?: string) { - const from = fromTime || PageObjects.timePicker.defaultStartTime; - const to = toTime || PageObjects.timePicker.defaultEndTime; + const from = fromTime || timePicker.defaultStartTime; + const to = toTime || timePicker.defaultEndTime; await retry.try(async () => { - await PageObjects.timePicker.ensureHiddenNoDataPopover(); - await PageObjects.timePicker.setAbsoluteRange(from, to); + await timePicker.ensureHiddenNoDataPopover(); + await timePicker.setAbsoluteRange(from, to); // give some time for the update button tooltip to close - await PageObjects.common.sleep(500); + await common.sleep(500); }); }, @@ -208,7 +207,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont if (opts.formula) { // Formula takes time to open - await PageObjects.common.sleep(500); + await common.sleep(500); await this.typeFormula(opts.formula); } @@ -282,7 +281,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont testSubjects.getCssSelector('lnsGeoFieldWorkspace') ); await this.waitForLensDragDropToFinish(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }, /** @@ -414,7 +413,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await browser.pressKeys(browser.keys.ENTER); await this.waitForLensDragDropToFinish(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }, /** @@ -447,7 +446,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await browser.pressKeys(browser.keys.ENTER); await this.waitForLensDragDropToFinish(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }, /** * Selects draggable element and reorders it by number of `steps` @@ -470,7 +469,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await browser.pressKeys(browser.keys.ENTER); await this.waitForLensDragDropToFinish(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }, async waitForLensDragDropToFinish() { @@ -496,7 +495,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont testSubjects.getCssSelector(dimension) ); await this.waitForLensDragDropToFinish(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }, /** @@ -513,7 +512,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont testSubjects.getCssSelector(to) ); await this.waitForLensDragDropToFinish(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }, /** @@ -528,7 +527,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await find.existsByCssSelector(dragging); await browser.html5DragAndDrop(dragging, dropping); await this.waitForLensDragDropToFinish(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }, async assertPalette(paletteId: string, isLegacy: boolean) { @@ -693,12 +692,12 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont // To close the Filter popover we need to move to the label input and then press Enter: // solution is to press Tab 3 tims (first Tab will close the dropdown) instead of Enter to avoid // race condition with the dropdown - await PageObjects.common.pressTabKey(); - await PageObjects.common.pressTabKey(); - await PageObjects.common.pressTabKey(); + await common.pressTabKey(); + await common.pressTabKey(); + await common.pressTabKey(); // Now it is safe to press Enter as we're in the label input - await PageObjects.common.pressEnterKey(); - await PageObjects.common.sleep(1000); // give time for debounced components to rerender + await common.pressEnterKey(); + await common.sleep(1000); // give time for debounced components to rerender }, /** @@ -726,7 +725,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont async setTermsNumberOfValues(value: number) { const valuesInput = await this.getNumericFieldReady('indexPattern-terms-values'); await valuesInput.type(`${value}`); - await PageObjects.common.sleep(500); + await common.sleep(500); }, async checkTermsAreNotAvailableToAgg(fields: string[]) { @@ -757,7 +756,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont dashboardId?: string, description?: string ) { - await PageObjects.timeToVisualize.setSaveModalValues(title, { + await timeToVisualize.setSaveModalValues(title, { saveAsNew, redirectToOrigin, addToDashboard: addToDashboard ? addToDashboard : null, @@ -787,7 +786,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont dashboardId?: string, description?: string ) { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.click('lnsApp_saveButton'); await this.saveModal( @@ -823,7 +822,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont if (options?.decimals != null) { await testSubjects.setValue('indexPattern-dimension-formatDecimals', `${options.decimals}`); // press tab key to remove the range popover of the EUI field - await PageObjects.common.pressTabKey(); + await common.pressTabKey(); } if (options?.prefix != null) { await testSubjects.setValue('indexPattern-dimension-formatSuffix', options.prefix); @@ -832,7 +831,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont async editDimensionColor(color: string) { const colorPickerInput = await testSubjects.find('~indexPattern-dimension-colorPicker'); await colorPickerInput.type(color); - await PageObjects.common.sleep(1000); // give time for debounced components to rerender + await common.sleep(1000); // give time for debounced components to rerender }, hasVisualOptionsButton() { return testSubjects.exists('lnsVisualOptionsButton'); @@ -903,12 +902,12 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await this.openChartSwitchPopover(layerIndex); await this.waitForSearchInputValue(subVisualizationId, searchTerm); await testSubjects.click(`lnsChartSwitchPopover_${subVisualizationId}`); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }, async waitForSearchInputValue(subVisualizationId: string, searchTerm?: string) { await retry.try(async () => { await this.searchOnChartSwitch(subVisualizationId, searchTerm); - await PageObjects.common.sleep(1000); // give time for the value to be typed + await common.sleep(1000); // give time for the value to be typed const searchInputValue = await testSubjects.getAttribute('lnsChartSwitchSearch', 'value'); const queryTerm = searchTerm ?? subVisualizationId.substring(subVisualizationId.length - 3); if (searchInputValue !== queryTerm) { @@ -1100,32 +1099,32 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont * Changes the index pattern in the data panel */ async switchDataPanelIndexPattern(dataViewTitle: string) { - await PageObjects.unifiedSearch.switchDataView('lns-dataView-switch-link', dataViewTitle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedSearch.switchDataView('lns-dataView-switch-link', dataViewTitle); + await header.waitUntilLoadingHasFinished(); }, /** * Changes the index pattern for the first layer */ async switchFirstLayerIndexPattern(dataViewTitle: string) { - await PageObjects.unifiedSearch.switchDataView('lns_layerIndexPatternLabel', dataViewTitle); - await PageObjects.header.waitUntilLoadingHasFinished(); + await unifiedSearch.switchDataView('lns_layerIndexPatternLabel', dataViewTitle); + await header.waitUntilLoadingHasFinished(); }, /** * Returns the current index pattern of the first layer */ async getFirstLayerIndexPattern() { - return await PageObjects.unifiedSearch.getSelectedDataView('lns_layerIndexPatternLabel'); + return await unifiedSearch.getSelectedDataView('lns_layerIndexPatternLabel'); }, async linkedToOriginatingApp() { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('lnsApp_saveAndReturnButton'); }, async notLinkedToOriginatingApp() { - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await testSubjects.missingOrFail('lnsApp_saveAndReturnButton'); }, @@ -1295,7 +1294,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await retry.try(async () => { await testSubjects.click(`lns_colorEditing_trigger`); // wait for the UI to settle - await PageObjects.common.sleep(100); + await common.sleep(100); await testSubjects.existOrFail('lns-palettePanelFlyout', { timeout: 2500, }); @@ -1315,13 +1314,13 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont async setPalette(paletteId: string, isLegacy: boolean) { await testSubjects.click('lns_colorEditing_trigger'); // This action needs to be slowed WAY down, otherwise it will not correctly set the palette - await PageObjects.common.sleep(200); + await common.sleep(200); await testSubjects.setEuiSwitch( 'lns_colorMappingOrLegacyPalette_switch', isLegacy ? 'uncheck' : 'check' ); - await PageObjects.common.sleep(200); + await common.sleep(200); if (isLegacy) { await testSubjects.click('lns-palettePicker'); @@ -1330,7 +1329,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await testSubjects.click('kbnColoring_ColorMapping_PalettePicker'); await testSubjects.click(`kbnColoring_ColorMapping_Palette-${paletteId}`); } - await PageObjects.common.sleep(200); + await common.sleep(200); await this.closePaletteEditor(); }, @@ -1363,16 +1362,16 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont async toggleColumnVisibility(dimension: string, no = 1) { await this.openDimensionEditor(dimension); const id = 'lns-table-column-hidden'; - await PageObjects.common.sleep(500); + await common.sleep(500); const isChecked = await testSubjects.isEuiSwitchChecked(id); log.debug(`switch status before the toggle = ${isChecked}`); await testSubjects.setEuiSwitch(id, isChecked ? 'uncheck' : 'check'); - await PageObjects.common.sleep(500); + await common.sleep(500); const isChecked2 = await testSubjects.isEuiSwitchChecked(id); log.debug(`switch status after the toggle = ${isChecked2}`); await this.closeDimensionEditor(); - await PageObjects.common.sleep(500); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.sleep(500); + await header.waitUntilLoadingHasFinished(); }, async clickTableCellAction(rowIndex = 0, colIndex = 0, actionTestSub: string) { @@ -1495,9 +1494,9 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont ignoreTimeFilter?: boolean; }) { log.debug(`createAndAddLens${title}`); - const inViewMode = await PageObjects.dashboard.getIsInViewMode(); + const inViewMode = await dashboard.getIsInViewMode(); if (inViewMode) { - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); } await dashboardAddPanel.clickCreateNewLink(); @@ -1562,11 +1561,11 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont const renderingCount = await visualizationContainer.getAttribute('data-rendering-count'); return Number(renderingCount); } - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await retry.waitFor('rendering count to stabilize', async () => { const firstCount = await getRenderingCount(); - await PageObjects.common.sleep(1000); + await common.sleep(1000); const secondCount = await getRenderingCount(); @@ -1576,7 +1575,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont async switchToTextBasedLanguage(language: string) { await testSubjects.click('lns-dataView-switch-link'); - await PageObjects.unifiedSearch.selectTextBasedLanguage(language); + await unifiedSearch.selectTextBasedLanguage(language); }, async configureTextBasedLanguagesDimension(opts: { @@ -1747,7 +1746,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont await input.clearValueWithKeyboard({ charByChar: true }); await input.type(formula); // Debounce time for formula - await PageObjects.common.sleep(300); + await common.sleep(300); }, async expectFormulaText(formula: string) { @@ -1926,12 +1925,12 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont }, closeShareModal() { - return PageObjects.share.closeShareModal(); + return share.closeShareModal(); }, async getUrl() { await this.ensureShareMenuIsOpen('link'); - const url = await PageObjects.share.getSharedUrl(); + const url = await share.getSharedUrl(); if (!url) { throw Error('No data-share-url attribute found'); diff --git a/x-pack/test/localization/tests/lens/formula.ts b/x-pack/test/localization/tests/lens/formula.ts index a897a5f1c7ed8..dcb63b2bdb484 100644 --- a/x-pack/test/localization/tests/lens/formula.ts +++ b/x-pack/test/localization/tests/lens/formula.ts @@ -9,24 +9,24 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const elasticChart = getService('elasticChart'); describe('lens formula tests', () => { it('should allow creation of a lens chart via formula', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.goToTimeRange(); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'formula', formula: `ifelse(count() > 1, (count() + average(bytes)) / 2, 5)`, }); - expect(await PageObjects.lens.getWorkspaceErrorCount()).to.eql(0); - const data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + expect(await lens.getWorkspaceErrorCount()).to.eql(0); + const data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data).to.be.ok(); }); }); diff --git a/x-pack/test/localization/tests/lens/index.ts b/x-pack/test/localization/tests/lens/index.ts index 0f4c210357833..c54db350dd83b 100644 --- a/x-pack/test/localization/tests/lens/index.ts +++ b/x-pack/test/localization/tests/lens/index.ts @@ -9,7 +9,7 @@ import { EsArchiver } from '@kbn/es-archiver'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects, loadTestFile }: FtrProviderContext) { - const PageObjects = getPageObjects(['timePicker']); + const { timePicker } = getPageObjects(['timePicker']); const browser = getService('browser'); const config = getService('config'); const log = getService('log'); @@ -54,7 +54,7 @@ export default function ({ getService, getPageObjects, loadTestFile }: FtrProvid await esNode.load(esArchive); // changing the timepicker default here saves us from having to set it in Discover (~8s) - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: indexPatternString, 'dateFormat:tz': 'UTC', @@ -65,7 +65,7 @@ export default function ({ getService, getPageObjects, loadTestFile }: FtrProvid after(async () => { await esArchiver.unload(esArchive); - await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + await timePicker.resetDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.importExport.unload(fixtureDirs.lensBasic); await kibanaServer.importExport.unload(fixtureDirs.lensDefault); await kibanaServer.savedObjects.cleanStandardList(); diff --git a/x-pack/test/localization/tests/lens/smokescreen.ts b/x-pack/test/localization/tests/lens/smokescreen.ts index 82056c17df1ac..5e679febb5d63 100644 --- a/x-pack/test/localization/tests/lens/smokescreen.ts +++ b/x-pack/test/localization/tests/lens/smokescreen.ts @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; import { getI18nLocaleFromServerArgs } from '../utils'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']); + const { visualize, lens } = getPageObjects(['visualize', 'lens']); const find = getService('find'); const listingTable = getService('listingTable'); const testSubjects = getService('testSubjects'); @@ -168,49 +168,49 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should allow creation of lens xy chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: '@message.raw', }); - await PageObjects.lens.switchToVisualization('lnsDatatable', termTranslator('datatable')); - await PageObjects.lens.removeDimension('lnsDatatable_rows'); - await PageObjects.lens.switchToVisualization('bar', termTranslator('bar')); + await lens.switchToVisualization('lnsDatatable', termTranslator('datatable')); + await lens.removeDimension('lnsDatatable_rows'); + await lens.switchToVisualization('bar', termTranslator('bar')); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'ip', }); - await PageObjects.lens.save('Afancilenstest'); + await lens.save('Afancilenstest'); // Ensure the visualization shows up in the visualize list, and takes // us back to the visualization as we configured it. - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('Afancilenstest'); - await PageObjects.lens.clickVisualizeListItemTitle('Afancilenstest'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.clickVisualizeListItemTitle('Afancilenstest'); + await lens.goToTimeRange(); + await lens.waitForVisualization('xyVisChart'); - expect(await PageObjects.lens.getTitle()).to.eql('Afancilenstest'); + expect(await lens.getTitle()).to.eql('Afancilenstest'); // .echLegendItem__title is the only viable way of getting the xy chart's // legend item(s), so we're using a class selector here. @@ -219,473 +219,443 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should create an xy visualization with filters aggregation', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); // Change the IP field to filters - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-dimensionTrigger', operation: 'filters', keepOpen: true, }); - await PageObjects.lens.addFilterToAgg(`geo.src : CN`); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.addFilterToAgg(`geo.src : CN`); + await lens.waitForVisualization('xyVisChart'); // Verify that the field was persisted from the transition - expect(await PageObjects.lens.getFiltersAggLabels()).to.eql([`"ip" : *`, `geo.src : CN`]); + expect(await lens.getFiltersAggLabels()).to.eql([`"ip" : *`, `geo.src : CN`]); expect(await find.allByCssSelector('.echLegendItem')).to.have.length(2); }); it('should transition from metric to table to metric', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('Artistpreviouslyknownaslens'); - await PageObjects.lens.clickVisualizeListItemTitle('Artistpreviouslyknownaslens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.assertLegacyMetric(termTranslator('max', 'bytes'), '19,986'); - await PageObjects.lens.switchToVisualization('lnsDatatable', termTranslator('datatable')); - expect(await PageObjects.lens.getDatatableHeaderText()).to.eql( - termTranslator('max', 'bytes') - ); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('19,986'); - await PageObjects.lens.switchToVisualization( - 'lnsLegacyMetric', - termTranslator('legacyMetric') - ); - await PageObjects.lens.assertLegacyMetric(termTranslator('max', 'bytes'), '19,986'); + await lens.clickVisualizeListItemTitle('Artistpreviouslyknownaslens'); + await lens.goToTimeRange(); + await lens.assertLegacyMetric(termTranslator('max', 'bytes'), '19,986'); + await lens.switchToVisualization('lnsDatatable', termTranslator('datatable')); + expect(await lens.getDatatableHeaderText()).to.eql(termTranslator('max', 'bytes')); + expect(await lens.getDatatableCellText(0, 0)).to.eql('19,986'); + await lens.switchToVisualization('lnsLegacyMetric', termTranslator('legacyMetric')); + await lens.assertLegacyMetric(termTranslator('max', 'bytes'), '19,986'); }); it('should transition from a multi-layer stacked bar to a multi-layer line chart and correctly remove all layers', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.createLayer(); + await lens.createLayer(); - expect(await PageObjects.lens.hasChartSwitchWarning('line', termTranslator('line'))).to.eql( - false - ); + expect(await lens.hasChartSwitchWarning('line', termTranslator('line'))).to.eql(false); - await PageObjects.lens.switchToVisualization('line', termTranslator('line')); + await lens.switchToVisualization('line', termTranslator('line')); - expect(await PageObjects.lens.getLayerType(0)).to.eql(termTranslator('line')); - expect(await PageObjects.lens.getLayerType(1)).to.eql(termTranslator('bar')); + expect(await lens.getLayerType(0)).to.eql(termTranslator('line')); + expect(await lens.getLayerType(1)).to.eql(termTranslator('bar')); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'machine.ram', }); - expect(await PageObjects.lens.getLayerCount()).to.eql(2); - await PageObjects.lens.removeLayer(); - await PageObjects.lens.removeLayer(); + expect(await lens.getLayerCount()).to.eql(2); + await lens.removeLayer(); + await lens.removeLayer(); await testSubjects.existOrFail('workspace-drag-drop-prompt'); }); it('should transition selected layer in a multi layer bar using layer chart switch', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.createLayer('data', undefined, 'bar'); - expect(await PageObjects.lens.getLayerType(1)).to.eql(termTranslator('bar')); - await PageObjects.lens.configureDimension({ + await lens.createLayer('data', undefined, 'bar'); + expect(await lens.getLayerType(1)).to.eql(termTranslator('bar')); + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.src', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lns-layerPanel-1 > lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'machine.ram', }); // only changes one layer for compatible chart - await PageObjects.lens.switchToVisualization('line', termTranslator('line'), 1); + await lens.switchToVisualization('line', termTranslator('line'), 1); - expect(await PageObjects.lens.getLayerType(0)).to.eql(termTranslator('bar')); - expect(await PageObjects.lens.getLayerType(1)).to.eql(termTranslator('line')); + expect(await lens.getLayerType(0)).to.eql(termTranslator('bar')); + expect(await lens.getLayerType(1)).to.eql(termTranslator('line')); // generates new one layer chart based on selected layer - await PageObjects.lens.switchToVisualization('pie', termTranslator('pie'), 1); - expect(await PageObjects.lens.getLayerType(0)).to.eql(termTranslator('pie')); - const sliceByText = await PageObjects.lens.getDimensionTriggerText( - 'lnsPie_sliceByDimensionPanel' - ); - const sizeByText = await PageObjects.lens.getDimensionTriggerText( - 'lnsPie_sizeByDimensionPanel' - ); + await lens.switchToVisualization('pie', termTranslator('pie'), 1); + expect(await lens.getLayerType(0)).to.eql(termTranslator('pie')); + const sliceByText = await lens.getDimensionTriggerText('lnsPie_sliceByDimensionPanel'); + const sizeByText = await lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel'); expect(sliceByText).to.be(termTranslator('terms', 'geo.src', 5)); expect(sizeByText).to.be(termTranslator('average', 'machine.ram')); }); it('should edit settings of xy line chart', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.removeDimension('lnsXY_splitDimensionPanel'); - await PageObjects.lens.switchToVisualization('line', termTranslator('line')); - await PageObjects.lens.configureDimension({ + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + await lens.removeDimension('lnsXY_splitDimensionPanel'); + await lens.switchToVisualization('line', termTranslator('line')); + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'max', field: 'memory', keepOpen: true, }); - await PageObjects.lens.editDimensionLabel('Test of label'); - await PageObjects.lens.editDimensionFormat(termTranslator('Percent')); - await PageObjects.lens.editDimensionColor('#ff0000'); - await PageObjects.lens.openVisualOptions(); + await lens.editDimensionLabel('Test of label'); + await lens.editDimensionFormat(termTranslator('Percent')); + await lens.editDimensionColor('#ff0000'); + await lens.openVisualOptions(); - await PageObjects.lens.setCurvedLines('CURVE_MONOTONE_X'); - await PageObjects.lens.editMissingValues('Linear'); + await lens.setCurvedLines('CURVE_MONOTONE_X'); + await lens.editMissingValues('Linear'); - await PageObjects.lens.assertMissingValues(termTranslator('Linear')); + await lens.assertMissingValues(termTranslator('Linear')); - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); - await PageObjects.lens.assertColor('#ff0000'); + await lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); + await lens.assertColor('#ff0000'); await testSubjects.existOrFail('indexPattern-dimension-formatDecimals'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( - 'Test of label' - ); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql('Test of label'); }); it('should not show static value tab for data layers', async () => { - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); + await lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); // Quick functions and Formula tabs should be visible expect(await testSubjects.exists('lens-dimensionTabs-quickFunctions')).to.eql(true); expect(await testSubjects.exists('lens-dimensionTabs-formula')).to.eql(true); // Static value tab should not be visible expect(await testSubjects.exists('lens-dimensionTabs-static_value')).to.eql(false); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should be able to add very long labels and still be able to remove a dimension', async () => { - await PageObjects.lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); + await lens.openDimensionEditor('lnsXY_yDimensionPanel > lns-dimensionTrigger'); const longLabel = 'Veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryvery long label wrapping multiple lines'; - await PageObjects.lens.editDimensionLabel(longLabel); - await PageObjects.lens.waitForVisualization('xyVisChart'); - await PageObjects.lens.closeDimensionEditor(); + await lens.editDimensionLabel(longLabel); + await lens.waitForVisualization('xyVisChart'); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( - longLabel - ); - expect(await PageObjects.lens.canRemoveDimension('lnsXY_yDimensionPanel')).to.equal(true); - await PageObjects.lens.removeDimension('lnsXY_yDimensionPanel'); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql(longLabel); + expect(await lens.canRemoveDimension('lnsXY_yDimensionPanel')).to.equal(true); + await lens.removeDimension('lnsXY_yDimensionPanel'); await testSubjects.missingOrFail('lnsXY_yDimensionPanel > lns-dimensionTrigger'); }); it('should allow creation of a multi-axis chart and switching multiple times', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); await elasticChart.setNewChartUiDebugFlag(true); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('bar', termTranslator('bar')); + await lens.goToTimeRange(); + await lens.switchToVisualization('bar', termTranslator('bar')); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.dest', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'unique_count', field: 'bytes', keepOpen: true, }); - await PageObjects.lens.changeAxisSide('right'); - let data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await lens.changeAxisSide('right'); + let data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.axes?.y.length).to.eql(2); expect(data?.axes?.y.some(({ position }) => position === 'right')).to.eql(true); - await PageObjects.lens.changeAxisSide('left'); - data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + await lens.changeAxisSide('left'); + data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.axes?.y.length).to.eql(1); expect(data?.axes?.y.some(({ position }) => position === 'right')).to.eql(false); - await PageObjects.lens.changeAxisSide('right'); - await PageObjects.lens.waitForVisualization('xyVisChart'); + await lens.changeAxisSide('right'); + await lens.waitForVisualization('xyVisChart'); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); }); it('should show value labels on bar charts when enabled', async () => { // enable value labels - await PageObjects.lens.openTextOptions(); + await lens.openTextOptions(); await testSubjects.click('lns_valueLabels_inside'); // check for value labels - let data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + let data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.bars?.[0].labels).not.to.eql(0); // switch to stacked bar chart - await PageObjects.lens.switchToVisualization('bar', termTranslator('bar')); + await lens.switchToVisualization('bar', termTranslator('bar')); // check for value labels - data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.bars?.[0].labels).not.to.eql(0); }); it('should override axis title', async () => { const axisTitle = 'overridden axis'; - await PageObjects.lens.toggleToolbarPopover('lnsLeftAxisButton'); + await lens.toggleToolbarPopover('lnsLeftAxisButton'); await testSubjects.setValue('lnsyLeftAxisTitle', axisTitle, { clearWithKeyboard: true, }); - let data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + let data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.axes?.y?.[1].title).to.eql(axisTitle); // hide the gridlines await testSubjects.click('lnsshowyLeftAxisGridlines'); - data = await PageObjects.lens.getCurrentChartDebugState('xyVisChart'); + data = await lens.getCurrentChartDebugState('xyVisChart'); expect(data?.axes?.y?.[1].gridlines.length).to.eql(0); }); it('should transition from line chart to pie chart and to bar chart', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - expect(await PageObjects.lens.hasChartSwitchWarning('pie', termTranslator('pie'))).to.eql( - true - ); - await PageObjects.lens.switchToVisualization('pie', termTranslator('pie')); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + expect(await lens.hasChartSwitchWarning('pie', termTranslator('pie'))).to.eql(true); + await lens.switchToVisualization('pie', termTranslator('pie')); - expect(await PageObjects.lens.getTitle()).to.eql('lnsXYvis'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sliceByDimensionPanel')).to.eql( + expect(await lens.getTitle()).to.eql('lnsXYvis'); + expect(await lens.getDimensionTriggerText('lnsPie_sliceByDimensionPanel')).to.eql( termTranslator('terms', 'ip') ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( termTranslator('average', 'bytes') ); - expect(await PageObjects.lens.hasChartSwitchWarning('bar', termTranslator('bar'))).to.eql( - false - ); - await PageObjects.lens.switchToVisualization('bar', termTranslator('bar')); - expect(await PageObjects.lens.getTitle()).to.eql('lnsXYvis'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( + expect(await lens.hasChartSwitchWarning('bar', termTranslator('bar'))).to.eql(false); + await lens.switchToVisualization('bar', termTranslator('bar')); + expect(await lens.getTitle()).to.eql('lnsXYvis'); + expect(await lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( termTranslator('terms', 'ip') ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( termTranslator('average', 'bytes') ); }); it('should transition from bar chart to line chart', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('line', termTranslator('line')); - expect(await PageObjects.lens.getTitle()).to.eql('lnsXYvis'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( - '@timestamp' - ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + await lens.switchToVisualization('line', termTranslator('line')); + expect(await lens.getTitle()).to.eql('lnsXYvis'); + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql('@timestamp'); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( termTranslator('average', 'bytes') ); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( + expect(await lens.getDimensionTriggerText('lnsXY_splitDimensionPanel')).to.eql( termTranslator('terms', 'ip') ); }); it('should transition from pie chart to treemap chart', async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsPieVis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsPieVis'); - await PageObjects.lens.goToTimeRange(); - expect( - await PageObjects.lens.hasChartSwitchWarning('treemap', termTranslator('treemap')) - ).to.eql(false); - await PageObjects.lens.switchToVisualization('treemap', termTranslator('treemap')); - expect( - await PageObjects.lens.getDimensionTriggersTexts('lnsPie_groupByDimensionPanel') - ).to.eql([termTranslator('terms', 'geo.dest', 7), termTranslator('terms', 'geo.src')]); - expect(await PageObjects.lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( + await lens.clickVisualizeListItemTitle('lnsPieVis'); + await lens.goToTimeRange(); + expect(await lens.hasChartSwitchWarning('treemap', termTranslator('treemap'))).to.eql(false); + await lens.switchToVisualization('treemap', termTranslator('treemap')); + expect(await lens.getDimensionTriggersTexts('lnsPie_groupByDimensionPanel')).to.eql([ + termTranslator('terms', 'geo.dest', 7), + termTranslator('terms', 'geo.src'), + ]); + expect(await lens.getDimensionTriggerText('lnsPie_sizeByDimensionPanel')).to.eql( termTranslator('average', 'bytes') ); }); it('should create a pie chart and switch to datatable', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('pie', termTranslator('pie')); - await PageObjects.lens.configureDimension({ + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('pie', termTranslator('pie')); + await lens.configureDimension({ dimension: 'lnsPie_sliceByDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', disableEmptyRows: true, }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsPie_sizeByDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - expect( - await PageObjects.lens.hasChartSwitchWarning('lnsDatatable', termTranslator('datatable')) - ).to.eql(false); - await PageObjects.lens.switchToVisualization('lnsDatatable', termTranslator('datatable')); + expect(await lens.hasChartSwitchWarning('lnsDatatable', termTranslator('datatable'))).to.eql( + false + ); + await lens.switchToVisualization('lnsDatatable', termTranslator('datatable')); // Need to provide a fn for these - // expect(await PageObjects.lens.getDatatableHeaderText()).to.eql('@timestamp per 3 hours'); - expect(await PageObjects.lens.getDatatableHeaderText(1)).to.eql( - termTranslator('average', 'bytes') - ); - expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('2015-09-20 00:00'); - expect(await PageObjects.lens.getDatatableCellText(0, 1)).to.eql('6,011.351'); + // expect(await lens.getDatatableHeaderText()).to.eql('@timestamp per 3 hours'); + expect(await lens.getDatatableHeaderText(1)).to.eql(termTranslator('average', 'bytes')); + expect(await lens.getDatatableCellText(0, 0)).to.eql('2015-09-20 00:00'); + expect(await lens.getDatatableCellText(0, 1)).to.eql('6,011.351'); }); it('should create a heatmap chart and transition to barchart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('heatmap', termTranslator('heatmap')); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('heatmap', termTranslator('heatmap')); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsHeatmap_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsHeatmap_yDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'geo.dest', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsHeatmap_cellPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - expect(await PageObjects.lens.hasChartSwitchWarning('bar', termTranslator('bar'))).to.eql( - false - ); - await PageObjects.lens.switchToVisualization('bar', termTranslator('bar')); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql( - '@timestamp' - ); + expect(await lens.hasChartSwitchWarning('bar', termTranslator('bar'))).to.eql(false); + await lens.switchToVisualization('bar', termTranslator('bar')); + expect(await lens.getDimensionTriggerText('lnsXY_xDimensionPanel')).to.eql('@timestamp'); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.contain( - 'bytes' - ); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.contain('bytes'); }); it('should create a valid XY chart with references', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'moving_average', keepOpen: true, }); - await PageObjects.lens.configureReference({ + await lens.configureReference({ operation: termTranslator('sum'), field: 'bytes', }); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'cumulative_sum', keepOpen: true, }); - await PageObjects.lens.configureReference({ + await lens.configureReference({ field: termTranslator('Records'), }); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); // Two Y axes that are both valid expect(await find.allByCssSelector('.echLegendItem')).to.have.length(2); }); it('should allow formatting on references', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('lnsDatatable', termTranslator('datatable')); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('lnsDatatable', termTranslator('datatable')); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_rows > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', disableEmptyRows: true, }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsDatatable_metrics > lns-empty-dimension', operation: 'moving_average', keepOpen: true, }); - await PageObjects.lens.configureReference({ + await lens.configureReference({ operation: termTranslator('sum'), field: 'bytes', }); - await PageObjects.lens.editDimensionFormat(termTranslator('Number')); - await PageObjects.lens.closeDimensionEditor(); + await lens.editDimensionFormat(termTranslator('Number')); + await lens.closeDimensionEditor(); - await PageObjects.lens.waitForVisualization(); + await lens.waitForVisualization(); const values = await Promise.all( - range(0, 6).map((index) => PageObjects.lens.getDatatableCellText(index, 1)) + range(0, 6).map((index) => lens.getDatatableCellText(index, 1)) ); expect(values).to.eql([ '-', @@ -705,149 +675,143 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { * 3. Being able to switch charts while in partial config */ it('should handle edge cases in reference-based operations', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'cumulative_sum', }); - expect(await PageObjects.lens.getWorkspaceErrorCount()).to.eql(1); + expect(await lens.getWorkspaceErrorCount()).to.eql(1); - await PageObjects.lens.removeDimension('lnsXY_xDimensionPanel'); - expect(await PageObjects.lens.getWorkspaceErrorCount()).to.eql(2); + await lens.removeDimension('lnsXY_xDimensionPanel'); + expect(await lens.getWorkspaceErrorCount()).to.eql(2); - await PageObjects.lens.dragFieldToDimensionTrigger( + await lens.dragFieldToDimensionTrigger( '@timestamp', 'lnsXY_xDimensionPanel > lns-empty-dimension' ); - expect(await PageObjects.lens.getWorkspaceErrorCount()).to.eql(1); + expect(await lens.getWorkspaceErrorCount()).to.eql(1); - expect( - await PageObjects.lens.hasChartSwitchWarning('lnsDatatable', termTranslator('datatable')) - ).to.eql(false); - await PageObjects.lens.switchToVisualization('lnsDatatable', termTranslator('datatable')); + expect(await lens.hasChartSwitchWarning('lnsDatatable', termTranslator('datatable'))).to.eql( + false + ); + await lens.switchToVisualization('lnsDatatable', termTranslator('datatable')); // TODO: fix this later on - // expect(await PageObjects.lens.getDimensionTriggerText('lnsDatatable_metrics')).to.eql( + // expect(await lens.getDimensionTriggerText('lnsDatatable_metrics')).to.eql( // 'Cumulative sum of (incomplete)' // ); }); it('should keep the field selection while transitioning to every reference-based operation', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'counter_rate', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'cumulative_sum', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'differences', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'moving_average', }); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.contain( - 'bytes' - ); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.contain('bytes'); }); it('should not leave an incomplete column in the visualization config with field-based operation', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'min', }); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql( - undefined - ); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.eql(undefined); }); it('should revert to previous configuration and not leave an incomplete column in the visualization config with reference-based operations', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'moving_average', field: termTranslator('Records'), }); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.contain( + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.contain( termTranslator('moving_average') ); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'median', isPreviousIncompatible: true, keepOpen: true, }); - expect(await PageObjects.lens.isDimensionEditorOpen()).to.eql(true); + expect(await lens.isDimensionEditorOpen()).to.eql(true); - await PageObjects.lens.closeDimensionEditor(); + await lens.closeDimensionEditor(); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.contain( + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.contain( termTranslator('moving_average') ); }); it('should transition from unique count to last value', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'unique_count', field: 'ip', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-dimensionTrigger', operation: 'last_value', field: 'bytes', isPreviousIncompatible: true, }); - expect(await PageObjects.lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.contain( - 'bytes' - ); + expect(await lens.getDimensionTriggerText('lnsXY_yDimensionPanel')).to.contain('bytes'); }); it('should allow to change index pattern', async () => { @@ -857,34 +821,34 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { } else { indexPatternString = 'log*'; } - await PageObjects.lens.switchFirstLayerIndexPattern(indexPatternString); - expect(await PageObjects.lens.getFirstLayerIndexPattern()).to.equal(indexPatternString); + await lens.switchFirstLayerIndexPattern(indexPatternString); + expect(await lens.getFirstLayerIndexPattern()).to.equal(indexPatternString); }); it('should allow filtering by legend on an xy chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension', operation: 'date_histogram', field: '@timestamp', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsXY_splitDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'extension.raw', }); - await PageObjects.lens.filterLegend('jpg'); + await lens.filterLegend('jpg'); const hasExtensionFilter = await filterBar.hasFilter('extension.raw', 'jpg'); expect(hasExtensionFilter).to.be(true); @@ -892,30 +856,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should allow filtering by legend on a pie chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.lens.switchToVisualization('pie', termTranslator('pie')); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.goToTimeRange(); + await lens.switchToVisualization('pie', termTranslator('pie')); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsPie_sliceByDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'extension.raw', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsPie_sliceByDimensionPanel > lns-empty-dimension', operation: 'terms', field: 'agent.raw', }); - await PageObjects.lens.configureDimension({ + await lens.configureDimension({ dimension: 'lnsPie_sizeByDimensionPanel > lns-empty-dimension', operation: 'average', field: 'bytes', }); - await PageObjects.lens.filterLegend('jpg'); + await lens.filterLegend('jpg'); const hasExtensionFilter = await filterBar.hasFilter('extension.raw', 'jpg'); expect(hasExtensionFilter).to.be(true); @@ -923,16 +887,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should show visual options button group for a pie chart', async () => { - await PageObjects.visualize.navigateToNewVisualization(); - await PageObjects.visualize.clickVisType('lens'); - await PageObjects.lens.switchToVisualization('pie', termTranslator('pie')); + await visualize.navigateToNewVisualization(); + await visualize.clickVisType('lens'); + await lens.switchToVisualization('pie', termTranslator('pie')); - const hasVisualOptionsButton = await PageObjects.lens.hasVisualOptionsButton(); + const hasVisualOptionsButton = await lens.hasVisualOptionsButton(); expect(hasVisualOptionsButton).to.be(true); - await PageObjects.lens.openVisualOptions(); + await lens.openVisualOptions(); await retry.try(async () => { - expect(await PageObjects.lens.hasEmptySizeRatioButtonGroup()).to.be(true); + expect(await lens.hasEmptySizeRatioButtonGroup()).to.be(true); }); }); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/async_search.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/async_search.ts index eabb15dd1cd4c..c64eed898fee9 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/async_search.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/async_search.ts @@ -12,7 +12,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const es = getService('es'); const testSubjects = getService('testSubjects'); const log = getService('log'); - const PageObjects = getPageObjects(['common', 'header', 'dashboard', 'visChart']); + const { common, header, dashboard, visChart } = getPageObjects([ + 'common', + 'header', + 'dashboard', + 'visChart', + ]); const dashboardPanelActions = getService('dashboardPanelActions'); const queryBar = getService('queryBar'); const elasticChart = getService('elasticChart'); @@ -35,36 +40,36 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('not delayed should load', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('Not Delayed'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('dashboard'); + await dashboard.loadSavedDashboard('Not Delayed'); + await header.waitUntilLoadingHasFinished(); await dashboardExpect.noErrorEmbeddablesPresent(); await enableNewChartLibraryDebug(); - const data = await PageObjects.visChart.getBarChartData(xyChartSelector, 'Sum of bytes'); + const data = await visChart.getBarChartData(xyChartSelector, 'Sum of bytes'); expect(data.length).to.be(5); }); it('delayed should load', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('Delayed 5s'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('dashboard'); + await dashboard.loadSavedDashboard('Delayed 5s'); + await header.waitUntilLoadingHasFinished(); await dashboardExpect.noErrorEmbeddablesPresent(); await enableNewChartLibraryDebug(); - const data = await PageObjects.visChart.getBarChartData(xyChartSelector, 'Sum of bytes'); + const data = await visChart.getBarChartData(xyChartSelector, 'Sum of bytes'); expect(data.length).to.be(5); }); it('timed out should show error', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('Delayed 15s'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('dashboard'); + await dashboard.loadSavedDashboard('Delayed 15s'); + await header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('searchTimeoutError'); }); it('multiple searches are grouped and only single error popup is shown', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('Multiple delayed'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('dashboard'); + await dashboard.loadSavedDashboard('Multiple delayed'); + await header.waitUntilLoadingHasFinished(); // but only single error toast because searches are grouped expect((await testSubjects.findAll('searchTimeoutError')).length).to.be(1); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/index.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/index.ts index deb4a53190ff6..4aafb68de0e88 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/index.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/index.ts @@ -10,8 +10,8 @@ import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ loadTestFile, getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common']); const searchSessions = getService('searchSessions'); + const { common } = getPageObjects(['common']); describe('Dashboard', function () { before(async () => { @@ -22,7 +22,7 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid ); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); await kibanaServer.uiSettings.replace({ 'search:timeout': 10000 }); - await PageObjects.common.navigateToApp('dashboard'); + await common.navigateToApp('dashboard'); }); beforeEach(async () => { diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts index bb7f87dadc3a1..e38db3afe0a75 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts @@ -12,7 +12,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const es = getService('es'); const testSubjects = getService('testSubjects'); const log = getService('log'); - const PageObjects = getPageObjects([ + const { common, header, dashboard, visChart, searchSessionsManagement } = getPageObjects([ 'common', 'header', 'dashboard', @@ -39,7 +39,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('Skipping because this build does not have the required shard_delay agg'); this.skip(); } - await PageObjects.common.navigateToApp('dashboard'); + await common.navigateToApp('dashboard'); }); after(async function () { @@ -47,12 +47,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Restore using non-existing sessionId errors out. Refresh starts a new session and completes. Back button restores a session.', async () => { - await PageObjects.dashboard.loadSavedDashboard('Not Delayed'); + await dashboard.loadSavedDashboard('Not Delayed'); let url = await browser.getCurrentUrl(); const fakeSessionId = '__fake__'; const savedSessionURL = `${url}&searchSessionId=${fakeSessionId}`; await browser.get(savedSessionURL); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('restored'); await testSubjects.existOrFail('embeddableError'); // expected that panel errors out because of non existing session @@ -62,7 +62,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(session1).to.be(fakeSessionId); await queryBar.clickQuerySubmitButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('completed'); await dashboardExpect.noErrorEmbeddablesPresent(); const session2 = await dashboardPanelActions.getSearchSessionIdByTitle( @@ -78,7 +78,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { url = await browser.getCurrentUrl(); expect(url).to.contain('searchSessionId'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('restored'); expect( @@ -87,8 +87,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Saves and restores a session', async () => { - await PageObjects.dashboard.loadSavedDashboard('Not Delayed'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.loadSavedDashboard('Not Delayed'); + await dashboard.waitForRenderComplete(); await searchSessions.expectState('completed'); await searchSessions.save(); await searchSessions.expectState('backgroundCompleted'); @@ -100,8 +100,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const url = await browser.getCurrentUrl(); const savedSessionURL = `${url}&searchSessionId=${savedSessionId}`; await browser.get(savedSessionURL); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); // Check that session is restored await searchSessions.expectState('restored'); @@ -109,23 +109,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // switching dashboard to edit mode (or any other non-fetch required) state change // should leave session state untouched - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); await searchSessions.expectState('restored'); const xyChartSelector = 'xyVisChart'; await enableNewChartLibraryDebug(); - const data = await PageObjects.visChart.getBarChartData(xyChartSelector, 'Sum of bytes'); + const data = await visChart.getBarChartData(xyChartSelector, 'Sum of bytes'); expect(data.length).to.be(5); // navigating to a listing page clears the session - await PageObjects.dashboard.gotoDashboardLandingPage(); + await dashboard.gotoDashboardLandingPage(); await searchSessions.missingOrFail(); }); describe('TSVB & Timelion', () => { it('Restore session with TSVB & Timelion', async () => { - await PageObjects.dashboard.loadSavedDashboard('TSVBwithTimelion'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.loadSavedDashboard('TSVBwithTimelion'); + await dashboard.waitForRenderComplete(); await searchSessions.expectState('completed'); await searchSessions.save(); await searchSessions.expectState('backgroundCompleted'); @@ -136,15 +136,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await searchSessions.openPopover(); await searchSessions.viewSearchSessions(); - const searchSessionList = await PageObjects.searchSessionsManagement.getList(); + const searchSessionList = await searchSessionsManagement.getList(); const searchSessionItem = searchSessionList.find( (session) => session.id === savedSessionId )!; expect(searchSessionItem.searchesCount).to.be(2); await searchSessionItem.view(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); await searchSessions.expectState('restored'); expect(await toasts.getCount()).to.be(0); // no session restoration related warnings }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts index ad46f0a2add88..a73594e3b805a 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts @@ -11,13 +11,11 @@ import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const retry = getService('retry'); - const PageObjects = getPageObjects([ + const { common, header, dashboard, home, maps, searchSessionsManagement } = getPageObjects([ 'common', 'header', 'dashboard', - 'visChart', 'home', - 'timePicker', 'maps', 'searchSessionsManagement', ]); @@ -30,33 +28,33 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('save a search sessions with relative time', () => { before(async () => { - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // use sample data set because it has recent relative time range and bunch of different visualizations - await PageObjects.home.addSampleDataSet('flights'); + await home.addSampleDataSet('flights'); await retry.tryForTime(10000, async () => { - const isInstalled = await PageObjects.home.isSampleDataSetInstalled('flights'); + const isInstalled = await home.isSampleDataSetInstalled('flights'); expect(isInstalled).to.be(true); }); - await PageObjects.common.navigateToApp('dashboard'); + await common.navigateToApp('dashboard'); }); after(async () => { - await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToUrl('home', '/tutorial_directory/sampleData', { useActualUrl: true, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.removeSampleDataSet('flights'); - const isInstalled = await PageObjects.home.isSampleDataSetInstalled('flights'); + await header.waitUntilLoadingHasFinished(); + await home.removeSampleDataSet('flights'); + const isInstalled = await home.isSampleDataSetInstalled('flights'); expect(isInstalled).to.be(false); }); it('Saves and restores a session with relative time ranges', async () => { - await PageObjects.dashboard.loadSavedDashboard('[Flights] Global Flight Dashboard'); - await PageObjects.dashboard.waitForRenderComplete(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await dashboard.loadSavedDashboard('[Flights] Global Flight Dashboard'); + await dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('completed'); await searchSessions.save(); @@ -65,14 +63,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await checkSampleDashboardLoaded('xyVisChart'); // load URL to restore a saved session - await PageObjects.searchSessionsManagement.goTo(); - const searchSessionList = await PageObjects.searchSessionsManagement.getList(); + await searchSessionsManagement.goTo(); + const searchSessionList = await searchSessionsManagement.getList(); // navigate to dashboard await searchSessionList[0].view(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); await checkSampleDashboardLoaded('xyVisChart'); // Check that session is restored @@ -99,7 +97,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardPanelActions.openInspectorByTitle('[Flights] Origin Time Delayed'); await inspector.openInspectorView('Requests'); const requestStats = await inspector.getTableData(); - const totalHits = PageObjects.maps.getInspectorStatRowHit(requestStats, 'Hits'); + const totalHits = maps.getInspectorStatRowHit(requestStats, 'Hits'); expect(totalHits).to.equal('0'); await inspector.close(); } diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/search_sessions_tour.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/search_sessions_tour.ts index 86b7f41abf4eb..1d8588c4b99d9 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/search_sessions_tour.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/search_sessions_tour.ts @@ -10,7 +10,7 @@ import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const es = getService('es'); const log = getService('log'); - const PageObjects = getPageObjects(['common', 'header', 'dashboard', 'visChart']); + const { common, header, dashboard } = getPageObjects(['common', 'header', 'dashboard']); const browser = getService('browser'); const searchSessions = getService('searchSessions'); const kibanaServer = getService('kibanaServer'); @@ -27,7 +27,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async () => { - await PageObjects.common.navigateToApp('dashboard'); + await common.navigateToApp('dashboard'); await searchSessions.markTourUndone(); }); @@ -38,23 +38,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('search session popover auto opens when search is taking a while', async () => { - await PageObjects.dashboard.loadSavedDashboard('Delayed 15s'); + await dashboard.loadSavedDashboard('Delayed 15s'); await searchSessions.openedOrFail(); // tour auto opens when there is a long running search - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('completed'); const url = await browser.getCurrentUrl(); const fakeSessionId = '__fake__'; const savedSessionURL = `${url}&searchSessionId=${fakeSessionId}`; await browser.get(savedSessionURL); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('restored'); await searchSessions.openedOrFail(); // tour auto opens on first restore await browser.get(savedSessionURL); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('restored'); await searchSessions.closedOrFail(); // do not open on next restore }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/session_searches_integration.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/session_searches_integration.ts index 0a6b4f0625e95..9fdad941c208d 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/session_searches_integration.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/session_searches_integration.ts @@ -13,11 +13,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const kibanaServer = getService('kibanaServer'); const browser = getService('browser'); - const PageObjects = getPageObjects([ + const { common, dashboard, searchSessionsManagement } = getPageObjects([ 'common', - 'header', 'dashboard', - 'visChart', 'searchSessionsManagement', ]); const toasts = getService('toasts'); @@ -36,7 +34,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('Skipping because this build does not have the required shard_delay agg'); this.skip(); } - await PageObjects.common.navigateToApp('dashboard'); + await common.navigateToApp('dashboard'); }); after(async function () { @@ -44,8 +42,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('until session is saved search keepAlive is short, when it is saved, keepAlive is extended and search is saved into the session saved object, when session is extended, searches are also extended', async () => { - await PageObjects.dashboard.loadSavedDashboard('Not Delayed'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.loadSavedDashboard('Not Delayed'); + await dashboard.waitForRenderComplete(); await searchSessions.expectState('completed'); const searchResponse = await dashboardPanelActions.getSearchResponseByTitle( @@ -86,7 +84,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await searchSessions.openPopover(); await searchSessions.viewSearchSessions(); - const searchSessionList = await PageObjects.searchSessionsManagement.getList(); + const searchSessionList = await searchSessionsManagement.getList(); const searchSessionItem = searchSessionList.find((session) => session.id === savedSessionId)!; expect(searchSessionItem.searchesCount).to.be(1); @@ -101,9 +99,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('When session is deleted, searches are also deleted', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('Not Delayed'); - await PageObjects.dashboard.waitForRenderComplete(); + await common.navigateToApp('dashboard'); + await dashboard.loadSavedDashboard('Not Delayed'); + await dashboard.waitForRenderComplete(); await searchSessions.expectState('completed'); const searchResponse = await dashboardPanelActions.getSearchResponseByTitle( @@ -125,7 +123,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await searchSessions.openPopover(); await searchSessions.viewSearchSessions(); - const searchSessionList = await PageObjects.searchSessionsManagement.getList(); + const searchSessionList = await searchSessionsManagement.getList(); const searchSessionItem = searchSessionList.find((session) => session.id === savedSessionId)!; expect(searchSessionItem.searchesCount).to.be(1); await searchSessionItem.delete(); @@ -140,7 +138,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Slow lens with other bucket', () => { before(async function () { await kibanaServer.uiSettings.unset('search:timeout'); - await PageObjects.common.navigateToApp('dashboard', { insertTimestamp: false }); + await common.navigateToApp('dashboard', { insertTimestamp: false }); await browser.execute(() => { window.ELASTIC_LENS_DELAY_SECONDS = 25; }); @@ -156,7 +154,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('Other bucket should be added to a session when restoring', async () => { // not using regular navigation method, because don't want to wait until all panels load - // await PageObjects.dashboard.loadSavedDashboard('Lens with other bucket'); + // await dashboard.loadSavedDashboard('Lens with other bucket'); await listingTable.clickItemLink('dashboard', 'Lens with other bucket'); await testSubjects.missingOrFail('dashboardLandingPage'); @@ -171,7 +169,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await searchSessions.openPopover(); await searchSessions.viewSearchSessions(); - let searchSessionList = await PageObjects.searchSessionsManagement.getList(); + let searchSessionList = await searchSessionsManagement.getList(); let searchSessionItem = searchSessionList.find((session) => session.id === savedSessionId)!; expect(searchSessionItem.searchesCount).to.be(1); await new Promise((resolve) => setTimeout(resolve, 10000)); @@ -189,7 +187,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await searchSessions.openPopover(); await searchSessions.viewSearchSessions(); - searchSessionList = await PageObjects.searchSessionsManagement.getList(); + searchSessionList = await searchSessionsManagement.getList(); searchSessionItem = searchSessionList.find((session) => session.id === savedSessionId)!; expect(searchSessionItem.searchesCount).to.be(2); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts index 79b98e4741e0d..e9356912ee92a 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts @@ -10,14 +10,12 @@ import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const spacesService = getService('spaces'); - const security = getService('security'); - const PageObjects = getPageObjects([ + const securityService = getService('security'); + const { common, header, dashboard, security, searchSessionsManagement } = getPageObjects([ 'common', 'header', 'dashboard', - 'visChart', 'security', - 'timePicker', 'searchSessionsManagement', ]); const dashboardPanelActions = getService('dashboardPanelActions'); @@ -33,10 +31,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => await load(['minimal_read', 'store_search_session'])); it('Saves and restores a session', async () => { - await PageObjects.common.navigateToApp('dashboard', { basePath: 's/another-space' }); - await PageObjects.dashboard.loadSavedDashboard('A Dashboard in another space'); + await common.navigateToApp('dashboard', { basePath: 's/another-space' }); + await dashboard.loadSavedDashboard('A Dashboard in another space'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await searchSessions.expectState('completed'); await searchSessions.save(); @@ -52,7 +50,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // https://github.com/elastic/kibana/issues/106074#issuecomment-920462094 await browser.refresh(); - const searchSessionList = await PageObjects.searchSessionsManagement.getList(); + const searchSessionList = await searchSessionsManagement.getList(); const searchSessionItem = searchSessionList.find( (session) => session.id === savedSessionId ); @@ -62,8 +60,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // navigate to discover await searchSessionItem.view(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); // Check that session is restored await searchSessions.expectState('restored'); @@ -75,17 +73,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => await load(['minimal_read'])); it("Doesn't allow to store a session", async () => { - await PageObjects.common.navigateToApp('dashboard', { basePath: 's/another-space' }); - await PageObjects.dashboard.loadSavedDashboard('A Dashboard in another space'); + await common.navigateToApp('dashboard', { basePath: 's/another-space' }); + await dashboard.loadSavedDashboard('A Dashboard in another space'); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboard.waitForRenderComplete(); await searchSessions.expectState('completed'); await searchSessions.disabledOrFail(); }); }); }); - async function load(dashboard: string[]) { + async function load(dashboards: string[]) { await kibanaServer.importExport.load( `x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_space` ); @@ -103,38 +101,38 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { { space: 'another-space' } ); - await security.role.create('data_analyst', { + await securityService.role.create('data_analyst', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['all'] }], }, kibana: [ { feature: { - dashboard, + dashboard: dashboards, }, spaces: ['another-space'], }, ], }); - await security.user.create('analyst', { + await securityService.user.create('analyst', { password: 'analyst-password', roles: ['data_analyst'], full_name: 'test user', }); - await PageObjects.security.forceLogout(); + await security.forceLogout(); - await PageObjects.security.login('analyst', 'analyst-password', { + await security.login('analyst', 'analyst-password', { expectSpaceSelector: false, }); } async function clean() { await kibanaServer.savedObjects.cleanStandardList(); // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); - await security.role.delete('data_analyst'); - await security.user.delete('analyst'); + await security.forceLogout(); + await securityService.role.delete('data_analyst'); + await securityService.user.delete('analyst'); await spacesService.delete('another-space'); await searchSessions.deleteAllSearchSessions(); } diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/session_sharing/index.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/session_sharing/index.ts index 021842a53191a..bae4cdb3f7e3a 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/session_sharing/index.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/session_sharing/index.ts @@ -10,14 +10,14 @@ import { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ loadTestFile, getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['common']); const searchSessions = getService('searchSessions'); + const { common } = getPageObjects(['common']); describe('Search session sharing', function () { before(async () => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); - await PageObjects.common.navigateToApp('dashboard'); + await common.navigateToApp('dashboard'); }); after(async () => { diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/session_sharing/lens.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/session_sharing/lens.ts index 39253534c54c7..2942e31ee2f77 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/session_sharing/lens.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/session_sharing/lens.ts @@ -12,9 +12,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const dashboardAddPanel = getService('dashboardAddPanel'); const find = getService('find'); - const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['header', 'common', 'dashboard', 'timePicker', 'lens']); + const { common, dashboard, lens } = getPageObjects(['common', 'dashboard', 'lens']); // Dashboard shares a search session with lens when navigating to and from by value lens to hit search cache // https://github.com/elastic/kibana/issues/99310 @@ -23,8 +22,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.importExport.load( 'x-pack/test/functional/fixtures/kbn_archiver/lens/lens_basic.json' ); - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.preserveCrossAppState(); + await common.navigateToApp('dashboard'); + await dashboard.preserveCrossAppState(); }); after(async () => { @@ -39,35 +38,34 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it("should share search session with by value lens and don't share with by reference", async () => { // Add a by ref lens panel to a new dashboard const lensTitle = 'Artistpreviouslyknownaslens'; - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.clickNewDashboard(); await dashboardAddPanel.clickOpenAddPanel(); await dashboardAddPanel.filterEmbeddableNames(lensTitle); await find.clickByButtonText(lensTitle); await dashboardAddPanel.closeAddPanel(); - await PageObjects.lens.goToTimeRange(); - await PageObjects.dashboard.waitForRenderComplete(); + await lens.goToTimeRange(); + await dashboard.waitForRenderComplete(); // Navigating to lens and back should create a new session const byRefSessionId = await dashboardPanelActions.getSearchSessionIdByTitle(lensTitle); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.lens.saveAndReturn(); - await PageObjects.dashboard.waitForRenderComplete(); + await lens.saveAndReturn(); + await dashboard.waitForRenderComplete(); const newByRefSessionId = await dashboardPanelActions.getSearchSessionIdByTitle(lensTitle); expect(byRefSessionId).not.to.eql(newByRefSessionId); // Convert to by-value - const byRefPanel = await testSubjects.find('embeddablePanelHeading-' + lensTitle); - await dashboardPanelActions.legacyUnlinkFromLibrary(byRefPanel); - await PageObjects.dashboard.waitForRenderComplete(); + await dashboardPanelActions.legacyUnlinkFromLibrary(lensTitle); + await dashboard.waitForRenderComplete(); const byValueSessionId = await dashboardPanelActions.getSearchSessionIdByTitle(lensTitle); // Navigating to lens and back should keep the session await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickEdit(); - await PageObjects.lens.saveAndReturn(); - await PageObjects.dashboard.waitForRenderComplete(); + await lens.saveAndReturn(); + await dashboard.waitForRenderComplete(); const newByValueSessionId = await dashboardPanelActions.getSearchSessionIdByTitle(lensTitle); expect(byValueSessionId).to.eql(newByValueSessionId); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts index 7fdea1ff3d648..21c613f506706 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts @@ -15,14 +15,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const browser = getService('browser'); const inspector = getService('inspector'); - const PageObjects = getPageObjects([ - 'discover', - 'common', - 'timePicker', - 'header', - 'context', - 'searchSessionsManagement', - ]); + const { discover, common, timePicker, header, context, searchSessionsManagement } = + getPageObjects([ + 'discover', + 'common', + 'timePicker', + 'header', + 'context', + 'searchSessionsManagement', + ]); const searchSessions = getService('searchSessions'); const retry = getService('retry'); const kibanaServer = getService('kibanaServer'); @@ -37,9 +38,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ enableESQL: true, }); - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); + await header.waitUntilLoadingHasFinished(); }); after(async () => { await kibanaServer.importExport.unload( @@ -60,14 +61,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const fakeSearchSessionId = '__test__'; const savedSessionURL = url + `&searchSessionId=${fakeSearchSessionId}`; await browser.navigateTo(savedSessionURL); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('restored'); await testSubjects.existOrFail('discoverErrorCalloutTitle'); // expect error because of fake searchSessionId await toasts.dismissAll(); const searchSessionId1 = await getSearchSessionId(); expect(searchSessionId1).to.be(fakeSearchSessionId); await queryBar.clickQuerySubmitButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('completed'); const searchSessionId2 = await getSearchSessionId(); expect(searchSessionId2).not.to.be(searchSessionId1); @@ -80,7 +81,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { url = await browser.getCurrentUrl(); expect(url).to.contain('searchSessionId'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); // Note this currently fails, for some reason the fakeSearchSessionId is not restored await searchSessions.expectState('restored'); expect(await getSearchSessionId()).to.be(fakeSearchSessionId); @@ -89,12 +90,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { // clean up page to get out of error state before proceeding to next test await toasts.dismissAll(); await queryBar.clickQuerySubmitButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); }); it('navigation to context cleans the session', async () => { - const table = await PageObjects.discover.getDocTable(); - const isLegacy = await PageObjects.discover.useLegacyTable(); + const table = await discover.getDocTable(); + const isLegacy = await discover.useLegacyTable(); await table.clickRowToggle({ rowIndex: 0 }); await retry.try(async () => { @@ -106,47 +107,47 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await rowActions[idxToClick].click(); }); - await PageObjects.context.waitUntilContextLoadingHasFinished(); + await context.waitUntilContextLoadingHasFinished(); await searchSessions.missingOrFail(); }); it('relative timerange works', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await header.waitUntilLoadingHasFinished(); await searchSessions.save(); await searchSessions.expectState('backgroundCompleted'); const searchSessionId = await getSearchSessionId(); - expect(await PageObjects.discover.hasNoResults()).to.be(true); + expect(await discover.hasNoResults()).to.be(true); log.info('searchSessionId', searchSessionId); // load URL to restore a saved session - await PageObjects.searchSessionsManagement.goTo(); - const searchSessionListBeforeRestore = await PageObjects.searchSessionsManagement.getList(); + await searchSessionsManagement.goTo(); + const searchSessionListBeforeRestore = await searchSessionsManagement.getList(); const searchesCountBeforeRestore = searchSessionListBeforeRestore[0].searchesCount; // navigate to Discover await searchSessionListBeforeRestore[0].view(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await searchSessions.expectState('restored'); - expect(await PageObjects.discover.hasNoResults()).to.be(true); + expect(await discover.hasNoResults()).to.be(true); expect(await toasts.getCount()).to.be(0); // no session restoration related warnings - await PageObjects.searchSessionsManagement.goTo(); - const searchSessionListAfterRestore = await PageObjects.searchSessionsManagement.getList(); + await searchSessionsManagement.goTo(); + const searchSessionListAfterRestore = await searchSessionsManagement.getList(); const searchesCountAfterRestore = searchSessionListAfterRestore[0].searchesCount; expect(searchesCountBeforeRestore).to.be(searchesCountAfterRestore); // no new searches started during restore }); it('should should clean the search session when navigating to ESQL mode, and reinitialize when navigating back', async () => { - await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await common.navigateToApp('discover'); + await timePicker.setDefaultAbsoluteRange(); + await header.waitUntilLoadingHasFinished(); expect(await searchSessions.exists()).to.be(true); - await PageObjects.discover.selectTextBaseLang(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await discover.selectTextBaseLang(); + await header.waitUntilLoadingHasFinished(); await searchSessions.missingOrFail(); await browser.goBack(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); expect(await searchSessions.exists()).to.be(true); }); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts b/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts index 6c6228aa0056f..8e545d7878d52 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts @@ -11,17 +11,17 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const spacesService = getService('spaces'); - const security = getService('security'); + const securityService = getService('security'); const inspector = getService('inspector'); - const PageObjects = getPageObjects([ - 'common', - 'header', - 'discover', - 'visChart', - 'security', - 'timePicker', - 'searchSessionsManagement', - ]); + const { common, header, discover, security, timePicker, searchSessionsManagement } = + getPageObjects([ + 'common', + 'header', + 'discover', + 'security', + 'timePicker', + 'searchSessionsManagement', + ]); const browser = getService('browser'); const searchSessions = getService('searchSessions'); const kibanaServer = getService('kibanaServer'); @@ -33,11 +33,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => await load(['all'])); it('Saves and restores a session', async () => { - await PageObjects.common.navigateToApp('discover', { basePath: 's/another-space' }); + await common.navigateToApp('discover', { basePath: 's/another-space' }); - await PageObjects.discover.selectIndexPattern('logstash-*'); + await discover.selectIndexPattern('logstash-*'); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await discover.waitForDocTableLoadingComplete(); await searchSessions.expectState('completed'); await searchSessions.save(); @@ -56,7 +56,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // https://github.com/elastic/kibana/issues/106074#issuecomment-920462094 await browser.refresh(); - const searchSessionList = await PageObjects.searchSessionsManagement.getList(); + const searchSessionList = await searchSessionsManagement.getList(); const searchSessionItem = searchSessionList.find( (session) => session.id === savedSessionId ); @@ -66,8 +66,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // navigate to discover await searchSessionItem.view(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await header.waitUntilLoadingHasFinished(); + await discover.waitForDocTableLoadingComplete(); // Check that session is restored await searchSessions.expectState('restored'); @@ -78,23 +78,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { before(async () => await load(['read'])); it("Doesn't allow to store a session", async () => { - await PageObjects.common.navigateToApp('discover', { basePath: 's/another-space' }); + await common.navigateToApp('discover', { basePath: 's/another-space' }); - await PageObjects.discover.selectIndexPattern('logstash-*'); + await discover.selectIndexPattern('logstash-*'); - await PageObjects.timePicker.setAbsoluteRange( + await timePicker.setAbsoluteRange( 'Sep 1, 2015 @ 00:00:00.000', 'Oct 1, 2015 @ 00:00:00.000' ); - await PageObjects.discover.waitForDocTableLoadingComplete(); + await discover.waitForDocTableLoadingComplete(); await searchSessions.expectState('completed'); await searchSessions.disabledOrFail(); }); }); }); - async function load(discover: string[]) { + async function load(discoverIDs: string[]) { await kibanaServer.importExport.load( `x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_space` ); @@ -112,29 +112,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { { space: 'another-space' } ); - await security.role.create('data_analyst', { + await securityService.role.create('data_analyst', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['all'] }], }, kibana: [ { feature: { - discover, + discover: discoverIDs, }, spaces: ['another-space'], }, ], }); - await security.user.create('analyst', { + await securityService.user.create('analyst', { password: 'analyst-password', roles: ['data_analyst'], full_name: 'test user', }); - await PageObjects.security.forceLogout(); + await security.forceLogout(); - await PageObjects.security.login('analyst', 'analyst-password', { + await security.login('analyst', 'analyst-password', { expectSpaceSelector: false, }); } @@ -143,9 +143,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'x-pack/test/functional/fixtures/kbn_archiver/dashboard/session_in_space' ); // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await PageObjects.security.forceLogout(); - await security.role.delete('data_analyst'); - await security.user.delete('analyst'); + await security.forceLogout(); + await securityService.role.delete('data_analyst'); + await securityService.user.delete('analyst'); await spacesService.delete('another-space'); await searchSessions.deleteAllSearchSessions(); } diff --git a/x-pack/test/search_sessions_integration/tests/apps/lens/search_sessions.ts b/x-pack/test/search_sessions_integration/tests/apps/lens/search_sessions.ts index 9690f9be99fc6..01359da876a55 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/lens/search_sessions.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/lens/search_sessions.ts @@ -11,7 +11,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const searchSession = getService('searchSessions'); - const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'timePicker', 'header']); + const { visualize, lens, header } = getPageObjects(['visualize', 'lens', 'header']); const listingTable = getService('listingTable'); const kibanaServer = getService('kibanaServer'); @@ -29,12 +29,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); it("doesn't shows search sessions indicator UI", async () => { - await PageObjects.visualize.gotoVisualizationLandingPage(); + await visualize.gotoVisualizationLandingPage(); await listingTable.searchForItemWithName('lnsXYvis'); - await PageObjects.lens.clickVisualizeListItemTitle('lnsXYvis'); - await PageObjects.lens.goToTimeRange(); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect(await PageObjects.lens.isShowingNoResults()).to.be(false); + await lens.clickVisualizeListItemTitle('lnsXYvis'); + await lens.goToTimeRange(); + await header.waitUntilLoadingHasFinished(); + expect(await lens.isShowingNoResults()).to.be(false); await searchSession.missingOrFail(); }); diff --git a/x-pack/test/upgrade/apps/canvas/canvas_smoke_tests.ts b/x-pack/test/upgrade/apps/canvas/canvas_smoke_tests.ts index 6ba9bc721e197..886a5f458f52b 100644 --- a/x-pack/test/upgrade/apps/canvas/canvas_smoke_tests.ts +++ b/x-pack/test/upgrade/apps/canvas/canvas_smoke_tests.ts @@ -10,7 +10,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const retry = getService('retry'); - const PageObjects = getPageObjects(['common', 'header', 'home']); + const { common, header, home } = getPageObjects(['common', 'header', 'home']); const testSubjects = getService('testSubjects'); const browser = getService('browser'); @@ -31,12 +31,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { canvasTests.forEach(({ name, numElements, page }) => { describe('space: ' + space, () => { before(async () => { - await PageObjects.common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { basePath, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.launchSampleCanvas(name); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await home.launchSampleCanvas(name); + await header.waitUntilLoadingHasFinished(); }); it('renders elements on workpad ' + name + ' page ' + page, async () => { const browserUrl = await browser.getCurrentUrl(); @@ -49,7 +49,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { if (name === 'ecommerce') { if (!browserUrl.includes('page/' + page)) { await browser.get(browserUrl.replace(/\/[^\/]*$/, '/' + page), false); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); } } await retry.try(async () => { diff --git a/x-pack/test/upgrade/apps/dashboard/dashboard_smoke_tests.ts b/x-pack/test/upgrade/apps/dashboard/dashboard_smoke_tests.ts index 2d54d3ba0a52b..dc51b0f294780 100644 --- a/x-pack/test/upgrade/apps/dashboard/dashboard_smoke_tests.ts +++ b/x-pack/test/upgrade/apps/dashboard/dashboard_smoke_tests.ts @@ -15,7 +15,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const renderable = getService('renderable'); const dashboardExpect = getService('dashboardExpect'); const kibanaServer = getService('kibanaServer'); - const PageObjects = getPageObjects(['common', 'header', 'home', 'dashboard', 'timePicker']); + const { common, header, home, dashboard } = getPageObjects([ + 'common', + 'header', + 'home', + 'dashboard', + ]); const browser = getService('browser'); describe('upgrade dashboard smoke tests', function describeIndexTests() { @@ -33,10 +38,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { spaces.forEach(({ space, basePath }) => { describe('space: ' + space, () => { beforeEach(async () => { - await PageObjects.common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { basePath, }); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); await browser.refresh(); }); dashboardTests.forEach(({ name, numPanels }) => { @@ -44,10 +49,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await kibanaServer.uiSettings.update({ 'timepicker:timeDefaults': `{ "from": "now-5y", "to": "now"}`, }); - await PageObjects.home.launchSampleDashboard(name); - await PageObjects.header.waitUntilLoadingHasFinished(); + await home.launchSampleDashboard(name); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); - const panelCount = await PageObjects.dashboard.getPanelCount(); + const panelCount = await dashboard.getPanelCount(); expect(panelCount).to.be.above(numPanels); }); }); @@ -55,8 +60,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await kibanaServer.uiSettings.update({ 'timepicker:timeDefaults': `{ "from": "now-5y", "to": "now"}`, }); - await PageObjects.home.launchSampleDashboard('flights'); - await PageObjects.header.waitUntilLoadingHasFinished(); + await home.launchSampleDashboard('flights'); + await header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); log.debug('Checking saved searches rendered'); await dashboardExpect.savedSearchRowCount(49); diff --git a/x-pack/test/upgrade/apps/discover/discover_smoke_tests.ts b/x-pack/test/upgrade/apps/discover/discover_smoke_tests.ts index 64adb488ca2b9..9f8378ecc4133 100644 --- a/x-pack/test/upgrade/apps/discover/discover_smoke_tests.ts +++ b/x-pack/test/upgrade/apps/discover/discover_smoke_tests.ts @@ -9,7 +9,13 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'header', 'home', 'discover', 'timePicker']); + const { common, header, home, discover, timePicker } = getPageObjects([ + 'common', + 'header', + 'home', + 'discover', + 'timePicker', + ]); describe('upgrade discover smoke tests', function describeIndexTests() { const spaces = [ @@ -27,25 +33,25 @@ export default function ({ getPageObjects }: FtrProviderContext) { discoverTests.forEach(({ name, timefield, hits }) => { describe('space: ' + space + ', name: ' + name, () => { before(async () => { - await PageObjects.common.navigateToApp('discover', { + await common.navigateToApp('discover', { basePath, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - const indices = await PageObjects.discover.getIndexPatterns(); + await header.waitUntilLoadingHasFinished(); + const indices = await discover.getIndexPatterns(); const index = indices.find((element) => { if (element.toLowerCase().includes(name)) { return true; } }); - await PageObjects.discover.selectIndexPattern(String(index)); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await discover.selectIndexPattern(String(index)); + await discover.waitUntilSearchingHasFinished(); if (timefield) { - await PageObjects.timePicker.setCommonlyUsedTime('Last_1 year'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setCommonlyUsedTime('Last_1 year'); + await discover.waitUntilSearchingHasFinished(); } }); it('shows hit count greater than zero', async () => { - const hitCount = await PageObjects.discover.getHitCountInt(); + const hitCount = await discover.getHitCountInt(); if (hits === '') { expect(hitCount).to.be.greaterThan(0); } else { @@ -53,7 +59,7 @@ export default function ({ getPageObjects }: FtrProviderContext) { } }); it('shows table rows not empty', async () => { - const tableRows = await PageObjects.discover.getDocTableRows(); + const tableRows = await discover.getDocTableRows(); expect(tableRows.length).to.be.greaterThan(0); }); }); @@ -62,19 +68,19 @@ export default function ({ getPageObjects }: FtrProviderContext) { discoverTests.forEach(({ name, timefield, hits }) => { describe('space: ' + space + ', name: ' + name, () => { before(async () => { - await PageObjects.common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { basePath, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.launchSampleDiscover(name); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await home.launchSampleDiscover(name); + await header.waitUntilLoadingHasFinished(); if (timefield) { - await PageObjects.timePicker.setCommonlyUsedTime('Last_1 year'); - await PageObjects.discover.waitUntilSearchingHasFinished(); + await timePicker.setCommonlyUsedTime('Last_1 year'); + await discover.waitUntilSearchingHasFinished(); } }); it('shows hit count greater than zero', async () => { - const hitCount = await PageObjects.discover.getHitCountInt(); + const hitCount = await discover.getHitCountInt(); if (hits === '') { expect(hitCount).to.be.greaterThan(0); } else { @@ -82,7 +88,7 @@ export default function ({ getPageObjects }: FtrProviderContext) { } }); it('shows table rows not empty', async () => { - const tableRows = await PageObjects.discover.getDocTableRows(); + const tableRows = await discover.getDocTableRows(); expect(tableRows.length).to.be.greaterThan(0); }); }); diff --git a/x-pack/test/upgrade/apps/graph/graph_smoke_tests.ts b/x-pack/test/upgrade/apps/graph/graph_smoke_tests.ts index d9e9c2dd39622..cdb3c069c7bb7 100644 --- a/x-pack/test/upgrade/apps/graph/graph_smoke_tests.ts +++ b/x-pack/test/upgrade/apps/graph/graph_smoke_tests.ts @@ -10,7 +10,7 @@ import semver from 'semver'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'header', 'home', 'graph']); + const { common, header, home, graph } = getPageObjects(['common', 'header', 'home', 'graph']); const log = getService('log'); describe('upgrade graph smoke tests', function describeIndexTests() { @@ -37,15 +37,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { graphTests.forEach(({ name, numNodes }) => { describe('space: ' + space, () => { before(async () => { - await PageObjects.common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { basePath, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.launchSampleGraph(name); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); + await home.launchSampleGraph(name); + await header.waitUntilLoadingHasFinished(); }); it('renders graph for ' + name, async () => { - const elements = await PageObjects.graph.getAllGraphNodes(); + const elements = await graph.getAllGraphNodes(); expect(elements).to.be.equal(numNodes); }); }); diff --git a/x-pack/test/upgrade/apps/maps/maps_smoke_tests.ts b/x-pack/test/upgrade/apps/maps/maps_smoke_tests.ts index db8e624ac4356..f653a3d32d65d 100644 --- a/x-pack/test/upgrade/apps/maps/maps_smoke_tests.ts +++ b/x-pack/test/upgrade/apps/maps/maps_smoke_tests.ts @@ -15,7 +15,13 @@ export default function ({ getService, updateBaselines, }: FtrProviderContext & { updateBaselines: boolean }) { - const PageObjects = getPageObjects(['common', 'maps', 'header', 'home', 'timePicker']); + const { common, maps, header, home, timePicker } = getPageObjects([ + 'common', + 'maps', + 'header', + 'home', + 'timePicker', + ]); const mapsHelper = getService('mapsHelper'); const screenshot = getService('screenshots'); const testSubjects = getService('testSubjects'); @@ -103,21 +109,21 @@ export default function ({ spaces.forEach(({ space, basePath }) => { describe('space: ' + space + ', name: ecommerce', () => { before(async () => { - await PageObjects.common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { basePath, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.launchSampleMap('ecommerce'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - await PageObjects.maps.toggleEmsBasemapLayerVisibility(); - await PageObjects.maps.toggleLayerVisibility('United Kingdom'); - await PageObjects.maps.toggleLayerVisibility('France'); - await PageObjects.maps.toggleLayerVisibility('United States'); - await PageObjects.maps.toggleLayerVisibility('World Countries'); - await PageObjects.timePicker.setCommonlyUsedTime('sample_data range'); - await PageObjects.maps.enterFullScreen(); - await PageObjects.maps.closeLegend(); + await header.waitUntilLoadingHasFinished(); + await home.launchSampleMap('ecommerce'); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + await maps.toggleEmsBasemapLayerVisibility(); + await maps.toggleLayerVisibility('United Kingdom'); + await maps.toggleLayerVisibility('France'); + await maps.toggleLayerVisibility('United States'); + await maps.toggleLayerVisibility('World Countries'); + await timePicker.setCommonlyUsedTime('sample_data range'); + await maps.enterFullScreen(); + await maps.closeLegend(); const mapContainerElement = await testSubjects.find('mapContainer'); await mapContainerElement.moveMouseTo({ xOffset: 0, yOffset: 0 }); }); @@ -131,17 +137,17 @@ export default function ({ }); describe('space: ' + space + ', name: flights', () => { before(async () => { - await PageObjects.common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { basePath, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.launchSampleMap('flights'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - await PageObjects.maps.toggleEmsBasemapLayerVisibility(); - await PageObjects.timePicker.setCommonlyUsedTime('sample_data range'); - await PageObjects.maps.enterFullScreen(); - await PageObjects.maps.closeLegend(); + await header.waitUntilLoadingHasFinished(); + await home.launchSampleMap('flights'); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + await maps.toggleEmsBasemapLayerVisibility(); + await timePicker.setCommonlyUsedTime('sample_data range'); + await maps.enterFullScreen(); + await maps.closeLegend(); const mapContainerElement = await testSubjects.find('mapContainer'); await mapContainerElement.moveMouseTo({ xOffset: 0, yOffset: 0 }); }); @@ -155,18 +161,18 @@ export default function ({ }); describe('space: ' + space + ', name: web logs', () => { before(async () => { - await PageObjects.common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { + await common.navigateToActualUrl('home', '/tutorial_directory/sampleData', { basePath, }); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.home.launchSampleMap('logs'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.maps.waitForLayersToLoad(); - await PageObjects.maps.toggleEmsBasemapLayerVisibility(); + await header.waitUntilLoadingHasFinished(); + await home.launchSampleMap('logs'); + await header.waitUntilLoadingHasFinished(); + await maps.waitForLayersToLoad(); + await maps.toggleEmsBasemapLayerVisibility(); await mapsHelper.toggleLayerVisibilityTotalRequests(); - await PageObjects.timePicker.setCommonlyUsedTime('sample_data range'); - await PageObjects.maps.enterFullScreen(); - await PageObjects.maps.closeLegend(); + await timePicker.setCommonlyUsedTime('sample_data range'); + await maps.enterFullScreen(); + await maps.closeLegend(); const mapContainerElement = await testSubjects.find('mapContainer'); await mapContainerElement.moveMouseTo({ xOffset: 0, yOffset: 0 }); }); diff --git a/x-pack/test/upgrade/services/maps_upgrade_services.ts b/x-pack/test/upgrade/services/maps_upgrade_services.ts index 63aa41e676c8a..e5949ce90708e 100644 --- a/x-pack/test/upgrade/services/maps_upgrade_services.ts +++ b/x-pack/test/upgrade/services/maps_upgrade_services.ts @@ -8,7 +8,7 @@ import { FtrProviderContext } from '../ftr_provider_context'; export function MapsHelper({ getPageObjects, getService }: FtrProviderContext) { - const PageObjects = getPageObjects(['maps', 'common']); + const { maps } = getPageObjects(['maps']); const testSubjects = getService('testSubjects'); return { @@ -28,10 +28,10 @@ export function MapsHelper({ getPageObjects, getService }: FtrProviderContext) { throw new Error('Layer total requests not found'); } if (isRequestByCountry) { - await PageObjects.maps.toggleLayerVisibility('Total Requests by Country'); + await maps.toggleLayerVisibility('Total Requests by Country'); } if (isRequestByDestination) { - await PageObjects.maps.toggleLayerVisibility('Total Requests by Destination'); + await maps.toggleLayerVisibility('Total Requests by Destination'); } }, }; diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/embeddable/_saved_search_embeddable.ts b/x-pack/test_serverless/functional/test_suites/common/discover/embeddable/_saved_search_embeddable.ts index fb310c7a17faa..6719a75c3ea5c 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/embeddable/_saved_search_embeddable.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/embeddable/_saved_search_embeddable.ts @@ -17,19 +17,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ + const { common, svlCommonPage, dashboard, header, discover } = getPageObjects([ 'common', 'svlCommonPage', 'dashboard', 'header', - 'timePicker', 'discover', ]); describe('discover saved search embeddable', () => { before(async () => { await browser.setWindowSize(1300, 800); - await PageObjects.svlCommonPage.loginWithPrivilegedRole(); + await svlCommonPage.loginWithPrivilegedRole(); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional'); await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/dashboard/current/data'); await kibanaServer.savedObjects.cleanStandardList(); @@ -39,7 +38,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.replace({ defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', }); - await PageObjects.common.setTime({ + await common.setTime({ from: 'Sep 22, 2015 @ 00:00:00.000', to: 'Sep 23, 2015 @ 00:00:00.000', }); @@ -49,28 +48,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional'); await esArchiver.unload('test/functional/fixtures/es_archiver/dashboard/current/data'); await kibanaServer.savedObjects.cleanStandardList(); - await PageObjects.common.unsetTime(); + await common.unsetTime(); }); beforeEach(async () => { - await PageObjects.dashboard.navigateToApp(); + await dashboard.navigateToApp(); await filterBar.ensureFieldEditorModalIsClosed(); - await PageObjects.dashboard.gotoDashboardLandingPage(); - await PageObjects.dashboard.clickNewDashboard(); + await dashboard.gotoDashboardLandingPage(); + await dashboard.clickNewDashboard(); }); const addSearchEmbeddableToDashboard = async () => { await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); const rows = await dataGrid.getDocTableRows(); expect(rows.length).to.be.above(0); }; const refreshDashboardPage = async () => { await browser.refresh(); - await PageObjects.header.waitUntilLoadingHasFinished(); - await PageObjects.dashboard.waitForRenderComplete(); + await header.waitUntilLoadingHasFinished(); + await dashboard.waitForRenderComplete(); }; it('can save a search embeddable with a defined rows per page number', async function () { @@ -78,7 +77,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await addSearchEmbeddableToDashboard(); await dataGrid.checkCurrentRowsPerPageToBe(100); - await PageObjects.dashboard.saveDashboard(dashboardName, { + await dashboard.saveDashboard(dashboardName, { waitDialogIsClosed: true, exitFromEditMode: false, saveAsNew: true, @@ -90,7 +89,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dataGrid.changeRowsPerPageTo(10); - await PageObjects.dashboard.saveDashboard(dashboardName, { saveAsNew: false }); + await dashboard.saveDashboard(dashboardName, { saveAsNew: false }); await refreshDashboardPage(); await dataGrid.checkCurrentRowsPerPageToBe(10); @@ -98,7 +97,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should control columns correctly', async () => { await addSearchEmbeddableToDashboard(); - await PageObjects.dashboard.switchToEditMode(); + await dashboard.switchToEditMode(); const cell = await dataGrid.getCellElementExcludingControlColumns(0, 0); expect(await cell.getVisibleText()).to.be('Sep 22, 2015 @ 23:50:13.253'); @@ -127,11 +126,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await addSearchEmbeddableToDashboard(); await queryBar.setQuery('bytes > 5000'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); - expect(await PageObjects.discover.getSavedSearchDocumentCount()).to.be('2,572 documents'); + await header.waitUntilLoadingHasFinished(); + expect(await discover.getSavedSearchDocumentCount()).to.be('2,572 documents'); await queryBar.setQuery('this < is not : a valid > query'); await queryBar.submitQuery(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await header.waitUntilLoadingHasFinished(); const embeddableError = await testSubjects.find('embeddableError'); const errorMessage = await embeddableError.findByTestSubject('errorMessageMarkdown'); const errorText = await errorMessage.getVisibleText(); diff --git a/x-pack/test_serverless/functional/test_suites/common/visualizations/group3/open_in_lens/tsvb/dashboard.ts b/x-pack/test_serverless/functional/test_suites/common/visualizations/group3/open_in_lens/tsvb/dashboard.ts index 91e5d16a8df5b..eff79084e9dee 100644 --- a/x-pack/test_serverless/functional/test_suites/common/visualizations/group3/open_in_lens/tsvb/dashboard.ts +++ b/x-pack/test_serverless/functional/test_suites/common/visualizations/group3/open_in_lens/tsvb/dashboard.ts @@ -18,11 +18,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ]); const dashboardCustomizePanel = getService('dashboardCustomizePanel'); const dashboardBadgeActions = getService('dashboardBadgeActions'); - const dashboardPanelActions = getService('dashboardPanelActions'); const testSubjects = getService('testSubjects'); const retry = getService('retry'); const panelActions = getService('dashboardPanelActions'); const kibanaServer = getService('kibanaServer'); + const visTitle = 'My TSVB to Lens viz 2'; describe('Dashboard to TSVB to Lens', function describeIndexTests() { const fixture = @@ -46,7 +46,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await dashboard.waitForRenderComplete(); const originalEmbeddableCount = await canvas.getEmbeddableCount(); - await dashboardPanelActions.customizePanel(); + await panelActions.customizePanel(); await dashboardCustomizePanel.enableCustomTimeRange(); await dashboardCustomizePanel.openDatePickerQuickMenu(); await dashboardCustomizePanel.clickCommonlyUsedTimeRange('Last_30 days'); @@ -75,17 +75,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('should convert a by reference TSVB viz to a Lens viz', async () => { await dashboard.gotoDashboardEditMode('Convert to Lens - Dashboard - TSVB - 2'); - // await dashboard.gotoDashboardEditMode('Convert to Lens - Dashboard - Metric'); await timePicker.setDefaultAbsoluteRange(); // save it to library - const originalPanel = await testSubjects.find('embeddablePanelHeading-'); - await panelActions.saveToLibrary('My TSVB to Lens viz 2', originalPanel); + await panelActions.saveToLibrary(visTitle); await dashboard.waitForRenderComplete(); const originalEmbeddableCount = await canvas.getEmbeddableCount(); - await dashboardPanelActions.customizePanel(); + await panelActions.customizePanel(); await dashboardCustomizePanel.expectCustomizePanelSettingsFlyoutOpen(); await dashboardCustomizePanel.enableCustomTimeRange(); await dashboardCustomizePanel.openDatePickerQuickMenu(); @@ -99,7 +97,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await dashboard.waitForRenderComplete(); await dashboardBadgeActions.expectExistsTimeRangeBadgeAction(); - await panelActions.convertToLensByTitle('My TSVB to Lens viz 2'); + await panelActions.convertToLensByTitle(visTitle); await lens.waitForVisualization('xyVisChart'); await retry.try(async () => { @@ -113,14 +111,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(embeddableCount).to.eql(originalEmbeddableCount); }); - const panel = await testSubjects.find(`embeddablePanelHeading-MyTSVBtoLensviz2(converted)`); - const descendants = await testSubjects.findAllDescendant( - 'embeddablePanelNotification-ACTION_LIBRARY_NOTIFICATION', - panel - ); - expect(descendants.length).to.equal(0); const titles = await dashboard.getPanelTitles(); - expect(titles[0]).to.be('My TSVB to Lens viz 2 (converted)'); + expect(titles[0]).to.be(`${visTitle} (converted)`); + await panelActions.expectNotLinkedToLibrary(titles[0], true); await dashboardBadgeActions.expectExistsTimeRangeBadgeAction(); await panelActions.removePanel(); });