ComfyUI-SwissArmyKnife - Playwright Tests
This directory contains Playwright-based browser automation tests for the ComfyUI-SwissArmyKnife ComfyUI extension.
Test Suite Overview
Tests Included
-
test_state_management.js- Comprehensive state management testing- Tests widget visibility when switching between image/video modes
- Verifies only appropriate upload buttons are shown
- Tests transitions between Upload Media and Randomize Media modes
- 6 comprehensive test scenarios
-
test_media_path_fix.js- Media path preservation testing- Tests that media_path values are preserved during widget recreation
- Verifies the fix for the "Media path is required" error
- Tests widget state transitions
-
quick_test.js- Quick validation test- Simplified test for rapid verification
- Tests basic image → video → image transitions
- Faster execution for quick checks
Setup
Install Dependencies
cd web/tests
npm install
Install Browser
npm run install-browser
Running Tests
Run All Tests
npm test
# or
npm run test:all
Run Individual Tests
# State management tests
npm run test:state
# Media path preservation tests
npm run test:media-path
# Quick validation test
npm run test:quick
Headless Mode
npm run test:headless
Test Requirements
- ComfyUI Instance: Tests connect to
https://comfyui.devlabhq.com/ - Workflow File: Requires
video-describe.jsonworkflow to be available - Node Type: Tests the
GeminiUtilMediaDescribenode specifically - Browser: Chromium (installed automatically via Playwright)
Test Structure
Each test follows this pattern:
- Setup: Launch browser and navigate to ComfyUI
- Workflow Loading: Open the video-describe workflow
- Node Interaction: Find and interact with the Gemini node
- State Testing: Perform various state transitions
- Validation: Check widget visibility and values
- Cleanup: Close browser
Understanding Test Output
Success Indicators
- ✅ PASSED - Individual test case passed
- 🎉 ALL TESTS PASSED - Complete test suite success
Debug Information
- 📝 ComfyUI Console - State change logs from the extension
- 📊 Test Results Summary - Overall pass/fail statistics
- 🔍 Widget State Info - Current widget configuration details
Troubleshooting
Common Issues
-
"Target page has been closed"
- Ensure running in headless mode on servers without X11
- Check that ComfyUI is accessible at the test URL
-
"No tests ran"
- Verify the workflow file exists in ComfyUI
- Check that the GeminiUtilMediaDescribe node is available
-
Widget state tests failing
- Clear browser cache and restart ComfyUI
- Verify the latest JavaScript widgets are loaded
Test Timeouts
- Navigation: 60 seconds
- Widget interactions: 1-2 seconds
- State transitions: 1-1.5 seconds
- Complete test suite: ~2-3 minutes
Development
Adding New Tests
- Create new test file in this directory
- Follow the existing class structure pattern
- Add npm script to
package.json - Update this README
Test Data
Tests use these standard values:
- Test paths:
/test/media/path,/reference-vids/jg-reels - Media types:
image,video - Media sources:
Upload Media,Randomize Media from Path
Console Logging
Tests listen for console messages with [STATE] prefix to track widget operations during state transitions.