import expect from '@kbn/expect' ; import path from 'path' ; import { FtrProviderContext } from '../../../ftr_provider_context' ; export default function ( { getService , getPageObjects } ) { const retry = getService ( 'retry' ) ; const pieChart = getService ( 'pieChart' ) ; const esArchiver = getService ( 'esArchiver' ) ; const kibanaServer = getService ( 'kibanaServer' ) ; const testSubjects = getService ( 'testSubjects' ) ; const { common , settings , savedObjects , dashboard , dashboardControls } = getPageObjects ( [ 'common' , 'settings' , 'dashboard' , 'savedObjects' , 'dashboardControls' , ] ) ; describe ( 'Export import saved objects between versions' , ( ) => { before ( async ( ) => { await esArchiver . loadIfNeeded ( 'x-pack/test/functional/es_archives/getting_started/shakespeare' ) ; await kibanaServer . uiSettings . replace ( { } ) ; await settings . navigateTo ( ) ; await settings . clickKibanaSavedObjects ( ) ; await savedObjects . importFile ( path . join ( __dirname , 'exports' , 'controls_dashboard_migration_test_8_0_0.ndjson' ) ) ; } ) ; after ( async ( ) => { await esArchiver . unload ( 'x-pack/test/functional/es_archives/getting_started/shakespeare' ) ; await esArchiver . load ( 'x-pack/test/functional/es_archives/empty_kibana' ) ; } ) ; it ( 'should be able to import dashboard with controls from 8.0.0' , async ( ) => { await savedObjects . checkImportSucceeded ( ) ; await savedObjects . clickImportDone ( ) ; } ) ; it ( 'should render all panels on the dashboard' , async ( ) => { await dashboardControls . enableControlsLab ( ) ; await common . navigateToApp ( 'dashboard' ) ; await dashboard . loadSavedDashboard ( '[8.0.0] Controls Dashboard' ) ; await dashboard . expectOnDashboard ( '[8.0.0] Controls Dashboard' ) ; await dashboard . waitForRenderComplete ( ) ; const errorEmbeddables = await testSubjects . findAll ( 'embeddableStackError' ) ; expect ( errorEmbeddables . length ) . to . be ( 0 ) ; } ) ; it ( 'loads all controls from the saved dashboard' , async ( ) => { expect ( await dashboardControls . getControlsCount ( ) ) . to . be ( 2 ) ; expect ( await dashboardControls . getAllControlTitles ( ) ) . to . eql ( [ 'Speaker Name' , 'Play Name' ] ) ; const ids = await dashboardControls . getAllControlIds ( ) ; for ( const id of ids ) { await dashboardControls . optionsListOpenPopover ( id ) ; await retry . try ( async ( ) => { expect ( await dashboardControls . optionsListPopoverGetAvailableOptionsCount ( ) ) . to . be ( 10 ) ; } ) ; await dashboardControls . optionsListEnsurePopoverIsClosed ( id ) ; } } ) ; it ( 'applies default selected options list options to control' , async ( ) => { const controlIds = await dashboardControls . getAllControlIds ( ) ; const selectionString = await dashboardControls . optionsListGetSelectionsString ( controlIds [ 0 ] ) ; expect ( selectionString ) . to . be ( 'HAMLET, ROMEO, JULIET, BRUTUS' ) ; } ) ; it ( 'applies default selected options list options to dashboard' , async ( ) => { expect ( await pieChart . getPieSliceCount ( ) ) . to . be ( 4 ) ; } ) ; } ) ; }