@cementic/cementic-test 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,460 +1,377 @@
1
- # CementicTest CLI
1
+ # 🚀 CementicTest CLI
2
2
 
3
- CementicTest CLI (`ct`) turns plain-English test cases into runnable Playwright tests with a Page Object Model-oriented workflow.
3
+ Turn plain English into **production-ready Playwright tests** instantly.
4
4
 
5
- ## Project links
5
+ No setup headaches. No framework confusion. Just run and automate.
6
6
 
7
- - Website: https://cementic.testamplify.io/
8
- - Community: https://t.me/+Wbx7oK7ivqgxZGJh
9
- - Web app: browser-based AI testing workflow coming soon
7
+ ---
10
8
 
11
- Current pipeline:
9
+ ## ⚡ Run instantly (no install)
12
10
 
13
- ```text
14
- ct tc -> ct normalize -> ct gen -> ct test
11
+ ```bash
12
+ npx @cementic/cementic-test
15
13
  ```
16
14
 
17
- It can scaffold a project, write or AI-generate case files, normalize them into JSON, generate Playwright specs plus page objects, and run the resulting suite.
15
+ Works even if your npm environment isn’t perfectly configured.
18
16
 
19
- ## Project status
17
+ ---
20
18
 
21
- This repository currently ships the CLI workflow.
19
+ ## 💡 What this does
22
20
 
23
- The browser-based web app is in progress and early product updates will be shared on the website and in the community channel.
21
+ CementicTest converts:
24
22
 
25
- ## What this version does
23
+ 👉 Plain English
24
+ 👉 Into structured test cases
25
+ 👉 Into Playwright specs + Page Objects
26
+ 👉 Then runs them
26
27
 
27
- - Scaffolds new Playwright projects in JavaScript or TypeScript
28
- - Generates Markdown test cases manually or with AI
29
- - Supports URL-aware case generation with live page capture
30
- - Normalizes case files into structured JSON
31
- - Generates Playwright specs and POM classes from normalized cases
32
- - Avoids overwriting existing generated page-object files
33
- - Runs Playwright tests through a CLI wrapper
34
- - Opens Playwright HTML reports
35
- - Serves Allure reports if Allure is installed in the target project
36
- - Generates a GitHub Actions workflow for Playwright CI
28
+ All from your terminal.
37
29
 
38
- ## Installation
30
+ ---
39
31
 
40
- ```bash
41
- # Run without a global install
42
- npx @cementic/cementic-test --help
32
+ ## 🧠 Why it’s different
43
33
 
44
- # Or install globally
45
- npm install -g @cementic/cementic-test
46
- ```
34
+ * No framework setup required
35
+ * No Playwright expertise needed
36
+ * No manual scripting to get started
37
+ * AI-assisted test generation
38
+ * Built-in Page Object Model (POM) structure
39
+ * Works from **day one**
40
+
41
+ ---
47
42
 
48
- Requirements:
43
+ ## 🧪 What you can do
49
44
 
50
- - Node.js 18+
51
- - npm
45
+ * Generate test cases (manual or AI)
46
+ * Capture real websites and generate tests
47
+ * Convert cases → JSON → Playwright code
48
+ * Run tests instantly
49
+ * Generate CI workflows
50
+ * View reports (Playwright + Allure)
52
51
 
53
- ## Quick start
52
+ ---
54
53
 
55
- ### JavaScript project
54
+ ## 60-second quick start
56
55
 
57
56
  ```bash
58
- ct new demo-js --lang js
59
- cd demo-js
60
- ct tc --feature "Login form" --count 2
61
- ct normalize ./cases --and-gen --lang js
62
- ct test
57
+ npx @cementic/cementic-test
63
58
  ```
64
59
 
65
- ### TypeScript project
60
+ Then:
66
61
 
67
62
  ```bash
68
- ct new demo-ts --lang ts
69
- cd demo-ts
70
- ct tc url https://mini-bank.testamplify.com/login --feature "Login" --count 2
71
- ct normalize ./cases --and-gen --lang ts
63
+ ct new demo
64
+ cd demo
65
+
66
+ ct tc --feature "Login form" --count 2
67
+ ct normalize ./cases --and-gen
72
68
  ct test
