From 87c61386768fedc4905801db515e2dbe9e07fa08 Mon Sep 17 00:00:00 2001 From: Glary Date: Wed, 7 Oct 2026 05:25:30 +0000 Subject: [PATCH 1/6] Add node contract tests for the 1.55 frontend bump Lock the three bundled-node contracts the 1.55 bump depends on and that no existing test covers: the camera node ids saved workflows reference, the camera_info shape its 3D consumers read, and the absence of DynamicGroup widgets from bundled nodes while the frontend has no renderer for them. --- .../camera_info_contract_test.py | 56 +++++++++++++++++++ .../nodes_test/test_bundled_node_contracts.py | 47 ++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 tests-unit/comfy_extras_test/camera_info_contract_test.py create mode 100644 tests-unit/nodes_test/test_bundled_node_contracts.py diff --git a/tests-unit/comfy_extras_test/camera_info_contract_test.py b/tests-unit/comfy_extras_test/camera_info_contract_test.py new file mode 100644 index 00000000000..c7536dc198d --- /dev/null +++ b/tests-unit/comfy_extras_test/camera_info_contract_test.py @@ -0,0 +1,56 @@ +import math + +import pytest +import torch + +from comfy.cli_args import args + +if not torch.cuda.is_available(): + args.cpu = True + +from comfy_extras.nodes_camera import CreateCameraInfo +from comfy_extras.nodes_camera_angle import CameraAngle, build_camera_info, vertical_term +from comfy_extras.nodes_gaussian_splat import _camera_basis, _lookat_camera_info, _quat_camera_info + +DEVICE = torch.device("cpu") +EYE = [0.0, 0.0, 4.0] +ORIGIN = [0.0, 0.0, 0.0] + + +@pytest.mark.parametrize("node", [CameraAngle, CreateCameraInfo]) +def test_camera_nodes_agree_on_the_camera_info_output_type(node): + outputs = [o for o in node.define_schema().outputs if o.display_name == "camera_info"] + assert [o.get_io_type() for o in outputs] == ["LOAD3D_CAMERA"] + + +@pytest.mark.parametrize("horizontal, vertical", [(0, 0), (90, 0), (180, 0), (270, 0), (45, 30), (0, -30)]) +def test_camera_angle_aims_the_splat_renderer_where_it_was_asked_to(horizontal, vertical): + # CameraAngle emits no quaternion, so _camera_basis takes its look-at path. The view direction + # it recovers there has to be the angle the node was given. + yaw, pitch = math.radians(horizontal), math.radians(vertical) + _, target, _, _, fwd = _camera_basis(build_camera_info(horizontal, vertical, 5.0), DEVICE) + assert [float(v) for v in fwd] == pytest.approx( + [-math.cos(pitch) * math.sin(yaw), math.sin(pitch), math.cos(pitch) * math.cos(yaw)], abs=1e-5) + assert [float(v) for v in target] == pytest.approx(ORIGIN, abs=1e-6) + + +@pytest.mark.parametrize("vertical, term", [(-30, "low-angle shot"), (60, "high-angle shot")]) +def test_camera_angle_elevation_wording_matches_the_rendered_view(vertical, term): + # The splat frame is Y-down, so a camera above the subject looks along a positive forward Y. + _, _, _, _, fwd = _camera_basis(build_camera_info(0, vertical, 5.0), DEVICE) + assert vertical_term(vertical) == term + assert (float(fwd[1]) > 0) is (term == "high-angle shot") + + +def test_custom_up_is_flagged_only_when_the_camera_carries_roll(): + # The viewer honours the quaternion's up only when useCustomUp is set, so a camera that rolls + # has to say so or its roll is dropped on the way to the frontend. + assert "useCustomUp" not in _lookat_camera_info(EYE, ORIGIN, 35.0, DEVICE) + assert _lookat_camera_info(EYE, ORIGIN, 35.0, DEVICE, roll=30.0)["useCustomUp"] is True + assert _quat_camera_info(EYE, [0.0, 0.0, 0.0, 1.0], 35.0, DEVICE)["useCustomUp"] is True + + +def test_camera_angle_leaves_the_viewer_up_vector_alone(): + info = build_camera_info(90, 0, 5.0) + assert "quaternion" not in info + assert "useCustomUp" not in info diff --git a/tests-unit/nodes_test/test_bundled_node_contracts.py b/tests-unit/nodes_test/test_bundled_node_contracts.py new file mode 100644 index 00000000000..2ddd424cf81 --- /dev/null +++ b/tests-unit/nodes_test/test_bundled_node_contracts.py @@ -0,0 +1,47 @@ +import asyncio + +import pytest +import torch + +from comfy.cli_args import args + +if not torch.cuda.is_available(): + args.cpu = True + +import nodes +from comfy_api.latest._io import _DynamicGroup + + +@pytest.fixture(scope="module") +def bundled_nodes(): + asyncio.run(nodes.init_builtin_extra_nodes()) + return nodes.NODE_CLASS_MAPPINGS + + +def test_camera_nodes_keep_the_ids_saved_workflows_reference(bundled_nodes): + # CreateCameraInfo moved out of nodes_gaussian_splat.py into nodes_camera.py, and CameraAngle + # was renamed for display only. Both node ids are already in saved workflows. + assert "CreateCameraInfo" in bundled_nodes + assert "CameraAngle" in bundled_nodes + assert nodes.NODE_DISPLAY_NAME_MAPPINGS["CameraAngle"] == "Compose Camera Angle Prompt" + + +def _strings(value): + if isinstance(value, str): + yield value + elif isinstance(value, dict): + for item in value.values(): + yield from _strings(item) + elif isinstance(value, (list, tuple)): + for item in value: + yield from _strings(item) + + +def test_no_bundled_node_offers_a_dynamic_group_widget(bundled_nodes): + # The bundled frontend has no DynamicGroup renderer, so a bundled node offering one would show + # an unusable widget. The input stays internal until the frontend ships support for it. + offenders = sorted( + name for name, node in bundled_nodes.items() + if _DynamicGroup.io_type in _strings(node.INPUT_TYPES()) + ) + assert offenders == [] From 68fbd200217277accb698db1437640bfb902f5ff Mon Sep 17 00:00:00 2001 From: Glary Date: Wed, 7 Oct 2026 06:06:12 +0000 Subject: [PATCH 2/6] Sweep API nodes too and fix the elevation invariant Review follow-ups: the node sweep only loaded comfy_extras, missing the 300 comfy_api_nodes that a default startup also registers; a failed module import silently shrank what it examined; and the elevation check tied forward Y to one wording bucket, which is false for the elevated range. --- .../camera_info_contract_test.py | 12 ++++---- .../nodes_test/test_bundled_node_contracts.py | 30 +++++++++++++++---- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/tests-unit/comfy_extras_test/camera_info_contract_test.py b/tests-unit/comfy_extras_test/camera_info_contract_test.py index c7536dc198d..e96731e0ace 100644 --- a/tests-unit/comfy_extras_test/camera_info_contract_test.py +++ b/tests-unit/comfy_extras_test/camera_info_contract_test.py @@ -34,17 +34,19 @@ def test_camera_angle_aims_the_splat_renderer_where_it_was_asked_to(horizontal, assert [float(v) for v in target] == pytest.approx(ORIGIN, abs=1e-6) -@pytest.mark.parametrize("vertical, term", [(-30, "low-angle shot"), (60, "high-angle shot")]) +@pytest.mark.parametrize("vertical, term", [ + (-30, "low-angle shot"), (0, "eye-level shot"), (20, "elevated shot"), (60, "high-angle shot"), +]) def test_camera_angle_elevation_wording_matches_the_rendered_view(vertical, term): # The splat frame is Y-down, so a camera above the subject looks along a positive forward Y. _, _, _, _, fwd = _camera_basis(build_camera_info(0, vertical, 5.0), DEVICE) assert vertical_term(vertical) == term - assert (float(fwd[1]) > 0) is (term == "high-angle shot") + assert (float(fwd[1]) > 0) is (vertical > 0) -def test_custom_up_is_flagged_only_when_the_camera_carries_roll(): - # The viewer honours the quaternion's up only when useCustomUp is set, so a camera that rolls - # has to say so or its roll is dropped on the way to the frontend. +def test_camera_info_flags_custom_up_when_world_up_would_be_wrong(): + # The viewer honours the quaternion's up only when useCustomUp is set. A rolled camera and an + # explicitly supplied rotation both have to say so, or the frontend falls back to world up. assert "useCustomUp" not in _lookat_camera_info(EYE, ORIGIN, 35.0, DEVICE) assert _lookat_camera_info(EYE, ORIGIN, 35.0, DEVICE, roll=30.0)["useCustomUp"] is True assert _quat_camera_info(EYE, [0.0, 0.0, 0.0, 1.0], 35.0, DEVICE)["useCustomUp"] is True diff --git a/tests-unit/nodes_test/test_bundled_node_contracts.py b/tests-unit/nodes_test/test_bundled_node_contracts.py index 2ddd424cf81..b72d4817eb4 100644 --- a/tests-unit/nodes_test/test_bundled_node_contracts.py +++ b/tests-unit/nodes_test/test_bundled_node_contracts.py @@ -11,16 +11,36 @@ import nodes from comfy_api.latest._io import _DynamicGroup +# nodes_replacements.py only registers node replacements, and needs a running PromptServer to do +# it. It contributes no nodes of its own, so skipping it here costs no coverage. +ALLOWED_IMPORT_FAILURES = {"nodes_replacements.py"} + + +async def _load_bundled_nodes(): + return await nodes.init_builtin_extra_nodes() + await nodes.init_builtin_api_nodes() + @pytest.fixture(scope="module") def bundled_nodes(): - asyncio.run(nodes.init_builtin_extra_nodes()) - return nodes.NODE_CLASS_MAPPINGS + class_mappings = dict(nodes.NODE_CLASS_MAPPINGS) + display_name_mappings = dict(nodes.NODE_DISPLAY_NAME_MAPPINGS) + # Both halves of a default startup, so the sweep below sees every node a user gets. + import_failed = asyncio.run(_load_bundled_nodes()) + assert set(import_failed) <= ALLOWED_IMPORT_FAILURES, \ + "a bundled module failed to import, so the checks below would skip its nodes" + try: + yield nodes.NODE_CLASS_MAPPINGS + finally: + nodes.NODE_CLASS_MAPPINGS.clear() + nodes.NODE_CLASS_MAPPINGS.update(class_mappings) + nodes.NODE_DISPLAY_NAME_MAPPINGS.clear() + nodes.NODE_DISPLAY_NAME_MAPPINGS.update(display_name_mappings) -def test_camera_nodes_keep_the_ids_saved_workflows_reference(bundled_nodes): - # CreateCameraInfo moved out of nodes_gaussian_splat.py into nodes_camera.py, and CameraAngle - # was renamed for display only. Both node ids are already in saved workflows. +def test_camera_nodes_register_under_the_ids_workflows_reference(bundled_nodes): + # CreateCameraInfo has shipped since v0.23.0 and just moved out of nodes_gaussian_splat.py into + # nodes_camera.py, so saved workflows already carry its id. CameraAngle is new, and the frontend + # picker ships against this id and display name. assert "CreateCameraInfo" in bundled_nodes assert "CameraAngle" in bundled_nodes assert nodes.NODE_DISPLAY_NAME_MAPPINGS["CameraAngle"] == "Compose Camera Angle Prompt" From 79cbdf6fd1ecc1a3532eabddd4d6dd586fc45fa9 Mon Sep 17 00:00:00 2001 From: Glary Date: Wed, 7 Oct 2026 07:12:18 +0000 Subject: [PATCH 3/6] Keep the node sweep honest when a module fails to import Review follow-ups: restore the mappings even when the import assert fires, name 1.57.0 as the condition for retiring the DynamicGroup guard, and add a canary node so the sweep cannot quietly stop detecting anything. --- .../camera_info_contract_test.py | 6 ++-- .../nodes_test/test_bundled_node_contracts.py | 31 ++++++++++++++----- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/tests-unit/comfy_extras_test/camera_info_contract_test.py b/tests-unit/comfy_extras_test/camera_info_contract_test.py index e96731e0ace..2318d6a6fc7 100644 --- a/tests-unit/comfy_extras_test/camera_info_contract_test.py +++ b/tests-unit/comfy_extras_test/camera_info_contract_test.py @@ -41,12 +41,12 @@ def test_camera_angle_elevation_wording_matches_the_rendered_view(vertical, term # The splat frame is Y-down, so a camera above the subject looks along a positive forward Y. _, _, _, _, fwd = _camera_basis(build_camera_info(0, vertical, 5.0), DEVICE) assert vertical_term(vertical) == term - assert (float(fwd[1]) > 0) is (vertical > 0) + assert (float(fwd[1]) > 0) == (vertical > 0) def test_camera_info_flags_custom_up_when_world_up_would_be_wrong(): - # The viewer honours the quaternion's up only when useCustomUp is set. A rolled camera and an - # explicitly supplied rotation both have to say so, or the frontend falls back to world up. + # The viewer reads the quaternion's up only when useCustomUp is set, so a rolled camera and an + # explicitly supplied rotation both say so. A plain look-at leaves it off and keeps world up. assert "useCustomUp" not in _lookat_camera_info(EYE, ORIGIN, 35.0, DEVICE) assert _lookat_camera_info(EYE, ORIGIN, 35.0, DEVICE, roll=30.0)["useCustomUp"] is True assert _quat_camera_info(EYE, [0.0, 0.0, 0.0, 1.0], 35.0, DEVICE)["useCustomUp"] is True diff --git a/tests-unit/nodes_test/test_bundled_node_contracts.py b/tests-unit/nodes_test/test_bundled_node_contracts.py index b72d4817eb4..363e2d7d944 100644 --- a/tests-unit/nodes_test/test_bundled_node_contracts.py +++ b/tests-unit/nodes_test/test_bundled_node_contracts.py @@ -9,10 +9,12 @@ args.cpu = True import nodes +from comfy_api.latest import io from comfy_api.latest._io import _DynamicGroup -# nodes_replacements.py only registers node replacements, and needs a running PromptServer to do -# it. It contributes no nodes of its own, so skipping it here costs no coverage. +# Startup only logs an import failure and carries on. The sweep below is only meaningful over a +# complete node list, so here a failure is fatal instead. nodes_replacements.py is exempt: it needs +# a running PromptServer, and registers no nodes of its own, so skipping it costs no coverage. ALLOWED_IMPORT_FAILURES = {"nodes_replacements.py"} @@ -24,11 +26,12 @@ async def _load_bundled_nodes(): def bundled_nodes(): class_mappings = dict(nodes.NODE_CLASS_MAPPINGS) display_name_mappings = dict(nodes.NODE_DISPLAY_NAME_MAPPINGS) - # Both halves of a default startup, so the sweep below sees every node a user gets. - import_failed = asyncio.run(_load_bundled_nodes()) - assert set(import_failed) <= ALLOWED_IMPORT_FAILURES, \ - "a bundled module failed to import, so the checks below would skip its nodes" try: + # Both halves of a default startup, so the sweep below sees every node a user gets. The + # loaded modules themselves stay resident; only the mappings are put back. + import_failed = asyncio.run(_load_bundled_nodes()) + assert set(import_failed) <= ALLOWED_IMPORT_FAILURES, \ + "a bundled module failed to import, so the checks below would skip its nodes" yield nodes.NODE_CLASS_MAPPINGS finally: nodes.NODE_CLASS_MAPPINGS.clear() @@ -57,9 +60,21 @@ def _strings(value): yield from _strings(item) +def test_a_dynamic_group_widget_is_detectable(bundled_nodes): + class Grouped(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema(node_id=cls.__name__, inputs=[ + _DynamicGroup.Input("rows", template=[io.Float.Input("x")]), + ], outputs=[]) + + assert _DynamicGroup.io_type in _strings(Grouped.INPUT_TYPES()) + + def test_no_bundled_node_offers_a_dynamic_group_widget(bundled_nodes): - # The bundled frontend has no DynamicGroup renderer, so a bundled node offering one would show - # an unusable widget. The input stays internal until the frontend ships support for it. + # comfyui-frontend-package 1.55.x has no DynamicGroup renderer, so a bundled node offering one + # would show an unusable widget. Frontend support landed in 1.57.0; drop this once the pin in + # requirements.txt reaches a version that has it. offenders = sorted( name for name, node in bundled_nodes.items() if _DynamicGroup.io_type in _strings(node.INPUT_TYPES()) From d131e4f92374acca025626dfb7493c8143883800 Mon Sep 17 00:00:00 2001 From: Glary Date: Wed, 7 Oct 2026 08:12:23 +0000 Subject: [PATCH 4/6] Pin the camera angle inputs the frontend picker binds to The picker is selected by widgetType and mirrors the node's widget ids, limits and scene constants, so either side can drift alone. Also anchor both halves of the node sweep, and roll the quaternion so the useCustomUp case matches its name. --- .../camera_info_contract_test.py | 30 +++++++++++++++---- .../nodes_test/test_bundled_node_contracts.py | 10 ++++++- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/tests-unit/comfy_extras_test/camera_info_contract_test.py b/tests-unit/comfy_extras_test/camera_info_contract_test.py index 2318d6a6fc7..05fefdd971f 100644 --- a/tests-unit/comfy_extras_test/camera_info_contract_test.py +++ b/tests-unit/comfy_extras_test/camera_info_contract_test.py @@ -9,12 +9,13 @@ args.cpu = True from comfy_extras.nodes_camera import CreateCameraInfo -from comfy_extras.nodes_camera_angle import CameraAngle, build_camera_info, vertical_term +from comfy_extras.nodes_camera_angle import CAMERA_FOV, SUBJECT_CENTER, CameraAngle, build_camera_info, vertical_term from comfy_extras.nodes_gaussian_splat import _camera_basis, _lookat_camera_info, _quat_camera_info DEVICE = torch.device("cpu") EYE = [0.0, 0.0, 4.0] ORIGIN = [0.0, 0.0, 0.0] +ROLLED = [0.0, 0.0, math.sin(math.pi / 8), math.cos(math.pi / 8)] @pytest.mark.parametrize("node", [CameraAngle, CreateCameraInfo]) @@ -23,19 +24,36 @@ def test_camera_nodes_agree_on_the_camera_info_output_type(node): assert [o.get_io_type() for o in outputs] == ["LOAD3D_CAMERA"] +def test_camera_angle_keeps_the_inputs_the_frontend_picker_binds_to(): + # The picker is selected by widgetType, writes back through these ids, and mirrors the limits, + # defaults and scene constants in src/extensions/core/cameraAngle/types.ts. Changing either + # side alone leaves the node and its 3D preview disagreeing. + inputs = {i.id: i for i in CameraAngle.define_schema().inputs} + assert inputs["view"].extra_dict == {"widgetType": "CAMERA_ANGLE_VIEW"} + assert [(i.default, i.min, i.max) for i in map(inputs.get, ("horizontal_angle", "vertical_angle", "zoom"))] == [ + (0, 0, 360), (0, -30, 60), (5.0, 0.0, 10.0), + ] + assert (SUBJECT_CENTER, CAMERA_FOV) == ((0.0, 0.0, 0.0), 35.0) + + @pytest.mark.parametrize("horizontal, vertical", [(0, 0), (90, 0), (180, 0), (270, 0), (45, 30), (0, -30)]) def test_camera_angle_aims_the_splat_renderer_where_it_was_asked_to(horizontal, vertical): # CameraAngle emits no quaternion, so _camera_basis takes its look-at path. The view direction # it recovers there has to be the angle the node was given. yaw, pitch = math.radians(horizontal), math.radians(vertical) - _, target, _, _, fwd = _camera_basis(build_camera_info(horizontal, vertical, 5.0), DEVICE) + _, _, _, _, fwd = _camera_basis(build_camera_info(horizontal, vertical, 5.0), DEVICE) assert [float(v) for v in fwd] == pytest.approx( [-math.cos(pitch) * math.sin(yaw), math.sin(pitch), math.cos(pitch) * math.cos(yaw)], abs=1e-5) + + +def test_camera_angle_always_aims_at_the_subject_centre(): + _, target, _, _, _ = _camera_basis(build_camera_info(45, 30, 5.0), DEVICE) assert [float(v) for v in target] == pytest.approx(ORIGIN, abs=1e-6) @pytest.mark.parametrize("vertical, term", [ - (-30, "low-angle shot"), (0, "eye-level shot"), (20, "elevated shot"), (60, "high-angle shot"), + (-30, "low-angle shot"), (-15, "eye-level shot"), (0, "eye-level shot"), + (15, "elevated shot"), (45, "high-angle shot"), (60, "high-angle shot"), ]) def test_camera_angle_elevation_wording_matches_the_rendered_view(vertical, term): # The splat frame is Y-down, so a camera above the subject looks along a positive forward Y. @@ -45,11 +63,11 @@ def test_camera_angle_elevation_wording_matches_the_rendered_view(vertical, term def test_camera_info_flags_custom_up_when_world_up_would_be_wrong(): - # The viewer reads the quaternion's up only when useCustomUp is set, so a rolled camera and an - # explicitly supplied rotation both say so. A plain look-at leaves it off and keeps world up. + # The viewer reads the quaternion's up only when useCustomUp is set, so a rolled camera and a + # supplied rotation that tilts up both say so. A plain look-at leaves it off and keeps world up. assert "useCustomUp" not in _lookat_camera_info(EYE, ORIGIN, 35.0, DEVICE) assert _lookat_camera_info(EYE, ORIGIN, 35.0, DEVICE, roll=30.0)["useCustomUp"] is True - assert _quat_camera_info(EYE, [0.0, 0.0, 0.0, 1.0], 35.0, DEVICE)["useCustomUp"] is True + assert _quat_camera_info(EYE, ROLLED, 35.0, DEVICE)["useCustomUp"] is True def test_camera_angle_leaves_the_viewer_up_vector_alone(): diff --git a/tests-unit/nodes_test/test_bundled_node_contracts.py b/tests-unit/nodes_test/test_bundled_node_contracts.py index 363e2d7d944..31fc401248c 100644 --- a/tests-unit/nodes_test/test_bundled_node_contracts.py +++ b/tests-unit/nodes_test/test_bundled_node_contracts.py @@ -40,6 +40,14 @@ def bundled_nodes(): nodes.NODE_DISPLAY_NAME_MAPPINGS.update(display_name_mappings) +def test_both_halves_of_a_default_startup_are_loaded(bundled_nodes): + # The sweep below is only as good as its node list, and the api nodes are a third of it. Pin one + # from each half so a glob that stops matching shows up here instead of quietly shrinking it. + assert "KSampler" in bundled_nodes + assert "CameraAngle" in bundled_nodes + assert "OpenAIGPTImage1" in bundled_nodes + + def test_camera_nodes_register_under_the_ids_workflows_reference(bundled_nodes): # CreateCameraInfo has shipped since v0.23.0 and just moved out of nodes_gaussian_splat.py into # nodes_camera.py, so saved workflows already carry its id. CameraAngle is new, and the frontend @@ -60,7 +68,7 @@ def _strings(value): yield from _strings(item) -def test_a_dynamic_group_widget_is_detectable(bundled_nodes): +def test_a_dynamic_group_widget_is_detectable(): class Grouped(io.ComfyNode): @classmethod def define_schema(cls): From a13dedb81cc1385e1b1d61ccee5a48169ee6942e Mon Sep 17 00:00:00 2001 From: Glary Date: Wed, 7 Oct 2026 09:01:51 +0000 Subject: [PATCH 5/6] Pin the rest of the scene constants the preview camera uses SUBJECT_DISTANCE and the lens zoom range are hand-duplicated in the frontend's cameraAngle/types.ts and place the preview camera, so a backend-only edit to any of them moves the preview away from the emitted camera_info. --- .../camera_info_contract_test.py | 29 ++++++++++++++----- .../nodes_test/test_bundled_node_contracts.py | 4 +-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/tests-unit/comfy_extras_test/camera_info_contract_test.py b/tests-unit/comfy_extras_test/camera_info_contract_test.py index 05fefdd971f..3ee0207023c 100644 --- a/tests-unit/comfy_extras_test/camera_info_contract_test.py +++ b/tests-unit/comfy_extras_test/camera_info_contract_test.py @@ -9,7 +9,16 @@ args.cpu = True from comfy_extras.nodes_camera import CreateCameraInfo -from comfy_extras.nodes_camera_angle import CAMERA_FOV, SUBJECT_CENTER, CameraAngle, build_camera_info, vertical_term +from comfy_extras.nodes_camera_angle import ( + CAMERA_FOV, + MAX_ZOOM_FACTOR, + MIN_ZOOM_FACTOR, + SUBJECT_CENTER, + SUBJECT_DISTANCE, + CameraAngle, + build_camera_info, + vertical_term, +) from comfy_extras.nodes_gaussian_splat import _camera_basis, _lookat_camera_info, _quat_camera_info DEVICE = torch.device("cpu") @@ -25,15 +34,19 @@ def test_camera_nodes_agree_on_the_camera_info_output_type(node): def test_camera_angle_keeps_the_inputs_the_frontend_picker_binds_to(): - # The picker is selected by widgetType, writes back through these ids, and mirrors the limits, - # defaults and scene constants in src/extensions/core/cameraAngle/types.ts. Changing either - # side alone leaves the node and its 3D preview disagreeing. + # The picker is selected by widgetType, writes back through these ids, and hand-duplicates the + # limits, defaults, steps and scene constants in src/extensions/core/cameraAngle/types.ts, which + # it uses to place the preview camera. Changing either side alone leaves the node and its 3D + # preview disagreeing, with nothing negotiating the difference at runtime. inputs = {i.id: i for i in CameraAngle.define_schema().inputs} - assert inputs["view"].extra_dict == {"widgetType": "CAMERA_ANGLE_VIEW"} - assert [(i.default, i.min, i.max) for i in map(inputs.get, ("horizontal_angle", "vertical_angle", "zoom"))] == [ - (0, 0, 360), (0, -30, 60), (5.0, 0.0, 10.0), + assert set(inputs) == {"horizontal_angle", "vertical_angle", "zoom", "image", "view"} + assert inputs["view"].extra_dict["widgetType"] == "CAMERA_ANGLE_VIEW" + assert [(inputs[i].default, inputs[i].min, inputs[i].max, inputs[i].step) + for i in ("horizontal_angle", "vertical_angle", "zoom")] == [ + (0, 0, 360, 1), (0, -30, 60, 1), (5.0, 0.0, 10.0, 0.1), ] - assert (SUBJECT_CENTER, CAMERA_FOV) == ((0.0, 0.0, 0.0), 35.0) + assert (SUBJECT_CENTER, CAMERA_FOV, SUBJECT_DISTANCE, MIN_ZOOM_FACTOR, MAX_ZOOM_FACTOR) == \ + ((0.0, 0.0, 0.0), 35.0, 6.0, 1.0, 1.875) @pytest.mark.parametrize("horizontal, vertical", [(0, 0), (90, 0), (180, 0), (270, 0), (45, 30), (0, -30)]) diff --git a/tests-unit/nodes_test/test_bundled_node_contracts.py b/tests-unit/nodes_test/test_bundled_node_contracts.py index 31fc401248c..1d4c9207861 100644 --- a/tests-unit/nodes_test/test_bundled_node_contracts.py +++ b/tests-unit/nodes_test/test_bundled_node_contracts.py @@ -50,10 +50,8 @@ def test_both_halves_of_a_default_startup_are_loaded(bundled_nodes): def test_camera_nodes_register_under_the_ids_workflows_reference(bundled_nodes): # CreateCameraInfo has shipped since v0.23.0 and just moved out of nodes_gaussian_splat.py into - # nodes_camera.py, so saved workflows already carry its id. CameraAngle is new, and the frontend - # picker ships against this id and display name. + # nodes_camera.py, so saved workflows already carry its id. assert "CreateCameraInfo" in bundled_nodes - assert "CameraAngle" in bundled_nodes assert nodes.NODE_DISPLAY_NAME_MAPPINGS["CameraAngle"] == "Compose Camera Angle Prompt" From 0734ad2d24b1e764b77fa0b963337797201542f2 Mon Sep 17 00:00:00 2001 From: Glary Date: Wed, 7 Oct 2026 09:21:04 +0000 Subject: [PATCH 6/6] Let the picker contract tolerate an added input An extra widget is inert for the bridge and the preview camera, so only require the inputs the frontend actually binds to. --- tests-unit/comfy_extras_test/camera_info_contract_test.py | 2 +- tests-unit/nodes_test/test_bundled_node_contracts.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests-unit/comfy_extras_test/camera_info_contract_test.py b/tests-unit/comfy_extras_test/camera_info_contract_test.py index 3ee0207023c..3e1288fce25 100644 --- a/tests-unit/comfy_extras_test/camera_info_contract_test.py +++ b/tests-unit/comfy_extras_test/camera_info_contract_test.py @@ -39,7 +39,7 @@ def test_camera_angle_keeps_the_inputs_the_frontend_picker_binds_to(): # it uses to place the preview camera. Changing either side alone leaves the node and its 3D # preview disagreeing, with nothing negotiating the difference at runtime. inputs = {i.id: i for i in CameraAngle.define_schema().inputs} - assert set(inputs) == {"horizontal_angle", "vertical_angle", "zoom", "image", "view"} + assert set(inputs) >= {"horizontal_angle", "vertical_angle", "zoom", "image", "view"} assert inputs["view"].extra_dict["widgetType"] == "CAMERA_ANGLE_VIEW" assert [(inputs[i].default, inputs[i].min, inputs[i].max, inputs[i].step) for i in ("horizontal_angle", "vertical_angle", "zoom")] == [ diff --git a/tests-unit/nodes_test/test_bundled_node_contracts.py b/tests-unit/nodes_test/test_bundled_node_contracts.py index 1d4c9207861..ae3fd0bd713 100644 --- a/tests-unit/nodes_test/test_bundled_node_contracts.py +++ b/tests-unit/nodes_test/test_bundled_node_contracts.py @@ -50,7 +50,8 @@ def test_both_halves_of_a_default_startup_are_loaded(bundled_nodes): def test_camera_nodes_register_under_the_ids_workflows_reference(bundled_nodes): # CreateCameraInfo has shipped since v0.23.0 and just moved out of nodes_gaussian_splat.py into - # nodes_camera.py, so saved workflows already carry its id. + # nodes_camera.py, so saved workflows already carry its id. CameraAngle is new, and shipped + # under a display name agreed after its node id was already in use. assert "CreateCameraInfo" in bundled_nodes assert nodes.NODE_DISPLAY_NAME_MAPPINGS["CameraAngle"] == "Compose Camera Angle Prompt"