@appliqation/automation-sdk 2.8.1 → 2.9.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/README.md CHANGED
@@ -125,23 +125,30 @@ Both forms accept the usual Playwright flags (`--project`, `--headed`,
125
125
 
126
126
  ## Scoping runs: Scenario or Test Set
127
127
 
128
- Add `scenarioId` to link a run to one scenario, or `testSetId` to link it
129
- to a Test Set — the grouping you'd use for a smoke, sanity, or regression
130
- suite that spans multiple scenarios. They're mutually exclusive;
131
- `scenarioId` wins if both are set.
128
+ Link a run to one scenario (`scenarioId`) or to a Test Set (`testSetId`)
129
+ the grouping you'd use for a smoke, sanity, or regression suite that spans
130
+ multiple scenarios. They're mutually exclusive; `scenarioId` wins if both
131
+ are set. No config changes needed — set it per-invocation:
132
+
133
+ ```bash
134
+ # CLI flag
135
+ npx playwright test -- --appq --appq-scenario-id=1154
136
+ npx playwright test -- --appq --appq-testset-id=2489
137
+
138
+ # Env var — same effect
139
+ APPLIQATION_SCENARIO_ID=1154 APPQ_ENABLED=1 npx playwright test
140
+ APPLIQATION_TEST_SET_ID=2489 APPQ_ENABLED=1 npx playwright test
141
+ ```
142
+
143
+ Or hardcode a default in `playwright.config.js` if a project always runs
144
+ against the same scope — CLI flag and env var still override it per-run:
132
145
 
133
146
  ```javascript
134
- const appliqationConfig = {
147
+ [AppliqationReporter, {
135
148
  apiKey: process.env.APPLIQATION_API_KEY,
136
149
  projectKey: process.env.APPLIQATION_PROJECT_KEY,
137
-
138
- scenarioId: parseInt(process.env.APPLIQATION_SCENARIO_ID) || undefined,
139
- // testSetId: parseInt(process.env.MY_SMOKE_TEST_SET_ID) || undefined,
140
-
141
- // How to resolve a run whose executed tests fall outside the configured
142
- // scope — 'cancel' (default, fail-safe), 'adhoc', or 'filter'.
143
- onScopeMismatch: process.env.APPLIQATION_ON_SCOPE_MISMATCH,
144
- };
150
+ testSetId: 2489,
151
+ }]
145
152
  ```
146
153
 
147
154
  Before the suite runs, the reporter checks every UUID it's about to execute
@@ -156,7 +163,9 @@ write results into the wrong run:
156
163
  | `filter` | Submits only the in-scope results; out-of-scope tests still execute but aren't uploaded. |
157
164
 
158
165
  Outside CI, with an interactive terminal, you're prompted to choose one of
159
- the three before the run starts.
166
+ the three before the run starts. Set the strategy the same way as the
167
+ scope itself — `--appq-on-scope-mismatch=filter` or
168
+ `APPLIQATION_ON_SCOPE_MISMATCH=filter`.
160
169
 
161
170
  ## Authenticated apps (gated SUTs)
162
171
 
@@ -315,24 +324,33 @@ CircleCI, Jenkins, or any other runner.
315
324
 
316
325
  ### Environment variables
317
326
 
318
- | Variable | Required | Description |
319
- |---|---|---|
320
- | `APPLIQATION_API_KEY` | Yes | API key from Project Settings → API Keys |
321
- | `APPLIQATION_PROJECT_KEY` | Yes | Project key from Project Settings |
322
- | `TEST_APP_URL` | Recommended | Your own convention for Playwright's `baseURL` — read it in your `playwright.config.js`, the SDK doesn't read it directly |
323
- | `APPLIQATION_ENVIRONMENT` | No | Environment label for the run (e.g. `Staging`) — also settable via `--appq-env` |
324
- | `APPLIQATION_RUN_TITLE` | No | Custom run title — also settable via `--appq_run_title` |
325
- | `APPLIQATION_RUN_ID` | No | Reuse an existing run instead of creating one (TDD iteration mode) |
326
- | `APPQ_ENABLED` | No | `1`/`true` enables reporting alternative to the `--appq` CLI flag |
327
- | `APPLIQATION_ON_SCOPE_MISMATCH` | No | `cancel` (default) / `adhoc` / `filter` see [Scoping runs](#scoping-runs-scenario-or-test-set) |
328
- | `APPLIQATION_AUTO_TAG_ENABLED` | No | `false` disables auto-tagging (default: enabled). The tag name itself (`Appq_Auto`) is fixed, not configurable see [Auto-tagging](#auto-tagging-test-cases) |
329
- | `APPLIQATION_INSECURE` | No | Set to `allow` to permit `rejectUnauthorized: false` in CI/production — see [Troubleshooting](#tls-certificate-errors) |
330
- | `LOG_LEVEL` | No | `ERROR` / `WARN` / `INFO` (default) / `DEBUG` |
331
-
332
- `scenarioId`/`testSetId` and orphan-run handling (below) are reporter
333
- constructor options, not environment variables read your own env var of
334
- choice into them in `playwright.config.js`, the same way the examples above
335
- do for `scenarioId`.
327
+ Every row below (except `APPLIQATION_API_KEY`/`APPLIQATION_PROJECT_KEY`,
328
+ which have no CLI equivalent — secrets don't belong in shell history or
329
+ `ps` output) also has a matching `--appq-*` CLI flag, at
330
+ **CLI flag > env var > `playwright.config.js` value > built-in default**
331
+ precedence, applied consistently across every one of them:
332
+
333
+ | Variable | CLI flag | Required | Description |
334
+ |---|---|---|---|
335
+ | `APPLIQATION_API_KEY` | | Yes | API key from Project Settings API Keys |
336
+ | `APPLIQATION_PROJECT_KEY` | | Yes | Project key from Project Settings |
337
+ | `TEST_APP_URL` | | Recommended | Your own convention for Playwright's `baseURL` read it in your `playwright.config.js`, the SDK doesn't read it directly |
338
+ | `APPLIQATION_ENVIRONMENT` | `--appq-env` | No | Environment label for the run (e.g. `Staging`) |
339
+ | `APPLIQATION_RUN_TITLE` | `--appq-title` / `--appq_run_title` | No | Custom run title |
340
+ | `APPLIQATION_RUN_ID` | `--appq-run-id` / `--appq_run_id` | No | Reuse an existing run instead of creating one (TDD iteration mode) |
341
+ | `APPQ_ENABLED` | `--appq` | No | `1`/`true` enables reporting |
342
+ | `APPLIQATION_SCENARIO_ID` | `--appq-scenario-id` / `--appq_scenario_id` | No | Link the run to one scenario — see [Scoping runs](#scoping-runs-scenario-or-test-set) |
343
+ | `APPLIQATION_TEST_SET_ID` | `--appq-testset-id` / `--appq_testset_id` | No | Link the run to a Test Set (scenario wins if both are set) |
344
+ | `APPLIQATION_ON_SCOPE_MISMATCH` | `--appq-on-scope-mismatch` / `--appq_on_scope_mismatch` | No | `cancel` (default) / `adhoc` / `filter` |
345
+ | `LOG_LEVEL` | `--appq-log-level` / `--appq_log_level` | No | `ERROR` / `WARN` / `INFO` (default) / `DEBUG` |
346
+ | `APPLIQATION_AUTO_TAG_ENABLED` | — | No | `false` disables auto-tagging (default: enabled). The tag name itself (`Appq_Auto`) is fixed, not configurable — see [Auto-tagging](#auto-tagging-test-cases) |
347
+ | `APPLIQATION_INSECURE` | — | No | Set to `allow` to permit `rejectUnauthorized: false` in CI/production — see [Troubleshooting](#tls-certificate-errors) |
348
+
349
+ `autoCreateRun`, `batchSubmit`, `batchSize`, `logOrphans`,
350
+ `deleteOrphanOnlyRuns`, `failOnOrphanOnlyRuns`, and `rejectUnauthorized`
351
+ are pipeline *policy*, not per-run identity — deliberately config-only,
352
+ not CLI/env-settable, so a stray shell variable can't silently change how
353
+ a project's runs behave.
336
354
 
337
355
  ### Reporter options (`playwright.config.js`)
338
356
 
@@ -340,16 +358,15 @@ do for `scenarioId`.
340
358
  ['@appliqation/automation-sdk/playwright/reporter', {
341
359
  apiKey: process.env.APPLIQATION_API_KEY,
342
360
  projectKey: process.env.APPLIQATION_PROJECT_KEY,
343
- environment: process.env.APPLIQATION_ENVIRONMENT,
344
361
 
345
- scenarioId: parseInt(process.env.APPLIQATION_SCENARIO_ID) || undefined,
346
- onScopeMismatch: process.env.APPLIQATION_ON_SCOPE_MISMATCH,
362
+ // Everything below has a CLI flag + env var too (table above) set
363
+ // here only if a project should default to a fixed value.
364
+ environment: 'Local',
347
365
 
348
366
  autoCreateRun: true, // default: true
349
367
  batchSubmit: true, // default: true
350
368
  batchSize: 50, // results per batch
351
369
  logOrphans: true, // log tests with no mapped UUID
352
- logLevel: 'INFO',
353
370
 
354
371
  deleteOrphanOnlyRuns: true, // delete a run if every test in it was orphaned
355
372
  failOnOrphanOnlyRuns: true, // exit 1 in that case, so CI catches it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appliqation/automation-sdk",
3
- "version": "2.8.1",
3
+ "version": "2.9.0",
4
4
  "description": "Appliqation Automation SDK for Playwright — API-key auth, scope-validated result reporting, portable storageState (setupAuth), and customer-defined login flows (defineLogin) for gated apps",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * TypeScript definitions for @appliqation/automation-sdk
3
- * @version 2.8.1
3
+ * @version 2.9.0
4
4
  */
5
5
 
6
6
  /**
@@ -73,10 +73,19 @@ export interface AppliqationConfig {
73
73
  */
74
74
  password?: string;
75
75
 
76
- /** Scenario ID (optional, 0 for generic automation runs) */
76
+ /**
77
+ * Scenario ID (optional, 0 for generic automation runs). Also settable
78
+ * via `--appq-scenario-id`/`--appq_scenario_id` CLI flag or
79
+ * `APPLIQATION_SCENARIO_ID` env var — CLI > env var > this config value.
80
+ */
77
81
  scenarioId?: number;
78
82
 
79
- /** Test set ID (alternative to scenarioId) */
83
+ /**
84
+ * Test set ID (alternative to scenarioId — scenarioId wins if both are
85
+ * set). Also settable via `--appq-testset-id`/`--appq_testset_id` CLI
86
+ * flag or `APPLIQATION_TEST_SET_ID` env var — CLI > env var > this
87
+ * config value.
88
+ */
80
89
  testSetId?: number;
81
90
 
82
91
  /** Environment name (e.g., 'Local', 'Development', 'Staging', 'Production') */
@@ -58,6 +58,74 @@ function getRunIdFromCli() {
58
58
  return null;
59
59
  }
60
60
 
61
+ /**
62
+ * Extract scenario ID from CLI arguments.
63
+ * Supports: --appq-scenario-id=1154 or --appq_scenario_id=1154
64
+ * @returns {string|null}
65
+ */
66
+ function getScenarioIdFromCli() {
67
+ const argv = process.argv || [];
68
+ for (const arg of argv) {
69
+ if (arg.startsWith('--appq-scenario-id=') || arg.startsWith('--appq_scenario_id=')) {
70
+ let value = arg.substring(arg.indexOf('=') + 1);
71
+ value = value.replace(/^["']|["']$/g, '');
72
+ return value || null;
73
+ }
74
+ }
75
+ return null;
76
+ }
77
+
78
+ /**
79
+ * Extract test set ID from CLI arguments.
80
+ * Supports: --appq-testset-id=2489 or --appq_testset_id=2489
81
+ * @returns {string|null}
82
+ */
83
+ function getTestSetIdFromCli() {
84
+ const argv = process.argv || [];
85
+ for (const arg of argv) {
86
+ if (arg.startsWith('--appq-testset-id=') || arg.startsWith('--appq_testset_id=')) {
87
+ let value = arg.substring(arg.indexOf('=') + 1);
88
+ value = value.replace(/^["']|["']$/g, '');
89
+ return value || null;
90
+ }
91
+ }
92
+ return null;
93
+ }
94
+
95
+ /**
96
+ * Extract scope-mismatch strategy from CLI arguments.
97
+ * Supports: --appq-on-scope-mismatch=filter or --appq_on_scope_mismatch=filter
98
+ * @returns {string|null}
99
+ */
100
+ function getOnScopeMismatchFromCli() {
101
+ const argv = process.argv || [];
102
+ for (const arg of argv) {
103
+ if (arg.startsWith('--appq-on-scope-mismatch=') || arg.startsWith('--appq_on_scope_mismatch=')) {
104
+ let value = arg.substring(arg.indexOf('=') + 1);
105
+ value = value.replace(/^["']|["']$/g, '');
106
+ return value || null;
107
+ }
108
+ }
109
+ return null;
110
+ }
111
+
112
+ /**
113
+ * Extract log level from CLI arguments.
114
+ * Supports: --appq-log-level=DEBUG or --appq_log_level=DEBUG
115
+ * @returns {string|null}
116
+ */
117
+ function getLogLevelFromCli() {
118
+ const argv = process.argv || [];
119
+ for (const arg of argv) {
120
+ if (arg.startsWith('--appq-log-level=') || arg.startsWith('--appq_log_level=')) {
121
+ let value = arg.substring(arg.indexOf('=') + 1);
122
+ value = value.replace(/^["']|["']$/g, '');
123
+ return value || null;
124
+ }
125
+ }
126
+ return null;
127
+ }
128
+
61
129
  /**
62
130
  * Appliqation Reporter for Playwright
63
131
  *
@@ -72,6 +140,25 @@ function getRunIdFromCli() {
72
140
  * ]
73
141
  *
74
142
  * // Run: npx playwright test -- --appq --appq-env=Stage
143
+ *
144
+ * // Scenario/test-set scoping — CLI flag > env var > config, same
145
+ * // precedence as environment/title/runId above. scenarioId wins if
146
+ * // both are set.
147
+ * // Run: npx playwright test -- --appq --appq-scenario-id=1154
148
+ * // Run: npx playwright test -- --appq --appq-testset-id=2489
149
+ * // Or: APPLIQATION_SCENARIO_ID=1154 npx playwright test -- --appq
150
+ * // Or: APPLIQATION_TEST_SET_ID=2489 npx playwright test -- --appq
151
+ *
152
+ * // Scope-mismatch strategy and log level — same CLI > env var > config
153
+ * // precedence throughout.
154
+ * // Run: npx playwright test -- --appq --appq-on-scope-mismatch=filter
155
+ * // Run: npx playwright test -- --appq --appq-log-level=DEBUG
156
+ * // Or: APPLIQATION_ON_SCOPE_MISMATCH=filter npx playwright test -- --appq
157
+ * // Or: LOG_LEVEL=DEBUG npx playwright test -- --appq
158
+ *
159
+ * // apiKey/projectKey/baseUrl are env-var + config only, deliberately no
160
+ * // CLI flag: secrets don't belong in shell history/process listings,
161
+ * // and baseUrl is internal/dev-only (see docs/SETUP.md).
75
162
  */
76
163
  class AppliqationReporter {
77
164
  constructor(config = {}) {
@@ -85,7 +172,6 @@ class AppliqationReporter {
85
172
  logOrphans: true,
86
173
  batchSubmit: true,
87
174
  batchSize: 50,
88
- logLevel: 'info',
89
175
  deleteOrphanOnlyRuns: config.deleteOrphanOnlyRuns !== false,
90
176
  failOnOrphanOnlyRuns: config.failOnOrphanOnlyRuns !== false,
91
177
  ...config
@@ -108,6 +194,39 @@ class AppliqationReporter {
108
194
  // Check for existing run ID (TDD iteration mode)
109
195
  this.existingRunId = this.config.runId || getRunIdFromCli() || process.env.APPLIQATION_RUN_ID || null;
110
196
 
197
+ // Resolve scenarioId: CLI --appq-scenario-id > env var > config
198
+ if (!this.config.scenarioId) {
199
+ const cliScenarioId = getScenarioIdFromCli();
200
+ this.config.scenarioId = parseInt(cliScenarioId, 10)
201
+ || parseInt(process.env.APPLIQATION_SCENARIO_ID, 10)
202
+ || undefined;
203
+ }
204
+
205
+ // Resolve testSetId: CLI --appq-testset-id > env var > config
206
+ if (!this.config.testSetId) {
207
+ const cliTestSetId = getTestSetIdFromCli();
208
+ this.config.testSetId = parseInt(cliTestSetId, 10)
209
+ || parseInt(process.env.APPLIQATION_TEST_SET_ID, 10)
210
+ || undefined;
211
+ }
212
+
213
+ // Resolve onScopeMismatch: CLI --appq-on-scope-mismatch > config.
214
+ // The env var (APPLIQATION_ON_SCOPE_MISMATCH) is read as a further
215
+ // fallback inside ScopeValidator itself — not duplicated here.
216
+ if (!this.config.onScopeMismatch) {
217
+ this.config.onScopeMismatch = getOnScopeMismatchFromCli() || undefined;
218
+ }
219
+
220
+ // Resolve logLevel: CLI --appq-log-level > env var > config > default.
221
+ // Must happen before logger.setLevel() is called below (and again in
222
+ // the AppliqationClient constructor) — LOG_LEVEL is otherwise read
223
+ // once at logger module load and then silently overwritten by
224
+ // whatever this resolves to.
225
+ if (!this.config.logLevel) {
226
+ const cliLogLevel = getLogLevelFromCli();
227
+ this.config.logLevel = cliLogLevel || process.env.LOG_LEVEL || 'info';
228
+ }
229
+
111
230
  // If disabled, stop here — true no-op
112
231
  if (!this.appqEnabled) {
113
232
  this.client = null;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * TypeScript definitions for @appliqation/automation-sdk/playwright
3
- * @version 2.1.0
3
+ * @version 2.9.0
4
4
  */
5
5
 
6
6
  import type {
@@ -22,7 +22,10 @@ import type { AppliqationConfig } from '../../index';
22
22
  * Configuration for the Appliqation Playwright Reporter
23
23
  */
24
24
  export interface AppliqationReporterConfig extends AppliqationConfig {
25
- /** Log level for reporter (default: 'INFO') */
25
+ /**
26
+ * Log level for reporter (default: 'info'). CLI `--appq-log-level` >
27
+ * `LOG_LEVEL` env var > this config value > default.
28
+ */
26
29
  logLevel?: 'ERROR' | 'WARN' | 'INFO' | 'DEBUG';
27
30
 
28
31
  /** Log orphan tests without UUID mappings (default: true) */
@@ -45,16 +48,24 @@ export interface AppliqationReporterConfig extends AppliqationConfig {
45
48
  * reporter: [
46
49
  * ['list'],
47
50
  * [AppliqationReporter, {
48
- * baseUrl: process.env.APPLIQATION_BASE_URL,
51
+ * // baseUrl intentionally omitted — internal/dev-only, defaults to
52
+ * // the real Appliqation instance. Don't set it.
49
53
  * apiKey: process.env.APPLIQATION_API_KEY,
50
54
  * projectKey: process.env.APPLIQATION_PROJECT_KEY,
51
- * scenarioId: 0,
52
55
  * environment: 'Local',
53
- * logLevel: 'INFO'
54
56
  * }]
55
57
  * ]
56
58
  * };
57
59
  * ```
60
+ *
61
+ * @remarks
62
+ * `scenarioId`, `testSetId`, `onScopeMismatch`, and `logLevel` can all be
63
+ * set without touching this config object at all — CLI flag > env var >
64
+ * config value, in that order:
65
+ * - `--appq-scenario-id=1154` / `APPLIQATION_SCENARIO_ID=1154`
66
+ * - `--appq-testset-id=2489` / `APPLIQATION_TEST_SET_ID=2489`
67
+ * - `--appq-on-scope-mismatch=filter` / `APPLIQATION_ON_SCOPE_MISMATCH=filter`
68
+ * - `--appq-log-level=DEBUG` / `LOG_LEVEL=DEBUG`
58
69
  */
59
70
  export class AppliqationReporter implements Reporter {
60
71
  /**