import { FtrProviderContext } from '../ftr_provider_context' ; export default ( { getService , getPageObjects } ) => { const PageObjects = getPageObjects ( [ 'common' , 'reporting' , 'dashboard' ] ) ; const testSubjects = getService ( 'testSubjects' ) ; const browser = getService ( 'browser' ) ; const reportingFunctional = getService ( 'reportingFunctional' ) ; describe ( 'Access to Management > Reporting' , ( ) => { before ( async ( ) => { await reportingFunctional . initEcommerce ( ) ; } ) ; after ( async ( ) => { await reportingFunctional . teardownEcommerce ( ) ; } ) ; it ( 'does not allow user that does not have reporting privileges' , async ( ) => { await reportingFunctional . loginDataAnalyst ( ) ; await PageObjects . common . navigateToApp ( 'reporting' ) ; await testSubjects . missingOrFail ( 'reportJobListing' ) ; } ) ; it ( 'does allow user with reporting privileges' , async ( ) => { await reportingFunctional . loginReportingUser ( ) ; await PageObjects . common . navigateToApp ( 'reporting' ) ; await testSubjects . existOrFail ( 'reportJobListing' ) ; } ) ; it ( 'Allows users to navigate back to where a report was generated' , async ( ) => { const dashboardTitle = 'Ecom Dashboard' ; await PageObjects . common . navigateToApp ( 'dashboard' ) ; await PageObjects . dashboard . loadSavedDashboard ( dashboardTitle ) ; await PageObjects . reporting . openPdfReportingPanel ( ) ; await PageObjects . reporting . clickGenerateReportButton ( ) ; await PageObjects . common . navigateToApp ( 'reporting' ) ; await PageObjects . common . sleep ( 3000 ) ; await ( await testSubjects . find ( 'euiCollapsedItemActionsButton' ) ) . click ( ) ; await ( await testSubjects . find ( 'reportOpenInKibanaApp' ) ) . click ( ) ; const [ , dashboardWindowHandle ] = await browser . getAllWindowHandles ( ) ; await browser . switchToWindow ( dashboardWindowHandle ) ; await PageObjects . dashboard . expectOnDashboard ( dashboardTitle ) ; } ) ; } ) ; } ;