@sun-asterisk/sungen 3.2.21 → 3.2.22-beta.2
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/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +8 -0
- package/dist/cli/commands/audit.js.map +1 -1
- package/dist/cli/commands/delivery.d.ts +3 -0
- package/dist/cli/commands/delivery.d.ts.map +1 -1
- package/dist/cli/commands/delivery.js +15 -0
- package/dist/cli/commands/delivery.js.map +1 -1
- package/dist/cli/commands/inspect.d.ts +41 -0
- package/dist/cli/commands/inspect.d.ts.map +1 -0
- package/dist/cli/commands/inspect.js +134 -0
- package/dist/cli/commands/inspect.js.map +1 -0
- package/dist/cli/commands/trace.d.ts.map +1 -1
- package/dist/cli/commands/trace.js +9 -0
- package/dist/cli/commands/trace.js.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/exporters/matrix/build.d.ts +10 -0
- package/dist/exporters/matrix/build.d.ts.map +1 -1
- package/dist/exporters/matrix/build.js +38 -0
- package/dist/exporters/matrix/build.js.map +1 -1
- package/dist/exporters/matrix/export.d.ts.map +1 -1
- package/dist/exporters/matrix/export.js +11 -0
- package/dist/exporters/matrix/export.js.map +1 -1
- package/dist/exporters/matrix/render-xlsx.d.ts.map +1 -1
- package/dist/exporters/matrix/render-xlsx.js +44 -1
- package/dist/exporters/matrix/render-xlsx.js.map +1 -1
- package/dist/exporters/matrix/types.d.ts +10 -0
- package/dist/exporters/matrix/types.d.ts.map +1 -1
- package/dist/exporters/matrix/types.js.map +1 -1
- package/dist/exporters/playwright-report-parser.d.ts.map +1 -1
- package/dist/exporters/playwright-report-parser.js +1 -0
- package/dist/exporters/playwright-report-parser.js.map +1 -1
- package/dist/exporters/types.d.ts +2 -0
- package/dist/exporters/types.d.ts.map +1 -1
- package/dist/generators/test-generator/adapters/appium/templates/imports.hbs +9 -0
- package/dist/generators/test-generator/adapters/appium/templates/scenario.hbs +23 -1
- package/dist/generators/test-generator/adapters/appium/templates/steps/actions/capture-row-column.hbs +2 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/actions/capture-variable.hbs +10 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/actions/click-with-alert-action.hbs +7 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/actions/drag-action.hbs +14 -2
- package/dist/generators/test-generator/adapters/appium/templates/steps/actions/hover-element-with-text.hbs +3 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/actions/table-action-in-row-nth.hbs +2 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/all-contain-assertion.hbs +17 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/all-contain-element.hbs +13 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/disabled-with-filter-assertion.hbs +26 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/disabled-with-role-variable-assertion.hbs +24 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/disabled-with-variable-assertion.hbs +9 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/hidden-dialog-heading-assertion.hbs +10 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/hidden-with-filter-assertion.hbs +14 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/hidden-with-role-variable-assertion.hbs +21 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/hidden-with-variable-assertion.hbs +10 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/row-scoped-column-assertion.hbs +2 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/state-with-filter-assertion.hbs +23 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/storage-key-assertion.hbs +2 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/tab-order-assertion.hbs +3 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/visible-dialog-heading-assertion.hbs +10 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/visible-filtered-assertion.hbs +17 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/visible-with-role-variable-assertion.hbs +13 -0
- package/dist/generators/test-generator/adapters/appium/templates/steps/navigation/wait-table-refresh.hbs +13 -0
- package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/drag-action.hbs +1 -1
- package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/frame-enter-action.hbs +1 -1
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/all-contain-element.hbs +5 -5
- package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/row-scoped-column-assertion.hbs +1 -0
- package/dist/generators/test-generator/code-generator.d.ts.map +1 -1
- package/dist/generators/test-generator/code-generator.js +29 -8
- package/dist/generators/test-generator/code-generator.js.map +1 -1
- package/dist/generators/test-generator/diagnostics.d.ts +25 -1
- package/dist/generators/test-generator/diagnostics.d.ts.map +1 -1
- package/dist/generators/test-generator/diagnostics.js +24 -0
- package/dist/generators/test-generator/diagnostics.js.map +1 -1
- package/dist/generators/test-generator/patterns/index.d.ts +45 -0
- package/dist/generators/test-generator/patterns/index.d.ts.map +1 -1
- package/dist/generators/test-generator/patterns/index.js +159 -20
- package/dist/generators/test-generator/patterns/index.js.map +1 -1
- package/dist/generators/test-generator/patterns/types.d.ts +36 -0
- package/dist/generators/test-generator/patterns/types.d.ts.map +1 -1
- package/dist/generators/test-generator/step-mapper.d.ts +33 -0
- package/dist/generators/test-generator/step-mapper.d.ts.map +1 -1
- package/dist/generators/test-generator/step-mapper.js +100 -24
- package/dist/generators/test-generator/step-mapper.js.map +1 -1
- package/dist/harness/audit.d.ts +2 -0
- package/dist/harness/audit.d.ts.map +1 -1
- package/dist/harness/audit.js +101 -10
- package/dist/harness/audit.js.map +1 -1
- package/dist/harness/flow-contract.d.ts +87 -0
- package/dist/harness/flow-contract.d.ts.map +1 -0
- package/dist/harness/flow-contract.js +259 -0
- package/dist/harness/flow-contract.js.map +1 -0
- package/dist/harness/flow-plan.d.ts +3 -0
- package/dist/harness/flow-plan.d.ts.map +1 -1
- package/dist/harness/flow-plan.js +6 -2
- package/dist/harness/flow-plan.js.map +1 -1
- package/dist/harness/parse.d.ts +5 -0
- package/dist/harness/parse.d.ts.map +1 -1
- package/dist/harness/parse.js +29 -1
- package/dist/harness/parse.js.map +1 -1
- package/dist/harness/perf.d.ts +40 -0
- package/dist/harness/perf.d.ts.map +1 -0
- package/dist/harness/perf.js +136 -0
- package/dist/harness/perf.js.map +1 -0
- package/dist/harness/sensors.d.ts.map +1 -1
- package/dist/harness/sensors.js +13 -1
- package/dist/harness/sensors.js.map +1 -1
- package/dist/harness/spec-coverage.d.ts +8 -0
- package/dist/harness/spec-coverage.d.ts.map +1 -1
- package/dist/harness/spec-coverage.js +60 -6
- package/dist/harness/spec-coverage.js.map +1 -1
- package/dist/orchestrator/templates/ai-src/commands/add-flow.md +51 -3
- package/dist/orchestrator/templates/ai-src/commands/create-test.md +10 -0
- package/dist/orchestrator/templates/ai-src/commands/run-test.md +23 -0
- package/dist/orchestrator/templates/ai-src/skills/sungen-api-design/SKILL.md +2 -2
- package/dist/orchestrator/templates/ai-src/skills/sungen-error-mapping/SKILL.md +4 -0
- package/dist/orchestrator/templates/ai-src/skills/sungen-gherkin-syntax/SKILL.md +61 -12
- package/dist/orchestrator/templates/ai-src/skills/sungen-mobile-gestures/SKILL.md +22 -8
- package/dist/orchestrator/templates/ai-src/skills/sungen-tc-generation/SKILL.md +65 -17
- package/dist/orchestrator/templates/qa-context.md +14 -1
- package/dist/orchestrator/templates/specs-api.d.ts.map +1 -1
- package/dist/orchestrator/templates/specs-api.js +104 -29
- package/dist/orchestrator/templates/specs-api.js.map +1 -1
- package/dist/orchestrator/templates/specs-api.ts +104 -26
- package/dist/orchestrator/templates/specs-db.d.ts.map +1 -1
- package/dist/orchestrator/templates/specs-db.js +18 -5
- package/dist/orchestrator/templates/specs-db.js.map +1 -1
- package/dist/orchestrator/templates/specs-db.ts +19 -5
- package/package.json +3 -3
- package/src/cli/commands/audit.ts +8 -0
- package/src/cli/commands/delivery.ts +14 -2
- package/src/cli/commands/inspect.ts +128 -0
- package/src/cli/commands/trace.ts +9 -0
- package/src/cli/index.ts +2 -0
- package/src/exporters/matrix/build.ts +40 -0
- package/src/exporters/matrix/export.ts +11 -0
- package/src/exporters/matrix/render-xlsx.ts +45 -1
- package/src/exporters/matrix/types.ts +10 -0
- package/src/exporters/playwright-report-parser.ts +2 -0
- package/src/exporters/types.ts +2 -0
- package/src/generators/test-generator/adapters/appium/templates/imports.hbs +9 -0
- package/src/generators/test-generator/adapters/appium/templates/scenario.hbs +23 -1
- package/src/generators/test-generator/adapters/appium/templates/steps/actions/capture-row-column.hbs +2 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/actions/capture-variable.hbs +10 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/actions/click-with-alert-action.hbs +7 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/actions/drag-action.hbs +14 -2
- package/src/generators/test-generator/adapters/appium/templates/steps/actions/hover-element-with-text.hbs +3 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/actions/table-action-in-row-nth.hbs +2 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/all-contain-assertion.hbs +17 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/all-contain-element.hbs +13 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/disabled-with-filter-assertion.hbs +26 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/disabled-with-role-variable-assertion.hbs +24 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/disabled-with-variable-assertion.hbs +9 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/hidden-dialog-heading-assertion.hbs +10 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/hidden-with-filter-assertion.hbs +14 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/hidden-with-role-variable-assertion.hbs +21 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/hidden-with-variable-assertion.hbs +10 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/row-scoped-column-assertion.hbs +2 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/state-with-filter-assertion.hbs +23 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/storage-key-assertion.hbs +2 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/tab-order-assertion.hbs +3 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/visible-dialog-heading-assertion.hbs +10 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/visible-filtered-assertion.hbs +17 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/assertions/visible-with-role-variable-assertion.hbs +13 -0
- package/src/generators/test-generator/adapters/appium/templates/steps/navigation/wait-table-refresh.hbs +13 -0
- package/src/generators/test-generator/adapters/playwright/templates/steps/actions/drag-action.hbs +1 -1
- package/src/generators/test-generator/adapters/playwright/templates/steps/actions/frame-enter-action.hbs +1 -1
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/all-contain-element.hbs +5 -5
- package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/row-scoped-column-assertion.hbs +1 -0
- package/src/generators/test-generator/code-generator.ts +34 -9
- package/src/generators/test-generator/diagnostics.ts +25 -1
- package/src/generators/test-generator/patterns/index.ts +172 -25
- package/src/generators/test-generator/patterns/types.ts +35 -0
- package/src/generators/test-generator/step-mapper.ts +106 -23
- package/src/harness/audit.ts +104 -11
- package/src/harness/flow-contract.ts +261 -0
- package/src/harness/flow-plan.ts +10 -3
- package/src/harness/parse.ts +31 -1
- package/src/harness/perf.ts +112 -0
- package/src/harness/sensors.ts +13 -1
- package/src/harness/spec-coverage.ts +55 -5
- package/src/orchestrator/templates/ai-src/commands/add-flow.md +51 -3
- package/src/orchestrator/templates/ai-src/commands/create-test.md +10 -0
- package/src/orchestrator/templates/ai-src/commands/run-test.md +23 -0
- package/src/orchestrator/templates/ai-src/skills/sungen-api-design/SKILL.md +2 -2
- package/src/orchestrator/templates/ai-src/skills/sungen-error-mapping/SKILL.md +4 -0
- package/src/orchestrator/templates/ai-src/skills/sungen-gherkin-syntax/SKILL.md +61 -12
- package/src/orchestrator/templates/ai-src/skills/sungen-mobile-gestures/SKILL.md +22 -8
- package/src/orchestrator/templates/ai-src/skills/sungen-tc-generation/SKILL.md +65 -17
- package/src/orchestrator/templates/qa-context.md +14 -1
- package/src/orchestrator/templates/specs-api.ts +104 -26
- package/src/orchestrator/templates/specs-db.ts +19 -5
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance budgets — config + percentile math + the per-unit verdict. (#569)
|
|
3
|
+
*
|
|
4
|
+
* A flow's regression value includes "still fast enough": after a lib/framework
|
|
5
|
+
* upgrade the main journeys must not only pass but hold their response-time
|
|
6
|
+
* budget. Sungen had no perf concept at all — the Playwright JSON parser even
|
|
7
|
+
* dropped the `duration` field Playwright already emits on every result.
|
|
8
|
+
*
|
|
9
|
+
* Scope discipline:
|
|
10
|
+
* - This is config + measurement + report over runs sungen already makes.
|
|
11
|
+
* Real load tests stay @manual:M8 → a dedicated tool.
|
|
12
|
+
* - The AUDIT never reads it: the quality score is documented as a pure
|
|
13
|
+
* function of the design artifacts ("reads no test-results, live page, or
|
|
14
|
+
* clock"). Perf reports where runs are already read — `sungen delivery`
|
|
15
|
+
* and the dashboard. Advisory: a blown budget never fails the design gate.
|
|
16
|
+
*
|
|
17
|
+
* Config: qa/perf.yaml
|
|
18
|
+
* percentile: p75 # default p75 — "≥75% of runs meet the budget"
|
|
19
|
+
* defaults:
|
|
20
|
+
* scenario_ms: 30000 # whole-scenario wall clock (Playwright duration)
|
|
21
|
+
* page_load_ms: 3000 # Phase B — needs per-transition runtime timing
|
|
22
|
+
* transition_ms: 2000 # Phase B
|
|
23
|
+
* units:
|
|
24
|
+
* place-order: { scenario_ms: 20000 }
|
|
25
|
+
*/
|
|
26
|
+
import * as fs from 'fs';
|
|
27
|
+
import * as path from 'path';
|
|
28
|
+
import { parse as parseYaml } from 'yaml';
|
|
29
|
+
import { readTextFile } from './read-text';
|
|
30
|
+
|
|
31
|
+
export interface PerfConfig {
|
|
32
|
+
/** 0..100 — e.g. 75 for p75. */
|
|
33
|
+
percentile: number;
|
|
34
|
+
defaults: Record<string, number>;
|
|
35
|
+
units: Record<string, Record<string, number>>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface PerfVerdict {
|
|
39
|
+
unit: string;
|
|
40
|
+
metric: string; // 'scenario_ms' today; page_load_ms/transition_ms in Phase B
|
|
41
|
+
percentile: number; // 75
|
|
42
|
+
budgetMs: number;
|
|
43
|
+
measuredMs: number; // the pXX of the observed durations
|
|
44
|
+
samples: number;
|
|
45
|
+
pass: boolean;
|
|
46
|
+
/** Titles of the slowest offenders (only when failing), for the report. */
|
|
47
|
+
slowest: Array<{ title: string; ms: number }>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function perfConfigPath(projectRoot: string): string {
|
|
51
|
+
return path.join(projectRoot, 'qa', 'perf.yaml');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Absent file → null (perf reporting is opt-in; nothing changes until configured). */
|
|
55
|
+
export function loadPerfConfig(projectRoot: string): PerfConfig | null {
|
|
56
|
+
const p = perfConfigPath(projectRoot);
|
|
57
|
+
if (!fs.existsSync(p)) return null;
|
|
58
|
+
let raw: Record<string, unknown>;
|
|
59
|
+
try { raw = parseYaml(readTextFile(p)) as Record<string, unknown>; } catch { return null; }
|
|
60
|
+
if (!raw || typeof raw !== 'object') return null;
|
|
61
|
+
const pctRaw = String(raw.percentile ?? 'p75').toLowerCase().replace(/^p/, '');
|
|
62
|
+
const percentile = Math.min(100, Math.max(1, Number(pctRaw) || 75));
|
|
63
|
+
const num = (o: unknown): Record<string, number> => {
|
|
64
|
+
const out: Record<string, number> = {};
|
|
65
|
+
if (o && typeof o === 'object') {
|
|
66
|
+
for (const [k, v] of Object.entries(o as Record<string, unknown>)) {
|
|
67
|
+
const n = Number(v);
|
|
68
|
+
if (Number.isFinite(n) && n > 0) out[k] = n;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
};
|
|
73
|
+
const units: Record<string, Record<string, number>> = {};
|
|
74
|
+
if (raw.units && typeof raw.units === 'object') {
|
|
75
|
+
for (const [u, o] of Object.entries(raw.units as Record<string, unknown>)) units[u] = num(o);
|
|
76
|
+
}
|
|
77
|
+
return { percentile, defaults: num(raw.defaults), units };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Nearest-rank percentile (ceil), the standard "≥pXX of samples meet the budget"
|
|
82
|
+
* reading: p75 of [a…] is the value at ceil(0.75·n) in the sorted list. One
|
|
83
|
+
* sample → that sample. Deterministic, no interpolation.
|
|
84
|
+
*/
|
|
85
|
+
export function percentileOf(p: number, values: number[]): number {
|
|
86
|
+
if (values.length === 0) return 0;
|
|
87
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
88
|
+
const rank = Math.min(sorted.length, Math.max(1, Math.ceil((p / 100) * sorted.length)));
|
|
89
|
+
return sorted[rank - 1];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Budget for a metric on a unit: per-unit override, else defaults, else none. */
|
|
93
|
+
export function budgetFor(config: PerfConfig, unit: string, metric: string): number | undefined {
|
|
94
|
+
return config.units[unit]?.[metric] ?? config.defaults[metric];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The scenario_ms verdict for one unit's run. `durations` = per-test wall-clock ms
|
|
99
|
+
* (a @cases scenario contributes one sample per row-test — each is a real run).
|
|
100
|
+
*/
|
|
101
|
+
export function perfVerdict(
|
|
102
|
+
config: PerfConfig,
|
|
103
|
+
unit: string,
|
|
104
|
+
samples: Array<{ title: string; ms: number }>,
|
|
105
|
+
): PerfVerdict | null {
|
|
106
|
+
const budgetMs = budgetFor(config, unit, 'scenario_ms');
|
|
107
|
+
if (budgetMs === undefined || samples.length === 0) return null;
|
|
108
|
+
const measuredMs = percentileOf(config.percentile, samples.map((s) => s.ms));
|
|
109
|
+
const pass = measuredMs <= budgetMs;
|
|
110
|
+
const slowest = pass ? [] : [...samples].sort((a, b) => b.ms - a.ms).slice(0, 3);
|
|
111
|
+
return { unit, metric: 'scenario_ms', percentile: config.percentile, budgetMs, measuredMs, samples: samples.length, pass, slowest };
|
|
112
|
+
}
|
package/src/harness/sensors.ts
CHANGED
|
@@ -33,10 +33,22 @@ const BUCKET_ORDER: Array<[string, string[]]> = [
|
|
|
33
33
|
];
|
|
34
34
|
const BUCKETS: Record<string, string[]> = Object.fromEntries(BUCKET_ORDER);
|
|
35
35
|
|
|
36
|
+
// Flow journey-phase categories (FL-HP-001, FL-ER-002 …). Matched on exact SEGMENTS,
|
|
37
|
+
// never by containment — 'SHOP'.includes('HP') is true, which is exactly the kind of
|
|
38
|
+
// false hit substring matching would produce for two-letter phase tokens. (#569)
|
|
39
|
+
const PHASE_BUCKETS: Record<string, string> = {
|
|
40
|
+
HP: 'business-core', // happy path = the business goal itself
|
|
41
|
+
ER: 'validation-security', // error recovery (validation must not trap the journey)
|
|
42
|
+
EH: 'validation-security', // guards & leakage (direct access, back, refresh)
|
|
43
|
+
};
|
|
44
|
+
|
|
36
45
|
/** Classify a VP category into a balance bucket by keyword containment + precedence (H1). */
|
|
37
46
|
export function bucketForCategory(category: string | undefined): string {
|
|
38
47
|
const cat = (category || '').toUpperCase();
|
|
39
48
|
if (!cat) return 'other';
|
|
49
|
+
for (const seg of cat.split('-')) {
|
|
50
|
+
if (PHASE_BUCKETS[seg]) return PHASE_BUCKETS[seg];
|
|
51
|
+
}
|
|
40
52
|
for (const [bucket, kws] of BUCKET_ORDER) {
|
|
41
53
|
if (kws.some((k) => cat.includes(k))) return bucket;
|
|
42
54
|
}
|
|
@@ -351,7 +363,7 @@ export function flowRegressionDepth(scenarios: ScenarioInfo[]): FlowDepthResult
|
|
|
351
363
|
// 1. Count/quantity proof — a row count or item quantity, not just presence of a row.
|
|
352
364
|
const countProof = any(/\b(quantity|qty|two (?:rows|lines|cart)|row count|count column|number of items|one[_ ]row|two[_ ]rows|qty[_ ])/i);
|
|
353
365
|
// 2. Teardown — removes the item and verifies the empty/zero state (the inverse operation).
|
|
354
|
-
const teardown = any(/\b(remove|delete|clear)
|
|
366
|
+
const teardown = any(/\b(remove|delete|clear)(?:s|d|ed|ing)?\b/i) && any(/\b(empty|emptied|no items|zero|removed|cleared|0 items)\b/i);
|
|
355
367
|
// 3. Multi-source — the cart is fed from >1 source (the main list AND a recommended/related rail).
|
|
356
368
|
const multiSource = any(/\b(recommended|related|you may also|suggest)\b/i) && addsToCart;
|
|
357
369
|
|
|
@@ -66,21 +66,43 @@ export function parseSpecClauses(specPath: string): { frs: FrClause[]; valRows:
|
|
|
66
66
|
if (!fs.existsSync(specPath)) return { frs: [], valRows: [] };
|
|
67
67
|
const lines = readTextFile(specPath).split('\n');
|
|
68
68
|
|
|
69
|
+
// Requirement ids follow the PROJECT's scheme, not ours (#572): `**FR-1**:` is one
|
|
70
|
+
// convention among many — a real spec declared ~30 MUST clauses as `` `REQ-SRCH-001`: ``
|
|
71
|
+
// and the FR-locked pattern returned zero, so the MUST-coverage gate never ran and the
|
|
72
|
+
// specFR axis was excluded "for lack of evidence" that was sitting right there. Same
|
|
73
|
+
// silent-failure class as the CRLF parsers, same id-scheme-tolerance lesson as delivery.
|
|
74
|
+
//
|
|
75
|
+
// A declaration is: line-leading (optionally bulleted / bold / backticked) `<ID>:` where
|
|
76
|
+
// the id ends in a number. Table rows are EXCLUDED — traceability tables cite requirement
|
|
77
|
+
// ids without declaring them — and so are prefixes that are never requirements
|
|
78
|
+
// (test cases, viewpoints, known-defect records, data-factory checks, flows, delivery items).
|
|
79
|
+
const NON_REQUIREMENT_PREFIX = /^(TC|VP|KD|CHK|FL|DI)-/i;
|
|
69
80
|
const frs: FrClause[] = [];
|
|
81
|
+
const seen = new Set<string>();
|
|
70
82
|
for (const line of lines) {
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
if (/^\s*\|/.test(line)) continue; // table row = citation, not declaration
|
|
84
|
+
const m = line.match(/^\s*(?:[-*+]\s+)?[*_`]*([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*-\d+[a-zA-Z]?)[*_`]*\s*:\s*(.+)$/);
|
|
85
|
+
if (!m || NON_REQUIREMENT_PREFIX.test(m[1])) continue;
|
|
86
|
+
const id = m[1].toUpperCase();
|
|
87
|
+
if (seen.has(id)) continue; // first declaration wins
|
|
88
|
+
seen.add(id);
|
|
89
|
+
frs.push({ id, text: m[2].replace(/\*\*/g, '').trim(), modality: modalityOf(m[2]) });
|
|
73
90
|
}
|
|
74
91
|
|
|
75
92
|
// Validation Rules table: a row carries a Constraint, a Trigger cell, and (often) a code.
|
|
93
|
+
// A "Trigger" column alone is NOT enough to claim the table (#578): a screen-STATES table
|
|
94
|
+
// ("State ID | Trigger | URL/heading oracle | …") uses Trigger for the user action that
|
|
95
|
+
// enters the state, and reading it as validation rows invented three gate-relevant
|
|
96
|
+
// TRIGGER-UNCOVERED gaps on a real spec. The table must also name a Constraint/Rule/
|
|
97
|
+
// Validation column — the thing a validation row is ABOUT.
|
|
76
98
|
const valRows: ValRow[] = [];
|
|
77
99
|
let cTrigger = -1, cConstraint = -1, cCode = -1, inTable = false;
|
|
78
100
|
for (const raw of lines) {
|
|
79
101
|
const line = raw.trim();
|
|
80
|
-
if (line.startsWith('|') && /\btrigger\b/i.test(line) && cTrigger < 0) {
|
|
102
|
+
if (line.startsWith('|') && /\btrigger\b/i.test(line) && /\b(constraint|rule|validation)\b/i.test(line) && cTrigger < 0) {
|
|
81
103
|
const cells = line.split('|').map((c) => c.trim());
|
|
82
104
|
cTrigger = cells.findIndex((c) => /^trigger$/i.test(c));
|
|
83
|
-
cConstraint = cells.findIndex((c) => /constraint/i.test(c));
|
|
105
|
+
cConstraint = cells.findIndex((c) => /constraint|rule|validation/i.test(c));
|
|
84
106
|
cCode = cells.findIndex((c) => /code/i.test(c));
|
|
85
107
|
inTable = cTrigger >= 0;
|
|
86
108
|
continue;
|
|
@@ -104,12 +126,40 @@ function scenarioBlocks(featureText: string): string[] {
|
|
|
104
126
|
return featureText.split(/\n\s*\n/).filter((b) => /\bScenario:/.test(b)).map((b) => b.toLowerCase());
|
|
105
127
|
}
|
|
106
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Requirement ids CITED anywhere in the feature (tags, comments, prose) — with the
|
|
131
|
+
* compressed notations authors naturally write expanded (#578 follow-up, 3rd recurrence):
|
|
132
|
+
* `REQ-CART-001..005` (range), `REQ-QTY-001/003` (enumeration). A plain substring check
|
|
133
|
+
* missed exactly the ids inside the shorthand, so a deferral comment that HONESTLY listed
|
|
134
|
+
* its flow-owned requirements still left them reported as uncovered.
|
|
135
|
+
*/
|
|
136
|
+
export function citedIds(featureText: string): Set<string> {
|
|
137
|
+
const t = featureText.toUpperCase();
|
|
138
|
+
const out = new Set<string>();
|
|
139
|
+
for (const m of t.matchAll(/\b([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*-\d+[A-Z]?)\b/g)) out.add(m[1]);
|
|
140
|
+
// Range: PREFIX-001..005 (also – — ~ as the dash). Width follows the FIRST number.
|
|
141
|
+
for (const m of t.matchAll(/\b([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*-)(\d+)\s*(?:\.\.|–|—|~)\s*(\d+)/g)) {
|
|
142
|
+
const w = m[2].length;
|
|
143
|
+
for (let i = parseInt(m[2], 10); i <= parseInt(m[3], 10) && i - parseInt(m[2], 10) < 200; i++) {
|
|
144
|
+
out.add(m[1] + String(i).padStart(w, '0'));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Enumeration: PREFIX-001/003/007 — every slash part is an id under the same prefix.
|
|
148
|
+
for (const m of t.matchAll(/\b([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*-)(\d+)((?:\/\d+)+)/g)) {
|
|
149
|
+
const w = m[2].length;
|
|
150
|
+
out.add(m[1] + m[2]);
|
|
151
|
+
for (const part of m[3].split('/').filter(Boolean)) out.add(m[1] + part.padStart(w, '0'));
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
|
|
107
156
|
export function specCoverage(specPath: string, scenarios: ScenarioInfo[], featureText: string): SpecCoverageResult {
|
|
108
157
|
const { frs, valRows } = parseSpecClauses(specPath);
|
|
109
158
|
if (!fs.existsSync(specPath) || (frs.length === 0 && valRows.length === 0)) {
|
|
110
159
|
return { hasSpec: fs.existsSync(specPath), frTotal: 0, frCovered: 0, uncoveredMust: [], inferredOnly: [], triggerGaps: [], verdict: 'pass' };
|
|
111
160
|
}
|
|
112
161
|
const featLower = featureText.toLowerCase();
|
|
162
|
+
const cites = citedIds(featureText);
|
|
113
163
|
|
|
114
164
|
// FR coverage: explicit @spec:FR / literal FR-id citation, else keyword fallback.
|
|
115
165
|
const uncoveredMust: { id: string; text: string }[] = [];
|
|
@@ -117,7 +167,7 @@ export function specCoverage(specPath: string, scenarios: ScenarioInfo[], featur
|
|
|
117
167
|
let frCovered = 0;
|
|
118
168
|
for (const fr of frs) {
|
|
119
169
|
const idLower = fr.id.toLowerCase();
|
|
120
|
-
const cited = featLower.includes(idLower);
|
|
170
|
+
const cited = featLower.includes(idLower) || cites.has(fr.id.toUpperCase());
|
|
121
171
|
const words = [...new Set((fr.text.toLowerCase().match(/[a-z][a-z-]{4,}/g) || []))]
|
|
122
172
|
.filter((w) => !/must|should|system|screen|users?|value|input|field/.test(w));
|
|
123
173
|
const kwHit = words.length > 0 && scenarios.some((s) => words.filter((w) => s.haystack.includes(w)).length >= Math.min(2, words.length));
|
|
@@ -86,15 +86,62 @@ qa/flows/${input:flow}/
|
|
|
86
86
|
└── ui/ # Screenshots, mockups
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
### 1a.
|
|
89
|
+
### 1a. Define the flow's BOUNDARY, then its screens
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
> QA teams often call this level **System Test** — same thing: one fully-integrated business
|
|
92
|
+
> journey verified against the spec. Use whichever name the team knows; the boundary rules
|
|
93
|
+
> below are the ISTQB system-test design rules.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
A flow is the **smallest complete business action chain**: one clear trigger ending in ONE
|
|
97
|
+
observable, valuable outcome. Before asking for screens, walk this checklist with the user —
|
|
98
|
+
if 1, 3 or 8 fails, propose SPLITTING into separate flows:
|
|
99
|
+
|
|
100
|
+
1. Exactly **one business goal**? (cart correctness + category filtering = two flows)
|
|
101
|
+
2. A clear **trigger** and precondition?
|
|
102
|
+
3. **One observable final outcome**? (a final assertion you can write in one sentence)
|
|
103
|
+
4. Is that outcome **valuable to the actor**? (an order placed, a password reset — not "a page rendered")
|
|
104
|
+
5. Is **every step necessary** for that outcome?
|
|
105
|
+
6. Are all steps at the **same business abstraction**?
|
|
106
|
+
7. Are optional/error branches **phases of this goal** (ER/EH), not new goals?
|
|
107
|
+
8. Does **no segment** form an independently valuable flow on its own?
|
|
108
|
+
9. Can you write **a single clear final assertion**?
|
|
109
|
+
10. Can you name it "**Verb + outcome**"? (`place-order`, `reset-password` — not `cart-and-filter`)
|
|
110
|
+
|
|
111
|
+
Then ask: "Which screens does this flow visit, in order? (e.g., login → dashboard → award-form → confirmation)"
|
|
92
112
|
|
|
93
113
|
Record the screen list — you will need it for:
|
|
94
114
|
- Filling `spec.md` (Step 3)
|
|
95
115
|
- Suggesting `[Screen:Element]` namespace prefixes
|
|
96
116
|
- Capturing visuals per screen (Step 2)
|
|
97
117
|
|
|
118
|
+
### 1b. Author the Flow Contract (`requirements/flow-contract.yaml`)
|
|
119
|
+
|
|
120
|
+
Write the answers down as the flow's contract — `sungen audit` scores the flow **against it**
|
|
121
|
+
(the `flowCoverage` axis: HP/ER/EH journey phases; `FLOW-OUTCOME-UNPROVEN` when no automated
|
|
122
|
+
scenario asserts data on the outcome screen; `FLOW-SCOPE-CREEP` when scenarios never touch it):
|
|
123
|
+
|
|
124
|
+
```yaml
|
|
125
|
+
goal: "Place an order for a product added from home" # Verb + outcome
|
|
126
|
+
actor: user
|
|
127
|
+
trigger: "Add a product to the cart from the home featured list"
|
|
128
|
+
precondition: "A registered account; an empty cart"
|
|
129
|
+
outcome:
|
|
130
|
+
screen: checkout # the [Screen:...] namespace carrying the final proof
|
|
131
|
+
assertion: "The confirmation shows the order number and the paid total"
|
|
132
|
+
value: "The customer has paid; the shop has a new order"
|
|
133
|
+
phases: [HP, ER, EH] # journey phases (default); add UI only if the flow owns UI states
|
|
134
|
+
stateful: cart # the mutated collection, if any — enables regression-depth dims
|
|
135
|
+
golden: true # optional — release-critical: Final Inspection expects @golden scenarios here
|
|
136
|
+
external: # optional — legs owned by another team/vendor (System INTEGRATION Testing)
|
|
137
|
+
- name: payment-gateway
|
|
138
|
+
owner: vendor-x
|
|
139
|
+
screens: [payment] # the flow namespaces that leg passes through
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**A filled contract is an INPUT to generation — never an output.** Like `test-viewpoint.md`,
|
|
143
|
+
generation must not rewrite it to match what was generated; disagree → propose the diff and ask.
|
|
144
|
+
|
|
98
145
|
### 2. Capture visual source
|
|
99
146
|
|
|
100
147
|
**Mobile path** (`platform: mobile`):
|
|
@@ -187,7 +234,8 @@ If user picks `/sungen:create-test`, **you MUST use the Skill tool** to invoke i
|
|
|
187
234
|
- Test data namespaced by phase: `login.email`, `submission.nominee`
|
|
188
235
|
- `@flow` tag required at feature level
|
|
189
236
|
- `Background:` should only contain the starting navigation — the URL path (web) or the `--reach` nav recipe (mobile)
|
|
190
|
-
- Each scenario = one phase of the journey
|
|
237
|
+
- Each scenario = one phase of the journey; ids are `FL-<PHASE>-NNN` (`HP`/`ER`/`EH`, optional `UI`)
|
|
238
|
+
- One flow = ONE business goal with ONE observable outcome (`requirements/flow-contract.yaml`) — a segment with its own value is its own flow
|
|
191
239
|
{{#cap parallel-subagents}}
|
|
192
240
|
- Mobile flows are tagged `@platform:mobile` and run via `/sungen:run-test <flow>` (WebdriverIO, not Playwright)
|
|
193
241
|
{{/cap}}
|
|
@@ -6,6 +6,16 @@ order: 20
|
|
|
6
6
|
claude-tools: "Read, Grep, Bash, Glob, Write, AskUserQuestion, Skill, mcp__playwright__browser_navigate, mcp__playwright__browser_snapshot, mcp__playwright__browser_take_screenshot"
|
|
7
7
|
copilot-tools: "[vscode, execute, read, agent, edit, search, web, browser, todo, 'playwright/*']"
|
|
8
8
|
codex-trigger: "Run when the user asks to CREATE, generate, write, or author test cases / a .feature file for a screen or flow. Step 2 (after add-screen/add-flow, before run-test). Do NOT use for executing, running, or compiling existing tests."
|
|
9
|
+
---
|
|
10
|
+
## ⛔ HARD RULE — the run's LAST action is the next-step hand-back
|
|
11
|
+
|
|
12
|
+
A create-test run is NOT finished when the files are written or the audit prints. The final
|
|
13
|
+
action of EVERY run — success, partial, or aborted — is the next-step hand-back
|
|
14
|
+
({{#cap parallel-subagents}}an `AskUserQuestion` offering the next actions{{/cap}}{{^cap parallel-subagents}}a numbered list of next-action choices{{/cap}};
|
|
15
|
+
see "Finish — always hand the next step back" at the end of this file). Ending with a prose
|
|
16
|
+
summary and no choices is a broken run: the operator is left guessing. This holds no matter
|
|
17
|
+
how long the generation/repair loop ran.
|
|
18
|
+
|
|
9
19
|
---
|
|
10
20
|
{{#cap parallel-subagents}}
|
|
11
21
|
## ⛔ HARD RULE — No Figma MCP when PAT data exists
|
|
@@ -7,6 +7,29 @@ claude-tools: "Read, Grep, Bash, Glob, Edit, Write, AskUserQuestion, mcp__playwr
|
|
|
7
7
|
copilot-tools: "[read, execute, edit, vscode/askQuestions, playwright/*, appium/*]"
|
|
8
8
|
codex-trigger: "Run when the user asks to RUN, execute, or compile tests, generate selectors.yaml, or run tests. Step 4. Do NOT use for authoring/creating new test cases."
|
|
9
9
|
---
|
|
10
|
+
## ⛔ HARD RULE — the transition INTO this run is a tool call, never prose
|
|
11
|
+
|
|
12
|
+
A QA field report: the user picked "Run test" from create-test's hand-back, and the session
|
|
13
|
+
answered with a BRIEFING — missing selector, expected reds, "run under Node 22" — written as
|
|
14
|
+
"Before you do…", then stopped. Correct facts, wrong role: those are conditions YOU handle
|
|
15
|
+
inside the run, not reasons to stop and hand the work back.
|
|
16
|
+
|
|
17
|
+
- The first thing this command produces is a **tool call** (platform detection, preflight,
|
|
18
|
+
compile — whatever comes first). Never open with a plan and end the turn.
|
|
19
|
+
- A **missing selector** goes to the selector-generation/fix step — that is what this command
|
|
20
|
+
is FOR.
|
|
21
|
+
- **Expected-red scenarios** (@known-defect asserting a live defect) stay red; note them in
|
|
22
|
+
the results summary, never "fix" them and never stop for them.
|
|
23
|
+
- **Runtime selection is yours**: check `node -v` first. If the major version is ≥ 23 and
|
|
24
|
+
Playwright browser runs are known-broken on it, select Node 22 yourself when available —
|
|
25
|
+
`export PATH="$HOME/.nvm/versions/node/$(ls $HOME/.nvm/versions/node | grep '^v22' | tail -1)/bin:$PATH"`
|
|
26
|
+
— and say so in one line. Only if NO compatible Node exists do you stop, with the exact
|
|
27
|
+
install command as the hand-back.
|
|
28
|
+
- Ending this run follows the same law as create-test: the LAST action is the next-step
|
|
29
|
+
hand-back (the AskUserQuestion in "After showing results"), no matter how the run went.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
10
33
|
## Role
|
|
11
34
|
|
|
12
35
|
You are a **Senior Developer**.
|
|
@@ -79,10 +79,10 @@ A flow (`create → login → delete`) is a **Functional integration** test, **n
|
|
|
79
79
|
- ":gift_image_1" # test-data: gift_image_1 → fixtures/a.png
|
|
80
80
|
- ":gift_image_2" # test-data: gift_image_2 → fixtures/b.png
|
|
81
81
|
```
|
|
82
|
-
Each element binds its own `:param` from test-data. Use this for endpoints that accept a list of files under the same field — a single object value can only hold one file. **Automate multi-file uploads with `@api`; don't defer to `@manual`.** (File uploads
|
|
82
|
+
Each element binds its own `:param` from test-data. Use this for endpoints that accept a list of files under the same field — a single object value can only hold one file. **Automate multi-file uploads with `@api`; don't defer to `@manual`.** (File uploads are sent as `multipart/form-data` built on Node's global `FormData`/`Blob` — **Node 18+, no Playwright dependency**, so the same upload runs in mobile specs too.)
|
|
83
83
|
- **`bodyFile:`** → raw binary body (the whole body IS the file's bytes, e.g. `application/octet-stream`): `bodyFile: { path: ":image", mimeType: application/octet-stream }`.
|
|
84
84
|
|
|
85
|
-
Fixture path resolves cwd-relative/absolute first, else `qa/fixtures/<path>` (drop sample files there, reference by name from `test-data`). An empty resolved file param omits the part → use for missing-file `@cases` error rows. `files:`/`bodyFile:` are mutually exclusive. **Automate the upload success case with `@api`** — don't defer it to `@manual`.
|
|
85
|
+
Fixture path resolves cwd-relative/absolute first, else `qa/fixtures/<path>` (drop sample files there, reference by name from `test-data`). An empty resolved file param omits the part → use for missing-file `@cases` error rows. `files:`/`bodyFile:` are mutually exclusive. A **`GET`/`HEAD` entry may carry no body at all** (no `body:`/`files:`/`bodyFile:`) — HTTP forbids it and the catalog lint refuses it; put the inputs in the path or `query`, or use `POST`. **Automate the upload success case with `@api`** — don't defer it to `@manual`.
|
|
86
86
|
|
|
87
87
|
## Per-endpoint knobs & auth patterns
|
|
88
88
|
- **Timeout** — a slow endpoint can override the datasource default (15s) with `timeout_ms: 30000` on its catalog entry (else the datasource `timeout_ms` applies).
|
|
@@ -99,6 +99,10 @@ needs any of these, it is a **finding for QA** — surface it in the run summary
|
|
|
99
99
|
| `SG-W012` | A mock-install step written AFTER a navigation step in the same block — `page.route()` registered after `goto()` misses every request fired during page load | Move the mock-install step before the navigation, or into `Background` |
|
|
100
100
|
| `SG-W013` | A page assertion (`see [X] page` / `is on [X] page`) whose `[Ref]` has no `type: page` selector entry (or collides with a non-page entry) — the step falls back to the feature's own path (or `/<ref>/`) instead of `X`'s real URL, so the anchored assertion can never pass | Declare a `type: page` entry for `[Ref]` with its real URL; if the key collides with another type, disambiguate with a `--type` suffix (`sungen-selector-keys` § Collision rule) |
|
|
101
101
|
| `SG-W014` | `[X] page with {{v}}` where `{{v}}`'s base test-data value carries no query and no fragment — the step checks the PATH only, asserting less than it reads as | Informational — pass a value like `?q=…` if you meant to assert a query, or drop `with {{v}}` for a bare page |
|
|
102
|
+
| `SG-E020` | A step matched a pattern, but the **active adapter ships no template** for it (e.g. a web-only step compiled under `platform: mobile`). The feature file still generates — that one step compiles to `throw new Error("[sungen] …")` naming the step, feature, pattern, template and adapter, so the failure is loud and traceable rather than a crashed build | Rephrase to a step the target adapter actually ships (see `sungen-gherkin-syntax` Platform Support section / `sungen-mobile-gestures`), or tag the scenario `@manual` with the platform reason |
|
|
103
|
+
| `SG-W020` | The matched pattern **declares `platforms`** (today: `@mock`) and the active platform isn't among them. Caught before template lookup, so the diagnostic can name the native alternative directly | Drop `@mock` from a mobile unit (there is no Mock Driver on Appium) — use `@api`/`@query` or a `@manual` note instead |
|
|
104
|
+
| `SG-W021` | `use dialog` / `User is on [X] dialog` scope under the **mobile** adapter — the scope is recorded but no Appium template reads `inDialog`, so every following step resolves against the whole screen, not just the dialog | Don't rely on `scope: dialog`/`use dialog` for disambiguation on mobile — give the element inside the dialog its own unique accessibility-id/testid instead |
|
|
105
|
+
| `SG-W022` | `Then User see [X] page` under the **mobile** adapter — a native app has no URL, so the step compiles to a bare COMMENT: it reads as an assertion, checks nothing, and the scenario passes whatever is on screen. Worse than a hard failure, because nothing ever goes red. (Its `is on [X] page` twin throws via `route-assertion`; `Given User is on [X] page` is the app-LAUNCH directive and correctly emits nothing) | Assert something actually on the screen — `Then User see [Some Header] text` / a screen-marker accessibility-id — instead of a page/URL check, or tag the scenario `@manual` |
|
|
102
106
|
|
|
103
107
|
### Runtime error → `Test data "<key>" references ${QA_*} but the environment variable is not set`
|
|
104
108
|
|
|
@@ -27,21 +27,26 @@ AND → inherits from preceding keyword
|
|
|
27
27
|
|
|
28
28
|
## Step Patterns (70 patterns)
|
|
29
29
|
|
|
30
|
+
> **Platform legend:** unmarked = `[both]` (compiles on Playwright AND Appium). `[web]` = compiles
|
|
31
|
+
> only on Playwright — the Appium template throws, naming the reason. `[mobile]` = mobile-only
|
|
32
|
+
> vocabulary with no web counterpart. Every marking is checked against a shipped `.hbs` — see
|
|
33
|
+
> **Platform Support** at the end of this section for the full web-only/mobile-only/divergence list.
|
|
34
|
+
|
|
30
35
|
### Setup / Form / Interaction
|
|
31
36
|
|
|
32
37
|
```
|
|
33
38
|
User is on [T] page | page with {{v}} | dialog
|
|
34
39
|
User fill [T] field | textarea | search | slider | date-picker with {{v}}
|
|
35
|
-
User fill [T] uploader with {{f}}
|
|
40
|
+
User fill [T] uploader with {{f}} [web]
|
|
36
41
|
User clear [T] field
|
|
37
42
|
User check [T] checkbox | toggle | radio
|
|
38
43
|
User uncheck [T] checkbox | toggle
|
|
39
44
|
User select [T] dropdown with {{v}}
|
|
40
45
|
User click [T] button | tab | column | breadcrumb
|
|
41
46
|
User click [T] row with {{v}}
|
|
42
|
-
User try to click [T] button | link # DISABLED element only — see rule below (v3.3)
|
|
47
|
+
User try to click [T] button | link # DISABLED element only — see rule below (v3.3) [web]
|
|
43
48
|
User double click [T] element
|
|
44
|
-
User hover [T] icon | row
|
|
49
|
+
User hover [T] icon | row # no-op on mobile (see Platform Support)
|
|
45
50
|
User drag [T] to [T2]
|
|
46
51
|
User expand | collapse [T] row
|
|
47
52
|
```
|
|
@@ -60,15 +65,15 @@ NEVER use it for a click that is supposed to work — it deletes the actionabili
|
|
|
60
65
|
User click [T] button and accept [OK] alert # PREFERRED (v3.3): natural order,
|
|
61
66
|
User click [T] button and dismiss [Cancel] alert # compiler registers the listener first
|
|
62
67
|
User click [OK | Cancel] alert # two-step form: must come BEFORE the trigger
|
|
63
|
-
User fill [T] alert with {{v}}
|
|
68
|
+
User fill [T] alert with {{v}} # no-op on mobile — native prompt fill is app-specific
|
|
64
69
|
User see [message text] alert
|
|
65
70
|
User press Escape key | [Enter] key | Tab key 5 times | Enter on [T] field
|
|
66
|
-
User wait for N seconds | [T] page
|
|
71
|
+
User wait for N seconds | [T] page # [T] page: web waits for the URL; mobile pauses (settle) — see Platform Support
|
|
67
72
|
User wait for [T] TYPE is visible | hidden | enabled | disabled # ANY reference (v3.3)
|
|
68
73
|
User wait for [T] TYPE with {{v}} # until it shows the value
|
|
69
74
|
User wait for [T] table to refresh # filter/search/pagination round-trip (v3.3)
|
|
70
75
|
User scroll to [T] section
|
|
71
|
-
User switch to [T] frame | [main] frame
|
|
76
|
+
User switch to [T] frame | [main] frame # web: iframe; mobile: hybrid-app WebView context (no-op if the screen has no WebView)
|
|
72
77
|
```
|
|
73
78
|
|
|
74
79
|
> **Browser alerts (native `window.confirm/alert/prompt` only):** prefer the compound form —
|
|
@@ -81,7 +86,7 @@ User switch to [T] frame | [main] frame
|
|
|
81
86
|
> `wait for N seconds` stays a last resort. `table to refresh` watches the app's loading
|
|
82
87
|
> indicator (`qa/app.yaml` `feedback.loading.indicator`, default `[aria-busy="true"]`).
|
|
83
88
|
|
|
84
|
-
### Positional table rows (v3.3)
|
|
89
|
+
### Positional table rows (v3.3) `[web]`
|
|
85
90
|
|
|
86
91
|
```
|
|
87
92
|
User remember [Col] column in [T] table row {{n}} as {{var}} # read a cell by POSITION
|
|
@@ -135,6 +140,11 @@ Two asymmetries worth knowing rather than discovering:
|
|
|
135
140
|
2. **A repeated param matches as a subset per key**, which is the same rule as "extra params are
|
|
136
141
|
tolerated": every value you declare must be present, and the URL may carry more.
|
|
137
142
|
|
|
143
|
+
> **Mobile:** `Then User is on [T] page` **throws** (no URL/address bar on native). `Then User see
|
|
144
|
+
> [T] page` \| `page with {{v}}` **silently no-ops** — the compiled step asserts nothing and the
|
|
145
|
+
> scenario passes regardless. Never use Pattern 8 to prove "landed on screen X" on mobile — assert
|
|
146
|
+
> a screen-marker element instead (`Then User see [X] header`).
|
|
147
|
+
|
|
138
148
|
The predicate itself lives in `specs/url-assert.ts` (auto-generated, `DO NOT EDIT`). If `[T]` has no
|
|
139
149
|
`type: page` selector entry — or its key collides with a non-page entry, so `value` is something like
|
|
140
150
|
`button` rather than a URL — the step falls back to another path and cannot match the real URL. The
|
|
@@ -152,7 +162,7 @@ User see all [Product Card] contain [Add To Cart] button
|
|
|
152
162
|
|
|
153
163
|
Use the all-card form whenever a title claims *every / each* card/row exposes something — a single `User see [Add To Cart] button` does NOT prove "each card" and the harness Claim-Proof gate will flag it.
|
|
154
164
|
|
|
155
|
-
### Table
|
|
165
|
+
### Table `[web]`
|
|
156
166
|
|
|
157
167
|
```
|
|
158
168
|
User see [Col] column in [Table] table
|
|
@@ -176,7 +186,7 @@ first contact row:
|
|
|
176
186
|
```
|
|
177
187
|
→ compiles to `expect(table.locator('tbody tr:first-child')).toContainText(v)` — the exact row must hold the value — and still enters row scope for `[Col] column` checks.
|
|
178
188
|
|
|
179
|
-
### Browser storage
|
|
189
|
+
### Browser storage `[web]`
|
|
180
190
|
|
|
181
191
|
```
|
|
182
192
|
Then User see [KEY] in local storage exists
|
|
@@ -189,7 +199,7 @@ Then User see key matching "PATTERN" in local storage # regex over key name
|
|
|
189
199
|
|
|
190
200
|
`[KEY]` is a **storage key, not a selector** — never add it to selectors.yaml. It may embed `{{vars}}`: `[{{exclusive_code}}_ACCESS_TOKEN]`. The check runs inside the browser and returns only a boolean, so a failure message never contains the stored value (safe for tokens). There is deliberately no `equals {{expected}}` form. ⚠️ `expect [KEY] in local storage …` is NOT valid (`expect` reads `{{response}}` refs only) — the compiler warns SG-W011.
|
|
191
201
|
|
|
192
|
-
### Tab order
|
|
202
|
+
### Tab order `[web]`
|
|
193
203
|
|
|
194
204
|
```
|
|
195
205
|
Then User see tab order:
|
|
@@ -201,7 +211,7 @@ Then User see tab order:
|
|
|
201
211
|
|
|
202
212
|
Focuses row 1 (the pinned origin — there is no separate `focus [X]` step) and asserts it actually HOLDS focus (a non-focusable ref fails loudly), then presses Tab per following row and asserts it receives focus. Cell refs ARE selector references (resolved via selectors.yaml; optional element type after the ref). Requires the `| Ref |` header and ≥2 element rows — a missing header or single row is a compile error, never an empty pass. A mismatch reports the expected ref + the actual focused element (shadow-DOM-aware tag/role/name). Limitations: web only (no Appium); declare tab order OUTSIDE `use dialog`/frame scope (cell locators render page-rooted — put `scope: dialog` on the selector ENTRIES if the elements live in a dialog); focus traps / dynamic comboboxes / `tabindex=-1` reordering / WebKit differences may need `@manual` keyboard-only audits — those stay legitimate manuals.
|
|
203
213
|
|
|
204
|
-
### Network mocking (optional Mock Driver — `sungen capability add mock`)
|
|
214
|
+
### Network mocking `[web]` (optional Mock Driver — `sungen capability add mock`)
|
|
205
215
|
|
|
206
216
|
```gherkin
|
|
207
217
|
@mock
|
|
@@ -294,6 +304,42 @@ Full-shape contract check: `expect {{name.body}} matches schema [Ref]` validates
|
|
|
294
304
|
- **Error (4xx/5xx)** → assert the status (via `@cases` `expect_status` or an explicit `is 4xx`); assert the error message field when the contract defines one.
|
|
295
305
|
- **Anti-pattern** — re-asserting the value you just sent (`{{x.body.email}} is {{email}}` on the thing you created) proves little; assert a **server-derived** field (id, timestamp, computed status) or read it back.
|
|
296
306
|
|
|
307
|
+
### Platform Support — web-only / mobile-only / divergences
|
|
308
|
+
|
|
309
|
+
Every claim below is checked against a shipped `.hbs` under
|
|
310
|
+
`adapters/{playwright,appium}/templates/steps/` or a shipped diagnostic — see
|
|
311
|
+
`tests/codegen/adapter-template-parity.run.ts` `DIVERGENCES` for the authoritative one-sided list.
|
|
312
|
+
|
|
313
|
+
**Web-only `[web]`** — the Appium template throws, naming the reason: `fill [T] uploader with
|
|
314
|
+
{{f}}`, Positional table rows, the whole Table section, Browser storage, Tab order, `@mock`,
|
|
315
|
+
`Then User is on [T] page` (route-assertion). Each targets something native has no equivalent for
|
|
316
|
+
(HTML `<table>`, `<input type=file>`, DOM storage, keyboard-focus traversal, `page.route`, a URL bar).
|
|
317
|
+
|
|
318
|
+
**Mobile-only `[mobile]`** — the gesture catalog (swipe, long-press, pinch-zoom, pull-to-refresh,
|
|
319
|
+
rotate, background/foreground, notifications, grant-permission, clipboard set, set-geolocation,
|
|
320
|
+
hide-keyboard, tap-top-of) has no web counterpart. Full syntax → `sungen-mobile-gestures`.
|
|
321
|
+
|
|
322
|
+
**Divergences — compiles on both, means something different:**
|
|
323
|
+
|
|
324
|
+
| Step | Web | Mobile |
|
|
325
|
+
|---|---|---|
|
|
326
|
+
| `see [T] page` \| `page with {{v}}` | asserts path+query | **silent no-op** — asserts nothing; the scenario passes regardless. Assert a screen-marker element instead |
|
|
327
|
+
| `is on [T] page` \| `open [T] page` (Given/When) | navigates via URL | no-op — the app is already launched; use tap/gesture steps for mobile screen changes |
|
|
328
|
+
| `wait for [T] page` | waits for the URL | fixed `driver.pause(500)` settle — not a real wait condition |
|
|
329
|
+
| `hover [T] icon \| row` | real hover | no-op — hover-revealed content is normally already visible on mobile; use `tap` |
|
|
330
|
+
| `fill [T] alert with {{v}}` | fills native `prompt()` | no-op (comment only) — app-specific, handle manually |
|
|
331
|
+
| `switch to [T] frame` | enters an `<iframe>` | switches a hybrid app's WebView context; no-op on a pure-native screen (no WebView found) |
|
|
332
|
+
| `see [X] with {{v}}` (filtered visibility forms) | CSS `hasText` filter | hand-rolled substring match over `getText()`/`content-desc` (Android) or `label`/`value` (iOS) — same substring semantics, different attribute set |
|
|
333
|
+
| `… is sorted …` / `… is loading` inside a filtered row/state check | reads `aria-sort`/`aria-busy` | **throws** — no native analog for these two states specifically (the plain, unfiltered `is loading` on a spinner still works on both) |
|
|
334
|
+
| `scope: dialog` selector option | resolves inside the dialog | no effect (`SG-W021`) — steps resolve against the whole screen |
|
|
335
|
+
| `open notification panel` (mobile gesture) | n/a | Android-only — throws on iOS |
|
|
336
|
+
|
|
337
|
+
**Partial support, not full unsupported** — read the `.hbs` before marking anything `[web]`:
|
|
338
|
+
`all-contain-*`, `check`/`uncheck`/`toggle-action`, `contain-text`/`have-text-assertion`,
|
|
339
|
+
`visible-filtered-assertion`, `disabled`/`hidden-with-filter-assertion` are fully supported on
|
|
340
|
+
mobile even though a grep shows a `throw` somewhere in their file — the throw is a normal
|
|
341
|
+
zero-match assertion failure, not a platform gap.
|
|
342
|
+
|
|
297
343
|
### States
|
|
298
344
|
|
|
299
345
|
`hidden` `visible` `disabled` `enabled` `checked` `unchecked` `focused` `empty` `loading` `selected` `sorted ascending` `sorted descending`
|
|
@@ -366,6 +412,9 @@ award:
|
|
|
366
412
|
|
|
367
413
|
Options: `nth` `exact` `scope` `match` `variant` `frame` `contenteditable` `columns`
|
|
368
414
|
|
|
415
|
+
`scope` (e.g. `scope: dialog`) is `[web]`-effective only — no Appium template reads `inDialog`, so
|
|
416
|
+
on mobile a dialog-scoped ref still resolves against the whole screen (`SG-W021`).
|
|
417
|
+
|
|
369
418
|
## Tags
|
|
370
419
|
|
|
371
420
|
### Functional tags (affect code generation)
|
|
@@ -383,7 +432,7 @@ Options: `nth` `exact` `scope` `match` `variant` `frame` `contenteditable` `colu
|
|
|
383
432
|
| `@cleanup:scroll` | Auto-cleanup: scroll to top after each test (cleanupPage) |
|
|
384
433
|
| `@cleanup:storage` | Auto-cleanup: clear sessionStorage after each test (cleanupPage) |
|
|
385
434
|
| `@screenshot:on-failure` | Auto-capture screenshot when test fails (base.ts fixture) |
|
|
386
|
-
| `@parallel` | Opt-out: fresh page per test instead of serial default (for independent scenarios) |
|
|
435
|
+
| `@parallel` | Opt-out: fresh page per test instead of serial default (for independent scenarios). Compiles on mobile too, but a single device/emulator gets no session-isolation benefit from it |
|
|
387
436
|
| `@beforeAll` | Hook: runs once before all tests → `test.beforeAll()` |
|
|
388
437
|
| `@afterEach` | Hook: runs after each test → `test.afterEach()` (custom cleanup) |
|
|
389
438
|
| `@afterAll` | Hook: runs once after all tests → `test.afterAll()` |
|
|
@@ -10,7 +10,8 @@ Document the **mobile-only interactions** that have no web equivalent, so the AI
|
|
|
10
10
|
during exploration via Appium MCP and (b) write Gherkin steps for them. These are gestures the web
|
|
11
11
|
patterns (`click`, `hover`, `fill`) don't cover.
|
|
12
12
|
|
|
13
|
-
> Codegen status
|
|
13
|
+
> Codegen status: the Appium adapter **compiles** all of the following (verified against the shipped
|
|
14
|
+
> `.hbs` under `adapters/appium/templates/steps/{gestures,actions}/`):
|
|
14
15
|
> - **`tap` / `taps`** — synonym for `click` (→ `.click()`); **`double-tap`** → double-click.
|
|
15
16
|
> - **`scroll to [X]`** → `.scrollIntoView()` (shared `scroll-action` template).
|
|
16
17
|
> - **`swipe <dir> on [X]`** → `mobile: swipeGesture`.
|
|
@@ -24,9 +25,19 @@ patterns (`click`, `hover`, `fill`) don't cover.
|
|
|
24
25
|
> - **`tap top of [X]`** / **`tap [X] at top`** → tap the element's **visible top edge** (`mobile: clickGesture`
|
|
25
26
|
> at top-centre from the element bounds) instead of its centre — use when the centre is occluded by a
|
|
26
27
|
> floating bottom bar so a normal centre tap would hit the bar.
|
|
27
|
-
>
|
|
28
|
-
>
|
|
29
|
-
>
|
|
28
|
+
> - **`dismiss [X]`** (any non-alert element) → best-effort tap-if-shown-within-2.5s, never fails the
|
|
29
|
+
> step (`dismiss-action`) — for launch interstitials / promo overlays, not the native alert dialog
|
|
30
|
+
> (that's the existing `accept/dismiss [OK] alert` form).
|
|
31
|
+
> - **`hide the keyboard`** → `driver.hideKeyboard()`. **Android-only** — XCUITest cannot dismiss the
|
|
32
|
+
> keyboard generically (WDA throws + retries, ~12s wasted); on iOS the step is a silent best-effort
|
|
33
|
+
> no-op (never fails, just does nothing).
|
|
34
|
+
> - **`grant [X] permission`** → Android `mobile: changePermissions`; iOS (Simulator only) `mobile:
|
|
35
|
+
> setPermission` — needs the `applesimutils` binary on iOS or the driver fails loud with the install hint.
|
|
36
|
+
> - **`set the clipboard to {{v}}`** → `driver.setClipboard(...)`. **Write-only**: the appium adapter
|
|
37
|
+
> ships a `clipboard-text-assertion` template that reads the clipboard back, but no Gherkin pattern
|
|
38
|
+
> requests it yet — there is currently no phrasing that compiles to an actual clipboard-read
|
|
39
|
+
> assertion. Don't author "see clipboard contains X" expecting it to compile; tag it `@manual` instead.
|
|
40
|
+
> - **`set location to {{lat}}, {{lng}}`** → `driver.setGeoLocation(...)`.
|
|
30
41
|
>
|
|
31
42
|
> 📜 **`scroll to [X]` — two failure modes seen, with the real cause (measured):**
|
|
32
43
|
> 1. *"Default scrollable element '//android.widget.ScrollView' not found"* — wdio's mobile scroll runs
|
|
@@ -69,12 +80,14 @@ from `appium_find_element`; screen gestures pass `direction` or coordinates.
|
|
|
69
80
|
| System back | `User go back` | `action=back` |
|
|
70
81
|
| Drag & drop | `User drag [A] onto [B]` | `appium_drag_and_drop` (separate tool) |
|
|
71
82
|
|
|
72
|
-
Other device-level actions (separate MCP tools
|
|
83
|
+
Other device-level actions (separate MCP tools for exploration; Gherkin now compiles — see codegen
|
|
84
|
+
status above):
|
|
73
85
|
- Rotate: `appium_orientation` — `User rotate to landscape`
|
|
74
86
|
- Permission dialog: `appium_mobile_permissions` / `appium_alert` — `User grant [Location] permission`
|
|
75
87
|
- Background/foreground: `appium_app_lifecycle` — `User send app to background for 5 seconds`
|
|
76
|
-
- Clipboard: `appium_mobile_clipboard` — `User
|
|
77
|
-
|
|
88
|
+
- Clipboard write: `appium_mobile_clipboard` — `User set the clipboard to {{value}}` (read-back has
|
|
89
|
+
no Gherkin pattern yet — see codegen status above)
|
|
90
|
+
- Notifications: open panel via `appium_mobile_device_control` — `User open notification panel`
|
|
78
91
|
|
|
79
92
|
---
|
|
80
93
|
|
|
@@ -104,6 +117,7 @@ them stable (accessibility-id) so the scroll terminates reliably.
|
|
|
104
117
|
|
|
105
118
|
## What this skill does NOT do
|
|
106
119
|
|
|
107
|
-
- Does not implement gesture codegen (templates land in a later phase).
|
|
108
120
|
- Does not replace `sungen-gherkin-syntax` — it supplements it with the mobile-only step vocabulary.
|
|
109
121
|
- Does not cover tap/set-value/assertions (those are the shared Tier-1 patterns already supported).
|
|
122
|
+
- Does not yet support a clipboard-READ assertion via Gherkin (see "Write-only" note above) — the
|
|
123
|
+
template exists but no pattern requests it.
|