- Update test URLs from localhost:18188 to gandalf.local:8188 - Make check_interval test flexible (accept any valid 1-168 value) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
123 lines
3.9 KiB
Python
123 lines
3.9 KiB
Python
"""Simple Playwright test for ComfyUI-ModelSync."""
|
|
|
|
import pytest
|
|
from playwright.sync_api import Page, expect
|
|
|
|
|
|
COMFYUI_URL = "http://gandalf.local:8188"
|
|
|
|
|
|
def test_api_works(page: Page):
|
|
"""Test that the API endpoints work."""
|
|
# Test status endpoint
|
|
response = page.request.get(f"{COMFYUI_URL}/modelsync/status")
|
|
assert response.ok
|
|
data = response.json()
|
|
assert "scheduler" in data
|
|
print(f"API Status: {data}")
|
|
|
|
# Test scan endpoint
|
|
response = page.request.post(f"{COMFYUI_URL}/modelsync/models/scan")
|
|
assert response.ok
|
|
data = response.json()
|
|
print(f"Scan result: {data}")
|
|
|
|
# Test models endpoint
|
|
response = page.request.get(f"{COMFYUI_URL}/modelsync/models")
|
|
assert response.ok
|
|
data = response.json()
|
|
print(f"Models count: {len(data.get('models', []))}")
|
|
|
|
|
|
def test_comfyui_loads_and_check_js(page: Page):
|
|
"""Test that ComfyUI loads and check for JS errors."""
|
|
# Capture console messages
|
|
console_messages = []
|
|
page.on("console", lambda msg: console_messages.append(f"{msg.type}: {msg.text}"))
|
|
|
|
page.goto(COMFYUI_URL)
|
|
page.wait_for_load_state("networkidle")
|
|
|
|
# Wait for ComfyUI to initialize
|
|
page.wait_for_timeout(5000)
|
|
|
|
# Print console messages
|
|
print("\n=== Console Messages ===")
|
|
for msg in console_messages:
|
|
if "ModelSync" in msg or "error" in msg.lower():
|
|
print(msg)
|
|
|
|
# Check if ModelSync initialized
|
|
modelsync_init = any("ModelSync" in msg for msg in console_messages)
|
|
print(f"\nModelSync initialized: {modelsync_init}")
|
|
|
|
# Take a screenshot for debugging
|
|
page.screenshot(path="/tmp/comfyui-modelsync-test.png")
|
|
print(f"\nScreenshot saved to /tmp/comfyui-modelsync-test.png")
|
|
|
|
# Try to find any buttons with "Model" or "Sync" in them
|
|
buttons = page.locator("button").all()
|
|
print(f"\n=== All buttons ({len(buttons)}) ===")
|
|
for btn in buttons[:20]: # First 20 buttons
|
|
try:
|
|
text = btn.text_content()
|
|
if text:
|
|
print(f" Button: {text.strip()[:50]}")
|
|
except:
|
|
pass
|
|
|
|
# Check what menus exist
|
|
menus = page.locator(".comfy-menu, .comfyui-menu, [class*='menu']").all()
|
|
print(f"\n=== Menu elements ({len(menus)}) ===")
|
|
for menu in menus[:5]:
|
|
try:
|
|
classes = menu.get_attribute("class")
|
|
print(f" Menu class: {classes}")
|
|
except:
|
|
pass
|
|
|
|
|
|
def test_manual_modelsync_button(page: Page):
|
|
"""Manually look for ModelSync button."""
|
|
page.goto(COMFYUI_URL)
|
|
page.wait_for_load_state("networkidle")
|
|
page.wait_for_timeout(5000)
|
|
|
|
# Try multiple selectors
|
|
selectors = [
|
|
"button:has-text('Model Sync')",
|
|
"button:has-text('ModelSync')",
|
|
".modelsync-menu-btn",
|
|
"button.modelsync-menu-btn",
|
|
"[class*='modelsync']",
|
|
]
|
|
|
|
for selector in selectors:
|
|
try:
|
|
elements = page.locator(selector).all()
|
|
print(f"Selector '{selector}': {len(elements)} matches")
|
|
for el in elements:
|
|
print(f" Element: {el.get_attribute('class')} - {el.text_content()[:50] if el.text_content() else 'no text'}")
|
|
except Exception as e:
|
|
print(f"Selector '{selector}': Error - {e}")
|
|
|
|
# Execute JS to check if ModelSyncPanel exists
|
|
result = page.evaluate("() => { return typeof window.ModelSyncPanel !== 'undefined' }")
|
|
print(f"\nwindow.ModelSyncPanel exists: {result}")
|
|
|
|
if result:
|
|
# Try to manually open the panel
|
|
page.evaluate("() => { window.ModelSyncPanel.toggle(); }")
|
|
page.wait_for_timeout(1000)
|
|
|
|
panel = page.locator(".modelsync-panel")
|
|
print(f"Panel visible after toggle: {panel.is_visible()}")
|
|
|
|
if panel.is_visible():
|
|
page.screenshot(path="/tmp/comfyui-modelsync-panel.png")
|
|
print("Panel screenshot saved to /tmp/comfyui-modelsync-panel.png")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
pytest.main([__file__, "-v", "-s"])
|