73
69
  ```
74
70
 
75
- ## Command flow
71
+ Done. You just created and ran automation.
76
72
 
77
- ### 1. `ct new <projectName>`
73
+ ---
78
74
 
79
- Scaffolds a new CementicTest + Playwright project.
75
+ ## 🌐 Generate tests from a real website
80
76
 
81
77
  ```bash
82
- ct new my-suite
83
- ct new my-suite --lang ts
84
- ct new my-suite --no-browsers
78
+ ct tc url https://mini-bank.testamplify.com/login --ai --feature "Login" --count 2
85
79
  ```
86
80
 
87
- Current scaffold support:
88
-
89
- - `--lang js`: JavaScript template with:
90
- - `pages/BasePage.js`
91
- - `pages/LoginPage.js`
92
- - `pages/DashboardPage.js`
93
- - `pages/FormPage.js`
94
- - `tests/login.spec.js`
95
- - `tests/dashboard.spec.js`
96
- - `--lang ts`: TypeScript template with:
97
- - `pages/LandingPage.ts`
98
- - `tests/landing.spec.ts`
99
- - `tsconfig.json`
100
- - `playwright.config.ts`
81
+ This will:
101
82
 
102
- What `ct new` does:
83
+ * Capture the page
84
+ * Understand elements
85
+ * Generate realistic test scenarios
86
+ * Produce runnable Playwright tests
103
87
 
104
- - creates the project directory
105
- - copies the selected template
106
- - initializes git
107
- - runs `npm install`
108
- - optionally runs `npx playwright install`
88
+ Important:
109
89
 
110
- ### 2. `ct tc`
90
+ * Live capture resolves Playwright from your current project first
91
+ * If you are inside a project created with `ct new`, `ct tc url --ai` uses that project's local `@playwright/test`
92
+ * If Playwright is missing or Chromium is not installed, the CLI now prints the exact next step instead of failing with a package-resolution stack trace
111
93
 
112
- Creates Markdown case files in `./cases`.
94
+ ---
113
95
 
114
- Interactive mode:
96
+ ## 🧱 How it works
115
97
 
116
- ```bash
117
- ct tc
98
+ ```text
99
+ Plain English → Markdown Cases
100
+ → Normalized JSON
101
+ → Playwright Specs + POM
102
+ → Test Execution
118
103
  ```
119
104
 
120
- Non-interactive mode:
105
+ ---
121
106
 
122
- ```bash
123
- ct tc --feature "Checkout" --desc "Guest checkout flow" --count 3
124
- ```
107
+ ## ⚠️ If install fails (important)
125
108
 
126
- AI mode:
109
+ If you see something like:
127
110
 
128
- ```bash
129
- ct tc --ai --feature "Login" --count 3
130
111
  ```
112
+ npm ERR! Cannot read properties of null (reading 'matches')
113
+ ```
114
+
115
+ 👉 That’s an npm issue, not CementicTest.
131
116
 
132
- ### 3. `ct tc url <url>`
117
+ ### Fix instantly
133
118
 
134
- Generates cases with awareness of a live page.
119
+ Just run:
135
120
 
136
121
  ```bash
137
- ct tc url https://mini-bank.testamplify.com/login --feature "Login" --count 2
138
- ct tc url https://mini-bank.testamplify.com/login --ai --feature "Login" --count 2
139
- ct tc url https://mini-bank.testamplify.com/login --ai --headed --feature "Login"
140
- ct tc url https://mini-bank.testamplify.com/login --ai --capture-only --feature "Login"
122
+ npx @cementic/cementic-test
141
123
  ```
142
124
 
143
- Current behavior:
144
-
145
- - captures a live page with Playwright and extracts headings, buttons, links, inputs, status regions, and selector candidates
146
- - sends that captured element map to the capture-aware AI flow when `--ai` is enabled
147
- - saves the full capture artifact to `.cementic/capture/capture-*.json`
148
- - saves a runnable preview spec to `tests/preview/spec-preview-*.spec.cjs` when AI scenarios are generated
149
- - writes `<!-- ct:url ... -->` metadata plus selector and `playwright` hints into generated Markdown so normalization and generation preserve the capture output
125
+ No install needed.
150
126
 
151
- ### 4. `ct normalize <path>`
127
+ ---
152
128
 
153
- Converts case files into normalized JSON in `.cementic/normalized/`.
129
+ ## 🧰 Optional install
154
130
 
155
131
  ```bash
