@percy/core 1.30.0 → 1.30.2-alpha.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/dist/discovery.js +5 -6
- package/dist/findRevision.sh +37 -0
- package/dist/network.js +15 -7
- package/dist/page.js +2 -2
- package/dist/percy.js +11 -2
- package/dist/snapshot.js +2 -2
- package/package.json +8 -8
- package/test/helpers/server.js +1 -1
package/dist/discovery.js
CHANGED
|
@@ -4,7 +4,6 @@ import Page from './page.js';
|
|
|
4
4
|
import { normalizeURL, hostnameMatches, createResource, createRootResource, createPercyCSSResource, createLogResource, yieldAll, snapshotLogName, waitForTimeout, withRetries, waitForSelectorInsideBrowser } from './utils.js';
|
|
5
5
|
import { sha256hash } from '@percy/client/utils';
|
|
6
6
|
import Pako from 'pako';
|
|
7
|
-
import TimeIt from './timing.js';
|
|
8
7
|
|
|
9
8
|
// Logs verbose debug logs detailing various snapshot options.
|
|
10
9
|
function debugSnapshotOptions(snapshot) {
|
|
@@ -76,7 +75,8 @@ function parseCookies(cookies) {
|
|
|
76
75
|
return cookies.map(c => ({
|
|
77
76
|
name: c.name,
|
|
78
77
|
value: c.value,
|
|
79
|
-
secure: c.secure
|
|
78
|
+
secure: c.secure,
|
|
79
|
+
domain: c.domain
|
|
80
80
|
}));
|
|
81
81
|
}
|
|
82
82
|
if (!(typeof cookies === 'string' && cookies !== '')) return null;
|
|
@@ -244,7 +244,7 @@ async function* captureSnapshotResources(page, snapshot, options) {
|
|
|
244
244
|
mobile,
|
|
245
245
|
captureForDevices
|
|
246
246
|
} = options;
|
|
247
|
-
let cookies = (
|
|
247
|
+
let cookies = ((_snapshot$domSnapshot = snapshot.domSnapshot) === null || _snapshot$domSnapshot === void 0 ? void 0 : _snapshot$domSnapshot.cookies) || ((_snapshot$domSnapshot2 = snapshot.domSnapshot) === null || _snapshot$domSnapshot2 === void 0 || (_snapshot$domSnapshot2 = _snapshot$domSnapshot2[0]) === null || _snapshot$domSnapshot2 === void 0 ? void 0 : _snapshot$domSnapshot2.cookies);
|
|
248
248
|
cookies = parseCookies(cookies);
|
|
249
249
|
|
|
250
250
|
// iterate over device to trigger reqeusts and capture other dpr width
|
|
@@ -419,7 +419,6 @@ export function createDiscoveryQueue(percy) {
|
|
|
419
419
|
concurrency
|
|
420
420
|
} = percy.config.discovery;
|
|
421
421
|
let queue = new Queue('discovery');
|
|
422
|
-
let timeit = new TimeIt();
|
|
423
422
|
let cache;
|
|
424
423
|
return queue.set({
|
|
425
424
|
concurrency
|
|
@@ -453,13 +452,13 @@ export function createDiscoveryQueue(percy) {
|
|
|
453
452
|
})
|
|
454
453
|
// discovery resources for snapshots and call the callback for each discovered snapshot
|
|
455
454
|
.handle('task', async function* (snapshot, callback) {
|
|
456
|
-
await
|
|
455
|
+
await logger.measure('asset-discovery', snapshot.name, snapshot.meta, async () => {
|
|
457
456
|
percy.log.debug(`Discovering resources: ${snapshot.name}`, snapshot.meta);
|
|
458
457
|
|
|
459
458
|
// expectation explained in tests
|
|
460
459
|
/* istanbul ignore next: tested, but coverage is stripped */
|
|
461
460
|
let assetDiscoveryPageEnableJS = snapshot.cliEnableJavaScript && !snapshot.domSnapshot || (snapshot.enableJavaScript ?? !snapshot.domSnapshot);
|
|
462
|
-
percy.log.debug(`Asset discovery Browser Page enable JS: ${assetDiscoveryPageEnableJS}
|
|
461
|
+
percy.log.debug(`Asset discovery Browser Page enable JS: ${assetDiscoveryPageEnableJS}`, snapshot.meta);
|
|
463
462
|
await withRetries(async function* () {
|
|
464
463
|
// create a new browser page
|
|
465
464
|
let page = yield percy.browser.page({
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
function download_url {
|
|
4
|
+
if [[ "$OS" == "Linux" ]]; then
|
|
5
|
+
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${1}%2Fchrome-linux.zip?alt=media"
|
|
6
|
+
elif [[ "$OS" == "Mac" ]] || [[ "$OS" == "Mac_Arm" ]]; then
|
|
7
|
+
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/$OS%2F${1}%2Fchrome-mac.zip?alt=media"
|
|
8
|
+
elif [[ "$OS" == "Win" ]] || [[ "$OS" == "Win_x64" ]]; then
|
|
9
|
+
echo "https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/$OS%2F${1}%2Fchrome-win.zip?alt=media"
|
|
10
|
+
fi
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function get_closest_rev {
|
|
14
|
+
while true; do
|
|
15
|
+
curl -I 2>/dev/null `download_url $REVISION` | head -1 | grep 404 >/dev/null
|
|
16
|
+
if (($? == 1)); then
|
|
17
|
+
break
|
|
18
|
+
fi
|
|
19
|
+
REVISION=$(($REVISION-1))
|
|
20
|
+
done
|
|
21
|
+
echo $REVISION
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if (($# < 1)); then
|
|
26
|
+
printf "usage: \n"
|
|
27
|
+
printf " ./get_chromuim [-r] rev - will get chromium by revision\n"
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
export REVISION=$1
|
|
32
|
+
|
|
33
|
+
for os in "Linux" "Mac" "Mac_Arm" "Win" "Win_x64";
|
|
34
|
+
do
|
|
35
|
+
export OS=$os
|
|
36
|
+
echo "$OS" `get_closest_rev`
|
|
37
|
+
done
|
package/dist/network.js
CHANGED
|
@@ -46,7 +46,7 @@ export class Network {
|
|
|
46
46
|
session.on('Network.requestWillBeSent', this._handleRequestWillBeSent);
|
|
47
47
|
session.on('Network.responseReceived', this._handleResponseReceived.bind(this, session));
|
|
48
48
|
session.on('Network.eventSourceMessageReceived', this._handleEventSourceMessageReceived);
|
|
49
|
-
session.on('Network.loadingFinished', this._handleLoadingFinished);
|
|
49
|
+
session.on('Network.loadingFinished', this._handleLoadingFinished.bind(this, session));
|
|
50
50
|
session.on('Network.loadingFailed', this._handleLoadingFailed);
|
|
51
51
|
let commands = [session.send('Network.enable'), session.send('Network.setBypassServiceWorker', {
|
|
52
52
|
bypass: !this.captureMockedServiceWorker
|
|
@@ -309,7 +309,7 @@ export class Network {
|
|
|
309
309
|
|
|
310
310
|
// Called when a request has finished loading which triggers the this.onrequestfinished
|
|
311
311
|
// callback. The request should have an associated response and be finished with any redirects.
|
|
312
|
-
_handleLoadingFinished = async event => {
|
|
312
|
+
_handleLoadingFinished = async (session, event) => {
|
|
313
313
|
let {
|
|
314
314
|
requestId
|
|
315
315
|
} = event;
|
|
@@ -318,7 +318,7 @@ export class Network {
|
|
|
318
318
|
let request = this.#requests.get(requestId);
|
|
319
319
|
/* istanbul ignore if: race condition paranioa */
|
|
320
320
|
if (!request) return;
|
|
321
|
-
await saveResponseResource(this, request);
|
|
321
|
+
await saveResponseResource(this, request, session);
|
|
322
322
|
this._forgetRequest(request);
|
|
323
323
|
};
|
|
324
324
|
|
|
@@ -441,10 +441,16 @@ async function sendResponseResource(network, request, session) {
|
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
// Make a new request with Node based on a network request
|
|
444
|
-
function makeDirectRequest(network, request) {
|
|
444
|
+
async function makeDirectRequest(network, request, session) {
|
|
445
445
|
var _network$authorizatio;
|
|
446
|
+
const {
|
|
447
|
+
cookies
|
|
448
|
+
} = await session.send('Network.getCookies', {
|
|
449
|
+
urls: [request.url]
|
|
450
|
+
});
|
|
446
451
|
let headers = {
|
|
447
|
-
...request.headers
|
|
452
|
+
...request.headers,
|
|
453
|
+
cookie: cookies.map(cookie => `${cookie.name}=${cookie.value}`).join('; ')
|
|
448
454
|
};
|
|
449
455
|
if ((_network$authorizatio = network.authorization) !== null && _network$authorizatio !== void 0 && _network$authorizatio.username) {
|
|
450
456
|
// include basic authorization username and password
|
|
@@ -462,7 +468,7 @@ function makeDirectRequest(network, request) {
|
|
|
462
468
|
}
|
|
463
469
|
|
|
464
470
|
// Save a resource from a request, skipping it if specific paramters are not met
|
|
465
|
-
async function saveResponseResource(network, request) {
|
|
471
|
+
async function saveResponseResource(network, request, session) {
|
|
466
472
|
let {
|
|
467
473
|
disableCache,
|
|
468
474
|
allowedHostnames,
|
|
@@ -514,7 +520,8 @@ async function saveResponseResource(network, request) {
|
|
|
514
520
|
// so request them directly.
|
|
515
521
|
if (mimeType !== null && mimeType !== void 0 && mimeType.includes('font') || detectedMime && detectedMime.includes('font')) {
|
|
516
522
|
log.debug('- Requesting asset directly', meta);
|
|
517
|
-
body = await makeDirectRequest(network, request);
|
|
523
|
+
body = await makeDirectRequest(network, request, session);
|
|
524
|
+
log.debug('- Got direct response', meta);
|
|
518
525
|
}
|
|
519
526
|
resource = createResource(url, body, mimeType, {
|
|
520
527
|
status: response.status,
|
|
@@ -533,6 +540,7 @@ async function saveResponseResource(network, request) {
|
|
|
533
540
|
}
|
|
534
541
|
}
|
|
535
542
|
if (resource && !resource.root) {
|
|
543
|
+
log.debug('- Saving resource', meta);
|
|
536
544
|
network.intercept.saveResource(resource);
|
|
537
545
|
}
|
|
538
546
|
}
|
package/dist/page.js
CHANGED
|
@@ -17,7 +17,7 @@ export class Page {
|
|
|
17
17
|
session.on('Runtime.executionContextDestroyed', this._handleExecutionContextDestroyed);
|
|
18
18
|
session.on('Runtime.executionContextsCleared', this._handleExecutionContextsCleared);
|
|
19
19
|
session.send('Runtime.enable').catch(session._handleClosedError);
|
|
20
|
-
this.log.debug('Page created');
|
|
20
|
+
this.log.debug('Page created', this.meta);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Close the page
|
|
@@ -33,7 +33,7 @@ export class Page {
|
|
|
33
33
|
deviceScaleFactor = 1,
|
|
34
34
|
mobile = false
|
|
35
35
|
}) {
|
|
36
|
-
this.log.debug(`Resize page to ${width}x${height} @${deviceScaleFactor}x
|
|
36
|
+
this.log.debug(`Resize page to ${width}x${height} @${deviceScaleFactor}x`, this.meta);
|
|
37
37
|
await this.session.send('Emulation.setDeviceMetricsOverride', {
|
|
38
38
|
deviceScaleFactor,
|
|
39
39
|
mobile,
|
package/dist/percy.js
CHANGED
|
@@ -383,12 +383,12 @@ export class Percy {
|
|
|
383
383
|
|
|
384
384
|
// Uploads one or more snapshots directly to the current Percy build
|
|
385
385
|
upload(options, callback = null, screenshotFlow = null) {
|
|
386
|
+
var _options$tag2;
|
|
386
387
|
if (this.readyState !== 1) {
|
|
387
388
|
throw new Error('Not running');
|
|
388
389
|
} else if (Array.isArray(options)) {
|
|
389
390
|
return yieldAll(options.map(o => this.yield.upload(o)));
|
|
390
391
|
}
|
|
391
|
-
|
|
392
392
|
// validate comparison uploads and warn about any errors
|
|
393
393
|
|
|
394
394
|
// we are having two similar attrs in options: tags & tag
|
|
@@ -416,6 +416,15 @@ export class Percy {
|
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
+
// set meta for logging
|
|
420
|
+
options.meta = {
|
|
421
|
+
snapshot: {
|
|
422
|
+
name: options.name,
|
|
423
|
+
testCase: options.testCase,
|
|
424
|
+
tag: (_options$tag2 = options.tag) === null || _options$tag2 === void 0 ? void 0 : _options$tag2.name
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
|
|
419
428
|
// add client & environment info
|
|
420
429
|
this.client.addClientInfo(options.clientInfo);
|
|
421
430
|
this.client.addEnvironmentInfo(options.environmentInfo);
|
|
@@ -555,7 +564,7 @@ function _displaySuggestionLogs(suggestions, options = {}) {
|
|
|
555
564
|
const suggestion = item === null || item === void 0 ? void 0 : item.suggestion;
|
|
556
565
|
const referenceDocLinks = item === null || item === void 0 ? void 0 : item.reference_doc_link;
|
|
557
566
|
if (options !== null && options !== void 0 && options.snapshotLevel) {
|
|
558
|
-
this.log.warn(`Detected
|
|
567
|
+
this.log.warn(`Detected error for Snapshot: ${options === null || options === void 0 ? void 0 : options.snapshotName}`);
|
|
559
568
|
} else {
|
|
560
569
|
this.log.warn('Detected error for percy build');
|
|
561
570
|
}
|
package/dist/snapshot.js
CHANGED
|
@@ -465,7 +465,7 @@ export function createSnapshotsQueue(percy) {
|
|
|
465
465
|
// Pushing to syncQueue, that will check for
|
|
466
466
|
// snapshot processing status, and will resolve once done
|
|
467
467
|
if (snapshot.sync) {
|
|
468
|
-
percy.log.info(`Waiting for snapshot '${name}' to be completed
|
|
468
|
+
percy.log.info(`Waiting for snapshot '${name}' to be completed`, meta);
|
|
469
469
|
const data = new JobData(response.data.id, null, snapshot.resolve, snapshot.reject);
|
|
470
470
|
percy.syncQueue.push(data);
|
|
471
471
|
}
|
|
@@ -501,7 +501,7 @@ export function createSnapshotsQueue(percy) {
|
|
|
501
501
|
if (duplicate) {
|
|
502
502
|
if (process.env.PERCY_IGNORE_DUPLICATES !== 'true') {
|
|
503
503
|
let errMsg = `Ignored duplicate snapshot. ${errors[1].detail}`;
|
|
504
|
-
percy.log.warn(errMsg);
|
|
504
|
+
percy.log.warn(errMsg, meta);
|
|
505
505
|
await percy.suggestionsForFix(errMsg, {
|
|
506
506
|
snapshotLevel: true,
|
|
507
507
|
snapshotName: name
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.30.0",
|
|
3
|
+
"version": "1.30.2-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
|
-
"tag": "
|
|
12
|
+
"tag": "alpha"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14"
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"test:types": "tsd"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@percy/client": "1.30.0",
|
|
47
|
-
"@percy/config": "1.30.0",
|
|
48
|
-
"@percy/dom": "1.30.0",
|
|
49
|
-
"@percy/logger": "1.30.0",
|
|
50
|
-
"@percy/webdriver-utils": "1.30.0",
|
|
46
|
+
"@percy/client": "1.30.2-alpha.0",
|
|
47
|
+
"@percy/config": "1.30.2-alpha.0",
|
|
48
|
+
"@percy/dom": "1.30.2-alpha.0",
|
|
49
|
+
"@percy/logger": "1.30.2-alpha.0",
|
|
50
|
+
"@percy/webdriver-utils": "1.30.2-alpha.0",
|
|
51
51
|
"content-disposition": "^0.5.4",
|
|
52
52
|
"cross-spawn": "^7.0.3",
|
|
53
53
|
"extract-zip": "^2.0.1",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"ws": "^8.17.1",
|
|
61
61
|
"yaml": "^2.4.1"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "5cf337161a28fe90a670b009f2d2149663734047"
|
|
64
64
|
}
|
package/test/helpers/server.js
CHANGED
|
@@ -21,7 +21,7 @@ export function createTestServer({ default: defaultReply, ...replies }, port = 8
|
|
|
21
21
|
server.route(async (req, res, next) => {
|
|
22
22
|
let pathname = req.url.pathname;
|
|
23
23
|
if (req.url.search) pathname += req.url.search;
|
|
24
|
-
server.requests.push(req.body ? [pathname, req.body] : [pathname]);
|
|
24
|
+
server.requests.push(req.body ? [pathname, req.body, req.headers] : [pathname, req.headers]);
|
|
25
25
|
let reply = replies[pathname] || defaultReply;
|
|
26
26
|
return reply ? await reply(req, res) : next();
|
|
27
27
|
});
|