@applitools/eyes.cypress
Advanced tools
Comparing version 3.3.20 to 3.3.21
{ | ||
"name": "@applitools/eyes.cypress", | ||
"version": "3.3.20", | ||
"version": "3.3.21", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,11 +6,10 @@ /* global Cypress,cy,window,before,after */ | ||
const processPage = require('@applitools/dom-capture/src/browser/visual-grid/processPage'); | ||
const send = makeSend(Cypress.config('eyesPort'), cy.request); | ||
const send = makeSend(Cypress.config('eyesPort'), window.fetch); | ||
const makeSendRequest = require('./sendRequest'); | ||
const makeEyesCheckWindow = require('./eyesCheckWindow'); | ||
const sendRequest = makeSendRequest(send); | ||
const Blob = window.frameElement.ownerDocument.defaultView.Blob; // yucky! cypress uses socket.io to communicate between browser and node. In order to encode the data in binary format, socket.io checks for binary values. But `value instanceof Blob` is falsy since Blob from the cypress runner window is not the Blob from the command's window. So using the Blob from cypress runner window here. | ||
const eyesCheckWindow = makeEyesCheckWindow({sendRequest, processPage, Blob}); | ||
const eyesCheckWindow = makeEyesCheckWindow({sendRequest, processPage}); | ||
if (!Cypress.config('eyesIsDisabled')) { | ||
const batchEnd = poll(function({timeout}) { | ||
const batchEnd = poll(({timeout}) => { | ||
return sendRequest({command: 'batchEnd', data: {timeout}}); | ||
@@ -20,7 +19,7 @@ }); | ||
before(() => { | ||
sendRequest({command: 'batchStart'}); | ||
cy.then({timeout: 86400000}, () => sendRequest({command: 'batchStart'})); | ||
}); | ||
after(() => { | ||
return batchEnd({timeout: Cypress.config('eyesTimeout')}); | ||
cy.then({timeout: 86400000}, () => batchEnd({timeout: Cypress.config('eyesTimeout')})); | ||
}); | ||
@@ -27,0 +26,0 @@ } |
'use strict'; | ||
const getAllBlobs = require('./getAllBlobs'); | ||
function makeEyesCheckWindow({sendRequest, processPage, Blob}) { | ||
function makeEyesCheckWindow({sendRequest, processPage}) { | ||
return function eyesCheckWindow(doc, args) { | ||
@@ -46,8 +46,8 @@ let tag, sizeMode, selector, region, scriptHooks, ignore, floating, sendDom; | ||
function putResource({url, type, value}) { | ||
function putResource({url, value}) { | ||
return sendRequest({ | ||
command: `resource/${encodeURIComponent(url)}`, | ||
data: new Blob([value]), | ||
data: value, | ||
method: 'PUT', | ||
headers: {'Content-Type': type}, | ||
headers: {'Content-Type': 'application/octet-stream'}, | ||
}); | ||
@@ -54,0 +54,0 @@ } |
'use strict'; | ||
function makeSend(port, fetch) { | ||
return function send({command, data, method = 'POST', headers}) { | ||
return fetch({ | ||
url: `http://localhost:${port}/eyes/${command}`, | ||
return function send({ | ||
command, | ||
data, | ||
method = 'POST', | ||
headers = {'Content-Type': 'application/json'}, | ||
}) { | ||
return fetch(`https://localhost:${port}/eyes/${command}`, { | ||
method, | ||
body: data, | ||
log: false, | ||
body: headers['Content-Type'] === 'application/json' ? JSON.stringify(data) : data, | ||
headers, | ||
@@ -11,0 +14,0 @@ }); |
@@ -5,8 +5,10 @@ 'use strict'; | ||
return function sendRequest(args) { | ||
return send(args).then(resp => { | ||
if (!resp.body.success) { | ||
throw new Error(resp.body.error); | ||
} | ||
return resp.body.result; | ||
}); | ||
return send(args) | ||
.then(resp => resp.json()) | ||
.then(body => { | ||
if (!body.success) { | ||
throw new Error(body.error); | ||
} | ||
return body.result; | ||
}); | ||
}; | ||
@@ -13,0 +15,0 @@ } |
@@ -17,3 +17,3 @@ 'use strict'; | ||
if (!(req.body instanceof Buffer)) throw new Error(`could not process resource ${id}`); // body-parser returned non-buffer body: https://github.com/expressjs/body-parser/blob/bd386d3a7d540bac90bbdaff88f653414f6647fc/lib/types/raw.js#L62 | ||
const buffer = Buffer.from(JSON.parse(req.body).data); | ||
const buffer = req.body; | ||
logger.log('[server] PUT resource:', id, buffer.length); | ||
@@ -20,0 +20,0 @@ handlers.putResource(id, buffer); |
'use strict'; | ||
const https = require('https'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
@@ -7,3 +10,10 @@ function makeStartServer({logger, app}) { | ||
logger.log(`starting plugin server`); | ||
const server = app.listen(0, err => { | ||
const server = https.createServer( | ||
{ | ||
key: fs.readFileSync(path.resolve(__dirname, '../pem/server.key')), | ||
cert: fs.readFileSync(path.resolve(__dirname, '../pem/server.cert')), | ||
}, | ||
app, | ||
); | ||
server.listen(0, err => { | ||
if (err) { | ||
@@ -10,0 +20,0 @@ logger.log('error starting plugin server', err); |
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
Network access
Supply chain riskThis module accesses the network.
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
134090
36
738
4
2