156
- ct normalize ./cases
157
- ct normalize "cases/**/*.md"
158
- ct normalize ./cases --and-gen --lang ts
132
+ npm install -g @cementic/cementic-test
159
133
  ```
160
134
 
161
- Current normalized output includes:
135
+ If you use the global CLI, live capture still expects Playwright to be installed in the project you are working in.
162
136
 
163
- - `id`
164
- - `title`
165
- - `tags`
166
- - `steps`
167
- - `expected`
168
- - `needs_review`
169
- - `review_reasons`
170
- - `source`
171
- - `url`
137
+ ---
172
138
 
173
- Important current behavior:
139
+ ## 🧪 Core commands
174
140
 
175
- - title is stored without duplicating the case ID prefix
176
- - URL metadata is read from `<!-- ct:url ... -->` first
177
- - if no metadata exists, normalization falls back to URL extraction from steps
178
-
179
- ### 5. `ct gen`
180
-
181
- Generates Playwright specs and page-object files from normalized JSON.
141
+ ### Create project
182
142
 
183
143
  ```bash
184
- ct gen --lang ts
185
- ct gen --lang js
186
- ct gen --lang ts --out tests/e2e
144
+ ct new my-suite
187
145
  ```
188
146
 
189
- Current output locations:
147
+ ### Generate test cases
190
148
 
191
- - specs: `tests/generated/` by default
192
- - page objects: `pages/`
193
-
194
- Current generator behavior:
149
+ ```bash
150
+ ct tc --feature "Checkout" --count 3
151
+ ```
195
152
 
196
- - maps common natural-language steps to Playwright actions
197
- - maps common expected-result phrases to Playwright assertions
198
- - derives one POM class per feature prefix where possible
199
- - uses `norm.url` for page-object `goto()`
200
- - avoids duplicate navigation when setup already handles the target URL
201
- - does not overwrite existing POM files
202
- - emits correct relative imports for generated specs
153
+ ### Generate from live site
203
154
 
204
- ### 6. `ct test`
155
+ ```bash
156
+ ct tc url <url> --ai
157
+ ```
205
158
 
206
- Runs Playwright tests.
159
+ Common setup after scaffolding:
207
160
 
208
161
  ```bash
209
- ct test
210
- ct test --headed
211
- ct test --project chromium
162
+ cd my-suite
163
+ npm install
164
+ npx playwright install chromium
165
+ ct tc url https://example.com/login --ai --feature "Login"
212
166
  ```
213
167
 
214
- This is a thin wrapper over:
168
+ ### Normalize + generate tests
215
169
 
216
170
  ```bash
217
- npx playwright test
171
+ ct normalize ./cases --and-gen
218
172
  ```
219
173
 
220
- Arguments after `ct test` are passed through to Playwright.
221
-
222
- ### 7. `ct flow`
174
+ ### Run tests
223
175
 
224
- Runs the end-to-end workflow:
176
+ ```bash
177
+ ct test
178
+ ```
225
179
 
226
- 1. normalize
227
- 2. generate
228
- 3. test
180
+ ### Full workflow
229
181
 
230
182
  ```bash
231
183
  ct flow
232
- ct flow ./cases
233
- ct flow --lang js
234
- ct flow --no-run
235
184
  ```
236
185
 
237
- ### 8. `ct report`
186
+ ---
238
187
 
239
- Opens the Playwright HTML report.
188
+ ## 📊 Reports
240
189
 
241
190
  ```bash
242
- ct report
191
+ ct report # Playwright report
192
+ ct serve # Allure report (if installed)
243
193
  ```
244
194
 
245
- Equivalent behavior:
195
+ ---
196
+
197
+ ## ⚙️ CI (GitHub Actions)
246
198
 
247
199
  ```bash
