@xrmforge/devkit 0.5.6 → 0.5.7

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.
@@ -26,6 +26,10 @@ names to form interface names. Do NOT guess interface names from entity names.
26
26
  Fields enum member names are based on the **primary language label** (often German),
27
27
  not the logical field name. Always read the generated files to get correct names.
28
28
 
29
+ **Large projects (50+ entities):** `form-mapping.json` can be large. Do NOT grep through
30
+ all generated files to find interface names. Read `form-mapping.json` once, then use
31
+ the mapping for all imports. This saves time and avoids wrong guesses.
32
+
29
33
  ## Rules: MANDATORY (every violation is a bug)
30
34
 
31
35
  1. **Fields Enum** for ALL getAttribute/getControl calls. Never raw strings.
@@ -209,6 +213,10 @@ assertions. Pure smoke tests (`onLoad` + `not.toThrow`) do NOT count as behavior
209
213
  Tests that only check `getOnChangeHandlers().length > 0` are registration tests, not
210
214
  behavior tests. Every onChange handler MUST have a `fireOnChange` test.
211
215
 
216
+ **attr.controls:** Since @xrmforge/testing 0.2.3, `createFormMock()` automatically links
217
+ each attribute to its control. `mock.getControl(Fields.Name)` works out of the box.
218
+ No need to mock controls separately.
219
+
212
220
  ## File Structure
213
221
 
214
222
  ```
@@ -313,6 +321,13 @@ When creating manual typings without `xrmforge generate`:
313
321
  After converting ALL scripts, run these checks. Fix every violation before proceeding to tests.
314
322
  Document results in SESSION-GEDAECHTNIS.md (violation count per category).
315
323
 
324
+ **Platform note:** The checks below use bash/grep syntax. On Windows PowerShell, use
325
+ `Select-String` instead of `grep`. Example:
326
+ ```powershell
327
+ # PowerShell equivalent of: grep -rn "getAttribute('" src/forms/ --include="*.ts"
328
+ Get-ChildItem -Recurse src/forms -Filter *.ts | Select-String "getAttribute\('" | Where-Object { $_.Line -notmatch 'Fields\.' }
329
+ ```
330
+
316
331
  ### Pattern Compliance (all must be 0, or documented exception)
317
332
 
318
333
  ```bash
@@ -399,6 +414,30 @@ for f in tests/**/*.test.ts; do
399
414
  done
400
415
  ```
401
416
 
417
+ ### Test Gap Analysis (after writing tests)
418
+
419
+ Before declaring tests complete, verify coverage gaps:
420
+
421
+ ```bash
422
+ # 1. onChange handlers without fireOnChange test
423
+ for f in tests/**/*.test.ts; do
424
+ has_onchange=$(grep -c "onChange\|on_change\|OnChange" "$(echo $f | sed 's|tests/|src/|;s|.test.ts|.ts|')" 2>/dev/null || echo 0)
425
+ has_fire=$(grep -c "fireOnChange" "$f" 2>/dev/null || echo 0)
426
+ [ "$has_onchange" -gt 0 ] && [ "$has_fire" -eq 0 ] && echo "Missing fireOnChange: $f"
427
+ done
428
+
429
+ # 2. WebApi calls without mock assertions
430
+ grep -rln "Xrm.WebApi\|retrieveRecord\|retrieveMultiple" src/forms/ --include="*.ts" | while read f; do
431
+ test_f="tests/forms/$(basename "$f" .ts).test.ts"
432
+ [ -f "$test_f" ] && ! grep -q "retrieveRecord\|retrieveMultiple\|webApiOverrides" "$test_f" && echo "No WebApi mock: $test_f"
433
+ done
434
+
435
+ # 3. Behavior test ratio (target: >= 30%)
436
+ total=$(grep -rc "it(" tests/ --include="*.test.ts" 2>/dev/null | awk -F: '{s+=$2}END{print s}')
437
+ behavior=$(grep -rc "fireOnChange\|retrieveRecord\|retrieveMultiple\|expect.*getValue\|expect.*getVisible" tests/ --include="*.test.ts" 2>/dev/null | awk -F: '{s+=$2}END{print s}')
438
+ echo "Behavior tests: $behavior / $total (target: >= 30%)"
439
+ ```
440
+
402
441
  ### Exceptions
403
442
 
404
443
  Some checks have legitimate exceptions:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xrmforge/devkit",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "Build orchestration and project tooling for Dynamics 365 WebResources",
5
5
  "keywords": [
6
6
  "dynamics-365",