Skip to content

test: Add unit tests for SensorDispatchBridge, SignalEmitter, and Error modules#10

Closed
dl-alexandre wants to merge 2 commits intoagentjido:mainfrom
dl-alexandre:add-missing-unit-tests
Closed

test: Add unit tests for SensorDispatchBridge, SignalEmitter, and Error modules#10
dl-alexandre wants to merge 2 commits intoagentjido:mainfrom
dl-alexandre:add-missing-unit-tests

Conversation

@dl-alexandre
Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive unit tests for three modules that previously had no dedicated test coverage:

Modules Tested

  1. SensorDispatchBridge (test/ash_jido/sensor_dispatch_bridge_test.exs)

    • Tests forward/2 with valid signals, invalid formats, and dead runtimes
    • Tests forward_many/2 for batch forwarding with success/error tracking
    • Tests forward_or_ignore/2 for handling signal filtering
  2. SignalEmitter (test/ash_jido/signal_emitter_test.exs)

    • Tests dispatch configuration validation for mutating actions
    • Tests signal emission with various dispatch configurations
    • Tests default signal type/source generation from resource names
    • Tests notification emission and error tracking
  3. Error (test/ash_jido/error_test.exs)

    • Tests conversion of all Ash error types (Invalid, Forbidden, Framework, Unknown)
    • Tests underlying error extraction from nested error structures
    • Tests field error mapping and changeset error extraction

Impact

  • Improves overall test coverage
  • Provides safety net for future refactoring
  • Documents expected behavior of internal modules
  • Makes it easier for contributors to understand module functionality

…or modules

Add comprehensive test coverage for three modules that previously had no tests:

- SensorDispatchBridge: Tests for forward/2, forward_many/2, and forward_or_ignore/2
  including success cases, error handling for dead runtimes, invalid signals,
  and batch forwarding with error tracking.

- SignalEmitter: Tests for dispatch configuration validation, signal emission
  with various formats, notification handling, and default signal type/source
  generation from resource names.

- Error: Tests for all Ash error type conversions (Invalid, Forbidden, Framework,
  Unknown), underlying error extraction, field error mapping, and changeset
  error extraction.

These tests improve overall test coverage and provide safety for future refactoring.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eca517d417

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


result = Error.extract_underlying_errors(ash_error)

assert length(result) == 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Align expected underlying error extraction with implementation

This assertion expects extract_underlying_errors/1 to return one item when %Ash.Error.Unknown{error: inner_error, errors: []} is passed, but AshJido.Error.extract_underlying_errors/1 checks :errors first and returns that list when present (even if empty). As written, this test will consistently fail against the current implementation unless the input omits :errors or the function logic is changed.

Useful? React with 👍 / 👎.


result = Error.extract_field_errors(ash_error)

assert result.name == ["is too short", "is required"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Correct expected ordering of grouped field error messages

The expected order here is reversed relative to AshJido.Error.extract_field_errors/1: that function preserves insertion order from the input list via Enum.group_by/3, so with Required followed by InvalidAttribute the value for :name is [is required, is too short]. This assertion will fail deterministically with the test data in this commit.

Useful? React with 👍 / 👎.

@mikehostetler
Copy link
Copy Markdown
Contributor

Superseded by #16, which carried this coverage work forward onto current main and aligned it with the Ash/Jido APIs in use on April 1, 2026.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants