Skip to content

Commit 5e4ebbd

Browse files
docs: expand sanity test env vars in testing rule and skill
- Document core vs suite-specific variables (OAuth, 2FA, MFA, MEMBER_EMAIL, DAM 2.0) - Optional PERSONALIZE_HOST, DELETE_DYNAMIC_RESOURCES; runtime vars from setup Made-with: Cursor
1 parent fe3bad5 commit 5e4ebbd

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

.cursor/rules/testing.mdc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ alwaysApply: false
2626

2727
## Credentials & env (sanity only)
2828

29-
- Sanity tests need env vars documented in **`test/sanity-check/utility/testSetup.js`** (`EMAIL`, `PASSWORD`, `HOST`, `ORGANIZATION`, optional OAuth/Personalize). **Do not** commit secrets or hardcode tokens in tests.
29+
- Canonical env documentation: **`test/sanity-check/utility/testSetup.js`** (see also `sanity.js`).
30+
- **Required for setup:** `EMAIL`, `PASSWORD`, `HOST`, `ORGANIZATION`.
31+
- **Suite-specific (tests skip when unset):** OAuth — `CLIENT_ID`, `APP_ID`, `REDIRECT_URI`; 2FA — `TFA_EMAIL`, `TFA_PASSWORD`; MFA — `MFA_SECRET`; team/stack share — `MEMBER_EMAIL`; DAM 2.0 — `DAM_2_0_ENABLED=true`.
32+
- **Optional / defaults:** `PERSONALIZE_HOST`, `DELETE_DYNAMIC_RESOURCES`. Use `HOST` for the target CMA API host / region.
33+
- Setup **writes** `API_KEY`, `AUTHTOKEN`, `MANAGEMENT_TOKEN`, `PERSONALIZE_PROJECT_UID` at runtime — never commit those.
3034
- Unit tests must **not** rely on real API keys; mock HTTP.
3135

3236
## Coverage

skills/testing/SKILL.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,36 @@ Always **`npm run build`** before sanity if `dist/node/contentstack-management.j
2828
## Sanity tests (`test/sanity-check/`)
2929

3030
- **Live** Contentstack CMA calls; orchestrated by `test/sanity-check/sanity.js`.
31-
- **Env**: required variables and optional OAuth/Personalize keys are listed at the top of **`test/sanity-check/utility/testSetup.js`** (e.g. `EMAIL`, `PASSWORD`, `HOST`, `ORGANIZATION`).
32-
- **Flow**: setup creates stack/management token/fixtures where applicable; teardown is handled in the same module — read it before adding destructive tests.
31+
- **Authoritative list:** variable names and defaults are documented in **`test/sanity-check/utility/testSetup.js`** (and mirrored in `sanity.js`); prefer that file when adding new env vars.
32+
33+
### Environment variables
34+
35+
**Required (core)** — setup fails or cannot run without these:
36+
37+
- `EMAIL`, `PASSWORD`, `HOST`, `ORGANIZATION`
38+
39+
Without them, login / stack creation / org-scoped setup does not complete.
40+
41+
**Required for specific suites** — related tests **skip** (or degrade) when missing:
42+
43+
| Area | Variables | Notes |
44+
|------|-----------|--------|
45+
| **OAuth** | `CLIENT_ID`, `APP_ID`, `REDIRECT_URI` | Used by `oauth-test.js` and auth flows that need app registration |
46+
| **2FA (TFA)** | `TFA_EMAIL`, `TFA_PASSWORD` | `user-test.js` — skip TFA scenarios when unset |
47+
| **MFA (TOTP)** | `MFA_SECRET` | `user-test.js` — MFA login path; optional asserts still run without it in some cases |
48+
| **Team / stack share** | `MEMBER_EMAIL` | `team-test.js`, `stack-test.js` — avoids mutating the admin user; share tests skip if unset |
49+
| **DAM 2.0** | `DAM_2_0_ENABLED=true` | `entry-test.js` — asset/DAM 2.0 block gated on this flag |
50+
51+
**Optional / config** (defaults exist; override when needed):
52+
53+
- `PERSONALIZE_HOST` — defaults to `personalize-api.contentstack.com` in setup
54+
- `DELETE_DYNAMIC_RESOURCES` — defaults to deleting dynamic stack/Personalize resources; set to `false` to keep them for debugging
55+
56+
**Regions / hosts:** point `HOST` at the **API host** for the stack you are testing (e.g. regional or custom CMA host), consistent with `testSetup.js`.
57+
58+
**Runtime (not for .env check-in):** after setup, `testSetup` assigns `process.env.API_KEY`, `AUTHTOKEN`, `MANAGEMENT_TOKEN`, `PERSONALIZE_PROJECT_UID`, etc. Do not commit those; they are produced by the harness.
59+
60+
- **Flow**: setup creates stack, management token, and Personalize project where applicable; teardown reads `DELETE_DYNAMIC_RESOURCES`. Read **`testSetup.js`** before adding destructive or org-wide tests.
3361

3462
## Jest (`test/typescript/`)
3563

0 commit comments

Comments
 (0)