@mablhq/mabl-cli 1.29.19 → 1.31.3

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/api/featureSet.js CHANGED
@@ -4,6 +4,7 @@ exports.FeatureSet = exports.FindImplementationVersion = void 0;
4
4
  const types_1 = require("../browserLauncher/types");
5
5
  const ACCESSIBILITY_CHECK_FEATURE_FLAG = 'accessibility_checks';
6
6
  const SMARTER_WAIT_FEATURE_FLAG = 'smarter_wait';
7
+ const EXECUTION_SCREENCAST_MODE = 'execution_screencast_mode';
7
8
  var FindImplementationVersion;
8
9
  (function (FindImplementationVersion) {
9
10
  FindImplementationVersion[FindImplementationVersion["V1"] = 0] = "V1";
@@ -24,5 +25,8 @@ class FeatureSet {
24
25
  hasAccessibilityChecksEnabled() {
25
26
  return this.featureFlags.has(ACCESSIBILITY_CHECK_FEATURE_FLAG);
26
27
  }
28
+ isExecutionScreencastModeEnabled() {
29
+ return this.featureFlags.has(EXECUTION_SCREENCAST_MODE);
30
+ }
27
31
  }
28
32
  exports.FeatureSet = FeatureSet;
@@ -34,8 +34,9 @@ const playwrightPage_1 = require("./playwrightPage");
34
34
  const types_1 = require("../types");
35
35
  const path_1 = __importDefault(require("path"));
36
36
  const fs_extra_1 = __importDefault(require("fs-extra"));
37
+ const loggingProvider_1 = require("../../providers/logging/loggingProvider");
37
38
  class PlaywrightBrowser extends events_1.default {
38
- constructor(defaultContext, downloadDirectory, browserWSEndpoint, disableFocusEmulation) {
39
+ constructor(defaultContext, downloadDirectory, browserWSEndpoint, enableScreencastMode, disableFocusEmulation) {
39
40
  super();
40
41
  this.defaultContext = defaultContext;
41
42
  this.downloadDirectory = downloadDirectory;
@@ -54,9 +55,16 @@ class PlaywrightBrowser extends events_1.default {
54
55
  if (!fs_extra_1.default.existsSync(path_1.default.join(this.downloadDirectory))) {
55
56
  fs_extra_1.default.mkdirSync(path_1.default.join(this.downloadDirectory));
56
57
  }
58
+ loggingProvider_1.logger.debug(`Screencast mode is ${enableScreencastMode ? 'enabled' : 'disabled'}`);
59
+ if (enableScreencastMode) {
60
+ this.defaultContext.on('page', async (page) => this.enableScreencastMode(page));
61
+ this.defaultContext.pages().forEach(async (page) => {
62
+ await this.enableScreencastMode(page);
63
+ });
64
+ }
57
65
  }
58
- static async create(defaultContext, downloadDirectory, browserWSEndpoint, disableFocusEmulation) {
59
- const browser = new PlaywrightBrowser(defaultContext, downloadDirectory, browserWSEndpoint, disableFocusEmulation);
66
+ static async create(defaultContext, downloadDirectory, browserWSEndpoint, enableScreencastMode, disableFocusEmulation) {
67
+ const browser = new PlaywrightBrowser(defaultContext, downloadDirectory, browserWSEndpoint, enableScreencastMode, disableFocusEmulation);
60
68
  await browser.setDownloadBehavior();
61
69
  return browser;
62
70
  }
@@ -127,6 +135,15 @@ class PlaywrightBrowser extends events_1.default {
127
135
  eventsEnabled: true,
128
136
  });
129
137
  }
138
+ async enableScreencastMode(page) {
139
+ const cdp = await this.defaultContext.newCDPSession(page);
140
+ cdp.on('Page.screencastFrame', async (params) => {
141
+ await cdp
142
+ .send('Page.screencastFrameAck', { sessionId: params.sessionId })
143
+ .catch(() => { });
144
+ });
145
+ await cdp.send('Page.startScreencast', {});
146
+ }
130
147
  onPageClose(page) {
131
148
  this.playwrightPages.delete(page.getPageId());
132
149
  this.emit(browserLauncher_1.BrowserEvent.PageDestroyed, page);
@@ -8,10 +8,6 @@ const playwrightBrowser_1 = require("./playwrightBrowser");
8
8
  const simplePlaywrightLogger_1 = require("./simplePlaywrightLogger");
9
9
  const BROWSER_LAUNCH_TIMEOUT_MS = 60000;
10
10
  class PlaywrightBrowserLauncher {
11
- async connect(options, currentDownloadPath) {
12
- const browser = await test_1.chromium.connect(options.browserWSEndpoint);
13
- return playwrightBrowser_1.PlaywrightBrowser.create(browser.contexts()[0], currentDownloadPath, options.browserWSEndpoint);
14
- }
15
11
  async launch(options) {
16
12
  var _a, _b, _c, _d;
17
13
  const viewport = options.defaultDeviceDescriptor
@@ -54,7 +50,7 @@ class PlaywrightBrowserLauncher {
54
50
  userAgent: (_d = options.userAgent) !== null && _d !== void 0 ? _d : options.defaultUserAgent,
55
51
  viewport,
56
52
  });
57
- return playwrightBrowser_1.PlaywrightBrowser.create(defaultContext, options.downloadPath, '', options.disableFocusEmulation);
53
+ return playwrightBrowser_1.PlaywrightBrowser.create(defaultContext, options.downloadPath, '', options.enableScreencastModeForScreenshotTimeouts, options.disableFocusEmulation);
58
54
  }
59
55
  }
60
56
  exports.PlaywrightBrowserLauncher = PlaywrightBrowserLauncher;
@@ -212,6 +212,7 @@ async function createBrowser(browserWidth, browserHeight, headless, containerTes
212
212
  ignoreDefaultArgs,
213
213
  userAgent: (_a = options === null || options === void 0 ? void 0 : options.userAgent) !== null && _a !== void 0 ? _a : emulationConfig === null || emulationConfig === void 0 ? void 0 : emulationConfig.device_config.user_agent,
214
214
  defaultUserAgent: options === null || options === void 0 ? void 0 : options.defaultUserAgent,
215
+ enableScreencastModeForScreenshotTimeouts: false,
215
216
  });
216
217
  if (!maybeBrowser) {
217
218
  throw new Error('Unable to start Chrome session');
@@ -599,6 +600,7 @@ async function pullDownTestRunConfig(testRunId, apiClient) {
599
600
  filterHttpRequests: false,
600
601
  importedVariables: (_k = journeyRun.journey_parameters) === null || _k === void 0 ? void 0 : _k.imported_variables,
601
602
  pageLoadWait: (_l = journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.page_load_wait,
603
+ runId: journeyRun.id,
602
604
  testId: (_m = journeyRun.journey) === null || _m === void 0 ? void 0 : _m.invariant_id,
603
605
  url: (_p = (_o = journeyRun.journey_parameters) === null || _o === void 0 ? void 0 : _o.deployment) === null || _p === void 0 ? void 0 : _p.uri,
604
606
  };
@@ -623,6 +625,7 @@ async function extractTestRunConfig(executionMessage, apiClient) {
623
625
  filterHttpRequests: true,
624
626
  importedVariables: (_l = journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.imported_variables,
625
627
  pageLoadWait: (_m = journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.page_load_wait,
628
+ runId: journeyRun.id,
626
629
  runnerType: maybeRunnerType,
627
630
  testId: (_o = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey) === null || _o === void 0 ? void 0 : _o.invariant_id,
628
631
  url: (_q = (_p = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _p === void 0 ? void 0 : _p.deployment) === null || _q === void 0 ? void 0 : _q.uri,