Files
Taremin f84fea75b6 refactor: テストディレクトリの構成整理とプリセット機能のモジュール化
- テストファイルを e2e, unit, debug などのカテゴリ別ディレクトリに移動し、構成を整理
- 不要な一時デバッグ用スクリプトを削除し、テスト環境をクリーンアップ
- 言語機能やプリセット定義を src/languages/ ディレクトリに分離・モジュール化
- 言語プリセット管理ダイアログ (preset_dialog.ts) の追加と関連スタイルの更新
- __init__.py での MultiText ノード入力値パース処理を堅牢化 (リスト入力や不正JSONへの対応)
- .gitignore に .agents および debug_dumps の除外設定を追加
2026-03-18 19:37:00 +09:00

84 lines
3.4 KiB
Python

import pytest
import time
import uuid
from playwright.sync_api import Page, expect
def test_multitext_full_search(page: Page, comfyui_server, wait_for_comfyui, wmp_helpers):
"""(UI操作方式) 非アクティブファイルの内容も検索で見つかることを確認する"""
wmp_helpers.load_comfyui(page, comfyui_server, wait_for_comfyui)
wmp_helpers.wait_for_graph_clear(page)
page.set_viewport_size({"width": 1920, "height": 1080})
# 一意のタイトルを持つノードを作成 (隔離)
node_title = f"MT-SEARCH-UI-{uuid.uuid4().hex[:6]}"
print(f"Creating node with title: {node_title}")
node_id = wmp_helpers.create_node(page, "WebuiMonacoPromptMultiText", [200, 200])
page.evaluate(f"""(args) => {{
const app = window.app || window.ComfyApp;
const node = app.graph.getNodeById(args.id);
node.title = args.title;
node.setSize([800, 600]);
}}""", {"id": node_id, "title": node_title})
# ノードとエディタの準備待ち
page.wait_for_function(f"""
(title) => {{
const app = window.app || window.ComfyApp;
const node = app.graph && app.graph._nodes.find(n => n.title === title && n.multitext_widget);
return node && node.multitext_widget && !!node.multitext_widget.editorInstance;
}}
""", arg=node_title)
print("Step 2: Setup files and content via JS")
second_file = "search_test_ui.txt"
page.evaluate(f"""(title) => {{
const node = (window.app || window.ComfyApp).graph._nodes.find(n => n.title === title);
const w = node.multitext_widget;
// second file
w.addItemWithName('file', '{second_file}');
const f = w.data.tree.find(i => i.name === '{second_file}');
w.openFile(f.id);
w.editorInstance.monaco.setValue("secret search word ui");
// defaultに戻す
const d = w.data.tree.find(i => i.name === 'default.txt');
w.openFile(d.id);
}}""", node_title)
wmp_helpers.wait_for_ui_stabilize(page)
print("Step 3: Perform Search via UI")
# 検索タブを開く
page.click("[title='Search']")
# 検索入力欄が出るまで待つ
page.wait_for_selector("input[class*='search-input']")
search_input = page.locator("input[class*='search-input']")
search_input.fill("secret")
search_input.press("Enter")
# 検索結果が出るのを待つ
page.wait_for_selector("div[class*='search-result-item']")
print("Step 4: Click result and verify Switch")
# 目的のファイルの結果をクリック
target_row = page.locator("div[class*='search-result-item']").filter(has_text=second_file).first
target_row.click()
wmp_helpers.wait_for_ui_stabilize(page)
# アクティブファイルが切り替わったかJSで確認
active_name = page.evaluate(f"""(title) => {{
const node = (window.app || window.ComfyApp).graph._nodes.find(n => n.title === title);
const w = node.multitext_widget;
const activeId = w.data.activeFileId;
const file = w.data.tree.find(i => i.id === activeId) ||
w.data.tree.flatMap(i => i.children || []).find(i => i.id === activeId);
return file ? file.name : null;
}}""", node_title)
assert active_name == second_file, f"Active file should be {second_file}, but got {active_name}"
print("Verification successful: UI Search & Switch Passed.")