@wdio/image-comparison-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/LICENSE +21 -0
- package/README.md +12 -0
- package/assets/ios/ipadair4th.ipadair5th-bottom.png +0 -0
- package/assets/ios/ipadair4th.ipadair5th-top.png +0 -0
- package/assets/ios/ipadmini6th-bottom.png +0 -0
- package/assets/ios/ipadmini6th-top.png +0 -0
- package/assets/ios/ipadpro11-bottom.png +0 -0
- package/assets/ios/ipadpro11-top.png +0 -0
- package/assets/ios/ipadpro129-bottom.png +0 -0
- package/assets/ios/ipadpro129-top.png +0 -0
- package/assets/ios/iphone11promax-bottom.png +0 -0
- package/assets/ios/iphone11promax-top.png +0 -0
- package/assets/ios/iphone12.iphone12pro-top.png +0 -0
- package/assets/ios/iphone12.iphone12pro.iphone13.iphone13pro.iphone14-bottom.png +0 -0
- package/assets/ios/iphone12mini-top.png +0 -0
- package/assets/ios/iphone12mini.iphone13mini-bottom.png +0 -0
- package/assets/ios/iphone12promax-top.png +0 -0
- package/assets/ios/iphone12promax.iphone13promax.iphone14plus-bottom.png +0 -0
- package/assets/ios/iphone13.iphone13pro.iphone14-top.png +0 -0
- package/assets/ios/iphone13mini-top.png +0 -0
- package/assets/ios/iphone13promax.iphone14plus-top.png +0 -0
- package/assets/ios/iphone14pro-bottom.png +0 -0
- package/assets/ios/iphone14pro-top.png +0 -0
- package/assets/ios/iphone14promax-bottom.png +0 -0
- package/assets/ios/iphone14promax-top.png +0 -0
- package/assets/ios/iphone15-bottom.png +0 -0
- package/assets/ios/iphone15-top.png +0 -0
- package/assets/ios/iphonex.iphonexs.iphone11pro-bottom.png +0 -0
- package/assets/ios/iphonex.iphonexs.iphone11pro-top.png +0 -0
- package/assets/ios/iphonexr.iphone11-bottom.png +0 -0
- package/assets/ios/iphonexr.iphone11-top.png +0 -0
- package/assets/ios/iphonexsmax-bottom.png +0 -0
- package/assets/ios/iphonexsmax-top.png +0 -0
- package/dist/base.d.ts +18 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.interfaces.d.ts +200 -0
- package/dist/base.interfaces.d.ts.map +1 -0
- package/dist/base.interfaces.js +1 -0
- package/dist/base.js +58 -0
- package/dist/base.test.d.ts +2 -0
- package/dist/base.test.d.ts.map +1 -0
- package/dist/base.test.js +45 -0
- package/dist/clientSideScripts/checkMetaTag.d.ts +2 -0
- package/dist/clientSideScripts/checkMetaTag.d.ts.map +1 -0
- package/dist/clientSideScripts/checkMetaTag.js +9 -0
- package/dist/clientSideScripts/checkMetaTag.test.d.ts +2 -0
- package/dist/clientSideScripts/checkMetaTag.test.d.ts.map +1 -0
- package/dist/clientSideScripts/checkMetaTag.test.js +25 -0
- package/dist/clientSideScripts/customCss.interfaces.d.ts +8 -0
- package/dist/clientSideScripts/customCss.interfaces.d.ts.map +1 -0
- package/dist/clientSideScripts/customCss.interfaces.js +1 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.d.ts +8 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.d.ts.map +1 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.interfaces.d.ts +4 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.interfaces.d.ts.map +1 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.interfaces.js +1 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.js +275 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.test.d.ts +2 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.test.d.ts.map +1 -0
- package/dist/clientSideScripts/drawTabbableOnCanvas.test.js +251 -0
- package/dist/clientSideScripts/elementPosition.interfaces.d.ts +3 -0
- package/dist/clientSideScripts/elementPosition.interfaces.d.ts.map +1 -0
- package/dist/clientSideScripts/elementPosition.interfaces.js +1 -0
- package/dist/clientSideScripts/getBoundingClientRect.d.ts +6 -0
- package/dist/clientSideScripts/getBoundingClientRect.d.ts.map +1 -0
- package/dist/clientSideScripts/getBoundingClientRect.js +12 -0
- package/dist/clientSideScripts/getBoundingClientRect.test.d.ts +2 -0
- package/dist/clientSideScripts/getBoundingClientRect.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getBoundingClientRect.test.js +28 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.d.ts +5 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.d.ts.map +1 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.js +48 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.test.d.ts +2 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getDocumentScrollHeight.test.js +30 -0
- package/dist/clientSideScripts/getElementPositionTopDom.d.ts +6 -0
- package/dist/clientSideScripts/getElementPositionTopDom.d.ts.map +1 -0
- package/dist/clientSideScripts/getElementPositionTopDom.js +11 -0
- package/dist/clientSideScripts/getElementPositionTopDom.test.d.ts +2 -0
- package/dist/clientSideScripts/getElementPositionTopDom.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getElementPositionTopDom.test.js +11 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.d.ts +14 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.d.ts.map +1 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.js +19 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.test.d.ts +2 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getElementPositionTopScreenNativeMobile.test.js +52 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.d.ts +6 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.d.ts.map +1 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.js +17 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.test.d.ts +2 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getMobileWebviewClickAndDimensions.test.js +47 -0
- package/dist/clientSideScripts/getScreenDimensions.d.ts +6 -0
- package/dist/clientSideScripts/getScreenDimensions.d.ts.map +1 -0
- package/dist/clientSideScripts/getScreenDimensions.js +104 -0
- package/dist/clientSideScripts/getScreenDimensions.test.d.ts +2 -0
- package/dist/clientSideScripts/getScreenDimensions.test.d.ts.map +1 -0
- package/dist/clientSideScripts/getScreenDimensions.test.js +161 -0
- package/dist/clientSideScripts/hideRemoveElements.d.ts +8 -0
- package/dist/clientSideScripts/hideRemoveElements.d.ts.map +1 -0
- package/dist/clientSideScripts/hideRemoveElements.js +60 -0
- package/dist/clientSideScripts/hideRemoveElements.test.d.ts +2 -0
- package/dist/clientSideScripts/hideRemoveElements.test.d.ts.map +1 -0
- package/dist/clientSideScripts/hideRemoveElements.test.js +199 -0
- package/dist/clientSideScripts/hideScrollbars.d.ts +9 -0
- package/dist/clientSideScripts/hideScrollbars.d.ts.map +1 -0
- package/dist/clientSideScripts/hideScrollbars.js +15 -0
- package/dist/clientSideScripts/hideScrollbars.test.d.ts +2 -0
- package/dist/clientSideScripts/hideScrollbars.test.d.ts.map +1 -0
- package/dist/clientSideScripts/hideScrollbars.test.js +12 -0
- package/dist/clientSideScripts/injectWebviewOverlay.d.ts +5 -0
- package/dist/clientSideScripts/injectWebviewOverlay.d.ts.map +1 -0
- package/dist/clientSideScripts/injectWebviewOverlay.js +35 -0
- package/dist/clientSideScripts/injectWebviewOverlay.test.d.ts +2 -0
- package/dist/clientSideScripts/injectWebviewOverlay.test.d.ts.map +1 -0
- package/dist/clientSideScripts/injectWebviewOverlay.test.js +74 -0
- package/dist/clientSideScripts/removeElementFromDom.d.ts +5 -0
- package/dist/clientSideScripts/removeElementFromDom.d.ts.map +1 -0
- package/dist/clientSideScripts/removeElementFromDom.js +9 -0
- package/dist/clientSideScripts/removeElementFromDom.test.d.ts +2 -0
- package/dist/clientSideScripts/removeElementFromDom.test.d.ts.map +1 -0
- package/dist/clientSideScripts/removeElementFromDom.test.js +43 -0
- package/dist/clientSideScripts/screenDimensions.interfaces.d.ts +96 -0
- package/dist/clientSideScripts/screenDimensions.interfaces.d.ts.map +1 -0
- package/dist/clientSideScripts/screenDimensions.interfaces.js +1 -0
- package/dist/clientSideScripts/scrollElementIntoView.d.ts +5 -0
- package/dist/clientSideScripts/scrollElementIntoView.d.ts.map +1 -0
- package/dist/clientSideScripts/scrollElementIntoView.js +31 -0
- package/dist/clientSideScripts/scrollElementIntoView.test.d.ts +2 -0
- package/dist/clientSideScripts/scrollElementIntoView.test.d.ts.map +1 -0
- package/dist/clientSideScripts/scrollElementIntoView.test.js +79 -0
- package/dist/clientSideScripts/scrollToPosition.d.ts +5 -0
- package/dist/clientSideScripts/scrollToPosition.d.ts.map +1 -0
- package/dist/clientSideScripts/scrollToPosition.js +25 -0
- package/dist/clientSideScripts/scrollToPosition.test.d.ts +2 -0
- package/dist/clientSideScripts/scrollToPosition.test.d.ts.map +1 -0
- package/dist/clientSideScripts/scrollToPosition.test.js +72 -0
- package/dist/clientSideScripts/setCustomCss.d.ts +6 -0
- package/dist/clientSideScripts/setCustomCss.d.ts.map +1 -0
- package/dist/clientSideScripts/setCustomCss.js +36 -0
- package/dist/clientSideScripts/setCustomCss.test.d.ts +2 -0
- package/dist/clientSideScripts/setCustomCss.test.d.ts.map +1 -0
- package/dist/clientSideScripts/setCustomCss.test.js +68 -0
- package/dist/clientSideScripts/statusAddressToolBarOffsets.interfaces.d.ts +11 -0
- package/dist/clientSideScripts/statusAddressToolBarOffsets.interfaces.d.ts.map +1 -0
- package/dist/clientSideScripts/statusAddressToolBarOffsets.interfaces.js +1 -0
- package/dist/clientSideScripts/toggleTextTransparency.d.ts +5 -0
- package/dist/clientSideScripts/toggleTextTransparency.d.ts.map +1 -0
- package/dist/clientSideScripts/toggleTextTransparency.js +16 -0
- package/dist/clientSideScripts/toggleTextTransparency.test.d.ts +2 -0
- package/dist/clientSideScripts/toggleTextTransparency.test.d.ts.map +1 -0
- package/dist/clientSideScripts/toggleTextTransparency.test.js +35 -0
- package/dist/clientSideScripts/waitForFonts.d.ts +8 -0
- package/dist/clientSideScripts/waitForFonts.d.ts.map +1 -0
- package/dist/clientSideScripts/waitForFonts.js +20 -0
- package/dist/clientSideScripts/waitForFonts.test.d.ts +2 -0
- package/dist/clientSideScripts/waitForFonts.test.d.ts.map +1 -0
- package/dist/clientSideScripts/waitForFonts.test.js +37 -0
- package/dist/commands/check.interfaces.d.ts +35 -0
- package/dist/commands/check.interfaces.d.ts.map +1 -0
- package/dist/commands/check.interfaces.js +1 -0
- package/dist/commands/checkAppElement.d.ts +7 -0
- package/dist/commands/checkAppElement.d.ts.map +1 -0
- package/dist/commands/checkAppElement.js +44 -0
- package/dist/commands/checkAppElement.test.d.ts +2 -0
- package/dist/commands/checkAppElement.test.d.ts.map +1 -0
- package/dist/commands/checkAppElement.test.js +241 -0
- package/dist/commands/checkAppScreen.d.ts +7 -0
- package/dist/commands/checkAppScreen.d.ts.map +1 -0
- package/dist/commands/checkAppScreen.js +73 -0
- package/dist/commands/checkAppScreen.test.d.ts +2 -0
- package/dist/commands/checkAppScreen.test.d.ts.map +1 -0
- package/dist/commands/checkAppScreen.test.js +295 -0
- package/dist/commands/checkElement.d.ts +7 -0
- package/dist/commands/checkElement.d.ts.map +1 -0
- package/dist/commands/checkElement.js +10 -0
- package/dist/commands/checkElement.test.d.ts +2 -0
- package/dist/commands/checkElement.test.d.ts.map +1 -0
- package/dist/commands/checkElement.test.js +66 -0
- package/dist/commands/checkFullPageScreen.d.ts +7 -0
- package/dist/commands/checkFullPageScreen.d.ts.map +1 -0
- package/dist/commands/checkFullPageScreen.js +56 -0
- package/dist/commands/checkFullPageScreen.test.d.ts +2 -0
- package/dist/commands/checkFullPageScreen.test.d.ts.map +1 -0
- package/dist/commands/checkFullPageScreen.test.js +259 -0
- package/dist/commands/checkScreen.d.ts +7 -0
- package/dist/commands/checkScreen.d.ts.map +1 -0
- package/dist/commands/checkScreen.js +10 -0
- package/dist/commands/checkScreen.test.d.ts +2 -0
- package/dist/commands/checkScreen.test.d.ts.map +1 -0
- package/dist/commands/checkScreen.test.js +62 -0
- package/dist/commands/checkTabbablePage.d.ts +7 -0
- package/dist/commands/checkTabbablePage.d.ts.map +1 -0
- package/dist/commands/checkTabbablePage.js +28 -0
- package/dist/commands/checkTabbablePage.test.d.ts +2 -0
- package/dist/commands/checkTabbablePage.test.d.ts.map +1 -0
- package/dist/commands/checkTabbablePage.test.js +200 -0
- package/dist/commands/checkWebElement.d.ts +7 -0
- package/dist/commands/checkWebElement.d.ts.map +1 -0
- package/dist/commands/checkWebElement.js +52 -0
- package/dist/commands/checkWebElement.test.d.ts +2 -0
- package/dist/commands/checkWebElement.test.d.ts.map +1 -0
- package/dist/commands/checkWebElement.test.js +278 -0
- package/dist/commands/checkWebScreen.d.ts +7 -0
- package/dist/commands/checkWebScreen.d.ts.map +1 -0
- package/dist/commands/checkWebScreen.js +50 -0
- package/dist/commands/checkWebScreen.test.d.ts +2 -0
- package/dist/commands/checkWebScreen.test.d.ts.map +1 -0
- package/dist/commands/checkWebScreen.test.js +227 -0
- package/dist/commands/element.interfaces.d.ts +27 -0
- package/dist/commands/element.interfaces.d.ts.map +1 -0
- package/dist/commands/element.interfaces.js +1 -0
- package/dist/commands/fullPage.interfaces.d.ts +38 -0
- package/dist/commands/fullPage.interfaces.d.ts.map +1 -0
- package/dist/commands/fullPage.interfaces.js +1 -0
- package/dist/commands/save.interfaces.d.ts +27 -0
- package/dist/commands/save.interfaces.d.ts.map +1 -0
- package/dist/commands/save.interfaces.js +1 -0
- package/dist/commands/saveAppElement.d.ts +7 -0
- package/dist/commands/saveAppElement.d.ts.map +1 -0
- package/dist/commands/saveAppElement.js +30 -0
- package/dist/commands/saveAppElement.test.d.ts +2 -0
- package/dist/commands/saveAppElement.test.d.ts.map +1 -0
- package/dist/commands/saveAppElement.test.js +199 -0
- package/dist/commands/saveAppScreen.d.ts +7 -0
- package/dist/commands/saveAppScreen.d.ts.map +1 -0
- package/dist/commands/saveAppScreen.js +43 -0
- package/dist/commands/saveAppScreen.test.d.ts +2 -0
- package/dist/commands/saveAppScreen.test.d.ts.map +1 -0
- package/dist/commands/saveAppScreen.test.js +221 -0
- package/dist/commands/saveElement.d.ts +7 -0
- package/dist/commands/saveElement.d.ts.map +1 -0
- package/dist/commands/saveElement.js +10 -0
- package/dist/commands/saveElement.test.d.ts +2 -0
- package/dist/commands/saveElement.test.d.ts.map +1 -0
- package/dist/commands/saveElement.test.js +62 -0
- package/dist/commands/saveFullPageScreen.d.ts +7 -0
- package/dist/commands/saveFullPageScreen.d.ts.map +1 -0
- package/dist/commands/saveFullPageScreen.js +60 -0
- package/dist/commands/saveFullPageScreen.test.d.ts +2 -0
- package/dist/commands/saveFullPageScreen.test.d.ts.map +1 -0
- package/dist/commands/saveFullPageScreen.test.js +293 -0
- package/dist/commands/saveScreen.d.ts +7 -0
- package/dist/commands/saveScreen.d.ts.map +1 -0
- package/dist/commands/saveScreen.js +10 -0
- package/dist/commands/saveScreen.test.d.ts +2 -0
- package/dist/commands/saveScreen.test.d.ts.map +1 -0
- package/dist/commands/saveScreen.test.js +47 -0
- package/dist/commands/saveTabbablePage.d.ts +7 -0
- package/dist/commands/saveTabbablePage.d.ts.map +1 -0
- package/dist/commands/saveTabbablePage.js +20 -0
- package/dist/commands/saveTabbablePage.test.d.ts +2 -0
- package/dist/commands/saveTabbablePage.test.d.ts.map +1 -0
- package/dist/commands/saveTabbablePage.test.js +74 -0
- package/dist/commands/saveWebElement.d.ts +7 -0
- package/dist/commands/saveWebElement.d.ts.map +1 -0
- package/dist/commands/saveWebElement.js +53 -0
- package/dist/commands/saveWebElement.test.d.ts +2 -0
- package/dist/commands/saveWebElement.test.d.ts.map +1 -0
- package/dist/commands/saveWebElement.test.js +253 -0
- package/dist/commands/saveWebScreen.d.ts +7 -0
- package/dist/commands/saveWebScreen.d.ts.map +1 -0
- package/dist/commands/saveWebScreen.js +48 -0
- package/dist/commands/saveWebScreen.test.d.ts +2 -0
- package/dist/commands/saveWebScreen.test.d.ts.map +1 -0
- package/dist/commands/saveWebScreen.test.js +222 -0
- package/dist/commands/screen.interfaces.d.ts +16 -0
- package/dist/commands/screen.interfaces.d.ts.map +1 -0
- package/dist/commands/screen.interfaces.js +1 -0
- package/dist/commands/tabbable.interfaces.d.ts +29 -0
- package/dist/commands/tabbable.interfaces.d.ts.map +1 -0
- package/dist/commands/tabbable.interfaces.js +1 -0
- package/dist/helpers/afterScreenshot.d.ts +7 -0
- package/dist/helpers/afterScreenshot.d.ts.map +1 -0
- package/dist/helpers/afterScreenshot.interfaces.d.ts +46 -0
- package/dist/helpers/afterScreenshot.interfaces.d.ts.map +1 -0
- package/dist/helpers/afterScreenshot.interfaces.js +1 -0
- package/dist/helpers/afterScreenshot.js +55 -0
- package/dist/helpers/afterScreenshot.test.d.ts +2 -0
- package/dist/helpers/afterScreenshot.test.d.ts.map +1 -0
- package/dist/helpers/afterScreenshot.test.js +241 -0
- package/dist/helpers/beforeScreenshot.d.ts +6 -0
- package/dist/helpers/beforeScreenshot.d.ts.map +1 -0
- package/dist/helpers/beforeScreenshot.interfaces.d.ts +15 -0
- package/dist/helpers/beforeScreenshot.interfaces.d.ts.map +1 -0
- package/dist/helpers/beforeScreenshot.interfaces.js +1 -0
- package/dist/helpers/beforeScreenshot.js +79 -0
- package/dist/helpers/beforeScreenshot.test.d.ts +2 -0
- package/dist/helpers/beforeScreenshot.test.d.ts.map +1 -0
- package/dist/helpers/beforeScreenshot.test.js +261 -0
- package/dist/helpers/compare.interfaces.d.ts +16 -0
- package/dist/helpers/compare.interfaces.d.ts.map +1 -0
- package/dist/helpers/compare.interfaces.js +1 -0
- package/dist/helpers/constants.d.ts +108 -0
- package/dist/helpers/constants.d.ts.map +1 -0
- package/dist/helpers/constants.interfaces.d.ts +30 -0
- package/dist/helpers/constants.interfaces.d.ts.map +1 -0
- package/dist/helpers/constants.interfaces.js +11 -0
- package/dist/helpers/constants.js +436 -0
- package/dist/helpers/options.d.ts +64 -0
- package/dist/helpers/options.d.ts.map +1 -0
- package/dist/helpers/options.interfaces.d.ts +363 -0
- package/dist/helpers/options.interfaces.d.ts.map +1 -0
- package/dist/helpers/options.interfaces.js +1 -0
- package/dist/helpers/options.js +184 -0
- package/dist/helpers/options.test.d.ts +2 -0
- package/dist/helpers/options.test.d.ts.map +1 -0
- package/dist/helpers/options.test.js +428 -0
- package/dist/helpers/utils.d.ts +134 -0
- package/dist/helpers/utils.d.ts.map +1 -0
- package/dist/helpers/utils.interfaces.d.ts +254 -0
- package/dist/helpers/utils.interfaces.d.ts.map +1 -0
- package/dist/helpers/utils.interfaces.js +1 -0
- package/dist/helpers/utils.js +566 -0
- package/dist/helpers/utils.test.d.ts +2 -0
- package/dist/helpers/utils.test.d.ts.map +1 -0
- package/dist/helpers/utils.test.js +900 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/methods/compareReport.interfaces.d.ts +109 -0
- package/dist/methods/compareReport.interfaces.d.ts.map +1 -0
- package/dist/methods/compareReport.interfaces.js +1 -0
- package/dist/methods/createCompareReport.d.ts +7 -0
- package/dist/methods/createCompareReport.d.ts.map +1 -0
- package/dist/methods/createCompareReport.js +61 -0
- package/dist/methods/createCompareReport.test.d.ts +2 -0
- package/dist/methods/createCompareReport.test.d.ts.map +1 -0
- package/dist/methods/createCompareReport.test.js +236 -0
- package/dist/methods/elementPosition.d.ts +18 -0
- package/dist/methods/elementPosition.d.ts.map +1 -0
- package/dist/methods/elementPosition.interfaces.d.ts +14 -0
- package/dist/methods/elementPosition.interfaces.d.ts.map +1 -0
- package/dist/methods/elementPosition.interfaces.js +1 -0
- package/dist/methods/elementPosition.js +34 -0
- package/dist/methods/images.d.ts +69 -0
- package/dist/methods/images.d.ts.map +1 -0
- package/dist/methods/images.executeImageCompare.test.d.ts +2 -0
- package/dist/methods/images.executeImageCompare.test.d.ts.map +1 -0
- package/dist/methods/images.executeImageCompare.test.js +770 -0
- package/dist/methods/images.interfaces.d.ts +214 -0
- package/dist/methods/images.interfaces.d.ts.map +1 -0
- package/dist/methods/images.interfaces.js +1 -0
- package/dist/methods/images.js +428 -0
- package/dist/methods/images.test.d.ts +2 -0
- package/dist/methods/images.test.d.ts.map +1 -0
- package/dist/methods/images.test.js +1465 -0
- package/dist/methods/instanceData.d.ts +6 -0
- package/dist/methods/instanceData.d.ts.map +1 -0
- package/dist/methods/instanceData.interfaces.d.ts +57 -0
- package/dist/methods/instanceData.interfaces.d.ts.map +1 -0
- package/dist/methods/instanceData.interfaces.js +1 -0
- package/dist/methods/instanceData.js +42 -0
- package/dist/methods/instanceData.test.d.ts +2 -0
- package/dist/methods/instanceData.test.d.ts.map +1 -0
- package/dist/methods/instanceData.test.js +224 -0
- package/dist/methods/processDiffPixels.d.ts +59 -0
- package/dist/methods/processDiffPixels.d.ts.map +1 -0
- package/dist/methods/processDiffPixels.js +242 -0
- package/dist/methods/processDiffPixels.test.d.ts +2 -0
- package/dist/methods/processDiffPixels.test.d.ts.map +1 -0
- package/dist/methods/processDiffPixels.test.js +122 -0
- package/dist/methods/rectangles.d.ts +51 -0
- package/dist/methods/rectangles.d.ts.map +1 -0
- package/dist/methods/rectangles.interfaces.d.ts +146 -0
- package/dist/methods/rectangles.interfaces.d.ts.map +1 -0
- package/dist/methods/rectangles.interfaces.js +1 -0
- package/dist/methods/rectangles.js +266 -0
- package/dist/methods/rectangles.test.d.ts +2 -0
- package/dist/methods/rectangles.test.d.ts.map +1 -0
- package/dist/methods/rectangles.test.js +853 -0
- package/dist/methods/screenshots.d.ts +37 -0
- package/dist/methods/screenshots.d.ts.map +1 -0
- package/dist/methods/screenshots.interfaces.d.ts +203 -0
- package/dist/methods/screenshots.interfaces.d.ts.map +1 -0
- package/dist/methods/screenshots.interfaces.js +1 -0
- package/dist/methods/screenshots.js +394 -0
- package/dist/methods/screenshots.test.d.ts +2 -0
- package/dist/methods/screenshots.test.d.ts.map +1 -0
- package/dist/methods/screenshots.test.js +656 -0
- package/dist/methods/takeElementScreenshots.d.ts +3 -0
- package/dist/methods/takeElementScreenshots.d.ts.map +1 -0
- package/dist/methods/takeElementScreenshots.js +104 -0
- package/dist/methods/takeElementScreenshots.test.d.ts +2 -0
- package/dist/methods/takeElementScreenshots.test.d.ts.map +1 -0
- package/dist/methods/takeElementScreenshots.test.js +314 -0
- package/dist/methods/takeFullPageScreenshots.d.ts +3 -0
- package/dist/methods/takeFullPageScreenshots.d.ts.map +1 -0
- package/dist/methods/takeFullPageScreenshots.js +56 -0
- package/dist/methods/takeFullPageScreenshots.test.d.ts +2 -0
- package/dist/methods/takeFullPageScreenshots.test.d.ts.map +1 -0
- package/dist/methods/takeFullPageScreenshots.test.js +72 -0
- package/dist/methods/takeWebScreenshots.d.ts +3 -0
- package/dist/methods/takeWebScreenshots.d.ts.map +1 -0
- package/dist/methods/takeWebScreenshots.js +41 -0
- package/dist/methods/takeWebScreenshots.test.d.ts +2 -0
- package/dist/methods/takeWebScreenshots.test.d.ts.map +1 -0
- package/dist/methods/takeWebScreenshots.test.js +149 -0
- package/dist/mocks/image.d.ts +4 -0
- package/dist/mocks/image.d.ts.map +1 -0
- package/dist/mocks/image.js +3 -0
- package/dist/mocks/mocks.d.ts +745 -0
- package/dist/mocks/mocks.d.ts.map +1 -0
- package/dist/mocks/mocks.js +392 -0
- package/dist/resemble/compare.interfaces.d.ts +136 -0
- package/dist/resemble/compare.interfaces.d.ts.map +1 -0
- package/dist/resemble/compare.interfaces.js +1 -0
- package/dist/resemble/compareImages.d.ts +3 -0
- package/dist/resemble/compareImages.d.ts.map +1 -0
- package/dist/resemble/compareImages.js +21 -0
- package/dist/resemble/resemble.jimp.cjs +981 -0
- package/dist/resemble/resemble.jimp.d.cts +46 -0
- package/dist/resemble/resemble.jimp.d.cts.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,853 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { determineElementRectangles, determineScreenRectangles, determineStatusAddressToolBarRectangles, determineIgnoreRegions, splitIgnores, determineDeviceBlockOuts, prepareIgnoreRectangles } from './rectangles.js';
|
|
4
|
+
import { IMAGE_STRING } from '../mocks/image.js';
|
|
5
|
+
vi.mock('@wdio/globals', () => ({
|
|
6
|
+
browser: {
|
|
7
|
+
execute: vi.fn(),
|
|
8
|
+
}
|
|
9
|
+
}));
|
|
10
|
+
vi.mock('@wdio/logger', () => import(join(process.cwd(), '__mocks__', '@wdio/logger')));
|
|
11
|
+
describe('rectangles', () => {
|
|
12
|
+
let mockBrowserInstance;
|
|
13
|
+
let mockExecute;
|
|
14
|
+
let mockGetElementRect;
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
mockExecute = vi.fn();
|
|
17
|
+
mockGetElementRect = vi.fn();
|
|
18
|
+
mockBrowserInstance = {
|
|
19
|
+
execute: mockExecute,
|
|
20
|
+
getElementRect: mockGetElementRect
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
vi.clearAllMocks();
|
|
25
|
+
});
|
|
26
|
+
const baseDeviceRectangles = {
|
|
27
|
+
bottomBar: { y: 0, x: 0, width: 0, height: 0 },
|
|
28
|
+
homeBar: { y: 0, x: 0, width: 0, height: 0 },
|
|
29
|
+
leftSidePadding: { y: 0, x: 0, width: 0, height: 0 },
|
|
30
|
+
rightSidePadding: { y: 0, x: 0, width: 0, height: 0 },
|
|
31
|
+
screenSize: { height: 0, width: 0 },
|
|
32
|
+
statusBar: { y: 0, x: 0, width: 0, height: 0 },
|
|
33
|
+
statusBarAndAddressBar: { y: 0, x: 0, width: 0, height: 0 },
|
|
34
|
+
viewport: { y: 0, x: 0, width: 0, height: 0 },
|
|
35
|
+
};
|
|
36
|
+
const createElementOptions = (overrides = {}) => ({
|
|
37
|
+
isAndroid: false,
|
|
38
|
+
devicePixelRatio: 2,
|
|
39
|
+
deviceRectangles: baseDeviceRectangles,
|
|
40
|
+
isAndroidNativeWebScreenshot: false,
|
|
41
|
+
innerHeight: 500,
|
|
42
|
+
isIOS: false,
|
|
43
|
+
initialDevicePixelRatio: 2,
|
|
44
|
+
isEmulated: false,
|
|
45
|
+
...overrides,
|
|
46
|
+
});
|
|
47
|
+
const createScreenOptions = (overrides = {}) => ({
|
|
48
|
+
innerHeight: 553,
|
|
49
|
+
innerWidth: 375,
|
|
50
|
+
isAndroidNativeWebScreenshot: false,
|
|
51
|
+
isAndroidChromeDriverScreenshot: false,
|
|
52
|
+
isIOS: false,
|
|
53
|
+
devicePixelRatio: 2,
|
|
54
|
+
isLandscape: false,
|
|
55
|
+
initialDevicePixelRatio: 2,
|
|
56
|
+
enableLegacyScreenshotMethod: false,
|
|
57
|
+
isEmulated: false,
|
|
58
|
+
...overrides,
|
|
59
|
+
});
|
|
60
|
+
const createStatusAddressToolBarOptions = (overrides = {}) => ({
|
|
61
|
+
blockOutSideBar: false,
|
|
62
|
+
blockOutStatusBar: false,
|
|
63
|
+
blockOutToolBar: false,
|
|
64
|
+
isAndroid: false,
|
|
65
|
+
isAndroidNativeWebScreenshot: false,
|
|
66
|
+
isMobile: false,
|
|
67
|
+
isViewPortScreenshot: false,
|
|
68
|
+
...overrides,
|
|
69
|
+
});
|
|
70
|
+
const createDeviceRectanglesWithData = (overrides = {}) => ({
|
|
71
|
+
...baseDeviceRectangles,
|
|
72
|
+
statusBarAndAddressBar: { y: 0, x: 0, width: 1344, height: 320 },
|
|
73
|
+
viewport: { y: 320, x: 0, width: 1344, height: 2601 },
|
|
74
|
+
bottomBar: { y: 2921, x: 0, width: 1344, height: 71 },
|
|
75
|
+
leftSidePadding: { y: 320, x: 0, width: 0, height: 2601 },
|
|
76
|
+
rightSidePadding: { y: 320, x: 1344, width: 0, height: 2601 },
|
|
77
|
+
...overrides,
|
|
78
|
+
});
|
|
79
|
+
const createDeviceBlockOutsOptions = (overrides = {}) => ({
|
|
80
|
+
isAndroid: false,
|
|
81
|
+
screenCompareOptions: {
|
|
82
|
+
blockOutStatusBar: false,
|
|
83
|
+
blockOutToolBar: false,
|
|
84
|
+
},
|
|
85
|
+
instanceData: {
|
|
86
|
+
appName: 'TestApp',
|
|
87
|
+
browserName: 'Chrome',
|
|
88
|
+
browserVersion: '118.0.0.0',
|
|
89
|
+
deviceName: 'iPhone 14',
|
|
90
|
+
devicePixelRatio: 2,
|
|
91
|
+
deviceRectangles: {
|
|
92
|
+
bottomBar: { y: 800, x: 0, width: 390, height: 0 },
|
|
93
|
+
homeBar: { x: 0, y: 780, width: 390, height: 34 },
|
|
94
|
+
leftSidePadding: { y: 0, x: 0, width: 0, height: 0 },
|
|
95
|
+
rightSidePadding: { y: 0, x: 0, width: 0, height: 0 },
|
|
96
|
+
screenSize: { height: 844, width: 390 },
|
|
97
|
+
statusBar: { x: 0, y: 0, width: 390, height: 47 },
|
|
98
|
+
statusBarAndAddressBar: { y: 0, x: 0, width: 390, height: 47 },
|
|
99
|
+
viewport: { y: 47, x: 0, width: 390, height: 733 }
|
|
100
|
+
},
|
|
101
|
+
initialDevicePixelRatio: 2,
|
|
102
|
+
isAndroid: false,
|
|
103
|
+
isIOS: true,
|
|
104
|
+
isMobile: true,
|
|
105
|
+
logName: 'test-log',
|
|
106
|
+
name: 'test-device',
|
|
107
|
+
nativeWebScreenshot: false,
|
|
108
|
+
platformName: 'iOS',
|
|
109
|
+
platformVersion: '17.0'
|
|
110
|
+
},
|
|
111
|
+
...overrides,
|
|
112
|
+
});
|
|
113
|
+
const createPrepareIgnoreRectanglesOptions = (overrides = {}) => ({
|
|
114
|
+
blockOut: [],
|
|
115
|
+
ignoreRegions: [],
|
|
116
|
+
deviceRectangles: createDeviceRectanglesWithData(),
|
|
117
|
+
devicePixelRatio: 2,
|
|
118
|
+
isMobile: false,
|
|
119
|
+
isNativeContext: false,
|
|
120
|
+
isAndroid: false,
|
|
121
|
+
isAndroidNativeWebScreenshot: false,
|
|
122
|
+
isViewPortScreenshot: true,
|
|
123
|
+
imageCompareOptions: {
|
|
124
|
+
blockOutSideBar: false,
|
|
125
|
+
blockOutStatusBar: false,
|
|
126
|
+
blockOutToolBar: false,
|
|
127
|
+
},
|
|
128
|
+
...overrides,
|
|
129
|
+
});
|
|
130
|
+
describe('determineElementRectangles', () => {
|
|
131
|
+
it('should determine them for iOS', async () => {
|
|
132
|
+
const options = createElementOptions({
|
|
133
|
+
isIOS: true,
|
|
134
|
+
innerHeight: 678,
|
|
135
|
+
deviceRectangles: {
|
|
136
|
+
...baseDeviceRectangles,
|
|
137
|
+
viewport: { y: 20, x: 30, width: 0, height: 0 },
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
mockExecute.mockResolvedValueOnce({
|
|
141
|
+
height: 120,
|
|
142
|
+
width: 120,
|
|
143
|
+
x: 100,
|
|
144
|
+
y: 10,
|
|
145
|
+
});
|
|
146
|
+
const result = await determineElementRectangles({
|
|
147
|
+
browserInstance: mockBrowserInstance,
|
|
148
|
+
base64Image: IMAGE_STRING,
|
|
149
|
+
options,
|
|
150
|
+
element: 'element',
|
|
151
|
+
});
|
|
152
|
+
expect(result).toMatchSnapshot();
|
|
153
|
+
expect(mockExecute).toHaveBeenCalled();
|
|
154
|
+
});
|
|
155
|
+
it('should determine them for Android Native webscreenshot', async () => {
|
|
156
|
+
const options = createElementOptions({
|
|
157
|
+
isAndroid: true,
|
|
158
|
+
devicePixelRatio: 3,
|
|
159
|
+
initialDevicePixelRatio: 3,
|
|
160
|
+
isAndroidNativeWebScreenshot: true,
|
|
161
|
+
innerHeight: 678,
|
|
162
|
+
deviceRectangles: {
|
|
163
|
+
...baseDeviceRectangles,
|
|
164
|
+
viewport: { y: 200, x: 300, width: 0, height: 0 },
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
mockExecute.mockResolvedValueOnce({
|
|
168
|
+
height: 300,
|
|
169
|
+
width: 200,
|
|
170
|
+
x: 100,
|
|
171
|
+
y: 10,
|
|
172
|
+
});
|
|
173
|
+
const result = await determineElementRectangles({
|
|
174
|
+
browserInstance: mockBrowserInstance,
|
|
175
|
+
base64Image: IMAGE_STRING,
|
|
176
|
+
options,
|
|
177
|
+
element: 'element',
|
|
178
|
+
});
|
|
179
|
+
expect(result).toMatchSnapshot();
|
|
180
|
+
expect(mockExecute).toHaveBeenCalled();
|
|
181
|
+
});
|
|
182
|
+
it('should determine them for Android ChromeDriver', async () => {
|
|
183
|
+
const options = createElementOptions({
|
|
184
|
+
isAndroid: true,
|
|
185
|
+
devicePixelRatio: 1,
|
|
186
|
+
initialDevicePixelRatio: 1,
|
|
187
|
+
innerHeight: 678,
|
|
188
|
+
deviceRectangles: {
|
|
189
|
+
...baseDeviceRectangles,
|
|
190
|
+
viewport: { y: 200, x: 300, width: 0, height: 0 },
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
mockExecute.mockResolvedValueOnce({
|
|
194
|
+
height: 20,
|
|
195
|
+
width: 375,
|
|
196
|
+
x: 0,
|
|
197
|
+
y: 0,
|
|
198
|
+
});
|
|
199
|
+
const result = await determineElementRectangles({
|
|
200
|
+
browserInstance: mockBrowserInstance,
|
|
201
|
+
base64Image: IMAGE_STRING,
|
|
202
|
+
options,
|
|
203
|
+
element: 'element',
|
|
204
|
+
});
|
|
205
|
+
expect(result).toMatchSnapshot();
|
|
206
|
+
expect(mockExecute).toHaveBeenCalled();
|
|
207
|
+
});
|
|
208
|
+
it('should determine them for a desktop browser', async () => {
|
|
209
|
+
const options = createElementOptions({
|
|
210
|
+
innerHeight: 500,
|
|
211
|
+
});
|
|
212
|
+
mockExecute.mockResolvedValueOnce({
|
|
213
|
+
height: 20,
|
|
214
|
+
width: 375,
|
|
215
|
+
x: 12,
|
|
216
|
+
y: 34,
|
|
217
|
+
});
|
|
218
|
+
const result = await determineElementRectangles({
|
|
219
|
+
browserInstance: mockBrowserInstance,
|
|
220
|
+
base64Image: IMAGE_STRING,
|
|
221
|
+
options,
|
|
222
|
+
element: 'element',
|
|
223
|
+
});
|
|
224
|
+
expect(result).toMatchSnapshot();
|
|
225
|
+
expect(mockExecute).toHaveBeenCalled();
|
|
226
|
+
});
|
|
227
|
+
it('should determine them for emulated device', async () => {
|
|
228
|
+
const options = createElementOptions({
|
|
229
|
+
isEmulated: true,
|
|
230
|
+
innerHeight: 600,
|
|
231
|
+
devicePixelRatio: 3,
|
|
232
|
+
});
|
|
233
|
+
mockExecute.mockResolvedValueOnce({
|
|
234
|
+
height: 50,
|
|
235
|
+
width: 200,
|
|
236
|
+
x: 15,
|
|
237
|
+
y: 25,
|
|
238
|
+
});
|
|
239
|
+
const result = await determineElementRectangles({
|
|
240
|
+
browserInstance: mockBrowserInstance,
|
|
241
|
+
base64Image: IMAGE_STRING,
|
|
242
|
+
options,
|
|
243
|
+
element: 'element',
|
|
244
|
+
});
|
|
245
|
+
expect(result).toMatchSnapshot();
|
|
246
|
+
expect(mockExecute).toHaveBeenCalled();
|
|
247
|
+
});
|
|
248
|
+
it('should throw an error when the element height is 0', async () => {
|
|
249
|
+
const options = createElementOptions();
|
|
250
|
+
mockExecute.mockResolvedValueOnce({
|
|
251
|
+
height: 0,
|
|
252
|
+
width: 375,
|
|
253
|
+
x: 12,
|
|
254
|
+
y: 34,
|
|
255
|
+
});
|
|
256
|
+
await expect(determineElementRectangles({
|
|
257
|
+
browserInstance: mockBrowserInstance,
|
|
258
|
+
base64Image: IMAGE_STRING,
|
|
259
|
+
options,
|
|
260
|
+
element: { selector: '#elementID' },
|
|
261
|
+
})).rejects.toThrow('The element, with selector "$(#elementID)",is not visible. The dimensions are 375x0');
|
|
262
|
+
});
|
|
263
|
+
it('should throw an error when the element width is 0', async () => {
|
|
264
|
+
const options = createElementOptions();
|
|
265
|
+
mockExecute.mockResolvedValueOnce({
|
|
266
|
+
height: 375,
|
|
267
|
+
width: 0,
|
|
268
|
+
x: 12,
|
|
269
|
+
y: 34,
|
|
270
|
+
});
|
|
271
|
+
await expect(determineElementRectangles({
|
|
272
|
+
browserInstance: mockBrowserInstance,
|
|
273
|
+
base64Image: IMAGE_STRING,
|
|
274
|
+
options,
|
|
275
|
+
element: { selector: '#elementID' },
|
|
276
|
+
})).rejects.toThrow('The element, with selector "$(#elementID)",is not visible. The dimensions are 0x375');
|
|
277
|
+
});
|
|
278
|
+
it('should throw an error when the element width is 0 and no element selector is provided', async () => {
|
|
279
|
+
const options = createElementOptions();
|
|
280
|
+
mockExecute.mockResolvedValueOnce({
|
|
281
|
+
height: 375,
|
|
282
|
+
width: 0,
|
|
283
|
+
x: 12,
|
|
284
|
+
y: 34,
|
|
285
|
+
});
|
|
286
|
+
await expect(determineElementRectangles({
|
|
287
|
+
browserInstance: mockBrowserInstance,
|
|
288
|
+
base64Image: IMAGE_STRING,
|
|
289
|
+
options,
|
|
290
|
+
element: {},
|
|
291
|
+
})).rejects.toThrow('The element is not visible. The dimensions are 0x375');
|
|
292
|
+
});
|
|
293
|
+
it('should handle Android webview elements', async () => {
|
|
294
|
+
const options = createElementOptions({
|
|
295
|
+
isAndroid: true,
|
|
296
|
+
isAndroidNativeWebScreenshot: true,
|
|
297
|
+
devicePixelRatio: 2,
|
|
298
|
+
deviceRectangles: {
|
|
299
|
+
...baseDeviceRectangles,
|
|
300
|
+
viewport: { y: 100, x: 50, width: 375, height: 667 },
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
mockExecute.mockResolvedValueOnce({
|
|
304
|
+
height: 100,
|
|
305
|
+
width: 200,
|
|
306
|
+
x: 50,
|
|
307
|
+
y: 75,
|
|
308
|
+
});
|
|
309
|
+
const result = await determineElementRectangles({
|
|
310
|
+
browserInstance: mockBrowserInstance,
|
|
311
|
+
base64Image: IMAGE_STRING,
|
|
312
|
+
options,
|
|
313
|
+
element: 'webview-element',
|
|
314
|
+
});
|
|
315
|
+
expect(result).toMatchSnapshot();
|
|
316
|
+
expect(mockExecute).toHaveBeenCalled();
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
describe('determineScreenRectangles', () => {
|
|
320
|
+
it('should determine them for iOS', async () => {
|
|
321
|
+
const options = createScreenOptions({
|
|
322
|
+
isIOS: true,
|
|
323
|
+
});
|
|
324
|
+
expect(determineScreenRectangles(IMAGE_STRING, options)).toMatchSnapshot();
|
|
325
|
+
});
|
|
326
|
+
it('should determine them for Android ChromeDriver', async () => {
|
|
327
|
+
const options = createScreenOptions({
|
|
328
|
+
isAndroidChromeDriverScreenshot: true,
|
|
329
|
+
});
|
|
330
|
+
expect(determineScreenRectangles(IMAGE_STRING, options)).toMatchSnapshot();
|
|
331
|
+
});
|
|
332
|
+
it('should determine them for Android Native webscreenshot', async () => {
|
|
333
|
+
const options = createScreenOptions({
|
|
334
|
+
isAndroidNativeWebScreenshot: true,
|
|
335
|
+
});
|
|
336
|
+
expect(determineScreenRectangles(IMAGE_STRING, options)).toMatchSnapshot();
|
|
337
|
+
});
|
|
338
|
+
it('should determine them for desktop browser', async () => {
|
|
339
|
+
const options = createScreenOptions({
|
|
340
|
+
innerHeight: 768,
|
|
341
|
+
innerWidth: 1024,
|
|
342
|
+
devicePixelRatio: 1,
|
|
343
|
+
});
|
|
344
|
+
expect(determineScreenRectangles(IMAGE_STRING, options)).toMatchSnapshot();
|
|
345
|
+
});
|
|
346
|
+
it('should determine them for emulated device', async () => {
|
|
347
|
+
const options = createScreenOptions({
|
|
348
|
+
isEmulated: true,
|
|
349
|
+
devicePixelRatio: 3,
|
|
350
|
+
isLandscape: true,
|
|
351
|
+
});
|
|
352
|
+
expect(determineScreenRectangles(IMAGE_STRING, options)).toMatchSnapshot();
|
|
353
|
+
});
|
|
354
|
+
it('should determine them with legacy screenshot method', async () => {
|
|
355
|
+
const options = createScreenOptions({
|
|
356
|
+
enableLegacyScreenshotMethod: true,
|
|
357
|
+
isIOS: true,
|
|
358
|
+
});
|
|
359
|
+
expect(determineScreenRectangles(IMAGE_STRING, options)).toMatchSnapshot();
|
|
360
|
+
});
|
|
361
|
+
it('should use initialDevicePixelRatio when isEmulated and enableLegacyScreenshotMethod are both true', async () => {
|
|
362
|
+
const options = createScreenOptions({
|
|
363
|
+
isEmulated: true,
|
|
364
|
+
enableLegacyScreenshotMethod: true,
|
|
365
|
+
devicePixelRatio: 3,
|
|
366
|
+
initialDevicePixelRatio: 2,
|
|
367
|
+
innerHeight: 768,
|
|
368
|
+
innerWidth: 1024,
|
|
369
|
+
});
|
|
370
|
+
expect(determineScreenRectangles(IMAGE_STRING, options)).toMatchSnapshot();
|
|
371
|
+
});
|
|
372
|
+
it('should handle landscape rotation when height > width', async () => {
|
|
373
|
+
const tallImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVR42mP8/5+hnoEIwDiqAAC4sAP9TiGZQgAAAABJRU5ErkJggg==';
|
|
374
|
+
const options = createScreenOptions({
|
|
375
|
+
isLandscape: true,
|
|
376
|
+
innerHeight: 1024,
|
|
377
|
+
innerWidth: 768,
|
|
378
|
+
devicePixelRatio: 1,
|
|
379
|
+
});
|
|
380
|
+
expect(determineScreenRectangles(tallImage, options)).toMatchSnapshot();
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
describe('determineStatusAddressToolBarRectangles', () => {
|
|
384
|
+
it('should determine the rectangles with all blockouts enabled', async () => {
|
|
385
|
+
const options = createStatusAddressToolBarOptions({
|
|
386
|
+
blockOutSideBar: true,
|
|
387
|
+
blockOutStatusBar: true,
|
|
388
|
+
blockOutToolBar: true,
|
|
389
|
+
isAndroid: true,
|
|
390
|
+
isAndroidNativeWebScreenshot: true,
|
|
391
|
+
isMobile: true,
|
|
392
|
+
isViewPortScreenshot: true,
|
|
393
|
+
});
|
|
394
|
+
const deviceRectangles = createDeviceRectanglesWithData();
|
|
395
|
+
expect(determineStatusAddressToolBarRectangles({ deviceRectangles, options })).toMatchSnapshot();
|
|
396
|
+
});
|
|
397
|
+
it('should determine the rectangles with no blockouts', async () => {
|
|
398
|
+
const options = createStatusAddressToolBarOptions();
|
|
399
|
+
const deviceRectangles = createDeviceRectanglesWithData();
|
|
400
|
+
expect(determineStatusAddressToolBarRectangles({ deviceRectangles, options })).toMatchSnapshot();
|
|
401
|
+
});
|
|
402
|
+
it('should determine the rectangles with only status bar blockout', async () => {
|
|
403
|
+
const options = createStatusAddressToolBarOptions({
|
|
404
|
+
blockOutStatusBar: true,
|
|
405
|
+
isAndroid: true,
|
|
406
|
+
isMobile: true,
|
|
407
|
+
isViewPortScreenshot: true,
|
|
408
|
+
});
|
|
409
|
+
const deviceRectangles = createDeviceRectanglesWithData();
|
|
410
|
+
expect(determineStatusAddressToolBarRectangles({ deviceRectangles, options })).toMatchSnapshot();
|
|
411
|
+
});
|
|
412
|
+
it('should determine the rectangles with only toolbar blockout', async () => {
|
|
413
|
+
const options = createStatusAddressToolBarOptions({
|
|
414
|
+
blockOutToolBar: true,
|
|
415
|
+
isAndroid: true,
|
|
416
|
+
isMobile: true,
|
|
417
|
+
isViewPortScreenshot: true,
|
|
418
|
+
});
|
|
419
|
+
const deviceRectangles = createDeviceRectanglesWithData();
|
|
420
|
+
expect(determineStatusAddressToolBarRectangles({ deviceRectangles, options })).toMatchSnapshot();
|
|
421
|
+
});
|
|
422
|
+
it('should determine the rectangles with only sidebar blockout', async () => {
|
|
423
|
+
const options = createStatusAddressToolBarOptions({
|
|
424
|
+
blockOutSideBar: true,
|
|
425
|
+
isAndroid: true,
|
|
426
|
+
isMobile: true,
|
|
427
|
+
isViewPortScreenshot: true,
|
|
428
|
+
});
|
|
429
|
+
const deviceRectangles = createDeviceRectanglesWithData();
|
|
430
|
+
expect(determineStatusAddressToolBarRectangles({ deviceRectangles, options })).toMatchSnapshot();
|
|
431
|
+
});
|
|
432
|
+
it('should determine the rectangles for iOS with blockouts', async () => {
|
|
433
|
+
const options = createStatusAddressToolBarOptions({
|
|
434
|
+
blockOutSideBar: true,
|
|
435
|
+
blockOutStatusBar: true,
|
|
436
|
+
blockOutToolBar: true,
|
|
437
|
+
isAndroid: false,
|
|
438
|
+
isAndroidNativeWebScreenshot: false,
|
|
439
|
+
isMobile: true,
|
|
440
|
+
isViewPortScreenshot: true,
|
|
441
|
+
});
|
|
442
|
+
const deviceRectangles = createDeviceRectanglesWithData();
|
|
443
|
+
expect(determineStatusAddressToolBarRectangles({ deviceRectangles, options })).toMatchSnapshot();
|
|
444
|
+
});
|
|
445
|
+
it('should determine the rectangles for non-mobile device', async () => {
|
|
446
|
+
const options = createStatusAddressToolBarOptions({
|
|
447
|
+
blockOutStatusBar: true,
|
|
448
|
+
isMobile: false,
|
|
449
|
+
isViewPortScreenshot: false,
|
|
450
|
+
});
|
|
451
|
+
const deviceRectangles = createDeviceRectanglesWithData();
|
|
452
|
+
expect(determineStatusAddressToolBarRectangles({ deviceRectangles, options })).toMatchSnapshot();
|
|
453
|
+
});
|
|
454
|
+
it('should determine the rectangles for Android without native web screenshot', async () => {
|
|
455
|
+
const options = createStatusAddressToolBarOptions({
|
|
456
|
+
blockOutStatusBar: true,
|
|
457
|
+
blockOutToolBar: true,
|
|
458
|
+
isAndroid: true,
|
|
459
|
+
isAndroidNativeWebScreenshot: false,
|
|
460
|
+
isMobile: true,
|
|
461
|
+
isViewPortScreenshot: true,
|
|
462
|
+
});
|
|
463
|
+
const deviceRectangles = createDeviceRectanglesWithData();
|
|
464
|
+
expect(determineStatusAddressToolBarRectangles({ deviceRectangles, options })).toMatchSnapshot();
|
|
465
|
+
});
|
|
466
|
+
it('should handle empty device rectangles', async () => {
|
|
467
|
+
const options = createStatusAddressToolBarOptions({
|
|
468
|
+
blockOutStatusBar: true,
|
|
469
|
+
blockOutToolBar: true,
|
|
470
|
+
isAndroid: true,
|
|
471
|
+
isMobile: true,
|
|
472
|
+
isViewPortScreenshot: true,
|
|
473
|
+
});
|
|
474
|
+
const deviceRectangles = baseDeviceRectangles;
|
|
475
|
+
expect(determineStatusAddressToolBarRectangles({ deviceRectangles, options })).toMatchSnapshot();
|
|
476
|
+
});
|
|
477
|
+
it('should handle edge case with complex mobile configuration', async () => {
|
|
478
|
+
const options = createStatusAddressToolBarOptions({
|
|
479
|
+
blockOutStatusBar: false,
|
|
480
|
+
blockOutToolBar: false,
|
|
481
|
+
blockOutSideBar: false,
|
|
482
|
+
isAndroid: true,
|
|
483
|
+
isAndroidNativeWebScreenshot: true,
|
|
484
|
+
isMobile: true,
|
|
485
|
+
isViewPortScreenshot: true,
|
|
486
|
+
});
|
|
487
|
+
const deviceRectangles = createDeviceRectanglesWithData();
|
|
488
|
+
expect(determineStatusAddressToolBarRectangles({ deviceRectangles, options })).toEqual([]);
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
describe('splitIgnores', () => {
|
|
492
|
+
it('should split valid elements and regions correctly', () => {
|
|
493
|
+
const mockElement1 = { elementId: 'element1', selector: '#test1' };
|
|
494
|
+
const mockElement2 = { elementId: 'element2', selector: '#test2' };
|
|
495
|
+
const mockRegion1 = { x: 10, y: 20, width: 100, height: 150 };
|
|
496
|
+
const mockRegion2 = { x: 30, y: 40, width: 200, height: 250 };
|
|
497
|
+
const items = [mockElement1, mockRegion1, mockElement2, mockRegion2];
|
|
498
|
+
const result = splitIgnores(items);
|
|
499
|
+
expect(result).toEqual({
|
|
500
|
+
elements: [mockElement1, mockElement2],
|
|
501
|
+
regions: [mockRegion1, mockRegion2]
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
it('should handle nested element arrays', () => {
|
|
505
|
+
const mockElement1 = { elementId: 'element1', selector: '#test1' };
|
|
506
|
+
const mockElement2 = { elementId: 'element2', selector: '#test2' };
|
|
507
|
+
const mockRegion = { x: 10, y: 20, width: 100, height: 150 };
|
|
508
|
+
const items = [[mockElement1, mockElement2], mockRegion];
|
|
509
|
+
const result = splitIgnores(items);
|
|
510
|
+
expect(result).toEqual({
|
|
511
|
+
elements: [mockElement1, mockElement2],
|
|
512
|
+
regions: [mockRegion]
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
it('should handle only elements', () => {
|
|
516
|
+
const mockElement1 = { elementId: 'element1', selector: '#test1' };
|
|
517
|
+
const mockElement2 = { elementId: 'element2', selector: '#test2' };
|
|
518
|
+
const items = [mockElement1, mockElement2];
|
|
519
|
+
const result = splitIgnores(items);
|
|
520
|
+
expect(result).toEqual({
|
|
521
|
+
elements: [mockElement1, mockElement2],
|
|
522
|
+
regions: []
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
it('should handle only regions', () => {
|
|
526
|
+
const mockRegion1 = { x: 10, y: 20, width: 100, height: 150 };
|
|
527
|
+
const mockRegion2 = { x: 30, y: 40, width: 200, height: 250 };
|
|
528
|
+
const items = [mockRegion1, mockRegion2];
|
|
529
|
+
const result = splitIgnores(items);
|
|
530
|
+
expect(result).toEqual({
|
|
531
|
+
elements: [],
|
|
532
|
+
regions: [mockRegion1, mockRegion2]
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
it('should handle empty array', () => {
|
|
536
|
+
const result = splitIgnores([]);
|
|
537
|
+
expect(result).toEqual({
|
|
538
|
+
elements: [],
|
|
539
|
+
regions: []
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
it('should throw error for invalid element in top-level array', () => {
|
|
543
|
+
const invalidItems = [
|
|
544
|
+
'invalid-string',
|
|
545
|
+
{ invalid: 'object' },
|
|
546
|
+
123
|
|
547
|
+
];
|
|
548
|
+
expect(() => splitIgnores(invalidItems)).toThrowErrorMatchingSnapshot();
|
|
549
|
+
});
|
|
550
|
+
it('should throw error for invalid element in nested array', () => {
|
|
551
|
+
const invalidNestedItems = [
|
|
552
|
+
[{ elementId: 'valid', selector: '#valid' }, 'invalid-nested'],
|
|
553
|
+
{ x: 10, y: 20, width: 100, height: 150 }
|
|
554
|
+
];
|
|
555
|
+
expect(() => splitIgnores(invalidNestedItems)).toThrowErrorMatchingSnapshot();
|
|
556
|
+
});
|
|
557
|
+
it('should throw error for mixed invalid items', () => {
|
|
558
|
+
const mixedInvalidItems = [
|
|
559
|
+
[{ elementId: 'valid', selector: '#valid' }, { invalid: 'nested' }],
|
|
560
|
+
'invalid-string',
|
|
561
|
+
{ x: 10, y: 20, width: 100, height: 150 },
|
|
562
|
+
null
|
|
563
|
+
];
|
|
564
|
+
expect(() => splitIgnores(mixedInvalidItems)).toThrow('Invalid elements or regions');
|
|
565
|
+
});
|
|
566
|
+
it('should handle mixed valid and invalid items in nested array', () => {
|
|
567
|
+
const validElement = { elementId: 'element1', selector: '#test1' };
|
|
568
|
+
const items = [
|
|
569
|
+
[validElement, 'invalid'],
|
|
570
|
+
{ x: 10, y: 20, width: 100, height: 150 }
|
|
571
|
+
];
|
|
572
|
+
expect(() => splitIgnores(items)).toThrowErrorMatchingSnapshot();
|
|
573
|
+
});
|
|
574
|
+
it('should handle object that looks like element but missing properties', () => {
|
|
575
|
+
const almostElement = { elementId: 'element1' };
|
|
576
|
+
const items = [almostElement];
|
|
577
|
+
expect(() => splitIgnores(items)).toThrow('Invalid elements or regions');
|
|
578
|
+
});
|
|
579
|
+
it('should handle object that looks like region but missing properties', () => {
|
|
580
|
+
const almostRegion = { x: 10, y: 20, width: 100 };
|
|
581
|
+
const items = [almostRegion];
|
|
582
|
+
expect(() => splitIgnores(items)).toThrow('Invalid elements or regions');
|
|
583
|
+
});
|
|
584
|
+
it('should handle region with non-numeric properties', () => {
|
|
585
|
+
const invalidRegion = { x: '10', y: 20, width: 100, height: 150 };
|
|
586
|
+
const items = [invalidRegion];
|
|
587
|
+
expect(() => splitIgnores(items)).toThrow('Invalid elements or regions');
|
|
588
|
+
});
|
|
589
|
+
it('should handle element with non-string properties', () => {
|
|
590
|
+
const invalidElement = { elementId: 123, selector: '#test' };
|
|
591
|
+
const items = [invalidElement];
|
|
592
|
+
expect(() => splitIgnores(items)).toThrow('Invalid elements or regions');
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
describe('determineIgnoreRegions', () => {
|
|
596
|
+
it('should await promises, combine regions and elements, and round coordinates', async () => {
|
|
597
|
+
const mockElement = { elementId: 'element1', selector: '#test1' };
|
|
598
|
+
const mockRegion = { x: 10.7, y: 20.3, width: 100.9, height: 150.1 };
|
|
599
|
+
mockGetElementRect.mockResolvedValueOnce({ x: 50.4, y: 60.8, width: 200.2, height: 250.6 });
|
|
600
|
+
const ignores = [mockElement, mockRegion];
|
|
601
|
+
const result = await determineIgnoreRegions(mockBrowserInstance, ignores);
|
|
602
|
+
expect(result).toEqual([
|
|
603
|
+
{ x: 11, y: 20, width: 101, height: 150 },
|
|
604
|
+
{ x: 50, y: 61, width: 200, height: 251 }
|
|
605
|
+
]);
|
|
606
|
+
expect(mockGetElementRect).toHaveBeenCalledWith('element1');
|
|
607
|
+
});
|
|
608
|
+
it('should handle Promise.all correctly for chainable elements', async () => {
|
|
609
|
+
const chainableElement = Promise.resolve({ elementId: 'element1', selector: '#test1' });
|
|
610
|
+
const mockRegion = { x: 10, y: 20, width: 100, height: 150 };
|
|
611
|
+
mockGetElementRect.mockResolvedValueOnce({ x: 50, y: 60, width: 200, height: 250 });
|
|
612
|
+
const ignores = [chainableElement, mockRegion];
|
|
613
|
+
const result = await determineIgnoreRegions(mockBrowserInstance, ignores);
|
|
614
|
+
expect(result).toEqual([
|
|
615
|
+
{ x: 10, y: 20, width: 100, height: 150 },
|
|
616
|
+
{ x: 50, y: 60, width: 200, height: 250 }
|
|
617
|
+
]);
|
|
618
|
+
expect(mockGetElementRect).toHaveBeenCalledWith('element1');
|
|
619
|
+
});
|
|
620
|
+
it('should handle empty arrays', async () => {
|
|
621
|
+
const result = await determineIgnoreRegions(mockBrowserInstance, []);
|
|
622
|
+
expect(result).toEqual([]);
|
|
623
|
+
expect(mockGetElementRect).not.toHaveBeenCalled();
|
|
624
|
+
});
|
|
625
|
+
it('should delegate validation to splitIgnores and propagate errors', async () => {
|
|
626
|
+
const invalidIgnores = ['invalid-string'];
|
|
627
|
+
// @ts-expect-error - invalid ignore regions for testing
|
|
628
|
+
await expect(determineIgnoreRegions(mockBrowserInstance, invalidIgnores))
|
|
629
|
+
.rejects.toThrow('Invalid elements or regions');
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
describe('determineDeviceBlockOuts', () => {
|
|
633
|
+
it('should return empty array when no blockouts are enabled', async () => {
|
|
634
|
+
const options = createDeviceBlockOutsOptions();
|
|
635
|
+
const result = await determineDeviceBlockOuts(options);
|
|
636
|
+
expect(result).toEqual([]);
|
|
637
|
+
});
|
|
638
|
+
it('should return statusBar when blockOutStatusBar is enabled', async () => {
|
|
639
|
+
const options = createDeviceBlockOutsOptions({
|
|
640
|
+
screenCompareOptions: {
|
|
641
|
+
blockOutStatusBar: true,
|
|
642
|
+
blockOutToolBar: false,
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
const result = await determineDeviceBlockOuts(options);
|
|
646
|
+
expect(result).toMatchSnapshot();
|
|
647
|
+
});
|
|
648
|
+
it('should return homeBar when blockOutToolBar is enabled for non-Android device', async () => {
|
|
649
|
+
const options = createDeviceBlockOutsOptions({
|
|
650
|
+
isAndroid: false,
|
|
651
|
+
screenCompareOptions: {
|
|
652
|
+
blockOutStatusBar: false,
|
|
653
|
+
blockOutToolBar: true,
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
const result = await determineDeviceBlockOuts(options);
|
|
657
|
+
expect(result).toMatchSnapshot();
|
|
658
|
+
});
|
|
659
|
+
it('should return both statusBar and homeBar when both blockouts are enabled for non-Android device', async () => {
|
|
660
|
+
const options = createDeviceBlockOutsOptions({
|
|
661
|
+
isAndroid: false,
|
|
662
|
+
screenCompareOptions: {
|
|
663
|
+
blockOutStatusBar: true,
|
|
664
|
+
blockOutToolBar: true,
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
const result = await determineDeviceBlockOuts(options);
|
|
668
|
+
expect(result).toMatchSnapshot();
|
|
669
|
+
});
|
|
670
|
+
it('should not return homeBar when blockOutToolBar is enabled for Android device', async () => {
|
|
671
|
+
const options = createDeviceBlockOutsOptions({
|
|
672
|
+
isAndroid: true,
|
|
673
|
+
screenCompareOptions: {
|
|
674
|
+
blockOutStatusBar: false,
|
|
675
|
+
blockOutToolBar: true,
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
const result = await determineDeviceBlockOuts(options);
|
|
679
|
+
expect(result).toEqual([]);
|
|
680
|
+
});
|
|
681
|
+
it('should only return statusBar when both blockouts are enabled for Android device', async () => {
|
|
682
|
+
const options = createDeviceBlockOutsOptions({
|
|
683
|
+
isAndroid: true,
|
|
684
|
+
screenCompareOptions: {
|
|
685
|
+
blockOutStatusBar: true,
|
|
686
|
+
blockOutToolBar: true,
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
const result = await determineDeviceBlockOuts(options);
|
|
690
|
+
expect(result).toMatchSnapshot();
|
|
691
|
+
});
|
|
692
|
+
it('should handle custom device rectangles', async () => {
|
|
693
|
+
const customDeviceRectangles = createDeviceRectanglesWithData({
|
|
694
|
+
statusBar: { x: 10, y: 20, width: 500, height: 60 },
|
|
695
|
+
homeBar: { x: 10, y: 900, width: 500, height: 40 }
|
|
696
|
+
});
|
|
697
|
+
const options = createDeviceBlockOutsOptions({
|
|
698
|
+
isAndroid: false,
|
|
699
|
+
screenCompareOptions: {
|
|
700
|
+
blockOutStatusBar: true,
|
|
701
|
+
blockOutToolBar: true,
|
|
702
|
+
},
|
|
703
|
+
instanceData: {
|
|
704
|
+
...createDeviceBlockOutsOptions().instanceData,
|
|
705
|
+
deviceRectangles: customDeviceRectangles
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
const result = await determineDeviceBlockOuts(options);
|
|
709
|
+
expect(result).toMatchSnapshot();
|
|
710
|
+
});
|
|
711
|
+
});
|
|
712
|
+
describe('prepareIgnoreRectangles', () => {
|
|
713
|
+
it('should return empty ignored boxes and false hasIgnoreRectangles when no inputs provided', () => {
|
|
714
|
+
const options = createPrepareIgnoreRectanglesOptions();
|
|
715
|
+
const result = prepareIgnoreRectangles(options);
|
|
716
|
+
expect(result).toEqual({
|
|
717
|
+
ignoredBoxes: [],
|
|
718
|
+
hasIgnoreRectangles: false
|
|
719
|
+
});
|
|
720
|
+
});
|
|
721
|
+
it('should handle blockOut and ignoreRegions without mobile web rectangles', () => {
|
|
722
|
+
const options = createPrepareIgnoreRectanglesOptions({
|
|
723
|
+
blockOut: [{ x: 10, y: 20, width: 100, height: 50 }],
|
|
724
|
+
ignoreRegions: [{ x: 200, y: 300, width: 150, height: 75 }],
|
|
725
|
+
devicePixelRatio: 2,
|
|
726
|
+
isAndroid: false
|
|
727
|
+
});
|
|
728
|
+
const result = prepareIgnoreRectangles(options);
|
|
729
|
+
expect(result.hasIgnoreRectangles).toBe(true);
|
|
730
|
+
expect(result.ignoredBoxes).toMatchSnapshot();
|
|
731
|
+
});
|
|
732
|
+
it('should handle Android device with different DPR calculation', () => {
|
|
733
|
+
const options = createPrepareIgnoreRectanglesOptions({
|
|
734
|
+
blockOut: [{ x: 10, y: 20, width: 100, height: 50 }],
|
|
735
|
+
ignoreRegions: [{ x: 200, y: 300, width: 150, height: 75 }],
|
|
736
|
+
devicePixelRatio: 3,
|
|
737
|
+
isAndroid: true
|
|
738
|
+
});
|
|
739
|
+
const result = prepareIgnoreRectangles(options);
|
|
740
|
+
expect(result.hasIgnoreRectangles).toBe(true);
|
|
741
|
+
expect(result.ignoredBoxes).toMatchSnapshot();
|
|
742
|
+
});
|
|
743
|
+
it('should skip mobile web rectangles when not mobile', () => {
|
|
744
|
+
const options = createPrepareIgnoreRectanglesOptions({
|
|
745
|
+
isMobile: false,
|
|
746
|
+
isNativeContext: false,
|
|
747
|
+
imageCompareOptions: {
|
|
748
|
+
blockOutSideBar: true,
|
|
749
|
+
blockOutStatusBar: true,
|
|
750
|
+
blockOutToolBar: true,
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
const result = prepareIgnoreRectangles(options);
|
|
754
|
+
expect(result).toEqual({
|
|
755
|
+
ignoredBoxes: [],
|
|
756
|
+
hasIgnoreRectangles: false
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
it('should skip mobile web rectangles when in native context', () => {
|
|
760
|
+
const options = createPrepareIgnoreRectanglesOptions({
|
|
761
|
+
isMobile: true,
|
|
762
|
+
isNativeContext: true,
|
|
763
|
+
imageCompareOptions: {
|
|
764
|
+
blockOutSideBar: true,
|
|
765
|
+
blockOutStatusBar: true,
|
|
766
|
+
blockOutToolBar: true,
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
const result = prepareIgnoreRectangles(options);
|
|
770
|
+
expect(result).toEqual({
|
|
771
|
+
ignoredBoxes: [],
|
|
772
|
+
hasIgnoreRectangles: false
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
it('should include mobile web rectangles when mobile and not native context', () => {
|
|
776
|
+
const options = createPrepareIgnoreRectanglesOptions({
|
|
777
|
+
isMobile: true,
|
|
778
|
+
isNativeContext: false,
|
|
779
|
+
isAndroid: false,
|
|
780
|
+
isAndroidNativeWebScreenshot: true,
|
|
781
|
+
isViewPortScreenshot: true,
|
|
782
|
+
devicePixelRatio: 2,
|
|
783
|
+
imageCompareOptions: {
|
|
784
|
+
blockOutSideBar: true,
|
|
785
|
+
blockOutStatusBar: true,
|
|
786
|
+
blockOutToolBar: true,
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
const result = prepareIgnoreRectangles(options);
|
|
790
|
+
expect(result.hasIgnoreRectangles).toBe(true);
|
|
791
|
+
expect(result.ignoredBoxes).toMatchSnapshot();
|
|
792
|
+
});
|
|
793
|
+
it('should filter out zero-sized rectangles from mobile web context', () => {
|
|
794
|
+
const deviceRectanglesWithZeros = createDeviceRectanglesWithData({
|
|
795
|
+
statusBarAndAddressBar: { x: 0, y: 0, width: 0, height: 0 }, // Will be filtered
|
|
796
|
+
bottomBar: { x: 0, y: 0, width: 390, height: 47 }, // Will be kept
|
|
797
|
+
});
|
|
798
|
+
const options = createPrepareIgnoreRectanglesOptions({
|
|
799
|
+
deviceRectangles: deviceRectanglesWithZeros,
|
|
800
|
+
isMobile: true,
|
|
801
|
+
isNativeContext: false,
|
|
802
|
+
isAndroid: false,
|
|
803
|
+
isAndroidNativeWebScreenshot: true,
|
|
804
|
+
isViewPortScreenshot: true,
|
|
805
|
+
devicePixelRatio: 2,
|
|
806
|
+
imageCompareOptions: {
|
|
807
|
+
blockOutStatusBar: true,
|
|
808
|
+
blockOutToolBar: true,
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
const result = prepareIgnoreRectangles(options);
|
|
812
|
+
expect(result.hasIgnoreRectangles).toBe(true);
|
|
813
|
+
expect(result.ignoredBoxes).toMatchSnapshot();
|
|
814
|
+
});
|
|
815
|
+
it('should handle empty web rectangles without filtering', () => {
|
|
816
|
+
const options = createPrepareIgnoreRectanglesOptions({
|
|
817
|
+
isMobile: true,
|
|
818
|
+
isNativeContext: false,
|
|
819
|
+
isAndroid: true,
|
|
820
|
+
isAndroidNativeWebScreenshot: false,
|
|
821
|
+
isViewPortScreenshot: true,
|
|
822
|
+
imageCompareOptions: {
|
|
823
|
+
blockOutStatusBar: false,
|
|
824
|
+
blockOutToolBar: false,
|
|
825
|
+
blockOutSideBar: false,
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
const result = prepareIgnoreRectangles(options);
|
|
829
|
+
expect(result).toEqual({
|
|
830
|
+
ignoredBoxes: [],
|
|
831
|
+
hasIgnoreRectangles: false
|
|
832
|
+
});
|
|
833
|
+
});
|
|
834
|
+
it('should combine all rectangle sources correctly', () => {
|
|
835
|
+
const options = createPrepareIgnoreRectanglesOptions({
|
|
836
|
+
blockOut: [{ x: 10, y: 20, width: 100, height: 50 }],
|
|
837
|
+
ignoreRegions: [{ x: 200, y: 300, width: 150, height: 75 }],
|
|
838
|
+
isMobile: true,
|
|
839
|
+
isNativeContext: false,
|
|
840
|
+
isAndroid: false,
|
|
841
|
+
isAndroidNativeWebScreenshot: true,
|
|
842
|
+
isViewPortScreenshot: true,
|
|
843
|
+
devicePixelRatio: 2,
|
|
844
|
+
imageCompareOptions: {
|
|
845
|
+
blockOutStatusBar: true,
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
const result = prepareIgnoreRectangles(options);
|
|
849
|
+
expect(result.hasIgnoreRectangles).toBe(true);
|
|
850
|
+
expect(result.ignoredBoxes).toMatchSnapshot();
|
|
851
|
+
});
|
|
852
|
+
});
|
|
853
|
+
});
|