@applitools/ec-client 1.2.26 → 1.2.28
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.
|
@@ -61,7 +61,6 @@ function makeExecuteScript({ req, core }) {
|
|
|
61
61
|
proxy: session.proxy,
|
|
62
62
|
appName: (_g = (_f = options === null || options === void 0 ? void 0 : options.appName) !== null && _f !== void 0 ? _f : session.options.appName) !== null && _g !== void 0 ? _g : ((await driver.getTitle()) || 'default'),
|
|
63
63
|
testName: (_h = options === null || options === void 0 ? void 0 : options.testName) !== null && _h !== void 0 ? _h : session.options.testName,
|
|
64
|
-
properties: [{ name: 'Execution Cloud', value: 'Yes' }],
|
|
65
64
|
batch: { ...session.options.batch, ...options === null || options === void 0 ? void 0 : options.batch },
|
|
66
65
|
environment: {
|
|
67
66
|
hostingApp: `${(_j = environment.browserName) !== null && _j !== void 0 ? _j : ''} ${(_k = environment.browserVersion) !== null && _k !== void 0 ? _k : ''}`.trim(),
|
|
@@ -6,18 +6,17 @@ function makeFindElement({ req }) {
|
|
|
6
6
|
var _a, _b, _c;
|
|
7
7
|
logger.log('Inspecting element lookup request to collect self-healing metadata');
|
|
8
8
|
const proxyResponse = await req(request.url, { io: { request, response, handle: false }, logger });
|
|
9
|
-
const responseBody = await proxyResponse.
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const responseBody = Buffer.from(await proxyResponse.arrayBuffer());
|
|
10
|
+
const parsed = JSON.parse(responseBody.toString('utf8'));
|
|
11
|
+
if ((_b = (_a = parsed === null || parsed === void 0 ? void 0 : parsed.appliCustomData) === null || _a === void 0 ? void 0 : _a.selfHealing) === null || _b === void 0 ? void 0 : _b.successfulSelector) {
|
|
12
|
+
logger.log('Self-healed locators detected', parsed.appliCustomData.selfHealing);
|
|
12
13
|
(_c = session.metadata) !== null && _c !== void 0 ? _c : (session.metadata = []);
|
|
13
|
-
session.metadata.push(
|
|
14
|
+
session.metadata.push(parsed.appliCustomData.selfHealing);
|
|
14
15
|
}
|
|
15
16
|
else {
|
|
16
17
|
logger.log('No self-healing metadata found');
|
|
17
18
|
}
|
|
18
|
-
response
|
|
19
|
-
.writeHead(proxyResponse.status, Object.fromEntries(proxyResponse.headers.entries()))
|
|
20
|
-
.end(JSON.stringify(responseBody));
|
|
19
|
+
response.writeHead(proxyResponse.status, Object.fromEntries(proxyResponse.headers.entries())).end(responseBody);
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
22
|
exports.makeFindElement = makeFindElement;
|
|
@@ -25,6 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.makeStartSession = void 0;
|
|
27
27
|
const queue_1 = require("../utils/queue");
|
|
28
|
+
//@ts-ignore
|
|
29
|
+
const execution_grid_tunnel_1 = require("@applitools/execution-grid-tunnel");
|
|
28
30
|
const utils = __importStar(require("@applitools/utils"));
|
|
29
31
|
const RETRY_BACKOFF = [
|
|
30
32
|
...Array(5).fill(2000),
|
|
@@ -34,10 +36,19 @@ const RETRY_BACKOFF = [
|
|
|
34
36
|
function makeStartSession({ settings, req, tunnels }) {
|
|
35
37
|
const queues = new Map();
|
|
36
38
|
return async function createSession({ request, response, logger, }) {
|
|
37
|
-
var _a, _b, _c;
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
38
40
|
const requestBody = await utils.streams.toJSON(request);
|
|
39
41
|
logger.log(`Request was intercepted with body:`, requestBody);
|
|
40
|
-
|
|
42
|
+
let capabilities = {};
|
|
43
|
+
if (!utils.types.isEmpty(requestBody.desiredCapabilities)) {
|
|
44
|
+
capabilities = requestBody.desiredCapabilities;
|
|
45
|
+
}
|
|
46
|
+
else if (!utils.types.isEmpty((_a = requestBody.capabilities) === null || _a === void 0 ? void 0 : _a.alwaysMatch)) {
|
|
47
|
+
capabilities = requestBody.capabilities.alwaysMatch;
|
|
48
|
+
}
|
|
49
|
+
else if (!utils.types.isEmpty((_c = (_b = requestBody.capabilities) === null || _b === void 0 ? void 0 : _b.firstMatch) === null || _c === void 0 ? void 0 : _c[0])) {
|
|
50
|
+
capabilities = (_e = (_d = requestBody.capabilities) === null || _d === void 0 ? void 0 : _d.firstMatch) === null || _e === void 0 ? void 0 : _e[0];
|
|
51
|
+
}
|
|
41
52
|
const options = {
|
|
42
53
|
...settings.options,
|
|
43
54
|
...capabilities === null || capabilities === void 0 ? void 0 : capabilities['applitools:options'],
|
|
@@ -49,18 +60,26 @@ function makeStartSession({ settings, req, tunnels }) {
|
|
|
49
60
|
options,
|
|
50
61
|
};
|
|
51
62
|
if (options.tunnel && tunnels) {
|
|
63
|
+
// TODO should be removed once tunnel spawning issue is solved
|
|
64
|
+
await (0, execution_grid_tunnel_1.prepareEnvironment)();
|
|
52
65
|
session.tunnels = await tunnels.acquire(session.credentials);
|
|
53
66
|
session.tunnels.forEach((tunnel, index) => {
|
|
54
67
|
options[`x-tunnel-id-${index}`] = tunnel.tunnelId;
|
|
55
68
|
});
|
|
56
69
|
}
|
|
57
70
|
const applitoolsCapabilities = Object.fromEntries(Object.entries(options).map(([key, value]) => [`applitools:${key}`, value]));
|
|
58
|
-
if (requestBody.
|
|
59
|
-
requestBody.capabilities.alwaysMatch = { ...(_c = requestBody.capabilities) === null || _c === void 0 ? void 0 : _c.alwaysMatch, ...applitoolsCapabilities };
|
|
60
|
-
}
|
|
61
|
-
if (requestBody.desiredCapabilities) {
|
|
71
|
+
if (!utils.types.isEmpty(requestBody.desiredCapabilities)) {
|
|
62
72
|
requestBody.desiredCapabilities = { ...requestBody.desiredCapabilities, ...applitoolsCapabilities };
|
|
63
73
|
}
|
|
74
|
+
else if (!utils.types.isEmpty((_f = requestBody.capabilities) === null || _f === void 0 ? void 0 : _f.alwaysMatch)) {
|
|
75
|
+
requestBody.capabilities.alwaysMatch = { ...(_g = requestBody.capabilities) === null || _g === void 0 ? void 0 : _g.alwaysMatch, ...applitoolsCapabilities };
|
|
76
|
+
}
|
|
77
|
+
else if (!utils.types.isEmpty((_j = (_h = requestBody.capabilities) === null || _h === void 0 ? void 0 : _h.firstMatch) === null || _j === void 0 ? void 0 : _j[0])) {
|
|
78
|
+
requestBody.capabilities.firstMatch = [{ ...requestBody.capabilities.firstMatch[0], ...applitoolsCapabilities }];
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
requestBody.desiredCapabilities = { ...applitoolsCapabilities };
|
|
82
|
+
}
|
|
64
83
|
logger.log('Request body has modified:', requestBody);
|
|
65
84
|
const queueKey = JSON.stringify(session.credentials);
|
|
66
85
|
let queue = queues.get(queueKey);
|
package/dist/tunnels/manager.js
CHANGED
|
@@ -22,17 +22,26 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.makeTunnelManager = void 0;
|
|
30
27
|
const req_1 = require("@applitools/req");
|
|
31
28
|
//@ts-ignore
|
|
32
|
-
const execution_grid_tunnel_1 =
|
|
29
|
+
const execution_grid_tunnel_1 = require("@applitools/execution-grid-tunnel");
|
|
33
30
|
const utils = __importStar(require("@applitools/utils"));
|
|
34
31
|
async function makeTunnelManager({ settings, logger, }) {
|
|
35
32
|
let server;
|
|
33
|
+
const getTunnelServiceUrl = utils.general.cachify(async () => {
|
|
34
|
+
const { port, cleanupFunction } = await (0, execution_grid_tunnel_1.startEgTunnelService)({ logger });
|
|
35
|
+
server = {
|
|
36
|
+
port,
|
|
37
|
+
async close() {
|
|
38
|
+
await cleanupFunction();
|
|
39
|
+
server = undefined;
|
|
40
|
+
getTunnelServiceUrl.clearCache();
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return `http://localhost:${port}`;
|
|
44
|
+
});
|
|
36
45
|
const req = (0, req_1.makeReq)({
|
|
37
46
|
retry: {
|
|
38
47
|
validate: async ({ response }) => {
|
|
@@ -52,7 +61,7 @@ async function makeTunnelManager({ settings, logger, }) {
|
|
|
52
61
|
},
|
|
53
62
|
});
|
|
54
63
|
const pools = new Map();
|
|
55
|
-
return { create, destroy, acquire, release, close };
|
|
64
|
+
return { create, destroy, acquire, release, close: async () => server === null || server === void 0 ? void 0 : server.close() };
|
|
56
65
|
async function acquire(credentials) {
|
|
57
66
|
const key = JSON.stringify(credentials);
|
|
58
67
|
let pool = pools.get(key);
|
|
@@ -77,7 +86,7 @@ async function makeTunnelManager({ settings, logger, }) {
|
|
|
77
86
|
var _a, _b;
|
|
78
87
|
if (!(settings === null || settings === void 0 ? void 0 : settings.serverUrl)) {
|
|
79
88
|
settings !== null && settings !== void 0 ? settings : (settings = {});
|
|
80
|
-
settings.serverUrl = await
|
|
89
|
+
settings.serverUrl = await getTunnelServiceUrl();
|
|
81
90
|
}
|
|
82
91
|
const response = await req('/tunnels', {
|
|
83
92
|
method: 'POST',
|
|
@@ -97,7 +106,7 @@ async function makeTunnelManager({ settings, logger, }) {
|
|
|
97
106
|
var _a, _b;
|
|
98
107
|
if (!(settings === null || settings === void 0 ? void 0 : settings.serverUrl)) {
|
|
99
108
|
settings !== null && settings !== void 0 ? settings : (settings = {});
|
|
100
|
-
settings.serverUrl = await
|
|
109
|
+
settings.serverUrl = await getTunnelServiceUrl();
|
|
101
110
|
}
|
|
102
111
|
const response = await req(`/tunnels/${tunnel.tunnelId}`, {
|
|
103
112
|
method: 'DELETE',
|
|
@@ -113,14 +122,6 @@ async function makeTunnelManager({ settings, logger, }) {
|
|
|
113
122
|
logger.error(`Failed to delete tunnel with status ${response.status} and code ${(_a = body === null || body === void 0 ? void 0 : body.message) !== null && _a !== void 0 ? _a : 'UNKNOWN_ERROR'}`);
|
|
114
123
|
throw new Error(`Failed to delete tunnel with code ${(_b = body === null || body === void 0 ? void 0 : body.message) !== null && _b !== void 0 ? _b : 'UNKNOWN_ERROR'}`);
|
|
115
124
|
}
|
|
116
|
-
async function open() {
|
|
117
|
-
const { port, cleanupFunction } = await (0, execution_grid_tunnel_1.default)({ logger });
|
|
118
|
-
server = { port, close: cleanupFunction };
|
|
119
|
-
return `http://localhost:${port}`;
|
|
120
|
-
}
|
|
121
|
-
async function close() {
|
|
122
|
-
await (server === null || server === void 0 ? void 0 : server.close());
|
|
123
|
-
}
|
|
124
125
|
}
|
|
125
126
|
exports.makeTunnelManager = makeTunnelManager;
|
|
126
127
|
function makePool(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/ec-client",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.28",
|
|
4
4
|
"homepage": "https://applitools.com",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@applitools/core-base": "1.1.53",
|
|
67
|
-
"@applitools/driver": "1.11.
|
|
68
|
-
"@applitools/execution-grid-tunnel": "
|
|
67
|
+
"@applitools/driver": "1.11.48",
|
|
68
|
+
"@applitools/execution-grid-tunnel": "2.0.1",
|
|
69
69
|
"@applitools/logger": "1.1.52",
|
|
70
70
|
"@applitools/req": "1.2.5",
|
|
71
71
|
"@applitools/socket": "1.0.13",
|
|
72
|
-
"@applitools/spec-driver-webdriver": "1.0.
|
|
72
|
+
"@applitools/spec-driver-webdriver": "1.0.29",
|
|
73
73
|
"@applitools/utils": "1.3.35",
|
|
74
74
|
"abort-controller": "3.0.0",
|
|
75
75
|
"webdriver": "7",
|