@percy/core 1.27.1 → 1.27.2

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/api.js CHANGED
@@ -138,9 +138,10 @@ export function createPercyServer(percy, port) {
138
138
  .route('post', '/percy/flush', async (req, res) => res.json(200, {
139
139
  success: await percy.flush(req.body).then(() => true)
140
140
  })).route('post', '/percy/automateScreenshot', async (req, res) => {
141
- req = percyAutomateRequestHandler(req, percy.build);
141
+ percyAutomateRequestHandler(req, percy);
142
+ percy.upload(await WebdriverUtils.automateScreenshot(req.body));
142
143
  res.json(200, {
143
- success: await percy.upload(await new WebdriverUtils(req.body).automateScreenshot()).then(() => true)
144
+ success: true
144
145
  });
145
146
  })
146
147
  // stops percy at the end of the current event loop
package/dist/config.js CHANGED
@@ -49,6 +49,48 @@ export const configSchema = {
49
49
  },
50
50
  scope: {
51
51
  type: 'string'
52
+ },
53
+ freezeAnimation: {
54
+ type: 'boolean',
55
+ onlyAutomate: true
56
+ },
57
+ ignoreRegions: {
58
+ type: 'object',
59
+ additionalProperties: false,
60
+ onlyAutomate: true,
61
+ properties: {
62
+ ignoreRegionSelectors: {
63
+ type: 'array',
64
+ items: {
65
+ type: 'string'
66
+ }
67
+ },
68
+ ignoreRegionXpaths: {
69
+ type: 'array',
70
+ items: {
71
+ type: 'string'
72
+ }
73
+ }
74
+ }
75
+ },
76
+ considerRegions: {
77
+ type: 'object',
78
+ additionalProperties: false,
79
+ onlyAutomate: true,
80
+ properties: {
81
+ considerRegionSelectors: {
82
+ type: 'array',
83
+ items: {
84
+ type: 'string'
85
+ }
86
+ },
87
+ considerRegionXPaths: {
88
+ type: 'array',
89
+ items: {
90
+ type: 'string'
91
+ }
92
+ }
93
+ }
52
94
  }
53
95
  }
54
96
  },
package/dist/utils.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import EventEmitter from 'events';
2
2
  import { sha256hash } from '@percy/client/utils';
3
+ import { camelcase, merge } from '@percy/config/utils';
3
4
  export { request, getPackageJSON, hostnameMatches } from '@percy/client/utils';
4
5
  export { Server, createServer } from './server.js';
5
6
 
@@ -19,19 +20,37 @@ export function normalizeURL(url) {
19
20
  return `${protocol}//${host}${pathname}${search}`;
20
21
  }
21
22
 
23
+ /* istanbul ignore next: tested, but coverage is stripped */
22
24
  // Returns the body for automateScreenshot in structure
23
- export function percyAutomateRequestHandler(req, buildInfo) {
25
+ export function percyAutomateRequestHandler(req, percy) {
26
+ var _percy$config$snapsho, _percy$config$snapsho2, _percy$config$snapsho3, _percy$config$snapsho4;
24
27
  if (req.body.client_info) {
25
28
  req.body.clientInfo = req.body.client_info;
26
29
  }
27
30
  if (req.body.environment_info) {
28
31
  req.body.environmentInfo = req.body.environment_info;
29
32
  }
30
- if (!req.body.options) {
31
- req.body.options = {};
32
- }
33
- req.body.buildInfo = buildInfo;
34
- return req;
33
+
34
+ // combines array and overrides global config with per-screenshot config
35
+ let camelCasedOptions = {};
36
+ Object.entries(req.body.options || {}).forEach(([key, value]) => {
37
+ camelCasedOptions[camelcase(key)] = value;
38
+ });
39
+ req.body.options = merge([{
40
+ percyCSS: percy.config.snapshot.percyCSS,
41
+ freezeAnimation: percy.config.snapshot.freezeAnimation,
42
+ ignoreRegionSelectors: (_percy$config$snapsho = percy.config.snapshot.ignoreRegions) === null || _percy$config$snapsho === void 0 ? void 0 : _percy$config$snapsho.ignoreRegionSelectors,
43
+ ignoreRegionXpaths: (_percy$config$snapsho2 = percy.config.snapshot.ignoreRegions) === null || _percy$config$snapsho2 === void 0 ? void 0 : _percy$config$snapsho2.ignoreRegionXpaths,
44
+ considerRegionSelectors: (_percy$config$snapsho3 = percy.config.snapshot.considerRegions) === null || _percy$config$snapsho3 === void 0 ? void 0 : _percy$config$snapsho3.considerRegionSelectors,
45
+ considerRegionXPaths: (_percy$config$snapsho4 = percy.config.snapshot.considerRegions) === null || _percy$config$snapsho4 === void 0 ? void 0 : _percy$config$snapsho4.considerRegionXPaths
46
+ }, camelCasedOptions], (path, prev, next) => {
47
+ switch (path.map(k => k.toString()).join('.')) {
48
+ case 'percyCSS':
49
+ // concatenate percy css
50
+ return [path, [prev, next].filter(Boolean).join('\n')];
51
+ }
52
+ });
53
+ req.body.buildInfo = percy.build;
35
54
  }
36
55
 
37
56
  // Creates a local resource object containing the resource URL, mimetype, content, sha, and any
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/core",
3
- "version": "1.27.1",
3
+ "version": "1.27.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,11 +43,11 @@
43
43
  "test:types": "tsd"
44
44
  },
45
45
  "dependencies": {
46
- "@percy/client": "1.27.1",
47
- "@percy/config": "1.27.1",
48
- "@percy/dom": "1.27.1",
49
- "@percy/logger": "1.27.1",
50
- "@percy/webdriver-utils": "1.27.1",
46
+ "@percy/client": "1.27.2",
47
+ "@percy/config": "1.27.2",
48
+ "@percy/dom": "1.27.2",
49
+ "@percy/logger": "1.27.2",
50
+ "@percy/webdriver-utils": "1.27.2",
51
51
  "content-disposition": "^0.5.4",
52
52
  "cross-spawn": "^7.0.3",
53
53
  "extract-zip": "^2.0.1",
@@ -58,5 +58,5 @@
58
58
  "rimraf": "^3.0.2",
59
59
  "ws": "^8.0.0"
60
60
  },
61
- "gitHead": "a6f6441483b9c092ee1de1832f53c9a774968202"
61
+ "gitHead": "cb64b0c124a5ee1fcb14b130a1fa8e33d26a7284"
62
62
  }