@testver/testver 1.2.3 → 1.2.4

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.
@@ -133,10 +133,33 @@ def _provider_options_key():
133
133
  return {
134
134
  "browserstack": "bstack:options",
135
135
  "saucelabs": "sauce:options",
136
- "lambdatest": "LT:Options",
136
+ "lambdatest": "lt:options",
137
137
  }.get(os.environ.get("TESTVER_PROVIDER"))
138
138
 
139
139
 
140
+ def _env_json(name):
141
+ try:
142
+ value = json.loads(os.environ.get(name) or "{}")
143
+ return value if isinstance(value, dict) else {}
144
+ except ValueError:
145
+ return {}
146
+
147
+
148
+ def _apply_local_caps(caps):
149
+ """Local Devices (Settings → Local Devices): capabilities the project
150
+ doesn't set itself (TESTVER_LOCAL_CAPS_DEFAULTS — WebDriverAgent port and
151
+ signing), then Testver's own over the project's (TESTVER_LOCAL_CAPS —
152
+ app launch mode)."""
153
+ for k, v in _env_json("TESTVER_LOCAL_CAPS_DEFAULTS").items():
154
+ bare = k[len("appium:"):] if k.startswith("appium:") else k
155
+ if k not in caps and bare not in caps:
156
+ caps[k] = v
157
+ for k, v in _env_json("TESTVER_LOCAL_CAPS").items():
158
+ bare = k[len("appium:"):] if k.startswith("appium:") else k
159
+ caps.pop(bare, None)
160
+ caps[k] = v
161
+
162
+
140
163
  def _apply_caps_to_dict(caps):
141
164
  """Mutate a flat capabilities dict in place with Testver overrides."""
142
165
  # Normalise any legacy unprefixed Appium keys.
@@ -164,6 +187,7 @@ def _apply_caps_to_dict(caps):
164
187
  if udid:
165
188
  caps["appium:udid"] = udid
166
189
  caps.pop("appium:avd", None)
190
+ _apply_local_caps(caps)
167
191
  else:
168
192
  caps.pop("appium:udid", None)
169
193
  caps.pop("appium:avd", None)
@@ -188,6 +212,9 @@ def _apply_caps_to_dict(caps):
188
212
 
189
213
  pkey = _provider_options_key()
190
214
  if pkey:
215
+ # the project's own spelling of the block (`LT:Options` / `lt:options`)
216
+ if pkey not in caps:
217
+ pkey = next((k for k in caps if isinstance(k, str) and k.lower() == pkey.lower()), pkey)
191
218
  caps[pkey] = _provider_options_block(caps.get(pkey))
192
219
  return caps
193
220
 
@@ -99,6 +99,36 @@ function flattenCaps(caps) {
99
99
  return caps;
100
100
  }
101
101
 
102
+ /**
103
+ * Local Devices (Settings → Local Devices): capabilities the project doesn't
104
+ * set itself (TESTVER_LOCAL_CAPS_DEFAULTS — WebDriverAgent port and signing),
105
+ * then Testver's own over the project's (TESTVER_LOCAL_CAPS — app launch mode).
106
+ */
107
+ function applyLocalCaps(caps) {
108
+ let defaults = {};
109
+ let overrides = {};
110
+ try { defaults = process.env.TESTVER_LOCAL_CAPS_DEFAULTS ? JSON.parse(process.env.TESTVER_LOCAL_CAPS_DEFAULTS) : {}; } catch (e) { defaults = {}; }
111
+ try { overrides = process.env.TESTVER_LOCAL_CAPS ? JSON.parse(process.env.TESTVER_LOCAL_CAPS) : {}; } catch (e) { overrides = {}; }
112
+ for (const k of Object.keys(defaults)) {
113
+ if (caps[k] === undefined && caps[k.replace(/^appium:/, '')] === undefined) caps[k] = defaults[k];
114
+ }
115
+ for (const k of Object.keys(overrides)) {
116
+ delete caps[k.replace(/^appium:/, '')];
117
+ caps[k] = overrides[k];
118
+ }
119
+ }
120
+
121
+ /**
122
+ * The key the capabilities already use for a vendor block, matched without
123
+ * regard to case (`LT:Options` / `lt:options`), else `key` — Testver merges
124
+ * into the project's own block rather than adding a second one.
125
+ */
126
+ function vendorKeyIn(caps, key) {
127
+ if (!key || !caps || typeof caps !== 'object' || Object.prototype.hasOwnProperty.call(caps, key)) return key;
128
+ const lower = key.toLowerCase();
129
+ return Object.keys(caps).find((k) => k.toLowerCase() === lower) || key;
130
+ }
131
+
102
132
  /** Apply Testver cloud overrides to a wdio `remote()` options object. */
103
133
  function applyTestverOverrides(opts) {
104
134
  opts = opts || {};
@@ -145,6 +175,7 @@ function applyTestverOverrides(opts) {
145
175
  caps['appium:udid'] = process.env.TESTVER_DEVICE_UDID;
146
176
  delete caps['appium:avd'];
147
177
  }
178
+ applyLocalCaps(caps);
148
179
  } else {
149
180
  delete caps['appium:udid'];
150
181
  delete caps['appium:avd'];
@@ -204,9 +235,11 @@ function applyTestverOverrides(opts) {
204
235
  let vendor = null;
205
236
  try { vendor = process.env.TESTVER_VENDOR_OPTIONS ? JSON.parse(process.env.TESTVER_VENDOR_OPTIONS) : null; } catch (e) { vendor = null; }
206
237
  if (vendor && vendor.key) {
207
- caps[vendor.key] = Object.assign({}, vendor.options || {}, caps[vendor.key] || {}, vendor.overrides || {});
238
+ // the project's own spelling of the block (`LT:Options` / `lt:options`)
239
+ const key = vendorKeyIn(caps, vendor.key);
240
+ caps[key] = Object.assign({}, vendor.options || {}, caps[key] || {}, vendor.overrides || {});
208
241
  } else {
209
- const key = { browserstack: 'bstack:options', saucelabs: 'sauce:options', lambdatest: 'LT:Options' }[process.env.TESTVER_PROVIDER || ''];
242
+ const key = vendorKeyIn(caps, { browserstack: 'bstack:options', saucelabs: 'sauce:options', lambdatest: 'lt:options' }[process.env.TESTVER_PROVIDER || ''] || '');
210
243
  const device = process.env.TESTVER_DEVICE_NAME || caps['appium:deviceName'];
211
244
  if (key && device) {
212
245
  const existing = caps[key] || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testver/testver",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "AI-powered interactive CLI for test automation",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -123,7 +123,7 @@
123
123
  "mammoth": "^1.13.0",
124
124
  "marked": "^15.0.12",
125
125
  "marked-terminal": "^7.3.0",
126
- "multer": "^2.4.0",
126
+ "multer": "^2.5.0",
127
127
  "nodemailer": "^10.1.4",
128
128
  "numfmt": "3.2.6",
129
129
  "open": "^11.0.4",