import expect from '@kbn/expect' ; import { resolve } from 'path' ; import { REPO_ROOT } from '@kbn/utils' ; import { FtrProviderContext } from '../../../functional/ftr_provider_context' ; const INTEGRATION_TEST_ROOT = process . env . WORKSPACE || resolve ( REPO_ROOT , '../integration-test' ) ; const ARCHIVE = resolve ( INTEGRATION_TEST_ROOT , 'test/es_archives/metricbeat' ) ; export default function ( { getService , getPageObjects , updateBaselines , } ) { const screenshot = getService ( 'screenshots' ) ; const browser = getService ( 'browser' ) ; const log = getService ( 'log' ) ; const esArchiver = getService ( 'esArchiver' ) ; const PageObjects = getPageObjects ( [ 'common' , 'dashboard' , 'timePicker' ] ) ; describe ( 'check metricbeat Dashboard' , function ( ) { before ( async function ( ) { await esArchiver . load ( ARCHIVE ) ; await PageObjects . common . navigateToActualUrl ( 'dashboard' , 'view/Metricbeat-system-overview-ecs?_g=(filters:!(),refreshInterval:(pause:!t,value:0),' + 'time:(from:%272020-09-29T19:02:37.902Z%27,to:%272020-09-29T19:06:43.218Z%27))&_a=' + '(description:%27Overview%20of%20system%20metrics%27,filters:!(),' + 'options:(darkTheme:!f),query:(language:kuery,query:%27%27),timeRestore:!f,' + 'title:%27%5BMetricbeat%20System%5D%20Overview%20ECS%27,viewMode:view)' , { ensureCurrentUrl : false , shouldLoginIfPrompted : true , } ) ; await PageObjects . common . sleep ( 2000 ) ; await PageObjects . common . dismissBanner ( ) ; await PageObjects . dashboard . waitForRenderComplete ( ) ; await PageObjects . common . sleep ( 2000 ) ; await browser . setScreenshotSize ( 1000 , 1337 ) ; await PageObjects . common . sleep ( 2000 ) ; } ) ; after ( async function ( ) { await esArchiver . unload ( ARCHIVE ) ; } ) ; it ( '[Metricbeat System] Overview ECS should match snapshot' , async function ( ) { try { const percentDifference = await screenshot . compareAgainstBaseline ( 'metricbeat_dashboard' , updateBaselines ) ; expect ( percentDifference ) . to . be . lessThan ( 0.017 ) ; } finally { log . debug ( '### Screenshot taken' ) ; } } ) ; } ) ; }