12 — Testing Strategy
The Admin Console requires tests at multiple levels because metadata changes can affect the whole application.
Unit Tests
Test pure functions and validators.
Examples:
- key validation,
- property value validation,
- relationship cardinality validation,
- hierarchy rule validation,
- model compatibility analysis,
- destructive change detection,
- root scope path matching.
Service Tests
Test backend use cases against a real or test PostgreSQL database.
Examples:
- create draft model,
- create entity type,
- create property definition,
- validate model,
- publish model,
- create runtime entity from published model,
- reject runtime entity from draft-only type,
- reject invalid property value,
- reject relationship disallowed by model.
Transaction Tests
Verify operations rollback correctly.
Examples:
- failed publish does not partially update model status,
- failed entity create does not create partial entity/property/tag rows,
- failed subtree move does not leave invalid paths.
Compatibility Tests
Test metadata changes against existing runtime data.
Examples:
- property type change with incompatible existing values,
- required property added when entities lack values,
- tag group changed from multi-select to single-select,
- relationship cardinality tightened with existing conflicts.
Authorization Tests
Test permissions and root scope.
Examples:
- model admin can edit draft,
- ordinary user cannot publish model,
- user cannot update entity outside root scope,
- user cannot create relationship to entity outside allowed root,
- user cannot reveal secret through generic property API.
Frontend Tests
Test critical admin flows.
Examples:
- create entity type form,
- property definition form validation,
- validation results display,
- publish button disabled when errors exist,
- destructive change warning.
End-To-End Tests
Suggested happy path:
- Create draft model.
- Add
customer,site,assetentity types. - Add
Deviceproperty group. - Add
hostnameproperty. - Assign group to
asset. - Publish model.
- Create asset through runtime API.
- Verify asset appears in frontend.
Regression Tests
Every model-related bug should add a regression test.
Metadata systems fail in subtle ways. Regression tests are essential.