@applitools/visual-grid-client
Advanced tools
Comparing version 4.2.6 to 4.3.1
{ | ||
"name": "@applitools/visual-grid-client", | ||
"version": "4.2.6", | ||
"version": "4.3.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/visual-grid-client.js", |
@@ -9,2 +9,3 @@ 'use strict'; | ||
const {presult} = require('@applitools/functional-commons'); | ||
const {RectangleSize} = require('@applitools/eyes.sdk.core'); | ||
@@ -19,3 +20,3 @@ function makeCheckWindow({ | ||
getAllResources, | ||
renderInfoPromise, | ||
renderInfo, | ||
logger, | ||
@@ -45,3 +46,4 @@ getCheckWindowPromises, | ||
if (getError()) { | ||
throw getError(); | ||
logger.log('aborting checkWindow synchronously'); | ||
return; | ||
} | ||
@@ -94,3 +96,3 @@ const resourceUrlsWithCss = resourceUrls.concat(extractCssResourcesFromCdt(cdt, url)); | ||
); | ||
const [{imageLocation, userAgent}] = await waitForRenderedStatus( | ||
const [{imageLocation, userAgent, deviceSize}] = await waitForRenderedStatus( | ||
[renderId], | ||
@@ -113,2 +115,5 @@ renderWrapper, | ||
wrapper.setInferredEnvironment(`useragent:${userAgent}`); | ||
if (deviceSize) { | ||
wrapper.setViewportSize(RectangleSize.fromObject(deviceSize)); | ||
} | ||
@@ -136,4 +141,2 @@ await prevJobPromise; | ||
async function startRender() { | ||
const renderInfo = await renderInfoPromise; | ||
if (getError()) { | ||
@@ -176,3 +179,2 @@ logger.log(`aborting startRender because there was an error in getRenderInfo`); | ||
async function uploadDom() { | ||
const renderInfo = await renderInfoPromise; | ||
const bundledCss = getBundledCssFromCdt(cdt, url); | ||
@@ -179,0 +181,0 @@ return await uploadResource( |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const createRGridDom = require('./createRGridDom'); | ||
const createEmulationInfo = require('./createEmulationInfo'); | ||
@@ -21,12 +22,22 @@ function createRenderRequests({ | ||
return browsers.map( | ||
({width, height, name}) => | ||
new RenderRequest( | ||
({width, height, name, deviceName, screenOrientation, deviceScaleFactor, mobile}) => { | ||
const emulationInfo = createEmulationInfo({ | ||
deviceName, | ||
screenOrientation, | ||
deviceScaleFactor, | ||
mobile, | ||
width, | ||
height, | ||
}); | ||
return new RenderRequest( | ||
renderInfo.getResultsUrl(), | ||
url, | ||
rGridDom, | ||
RenderInfo.fromObject({width, height, sizeMode, selector, region}), | ||
RenderInfo.fromObject({width, height, sizeMode, selector, region, emulationInfo}), | ||
'Linux', | ||
name, | ||
scriptHooks, | ||
), | ||
); | ||
}, | ||
); | ||
@@ -33,0 +44,0 @@ } |
'use strict'; | ||
const {EyesBase, RectangleSize, NullRegionProvider} = require('@applitools/eyes.sdk.core'); | ||
const {EyesBase, NullRegionProvider} = require('@applitools/eyes.sdk.core'); | ||
@@ -16,3 +16,5 @@ const VERSION = require('../../package.json').version; | ||
this._viewportSizeHandler.set(new RectangleSize(viewportSize)); // Not doing this causes an exception at a later | ||
if (viewportSize) { | ||
this.setViewportSize(viewportSize); | ||
} | ||
} | ||
@@ -89,2 +91,6 @@ | ||
async setViewportSize(viewportSize) { | ||
this._viewportSizeHandler.set(viewportSize); | ||
} | ||
async getTitle() { | ||
@@ -91,0 +97,0 @@ return await 'some title'; // TODO what should this be? is it connected with the tag in `checkWindow` somehow? |
'use strict'; | ||
const makeCheckWindow = require('./checkWindow'); | ||
const makeCloseEyes = require('./closeEyes'); | ||
const {initWrappers, configureWrappers, openWrappers, apiKeyFailMsg} = require('./wrapperUtils'); | ||
const { | ||
initWrappers, | ||
configureWrappers, | ||
openWrappers, | ||
apiKeyFailMsg, | ||
authorizationErrMsg, | ||
} = require('./wrapperUtils'); | ||
const createLogger = require('./createLogger'); | ||
function makeOpenEyes({ | ||
getError, | ||
setError, | ||
extractCssResourcesFromCdt, | ||
@@ -16,4 +20,4 @@ getBundledCssFromCdt, | ||
renderThroat, | ||
renderInfoPromise, | ||
renderWrapper, | ||
getLazyRenderInfo, | ||
setLazyRenderInfo, | ||
uploadResource, | ||
@@ -49,6 +53,3 @@ }) { | ||
}) { | ||
if (getError()) { | ||
throw getError(); | ||
} | ||
let error; | ||
const logger = createLogger(showLogs); | ||
@@ -99,4 +100,31 @@ | ||
await openWrappers({wrappers, browsers, appName, testName}); | ||
const renderWrapper = wrappers[0]; | ||
const renderInfoPromise = getLazyRenderInfo() | ||
? Promise.resolve(getLazyRenderInfo()) | ||
: renderWrapper | ||
.getRenderInfo() | ||
.then(_renderInfo => { | ||
setLazyRenderInfo(_renderInfo); | ||
renderWrapper.setRenderingInfo(_renderInfo); | ||
return _renderInfo; | ||
}) | ||
.catch(err => { | ||
if (err.response && err.response.status === 401) { | ||
err = new Error(authorizationErrMsg); | ||
} | ||
setLazyRenderInfo(err); | ||
return err; | ||
}); | ||
const [renderInfo] = await Promise.all([ | ||
renderInfoPromise, | ||
openWrappers({wrappers, browsers, appName, testName}), | ||
]); | ||
if (renderInfo instanceof Error) { | ||
throw renderInfo; | ||
} | ||
const checkWindow = makeCheckWindow({ | ||
@@ -110,3 +138,3 @@ getError, | ||
getAllResources, | ||
renderInfoPromise, | ||
renderInfo, | ||
logger, | ||
@@ -131,2 +159,11 @@ getCheckWindowPromises, | ||
function setError(err) { | ||
logger.log('error set in test', testName, err); | ||
error = err; | ||
} | ||
function getError() { | ||
return error; | ||
} | ||
function getCheckWindowPromises() { | ||
@@ -133,0 +170,0 @@ return checkWindowPromises; |
@@ -18,3 +18,2 @@ 'use strict'; | ||
const makeUploadResource = require('./uploadResource'); | ||
const EyesWrapper = require('./EyesWrapper'); | ||
@@ -30,3 +29,2 @@ function makeRenderingGridClient({ | ||
renderConcurrencyFactor = 5, | ||
wrapper, | ||
}) { | ||
@@ -39,5 +37,4 @@ const openEyesConcurrency = Number(getConfig({concurrency}).concurrency); | ||
let lazyRenderInfo; | ||
const renderThroat = throatPkg(openEyesConcurrency * renderConcurrencyFactor); | ||
let error; | ||
const logger = createLogger(showLogs); | ||
@@ -65,22 +62,3 @@ const resourceCache = createResourceCache(); | ||
wrapper = | ||
wrapper || new EyesWrapper({apiKey: getConfig().apiKey, logHandler: logger.getLogHandler()}); // TODO when organizing config, make this a default value in the function parameters | ||
const renderInfoPromise = wrapper | ||
.getRenderInfo() | ||
.then(renderInfo => { | ||
wrapper.setRenderingInfo(renderInfo); | ||
return renderInfo; | ||
}) | ||
.catch(err => { | ||
if (err.response && err.response.status === 401) { | ||
setError(new Error('Unauthorized access to Eyes server. Please check your API key.')); | ||
} else { | ||
setError(err); | ||
} | ||
}); | ||
const openEyes = makeOpenEyes({ | ||
setError, | ||
getError, | ||
extractCssResourcesFromCdt, | ||
@@ -92,4 +70,4 @@ getBundledCssFromCdt, | ||
renderThroat, | ||
renderInfoPromise, | ||
renderWrapper: wrapper, | ||
getLazyRenderInfo, | ||
setLazyRenderInfo, | ||
uploadResource, | ||
@@ -101,3 +79,3 @@ }); | ||
); | ||
const waitForTestResults = makeWaitForTestResults({logger, getError}); | ||
const waitForTestResults = makeWaitForTestResults({logger}); | ||
@@ -111,17 +89,15 @@ const defaultBatch = getBatch(getInitialConfig()); | ||
waitForTestResults, | ||
getError, | ||
}; | ||
function setError(err) { | ||
logger.log('error set', err); | ||
error = err; | ||
function openEyesWithConfig(args) { | ||
const config = getConfig(args); | ||
return openEyes(config); | ||
} | ||
function getError() { | ||
return error; | ||
function getLazyRenderInfo() { | ||
return lazyRenderInfo; | ||
} | ||
function openEyesWithConfig(args) { | ||
const config = getConfig(args); | ||
return openEyes(config); | ||
function setLazyRenderInfo(renderInfo) { | ||
lazyRenderInfo = renderInfo; | ||
} | ||
@@ -128,0 +104,0 @@ } |
@@ -21,3 +21,3 @@ 'use strict'; | ||
logger.log('resource uploaded to ', location); | ||
logger.log('resource uploaded to', location); | ||
@@ -24,0 +24,0 @@ return location; |
'use strict'; | ||
const {presult} = require('@applitools/functional-commons'); | ||
function makeWaitForTestResults({logger, getError}) { | ||
function makeWaitForTestResults({logger}) { | ||
return async function waitForTestResults(closePromises) { | ||
let error; | ||
if ((error = getError())) { | ||
logger.log('waitForTestResults() aborting when started'); | ||
throw error; | ||
} | ||
logger.log(`waitForTestResults: waiting for ${closePromises.length} tests`); | ||
const closeResults = await Promise.all(closePromises.map(presult)); | ||
if ((error = getError())) { | ||
logger.log('waitForTestResults() aborting after closes'); | ||
throw error; | ||
} | ||
const closeErrors = closeResults.filter(result => result[0]); | ||
if (closeErrors.length) { | ||
throw closeErrors[0][0]; | ||
} | ||
return closeResults.map(result => result[1]); | ||
return closeResults | ||
.map(result => result[0] || result[1]) | ||
.map(arr => (arr.length === 1 ? arr[0] : arr)); | ||
}; | ||
@@ -26,0 +12,0 @@ } |
'use strict'; | ||
const EyesWrapper = require('./EyesWrapper'); | ||
const {BatchInfo} = require('@applitools/eyes.sdk.core'); | ||
const {BatchInfo, RectangleSize} = require('@applitools/eyes.sdk.core'); | ||
@@ -73,3 +73,8 @@ function initWrappers({count, apiKey, logHandler}) { | ||
function openWrappers({wrappers, browsers, appName, testName}) { | ||
return Promise.all(wrappers.map((wrapper, i) => wrapper.open(appName, testName, browsers[i]))); | ||
return Promise.all( | ||
wrappers.map((wrapper, i) => { | ||
const viewportSize = browsers[i].width && new RectangleSize(browsers[i]); | ||
return wrapper.open(appName, testName, viewportSize); | ||
}), | ||
); | ||
} | ||
@@ -83,2 +88,4 @@ | ||
const authorizationErrMsg = 'Unauthorized access to Eyes server. Please check your API key.'; | ||
module.exports = { | ||
@@ -90,2 +97,3 @@ initWrappers, | ||
propertiesFailMsg, | ||
authorizationErrMsg, | ||
}; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const {initConfig} = require('./sdk/config'); | ||
const {DiffsFoundError} = require('@applitools/eyes.sdk.core'); | ||
@@ -11,2 +12,3 @@ module.exports = { | ||
initConfig, | ||
DiffsFoundError, | ||
}; |
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
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
63244
41
1641