Files
Taremin 26e910b4f1 chore(test): ComfyUIの複数バージョン自動検証基盤の導入とテスト安定化
テスト時に指定された複数のComfyUIバージョンを自動ダウンロードし、最適な仮想環境を構築した上でテストを実行する仕組みを導入。また、Playwright同期APIに起因するデッドロックやキャッシュ汚染によるテストのハングアップ問題を解消。

- 設定ファイルで複数バージョンの定義をサポート
- 該当するComfyUIおよびEmbeddable Pythonを自動取得するdownloaderモジュールを追加
- pytest_generate_testsによりバージョン別のテストを動的にパラメータ化
- min_comfy_versionマーカーによるバージョン制限テストの条件付きスキップをサポート
- Windows環境でのゾンビプロセス防止のためtaskkillによる強制終了処理を追加
- バージョン切り替え時のブラウザキャッシュ汚染を防ぐためキャッシュを無効化
- Playwright同期APIのダイアログ処理をJavaScript側でのモック化へ移行しデッドロックを回避
- 設定画面でのCSVトグル描画有無によるテストアプローチの動的切り替えを実装
- リサイズ操作のsteps指定など各種タイミング競合とタイムアウト処理を強化
2026-07-13 21:13:11 +09:00

98 lines
4.1 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 setup_console_log(page: Page):
page.on("console", lambda msg: print(f"BROWSER CONSOLE: {msg.type}: {msg.text}"))
page.on("pageerror", lambda err: print(f"BROWSER ERROR: {err}"))
# ヘルパー関数: APIを使用してMultiTextノードを直接追加
def add_node_api_force(page: Page):
for _ in range(10):
found = page.evaluate("""
() => {
const lg = window.LiteGraph;
if (!lg || !lg.registered_node_types) return null;
const type = Object.keys(lg.registered_node_types).find(k => k.includes("MultiText"));
if (type) {
const getApp = () => window.app || (window.comfyAPI && window.comfyAPI.app) || window.ComfyApp || (window.parent && window.parent.app);
const app = getApp();
app.graph.clear();
const node = lg.createNode(type);
const uniqueId = Math.random().toString(36).substring(2, 8);
node.title = "MT-INLINE-EDIT-" + uniqueId;
node.pos = [300, 300];
node.size = [400, 400];
app.graph.add(node);
app.canvas.draw(true, true);
return { type, id: node.id };
}
return null;
}
""")
if found:
return found
time.sleep(2.0)
raise Exception("MultiText node type not found")
def test_multitext_inline_edit(page: Page, comfyui_server, wait_for_comfyui, wmp_helpers):
"""インライン編集機能の動作確認(Renameボタン, ダブルクリック, Enter, Escape, blur)"""
setup_console_log(page)
# 1. ComfyUIを開く (fixtureを使用)
page.goto(comfyui_server)
wait_for_comfyui(page)
# 2. MultiTextノードを追加
add_node_api_force(page)
# サイドバーのアイテムが表示されるまで待機(default.txt)
wmp_helpers.wait_for_editor(page)
item_selector = "[class*='tree-name']"
expect(page.locator(item_selector).first).to_be_visible()
expect(page.locator(item_selector).first).to_have_text("default.txt")
# 3. 編集ボタンをクリックしてインライン編集に切り替わるか確認
# アクションを表示させるためにホバー
page.locator("[class*='tree-item']").first.hover()
# Renameボタン(editアイコン)をクリック
edit_btn = page.locator("[class*='multitext-tree-action'][title='Rename']")
edit_btn.click()
# inputが表示されていることを確認
input_selector = "[class*='tree-name-input']"
expect(page.locator(input_selector)).to_be_visible()
expect(page.locator(input_selector)).to_have_value("default.txt")
# 4. 名前を変更してEnterで確定
page.locator(input_selector).fill("renamed_via_enter.txt")
page.keyboard.press("Enter")
# inputが消え、新しい名前が表示されていることを確認
expect(page.locator(input_selector)).not_to_be_visible()
expect(page.locator(item_selector)).to_have_text("renamed_via_enter.txt")
# 5. ダブルクリックで編集開始
page.locator(item_selector).dblclick()
expect(page.locator(input_selector)).to_be_visible()
# 6. 変更してEscapeでキャンセル
page.locator(input_selector).fill("canceled.txt")
page.keyboard.press("Escape")
# 名前が変わっていないことを確認
expect(page.locator(input_selector)).not_to_be_visible()
expect(page.locator(item_selector)).to_have_text("renamed_via_enter.txt")
# 7. blurでの確定を確認
page.locator(item_selector).dblclick()
page.locator(input_selector).fill("renamed_via_blur.txt")
# 他の場所をクリックしてフォーカスを外す(キャンバス領域など)
page.mouse.click(10, 10)
expect(page.locator(input_selector)).not_to_be_visible()
expect(page.locator(item_selector)).to_have_text("renamed_via_blur.txt")
print("Inline edit E2E test passed!")