AshSDUI.Mock (ash_sdui v0.2.0)

Copy Markdown View Source

Utilities for building test fixtures and mock trees without manual TreeNode construction.

Examples

# Simple node
node = AshSDUI.Mock.tree_node("Card@v1")

# Node with children
parent = AshSDUI.Mock.tree_node("Panel@v1", children: [
  AshSDUI.Mock.tree_node("Header@v1"),
  AshSDUI.Mock.tree_node("Body@v1")
])

# From a resource
tree = AshSDUI.Mock.from_resource(MyApp.Player, subject_id: "player-42")

Summary

Functions

Builds a TreeNode from a resource with SDUI annotation.

Builds a TreeNode with sensible defaults.

Functions

from_resource(resource, opts \\ [])

Builds a TreeNode from a resource with SDUI annotation.

Reads :default_component from the resource's sdui block and wraps it in a TreeNode pointing to the resource as the subject.

Options

  • :subject_id — string record ID, default "first"
  • :component_name — override the resource's default component name

Raises

  • ArgumentError if resource has no :default_component and :component_name is not passed

tree_node(component_name, opts \\ [])

Builds a TreeNode with sensible defaults.

Options

  • :id — UUID string, generated if omitted
  • :static_props — map, default %{}
  • :subject_resource — string resource name, optional
  • :subject_id — string record ID, optional
  • :region — atom region name, default :default
  • :order — non-negative integer, default 0
  • :children — list of TreeNode structs, default []