Skip to content

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:

  1. Create draft model.
  2. Add customer, site, asset entity types.
  3. Add Device property group.
  4. Add hostname property.
  5. Assign group to asset.
  6. Publish model.
  7. Create asset through runtime API.
  8. 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.