@test-lab-ai/cli 0.2.19 → 0.2.20

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.
Files changed (2) hide show
  1. package/bin/testlab.mjs +56 -0
  2. package/package.json +1 -1
package/bin/testlab.mjs CHANGED
@@ -49,6 +49,11 @@ Usage:
49
49
  testlab credentials set <key> --value <value> Set a credential ({{credentials.<key>}})
50
50
  testlab credentials list List credential keys (values never shown)
51
51
  testlab labels list List your labels
52
+ testlab preferences get Show account testing preferences
53
+ testlab preferences set <pref> <value> Set a preference:
54
+ auto-upgrade <on|off>
55
+ script-retry <0-5>
56
+ auto-fix-flaky <on|off>
52
57
  testlab data list List data fixtures + built-in file fixtures
53
58
  testlab data create -f fixture.json Create a data fixture ({{data.<fixture>.<field>}})
54
59
  testlab scripts upload <file> --plan <id> Upload a local Playwright script for a plan
@@ -303,6 +308,52 @@ async function cmdLabelsList(flags) {
303
308
  log(`\n${labels.length} label(s)`)
304
309
  }
305
310
 
311
+ function parseOnOff(v, label) {
312
+ const s = String(v).toLowerCase()
313
+ if (["on", "true", "1", "enable", "enabled", "yes"].includes(s)) return true
314
+ if (["off", "false", "0", "disable", "disabled", "no"].includes(s)) return false
315
+ errExit(`${label} must be on or off (got "${v}")`)
316
+ }
317
+
318
+ async function cmdPreferencesGet(flags) {
319
+ const { apiKey, apiUrl } = requireAuth(flags)
320
+ const r = await apiFetch(apiUrl, apiKey, "GET", "/api/v1/preferences")
321
+ if (!r.ok) errExit(`${r.status}: ${r.json?.error || ""}`)
322
+ const p = r.json || {}
323
+ log(` auto-upgrade: ${p.autoUpgradeEnabled ? "on" : "off"}`)
324
+ log(` script-retry: ${p.scriptRetryOnFailure ?? 0}`)
325
+ log(` auto-fix-flaky: ${p.autoFixFlaky ? "on" : "off"}`)
326
+ }
327
+
328
+ async function cmdPreferencesSet(flags, args) {
329
+ const { apiKey, apiUrl } = requireAuth(flags)
330
+ const key = args[2]
331
+ const value = args[3] ?? flags.value
332
+ if (!key || value === undefined) {
333
+ errExit("usage: testlab preferences set <auto-upgrade|script-retry|auto-fix-flaky> <on|off|0-5>")
334
+ }
335
+ let patch
336
+ switch (key) {
337
+ case "auto-upgrade":
338
+ patch = { autoUpgradeEnabled: parseOnOff(value, "auto-upgrade") }
339
+ break
340
+ case "auto-fix-flaky":
341
+ patch = { autoFixFlaky: parseOnOff(value, "auto-fix-flaky") }
342
+ break
343
+ case "script-retry": {
344
+ const n = parseInt(value, 10)
345
+ if (!Number.isInteger(n) || n < 0 || n > 5) errExit("script-retry must be an integer 0-5")
346
+ patch = { scriptRetryOnFailure: n }
347
+ break
348
+ }
349
+ default:
350
+ errExit(`unknown preference "${key}". Use auto-upgrade, script-retry, or auto-fix-flaky.`)
351
+ }
352
+ const r = await apiFetch(apiUrl, apiKey, "PATCH", "/api/v1/preferences", patch)
353
+ if (!r.ok) errExit(`${r.status}: ${r.json?.error || ""}`)
354
+ log(`✓ Updated ${key}`)
355
+ }
356
+
306
357
  // Resolve which project imported plans go into.
307
358
  // --project none -> null (account-level, no project)
308
359
  // --project <id|name> -> that project
@@ -698,6 +749,11 @@ async function main() {
698
749
  case "labels":
699
750
  if (args[1] === "list") return cmdLabelsList(flags)
700
751
  return errExit("usage: testlab labels list")
752
+ case "preferences":
753
+ case "prefs":
754
+ if (args[1] === "get") return cmdPreferencesGet(flags)
755
+ if (args[1] === "set") return cmdPreferencesSet(flags, args)
756
+ return errExit("usage: testlab preferences <get | set <auto-upgrade|script-retry|auto-fix-flaky> <on|off|0-5>>")
701
757
  case "data":
702
758
  if (args[1] === "list") return cmdDataList(flags)
703
759
  if (args[1] === "create") return cmdDataCreate(flags)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@test-lab-ai/cli",
3
- "version": "0.2.19",
3
+ "version": "0.2.20",
4
4
  "description": "Import existing test plans into test-lab.ai from the command line (or an AI agent).",
5
5
  "type": "module",
6
6
  "bin": {