@esimplicitylabs/katalyst-xspec 0.7.0 → 0.8.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 +15 -1
- package/cli/init.cjs +74 -22
- package/cli/upgrade.cjs +21 -10
- package/dist/{chunk-UTTKW2SR.js → chunk-VHVH476W.js} +39 -6
- package/dist/index.d.ts +160 -8
- package/dist/index.js +323 -71
- package/dist/steps/index.js +1 -1
- package/package.json +2 -2
- package/skills/katalyst-bdd-architecture/SKILL.md +23 -38
- package/skills/katalyst-bdd-architecture/references/adapters.md +44 -25
- package/skills/katalyst-bdd-architecture/references/ports.md +16 -2
- package/skills/katalyst-bdd-create-test/SKILL.md +15 -5
- package/skills/katalyst-bdd-create-test/references/api-patterns.md +25 -16
- package/skills/katalyst-bdd-create-test/references/hybrid-patterns.md +30 -13
- package/skills/katalyst-bdd-create-test/references/ui-patterns.md +11 -0
- package/skills/katalyst-bdd-quickstart/SKILL.md +21 -17
- package/skills/katalyst-bdd-step-reference/SKILL.md +7 -4
- package/skills/katalyst-bdd-step-reference/references/api-steps.md +14 -6
- package/skills/katalyst-bdd-step-reference/references/shared-steps.md +2 -2
- package/skills/katalyst-bdd-step-reference/references/ui-steps.md +22 -1
- package/skills/katalyst-bdd-troubleshooting/SKILL.md +46 -37
|
@@ -348,7 +348,28 @@ Then the element "#terms" should be checked
|
|
|
348
348
|
Then the element "#newsletter" should not be checked
|
|
349
349
|
```
|
|
350
350
|
|
|
351
|
-
## UI
|
|
351
|
+
## UI Login Steps
|
|
352
|
+
|
|
353
|
+
```gherkin
|
|
354
|
+
Given I am logged in as {string}
|
|
355
|
+
When I log in as {string} in UI
|
|
356
|
+
When I log in as admin in UI
|
|
357
|
+
When I log in as user in UI
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
**Examples:**
|
|
361
|
+
```gherkin
|
|
362
|
+
Given I am logged in as "pm"
|
|
363
|
+
When I log in as "pm" in UI
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
- `I am logged in as "<role>"` fills the login form once per role per worker, then restores the saved cookies + localStorage in later scenarios (`UI_SESSION_REUSE=false` disables).
|
|
367
|
+
- `I log in as "<role>" in UI` always submits the form (use when testing login).
|
|
368
|
+
- `admin` / `user` variants are shorthand for those roles.
|
|
369
|
+
- Credentials: `AUTH_<ROLE>_USERNAME` / `AUTH_<ROLE>_PASSWORD`. Missing credentials fail the step with a message naming the variables. Staying on the login page also fails.
|
|
370
|
+
- Settings: `UI_LOGIN_PATH` (`/login`), `UI_USERNAME_FIELD` (`Username`), `UI_PASSWORD_FIELD` (`Password`) match the field's label, placeholder or `name`; `UI_LOGIN_BUTTON` (`Login`), `UI_LOGIN_SUCCESS_URL`, `UI_LOGIN_SUCCESS_TEXT`, `UI_LOGIN_TIMEOUT` (`10000`).
|
|
371
|
+
|
|
372
|
+
## UI Authentication Steps (header-based)
|
|
352
373
|
|
|
353
374
|
### Auth with Fetch Intercept
|
|
354
375
|
|
|
@@ -100,34 +100,38 @@ Old `@api`/`@ui` tags left in feature files are harmless.
|
|
|
100
100
|
|
|
101
101
|
## Issue 3: Authentication Failures
|
|
102
102
|
|
|
103
|
-
###
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
### Login step fails
|
|
104
|
+
|
|
105
|
+
Role login steps (`Given I am authenticated as "pm" via API`, `Given I am logged in as "pm"`, `When I log in as "pm" in UI`, and the older admin/user steps) read `AUTH_<ROLE>_USERNAME` / `AUTH_<ROLE>_PASSWORD` (role upper-cased, spaces/dashes become `_`). Since 0.8, missing credentials **fail the step** with a message naming the variables; they no longer warn and continue logged out. Match the error message:
|
|
106
|
+
|
|
107
|
+
| Message | Fix |
|
|
108
|
+
|---------|-----|
|
|
109
|
+
| `No username for role "x"` | Set `AUTH_X_USERNAME` / `AUTH_X_PASSWORD` (check the role spelling) |
|
|
110
|
+
| `API login as "x" failed: POST /auth/login returned 401` | Wrong credentials, or wrong `API_AUTH_BODY` (`form`/`json`) / `API_AUTH_USERNAME_FIELD` / `API_AUTH_PASSWORD_FIELD`; the message includes the response body |
|
|
111
|
+
| `returned 404` | Wrong `API_AUTH_LOGIN_PATH`, or the API base URL is wrong; check the `katalyst-xspec targets:` line printed at the start of the run |
|
|
112
|
+
| `returned 200 but no token found` | Set `API_AUTH_TOKEN_PATH` to where the token is (e.g. `data.jwt`) |
|
|
113
|
+
| `No username field "Username" on /login` | Set `UI_USERNAME_FIELD` to the field's label, placeholder or `name`, or fix `UI_LOGIN_PATH` |
|
|
114
|
+
| `UI login as "x" stayed on /login` | Wrong credentials, or the app doesn't change URL after login: set `UI_LOGIN_SUCCESS_TEXT` (or `UI_LOGIN_SUCCESS_URL`) |
|
|
115
|
+
| Logged out in a later scenario | A previous scenario ended the shared session: use `When I log in as "x" in UI` there, or `UI_SESSION_REUSE=false` |
|
|
116
|
+
| `UI login needs the browser` | A custom step called `auth.uiLoginAs` without the `ui` fixture: add `ui` to its parameters (`async ({ auth, ui, world }) => ...`) |
|
|
117
|
+
|
|
118
|
+
**Typical `.env`:**
|
|
106
119
|
```bash
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
# Required for user auth
|
|
112
|
-
DEFAULT_USER_USERNAME=user@example.com
|
|
113
|
-
DEFAULT_USER_PASSWORD=changeme
|
|
120
|
+
AUTH_ADMIN_USERNAME=admin@example.com
|
|
121
|
+
AUTH_ADMIN_PASSWORD=changeme
|
|
122
|
+
# Older names still work for admin/user: DEFAULT_ADMIN_*, DEFAULT_USER_*, NON_ADMIN_*
|
|
114
123
|
|
|
115
|
-
#
|
|
116
|
-
API_AUTH_LOGIN_PATH=/auth/login
|
|
124
|
+
# API login (defaults shown)
|
|
125
|
+
# API_AUTH_LOGIN_PATH=/auth/login
|
|
126
|
+
# API_AUTH_BODY=form
|
|
127
|
+
# API_AUTH_TOKEN_PATH=access_token
|
|
117
128
|
```
|
|
118
129
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
**Debug:** Add logging to see what's being sent:
|
|
122
|
-
```gherkin
|
|
123
|
-
# Check your variables are loaded
|
|
124
|
-
Given I set variable "debug" to "true"
|
|
125
|
-
Then I log all feature flags
|
|
126
|
-
```
|
|
130
|
+
Full settings: docs/guides/authentication.md.
|
|
127
131
|
|
|
128
132
|
### UI Auth Fails
|
|
129
133
|
|
|
130
|
-
For `Given I am authenticated in UI as "admin"
|
|
134
|
+
For `Given I am authenticated in UI as "admin"` (header-based, not `I am logged in as`):
|
|
131
135
|
- This uses fetch intercept, not actual login
|
|
132
136
|
- Ensure your app accepts the intercepted auth headers
|
|
133
137
|
- Check the auth adapter configuration
|
|
@@ -275,9 +279,9 @@ Given I disable cleanup
|
|
|
275
279
|
```
|
|
276
280
|
|
|
277
281
|
### Check 3: API Base URL Set
|
|
278
|
-
Cleanup uses the API base URL:
|
|
282
|
+
Cleanup uses the API base URL (`API_BASE_URL`, or `FRONTEND_URL` when it isn't set). Check the `katalyst-xspec targets: UI … | API …` line at the start of the run:
|
|
279
283
|
```bash
|
|
280
|
-
# In .env
|
|
284
|
+
# In .env (only if the API is on another origin than FRONTEND_URL)
|
|
281
285
|
API_BASE_URL=http://localhost:3000
|
|
282
286
|
```
|
|
283
287
|
|
|
@@ -411,26 +415,31 @@ npx playwright test --ui
|
|
|
411
415
|
## Environment Variable Checklist
|
|
412
416
|
|
|
413
417
|
```bash
|
|
414
|
-
#
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
# UI Testing
|
|
418
|
-
FRONTEND_URL=http://localhost:3000
|
|
419
|
-
BASE_URL=http://localhost:3000
|
|
418
|
+
# Where to test
|
|
419
|
+
FRONTEND_URL=http://localhost:3000 # older alias: BASE_URL
|
|
420
|
+
# API_BASE_URL=http://localhost:4000 # optional; defaults to FRONTEND_URL
|
|
420
421
|
HEADLESS=true
|
|
421
422
|
|
|
422
|
-
#
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
423
|
+
# Who logs in: one pair per role used in features (no hardcoded defaults)
|
|
424
|
+
AUTH_ADMIN_USERNAME=admin@example.com
|
|
425
|
+
AUTH_ADMIN_PASSWORD=changeme
|
|
426
|
+
# AUTH_PM_USERNAME=pm@example.com
|
|
427
|
+
# AUTH_PM_PASSWORD=changeme
|
|
428
|
+
|
|
429
|
+
# API login (optional, defaults shown)
|
|
430
|
+
# API_AUTH_LOGIN_PATH=/auth/login
|
|
431
|
+
# API_AUTH_BODY=form
|
|
432
|
+
# API_AUTH_USERNAME_FIELD=username
|
|
433
|
+
# API_AUTH_PASSWORD_FIELD=password
|
|
434
|
+
# API_AUTH_TOKEN_PATH=access_token
|
|
428
435
|
|
|
429
|
-
# UI
|
|
436
|
+
# UI login (optional, defaults shown)
|
|
430
437
|
# UI_LOGIN_PATH=/login
|
|
431
|
-
# UI_USERNAME_FIELD=Username
|
|
438
|
+
# UI_USERNAME_FIELD=Username # label, placeholder or name
|
|
432
439
|
# UI_PASSWORD_FIELD=Password
|
|
433
440
|
# UI_LOGIN_BUTTON=Login
|
|
441
|
+
# UI_LOGIN_SUCCESS_TEXT=Welcome
|
|
442
|
+
# UI_SESSION_REUSE=true
|
|
434
443
|
|
|
435
444
|
# Cleanup Auth (optional -- alternative to login-based auth)
|
|
436
445
|
# CLEANUP_AUTH_TOKEN=your-admin-token
|