Files
DumiFlex-ComfyUI-Wildcard-P…/tests/test_nodes_integration.py
T
DumiFlex f8ac25f443 chore: pre-merge polish — kind-aware chips, injector + debug improvements, engine fixes
Omnibus polish landing the remaining unstaged work on the branch:

frontend
  - kind-aware RefChip — @{uuid} refs targeting non-wildcard library
    modules (constraint, combine, derivation, fixed_values, bundle) now
    render with the matching kind color + PrimeIcon instead of falling
    through as unresolved wildcards. cascade/resolveChip exposes
    resolveModuleChip; preview-resolver caches snap.type as kind;
    RichTextPreview accepts a uuid-to-kind map; RefChip honours the
    new moduleKind prop.
  - DebugViewer derives uuid-to-kind from trace entries so engine
    warnings (e.g. constraint_never_applied carrying @{constraint_id})
    render the constraint id as a colored constraint chip.
  - Injector node refactor: two-tier socket (template_subject /
    subject row pairs) + general-template row model; binding modal
    handles general rows; row reorder + cap; rows collapsed by
    default; sockets gain tooltips.
  - SPA misc: useStarterSet rebuilds cascade reverse-dep index on
    catalog refresh so just-created starters surface in cascade
    impact dialogs; tokens / resolveTokens / EmptyState height /
    AppLayout sidebar count live-refresh / ModuleListView mid-cols.

engine
  - constraint_handler: 3 dedup bugs in carrier-claim + classify the
    never_applied warning.
  - pipeline: detect via-nested constraint carriers; carrier-claim
    failsafe + clearer never_applied warning text.
  - syntax/resolve: nested @{uuid#name} optional segment recognised.

tests
  - DebugViewer / Injector / RefChip / resolveChip / preview-resolver
    test suites extended for the new behaviour.
  - Engine + integration tests adjusted for constraint dedup + new
    carrier path + nested-ref parsing.
2026-05-28 12:53:23 +03:00

76 lines
2.2 KiB
Python

"""End-to-end node integration — simulate a small ComfyUI workflow."""
import json
from wp_nodes.assembler_node import WPPromptAssembler
from wp_nodes.context_node import WPContext
from wp_nodes.debug_node import WPDebug
from wp_nodes.types import ContextPayload
def _mods(entries):
return json.dumps({
"version": 1,
"modules": [{
"id": "auto",
"type": "fixed_values",
"entries": entries,
}],
})
def test_chain_of_two_context_nodes_into_assembler():
# Upstream context sets style + subject.
upstream = WPContext.execute(
seed=1,
wp_modules=_mods([
{"variable_name": "style", "value": "photoreal"},
{"variable_name": "subject", "value": "knight"},
]),
upstream=None,
).values[0]
# Downstream context adds environment vars + overrides style.
downstream = WPContext.execute(
seed=2,
wp_modules=_mods([
{"variable_name": "style", "value": "painted"},
{"variable_name": "location", "value": "forest"},
]),
upstream=upstream,
).values[0]
assert isinstance(downstream, ContextPayload)
assert downstream.context == {
"subject": "knight",
"style": "painted",
"location": "forest",
}
# Assembler renders the final template.
assembled = WPPromptAssembler.execute(
context=downstream,
template="A $style $subject in the $location",
)
assert assembled.values == ("A painted knight in the forest",)
def test_debug_node_snapshots_downstream_context():
upstream = WPContext.execute(
seed=7,
wp_modules=_mods([
{"variable_name": "style", "value": "photoreal"},
]),
upstream=None,
).values[0]
out = WPDebug.execute(context=upstream, wp_viewer=None)
snapshot = json.loads(out.ui["wp_debug_snapshot"][0])
# Flat snapshot shape — user vars at the top, engine internals
# under `__wp_*` keys ready for the per-tab readers in
# `DebugViewer.vue`.
assert snapshot["style"] == "photoreal"
assert snapshot["__wp_node_seed__"] == 7
assert len(snapshot["__wp_trace__"]) == 1