248
- npx playwright show-report
200
+ ct ci
249
201
  ```
250
202
 
251
- ### 9. `ct serve`
203
+ Generates a ready-to-run workflow.
252
204
 
253
- Serves the Allure report if `allure-commandline` is available in the current project.
205
+ ---
254
206
 
255
- ```bash
256
- ct serve
257
- ```
207
+ ## 🤖 AI support
258
208
 
259
- Current behavior:
209
+ Supports multiple providers:
260
210
 
261
- - prefers the local `node_modules/allure-commandline/bin/allure` binary
262
- - falls back to `npx allure serve ./allure-results`
211
+ * OpenAI
212
+ * Anthropic
213
+ * Gemini
214
+ * DeepSeek
215
+ * Qwen
216
+ * Kimi
263
217
 
264
- ### 10. `ct ci`
218
+ Set your key:
265
219
 
266
- Generates a GitHub Actions workflow at `.github/workflows/cementic.yml`.
220
+ ```bash
221
+ export OPENAI_API_KEY=your_key
222
+ ```
223
+ or
267
224
 
268
225
  ```bash
269
- ct ci
226
+ export ANTHROPIC_API_KEY=your_key
227
+ export GEMINI_API_KEY=your_key
228
+ export DEEPSEEK_API_KEY=your_key
229
+ export QWEN_API_KEY=your_key
230
+ export KIMI_API_KEY=your_key
270
231
  ```
271
232
 
272
- Current workflow behavior:
233
+ # Optional (generic / override)
234
+ ```bash
235
+ export CT_LLM_API_KEY=your_key
236
+ export CT_LLM_PROVIDER=openai
237
+ export CT_LLM_MODEL=your_model
238
+ export CT_LLM_BASE_URL=https://your-api-base-url
239
+ ```
273
240
 
274
- - skips generation if the workflow file already exists
275
- - installs dependencies
276
- - installs Playwright browsers
277
- - runs `npx playwright test`
278
- - uploads the Playwright HTML report as an artifact
241
+ Provider notes:
279
242
 
280
- ## AI provider support
243
+ * `DEEPSEEK_API_KEY`, `ANTHROPIC_API_KEY`, `GEMINI_API_KEY`, `QWEN_API_KEY`, `KIMI_API_KEY`, and `OPENAI_API_KEY` are all detected directly
244
+ * `CT_LLM_API_KEY` + `CT_LLM_BASE_URL` works for OpenAI-compatible endpoints
245
+ * `CT_LLM_PROVIDER` can explicitly select `deepseek`, `anthropic`, `gemini`, `qwen`, `kimi`, or `openai`
246
+ ---
281
247
 
282
- Current AI flows live in `src/core/llm.ts` and `src/core/analyse.ts`.
248
+ ## 🛠️ Troubleshooting
283
249
 
284
- Provider behavior in this version:
250
+ ### `ct tc url --ai` says Playwright is not found
285
251
 
286
- - `ct tc --ai` uses the standard Markdown case writer in `src/core/llm.ts`
287
- - `ct tc url --ai` uses the capture-aware analysis flow in `src/core/analyse.ts`
288
- - manual template generation is used if AI generation fails
252
+ Run:
289
253
 
290
- Supported environment variables:
254
+ ```bash
255
+ npm install
256
+ npx playwright install chromium
257
+ ```
291
258
 
292
- | Variable | Purpose |
293
- | --- | --- |
294
- | `DEEPSEEK_API_KEY` | DeepSeek key for capture-aware analysis |
295
- | `ANTHROPIC_API_KEY` | Primary Anthropic key |
296
- | `CT_ANTHROPIC_API_KEY` | Alternate Anthropic key |
297
- | `GEMINI_API_KEY` | Gemini key for capture-aware analysis |
298
- | `OPENAI_API_KEY` | OpenAI key |
299
- | `QWEN_API_KEY` | Qwen key for capture-aware analysis |
300
- | `KIMI_API_KEY` | Kimi / Moonshot key for capture-aware analysis |
301
- | `CT_LLM_API_KEY` | Generic OpenAI-compatible API key |
302
- | `CT_LLM_PROVIDER` | Optional provider override (`deepseek`, `anthropic`, `gemini`, `qwen`, `kimi`, or `openai`) |
303
- | `CT_LLM_MODEL` | Model override |
304
- | `CT_LLM_BASE_URL` | OpenAI-compatible base URL override |
259
+ This command resolves Playwright from the active project directory first, not from the CLI's global install.
305
260
 
306
- Current defaults:
261
+ ### `ct tc url --ai` says Chromium is not installed
307
262
 
308
- - DeepSeek default: `deepseek-chat`
309
- - Anthropic default: `claude-sonnet-4-5`
310
- - Gemini default: `gemini-2.5-flash`
311
- - Qwen default: `qwen-plus`
312
- - Kimi default: `moonshot-v1-8k`
313
- - OpenAI-compatible default: `gpt-4o-mini`
263
+ Run:
314
264
 
315
- ## URL capture
265
+ ```bash
266
+ npx playwright install chromium
267
+ ```
316
268
 
317
- Current capture behavior lives in `src/core/capture.ts`.
269
+ ### No AI key found
318
270
 
319
- Primary path:
271
+ Set one of:
320
272
 
321
- - uses a real Playwright browser
322
- - extracts:
323
- - page title
324
- - headings
325
- - buttons
326
- - links
327
- - inputs with label, placeholder, name, type, and `data-testid`
328
- - status and alert regions
329
- - selector confidence and alternative selectors
330
- - builds a structured `ElementMap`
331
- - passes that capture into `src/core/analyse.ts` for evidence-backed scenario generation
332
- - formats markdown, JSON, and preview-spec outputs through `src/core/report.ts`
273
+ ```bash
274
+ export OPENAI_API_KEY=your_key
275
+ export ANTHROPIC_API_KEY=your_key
276
+ export GEMINI_API_KEY=your_key
277
+ export DEEPSEEK_API_KEY=your_key
278
+ export QWEN_API_KEY=your_key
279
+ export KIMI_API_KEY=your_key
280
+ ```
281
+
282
+ Or use:
283
+
284
+ ```bash
285
+ export CT_LLM_API_KEY=your_key
286
+ export CT_LLM_BASE_URL=https://your-api-base-url
287
+ ```
333
288
 
334
- ## Generated project structure
289
+ ### Legacy macOS project setup
335
290
 
336
- After a typical run:
291
+ On macOS 13 and older, `ct new` installs Chromium only during Playwright browser setup to avoid unsupported WebKit failures.
292
+
293
+ ## 📁 Output structure
337
294
 
338
295
  ```text
