@sun-asterisk/sungen 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +3 -2
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/orchestrator/project-initializer.d.ts +3 -6
- package/dist/orchestrator/project-initializer.d.ts.map +1 -1
- package/dist/orchestrator/project-initializer.js +62 -58
- package/dist/orchestrator/project-initializer.js.map +1 -1
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +42 -0
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md +60 -0
- package/dist/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +59 -0
- package/dist/orchestrator/templates/ai-instructions/claude-config.md +90 -0
- package/dist/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +27 -0
- package/dist/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +123 -0
- package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +94 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +41 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-make-tc.md +59 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +58 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-config.md +90 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-skill-error-mapping.md +27 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-skill-gherkin-syntax.md +123 -0
- package/dist/orchestrator/templates/ai-instructions/copilot-skill-selector-keys.md +94 -0
- package/dist/orchestrator/templates/readme.md +42 -38
- package/docs/gherkin standards/gherkin-core-standard.md +141 -90
- package/docs/gherkin standards/gherkin-core-standard.vi.md +264 -54
- package/package.json +2 -2
- package/src/cli/commands/init.ts +3 -2
- package/src/cli/index.ts +1 -1
- package/src/orchestrator/project-initializer.ts +74 -58
- package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +42 -0
- package/src/orchestrator/templates/ai-instructions/claude-cmd-make-tc.md +60 -0
- package/src/orchestrator/templates/ai-instructions/claude-cmd-make-test.md +59 -0
- package/src/orchestrator/templates/ai-instructions/claude-config.md +90 -0
- package/src/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +27 -0
- package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +123 -0
- package/src/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +94 -0
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +41 -0
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-make-tc.md +59 -0
- package/src/orchestrator/templates/ai-instructions/copilot-cmd-make-test.md +58 -0
- package/src/orchestrator/templates/ai-instructions/copilot-config.md +90 -0
- package/src/orchestrator/templates/ai-instructions/copilot-skill-error-mapping.md +27 -0
- package/src/orchestrator/templates/ai-instructions/copilot-skill-gherkin-syntax.md +123 -0
- package/src/orchestrator/templates/ai-instructions/copilot-skill-selector-keys.md +94 -0
- package/src/orchestrator/templates/readme.md +42 -38
- package/dist/orchestrator/templates/ai-rules.md +0 -189
- package/src/orchestrator/templates/ai-rules.md +0 -189
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sungen v2 — Deterministic E2E Test Compiler
|
|
2
2
|
|
|
3
|
-
**Version**: 2.
|
|
3
|
+
**Version**: 2.1.0
|
|
4
4
|
**Gherkin + Selector YAML + Test Data → Playwright .spec.ts**
|
|
5
5
|
|
|
6
6
|
---
|
|
@@ -292,4 +292,4 @@ specs/generated/<name>/
|
|
|
292
292
|
|
|
293
293
|
MIT License - see LICENSE file for details.
|
|
294
294
|
|
|
295
|
-
**Made with ❤️ by Sun Asterisk**
|
|
295
|
+
**Made with ❤️ by ee team (engineer-excellence) — Sun Asterisk**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAe1D"}
|
|
@@ -5,10 +5,11 @@ function registerInitCommand(program) {
|
|
|
5
5
|
program
|
|
6
6
|
.command('init [projectName]')
|
|
7
7
|
.description('Initialize Sungen project (optionally create and initialize in a new project folder)')
|
|
8
|
-
.
|
|
8
|
+
.requiredOption('--base-url <url>', 'Base URL for Playwright tests (e.g. https://your-app.com)')
|
|
9
|
+
.action(async (projectName, options) => {
|
|
9
10
|
try {
|
|
10
11
|
const { ProjectInitializer } = require('../../orchestrator/project-initializer');
|
|
11
|
-
const initializer = new ProjectInitializer();
|
|
12
|
+
const initializer = new ProjectInitializer(options.baseUrl);
|
|
12
13
|
await initializer.initialize(projectName);
|
|
13
14
|
}
|
|
14
15
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":";;AAEA,kDAeC;AAfD,SAAgB,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,oBAAoB,CAAC;SAC7B,WAAW,CAAC,sFAAsF,CAAC;SACnG,cAAc,CAAC,kBAAkB,EAAE,2DAA2D,CAAC;SAC/F,MAAM,CAAC,KAAK,EAAE,WAA+B,EAAE,OAA4B,EAAE,EAAE;QAC9E,IAAI,CAAC;YACH,MAAM,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;YACjF,MAAM,WAAW,GAAG,IAAI,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC5D,MAAM,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
@@ -15,7 +15,7 @@ async function main() {
|
|
|
15
15
|
program
|
|
16
16
|
.name('sungen')
|
|
17
17
|
.description('Deterministic E2E Test Compiler — Gherkin + Selectors → Playwright')
|
|
18
|
-
.version('2.0
|
|
18
|
+
.version('2.1.0');
|
|
19
19
|
// Global options
|
|
20
20
|
program
|
|
21
21
|
.option('-v, --verbose', 'Enable verbose logging');
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* Creates essential directory structure for Sungen pipeline
|
|
4
4
|
*/
|
|
5
5
|
export declare class ProjectInitializer {
|
|
6
|
+
private baseUrl;
|
|
6
7
|
private baseCwd;
|
|
7
8
|
private cwd;
|
|
8
9
|
private createdItems;
|
|
9
10
|
private skippedItems;
|
|
10
|
-
constructor();
|
|
11
|
+
constructor(baseUrl: string);
|
|
11
12
|
/**
|
|
12
13
|
* Initialize project with essential directories and config
|
|
13
14
|
*/
|
|
@@ -44,14 +45,10 @@ export declare class ProjectInitializer {
|
|
|
44
45
|
* Read a template file from the templates directory
|
|
45
46
|
*/
|
|
46
47
|
private readTemplate;
|
|
47
|
-
/**
|
|
48
|
-
* Get AI rules content (shared between Copilot and Claude)
|
|
49
|
-
*/
|
|
50
|
-
private getAIRulesContent;
|
|
51
48
|
/**
|
|
52
49
|
* Check for required dependencies
|
|
53
50
|
*/
|
|
54
|
-
private
|
|
51
|
+
private setupDependencies;
|
|
55
52
|
/**
|
|
56
53
|
* Get Playwright configuration template
|
|
57
54
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-initializer.d.ts","sourceRoot":"","sources":["../../src/orchestrator/project-initializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"project-initializer.d.ts","sourceRoot":"","sources":["../../src/orchestrator/project-initializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,qBAAa,kBAAkB;IAMjB,OAAO,CAAC,OAAO;IAL3B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,YAAY,CAAgB;gBAEhB,OAAO,EAAE,MAAM;IAKnC;;OAEG;IACG,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCrD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IASzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAoBzB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAc9B;;OAEG;IACH,OAAO,CAAC,eAAe;IA+BvB;;OAEG;IACH,OAAO,CAAC,YAAY;IAapB;;OAEG;IACH,OAAO,CAAC,cAAc;IA4BtB;;OAEG;IACH,OAAO,CAAC,aAAa;IAmDrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAKpB;;OAEG;YACW,iBAAiB;IA+B/B;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAInC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAG1B"}
|
|
@@ -40,8 +40,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.ProjectInitializer = void 0;
|
|
41
41
|
const fs = __importStar(require("fs"));
|
|
42
42
|
const path = __importStar(require("path"));
|
|
43
|
+
const child_process_1 = require("child_process");
|
|
43
44
|
class ProjectInitializer {
|
|
44
|
-
constructor() {
|
|
45
|
+
constructor(baseUrl) {
|
|
46
|
+
this.baseUrl = baseUrl;
|
|
45
47
|
this.createdItems = [];
|
|
46
48
|
this.skippedItems = [];
|
|
47
49
|
this.baseCwd = process.cwd();
|
|
@@ -63,6 +65,8 @@ class ProjectInitializer {
|
|
|
63
65
|
}
|
|
64
66
|
// Create directories
|
|
65
67
|
this.createDirectories();
|
|
68
|
+
// Ensure package.json and install Playwright
|
|
69
|
+
await this.setupDependencies();
|
|
66
70
|
// Create playwright config if doesn't exist
|
|
67
71
|
this.createPlaywrightConfig();
|
|
68
72
|
// Create/update .gitignore
|
|
@@ -117,7 +121,8 @@ class ProjectInitializer {
|
|
|
117
121
|
this.skippedItems.push('playwright.config.ts');
|
|
118
122
|
return;
|
|
119
123
|
}
|
|
120
|
-
const configContent = this.getPlaywrightConfigTemplate()
|
|
124
|
+
const configContent = this.getPlaywrightConfigTemplate()
|
|
125
|
+
.replace('https://example.com', this.baseUrl);
|
|
121
126
|
fs.writeFileSync(configPath, configContent, 'utf-8');
|
|
122
127
|
this.createdItems.push('playwright.config.ts');
|
|
123
128
|
}
|
|
@@ -184,8 +189,6 @@ class ProjectInitializer {
|
|
|
184
189
|
console.log(` ⊳ ${item}`);
|
|
185
190
|
});
|
|
186
191
|
}
|
|
187
|
-
// Check for Playwright installation
|
|
188
|
-
this.checkDependencies();
|
|
189
192
|
console.log('\nNext steps:');
|
|
190
193
|
let stepIndex = 1;
|
|
191
194
|
if (projectName) {
|
|
@@ -200,48 +203,43 @@ class ProjectInitializer {
|
|
|
200
203
|
* Create AI rules files for GitHub Copilot and Claude Code
|
|
201
204
|
*/
|
|
202
205
|
createAIRules() {
|
|
203
|
-
const
|
|
204
|
-
//
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const packageDictPath = path.join(__dirname, '..', '..', 'docs', 'gherkin-dictionary.md');
|
|
232
|
-
if (!fs.existsSync(docsDir)) {
|
|
233
|
-
fs.mkdirSync(docsDir, { recursive: true });
|
|
234
|
-
}
|
|
235
|
-
if (fs.existsSync(packageDictPath)) {
|
|
236
|
-
fs.copyFileSync(packageDictPath, dictPath);
|
|
206
|
+
const aiTemplateDir = path.join(__dirname, 'templates', 'ai-instructions');
|
|
207
|
+
// File mapping: [templateFile, outputPath]
|
|
208
|
+
const fileMapping = [
|
|
209
|
+
// Config
|
|
210
|
+
['claude-config.md', 'CLAUDE.md'],
|
|
211
|
+
['copilot-config.md', '.github/copilot-instructions.md'],
|
|
212
|
+
// Commands — Claude Code
|
|
213
|
+
['claude-cmd-add-screen.md', '.claude/commands/sungen/add-screen.md'],
|
|
214
|
+
['claude-cmd-make-tc.md', '.claude/commands/sungen/make-tc.md'],
|
|
215
|
+
['claude-cmd-make-test.md', '.claude/commands/sungen/make-test.md'],
|
|
216
|
+
// Commands — GitHub Copilot
|
|
217
|
+
['copilot-cmd-add-screen.md', '.github/prompts/sungen-add-screen.prompt.md'],
|
|
218
|
+
['copilot-cmd-make-tc.md', '.github/prompts/sungen-make-tc.prompt.md'],
|
|
219
|
+
['copilot-cmd-make-test.md', '.github/prompts/sungen-make-test.prompt.md'],
|
|
220
|
+
// Skills — Claude Code
|
|
221
|
+
['claude-skill-gherkin-syntax.md', '.claude/skills/sungen-gherkin-syntax/SKILL.md'],
|
|
222
|
+
['claude-skill-selector-keys.md', '.claude/skills/sungen-selector-keys/SKILL.md'],
|
|
223
|
+
['claude-skill-error-mapping.md', '.claude/skills/sungen-error-mapping/SKILL.md'],
|
|
224
|
+
// Skills — GitHub Copilot
|
|
225
|
+
['copilot-skill-gherkin-syntax.md', '.github/prompts/sungen-gherkin-syntax.prompt.md'],
|
|
226
|
+
['copilot-skill-selector-keys.md', '.github/prompts/sungen-selector-keys.prompt.md'],
|
|
227
|
+
['copilot-skill-error-mapping.md', '.github/prompts/sungen-error-mapping.prompt.md'],
|
|
228
|
+
];
|
|
229
|
+
for (const [templateFile, outputRelPath] of fileMapping) {
|
|
230
|
+
const outputPath = path.join(this.cwd, outputRelPath);
|
|
231
|
+
if (fs.existsSync(outputPath)) {
|
|
232
|
+
this.skippedItems.push(outputRelPath);
|
|
233
|
+
continue;
|
|
237
234
|
}
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
const outputDir = path.dirname(outputPath);
|
|
236
|
+
if (!fs.existsSync(outputDir)) {
|
|
237
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
240
238
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
this.
|
|
239
|
+
const templatePath = path.join(aiTemplateDir, templateFile);
|
|
240
|
+
const content = fs.readFileSync(templatePath, 'utf-8');
|
|
241
|
+
fs.writeFileSync(outputPath, content, 'utf-8');
|
|
242
|
+
this.createdItems.push(outputRelPath);
|
|
245
243
|
}
|
|
246
244
|
}
|
|
247
245
|
/**
|
|
@@ -251,29 +249,35 @@ class ProjectInitializer {
|
|
|
251
249
|
const templatePath = path.join(__dirname, 'templates', filename);
|
|
252
250
|
return fs.readFileSync(templatePath, 'utf-8');
|
|
253
251
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Get AI rules content (shared between Copilot and Claude)
|
|
256
|
-
*/
|
|
257
|
-
getAIRulesContent() {
|
|
258
|
-
return this.readTemplate('ai-rules.md');
|
|
259
|
-
}
|
|
260
252
|
/**
|
|
261
253
|
* Check for required dependencies
|
|
262
254
|
*/
|
|
263
|
-
|
|
255
|
+
async setupDependencies() {
|
|
256
|
+
const packageJsonPath = path.join(this.cwd, 'package.json');
|
|
257
|
+
const execOpts = { cwd: this.cwd, stdio: 'inherit' };
|
|
258
|
+
// Initialize package.json if it doesn't exist
|
|
259
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
260
|
+
console.log('📦 No package.json found. Initializing...\n');
|
|
261
|
+
(0, child_process_1.execSync)('npm init -y', execOpts);
|
|
262
|
+
this.createdItems.push('package.json');
|
|
263
|
+
}
|
|
264
|
+
// Check if @playwright/test is already installed
|
|
264
265
|
try {
|
|
265
|
-
const packageJsonPath = path.join(this.cwd, 'package.json');
|
|
266
266
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
267
267
|
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
268
|
-
if (
|
|
269
|
-
console.log('
|
|
270
|
-
|
|
271
|
-
console.log(' npx playwright install');
|
|
268
|
+
if (deps['@playwright/test']) {
|
|
269
|
+
console.log('✓ @playwright/test already installed\n');
|
|
270
|
+
return;
|
|
272
271
|
}
|
|
273
272
|
}
|
|
274
|
-
catch
|
|
275
|
-
//
|
|
273
|
+
catch {
|
|
274
|
+
// package.json just created, proceed with install
|
|
276
275
|
}
|
|
276
|
+
// Install Playwright
|
|
277
|
+
console.log('📦 Installing @playwright/test...\n');
|
|
278
|
+
(0, child_process_1.execSync)('npm install -D @playwright/test', execOpts);
|
|
279
|
+
console.log('\n🎭 Installing Playwright browsers...\n');
|
|
280
|
+
(0, child_process_1.execSync)('npx playwright install', execOpts);
|
|
277
281
|
}
|
|
278
282
|
/**
|
|
279
283
|
* Get Playwright configuration template
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-initializer.js","sourceRoot":"","sources":["../../src/orchestrator/project-initializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;
|
|
1
|
+
{"version":3,"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AE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACK,2BAA2B;QACjC,OAAO,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACK,oBAAoB;QAC1B,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACK,iBAAiB;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;CACF;AA3SD,gDA2SC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: add-screen
|
|
3
|
+
description: 'Add a new Sungen screen — scaffolds directories and delegates to make-tc for test case creation'
|
|
4
|
+
argument-hint: [screen-name] [url-path]
|
|
5
|
+
allowed-tools: Read, Grep, Bash, Glob
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are adding a new Sungen screen for test generation.
|
|
9
|
+
|
|
10
|
+
## Parameters
|
|
11
|
+
|
|
12
|
+
Parse from `$ARGUMENTS`:
|
|
13
|
+
- **screen** — screen name (e.g., `login`, `dashboard`, `settings`)
|
|
14
|
+
- **path** — URL path (e.g., `/login`, `/dashboard`, `/settings`)
|
|
15
|
+
|
|
16
|
+
If **screen** is missing, ask: "What is the screen name? (e.g., `login`, `dashboard`)"
|
|
17
|
+
If **path** is missing, ask: "What is the URL path? (e.g., `/login`, `/dashboard`)"
|
|
18
|
+
|
|
19
|
+
## Steps
|
|
20
|
+
|
|
21
|
+
### 1. Scaffold the screen
|
|
22
|
+
|
|
23
|
+
Run:
|
|
24
|
+
```bash
|
|
25
|
+
sungen add --screen <screen> --path <path>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Create test cases
|
|
29
|
+
|
|
30
|
+
Ask the user: "Would you like to create test cases now?"
|
|
31
|
+
|
|
32
|
+
If yes, delegate to `/sungen:make-tc <screen>` to handle:
|
|
33
|
+
- Exploring the live page or analyzing static designs
|
|
34
|
+
- Gathering test viewpoints (UI/UX, Validation, Logic, Security)
|
|
35
|
+
- Generating the 3 files (feature, selectors, test-data)
|
|
36
|
+
|
|
37
|
+
### 3. Confirm
|
|
38
|
+
|
|
39
|
+
Tell the user what was created and next steps:
|
|
40
|
+
- If the page requires authentication before exploring via browser, read `baseURL` from `playwright.config.ts` and tell the user to manually run: `sungen makeauth <role> --url <baseURL>` (e.g., `sungen makeauth admin --url http://localhost:3000`). **Do NOT execute this command yourself.**
|
|
41
|
+
- Edit the generated files as needed
|
|
42
|
+
- Run `sungen generate --screen <screen>` to compile to Playwright `.spec.ts`
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: make-tc
|
|
3
|
+
description: 'Create test cases for a Sungen screen — gathers viewpoints, explores live page or static designs, generates feature/selectors/test-data files'
|
|
4
|
+
argument-hint: [screen-name]
|
|
5
|
+
allowed-tools: Read, Grep, Bash, Glob
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Role
|
|
9
|
+
|
|
10
|
+
You are a **Senior QA Engineer** specialized in test case design. You structure test cases by viewpoint categories and translate UI into Gherkin test cases following the `sungen-gherkin-syntax` and `sungen-selector-keys` skills.
|
|
11
|
+
|
|
12
|
+
## Parameters
|
|
13
|
+
|
|
14
|
+
Parse from `$ARGUMENTS`:
|
|
15
|
+
- **screen** — screen name (e.g., `login`, `dashboard`)
|
|
16
|
+
|
|
17
|
+
If missing, ask the user.
|
|
18
|
+
|
|
19
|
+
## Steps
|
|
20
|
+
|
|
21
|
+
### 1. Verify screen exists
|
|
22
|
+
|
|
23
|
+
Check `qa/screens/<screen>/` exists. If not, tell user to run `/sungen:add-screen` first.
|
|
24
|
+
|
|
25
|
+
### 2. Determine source mode
|
|
26
|
+
|
|
27
|
+
Ask: "Do you have a **live page** or **static designs** (screenshots, Figma, images)?"
|
|
28
|
+
|
|
29
|
+
**Live page →** explore via browser (see CLAUDE.md for Playwright MCP rules). If auth needed, check `specs/.auth/<role>.json` exists — if not, read `baseURL` from `playwright.config.ts` and tell the user to manually run: `sungen makeauth <role> --url <baseURL>` (e.g., `sungen makeauth admin --url http://localhost:3000`). **Do NOT execute `sungen makeauth` yourself.** Wait for the user to confirm auth is ready before proceeding.
|
|
30
|
+
|
|
31
|
+
**Static designs →** ask user to provide screenshot paths, Figma exports, or UI descriptions. Note: selectors will be best-guess until live page is available.
|
|
32
|
+
|
|
33
|
+
Present discovered elements to user, then proceed.
|
|
34
|
+
|
|
35
|
+
### 3. Gather test viewpoints
|
|
36
|
+
|
|
37
|
+
| VP Category | Description |
|
|
38
|
+
|---|---|
|
|
39
|
+
| **UI/UX** | Default screen appearance, static elements, default states |
|
|
40
|
+
| **Validation** | Field/form validation, error messages |
|
|
41
|
+
| **Logic** | Business logic, happy paths, redirects |
|
|
42
|
+
| **Security** | Auth guards, permission checks |
|
|
43
|
+
|
|
44
|
+
For each viewpoint, gather: **UI Target**, **Test Viewpoint**, **Expected Result**.
|
|
45
|
+
|
|
46
|
+
User can provide all at once as a table:
|
|
47
|
+
```
|
|
48
|
+
| VP Category | UI Target | Test Viewpoint | Expected Result |
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 4. Generate files
|
|
52
|
+
|
|
53
|
+
Generate the 3 files following `sungen-gherkin-syntax` and `sungen-selector-keys` skill rules:
|
|
54
|
+
- `qa/screens/<screen>/features/<screen>.feature` — one Scenario per viewpoint
|
|
55
|
+
- `qa/screens/<screen>/selectors/<screen>.yaml`
|
|
56
|
+
- `qa/screens/<screen>/test-data/<screen>.yaml`
|
|
57
|
+
|
|
58
|
+
### 5. Confirm
|
|
59
|
+
|
|
60
|
+
Show what was generated. Next: `sungen generate --screen <screen>`
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: make-test
|
|
3
|
+
description: 'Compile and run Playwright tests for a Sungen screen — auto-fixes selectors on failure, falls back to AI .spec.ts fix after 5 attempts'
|
|
4
|
+
argument-hint: [screen-name]
|
|
5
|
+
allowed-tools: Read, Grep, Bash, Glob, Edit
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Role
|
|
9
|
+
|
|
10
|
+
You are a **Senior Developer** specialized in Playwright test debugging. You diagnose test failures, fix selectors/test-data, and patch `.spec.ts` when needed. Use the `sungen-error-mapping` and `sungen-selector-keys` skills for error diagnosis and key fixes.
|
|
11
|
+
|
|
12
|
+
## Parameters
|
|
13
|
+
|
|
14
|
+
Parse from `$ARGUMENTS`:
|
|
15
|
+
- **screen** — screen name (e.g., `login`, `dashboard`)
|
|
16
|
+
|
|
17
|
+
If missing, ask the user.
|
|
18
|
+
|
|
19
|
+
## Steps
|
|
20
|
+
|
|
21
|
+
### 1. Verify screen exists
|
|
22
|
+
|
|
23
|
+
Check `qa/screens/<screen>/` has all 3 source files. If not, tell user to run `/sungen:add-screen` and `/sungen:make-tc` first.
|
|
24
|
+
|
|
25
|
+
### 2. Compile
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
sungen generate --screen <screen>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If fails, fix source files per `sungen-error-mapping` skill and retry.
|
|
32
|
+
|
|
33
|
+
### 3. Run tests
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx playwright test specs/screens/<screen>/<screen>.spec.ts
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If pass → Step 5. If fail → Step 4.
|
|
40
|
+
|
|
41
|
+
### 4. Fix and retry (max 5 attempts)
|
|
42
|
+
|
|
43
|
+
Per attempt:
|
|
44
|
+
1. Read Playwright error output
|
|
45
|
+
2. Map error to fix using `sungen-error-mapping` skill
|
|
46
|
+
3. Fix `selectors.yaml` or `test-data.yaml`
|
|
47
|
+
4. Recompile: `sungen generate --screen <screen>`
|
|
48
|
+
5. Retest
|
|
49
|
+
|
|
50
|
+
### 5. Fallback — AI fix .spec.ts
|
|
51
|
+
|
|
52
|
+
After 5 failed attempts, ask user:
|
|
53
|
+
> Tests still failing. Would you like me to directly fix the `.spec.ts` file?
|
|
54
|
+
|
|
55
|
+
If yes: read `.spec.ts`, fix locators/assertions, mark with `// AI-fixed: <reason>`
|
|
56
|
+
|
|
57
|
+
### 6. Confirm
|
|
58
|
+
|
|
59
|
+
Show: pass/fail, attempt count, files changed.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Sungen AI Rules
|
|
2
|
+
|
|
3
|
+
You generate 3 files for sungen — a Gherkin compiler that produces Playwright tests.
|
|
4
|
+
**You do NOT write Playwright code.** You only write `.feature`, `selectors.yaml`, and `test-data.yaml`.
|
|
5
|
+
|
|
6
|
+
For Gherkin syntax, selector types, and YAML rules, the `sungen-gherkin-syntax` skill is auto-loaded when needed.
|
|
7
|
+
For error diagnosis, the `sungen-error-mapping` skill is auto-loaded when needed.
|
|
8
|
+
|
|
9
|
+
## Complete Example
|
|
10
|
+
|
|
11
|
+
Given a login page, here are the 3 files you generate:
|
|
12
|
+
|
|
13
|
+
**qa/screens/login/features/login.feature**
|
|
14
|
+
```gherkin
|
|
15
|
+
@auth:admin
|
|
16
|
+
Feature: Login Screen
|
|
17
|
+
|
|
18
|
+
Scenario: Successful login
|
|
19
|
+
Given User is on [login] page
|
|
20
|
+
When User fill [Email] field with {{email}}
|
|
21
|
+
And User fill [Password] field with {{password}}
|
|
22
|
+
And User click [Submit] button
|
|
23
|
+
Then User see [Welcome] heading with {{welcome_text}}
|
|
24
|
+
And User see [Dashboard] link is visible
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**qa/screens/login/selectors/login.yaml**
|
|
28
|
+
```yaml
|
|
29
|
+
login:
|
|
30
|
+
type: 'page'
|
|
31
|
+
value: '/login'
|
|
32
|
+
|
|
33
|
+
email:
|
|
34
|
+
type: 'placeholder'
|
|
35
|
+
value: 'Enter your email'
|
|
36
|
+
|
|
37
|
+
password:
|
|
38
|
+
type: 'placeholder'
|
|
39
|
+
value: 'Enter your password'
|
|
40
|
+
|
|
41
|
+
submit:
|
|
42
|
+
type: 'role'
|
|
43
|
+
value: 'button'
|
|
44
|
+
name: 'Submit'
|
|
45
|
+
|
|
46
|
+
welcome:
|
|
47
|
+
type: 'role'
|
|
48
|
+
value: 'heading'
|
|
49
|
+
name: 'Welcome'
|
|
50
|
+
|
|
51
|
+
dashboard:
|
|
52
|
+
type: 'role'
|
|
53
|
+
value: 'link'
|
|
54
|
+
name: 'Dashboard'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**qa/screens/login/test-data/login.yaml**
|
|
58
|
+
```yaml
|
|
59
|
+
email: 'admin@example.com'
|
|
60
|
+
password: 'password123'
|
|
61
|
+
welcome_text: 'Welcome back'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Using Playwright MCP to explore pages
|
|
65
|
+
|
|
66
|
+
When exploring a page to generate test files:
|
|
67
|
+
1. Read `playwright.config.ts` for `baseURL`
|
|
68
|
+
2. Use `browser_navigate` to open `baseURL + /path`
|
|
69
|
+
3. Use `browser_snapshot` to see all elements
|
|
70
|
+
4. Generate the 3 files from the snapshot
|
|
71
|
+
|
|
72
|
+
**NEVER use `browser_run_code`.** It fails with `require is not defined`.
|
|
73
|
+
Only use: `browser_navigate`, `browser_snapshot`, `browser_click`, `browser_fill_form`, `browser_evaluate`.
|
|
74
|
+
|
|
75
|
+
To browse authenticated pages via MCP:
|
|
76
|
+
1. Check if `specs/.auth/<role>.json` exists
|
|
77
|
+
2. If not, read `baseURL` from `playwright.config.ts` and tell the user to manually run: `sungen makeauth <role> --url <baseURL>`. **Do NOT execute `sungen makeauth` yourself.** Wait for user confirmation.
|
|
78
|
+
3. Read `specs/.auth/<role>.json`
|
|
79
|
+
4. `browser_navigate` to the page
|
|
80
|
+
5. `browser_evaluate` to inject localStorage and cookies from the JSON
|
|
81
|
+
6. `browser_navigate` again to reload with auth
|
|
82
|
+
|
|
83
|
+
## Commands
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
sungen add --screen <name> --path <url-path> # Create screen
|
|
87
|
+
sungen generate --screen <name> # Compile to .spec.ts
|
|
88
|
+
sungen generate --all # Compile all
|
|
89
|
+
sungen makeauth <role> # Capture auth state
|
|
90
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sungen-error-mapping
|
|
3
|
+
description: 'Playwright and Sungen error to fix mapping. Auto-loaded when running or debugging tests.'
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Playwright Errors → Fix
|
|
8
|
+
|
|
9
|
+
| Error | Fix in `selectors.yaml` |
|
|
10
|
+
|---|---|
|
|
11
|
+
| strict mode violation | add `nth`, `exact: true`, or specific `name` |
|
|
12
|
+
| Element is not an input | change `type` or `value` |
|
|
13
|
+
| Timeout waiting for selector | fix `type`/`value`/`name` to match element |
|
|
14
|
+
| toBeVisible Timeout | verify accessible name or use `testid` |
|
|
15
|
+
| toHaveText mismatch | fix in `test-data.yaml` |
|
|
16
|
+
| Navigation failed | fix page `value` path |
|
|
17
|
+
| not a select | set `variant: 'custom'` |
|
|
18
|
+
| Frame not found | fix `frame` value |
|
|
19
|
+
|
|
20
|
+
## Sungen Errors → Fix
|
|
21
|
+
|
|
22
|
+
| Error | Fix |
|
|
23
|
+
|---|---|
|
|
24
|
+
| Unknown step pattern | rewrite `.feature` step to match supported pattern |
|
|
25
|
+
| Missing selector | add key to `selectors.yaml` |
|
|
26
|
+
| Missing variable | add key to `test-data.yaml` |
|
|
27
|
+
| Invalid selector type | use: role/testid/placeholder/label/text/locator/page/upload/frame |
|