@fasttest-ai/qa-agent 0.1.3 → 0.3.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.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Environment variable substitution for test steps and assertions.
3
+ *
4
+ * Test steps can contain {{VAR_NAME}} placeholders that are resolved from
5
+ * process.env at execution time. This allows suites to be saved with
6
+ * placeholders for credentials, then executed in CI/CD where the actual
7
+ * values are set as GitHub Secrets or environment variables.
8
+ */
9
+ import type { TestStep, TestAssertion } from "./cloud.js";
10
+ /**
11
+ * Replace all {{VAR}} placeholders in a string with values from the environment.
12
+ * Throws if any referenced variable is missing, listing ALL missing names.
13
+ */
14
+ export declare function resolveString(input: string, env?: Record<string, string | undefined>): string;
15
+ /**
16
+ * Resolve {{VAR}} placeholders in a test step's value fields.
17
+ * Returns a new step object — does not mutate the original.
18
+ * Does NOT resolve selectors or descriptions.
19
+ */
20
+ export declare function resolveStepVariables(step: TestStep, env?: Record<string, string | undefined>): TestStep;
21
+ /**
22
+ * Resolve {{VAR}} placeholders in an assertion's value fields.
23
+ * Returns a new assertion object — does not mutate the original.
24
+ */
25
+ export declare function resolveAssertionVariables(assertion: TestAssertion, env?: Record<string, string | undefined>): TestAssertion;
26
+ /**
27
+ * Collect all unique {{VAR}} names referenced across steps and assertions.
28
+ * Used for pre-flight logging and CI YAML generation.
29
+ */
30
+ export declare function collectVariableNames(steps: TestStep[], assertions: TestAssertion[]): string[];
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Environment variable substitution for test steps and assertions.
3
+ *
4
+ * Test steps can contain {{VAR_NAME}} placeholders that are resolved from
5
+ * process.env at execution time. This allows suites to be saved with
6
+ * placeholders for credentials, then executed in CI/CD where the actual
7
+ * values are set as GitHub Secrets or environment variables.
8
+ */
9
+ /** Matches {{UPPER_SNAKE_CASE}} variable placeholders. */
10
+ const VAR_PATTERN = /\{\{([A-Z][A-Z0-9_]*)\}\}/g;
11
+ /**
12
+ * Replace all {{VAR}} placeholders in a string with values from the environment.
13
+ * Throws if any referenced variable is missing, listing ALL missing names.
14
+ */
15
+ export function resolveString(input, env = process.env) {
16
+ const missing = [];
17
+ const resolved = input.replace(VAR_PATTERN, (match, varName) => {
18
+ const value = env[varName];
19
+ if (value === undefined) {
20
+ missing.push(varName);
21
+ return match;
22
+ }
23
+ return value;
24
+ });
25
+ if (missing.length > 0) {
26
+ throw new Error(`Missing environment variable(s): ${missing.join(", ")}. ` +
27
+ `Set these before running tests. In GitHub Actions, add them as repository secrets.`);
28
+ }
29
+ return resolved;
30
+ }
31
+ /**
32
+ * Resolve {{VAR}} placeholders in a test step's value fields.
33
+ * Returns a new step object — does not mutate the original.
34
+ * Does NOT resolve selectors or descriptions.
35
+ */
36
+ export function resolveStepVariables(step, env) {
37
+ const resolved = { ...step };
38
+ if (resolved.value !== undefined)
39
+ resolved.value = resolveString(resolved.value, env);
40
+ if (resolved.url !== undefined)
41
+ resolved.url = resolveString(resolved.url, env);
42
+ if (resolved.expression !== undefined)
43
+ resolved.expression = resolveString(resolved.expression, env);
44
+ if (resolved.key !== undefined)
45
+ resolved.key = resolveString(resolved.key, env);
46
+ if (resolved.fields !== undefined) {
47
+ const resolvedFields = {};
48
+ for (const [selector, val] of Object.entries(resolved.fields)) {
49
+ resolvedFields[selector] = resolveString(val, env);
50
+ }
51
+ resolved.fields = resolvedFields;
52
+ }
53
+ return resolved;
54
+ }
55
+ /**
56
+ * Resolve {{VAR}} placeholders in an assertion's value fields.
57
+ * Returns a new assertion object — does not mutate the original.
58
+ */
59
+ export function resolveAssertionVariables(assertion, env) {
60
+ const resolved = { ...assertion };
61
+ if (resolved.text !== undefined)
62
+ resolved.text = resolveString(resolved.text, env);
63
+ if (resolved.url !== undefined)
64
+ resolved.url = resolveString(resolved.url, env);
65
+ if (resolved.value !== undefined)
66
+ resolved.value = resolveString(resolved.value, env);
67
+ if (resolved.expected_value !== undefined)
68
+ resolved.expected_value = resolveString(resolved.expected_value, env);
69
+ return resolved;
70
+ }
71
+ /**
72
+ * Collect all unique {{VAR}} names referenced across steps and assertions.
73
+ * Used for pre-flight logging and CI YAML generation.
74
+ */
75
+ export function collectVariableNames(steps, assertions) {
76
+ const vars = new Set();
77
+ function scan(input) {
78
+ if (!input)
79
+ return;
80
+ const re = /\{\{([A-Z][A-Z0-9_]*)\}\}/g;
81
+ let match;
82
+ while ((match = re.exec(input)) !== null) {
83
+ vars.add(match[1]);
84
+ }
85
+ }
86
+ for (const step of steps) {
87
+ scan(step.value);
88
+ scan(step.url);
89
+ scan(step.expression);
90
+ scan(step.key);
91
+ if (step.fields) {
92
+ for (const val of Object.values(step.fields))
93
+ scan(val);
94
+ }
95
+ }
96
+ for (const assertion of assertions) {
97
+ scan(assertion.text);
98
+ scan(assertion.url);
99
+ scan(assertion.value);
100
+ scan(assertion.expected_value);
101
+ }
102
+ return Array.from(vars).sort();
103
+ }
104
+ //# sourceMappingURL=variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variables.js","sourceRoot":"","sources":["../src/variables.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,0DAA0D;AAC1D,MAAM,WAAW,GAAG,4BAA4B,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAa,EACb,MAA0C,OAAO,CAAC,GAAG;IAErD,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,OAAe,EAAE,EAAE;QACrE,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,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CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;gBAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AACjC,CAAC"}
package/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "@fasttest-ai/qa-agent",
3
- "version": "0.1.3",
4
- "description": "QA Agent — AI testing engineer MCP server",
3
+ "version": "0.3.0",
4
+ "description": "FastTest Agent — AI testing engineer MCP server",
5
5
  "type": "module",
6
6
  "bin": {
7
- "qa-agent": "bin/qa-agent.js"
7
+ "qa-agent": "bin/qa-agent.js",
8
+ "qa-agent-ci": "bin/qa-agent-ci.js",
9
+ "fasttest": "bin/qa-agent.js",
10
+ "fasttest-ci": "bin/qa-agent-ci.js"
8
11
  },
9
12
  "main": "./dist/index.js",
10
13
  "scripts": {
11
14
  "build": "tsc",
12
15
  "dev": "tsc --watch",
13
- "start": "node dist/index.js"
16
+ "start": "node dist/index.js",
17
+ "ci": "node dist/cli.js"
14
18
  },
15
19
  "dependencies": {
16
20
  "@modelcontextprotocol/sdk": "^1.12.0",