@midscene/cli 1.0.1-beta-20251202152706.0 → 1.0.1-beta-20251203125942.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/lib/index.js CHANGED
@@ -3015,7 +3015,7 @@ var __webpack_modules__ = {
3015
3015
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
3016
3016
  var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
3017
3017
  var main_default = /*#__PURE__*/ __webpack_require__.n(main);
3018
- var package_namespaceObject = JSON.parse('{"rE":"1.0.1-beta-20251202152706.0"}');
3018
+ var package_namespaceObject = JSON.parse('{"rE":"1.0.1-beta-20251203125942.0"}');
3019
3019
  const yaml_namespaceObject = require("@midscene/core/yaml");
3020
3020
  const common_namespaceObject = require("@midscene/shared/common");
3021
3021
  const external_lodash_merge_namespaceObject = require("lodash.merge");
@@ -3158,6 +3158,16 @@ var __webpack_modules__ = {
3158
3158
  resolve(server);
3159
3159
  });
3160
3160
  });
3161
+ function resolveTestId(cliTestId, yamlTestId, fileName) {
3162
+ return cliTestId ?? yamlTestId ?? fileName;
3163
+ }
3164
+ function buildAgentOptions(yamlAgent, preferenceTestId, fileName) {
3165
+ return {
3166
+ ...yamlAgent || {},
3167
+ cache: (0, utils_namespaceObject.processCacheConfig)(yamlAgent?.cache, fileName),
3168
+ testId: preferenceTestId
3169
+ };
3170
+ }
3161
3171
  async function createYamlPlayer(file, script, options) {
3162
3172
  const yamlScript = script || (0, yaml_namespaceObject.parseYamlScript)((0, external_node_fs_namespaceObject.readFileSync)(file, 'utf-8'), file);
3163
3173
  const clonedYamlScript = structuredClone(yamlScript);
@@ -3165,7 +3175,7 @@ var __webpack_modules__ = {
3165
3175
  const preference = {
3166
3176
  headed: options?.headed,
3167
3177
  keepWindow: options?.keepWindow,
3168
- testId: fileName
3178
+ testId: resolveTestId(options?.testId, clonedYamlScript.agent?.testId, fileName)
3169
3179
  };
3170
3180
  const player = new yaml_namespaceObject.ScriptPlayer(clonedYamlScript, async ()=>{
3171
3181
  const freeFn = [];
@@ -3203,7 +3213,7 @@ var __webpack_modules__ = {
3203
3213
  if (!webTarget.bridgeMode) {
3204
3214
  const { agent, freeFn: newFreeFn } = await (0, puppeteer_agent_launcher_namespaceObject.puppeteerAgentForTarget)(webTarget, {
3205
3215
  ...preference,
3206
- cache: (0, utils_namespaceObject.processCacheConfig)(clonedYamlScript.agent?.cache, fileName)
3216
+ ...buildAgentOptions(clonedYamlScript.agent, preference.testId, fileName)
3207
3217
  }, options?.browser);
3208
3218
  freeFn.push(...newFreeFn);
3209
3219
  return {
@@ -3212,11 +3222,10 @@ var __webpack_modules__ = {
3212
3222
  };
3213
3223
  }
3214
3224
  external_node_assert_default()('newTabWithUrl' === webTarget.bridgeMode || 'currentTab' === webTarget.bridgeMode, `bridgeMode config value must be either "newTabWithUrl" or "currentTab", but got ${webTarget.bridgeMode}`);
3215
- if (webTarget.userAgent || webTarget.viewportWidth || webTarget.viewportHeight || webTarget.viewportScale || webTarget.waitForNetworkIdle || webTarget.cookie) console.warn('puppeteer options (userAgent, viewportWidth, viewportHeight, viewportScale, waitForNetworkIdle, cookie) are not supported in bridge mode. They will be ignored.');
3225
+ if (webTarget.userAgent || webTarget.viewportWidth || webTarget.viewportHeight || webTarget.viewportScale || webTarget.waitForNetworkIdle || webTarget.cookie || webTarget.chromeArgs) console.warn('puppeteer options (userAgent, viewportWidth, viewportHeight, viewportScale, waitForNetworkIdle, cookie, chromeArgs) are not supported in bridge mode. They will be ignored.');
3216
3226
  const agent = new bridge_mode_namespaceObject.AgentOverChromeBridge({
3217
3227
  closeNewTabsAfterDisconnect: webTarget.closeNewTabsAfterDisconnect,
3218
- cache: (0, utils_namespaceObject.processCacheConfig)(clonedYamlScript.agent?.cache, fileName),
3219
- aiActionContext: clonedYamlScript.agent?.aiActionContext
3228
+ ...buildAgentOptions(clonedYamlScript.agent, preference.testId, fileName)
3220
3229
  });
3221
3230
  if ('newTabWithUrl' === webTarget.bridgeMode) await agent.connectNewTabWithUrl(webTarget.url);
3222
3231
  else {
@@ -3236,8 +3245,7 @@ var __webpack_modules__ = {
3236
3245
  const androidTarget = clonedYamlScript.android;
3237
3246
  const agent = await (0, android_namespaceObject.agentFromAdbDevice)(androidTarget?.deviceId, {
3238
3247
  ...androidTarget,
3239
- cache: (0, utils_namespaceObject.processCacheConfig)(clonedYamlScript.agent?.cache, fileName),
3240
- aiActionContext: clonedYamlScript.agent?.aiActionContext
3248
+ ...buildAgentOptions(clonedYamlScript.agent, preference.testId, fileName)
3241
3249
  });
3242
3250
  if (androidTarget?.launch) await agent.launch(androidTarget.launch);
3243
3251
  freeFn.push({
@@ -3253,8 +3261,7 @@ var __webpack_modules__ = {
3253
3261
  const iosTarget = clonedYamlScript.ios;
3254
3262
  const agent = await (0, ios_namespaceObject.agentFromWebDriverAgent)({
3255
3263
  ...iosTarget,
3256
- cache: (0, utils_namespaceObject.processCacheConfig)(clonedYamlScript.agent?.cache, fileName),
3257
- aiActionContext: clonedYamlScript.agent?.aiActionContext
3264
+ ...buildAgentOptions(clonedYamlScript.agent, preference.testId, fileName)
3258
3265
  });
3259
3266
  if (iosTarget?.launch) await agent.launch(iosTarget.launch);
3260
3267
  freeFn.push({
@@ -3280,10 +3287,7 @@ var __webpack_modules__ = {
3280
3287
  debug('DeviceClass', DeviceClass, 'with param', interfaceTarget.param);
3281
3288
  const device = new DeviceClass(interfaceTarget.param || {});
3282
3289
  debug('creating agent from device', device);
3283
- const agent = (0, agent_namespaceObject.createAgent)(device, {
3284
- ...clonedYamlScript.agent,
3285
- cache: (0, utils_namespaceObject.processCacheConfig)(clonedYamlScript.agent?.cache, fileName)
3286
- });
3290
+ const agent = (0, agent_namespaceObject.createAgent)(device, buildAgentOptions(clonedYamlScript.agent, preference.testId, fileName));
3287
3291
  freeFn.push({
3288
3292
  name: 'destroy_general_interface_agent',
3289
3293
  fn: ()=>{
@@ -11888,7 +11892,7 @@ Usage:
11888
11892
  type: 'boolean',
11889
11893
  description: `Turn on logging to help debug why certain keys or values are not being set as you expect, default is ${config_factory_defaultConfig.dotenvDebug}`
11890
11894
  }
11891
- }).version('version', 'Show version number', "1.0.1-beta-20251202152706.0").help().epilogue(`For complete list of configuration options, please visit:
11895
+ }).version('version', 'Show version number', "1.0.1-beta-20251203125942.0").help().epilogue(`For complete list of configuration options, please visit:
11892
11896
  • Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
11893
11897
  • Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
11894
11898
  • iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part