@percy/appium-app
Advanced tools
Comparing version 2.0.0-beta.1 to 2.0.0-beta.2
12
index.js
@@ -22,2 +22,6 @@ const { AppiumDriver } = require('./percy/driver/driverWrapper'); | ||
customIgnoreRegions, | ||
considerRegionXpaths, | ||
considerRegionAccessibilityIds, | ||
considerRegionAppiumElements, | ||
customConsiderRegions, | ||
scrollableXpath, | ||
@@ -43,2 +47,6 @@ scrollableId | ||
customIgnoreRegions = name.customIgnoreRegions; | ||
considerRegionXpaths = name.considerRegionXpaths; | ||
considerRegionAccessibilityIds = name.considerRegionAccessibilityIds; | ||
considerRegionAppiumElements = name.considerRegionAppiumElements; | ||
customConsiderRegions = name.customConsiderRegions; | ||
scrollableXpath = name.scrollableXpath; | ||
@@ -84,2 +92,6 @@ scrollableId = name.scrollableId; | ||
customIgnoreRegions, | ||
considerRegionXpaths, | ||
considerRegionAccessibilityIds, | ||
considerRegionAppiumElements, | ||
customConsiderRegions, | ||
scrollableXpath, | ||
@@ -86,0 +98,0 @@ scrollableId |
{ | ||
"name": "@percy/appium-app", | ||
"description": "Appium client library for visual testing with Percy", | ||
"version": "2.0.0-beta.1", | ||
"version": "2.0.0-beta.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "Perceptual Inc.", |
@@ -35,5 +35,20 @@ const log = require('./util/log'); | ||
if (options && 'ignore_region_appium_elements' in options) { | ||
options.ignore_region_elements = await getElementIdFromElements(driver.type, options.ignore_region_appium_elements); | ||
delete options.ignore_region_appium_elements; | ||
/* istanbul ignore next */ | ||
if (options) { | ||
if ('ignoreRegionAppiumElements' in options) { | ||
options.ignore_region_appium_elements = options.ignoreRegionAppiumElements; | ||
delete options.ignoreRegionAppiumElements; | ||
} | ||
if ('considerRegionAppiumElements' in options) { | ||
options.consider_region_appium_elements = options.considerRegionAppiumElements; | ||
delete options.considerRegionAppiumElements; | ||
} | ||
if ('ignore_region_appium_elements' in options) { | ||
options.ignore_region_elements = await getElementIdFromElements(driver.type, options.ignore_region_appium_elements); | ||
delete options.ignore_region_appium_elements; | ||
} | ||
if ('consider_region_appium_elements' in options) { | ||
options.consider_region_elements = await getElementIdFromElements(driver.type, options.consider_region_appium_elements); | ||
delete options.consider_region_appium_elements; | ||
} | ||
} | ||
@@ -40,0 +55,0 @@ |
@@ -29,2 +29,6 @@ const { GenericProvider } = require('./genericProvider'); | ||
customIgnoreRegions, | ||
considerRegionXpaths, | ||
considerRegionAccessibilityIds, | ||
considerRegionAppiumElements, | ||
customConsiderRegions, | ||
scrollableXpath, | ||
@@ -51,2 +55,6 @@ scrollableId | ||
customIgnoreRegions, | ||
considerRegionXpaths, | ||
considerRegionAccessibilityIds, | ||
considerRegionAppiumElements, | ||
customConsiderRegions, | ||
scrollableXpath, | ||
@@ -100,7 +108,18 @@ scrollableId | ||
async getTiles(fullscreen, fullPage, screenLengths, scrollableXpath, scrollableId) { | ||
// Temporarily restrict AA optimizations only for full page | ||
if (fullPage !== true) { | ||
// Override AA optimizations | ||
if (this.isDisableRemoteUpload()) { | ||
if (fullPage === true) { | ||
log.warn('Full page screenshots are only supported when "PERCY_DISABLE_REMOTE_UPLOADS" is not set'); | ||
} | ||
return await super.getTiles(fullscreen, fullPage, screenLengths); | ||
} | ||
let screenshotType = 'fullpage'; | ||
let projectId = 'percy-prod'; | ||
if (fullPage !== true) { | ||
screenshotType = 'singlepage'; | ||
} | ||
if (this.isPercyDev()) { | ||
projectId = 'percy-dev'; | ||
} | ||
// Take screenshots via browserstack executor | ||
@@ -111,3 +130,4 @@ const response = await TimeIt.run('percyScreenshot:screenshot', async () => { | ||
percyBuildId: utils.percy?.build?.id, | ||
screenshotType: 'fullpage', | ||
screenshotType, | ||
projectId, | ||
scaleFactor: await this.metadata.scaleFactor(), | ||
@@ -118,3 +138,4 @@ options: { | ||
scollableXpath: scrollableXpath || null, | ||
scrollableId: scrollableId || null | ||
scrollableId: scrollableId || null, | ||
FORCE_FULL_PAGE: process.env.FORCE_FULL_PAGE === 'true' | ||
} | ||
@@ -126,3 +147,3 @@ }); | ||
throw new Error('Failed to get screenshots from App Automate.' + | ||
' Check dashboard for error.'); | ||
' Check dashboard for error.'); | ||
} | ||
@@ -160,2 +181,10 @@ | ||
} | ||
isDisableRemoteUpload() { | ||
return process.env.PERCY_DISABLE_REMOTE_UPLOADS === 'true'; | ||
} | ||
isPercyDev() { | ||
return process.env.PERCY_ENABLE_DEV === 'true'; | ||
} | ||
} | ||
@@ -162,0 +191,0 @@ |
@@ -49,2 +49,6 @@ const utils = require('@percy/sdk-utils'); | ||
customIgnoreRegions, | ||
considerRegionXpaths, | ||
considerRegionAccessibilityIds, | ||
considerRegionAppiumElements, | ||
customConsiderRegions, | ||
scrollableXpath, | ||
@@ -65,5 +69,8 @@ scrollableId | ||
const tiles = await this.getTiles(fullscreen, fullPage, screenLengths, scrollableXpath, scrollableId); | ||
const ignoreRegions = await this.findIgnoredRegions( | ||
const ignoreRegions = await this.findRegions( | ||
ignoreRegionXpaths, ignoreRegionAccessibilityIds, ignoreRegionAppiumElements, customIgnoreRegions | ||
); | ||
const considerRegions = await this.findRegions( | ||
considerRegionXpaths, considerRegionAccessibilityIds, considerRegionAppiumElements, customConsiderRegions | ||
); | ||
@@ -79,3 +86,8 @@ log.debug(`${name} : Tag ${JSON.stringify(ignoreRegions)}`); | ||
externalDebugUrl: await this.getDebugUrl(), | ||
ignoredElementsData: ignoreRegions, | ||
ignoredElementsData: { | ||
ignoreElementsData: ignoreRegions | ||
}, | ||
consideredElementsData: { | ||
considerElementsData: considerRegions | ||
}, | ||
environmentInfo: ENV_INFO, | ||
@@ -155,17 +167,13 @@ clientInfo: CLIENT_INFO | ||
async findIgnoredRegions(ignoreRegionXpaths, ignoreRegionAccessibilityIds, ignoreRegionAppiumElements, customIgnoreRegions) { | ||
const ignoredElementsArray = []; | ||
await this.ignoreRegionsByXpaths(ignoredElementsArray, ignoreRegionXpaths || []); | ||
await this.ignoreRegionsByIds(ignoredElementsArray, ignoreRegionAccessibilityIds || []); | ||
await this.ignoreRegionsByElement(ignoredElementsArray, ignoreRegionAppiumElements || []); | ||
await this.addCustomIgnoreRegions(ignoredElementsArray, customIgnoreRegions || []); | ||
async findRegions(xpaths, accessibilityIds, appiumElements, customLocations) { | ||
const regionsArray = []; | ||
await this.getRegionsByXpath(regionsArray, xpaths || []); | ||
await this.getRegionsByIds(regionsArray, accessibilityIds || []); | ||
await this.getRegionsByElements(regionsArray, appiumElements || []); | ||
await this.getRegionsByLocation(regionsArray, customLocations || []); | ||
const ignoredElementsLocations = { | ||
ignoreElementsData: ignoredElementsArray | ||
}; | ||
return ignoredElementsLocations; | ||
return regionsArray; | ||
} | ||
async ignoreElementObject(selector, element) { | ||
async getRegionObject(selector, element) { | ||
const scaleFactor = await this.metadata.scaleFactor(); | ||
@@ -189,3 +197,3 @@ const location = await element.getLocation(); | ||
async ignoreRegionsByXpaths(ignoredElementsArray, xpaths) { | ||
async getRegionsByXpath(elementsArray, xpaths) { | ||
for (const xpath of xpaths) { | ||
@@ -195,4 +203,4 @@ try { | ||
const selector = `xpath: ${xpath}`; | ||
const ignoredRegion = await this.ignoreElementObject(selector, element); | ||
ignoredElementsArray.push(ignoredRegion); | ||
const ignoredRegion = await this.getRegionObject(selector, element); | ||
elementsArray.push(ignoredRegion); | ||
} catch (e) { | ||
@@ -205,3 +213,3 @@ log.info(`Appium Element with xpath: ${xpath} not found. Ignoring this xpath.`); | ||
async ignoreRegionsByIds(ignoredElementsArray, ids) { | ||
async getRegionsByIds(elementsArray, ids) { | ||
for (const id of ids) { | ||
@@ -211,4 +219,4 @@ try { | ||
const selector = `id: ${id}`; | ||
const ignoredRegion = await this.ignoreElementObject(selector, element); | ||
ignoredElementsArray.push(ignoredRegion); | ||
const ignoredRegion = await this.getRegionObject(selector, element); | ||
elementsArray.push(ignoredRegion); | ||
} catch (e) { | ||
@@ -221,3 +229,3 @@ log.info(`Appium Element with id: ${id} not found. Ignoring this id.`); | ||
async ignoreRegionsByElement(ignoredElementsArray, elements) { | ||
async getRegionsByElements(elementsArray, elements) { | ||
for (let index = 0; index < elements.length; index++) { | ||
@@ -228,4 +236,4 @@ try { | ||
const ignoredRegion = await this.ignoreElementObject(selector, elements[index]); | ||
ignoredElementsArray.push(ignoredRegion); | ||
const ignoredRegion = await this.getRegionObject(selector, elements[index]); | ||
elementsArray.push(ignoredRegion); | ||
} catch (e) { | ||
@@ -238,3 +246,3 @@ log.info(`Correct Mobile Element not passed at index ${index}.`); | ||
async addCustomIgnoreRegions(ignoredElementsArray, customLocations) { | ||
async getRegionsByLocation(elementsArray, customLocations) { | ||
const { width, height } = await this.metadata.screenSize(); | ||
@@ -254,3 +262,3 @@ for (let index = 0; index < customLocations.length; index++) { | ||
}; | ||
ignoredElementsArray.push(ignoredRegion); | ||
elementsArray.push(ignoredRegion); | ||
} else { | ||
@@ -257,0 +265,0 @@ log.info(`Values passed in custom ignored region at index: ${index} is not valid`); |
@@ -1,32 +0,7 @@ | ||
class IgnoreRegion { | ||
constructor(top, bottom, left, right) { | ||
if (top < 0 || bottom < 0 || left < 0 || right < 0) { | ||
throw new Error('Only Positive integer is allowed!'); | ||
} | ||
const { Region } = require('./region'); | ||
if (top >= bottom || left >= right) { | ||
throw new Error('Invalid ignore region parameters!'); | ||
} | ||
class IgnoreRegion extends Region {} | ||
this.top = top; | ||
this.bottom = bottom; | ||
this.left = left; | ||
this.right = right; | ||
} | ||
isValid(screenHeight, screenWidth) { | ||
if ( | ||
this.top >= screenHeight || | ||
this.bottom > screenHeight || | ||
this.left >= screenWidth || | ||
this.right > screenWidth) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
module.exports = { | ||
IgnoreRegion | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45221
22
1142
7