Skip to content

v2: Add comprehensive tests for command DSL #748

Description

@javiertoledo

Parent

Part of #739

Context

The command DSL (command() function) currently has no direct unit tests. The decorator tests indirectly test it, but we need dedicated tests for:

  1. DSL function tests (packages/core/test/dsl/command.test.ts):

    • Registration works correctly and metadata is stored in config
    • Duplicate name detection throws error
    • Default values (before defaults to [], methods defaults to [])
    • All three authorize option variants ('all', roles array, custom function)
    • Returned metadata matches what was registered
    • Properties are properly passed through
    • Handler function is stored correctly
  2. DSL integration tests:

    • A command defined via command() can be dispatched through MagekCommandDispatcher
    • Authorization works for DSL-defined commands
    • Before hooks work for DSL-defined commands
  3. Interoperability tests:

    • DSL commands and decorator commands can coexist in the same config
    • Both types are dispatched correctly
  4. Decorator regression tests:

    • Ensure the existing decorator tests are comprehensive enough to catch regressions
    • The decorator's class instantiation adapter (Object.assign + handle) works correctly

Acceptance Criteria

  • packages/core/test/dsl/command.test.ts created with comprehensive tests
  • DSL and decorator tests are clearly separated
  • All edge cases covered (no fields, no authorize, duplicate names, etc.)
  • Integration test showing full dispatch flow with DSL-defined command

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions