Files
Taremin-comfyui-string-tools/tests/test_list_nodes_stability.py
Taremin c8647cab54 fix: ComfyUIの仕様変更に伴うリスト型ノードの出力バグの修正
最新のComfyUIにおける実行エンジンのリスト自動アンラップ廃止に伴い、リスト型ノードの出力データが下流ノードで二重にラップされて正常に結合できなくなる不具合を解消するため、およびE2Eテスト環境の不整合を修正

- StringToolsRandomChoiceList、StringToolsBalancedChoiceList、StringToolsConcatList の process 戻り値から不要なリストブラケットを削除
- test_string_tools_complex_interconnection において seed と text_list の接続ポートが逆になっていた不具合を修正
- テスト内モックノード StringToolsMockStringList をテスト実行環境(COMFYUI_TEST_MODE または pytest 稼働中)のみ動的に登録するように制御
- モックノード誤露出時のフェイルセーフとして NODE_DISPLAY_NAME_MAPPINGS にテスト用である旨の表示名を設定
- conftest.py の起動オプションにホワイトリストを追加しテスト実行速度を高速化
2026-07-04 09:08:02 +09:00

63 lines
2.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import pytest
import time
from playwright.sync_api import Page, expect
def test_list_nodes_do_not_have_dynamic_text_sockets(page: Page, comfyui_server: str, wait_for_comfyui):
"""
List系ノード(ConcateList, RandomChoiceList, BalancedChoiceList)において、
接続後も text_0, text_1 といった不要な動的ソケットが生成されないことを検証する。
"""
page.goto(comfyui_server)
wait_for_comfyui(page)
nodes_to_test = [
"StringToolsConcatList",
"StringToolsRandomChoiceList",
"StringToolsBalancedChoiceList"
]
for node_type in nodes_to_test:
print(f"Testing node type: {node_type}")
input_count = page.evaluate(f'''(type) => {{
app.graph.clear();
const node = LiteGraph.createNode(type);
app.graph.add(node);
const stringNode = LiteGraph.createNode("StringToolsString");
app.graph.add(stringNode);
// ポート接続を試みる(BalancedChoiceListの場合は slot 0: seed, slot 1: text_list)
// ポート名を検索して接続する
let targetSlot = -1;
for(let i=0; i < node.inputs.length; i++) {{
if(node.inputs[i].name === "text_list") {{
targetSlot = i;
break;
}}
}}
if (targetSlot === -1) throw new Error("text_list input not found for " + type);
stringNode.connect(0, node, targetSlot);
// onConnectionsChange を明示的に呼んでJS側のフックをトリガーする
if (node.onConnectionsChange) {{
node.onConnectionsChange(1, targetSlot, true, null, node.inputs[targetSlot]);
}}
// 入力ポートの一覧を返す
return node.inputs.map(i => i.name);
}}''', node_type)
print(f"Inputs for {node_type}: {input_count}")
# text_0 や text_1 が含まれていないことを確認
assert "text_0" not in input_count, f"Node {node_type} should not have text_0 socket"
assert "text_1" not in input_count, f"Node {node_type} should not have text_1 socket"
# かつ、text_list が維持されていることを確認
assert "text_list" in input_count, f"Node {node_type} should maintain text_list socket"
if __name__ == "__main__":
# 手動実行用
pass