339
296
  project/
340
297
  cases/
341
298
  pages/
342
- tests/
343
- generated/
344
- .cementic/
345
- normalized/
346
- playwright.config.js|ts
347
- ```
348
-
349
- Typical file flow:
350
-
351
- ```text
352
- cases/*.md
353
- -> .cementic/normalized/*.json
354
- -> tests/generated/*.spec.ts|js
355
- -> pages/*.ts|js
299
+ tests/generated/
300
+ .cementic/normalized/
356
301
  ```
357
302
 
358
- ## Example case file
303
+ ---
359
304
 
360
- ```md
361
- # AUTH-001 — User can log in @smoke @auth
362
- <!-- ct:url https://mini-bank.testamplify.com/login -->
363
- ## Steps
364
- 1. Navigate to https://mini-bank.testamplify.com/login
365
- 2. Fill in email with [EMAIL_ADDRESS]'
366
- 3. Fill in password with 'secret'
367
- 4. Click the 'Sign In' button
305
+ ## 🎯 Who this is for
368
306
 
369
- ## Expected Results
370
- - Page redirects to /dashboard
371
- - Welcome message is visible
372
- ```
373
-
374
- ## Current implementation notes
307
+ * QA engineers moving into automation
308
+ * Beginners learning Playwright
309
+ * Teams needing fast test generation
310
+ * Developers who want speed over setup
375
311
 
376
- This version is intentionally heuristic and file-oriented.
312
+ ---
377
313
 
378
- Important current characteristics:
314
+ ## 🚀 Philosophy
379
315
 
380
- - generated specs are POM-oriented, not raw recorded scripts
381
- - capture-generated selector and assertion hints are preserved through `normalize` and `gen`
382
- - generator rules still cover non-capture cases heuristically, but capture-backed cases now keep exact selectors and assertions
383
- - Playwright itself is used for capture and test execution
384
- - Playwright CLI and Playwright agents are not yet first-class runtime backends in this version
316
+ > Meaning Structure System Resilience
385
317
 
386
- ## Developer setup
318
+ CementicTest flips automation from:
387
319
 
388
- ```bash
389
- git clone <repo>
390
- cd cementic-test-cli
391
- npm install
320
+ ```
321
+ Code Tests
392
322
  ```
393
323
 
394
- Build the CLI:
324
+ to:
395
325
 
396
- ```bash
397
- npm run build
326
+ ```
327
+ Intent Tests
398
328
  ```
399
329
 
400
- Run the repo test suite:
330
+ ---
401
331
 
402
- ```bash
403
- npm test
404
- ```
332
+ ## 🔗 Links
405
333
 
406
- What `npm test` currently verifies:
334
+ * 🌐 Website: [https://cementic.testamplify.io/](https://cementic.testamplify.io/)
335
+ * 💬 Community: [https://t.me/+Wbx7oK7ivqgxZGJh](https://t.me/+Wbx7oK7ivqgxZGJh)
407
336
 
408
- - build succeeds
409
- - `ct tc url` writes URL metadata
410
- - capture-generated selector and `playwright` hints survive `normalize` and `gen`
411
- - `ct normalize` and `ct gen` preserve the recent generator fixes
412
- - the JavaScript scaffold contains the expected page objects and sample specs
337
+ ---
413
338
 
414
- ## Local development loop
339
+ ## 🧪 Status
415
340
 
416
- ```bash
417
- npm run build
418
- npm link
341
+ * CLI: ✅ Production-ready
342
+ * Web App (Agentic UI): 🚧 Coming soon
419
343
 
420
- ct --help
421
- ```
344
+ ---
422
345
 
423
- Manual smoke flow:
346
+ ## 💬 Final note
424
347
 
425
- ```bash
426
- mkdir demo
427
- cd demo
348
+ You don’t need to install anything.
349
+ You don’t need to configure anything.
428
350
 
429
- ct new sample --lang ts --no-browsers
430
- cd sample
351
+ Just run:
431
352
 
432
- ct tc url https://mini-bank.testamplify.com/login --ai --feature "Login" --count 1
433
- ct normalize ./cases --and-gen --lang ts
434
- ct test
353
+ ```bash
354
+ npx @cementic/cementic-test
435
355
  ```
436
356
 
437
- ## Key source files
357
+ And start automating.
438
358
 
439
- ```text
440
- src/cli.ts
441
- src/commands/new.ts
442
- src/commands/tc.ts
443
- src/commands/normalize.ts
444
- src/commands/gen.ts
445
- src/commands/test.ts
446
- src/commands/flow.ts
447
- src/core/capture.ts
448
- src/core/analyse.ts
449
- src/core/llm.ts
450
- src/core/report.ts
451
- src/core/prefix.ts
452
- templates/student-framework/
453
- templates/student-framework-ts/
454
- ```
455
359
 
456
360
  ## Changelog
457
361
 
362
+ ### v0.2.8
363
+
364
+ - fixed TypeScript generator identifier sanitization so scenario titles containing em dashes and other non-identifier characters no longer break generated POM class names or spec imports
365
+ - added regression coverage for generated TypeScript output from scenario titles like `Login-002 — User can enter credentials — before submission`
366
+
367
+ ### v0.2.7
368
+
369
+ - fixed project-first Playwright resolution for `ct tc url --ai`, including global and `npx` CLI usage
370
+ - added clearer capture failure categories and setup guidance for missing Playwright, missing browsers, and page-load failures
371
+ - centralized AI provider detection so `tc --ai` and capture analysis recognize the same providers and env vars
372
+ - fixed missing DeepSeek guidance in the CLI help path
373
+ - changed legacy macOS browser setup to install Chromium only by default and avoid WebKit unsupported failures
374
+
458
375
  ### v0.2.6
459
376
 
460
377
  - added an install-time banner with links to the website and community