@cementic/cementic-test 0.2.9 → 0.2.11
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 +14 -0
- package/dist/{chunk-XM2TYPU7.js → chunk-RG26I5FB.js} +182 -26
- package/dist/chunk-RG26I5FB.js.map +1 -0
- package/dist/cli.js +20 -2
- package/dist/cli.js.map +1 -1
- package/dist/{gen-EST5UZNZ.js → gen-6Y65IYXO.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-XM2TYPU7.js.map +0 -1
- /package/dist/{gen-EST5UZNZ.js.map → gen-6Y65IYXO.js.map} +0 -0
package/README.md
CHANGED
|
@@ -365,6 +365,20 @@ And start automating.
|
|
|
365
365
|
|
|
366
366
|
## Changelog
|
|
367
367
|
|
|
368
|
+
### v0.2.11
|
|
369
|
+
|
|
370
|
+
- AI no longer writes `'value'` as a step input and now prefers matching `CT_VAR_*` references or `test-{fieldname}` fallbacks
|
|
371
|
+
- fixed `ct gen` so generic fill steps read matching `CT_VAR_*` values from the environment and emit env-backed constants only when they are actually needed
|
|
372
|
+
- fixed generated `toHaveValue(...)` assertions so they reuse the same emitted fill value for selector-backed form fields
|
|
373
|
+
- added a generated spec header comment that lists required `CT_VAR_*` variables with inline usage examples
|
|
374
|
+
- breaking change: none
|
|
375
|
+
|
|
376
|
+
### v0.2.10
|
|
377
|
+
|
|
378
|
+
- fixed `ct gen` so selector-hinted fields like `#username` and `#password` infer matching `CT_VAR_*` constants instead of leaving `.fill('value')` placeholders behind
|
|
379
|
+
- fixed generated `toHaveValue(...)` assertions so they reuse the same `CT_VAR_*` binding when the related fill step was variablized
|
|
380
|
+
- added regression coverage for selector-driven auth generation to keep fill calls and value assertions aligned
|
|
381
|
+
|
|
368
382
|
### v0.2.9
|
|
369
383
|
|
|
370
384
|
- added `CT_VAR_*` extraction in `ct gen` for input and select test data so generated specs use env-backed constants instead of hardcoded values
|
|
@@ -70,6 +70,79 @@ function fieldNameToEnvSuffix(value) {
|
|
|
70
70
|
if (/^(?:FIELD|INPUT|BOX|AREA|DROPDOWN|COMBOBOX|SELECT|MENU)$/.test(suffix)) return void 0;
|
|
71
71
|
return suffix;
|
|
72
72
|
}
|
|
73
|
+
function normalizeSelectorTarget(value) {
|
|
74
|
+
if (!value) return void 0;
|
|
75
|
+
const trimmed = value.trim();
|
|
76
|
+
if (!trimmed) return void 0;
|
|
77
|
+
return trimmed.replace(/^page\./, "").replace(/\s+/g, " ");
|
|
78
|
+
}
|
|
79
|
+
function parseQuotedLiteral(value) {
|
|
80
|
+
if (!value) return void 0;
|
|
81
|
+
const trimmed = value.trim();
|
|
82
|
+
if (trimmed.length < 2) return void 0;
|
|
83
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"')) {
|
|
84
|
+
try {
|
|
85
|
+
return JSON.parse(trimmed);
|
|
86
|
+
} catch {
|
|
87
|
+
return trimmed.slice(1, -1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
91
|
+
return trimmed.slice(1, -1).replace(/\\\\/g, "\\").replace(/\\'/g, "'");
|
|
92
|
+
}
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
function selectorTargetToEnvSuffix(value) {
|
|
96
|
+
const selector = normalizeSelectorTarget(value);
|
|
97
|
+
if (!selector) return void 0;
|
|
98
|
+
const quotedArg = (pattern, group = 2) => {
|
|
99
|
+
const match = selector.match(pattern);
|
|
100
|
+
return match?.[group]?.trim();
|
|
101
|
+
};
|
|
102
|
+
const locatorArg = quotedArg(/^(?:locator)\((['"])(.*?)\1\)/i);
|
|
103
|
+
if (locatorArg) {
|
|
104
|
+
const idMatch = locatorArg.match(/#([A-Za-z][\w-]*)/);
|
|
105
|
+
if (idMatch) return sanitizeEnvSegment(idMatch[1]);
|
|
106
|
+
const attrMatch = locatorArg.match(/\[(?:name|id|data-testid|aria-label)=['"]?([^'"\]]+)['"]?\]/i);
|
|
107
|
+
if (attrMatch) return sanitizeEnvSegment(attrMatch[1]);
|
|
108
|
+
const classMatch = locatorArg.match(/\.([A-Za-z][\w-]*)/);
|
|
109
|
+
if (classMatch) return sanitizeEnvSegment(classMatch[1]);
|
|
110
|
+
return sanitizeEnvSegment(locatorArg.replace(/^[#.]+/, ""));
|
|
111
|
+
}
|
|
112
|
+
const labelArg = quotedArg(/^(?:getByLabel|getByPlaceholder|getByTestId|getByText)\((['"])(.*?)\1/i) ?? quotedArg(/^getByRole\((['"])(?:textbox|searchbox|combobox|spinbutton)\1,\s*\{\s*name:\s*(['"])(.*?)\2/i, 3);
|
|
113
|
+
if (labelArg) return fieldNameToEnvSuffix(labelArg) ?? sanitizeEnvSegment(labelArg);
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
function isGenericFallbackValue(value) {
|
|
117
|
+
if (!value) return true;
|
|
118
|
+
return /^(?:value|text|input|option|selection|selected value|default)$/i.test(value.trim());
|
|
119
|
+
}
|
|
120
|
+
function extractCtVarTemplate(value) {
|
|
121
|
+
const match = value?.trim().match(/^\$\{(CT_VAR_[A-Z0-9_]+)\}$/);
|
|
122
|
+
return match?.[1];
|
|
123
|
+
}
|
|
124
|
+
function placeholderTokenFromSuffix(value) {
|
|
125
|
+
const cleaned = value?.trim().replace(/^CT_VAR_/, "");
|
|
126
|
+
if (!cleaned) return "input";
|
|
127
|
+
return cleaned.toLowerCase().replace(/_+/g, "-");
|
|
128
|
+
}
|
|
129
|
+
function inferFieldToken(rawField, fieldLabel, selectorTarget) {
|
|
130
|
+
const suffix = fieldNameToEnvSuffix(rawField) ?? fieldNameToEnvSuffix(fieldLabel) ?? selectorTargetToEnvSuffix(selectorTarget);
|
|
131
|
+
return placeholderTokenFromSuffix(suffix);
|
|
132
|
+
}
|
|
133
|
+
function buildFillPlaceholder(rawField, fieldLabel, selectorTarget) {
|
|
134
|
+
return `test-${inferFieldToken(rawField, fieldLabel, selectorTarget)}`;
|
|
135
|
+
}
|
|
136
|
+
function resolveLiteralFillValue(binding, selectorTarget) {
|
|
137
|
+
const rawValue = binding.value?.trim();
|
|
138
|
+
if (rawValue && !isGenericFallbackValue(rawValue) && !extractCtVarTemplate(rawValue)) {
|
|
139
|
+
return rawValue;
|
|
140
|
+
}
|
|
141
|
+
return buildFillPlaceholder(binding.rawField, binding.fieldLabel, selectorTarget);
|
|
142
|
+
}
|
|
143
|
+
function exampleValueForEnvKey(envKey) {
|
|
144
|
+
return `your-${placeholderTokenFromSuffix(envKey)}`;
|
|
145
|
+
}
|
|
73
146
|
function parseStepBinding(step) {
|
|
74
147
|
const s = step.trim();
|
|
75
148
|
const fillMatch = s.match(/\b(?:fill|input|write)\s+(?:in\s+)?(.+?)\s+with\s+(['"])(.*?)\2/i);
|
|
@@ -81,6 +154,14 @@ function parseStepBinding(step) {
|
|
|
81
154
|
value: fillMatch[3].trim()
|
|
82
155
|
};
|
|
83
156
|
}
|
|
157
|
+
const fillWithoutValueMatch = s.match(/\b(?:fill|input|write)\s+(?:in\s+)?(.+?)$/i);
|
|
158
|
+
if (fillWithoutValueMatch) {
|
|
159
|
+
return {
|
|
160
|
+
kind: "fill",
|
|
161
|
+
rawField: fillWithoutValueMatch[1].trim(),
|
|
162
|
+
fieldLabel: cleanFieldLabel(fillWithoutValueMatch[1])
|
|
163
|
+
};
|
|
164
|
+
}
|
|
84
165
|
const enterMatch = s.match(/\b(?:enter|type)\s+(['"])(.*?)\1\s+(?:in|into)\s+(.+)/i);
|
|
85
166
|
if (enterMatch) {
|
|
86
167
|
return {
|
|
@@ -90,6 +171,14 @@ function parseStepBinding(step) {
|
|
|
90
171
|
value: enterMatch[2].trim()
|
|
91
172
|
};
|
|
92
173
|
}
|
|
174
|
+
const enterWithoutValueMatch = s.match(/\b(?:enter|type)\s+(?:in|into)\s+(.+)/i);
|
|
175
|
+
if (enterWithoutValueMatch) {
|
|
176
|
+
return {
|
|
177
|
+
kind: "fill",
|
|
178
|
+
rawField: enterWithoutValueMatch[1].trim(),
|
|
179
|
+
fieldLabel: cleanFieldLabel(enterWithoutValueMatch[1])
|
|
180
|
+
};
|
|
181
|
+
}
|
|
93
182
|
const selectMatch = s.match(/\b(?:select|choose|pick)\s+(['"])(.*?)\1\s+(?:from|in|into|on)\s+(.+)/i);
|
|
94
183
|
if (selectMatch) {
|
|
95
184
|
return {
|
|
@@ -99,6 +188,14 @@ function parseStepBinding(step) {
|
|
|
99
188
|
value: selectMatch[2].trim()
|
|
100
189
|
};
|
|
101
190
|
}
|
|
191
|
+
const selectWithoutValueMatch = s.match(/\b(?:select|choose|pick)\s+(.+?)\s+(?:dropdown|combobox|select|menu)\b/i);
|
|
192
|
+
if (selectWithoutValueMatch) {
|
|
193
|
+
return {
|
|
194
|
+
kind: "select",
|
|
195
|
+
rawField: selectWithoutValueMatch[1].trim(),
|
|
196
|
+
fieldLabel: cleanFieldLabel(selectWithoutValueMatch[1])
|
|
197
|
+
};
|
|
198
|
+
}
|
|
102
199
|
return void 0;
|
|
103
200
|
}
|
|
104
201
|
function resolveStepVarOverride(overrides, envKey, keySuffix, rawField, fieldLabel) {
|
|
@@ -110,43 +207,67 @@ function resolveStepVarOverride(overrides, envKey, keySuffix, rawField, fieldLab
|
|
|
110
207
|
}
|
|
111
208
|
return void 0;
|
|
112
209
|
}
|
|
113
|
-
function extractStepVars(steps, overrides) {
|
|
210
|
+
function extractStepVars(steps, stepHints, assertionHints, overrides) {
|
|
114
211
|
const declarations = [];
|
|
115
212
|
const byStepIndex = /* @__PURE__ */ new Map();
|
|
213
|
+
const fillValueBySelector = /* @__PURE__ */ new Map();
|
|
116
214
|
const seen = /* @__PURE__ */ new Map();
|
|
117
215
|
let unnamedFillIndex = 0;
|
|
118
216
|
let unnamedSelectIndex = 0;
|
|
217
|
+
const assertionFallbacks = /* @__PURE__ */ new Map();
|
|
218
|
+
for (const hint of assertionHints ?? []) {
|
|
219
|
+
const parsed = parseValueAssertionHint(hint?.playwright);
|
|
220
|
+
if (!parsed?.expected) continue;
|
|
221
|
+
if (parsed.target) assertionFallbacks.set(parsed.target, parsed.expected);
|
|
222
|
+
const envSuffix = selectorTargetToEnvSuffix(parsed.target);
|
|
223
|
+
if (envSuffix) assertionFallbacks.set(`CT_VAR_${envSuffix}`, parsed.expected);
|
|
224
|
+
}
|
|
119
225
|
for (const [index, step] of steps.entries()) {
|
|
120
226
|
const binding = parseStepBinding(step);
|
|
121
227
|
if (!binding) continue;
|
|
122
|
-
const
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
228
|
+
const selectorTarget = normalizeSelectorTarget(stepHints?.[index]?.selector);
|
|
229
|
+
const keySuffix = fieldNameToEnvSuffix(binding.rawField) ?? fieldNameToEnvSuffix(binding.fieldLabel) ?? selectorTargetToEnvSuffix(selectorTarget) ?? `${binding.kind === "select" ? "SELECT" : "INPUT"}_${binding.kind === "select" ? ++unnamedSelectIndex : ++unnamedFillIndex}`;
|
|
230
|
+
const templateEnvKey = extractCtVarTemplate(binding.value);
|
|
231
|
+
const envKey = templateEnvKey ?? `CT_VAR_${keySuffix}`;
|
|
232
|
+
const assertionFallback = (selectorTarget ? assertionFallbacks.get(selectorTarget) : void 0) ?? assertionFallbacks.get(envKey);
|
|
233
|
+
const overrideValue = resolveStepVarOverride(overrides, envKey, keySuffix, binding.rawField, binding.fieldLabel);
|
|
234
|
+
const fallbackFromBinding = binding.value?.trim();
|
|
235
|
+
const hasRuntimeEnvValue = process.env[envKey] !== void 0;
|
|
236
|
+
const shouldDeclareVariable = binding.kind === "select" || templateEnvKey !== void 0 || overrideValue !== void 0 || hasRuntimeEnvValue;
|
|
237
|
+
let stepVar = shouldDeclareVariable ? seen.get(envKey) : void 0;
|
|
238
|
+
if (shouldDeclareVariable && !stepVar) {
|
|
239
|
+
const fallback = overrideValue ?? process.env[envKey] ?? ((!fallbackFromBinding || isGenericFallbackValue(fallbackFromBinding) || templateEnvKey) && assertionFallback ? assertionFallback : fallbackFromBinding) ?? (binding.kind === "fill" ? buildFillPlaceholder(binding.rawField, binding.fieldLabel, selectorTarget) : assertionFallback ?? "option");
|
|
126
240
|
stepVar = {
|
|
127
241
|
envKey,
|
|
128
242
|
constName: envKey,
|
|
129
|
-
fallback
|
|
243
|
+
fallback,
|
|
244
|
+
selectorHint: stepHints?.[index]?.selector,
|
|
245
|
+
selectorTarget,
|
|
246
|
+
fieldLabel: binding.fieldLabel
|
|
130
247
|
};
|
|
131
248
|
seen.set(envKey, stepVar);
|
|
132
249
|
declarations.push(stepVar);
|
|
133
250
|
}
|
|
134
|
-
byStepIndex.set(index, stepVar);
|
|
251
|
+
if (stepVar) byStepIndex.set(index, stepVar);
|
|
252
|
+
if (binding.kind === "fill" && selectorTarget) {
|
|
253
|
+
const expression = stepVar ? stepVar.constName : `'${escapeForSingleQuotedString(resolveLiteralFillValue(binding, selectorTarget))}'`;
|
|
254
|
+
fillValueBySelector.set(selectorTarget, expression);
|
|
255
|
+
}
|
|
135
256
|
}
|
|
136
|
-
return { declarations, byStepIndex };
|
|
257
|
+
return { declarations, byStepIndex, fillValueBySelector };
|
|
137
258
|
}
|
|
138
259
|
function buildVariableHeaderComment(stepVars) {
|
|
139
260
|
if (stepVars.length === 0) return "";
|
|
140
|
-
const
|
|
261
|
+
const exampleEntries = stepVars.map((stepVar) => `${stepVar.envKey}=${exampleValueForEnvKey(stepVar.envKey)}`);
|
|
141
262
|
return [
|
|
142
|
-
"// Test variables
|
|
143
|
-
"// Set these environment variables before running
|
|
263
|
+
"// \u2500\u2500 Test variables \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
|
|
264
|
+
"// Set these environment variables before running:",
|
|
144
265
|
"//",
|
|
145
|
-
...stepVars.map((stepVar) => `// ${stepVar.envKey}
|
|
266
|
+
...stepVars.map((stepVar) => `// ${stepVar.envKey}=${exampleValueForEnvKey(stepVar.envKey)}`),
|
|
146
267
|
"//",
|
|
147
268
|
"// Or pass them inline:",
|
|
148
|
-
`// ${
|
|
149
|
-
""
|
|
269
|
+
`// ${exampleEntries.join(" ")} npx playwright test`,
|
|
270
|
+
"// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
|
|
150
271
|
].join("\n");
|
|
151
272
|
}
|
|
152
273
|
function buildVariableDeclarations(stepVars) {
|
|
@@ -185,9 +306,32 @@ function ensureStatement(value) {
|
|
|
185
306
|
if (!trimmed) return trimmed;
|
|
186
307
|
return trimmed.endsWith(";") ? trimmed : `${trimmed};`;
|
|
187
308
|
}
|
|
309
|
+
function parseValueAssertionHint(playwright) {
|
|
310
|
+
const statement = ensureStatement(String(playwright ?? "").trim());
|
|
311
|
+
if (!statement) return void 0;
|
|
312
|
+
const match = statement.match(/expect\(([\s\S]+)\)\.toHaveValue\(([\s\S]+)\)\s*;$/);
|
|
313
|
+
if (!match) return void 0;
|
|
314
|
+
return {
|
|
315
|
+
target: normalizeSelectorTarget(match[1]),
|
|
316
|
+
expected: parseQuotedLiteral(match[2])
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function findFillValueExpressionForTarget(target, stepState) {
|
|
320
|
+
const normalizedTarget = normalizeSelectorTarget(target);
|
|
321
|
+
if (!normalizedTarget) return void 0;
|
|
322
|
+
return stepState.fillValueBySelector.get(normalizedTarget);
|
|
323
|
+
}
|
|
324
|
+
function rewriteValueAssertionToUseVariable(playwright, stepState) {
|
|
325
|
+
const parsed = parseValueAssertionHint(playwright);
|
|
326
|
+
if (!parsed?.target) return void 0;
|
|
327
|
+
const valueExpression = findFillValueExpressionForTarget(parsed.target, stepState);
|
|
328
|
+
if (!valueExpression) return void 0;
|
|
329
|
+
return ensureStatement(`await expect(page.${parsed.target}).toHaveValue(${valueExpression})`);
|
|
330
|
+
}
|
|
188
331
|
function stepToPlaywright(step, url, hint, stepVar) {
|
|
189
332
|
const s = step.trim();
|
|
190
333
|
const hintedSelector = hint?.selector ? `page.${hint.selector}` : void 0;
|
|
334
|
+
const selectorTarget = normalizeSelectorTarget(hint?.selector);
|
|
191
335
|
const valueExpression = (value) => stepVar?.constName ?? `'${escapeForSingleQuotedString(value)}'`;
|
|
192
336
|
if (/^(navigate|go to|open|visit|load)/i.test(s)) {
|
|
193
337
|
const urlMatch = s.match(/https?:\/\/[^\s'"]+/) || s.match(/["']([^"']+)["']/);
|
|
@@ -199,9 +343,10 @@ function stepToPlaywright(step, url, hint, stepVar) {
|
|
|
199
343
|
}
|
|
200
344
|
const binding = parseStepBinding(s);
|
|
201
345
|
if (binding?.kind === "fill") {
|
|
202
|
-
|
|
346
|
+
const fallbackValue = stepVar?.fallback ?? resolveLiteralFillValue(binding, selectorTarget);
|
|
347
|
+
if (hintedSelector) return `await ${hintedSelector}.fill(${valueExpression(fallbackValue)});`;
|
|
203
348
|
const field = binding.fieldLabel ?? "field";
|
|
204
|
-
return `await page.getByLabel('${escapeForSingleQuotedString(field)}').fill(${valueExpression(
|
|
349
|
+
return `await page.getByLabel('${escapeForSingleQuotedString(field)}').fill(${valueExpression(fallbackValue)});`;
|
|
205
350
|
}
|
|
206
351
|
if (/\bclick\b.*(button|btn|submit|sign in|log in|login|register|continue|next|save|confirm)/i.test(s)) {
|
|
207
352
|
if (hintedSelector) return `await ${hintedSelector}.click();`;
|
|
@@ -223,11 +368,12 @@ function stepToPlaywright(step, url, hint, stepVar) {
|
|
|
223
368
|
return `await page.getByText('${escapeForSingleQuotedString(target)}').click();`;
|
|
224
369
|
}
|
|
225
370
|
if (binding?.kind === "select") {
|
|
226
|
-
|
|
371
|
+
const fallbackValue = binding.value ?? stepVar?.fallback ?? "option";
|
|
372
|
+
if (hintedSelector) return `await ${hintedSelector}.selectOption(${valueExpression(fallbackValue)});`;
|
|
227
373
|
if (binding.fieldLabel) {
|
|
228
|
-
return `await page.getByLabel('${escapeForSingleQuotedString(binding.fieldLabel)}').selectOption(${valueExpression(
|
|
374
|
+
return `await page.getByLabel('${escapeForSingleQuotedString(binding.fieldLabel)}').selectOption(${valueExpression(fallbackValue)});`;
|
|
229
375
|
}
|
|
230
|
-
return `await page.getByRole('combobox').selectOption(${valueExpression(
|
|
376
|
+
return `await page.getByRole('combobox').selectOption(${valueExpression(fallbackValue)});`;
|
|
231
377
|
}
|
|
232
378
|
if (/\b(uncheck|untick|disable)\b/i.test(s)) {
|
|
233
379
|
if (hintedSelector) return `await ${hintedSelector}.uncheck();`;
|
|
@@ -260,8 +406,11 @@ function stepToPlaywright(step, url, hint, stepVar) {
|
|
|
260
406
|
}
|
|
261
407
|
return `// TODO: map to Playwright action \u2192 "${s}"`;
|
|
262
408
|
}
|
|
263
|
-
function expectedToAssertion(expected, norm, hint) {
|
|
264
|
-
if (hint?.playwright)
|
|
409
|
+
function expectedToAssertion(expected, norm, hint, stepState) {
|
|
410
|
+
if (hint?.playwright) {
|
|
411
|
+
const rewritten = stepState ? rewriteValueAssertionToUseVariable(hint.playwright, stepState) : void 0;
|
|
412
|
+
return rewritten ?? ensureStatement(hint.playwright);
|
|
413
|
+
}
|
|
265
414
|
const s = expected.trim();
|
|
266
415
|
const fieldName = fieldNameFromSentence(s);
|
|
267
416
|
const currentUrlPattern = urlPatternFromAbsoluteUrl(norm?.url);
|
|
@@ -339,7 +488,12 @@ function expectedToAssertion(expected, norm, hint) {
|
|
|
339
488
|
}
|
|
340
489
|
if (/\b(field|input|value|filled)\b/i.test(s)) {
|
|
341
490
|
const valMatch = s.match(/["']([^"']+)["']/);
|
|
342
|
-
if (valMatch)
|
|
491
|
+
if (valMatch) {
|
|
492
|
+
const envSuffix = fieldNameToEnvSuffix(fieldName);
|
|
493
|
+
const stepVar = envSuffix ? stepState?.declarations.find((candidate) => candidate.envKey === `CT_VAR_${envSuffix}`) : void 0;
|
|
494
|
+
if (stepVar) return `await expect(page.getByRole('textbox').first()).toHaveValue(${stepVar.constName});`;
|
|
495
|
+
return `await expect(page.getByRole('textbox').first()).toHaveValue('${escapeForSingleQuotedString(valMatch[1])}');`;
|
|
496
|
+
}
|
|
343
497
|
return `await expect(page.getByRole('textbox').first()).not.toBeEmpty();`;
|
|
344
498
|
}
|
|
345
499
|
if (/\b(text|content|label|message|heading)\b/i.test(s)) {
|
|
@@ -413,21 +567,23 @@ function buildSpecFile(norm, pomClassName, pomImportPath, overrides) {
|
|
|
413
567
|
const title = buildTestTitle(norm);
|
|
414
568
|
const steps = norm.steps ?? [];
|
|
415
569
|
const expected = norm.expected ?? [];
|
|
416
|
-
const stepVars = extractStepVars(steps, overrides);
|
|
570
|
+
const stepVars = extractStepVars(steps, norm.step_hints, norm.assertion_hints, overrides);
|
|
417
571
|
let importPath = pomImportPath.replace(/\\/g, "/");
|
|
418
572
|
if (!importPath.startsWith(".")) importPath = `./${importPath}`;
|
|
419
573
|
importPath = importPath.replace(/\.ts$/, "");
|
|
420
574
|
const stepLines = steps.length ? steps.map((s, index) => ` ${stepToPlaywright(s, norm.url, norm.step_hints?.[index], stepVars.byStepIndex.get(index))}`).join("\n") : " // TODO: add steps";
|
|
421
|
-
const assertionLines = expected.length ? expected.map((e, index) => ` ${expectedToAssertion(e, norm, norm.assertion_hints?.[index])}`).join("\n") : " // TODO: add assertions";
|
|
575
|
+
const assertionLines = expected.length ? expected.map((e, index) => ` ${expectedToAssertion(e, norm, norm.assertion_hints?.[index], stepVars)}`).join("\n") : " // TODO: add assertions";
|
|
422
576
|
const reviewNote = norm.needs_review ? `
|
|
423
577
|
// \u26A0\uFE0F Flagged for review \u2014 steps or assertions may need manual refinement
|
|
424
578
|
` : "";
|
|
425
579
|
const variableHeader = buildVariableHeaderComment(stepVars.declarations);
|
|
580
|
+
const variableHeaderBlock = variableHeader ? `${variableHeader}
|
|
581
|
+
` : "";
|
|
426
582
|
const variableDeclarations = buildVariableDeclarations(stepVars.declarations);
|
|
427
583
|
return `import { test, expect } from '@playwright/test';
|
|
428
584
|
import { ${pomClassName} } from '${importPath}';
|
|
429
585
|
|
|
430
|
-
${
|
|
586
|
+
${variableHeaderBlock}test('${title}', async ({ page }) => {${reviewNote}
|
|
431
587
|
const pomPage = new ${pomClassName}(page);
|
|
432
588
|
|
|
433
589
|
${variableDeclarations} // \u2500\u2500 Setup \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -507,4 +663,4 @@ export {
|
|
|
507
663
|
gen,
|
|
508
664
|
genCmd
|
|
509
665
|
};
|
|
510
|
-
//# sourceMappingURL=chunk-
|
|
666
|
+
//# sourceMappingURL=chunk-RG26I5FB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/gen.ts"],"sourcesContent":["import { Command } from 'commander';\nimport fg from 'fast-glob';\nimport { readFileSync, mkdirSync, writeFileSync, existsSync } from 'node:fs';\nimport { join, basename, relative, resolve } from 'node:path';\n\ntype NormalizedCase = {\n id?: string;\n title: string;\n tags?: string[];\n steps?: string[];\n step_hints?: Array<{ selector?: string }>;\n expected?: string[];\n assertion_hints?: Array<{ playwright?: string }>;\n needs_review?: boolean;\n review_reasons?: string[];\n source?: string;\n url?: string;\n};\n\ntype VarsOverrideMap = Map<string, string>;\n\ntype StepBinding = {\n kind: 'fill' | 'select';\n rawField?: string;\n fieldLabel?: string;\n value?: string;\n};\n\ntype StepVar = {\n envKey: string;\n constName: string;\n fallback: string;\n selectorHint?: string;\n selectorTarget?: string;\n fieldLabel?: string;\n};\n\ntype StepValueState = {\n declarations: StepVar[];\n byStepIndex: Map<number, StepVar>;\n fillValueBySelector: Map<string, string>;\n};\n\nfunction escapeForSingleQuotedString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n}\n\nfunction escapeForRegex(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\\\/]/g, '\\\\$&');\n}\n\nfunction normalizeUrlForComparison(value?: string): string | undefined {\n if (!value) return undefined;\n try {\n return new URL(value).toString().replace(/\\/$/, '');\n } catch {\n return value.trim().replace(/\\/$/, '');\n }\n}\n\nfunction urlPatternFromAbsoluteUrl(value?: string): string | undefined {\n if (!value) return undefined;\n try {\n const parsed = new URL(value);\n const normalizedPath = `${parsed.pathname}${parsed.search}`.replace(/\\/$/, '') || '/';\n if (normalizedPath === '/') return '\\\\/';\n return normalizedPath.replace(/^\\/+/, '').split('/').map(escapeForRegex).join('\\\\/');\n } catch {\n return undefined;\n }\n}\n\nfunction pageNameToUrlPattern(value: string): string | undefined {\n const cleaned = value\n .replace(/\\b(the|a|an|user)\\b/gi, ' ')\n .replace(/\\b(page|screen)\\b/gi, ' ')\n .trim();\n const tokens = cleaned.split(/[\\s/-]+/).map(token => token.trim()).filter(Boolean);\n if (tokens.length === 0) return undefined;\n return tokens.map(token => escapeForRegex(token.toLowerCase())).join('[-_\\\\/]?');\n}\n\nfunction fieldNameFromSentence(value: string): string | undefined {\n const match =\n value.match(/\\bfor\\s+([a-zA-Z][a-zA-Z\\s-]{0,30}?)\\s+field\\b/i) ??\n value.match(/\\b([a-zA-Z][a-zA-Z\\s-]{0,30}?)\\s+field\\b/i) ??\n value.match(/\\b([a-zA-Z][a-zA-Z\\s-]{0,30}?)\\s+input\\b/i);\n return match?.[1]?.trim();\n}\n\nfunction visibleTextRegexFromPhrase(value: string): string {\n const cleaned = value\n .replace(/[\"']/g, '')\n .replace(/\\b(the|a|an|user|should|must|is|are|be|visible|shown|showing|displayed|present|appears?|rendered)\\b/gi, ' ')\n .replace(/\\b(message|text|content|heading|label)\\b/gi, ' ')\n .trim();\n const tokens = cleaned.split(/\\s+/).filter(Boolean);\n if (tokens.length === 0) return '.+';\n return tokens.map(token => escapeForRegex(token)).join('\\\\s+');\n}\n\nfunction sanitizeEnvSegment(value: string): string {\n return value\n .toUpperCase()\n .replace(/[^A-Z0-9]+/g, '_')\n .replace(/_+/g, '_')\n .replace(/^_|_$/g, '');\n}\n\nfunction normalizeOverrideKey(value: string): string {\n return sanitizeEnvSegment(value.replace(/^CT_VAR_/i, ''));\n}\n\nfunction cleanFieldLabel(value?: string): string | undefined {\n if (!value) return undefined;\n const cleaned = value\n .replace(/[.?!,:;]+$/g, '')\n .replace(/^(?:the|a|an)\\s+/i, '')\n .replace(/\\s+(?:field|input|box|area|dropdown|combobox|select|menu)\\b/gi, '')\n .trim();\n return cleaned || undefined;\n}\n\nfunction isPositionalFieldReference(value?: string): boolean {\n if (!value) return false;\n const cleaned = value.trim().toLowerCase();\n return /^(?:(?:the|a|an)\\s+)?(?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|\\d+(?:st|nd|rd|th)?)(?:\\s+\\w+){0,2}\\s+(?:field|input|box|area|dropdown|combobox|select|menu)$/.test(cleaned);\n}\n\nfunction fieldNameToEnvSuffix(value?: string): string | undefined {\n if (!value || isPositionalFieldReference(value)) return undefined;\n const cleaned = value\n .replace(/[.?!,:;]+$/g, '')\n .replace(/^(?:the|a|an)\\s+/i, '')\n .replace(/\\b(?:field|input|box|area|dropdown|combobox|select|menu)\\b/gi, ' ')\n .trim();\n const suffix = sanitizeEnvSegment(cleaned);\n if (!suffix) return undefined;\n if (/^(?:FIELD|INPUT|BOX|AREA|DROPDOWN|COMBOBOX|SELECT|MENU)$/.test(suffix)) return undefined;\n return suffix;\n}\n\nfunction normalizeSelectorTarget(value?: string): string | undefined {\n if (!value) return undefined;\n const trimmed = value.trim();\n if (!trimmed) return undefined;\n return trimmed.replace(/^page\\./, '').replace(/\\s+/g, ' ');\n}\n\nfunction parseQuotedLiteral(value?: string): string | undefined {\n if (!value) return undefined;\n const trimmed = value.trim();\n if (trimmed.length < 2) return undefined;\n\n if (trimmed.startsWith('\"') && trimmed.endsWith('\"')) {\n try {\n return JSON.parse(trimmed);\n } catch {\n return trimmed.slice(1, -1);\n }\n }\n\n if (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\")) {\n return trimmed\n .slice(1, -1)\n .replace(/\\\\\\\\/g, '\\\\')\n .replace(/\\\\'/g, \"'\");\n }\n\n return undefined;\n}\n\nfunction selectorTargetToEnvSuffix(value?: string): string | undefined {\n const selector = normalizeSelectorTarget(value);\n if (!selector) return undefined;\n\n const quotedArg = (pattern: RegExp, group = 2): string | undefined => {\n const match = selector.match(pattern);\n return match?.[group]?.trim();\n };\n\n const locatorArg = quotedArg(/^(?:locator)\\((['\"])(.*?)\\1\\)/i);\n if (locatorArg) {\n const idMatch = locatorArg.match(/#([A-Za-z][\\w-]*)/);\n if (idMatch) return sanitizeEnvSegment(idMatch[1]);\n\n const attrMatch = locatorArg.match(/\\[(?:name|id|data-testid|aria-label)=['\"]?([^'\"\\]]+)['\"]?\\]/i);\n if (attrMatch) return sanitizeEnvSegment(attrMatch[1]);\n\n const classMatch = locatorArg.match(/\\.([A-Za-z][\\w-]*)/);\n if (classMatch) return sanitizeEnvSegment(classMatch[1]);\n\n return sanitizeEnvSegment(locatorArg.replace(/^[#.]+/, ''));\n }\n\n const labelArg =\n quotedArg(/^(?:getByLabel|getByPlaceholder|getByTestId|getByText)\\((['\"])(.*?)\\1/i) ??\n quotedArg(/^getByRole\\((['\"])(?:textbox|searchbox|combobox|spinbutton)\\1,\\s*\\{\\s*name:\\s*(['\"])(.*?)\\2/i, 3);\n if (labelArg) return fieldNameToEnvSuffix(labelArg) ?? sanitizeEnvSegment(labelArg);\n\n return undefined;\n}\n\nfunction isGenericFallbackValue(value?: string): boolean {\n if (!value) return true;\n return /^(?:value|text|input|option|selection|selected value|default)$/i.test(value.trim());\n}\n\nfunction extractCtVarTemplate(value?: string): string | undefined {\n const match = value?.trim().match(/^\\$\\{(CT_VAR_[A-Z0-9_]+)\\}$/);\n return match?.[1];\n}\n\nfunction placeholderTokenFromSuffix(value?: string): string {\n const cleaned = value?.trim().replace(/^CT_VAR_/, '');\n if (!cleaned) return 'input';\n return cleaned.toLowerCase().replace(/_+/g, '-');\n}\n\nfunction inferFieldToken(rawField?: string, fieldLabel?: string, selectorTarget?: string): string {\n const suffix =\n fieldNameToEnvSuffix(rawField) ??\n fieldNameToEnvSuffix(fieldLabel) ??\n selectorTargetToEnvSuffix(selectorTarget);\n return placeholderTokenFromSuffix(suffix);\n}\n\nfunction buildFillPlaceholder(\n rawField?: string,\n fieldLabel?: string,\n selectorTarget?: string,\n): string {\n return `test-${inferFieldToken(rawField, fieldLabel, selectorTarget)}`;\n}\n\nfunction resolveLiteralFillValue(binding: StepBinding, selectorTarget?: string): string {\n const rawValue = binding.value?.trim();\n if (rawValue && !isGenericFallbackValue(rawValue) && !extractCtVarTemplate(rawValue)) {\n return rawValue;\n }\n return buildFillPlaceholder(binding.rawField, binding.fieldLabel, selectorTarget);\n}\n\nfunction exampleValueForEnvKey(envKey: string): string {\n return `your-${placeholderTokenFromSuffix(envKey)}`;\n}\n\nfunction parseStepBinding(step: string): StepBinding | undefined {\n const s = step.trim();\n\n const fillMatch = s.match(/\\b(?:fill|input|write)\\s+(?:in\\s+)?(.+?)\\s+with\\s+(['\"])(.*?)\\2/i);\n if (fillMatch) {\n return {\n kind: 'fill',\n rawField: fillMatch[1].trim(),\n fieldLabel: cleanFieldLabel(fillMatch[1]),\n value: fillMatch[3].trim(),\n };\n }\n\n const fillWithoutValueMatch = s.match(/\\b(?:fill|input|write)\\s+(?:in\\s+)?(.+?)$/i);\n if (fillWithoutValueMatch) {\n return {\n kind: 'fill',\n rawField: fillWithoutValueMatch[1].trim(),\n fieldLabel: cleanFieldLabel(fillWithoutValueMatch[1]),\n };\n }\n\n const enterMatch = s.match(/\\b(?:enter|type)\\s+(['\"])(.*?)\\1\\s+(?:in|into)\\s+(.+)/i);\n if (enterMatch) {\n return {\n kind: 'fill',\n rawField: enterMatch[3].trim(),\n fieldLabel: cleanFieldLabel(enterMatch[3]),\n value: enterMatch[2].trim(),\n };\n }\n\n const enterWithoutValueMatch = s.match(/\\b(?:enter|type)\\s+(?:in|into)\\s+(.+)/i);\n if (enterWithoutValueMatch) {\n return {\n kind: 'fill',\n rawField: enterWithoutValueMatch[1].trim(),\n fieldLabel: cleanFieldLabel(enterWithoutValueMatch[1]),\n };\n }\n\n const selectMatch = s.match(/\\b(?:select|choose|pick)\\s+(['\"])(.*?)\\1\\s+(?:from|in|into|on)\\s+(.+)/i);\n if (selectMatch) {\n return {\n kind: 'select',\n rawField: selectMatch[3].trim(),\n fieldLabel: cleanFieldLabel(selectMatch[3]),\n value: selectMatch[2].trim(),\n };\n }\n\n const selectWithoutValueMatch = s.match(/\\b(?:select|choose|pick)\\s+(.+?)\\s+(?:dropdown|combobox|select|menu)\\b/i);\n if (selectWithoutValueMatch) {\n return {\n kind: 'select',\n rawField: selectWithoutValueMatch[1].trim(),\n fieldLabel: cleanFieldLabel(selectWithoutValueMatch[1]),\n };\n }\n\n return undefined;\n}\n\nfunction resolveStepVarOverride(\n overrides: VarsOverrideMap,\n envKey: string,\n keySuffix: string,\n rawField?: string,\n fieldLabel?: string,\n): string | undefined {\n const candidates = [envKey, keySuffix, rawField, fieldLabel];\n for (const candidate of candidates) {\n if (!candidate) continue;\n const normalized = normalizeOverrideKey(candidate);\n if (normalized && overrides.has(normalized)) return overrides.get(normalized);\n }\n return undefined;\n}\n\nfunction extractStepVars(\n steps: string[],\n stepHints: Array<{ selector?: string }> | undefined,\n assertionHints: Array<{ playwright?: string }> | undefined,\n overrides: VarsOverrideMap,\n): StepValueState {\n const declarations: StepVar[] = [];\n const byStepIndex = new Map<number, StepVar>();\n const fillValueBySelector = new Map<string, string>();\n const seen = new Map<string, StepVar>();\n let unnamedFillIndex = 0;\n let unnamedSelectIndex = 0;\n\n const assertionFallbacks = new Map<string, string>();\n for (const hint of assertionHints ?? []) {\n const parsed = parseValueAssertionHint(hint?.playwright);\n if (!parsed?.expected) continue;\n if (parsed.target) assertionFallbacks.set(parsed.target, parsed.expected);\n const envSuffix = selectorTargetToEnvSuffix(parsed.target);\n if (envSuffix) assertionFallbacks.set(`CT_VAR_${envSuffix}`, parsed.expected);\n }\n\n for (const [index, step] of steps.entries()) {\n const binding = parseStepBinding(step);\n if (!binding) continue;\n\n const selectorTarget = normalizeSelectorTarget(stepHints?.[index]?.selector);\n const keySuffix =\n fieldNameToEnvSuffix(binding.rawField) ??\n fieldNameToEnvSuffix(binding.fieldLabel) ??\n selectorTargetToEnvSuffix(selectorTarget) ??\n `${binding.kind === 'select' ? 'SELECT' : 'INPUT'}_${binding.kind === 'select' ? ++unnamedSelectIndex : ++unnamedFillIndex}`;\n const templateEnvKey = extractCtVarTemplate(binding.value);\n const envKey = templateEnvKey ?? `CT_VAR_${keySuffix}`;\n const assertionFallback =\n (selectorTarget ? assertionFallbacks.get(selectorTarget) : undefined) ??\n assertionFallbacks.get(envKey);\n const overrideValue = resolveStepVarOverride(overrides, envKey, keySuffix, binding.rawField, binding.fieldLabel);\n const fallbackFromBinding = binding.value?.trim();\n const hasRuntimeEnvValue = process.env[envKey] !== undefined;\n const shouldDeclareVariable =\n binding.kind === 'select' ||\n templateEnvKey !== undefined ||\n overrideValue !== undefined ||\n hasRuntimeEnvValue;\n\n let stepVar = shouldDeclareVariable ? seen.get(envKey) : undefined;\n if (shouldDeclareVariable && !stepVar) {\n const fallback =\n overrideValue ??\n process.env[envKey] ??\n ((!fallbackFromBinding || isGenericFallbackValue(fallbackFromBinding) || templateEnvKey) && assertionFallback\n ? assertionFallback\n : fallbackFromBinding) ??\n (binding.kind === 'fill'\n ? buildFillPlaceholder(binding.rawField, binding.fieldLabel, selectorTarget)\n : assertionFallback ?? 'option');\n\n stepVar = {\n envKey,\n constName: envKey,\n fallback,\n selectorHint: stepHints?.[index]?.selector,\n selectorTarget,\n fieldLabel: binding.fieldLabel,\n };\n seen.set(envKey, stepVar);\n declarations.push(stepVar);\n }\n\n if (stepVar) byStepIndex.set(index, stepVar);\n if (binding.kind === 'fill' && selectorTarget) {\n const expression = stepVar\n ? stepVar.constName\n : `'${escapeForSingleQuotedString(resolveLiteralFillValue(binding, selectorTarget))}'`;\n fillValueBySelector.set(selectorTarget, expression);\n }\n }\n\n return { declarations, byStepIndex, fillValueBySelector };\n}\n\nfunction buildVariableHeaderComment(stepVars: StepVar[]): string {\n if (stepVars.length === 0) return '';\n const exampleEntries = stepVars.map((stepVar) => `${stepVar.envKey}=${exampleValueForEnvKey(stepVar.envKey)}`);\n return [\n '// ── Test variables ────────────────────────────────────────────────────────────',\n '// Set these environment variables before running:',\n '//',\n ...stepVars.map((stepVar) => `// ${stepVar.envKey}=${exampleValueForEnvKey(stepVar.envKey)}`),\n '//',\n '// Or pass them inline:',\n `// ${exampleEntries.join(' ')} npx playwright test`,\n '// ─────────────────────────────────────────────────────────────────────────────',\n ].join('\\n');\n}\n\nfunction buildVariableDeclarations(stepVars: StepVar[]): string {\n if (stepVars.length === 0) return '';\n return [\n ' // Test variables',\n ...stepVars.map(\n stepVar =>\n ` const ${stepVar.constName} = process.env['${stepVar.envKey}'] ?? '${escapeForSingleQuotedString(stepVar.fallback)}';`,\n ),\n '',\n ].join('\\n');\n}\n\nfunction parseVarsOverride(raw?: string): VarsOverrideMap {\n if (!raw) return new Map();\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n console.error('❌ --vars must be a valid JSON object');\n process.exit(1);\n }\n\n if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n console.error('❌ --vars must be a valid JSON object');\n process.exit(1);\n }\n\n const overrides = new Map<string, string>();\n for (const [key, value] of Object.entries(parsed)) {\n const normalizedKey = normalizeOverrideKey(key);\n if (!normalizedKey) continue;\n overrides.set(normalizedKey, String(value));\n }\n return overrides;\n}\n\n// ─── Step → Playwright action ─────────────────────────────────────────────────\n\nfunction ensureStatement(value: string): string {\n const trimmed = value.trim();\n if (!trimmed) return trimmed;\n return trimmed.endsWith(';') ? trimmed : `${trimmed};`;\n}\n\nfunction parseValueAssertionHint(playwright?: string): { target?: string; expected?: string } | undefined {\n const statement = ensureStatement(String(playwright ?? '').trim());\n if (!statement) return undefined;\n\n const match = statement.match(/expect\\(([\\s\\S]+)\\)\\.toHaveValue\\(([\\s\\S]+)\\)\\s*;$/);\n if (!match) return undefined;\n\n return {\n target: normalizeSelectorTarget(match[1]),\n expected: parseQuotedLiteral(match[2]),\n };\n}\n\nfunction findFillValueExpressionForTarget(\n target: string | undefined,\n stepState: StepValueState,\n): string | undefined {\n const normalizedTarget = normalizeSelectorTarget(target);\n if (!normalizedTarget) return undefined;\n\n return stepState.fillValueBySelector.get(normalizedTarget);\n}\n\nfunction rewriteValueAssertionToUseVariable(\n playwright: string,\n stepState: StepValueState,\n): string | undefined {\n const parsed = parseValueAssertionHint(playwright);\n if (!parsed?.target) return undefined;\n\n const valueExpression = findFillValueExpressionForTarget(parsed.target, stepState);\n if (!valueExpression) return undefined;\n\n return ensureStatement(`await expect(page.${parsed.target}).toHaveValue(${valueExpression})`);\n}\n\nfunction stepToPlaywright(\n step: string,\n url?: string,\n hint?: { selector?: string },\n stepVar?: StepVar,\n): string {\n const s = step.trim();\n const hintedSelector = hint?.selector ? `page.${hint.selector}` : undefined;\n const selectorTarget = normalizeSelectorTarget(hint?.selector);\n const valueExpression = (value: string): string =>\n stepVar?.constName ?? `'${escapeForSingleQuotedString(value)}'`;\n\n // Navigate\n if (/^(navigate|go to|open|visit|load)/i.test(s)) {\n const urlMatch = s.match(/https?:\\/\\/[^\\s'\"]+/) || s.match(/[\"']([^\"']+)[\"']/);\n const dest = urlMatch?.[1] ?? urlMatch?.[0] ?? url ?? '/';\n if (\n normalizeUrlForComparison(dest) &&\n normalizeUrlForComparison(dest) === normalizeUrlForComparison(url)\n ) {\n return `// navigation handled by pomPage.goto()`;\n }\n return `await page.goto('${escapeForSingleQuotedString(dest)}');`;\n }\n\n // Fill / type / enter into a field\n // Pattern: \"Fill in <field> with '<value>'\" or \"Enter '<value>' in <field>\"\n const binding = parseStepBinding(s);\n if (binding?.kind === 'fill') {\n const fallbackValue = stepVar?.fallback ?? resolveLiteralFillValue(binding, selectorTarget);\n if (hintedSelector) return `await ${hintedSelector}.fill(${valueExpression(fallbackValue)});`;\n const field = binding.fieldLabel ?? 'field';\n return `await page.getByLabel('${escapeForSingleQuotedString(field)}').fill(${valueExpression(fallbackValue)});`;\n }\n\n // Click a button\n if (/\\bclick\\b.*(button|btn|submit|sign in|log in|login|register|continue|next|save|confirm)/i.test(s)) {\n if (hintedSelector) return `await ${hintedSelector}.click();`;\n const nameMatch = s.match(/[\"']([^\"']+)[\"']/);\n const name = nameMatch?.[1] ?? s.replace(/click\\s+(the\\s+)?/i, '').trim();\n return `await page.getByRole('button', { name: '${escapeForSingleQuotedString(name)}' }).click();`;\n }\n\n // Click a link\n if (/\\bclick\\b.*(link|anchor|nav)/i.test(s)) {\n if (hintedSelector) return `await ${hintedSelector}.click();`;\n const nameMatch = s.match(/[\"']([^\"']+)[\"']/);\n const name = nameMatch?.[1] ?? s.replace(/click\\s+(the\\s+)?/i, '').trim();\n return `await page.getByRole('link', { name: '${escapeForSingleQuotedString(name)}' }).click();`;\n }\n\n // Generic click\n if (/^(click|press|tap)\\b/i.test(s)) {\n if (hintedSelector) return `await ${hintedSelector}.click();`;\n const nameMatch = s.match(/[\"']([^\"']+)[\"']/);\n if (nameMatch) return `await page.getByText('${escapeForSingleQuotedString(nameMatch[1])}').click();`;\n const target = s.replace(/^(click|press|tap)\\s+(on\\s+)?/i, '').trim();\n return `await page.getByText('${escapeForSingleQuotedString(target)}').click();`;\n }\n\n // Select dropdown\n if (binding?.kind === 'select') {\n const fallbackValue = binding.value ?? stepVar?.fallback ?? 'option';\n if (hintedSelector) return `await ${hintedSelector}.selectOption(${valueExpression(fallbackValue)});`;\n if (binding.fieldLabel) {\n return `await page.getByLabel('${escapeForSingleQuotedString(binding.fieldLabel)}').selectOption(${valueExpression(fallbackValue)});`;\n }\n return `await page.getByRole('combobox').selectOption(${valueExpression(fallbackValue)});`;\n }\n\n // Check / uncheck\n if (/\\b(uncheck|untick|disable)\\b/i.test(s)) {\n if (hintedSelector) return `await ${hintedSelector}.uncheck();`;\n const nameMatch = s.match(/[\"']([^\"']+)[\"']/);\n const name = nameMatch?.[1] ?? s.replace(/uncheck|untick|disable/gi, '').trim();\n return `await page.getByLabel('${escapeForSingleQuotedString(name)}').uncheck();`;\n }\n if (/\\b(check|tick|enable)\\b/i.test(s)) {\n if (hintedSelector) return `await ${hintedSelector}.check();`;\n const nameMatch = s.match(/[\"']([^\"']+)[\"']/);\n const name = nameMatch?.[1] ?? s.replace(/check|tick|enable/gi, '').trim();\n return `await page.getByLabel('${escapeForSingleQuotedString(name)}').check();`;\n }\n\n // Keyboard key\n if (/press.*(enter|tab|escape|esc|space|backspace)/i.test(s)) {\n const keyMatch = s.match(/enter|tab|escape|esc|space|backspace/i);\n const key = (keyMatch?.[0] ?? 'Enter');\n return `await page.keyboard.press('${key.charAt(0).toUpperCase() + key.slice(1).toLowerCase()}');`;\n }\n\n // Reload\n if (/\\b(reload|refresh)\\b/i.test(s)) {\n return `await page.reload();`;\n }\n\n // Hover\n if (/\\bhover\\b/i.test(s)) {\n if (hintedSelector) return `await ${hintedSelector}.hover();`;\n const nameMatch = s.match(/[\"']([^\"']+)[\"']/);\n const name = nameMatch?.[1] ?? s.replace(/hover\\s+(over\\s+)?/i, '').trim();\n return `await page.getByText('${escapeForSingleQuotedString(name)}').hover();`;\n }\n\n // Scroll\n if (/\\bscroll\\b/i.test(s)) {\n return `await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));`;\n }\n\n // Fallback — preserve the step as a comment so the file is still valid\n return `// TODO: map to Playwright action → \"${s}\"`;\n}\n\n// ─── Expected result → assertion ──────────────────────────────────────────────\n\nfunction expectedToAssertion(\n expected: string,\n norm?: NormalizedCase,\n hint?: { playwright?: string },\n stepState?: StepValueState,\n): string {\n if (hint?.playwright) {\n const rewritten = stepState ? rewriteValueAssertionToUseVariable(hint.playwright, stepState) : undefined;\n return rewritten ?? ensureStatement(hint.playwright);\n }\n const s = expected.trim();\n const fieldName = fieldNameFromSentence(s);\n const currentUrlPattern = urlPatternFromAbsoluteUrl(norm?.url);\n\n // Cleared / empty field\n if (/\\b(clear|cleared|empty|blank)\\b/i.test(s) && /\\b(field|input|value)\\b/i.test(s) && fieldName) {\n return `await expect(page.getByLabel('${escapeForSingleQuotedString(fieldName)}')).toHaveValue('');`;\n }\n\n // Stayed on the same page / did not submit\n if (/\\bform\\b.*\\b(?:does not submit|doesn't submit|not submit|not submitted)\\b/i.test(s)) {\n const fallbackPattern = currentUrlPattern || 'login';\n return `await expect(page).toHaveURL(/${fallbackPattern}/); // form did not navigate`;\n }\n if (/\\b(remains?|stays?|still)\\s+on\\b/i.test(s)) {\n const pageMatch = s.match(/\\b(?:remains?|stays?|still)\\s+on\\s+(?:the\\s+)?(.+?)(?:\\s+page|\\s+screen)?$/i);\n const pagePattern = pageMatch?.[1] ? pageNameToUrlPattern(pageMatch[1]) : undefined;\n return `await expect(page).toHaveURL(/${pagePattern || currentUrlPattern || 'login'}/);`;\n }\n\n // URL / redirect check\n if (/\\b(url|redirect(?:s|ed)?|navigate(?:s|d)?|route|path)\\b/i.test(s)) {\n const pathMatch =\n s.match(/[\"'](\\/[^\"']+)[\"']/) ??\n s.match(/to\\s+(\\/[\\w/-]+)/i) ??\n s.match(/https?:\\/\\/[^\\s'\"]+/i);\n const matchedPath = pathMatch?.[1] ?? pathMatch?.[0];\n if (matchedPath) {\n const fromUrl = matchedPath.startsWith('http') ? urlPatternFromAbsoluteUrl(matchedPath) : undefined;\n const directPath = matchedPath.startsWith('/') ? matchedPath.replace(/^\\/+/, '').split('/').map(escapeForRegex).join('\\\\/') : undefined;\n const finalPattern = fromUrl ?? directPath ?? currentUrlPattern;\n if (finalPattern !== undefined) return `await expect(page).toHaveURL(/${finalPattern}/);`;\n }\n return `await expect(page).toHaveURL(/dashboard|success|home/);`;\n }\n\n // Page title\n if (/\\bpage title\\b|\\btitle should\\b|\\bdocument title\\b/i.test(s)) {\n const titleMatch = s.match(/[\"']([^\"']+)[\"']/);\n if (titleMatch) return `await expect(page).toHaveTitle('${escapeForSingleQuotedString(titleMatch[1])}');`;\n return `await expect(page).toHaveTitle(/.+/);`;\n }\n\n // Error / validation message\n if (/\\b(error|invalid|fail|incorrect|required|validation)\\b/i.test(s)) {\n const msgMatch = s.match(/[\"']([^\"']+)[\"']/);\n if (msgMatch) return `await expect(page.getByText('${escapeForSingleQuotedString(msgMatch[1])}')).toBeVisible();`;\n if (fieldName) return `await expect(page.getByText(/${escapeForRegex(fieldName)}/i)).toBeVisible();`;\n return `await expect(page.getByRole('alert')).toBeVisible();`;\n }\n\n // Success / confirmation\n if (/\\b(success|confirm|complete|thank|welcome|sent|saved)\\b/i.test(s)) {\n const msgMatch = s.match(/[\"']([^\"']+)[\"']/);\n if (msgMatch) return `await expect(page.getByText('${escapeForSingleQuotedString(msgMatch[1])}')).toBeVisible();`;\n if (/\\bwelcome\\b/i.test(s)) return `await expect(page.getByText(/welcome/i)).toBeVisible();`;\n return `await expect(page.getByRole('status')).toBeVisible();`;\n }\n\n // Not visible / hidden\n if (/\\b(not visible|hidden|disappear|removed|gone)\\b/i.test(s)) {\n const elementMatch = s.match(/[\"']([^\"']+)[\"']/);\n if (elementMatch) return `await expect(page.getByText('${escapeForSingleQuotedString(elementMatch[1])}')).not.toBeVisible();`;\n return `await expect(page.locator('.modal, [role=\"dialog\"]').first()).not.toBeVisible();`;\n }\n\n // Visible / present\n if (/\\b(visible|appear|display|show|render|present)\\b/i.test(s)) {\n const elementMatch = s.match(/[\"']([^\"']+)[\"']/);\n if (elementMatch) return `await expect(page.getByText('${escapeForSingleQuotedString(elementMatch[1])}')).toBeVisible();`;\n const subjectMatch =\n s.match(/^(?:the\\s+)?(.+?)\\s+(?:is|are|should|must|becomes?|appears?|renders?|shows?|displays?)\\b/i) ??\n s.match(/^(?:the\\s+)?(.+?)\\s+(?:visible|present)\\b/i);\n const subject = subjectMatch?.[1]?.trim();\n if (subject) {\n if (/\\bnavigation\\b.*\\bmenu\\b|\\bmenu\\b.*\\bnavigation\\b|\\bnavigation\\b/i.test(subject)) {\n return `await expect(page.getByRole('navigation')).toBeVisible();`;\n }\n return `await expect(page.getByText(/${visibleTextRegexFromPhrase(subject)}/i)).toBeVisible();`;\n }\n return `await expect(page.locator('[data-testid]').first()).toBeVisible();`;\n }\n\n // Count of items\n if (/\\b(count|number of|list of|\\d+\\s+item)\\b/i.test(s)) {\n const countMatch = s.match(/(\\d+)/);\n if (countMatch) return `await expect(page.locator('li, tr, [role=\"listitem\"]')).toHaveCount(${countMatch[1]});`;\n return `await expect(page.locator('li, tr').first()).toBeVisible();`;\n }\n\n // Enabled / disabled\n if (/\\b(enabled|clickable|active)\\b/i.test(s)) {\n return `await expect(page.getByRole('button').first()).toBeEnabled();`;\n }\n if (/\\b(disabled|inactive)\\b/i.test(s)) {\n return `await expect(page.getByRole('button').first()).toBeDisabled();`;\n }\n\n // Input value\n if (/\\b(clear|cleared|empty|blank)\\b/i.test(s) && /\\b(field|input|value)\\b/i.test(s)) {\n return `await expect(page.getByRole('textbox').first()).toHaveValue('');`;\n }\n if (/\\b(field|input|value|filled)\\b/i.test(s)) {\n const valMatch = s.match(/[\"']([^\"']+)[\"']/);\n if (valMatch) {\n const envSuffix = fieldNameToEnvSuffix(fieldName);\n const stepVar = envSuffix ? stepState?.declarations.find(candidate => candidate.envKey === `CT_VAR_${envSuffix}`) : undefined;\n if (stepVar) return `await expect(page.getByRole('textbox').first()).toHaveValue(${stepVar.constName});`;\n return `await expect(page.getByRole('textbox').first()).toHaveValue('${escapeForSingleQuotedString(valMatch[1])}');`;\n }\n return `await expect(page.getByRole('textbox').first()).not.toBeEmpty();`;\n }\n\n // Text / heading / content (broad fallback before final fallback)\n if (/\\b(text|content|label|message|heading)\\b/i.test(s)) {\n const textMatch = s.match(/[\"']([^\"']+)[\"']/);\n if (textMatch) return `await expect(page.getByText('${escapeForSingleQuotedString(textMatch[1])}')).toBeVisible();`;\n const words = s.replace(/\\b(the|should|must|contain|display|show|have|text|content)\\b/gi, '').trim();\n return `await expect(page.getByText(/${visibleTextRegexFromPhrase(words)}/i)).toBeVisible();`;\n }\n\n // Final fallback\n const cleaned = s.replace(/[\"']/g, '').trim();\n return `await expect(page.getByText(/${visibleTextRegexFromPhrase(cleaned)}/i)).toBeVisible(); // TODO: refine assertion`;\n}\n\n// ─── POM class name / filename ────────────────────────────────────────────────\n\nfunction toIdentifier(value: string, fallback = 'Landing'): string {\n const tokens = value\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .split(/[^a-zA-Z0-9_]+/)\n .filter(Boolean);\n\n const identifier = tokens\n .map((token) => token.charAt(0).toUpperCase() + token.slice(1))\n .join('');\n\n if (!identifier) return fallback;\n return /^[0-9]/.test(identifier) ? `Case${identifier}` : identifier;\n}\n\nfunction derivePomClassName(norm: NormalizedCase): string {\n const raw = norm.id ?? norm.title ?? 'Landing';\n const withoutNum = raw.replace(/-\\d+$/, '');\n return `${toIdentifier(withoutNum)}Page`;\n}\n\n// ─── POM class source ─────────────────────────────────────────────────────────\n\nfunction buildPomClass(className: string, norm: NormalizedCase, lang: 'ts' | 'js'): string {\n const pageUrl = norm.url ?? '/';\n const isTs = lang === 'ts';\n\n return isTs\n ? `import { Page } from '@playwright/test';\n\nexport class ${className} {\n readonly page: Page;\n\n constructor(page: Page) {\n this.page = page;\n }\n\n async goto(): Promise<void> {\n await this.page.goto('${escapeForSingleQuotedString(pageUrl)}');\n }\n\n async waitForLoad(): Promise<void> {\n await this.page.waitForLoadState('domcontentloaded');\n }\n}\n`\n : `// @ts-check\nexport class ${className} {\n /** @param {import('@playwright/test').Page} page */\n constructor(page) {\n /** @type {import('@playwright/test').Page} */\n this.page = page;\n }\n\n async goto() {\n await this.page.goto('${escapeForSingleQuotedString(pageUrl)}');\n }\n\n async waitForLoad() {\n await this.page.waitForLoadState('domcontentloaded');\n }\n}\n`;\n}\n\n// ─── Spec file source ─────────────────────────────────────────────────────────\n\nfunction buildTestTitle(norm: NormalizedCase): string {\n const idPart = norm.id ?? '';\n\n // norm.title may already include the ID prefix (e.g. \"AUTH-001 — User can log in\")\n // Strip it to avoid \"AUTH-001 — AUTH-001 — User can log in\" in the test name.\n let cleanTitle = norm.title || 'Untitled';\n if (idPart && cleanTitle.startsWith(idPart)) {\n cleanTitle = cleanTitle.slice(idPart.length).replace(/^\\s*[—\\-–]+\\s*/, '').trim();\n }\n\n const tagSuffix = (norm.tags ?? []).map(t => `@${t}`).join(' ');\n return [idPart, cleanTitle, tagSuffix].filter(Boolean).join(' — ').trim();\n}\n\nfunction buildSpecFile(\n norm: NormalizedCase,\n pomClassName: string,\n pomImportPath: string,\n overrides: VarsOverrideMap,\n): string {\n const title = buildTestTitle(norm);\n const steps = norm.steps ?? [];\n const expected = norm.expected ?? [];\n const stepVars = extractStepVars(steps, norm.step_hints, norm.assertion_hints, overrides);\n\n let importPath = pomImportPath.replace(/\\\\/g, '/');\n if (!importPath.startsWith('.')) importPath = `./${importPath}`;\n // Strip .ts extension — TypeScript resolves without it\n importPath = importPath.replace(/\\.ts$/, '');\n\n const stepLines = steps.length\n ? steps\n .map((s, index) => ` ${stepToPlaywright(s, norm.url, norm.step_hints?.[index], stepVars.byStepIndex.get(index))}`)\n .join('\\n')\n : ' // TODO: add steps';\n\n const assertionLines = expected.length\n ? expected.map((e, index) => ` ${expectedToAssertion(e, norm, norm.assertion_hints?.[index], stepVars)}`).join('\\n')\n : ' // TODO: add assertions';\n\n const reviewNote = norm.needs_review\n ? `\\n // ⚠️ Flagged for review — steps or assertions may need manual refinement\\n`\n : '';\n const variableHeader = buildVariableHeaderComment(stepVars.declarations);\n const variableHeaderBlock = variableHeader ? `${variableHeader}\\n` : '';\n const variableDeclarations = buildVariableDeclarations(stepVars.declarations);\n\n return `import { test, expect } from '@playwright/test';\nimport { ${pomClassName} } from '${importPath}';\n\n${variableHeaderBlock}test('${title}', async ({ page }) => {${reviewNote}\n const pomPage = new ${pomClassName}(page);\n\n${variableDeclarations} // ── Setup ─────────────────────────────────────────────────────────────────\n await pomPage.goto();\n await pomPage.waitForLoad();\n\n // ── Steps ─────────────────────────────────────────────────────────────────\n${stepLines}\n\n // ── Assertions ────────────────────────────────────────────────────────────\n${assertionLines}\n});\n`;\n}\n\n// ─── Main ─────────────────────────────────────────────────────────────────────\n\nexport async function gen(opts: { lang: string; out: string; vars?: string }) {\n if (opts.lang !== 'ts' && opts.lang !== 'js') {\n console.error('❌ --lang must be ts or js');\n process.exit(1);\n }\n const lang = opts.lang as 'ts' | 'js';\n const specExt = lang === 'js' ? 'spec.js' : 'spec.ts';\n const pomExt = lang === 'js' ? '.js' : '.ts';\n const varsOverride = parseVarsOverride(opts.vars);\n\n const normalized = await fg([\n '.cementic/normalized/*.json',\n '!.cementic/normalized/_index.json',\n ]);\n\n if (normalized.length === 0) {\n console.warn('⚠️ No normalized cases found in .cementic/normalized/');\n console.warn(' Run: ct normalize ./cases');\n process.exit(1);\n }\n\n const projectRoot = process.cwd();\n const testsOutDir = resolve(projectRoot, opts.out);\n const pagesOutDir = resolve(projectRoot, 'pages');\n\n mkdirSync(testsOutDir, { recursive: true });\n mkdirSync(pagesOutDir, { recursive: true });\n\n let specCount = 0;\n let pomCount = 0;\n\n for (const f of normalized) {\n const norm = JSON.parse(readFileSync(f, 'utf8')) as NormalizedCase;\n\n const pomClassName = derivePomClassName(norm);\n const pomFileName = pomClassName + pomExt;\n const pomFilePath = join(pagesOutDir, pomFileName);\n\n // Only write a POM file if one doesn't exist yet — never overwrite user edits\n if (!existsSync(pomFilePath)) {\n writeFileSync(pomFilePath, buildPomClass(pomClassName, norm, lang));\n pomCount++;\n }\n\n // Relative import from the test file location to the POM file\n const relToPages = relative(testsOutDir, pagesOutDir);\n const pomImportPath = join(relToPages, pomFileName);\n\n const stem = basename(f).replace(/\\.json$/, '').replace(/[^\\w-]+/g, '-');\n const specPath = join(testsOutDir, `${stem}.${specExt}`);\n writeFileSync(specPath, buildSpecFile(norm, pomClassName, pomImportPath, varsOverride));\n specCount++;\n }\n\n console.log(`✅ Generated ${specCount} spec file(s) → ${opts.out}/`);\n if (pomCount > 0) {\n console.log(`✅ Generated ${pomCount} POM class file(s) → pages/`);\n }\n if (pomCount === 0 && specCount > 0) {\n console.log(`ℹ️ POM classes already exist — skipped regeneration`);\n }\n}\n\nexport function genCmd() {\n const cmd = new Command('gen')\n .description('Generate Playwright POM spec + page-object files from normalized cases')\n .addHelpText('after', `\nExamples:\n $ ct gen --lang ts\n $ ct gen --lang js --out tests/e2e\n $ ct gen --lang ts --vars '{\"email\":\"admin@example.com\"}'\n`)\n .option('--lang <lang>', 'Target language (ts|js)', 'ts')\n .option('--out <dir>', 'Output directory for spec files', 'tests/generated')\n .option('--vars <json>', 'JSON object of fallback values for generated CT_VAR_* constants')\n .action(async opts => {\n await gen({ lang: opts.lang, out: opts.out, vars: opts.vars });\n });\n return cmd;\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,OAAO,QAAQ;AACf,SAAS,cAAc,WAAW,eAAe,kBAAkB;AACnE,SAAS,MAAM,U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AA,EAClE;AACA,MAAI,aAAa,KAAK,YAAY,GAAG;AACnC,YAAQ,IAAI,qEAAsD;AAAA,EACpE;AACF;AAEO,SAAS,SAAS;AACvB,QAAM,MAAM,IAAI,QAAQ,KAAK,EAC1B,YAAY,wEAAwE,EACpF,YAAY,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,CAKzB,EACI,OAAO,iBAAiB,2BAA2B,IAAI,EACvD,OAAO,eAAgB,mCAAmC,iBAAiB,EAC3E,OAAO,iBAAiB,iEAAiE,EACzF,OAAO,OAAM,SAAQ;AACpB,UAAM,IAAI,EAAE,MAAM,KAAK,MAAM,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK,CAAC;AAAA,EAC/D,CAAC;AACH,SAAO;AACT;","names":[]}
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
genCmd
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RG26I5FB.js";
|
|
5
5
|
|
|
6
6
|
// src/cli.ts
|
|
7
7
|
import { Command as Command9 } from "commander";
|
|
@@ -321,7 +321,7 @@ Examples:
|
|
|
321
321
|
}
|
|
322
322
|
console.log(`\u2705 Normalized ${index.summary.parsed} case(s). Output \u2192 .cementic/normalized/`);
|
|
323
323
|
if (opts.andGen) {
|
|
324
|
-
const { gen } = await import("./gen-
|
|
324
|
+
const { gen } = await import("./gen-6Y65IYXO.js");
|
|
325
325
|
await gen({ lang: opts.lang || "ts", out: "tests/generated" });
|
|
326
326
|
}
|
|
327
327
|
});
|
|
@@ -498,6 +498,9 @@ function buildProviderConfigs(env) {
|
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
// src/core/llm.ts
|
|
501
|
+
function getAvailableCtVarKeys() {
|
|
502
|
+
return Object.keys(process.env).filter((key) => /^CT_VAR_[A-Z0-9_]+$/.test(key)).sort();
|
|
503
|
+
}
|
|
501
504
|
function buildSystemMessage() {
|
|
502
505
|
return `
|
|
503
506
|
You are a senior QA engineer and test automation specialist.
|
|
@@ -522,6 +525,11 @@ Rules:
|
|
|
522
525
|
- ID must be PREFIX-NNN where NNN is zero-padded 3 digits starting from startIndex
|
|
523
526
|
- Use 1\u20133 tags: @smoke @regression @auth @ui @critical @happy-path @negative
|
|
524
527
|
- Steps = concrete user actions ("Click the 'Sign In' button", "Fill in email with 'user@example.com'")
|
|
528
|
+
- When writing fill steps, always use meaningful values
|
|
529
|
+
- Never use the literal word 'value' as a placeholder in any fill step
|
|
530
|
+
- If the user context lists available CT_VAR_* variables for a field, reference them in steps as '\${CT_VAR_FIELDNAME}` + `'
|
|
531
|
+
- If no CT_VAR_* variable is available for a field, use a field-based placeholder like 'test-username', 'test-email', 'test-password', or 'test-phone'
|
|
532
|
+
- If you do not know the real value, use the pattern 'test-{fieldname}'
|
|
525
533
|
- Expected Results = verifiable UI outcomes ("Error message 'Invalid credentials' is visible", "Page redirects to /dashboard")
|
|
526
534
|
- Include both happy-path AND negative/edge-case tests
|
|
527
535
|
- Do NOT explain or add preamble \u2014 output ONLY the test cases
|
|
@@ -530,6 +538,7 @@ Rules:
|
|
|
530
538
|
}
|
|
531
539
|
function buildUserMessage(ctx) {
|
|
532
540
|
const lines = [];
|
|
541
|
+
const availableCtVarKeys = getAvailableCtVarKeys();
|
|
533
542
|
lines.push(`App / product description:`);
|
|
534
543
|
lines.push(ctx.appDescription || "N/A");
|
|
535
544
|
lines.push("");
|
|
@@ -568,6 +577,15 @@ function buildUserMessage(ctx) {
|
|
|
568
577
|
}
|
|
569
578
|
lines.push("");
|
|
570
579
|
}
|
|
580
|
+
if (availableCtVarKeys.length > 0) {
|
|
581
|
+
lines.push("Available CT_VAR_* test variables:");
|
|
582
|
+
for (const envKey of availableCtVarKeys) {
|
|
583
|
+
lines.push(`- ${envKey}`);
|
|
584
|
+
}
|
|
585
|
+
lines.push("");
|
|
586
|
+
lines.push(`Use a listed variable when it clearly matches a form field, written exactly as '\${CT_VAR_NAME}'.`);
|
|
587
|
+
lines.push("");
|
|
588
|
+
}
|
|
571
589
|
lines.push(`Test ID prefix: ${ctx.prefix}`);
|
|
572
590
|
lines.push(`Start numbering from: ${String(ctx.startIndex).padStart(3, "0")}`);
|
|
573
591
|
lines.push(`Number of test cases: ${ctx.numCases}`);
|