import { getBase64FullPageScreenshotsData } from './screenshots' ; import { FullPageScreenshotDataOptions } from './screenshots.interfaces' ; import { IMAGE_STRING } from '../mocks/mocks' ; import { LogLevel } from "../helpers/options.interface" ; describe ( 'screenshots' , ( ) => { describe ( 'getBase64FullPageScreenshotsData' , ( ) => { const MOCKED_TAKESCREENSHOT = jest . fn ( ) . mockResolvedValue ( IMAGE_STRING ) ; it ( 'should get the Android nativeWebScreenshot fullpage screenshot data' , async ( ) => { const options = { addressBarShadowPadding : 6 , devicePixelRatio : 2 , fullPageScrollTimeout : 1 , innerHeight : 800 , isAndroid : true , isAndroidNativeWebScreenshot : true , isAndroidChromeDriverScreenshot : false , isHybridApp : false , isIos : false , logLevel : LogLevel . debug , toolBarShadowPadding : 6 , hideAfterFirstScroll : [ ] , } ; const MOCKED_EXECUTOR = jest . fn ( ) . mockResolvedValueOnce ( { statusAddressBar : { height : 56 } } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 788 ) . mockResolvedValueOnce ( { } ) ; const result = await getBase64FullPageScreenshotsData ( MOCKED_TAKESCREENSHOT , MOCKED_EXECUTOR , options ) ; result . data . forEach ( dataObject => dataObject . screenshot = 'mocked-screenshot-string' ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; it ( 'should get hide elements for the Android nativeWebScreenshot fullpage screenshot' , async ( ) => { const options = { addressBarShadowPadding : 6 , devicePixelRatio : 2 , fullPageScrollTimeout : 1 , innerHeight : 600 , isAndroid : true , isAndroidNativeWebScreenshot : true , isAndroidChromeDriverScreenshot : false , isHybridApp : false , isIos : false , logLevel : LogLevel . debug , toolBarShadowPadding : 6 , hideAfterFirstScroll : [ < HTMLElement > < unknown > '<div/>' ] , } ; const MOCKED_EXECUTOR = jest . fn ( ) . mockResolvedValueOnce ( { statusAddressBar : { height : 56 } } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 788 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 788 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) ; const result = await getBase64FullPageScreenshotsData ( MOCKED_TAKESCREENSHOT , MOCKED_EXECUTOR , options ) ; result . data . forEach ( dataObject => dataObject . screenshot = 'mocked-screenshot-string' ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; it ( 'should get the Android ChromeDriver fullpage screenshot data' , async ( ) => { const options = { addressBarShadowPadding : 6 , devicePixelRatio : 2 , fullPageScrollTimeout : 1 , innerHeight : 800 , isAndroid : true , isAndroidNativeWebScreenshot : false , isAndroidChromeDriverScreenshot : true , isHybridApp : false , isIos : false , logLevel : LogLevel . debug , toolBarShadowPadding : 6 , hideAfterFirstScroll : [ ] , } ; const MOCKED_EXECUTOR = jest . fn ( ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 1200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 1200 ) . mockResolvedValueOnce ( { } ) ; const result = await getBase64FullPageScreenshotsData ( MOCKED_TAKESCREENSHOT , MOCKED_EXECUTOR , options ) ; result . data . forEach ( dataObject => dataObject . screenshot = 'mocked-screenshot-string' ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; it ( 'should hide elements for the Android ChromeDriver fullpage screenshot' , async ( ) => { const options = { addressBarShadowPadding : 6 , devicePixelRatio : 2 , fullPageScrollTimeout : 1 , innerHeight : 800 , isAndroid : true , isAndroidNativeWebScreenshot : false , isAndroidChromeDriverScreenshot : true , isHybridApp : false , isIos : false , logLevel : LogLevel . debug , toolBarShadowPadding : 6 , hideAfterFirstScroll : [ < HTMLElement > < unknown > '<div/>' ] , } ; const MOCKED_EXECUTOR = jest . fn ( ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 1200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 1200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) ; const result = await getBase64FullPageScreenshotsData ( MOCKED_TAKESCREENSHOT , MOCKED_EXECUTOR , options ) ; result . data . forEach ( dataObject => dataObject . screenshot = 'mocked-screenshot-string' ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; it ( 'should get the iOS fullpage screenshot data' , async ( ) => { const options = { addressBarShadowPadding : 6 , devicePixelRatio : 2 , fullPageScrollTimeout : 1 , innerHeight : 800 , isAndroid : false , isAndroidNativeWebScreenshot : false , isAndroidChromeDriverScreenshot : false , isHybridApp : false , isIos : true , logLevel : LogLevel . debug , toolBarShadowPadding : 6 , hideAfterFirstScroll : [ ] , } ; const MOCKED_EXECUTOR = jest . fn ( ) . mockResolvedValueOnce ( { statusAddressBar : { height : 94 } } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 1200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 1200 ) . mockResolvedValueOnce ( { } ) ; const result = await getBase64FullPageScreenshotsData ( MOCKED_TAKESCREENSHOT , MOCKED_EXECUTOR , options ) ; result . data . forEach ( dataObject => dataObject . screenshot = 'mocked-screenshot-string' ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; it ( 'should hide elements for the iOS fullpage screenshot' , async ( ) => { const options = { addressBarShadowPadding : 6 , devicePixelRatio : 2 , fullPageScrollTimeout : 1 , innerHeight : 800 , isAndroid : false , isAndroidNativeWebScreenshot : false , isAndroidChromeDriverScreenshot : false , isHybridApp : false , isIos : true , logLevel : LogLevel . debug , toolBarShadowPadding : 6 , hideAfterFirstScroll : [ < HTMLElement > < unknown > '<div/>' ] , } ; const MOCKED_EXECUTOR = jest . fn ( ) . mockResolvedValueOnce ( { statusAddressBar : { height : 94 } } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 1200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 1200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) ; const result = await getBase64FullPageScreenshotsData ( MOCKED_TAKESCREENSHOT , MOCKED_EXECUTOR , options ) ; result . data . forEach ( dataObject => dataObject . screenshot = 'mocked-screenshot-string' ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; it ( 'should get the desktop browser fullpage screenshot data' , async ( ) => { const options = { addressBarShadowPadding : 6 , devicePixelRatio : 2 , fullPageScrollTimeout : 1 , innerHeight : 768 , isAndroid : false , isAndroidNativeWebScreenshot : false , isAndroidChromeDriverScreenshot : false , isHybridApp : false , isIos : false , logLevel : LogLevel . debug , toolBarShadowPadding : 6 , hideAfterFirstScroll : [ ] , } ; const MOCKED_EXECUTOR = jest . fn ( ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 3200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 3200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 3200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 3200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 3200 ) ; const result = await getBase64FullPageScreenshotsData ( MOCKED_TAKESCREENSHOT , MOCKED_EXECUTOR , options ) ; result . data . forEach ( dataObject => dataObject . screenshot = 'mocked-screenshot-string' ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; it ( 'should hide elements for the desktop browser fullpage screenshot' , async ( ) => { const options = { addressBarShadowPadding : 6 , devicePixelRatio : 2 , fullPageScrollTimeout : 1 , innerHeight : 768 , isAndroid : false , isAndroidNativeWebScreenshot : false , isAndroidChromeDriverScreenshot : false , isHybridApp : false , isIos : false , logLevel : LogLevel . debug , toolBarShadowPadding : 6 , hideAfterFirstScroll : [ < HTMLElement > < unknown > '<div/>' ] , } ; const MOCKED_EXECUTOR = jest . fn ( ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 3200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 3200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 3200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 3200 ) . mockResolvedValueOnce ( { } ) . mockResolvedValueOnce ( 3200 ) . mockResolvedValueOnce ( { } ) ; const result = await getBase64FullPageScreenshotsData ( MOCKED_TAKESCREENSHOT , MOCKED_EXECUTOR , options ) ; result . data . forEach ( dataObject => dataObject . screenshot = 'mocked-screenshot-string' ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; } ) ; } ) ;