import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../../../ftr_provider_context' ; export default function ( { getService , getPageObjects } ) { 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' ] ) ; describe ( 'Search session sharing with lens' , ( ) => { before ( async ( ) => { await kibanaServer . importExport . load ( 'x-pack/test/functional/fixtures/kbn_archiver/lens/lens_basic.json' ) ; await PageObjects . common . navigateToApp ( 'dashboard' ) ; await PageObjects . dashboard . preserveCrossAppState ( ) ; } ) ; after ( async ( ) => { await kibanaServer . importExport . unload ( 'x-pack/test/functional/fixtures/kbn_archiver/lens/lens_basic.json' ) ; } ) ; it ( "should share search session with by value lens and don't share with by reference" , async ( ) => { const lensTitle = 'Artistpreviouslyknownaslens' ; await PageObjects . dashboard . clickNewDashboard ( ) ; await dashboardAddPanel . clickOpenAddPanel ( ) ; await dashboardAddPanel . filterEmbeddableNames ( lensTitle ) ; await find . clickByButtonText ( lensTitle ) ; await dashboardAddPanel . closeAddPanel ( ) ; await PageObjects . lens . goToTimeRange ( ) ; await PageObjects . dashboard . waitForRenderComplete ( ) ; const byRefSessionId = await dashboardPanelActions . getSearchSessionIdByTitle ( lensTitle ) ; await dashboardPanelActions . openContextMenu ( ) ; await dashboardPanelActions . clickEdit ( ) ; await PageObjects . lens . saveAndReturn ( ) ; await PageObjects . dashboard . waitForRenderComplete ( ) ; const newByRefSessionId = await dashboardPanelActions . getSearchSessionIdByTitle ( lensTitle ) ; expect ( byRefSessionId ) . not . to . eql ( newByRefSessionId ) ; const byRefPanel = await testSubjects . find ( 'embeddablePanelHeading-' + lensTitle ) ; await dashboardPanelActions . unlinkFromLibary ( byRefPanel ) ; await PageObjects . dashboard . waitForRenderComplete ( ) ; const byValueSessionId = await dashboardPanelActions . getSearchSessionIdByTitle ( lensTitle ) ; await dashboardPanelActions . openContextMenu ( ) ; await dashboardPanelActions . clickEdit ( ) ; await PageObjects . lens . saveAndReturn ( ) ; await PageObjects . dashboard . waitForRenderComplete ( ) ; const newByValueSessionId = await dashboardPanelActions . getSearchSessionIdByTitle ( lensTitle ) ; expect ( byValueSessionId ) . to . eql ( newByValueSessionId ) ; } ) ; } ) ; }