@percy/core 1.26.3-beta.1 → 1.27.0-beta.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/api.js CHANGED
@@ -3,8 +3,8 @@ import path from 'path';
3
3
  import { createRequire } from 'module';
4
4
  import logger from '@percy/logger';
5
5
  import { normalize } from '@percy/config/utils';
6
- import { getPackageJSON, Server } from './utils.js';
7
-
6
+ import { getPackageJSON, Server, percyAutomateRequestHandler } from './utils.js';
7
+ import WebdriverUtils from '@percy/webdriver-utils';
8
8
  // need require.resolve until import.meta.resolve can be transpiled
9
9
  export const PERCY_DOM = createRequire(import.meta.url).resolve('@percy/dom');
10
10
 
@@ -73,7 +73,8 @@ export function createPercyServer(percy, port) {
73
73
  build: ((_percy$testing7 = percy.testing) === null || _percy$testing7 === void 0 ? void 0 : _percy$testing7.build) ?? percy.build,
74
74
  loglevel: percy.loglevel(),
75
75
  config: percy.config,
76
- success: true
76
+ success: true,
77
+ type: percy.client.tokenType()
77
78
  });
78
79
  })
79
80
  // get or set config options
@@ -136,7 +137,12 @@ export function createPercyServer(percy, port) {
136
137
  // flushes one or more snapshots from the internal queue
137
138
  .route('post', '/percy/flush', async (req, res) => res.json(200, {
138
139
  success: await percy.flush(req.body).then(() => true)
139
- }))
140
+ })).route('post', '/percy/automateScreenshot', async (req, res) => {
141
+ req = percyAutomateRequestHandler(req, percy.build);
142
+ res.json(200, {
143
+ success: await percy.upload(await new WebdriverUtils(req.body).automateScreenshot()).then(() => true)
144
+ });
145
+ })
140
146
  // stops percy at the end of the current event loop
141
147
  .route('/percy/stop', (req, res) => {
142
148
  setImmediate(() => percy.stop());
package/dist/config.js CHANGED
@@ -555,6 +555,9 @@ export const comparisonSchema = {
555
555
  externalDebugUrl: {
556
556
  type: 'string'
557
557
  },
558
+ domInfoSha: {
559
+ type: 'string'
560
+ },
558
561
  tag: {
559
562
  type: 'object',
560
563
  additionalProperties: false,
@@ -582,6 +585,15 @@ export const comparisonSchema = {
582
585
  orientation: {
583
586
  type: 'string',
584
587
  enum: ['portrait', 'landscape']
588
+ },
589
+ browserName: {
590
+ type: 'string'
591
+ },
592
+ browserVersion: {
593
+ type: 'string'
594
+ },
595
+ resolution: {
596
+ type: 'string'
585
597
  }
586
598
  }
587
599
  },
package/dist/percy.js CHANGED
@@ -364,5 +364,11 @@ export class Percy {
364
364
  }
365
365
  }.call(this);
366
366
  }
367
+ shouldSkipAssetDiscovery(tokenType) {
368
+ if (this.testing && JSON.stringify(this.testing) === JSON.stringify({})) {
369
+ return true;
370
+ }
371
+ return tokenType !== 'web';
372
+ }
367
373
  }
368
374
  export default Percy;
package/dist/utils.js CHANGED
@@ -19,6 +19,21 @@ export function normalizeURL(url) {
19
19
  return `${protocol}//${host}${pathname}${search}`;
20
20
  }
21
21
 
22
+ // Returns the body for automateScreenshot in structure
23
+ export function percyAutomateRequestHandler(req, buildInfo) {
24
+ if (req.body.client_info) {
25
+ req.body.clientInfo = req.body.client_info;
26
+ }
27
+ if (req.body.environment_info) {
28
+ req.body.environmentInfo = req.body.environment_info;
29
+ }
30
+ if (!req.body.options) {
31
+ req.body.options = {};
32
+ }
33
+ req.body.buildInfo = buildInfo;
34
+ return req;
35
+ }
36
+
22
37
  // Creates a local resource object containing the resource URL, mimetype, content, sha, and any
23
38
  // other additional resources attributes.
24
39
  export function createResource(url, content, mimetype, attrs) {
package/dist/work.js ADDED
@@ -0,0 +1,30 @@
1
+ const webdriver = require('selenium-webdriver');
2
+ const remote = require('selenium-webdriver/remote');
3
+ export default class PoaDriver {
4
+ sessionId = '';
5
+ commandExecutorUrl = '';
6
+ capabilities = {};
7
+ driver = null;
8
+ constructor(sessionId, commandExecutorUrl, capabilities) {
9
+ this.sessionId = sessionId;
10
+ this.commandExecutorUrl = commandExecutorUrl;
11
+ this.capabilities = capabilities;
12
+ this.createDriver();
13
+ this.localScreenshot();
14
+ }
15
+ createDriver() {
16
+ this.driver = new webdriver.Remote({
17
+ sessionId: this.sessionId,
18
+ commandExecutor: new remote.SeleniumWebDriverError(this.commandExecutorUrl),
19
+ desiredCapabilities: this.capabilities
20
+ });
21
+ }
22
+ localScreenshot() {
23
+ console.log(this.driver);
24
+ this.driver.takeScreenshot().then(function (image, err) {
25
+ require('fs').writeFile('./out1234.png', image, 'base64', function (err) {
26
+ console.log(err);
27
+ });
28
+ });
29
+ }
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/core",
3
- "version": "1.26.3-beta.1",
3
+ "version": "1.27.0-beta.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,10 +43,11 @@
43
43
  "test:types": "tsd"
44
44
  },
45
45
  "dependencies": {
46
- "@percy/client": "1.26.3-beta.1",
47
- "@percy/config": "1.26.3-beta.1",
48
- "@percy/dom": "1.26.3-beta.1",
49
- "@percy/logger": "1.26.3-beta.1",
46
+ "@percy/client": "1.27.0-beta.0",
47
+ "@percy/config": "1.27.0-beta.0",
48
+ "@percy/dom": "1.27.0-beta.0",
49
+ "@percy/logger": "1.27.0-beta.0",
50
+ "@percy/webdriver-utils": "1.27.0-beta.0",
50
51
  "content-disposition": "^0.5.4",
51
52
  "cross-spawn": "^7.0.3",
52
53
  "extract-zip": "^2.0.1",
@@ -57,5 +58,5 @@
57
58
  "rimraf": "^3.0.2",
58
59
  "ws": "^8.0.0"
59
60
  },
60
- "gitHead": "6571d4ad016bc8b3b32d49bf8a7da1393c1a5eba"
61
+ "gitHead": "2bc16314f51dddcc1cda459e7aa4b7b2db85f00a"
61
62
  }