@mablhq/mabl-cli 1.11.4 → 1.11.15

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.
@@ -1,2 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isElementHandle = void 0;
4
+ function isElementHandle(value) {
5
+ return (value &&
6
+ typeof value === 'object' &&
7
+ typeof value.evaluate === 'function' &&
8
+ typeof value.focus === 'function' &&
9
+ typeof value.select === 'function' &&
10
+ typeof value.type === 'function' &&
11
+ typeof value.$x === 'function');
12
+ }
13
+ exports.isElementHandle = isElementHandle;
@@ -107,7 +107,7 @@ class PlaywrightFrame {
107
107
  async goto(url, options) {
108
108
  try {
109
109
  const response = await this.frame.goto(url, options);
110
- return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(response));
110
+ return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this.parentPage, response));
111
111
  }
112
112
  catch (e) {
113
113
  if (e instanceof playwright.errors.TimeoutError) {
@@ -1,27 +1,65 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  Object.defineProperty(exports, "__esModule", { value: true });
3
22
  exports.PlaywrightHttpRequest = void 0;
23
+ const playwright = __importStar(require("@playwright/test"));
4
24
  class PlaywrightHttpRequest {
5
- constructor(request) {
25
+ constructor(page, request, route) {
26
+ this.page = page;
6
27
  this.request = request;
28
+ this.route = route;
29
+ this.documentId = playwright._toImpl(this.request)._documentId;
7
30
  }
8
31
  abort() {
9
- throw new Error('PlaywrightHttpRequest.abort not implemented');
32
+ var _a;
33
+ if (this.route === undefined) {
34
+ throw new Error('Unable to abort an unrouted request');
35
+ }
36
+ return (_a = this.route) === null || _a === void 0 ? void 0 : _a.abort();
10
37
  }
11
38
  continue() {
12
- throw new Error('PlaywrightHttpRequest.continue not implemented');
39
+ var _a;
40
+ if (this.route === undefined) {
41
+ throw new Error('Unable to continue an unrouted request');
42
+ }
43
+ return (_a = this.route) === null || _a === void 0 ? void 0 : _a.continue();
13
44
  }
14
45
  frame() {
15
- throw new Error('PlaywrightHttpRequest.frame not implemented');
46
+ return this.page.getOrCreateFrame(this.request.frame());
16
47
  }
17
48
  requestId() {
18
- return this.request._guid;
49
+ return this.documentId;
19
50
  }
20
- respond(_response) {
21
- throw new Error('PlaywrightHttpRequest.respond not implemented');
51
+ respond(response) {
52
+ var _a;
53
+ if (this.route === undefined) {
54
+ throw new Error('Unable to respond an unrouted request');
55
+ }
56
+ return (_a = this.route) === null || _a === void 0 ? void 0 : _a.fulfill(response);
22
57
  }
23
58
  url() {
24
- throw new Error('PlaywrightHttpRequest.url not implemented');
59
+ return this.request.url();
60
+ }
61
+ headers() {
62
+ return this.request.allHeaders();
25
63
  }
26
64
  }
27
65
  exports.PlaywrightHttpRequest = PlaywrightHttpRequest;
@@ -3,20 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlaywrightHttpResponse = void 0;
4
4
  const playwrightHttpRequest_1 = require("./playwrightHttpRequest");
5
5
  class PlaywrightHttpResponse {
6
- constructor(response) {
6
+ constructor(page, response) {
7
+ this.page = page;
7
8
  this.response = response;
8
9
  }
9
10
  frame() {
10
- throw new Error('PlaywrightHttpResponse.frame not implemented');
11
+ return this.page.getOrCreateFrame(this.response.frame());
11
12
  }
12
13
  headers() {
13
- throw new Error('PlaywrightHttpResponse.headers not implemented');
14
+ return this.response.headers();
14
15
  }
15
16
  request() {
16
- return new playwrightHttpRequest_1.PlaywrightHttpRequest(this.response.request());
17
+ return new playwrightHttpRequest_1.PlaywrightHttpRequest(this.page, this.response.request());
17
18
  }
18
19
  url() {
19
- throw new Error('PlaywrightHttpResponse.url not implemented');
20
+ return this.response.url();
20
21
  }
21
22
  }
22
23
  exports.PlaywrightHttpResponse = PlaywrightHttpResponse;
@@ -35,6 +35,7 @@ const wrappers_1 = require("./wrappers");
35
35
  const testsUtil_1 = require("../../commands/tests/testsUtil");
36
36
  const path_1 = __importDefault(require("path"));
37
37
  const logUtils_1 = require("../../util/logUtils");
38
+ const uuid = __importStar(require("uuid"));
38
39
  exports.MAX_HIGHLIGHT_OPACITY = 0.9;
39
40
  exports.highlightColor = (transparency) => ({
40
41
  r: 196,
@@ -57,7 +58,21 @@ class PlaywrightPage extends events_1.default {
57
58
  this.browser.onPageClose(this);
58
59
  });
59
60
  page.on('download', async (download) => {
61
+ var _a, _b;
62
+ const guid = uuid.v4();
63
+ const downloadSize = (_b = (_a = (await download.createReadStream())) === null || _a === void 0 ? void 0 : _a.readableLength) !== null && _b !== void 0 ? _b : 0;
60
64
  await download.saveAs(path_1.default.join(this.browser.getDownloadDirectory(), download.suggestedFilename()));
65
+ browser.emit(browserLauncher_1.BrowserEvent.DownloadWillBegin, {
66
+ guid,
67
+ suggestedFilename: download.suggestedFilename(),
68
+ url: download.url(),
69
+ });
70
+ browser.emit(browserLauncher_1.BrowserEvent.DownloadProgress, {
71
+ guid,
72
+ totalBytes: downloadSize,
73
+ receivedBytes: downloadSize,
74
+ state: 'completed',
75
+ });
61
76
  });
62
77
  }
63
78
  async waitForInitialization() {
@@ -74,14 +89,20 @@ class PlaywrightPage extends events_1.default {
74
89
  return this;
75
90
  }
76
91
  wireEvents(event) {
92
+ if (event === browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo &&
93
+ !this.listenerCount(event)) {
94
+ this.client.on('Network.requestWillBeSentExtraInfo', (event) => {
95
+ this.emit(browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo, event);
96
+ });
97
+ }
77
98
  if (event === browserLauncher_1.PageEvent.Response && !this.listenerCount(event)) {
78
99
  this.page.on('response', (event) => {
79
- this.emit(browserLauncher_1.PageEvent.Response, new playwrightHttpResponse_1.PlaywrightHttpResponse(event));
100
+ this.emit(browserLauncher_1.PageEvent.Response, new playwrightHttpResponse_1.PlaywrightHttpResponse(this, event));
80
101
  });
81
102
  }
82
103
  if (event === browserLauncher_1.PageEvent.Request && !this.listenerCount(event)) {
83
- this.page.on('request', (request) => {
84
- this.emit(browserLauncher_1.PageEvent.Request, new playwrightHttpRequest_1.PlaywrightHttpRequest(request));
104
+ void this.page.route('**/*', route => {
105
+ this.emit(browserLauncher_1.PageEvent.Request, new playwrightHttpRequest_1.PlaywrightHttpRequest(this, route.request(), route));
85
106
  });
86
107
  }
87
108
  if (event === browserLauncher_1.PageEvent.FrameNavigated && !this.listenerCount(event)) {
@@ -175,7 +196,7 @@ class PlaywrightPage extends events_1.default {
175
196
  throw new Error('PlaywrightPage.authenticate not implemented');
176
197
  }
177
198
  bringToFront() {
178
- return Promise.resolve();
199
+ return this.page.bringToFront();
179
200
  }
180
201
  cookies() {
181
202
  return this.page.context().cookies();
@@ -201,7 +222,7 @@ class PlaywrightPage extends events_1.default {
201
222
  async goto(url, options) {
202
223
  try {
203
224
  const response = await this.page.goto(url, options);
204
- return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(response));
225
+ return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
205
226
  }
206
227
  catch (e) {
207
228
  if (e instanceof playwright.errors.TimeoutError) {
@@ -255,7 +276,7 @@ class PlaywrightPage extends events_1.default {
255
276
  }
256
277
  async reload(options) {
257
278
  try {
258
- return utils_1.mapIfNotNull(await this.page.reload(options), response => new playwrightHttpResponse_1.PlaywrightHttpResponse(response));
279
+ return utils_1.mapIfNotNull(await this.page.reload(options), response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
259
280
  }
260
281
  catch (e) {
261
282
  if (e instanceof playwright.errors.TimeoutError) {
@@ -289,7 +310,7 @@ class PlaywrightPage extends events_1.default {
289
310
  }));
290
311
  }
291
312
  setRequestInterception(_value) {
292
- throw new Error('PlaywrightPage.setRequestInterception not implemented');
313
+ return Promise.resolve();
293
314
  }
294
315
  async setViewport(viewport) {
295
316
  try {
@@ -312,7 +333,7 @@ class PlaywrightPage extends events_1.default {
312
333
  async waitForNavigation(options) {
313
334
  try {
314
335
  const result = await this.page.waitForNavigation(options);
315
- return utils_1.mapIfNotNull(result, result => new playwrightHttpResponse_1.PlaywrightHttpResponse(result));
336
+ return utils_1.mapIfNotNull(result, result => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, result));
316
337
  }
317
338
  catch (e) {
318
339
  if (e instanceof playwright.errors.TimeoutError) {
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -31,5 +31,8 @@ class PuppeteerHttpRequest {
31
31
  requestId() {
32
32
  return this.request._requestId;
33
33
  }
34
+ headers() {
35
+ return Promise.resolve(this.request.headers());
36
+ }
34
37
  }
35
38
  exports.PuppeteerHttpRequest = PuppeteerHttpRequest;
@@ -56,8 +56,7 @@ class PuppeteerPage extends events_1.default {
56
56
  this.openerPage = await utils_1.mapIfNotNull(opener, page => this.browser.getOrCreatePage(page));
57
57
  }
58
58
  makeCdpCall(method, paramArgs) {
59
- const client = this.page._client;
60
- return client.send(method, paramArgs);
59
+ return this.getCdpClient().send(method, paramArgs);
61
60
  }
62
61
  sendCharacter(key) {
63
62
  return this.page.keyboard.sendCharacter(key);
@@ -190,7 +189,8 @@ class PuppeteerPage extends events_1.default {
190
189
  wireEvents(event) {
191
190
  if (event === browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo &&
192
191
  !this.listenerCount(event)) {
193
- this.page.on('Network.requestWillBeSentExtraInfo', (event) => {
192
+ const client = this.getCdpClient();
193
+ client.on('Network.requestWillBeSentExtraInfo', (event) => {
194
194
  this.emit(browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo, event);
195
195
  });
196
196
  }
@@ -230,14 +230,12 @@ class PuppeteerPage extends events_1.default {
230
230
  });
231
231
  }
232
232
  if (event === browserLauncher_1.PageEvent.TracingBufferUsage && !this.listenerCount(event)) {
233
- const client = this.page._client;
234
- client.on('Tracing.bufferUsage', (tracing) => {
233
+ this.getCdpClient().on('Tracing.bufferUsage', (tracing) => {
235
234
  this.emit(browserLauncher_1.PageEvent.TracingBufferUsage, tracing);
236
235
  });
237
236
  }
238
237
  if (event === browserLauncher_1.PageEvent.TracingComplete && !this.listenerCount(event)) {
239
- const client = this.page._client;
240
- client.on('Tracing.tracingComplete', (tracingComplete) => {
238
+ this.getCdpClient().on('Tracing.tracingComplete', (tracingComplete) => {
241
239
  this.emit(browserLauncher_1.PageEvent.TracingComplete, tracingComplete);
242
240
  });
243
241
  }
@@ -358,5 +356,8 @@ class PuppeteerPage extends events_1.default {
358
356
  }
359
357
  return this.puppeteerFrames.get(frameId);
360
358
  }
359
+ getCdpClient() {
360
+ return this.page._client;
361
+ }
361
362
  }
362
363
  exports.PuppeteerPage = PuppeteerPage;
@@ -57,8 +57,10 @@ class AwaitCompletion {
57
57
  status: PollingOutcomeType.Complete,
58
58
  };
59
59
  }
60
- return new Promise(resolve => {
61
- setTimeout(() => this.awaitCompletion(seedId).then(result => resolve(result)), this.pollingIntervalMilliseconds);
60
+ return new Promise((resolve, reject) => {
61
+ setTimeout(() => this.awaitCompletion(seedId)
62
+ .then(result => resolve(result))
63
+ .catch(error => reject(error)), this.pollingIntervalMilliseconds);
62
64
  });
63
65
  }
64
66
  }
@@ -42,6 +42,7 @@ const logLineMessaging_1 = require("../../core/messaging/logLineMessaging");
42
42
  const resourceUtil_1 = require("../../util/resourceUtil");
43
43
  const mobileEmulationUtil_1 = require("./mobileEmulationUtil");
44
44
  const browserLauncher_1 = require("../../browserLauncher/browserLauncher");
45
+ const stream_1 = require("stream");
45
46
  const chalk = require('chalk');
46
47
  const chromeFinder = require('chrome-launcher/dist/chrome-finder');
47
48
  const launchUtils = require('chrome-launcher/dist/utils');
@@ -505,8 +506,14 @@ function handleExtensionMessage(message, trainingBrowser) {
505
506
  break;
506
507
  }
507
508
  }
508
- async function downloadUploadFile(fileUploadUrl, fileUpload, downloadDirectory) {
509
- const client = axios_1.default.create(httpUtil_1.currentProxyConfig());
509
+ async function downloadUploadFile(fileUploadUrl, fileUpload, downloadDirectory, mablApiClient) {
510
+ let client;
511
+ if (mablApiClient) {
512
+ client = mablApiClient.httpClient;
513
+ }
514
+ else {
515
+ client = axios_1.default.create(httpUtil_1.currentProxyConfig());
516
+ }
510
517
  try {
511
518
  const finalDirectory = path.normalize(`${downloadDirectory}/${fileUpload.id}`);
512
519
  try {
@@ -522,7 +529,12 @@ async function downloadUploadFile(fileUploadUrl, fileUpload, downloadDirectory)
522
529
  const response = await client.get(fileUploadUrl, {
523
530
  responseType: 'stream',
524
531
  });
525
- response.data.pipe(writer);
532
+ if (response.data.pipe) {
533
+ response.data.pipe(writer);
534
+ }
535
+ else if (!(response.status >= 400)) {
536
+ stream_1.Readable.from(response.data).pipe(writer);
537
+ }
526
538
  return new Promise((resolve, reject) => {
527
539
  writer.on('finish', () => resolve(finalPath));
528
540
  writer.on('error', reject);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deduplicateApiTestExecutionResults = void 0;
4
+ function deduplicateApiTestExecutionResults(postmanResult) {
5
+ var _a;
6
+ const executionsById = {};
7
+ const orderedExecutionIds = [];
8
+ (_a = postmanResult.run.executions) === null || _a === void 0 ? void 0 : _a.forEach(execution => {
9
+ const executionId = execution.id;
10
+ if (!executionsById[executionId]) {
11
+ orderedExecutionIds.push(executionId);
12
+ }
13
+ executionsById[executionId] = execution;
14
+ });
15
+ postmanResult.run.executions = orderedExecutionIds.map(executionId => executionsById[executionId]);
16
+ return postmanResult;
17
+ }
18
+ exports.deduplicateApiTestExecutionResults = deduplicateApiTestExecutionResults;