Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64f70b6970 | ||
|
|
ae0fb7f229 | ||
|
|
ddf73a667e | ||
|
|
c182c775f4 | ||
|
|
02108be2d1 | ||
|
|
2a9fbe78c7 | ||
|
|
5a8a8b62e4 | ||
|
|
335cc53961 | ||
|
|
c5e00c130b | ||
|
|
78f1498ea8 | ||
|
|
c65f3aad03 | ||
|
|
9a55c23282 | ||
|
|
e90bde5849 | ||
|
|
49523e10de | ||
|
|
8e6cf4233a | ||
|
|
6301cf90f8 | ||
|
|
f87eb959b3 | ||
|
|
7783ed8a16 | ||
|
|
726fcee761 | ||
|
|
98f3defe50 | ||
|
|
143a6c47f6 | ||
|
|
76a52765c7 | ||
|
|
f308b23631 |
@@ -0,0 +1,28 @@
|
|||||||
|
# Files excluded from the Comfy Registry archive (gitignore syntax).
|
||||||
|
# Everything here is development-only; the published node needs
|
||||||
|
# __init__.py, kikotools/, web/, examples/, README, LICENSE, pyproject.toml.
|
||||||
|
|
||||||
|
# Test suite and tooling
|
||||||
|
tests/
|
||||||
|
scripts/
|
||||||
|
.github/
|
||||||
|
Makefile
|
||||||
|
pytest.ini
|
||||||
|
mypy.ini
|
||||||
|
.flake8
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
.secrets.baseline
|
||||||
|
requirements-dev.txt
|
||||||
|
|
||||||
|
# Reference / scratch code not imported by the node
|
||||||
|
example.py
|
||||||
|
|
||||||
|
# Agent and contributor docs
|
||||||
|
CLAUDE.md
|
||||||
|
CONTRIBUTING.md
|
||||||
|
CODE_OF_CONDUCT.md
|
||||||
|
|
||||||
|
tools/
|
||||||
|
coverage/
|
||||||
|
TESTING.md
|
||||||
|
AGENTS.md
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
max-line-length = 127
|
max-line-length = 127
|
||||||
max-complexity = 10
|
max-complexity = 10
|
||||||
exclude =
|
exclude =
|
||||||
|
node_modules,
|
||||||
.git,
|
.git,
|
||||||
__pycache__,
|
__pycache__,
|
||||||
.mypy_cache,
|
.mypy_cache,
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"required_status_checks": {
|
||||||
|
"strict": true,
|
||||||
|
"contexts": [
|
||||||
|
"py3.10 on ubuntu-latest", "py3.11 on ubuntu-latest", "py3.12 on ubuntu-latest", "py3.13 on ubuntu-latest",
|
||||||
|
"py3.10 on windows-latest", "py3.11 on windows-latest", "py3.12 on windows-latest", "py3.13 on windows-latest",
|
||||||
|
"py3.10 on macos-latest", "py3.11 on macos-latest", "py3.12 on macos-latest", "py3.13 on macos-latest",
|
||||||
|
"coverage gate (85%)", "frontend syntax", "frontend workflows and coverage", "code-quality"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"enforce_admins": true,
|
||||||
|
"required_pull_request_reviews": null,
|
||||||
|
"restrictions": null,
|
||||||
|
"allow_force_pushes": false,
|
||||||
|
"allow_deletions": false
|
||||||
|
}
|
||||||
@@ -8,3 +8,7 @@ updates:
|
|||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/tools/testing"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Set up Python 3.10
|
- name: Set up Python 3.10
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
python-version: '3.10'
|
python-version: '3.10'
|
||||||
|
|
||||||
- name: Cache pip dependencies
|
- name: Cache pip dependencies
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v6
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
key: ${{ runner.os }}-pip-quality-${{ hashFiles('**/requirements-dev.txt') }}
|
key: ${{ runner.os }}-pip-quality-${{ hashFiles('**/requirements-dev.txt') }}
|
||||||
@@ -31,6 +31,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
|
pip install torch --index-url https://download.pytorch.org/whl/cpu
|
||||||
pip install -r requirements-dev.txt
|
pip install -r requirements-dev.txt
|
||||||
|
|
||||||
- name: Format check with Black
|
- name: Format check with Black
|
||||||
@@ -141,7 +142,7 @@ jobs:
|
|||||||
security:
|
security:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Set up Python 3.10
|
- name: Set up Python 3.10
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
@@ -172,7 +173,7 @@ jobs:
|
|||||||
architecture:
|
architecture:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Set up Python 3.10
|
- name: Set up Python 3.10
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
@@ -182,6 +183,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
|
pip install torch --index-url https://download.pytorch.org/whl/cpu
|
||||||
pip install -r requirements-dev.txt
|
pip install -r requirements-dev.txt
|
||||||
|
|
||||||
- name: Check architecture compliance
|
- name: Check architecture compliance
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ jobs:
|
|||||||
if: ${{ github.repository_owner == 'ComfyAssets' }}
|
if: ${{ github.repository_owner == 'ComfyAssets' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- name: Publish Custom Node
|
- name: Publish Custom Node
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-release:
|
create-release:
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.get_version.outputs.version }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Set up Python 3.10
|
- name: Set up Python 3.10
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
@@ -25,40 +27,11 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
|
pip install torch --index-url https://download.pytorch.org/whl/cpu
|
||||||
pip install -r requirements-dev.txt
|
pip install -r requirements-dev.txt
|
||||||
|
|
||||||
- name: Run full test suite
|
- name: Run full test suite and coverage gate
|
||||||
run: |
|
run: python -m pytest tests --cov=kikotools --cov-report=term-missing
|
||||||
python -c "
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
sys.path.insert(0, os.getcwd())
|
|
||||||
|
|
||||||
# Run comprehensive tests before release
|
|
||||||
from kikotools.base import ComfyAssetsBaseNode
|
|
||||||
from kikotools.tools.resolution_calculator.logic import extract_dimensions, calculate_scaled_dimensions
|
|
||||||
from kikotools.tools.resolution_calculator.node import ResolutionCalculatorNode
|
|
||||||
import torch
|
|
||||||
|
|
||||||
print('Running pre-release validation...')
|
|
||||||
|
|
||||||
# Test all major functionality
|
|
||||||
node = ResolutionCalculatorNode()
|
|
||||||
|
|
||||||
# Test various scenarios
|
|
||||||
test_cases = [
|
|
||||||
(torch.randn(1, 512, 512, 3), 2.0),
|
|
||||||
(torch.randn(1, 1024, 1024, 3), 1.5),
|
|
||||||
(torch.randn(1, 1216, 832, 3), 1.53), # User scenario
|
|
||||||
]
|
|
||||||
|
|
||||||
for i, (image, scale) in enumerate(test_cases):
|
|
||||||
width, height = node.calculate_resolution(scale, image=image)
|
|
||||||
print(f'✓ Test case {i+1}: {image.shape[2]}×{image.shape[1]} → {width}×{height} (scale: {scale})')
|
|
||||||
assert width % 8 == 0 and height % 8 == 0
|
|
||||||
|
|
||||||
print('🎉 All pre-release tests passed!')
|
|
||||||
"
|
|
||||||
|
|
||||||
- name: Extract version from tag
|
- name: Extract version from tag
|
||||||
id: get_version
|
id: get_version
|
||||||
@@ -100,7 +73,7 @@ jobs:
|
|||||||
### 📊 Technical Details
|
### 📊 Technical Details
|
||||||
|
|
||||||
- **Nodes**: 1 (Resolution Calculator)
|
- **Nodes**: 1 (Resolution Calculator)
|
||||||
- **Test Coverage**: 100%
|
- **Python Coverage Gate**: 85% combined statement/branch coverage
|
||||||
- **Python Support**: 3.8+
|
- **Python Support**: 3.8+
|
||||||
- **ComfyUI Compatibility**: Latest
|
- **ComfyUI Compatibility**: Latest
|
||||||
|
|
||||||
@@ -114,7 +87,7 @@ jobs:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v3
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.get_version.outputs.version }}
|
tag_name: ${{ steps.get_version.outputs.version }}
|
||||||
name: ComfyUI-KikoTools ${{ steps.get_version.outputs.version }}
|
name: ComfyUI-KikoTools ${{ steps.get_version.outputs.version }}
|
||||||
@@ -147,4 +120,4 @@ jobs:
|
|||||||
echo "- Resolution Calculator tool"
|
echo "- Resolution Calculator tool"
|
||||||
echo "- Complete documentation"
|
echo "- Complete documentation"
|
||||||
echo "- Example workflows"
|
echo "- Example workflows"
|
||||||
echo "- 100% test coverage"
|
echo "- Enforced Python coverage and frontend regression checks"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
@@ -40,16 +40,25 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements-dev.txt aiohttp
|
pip install -r requirements-dev.txt
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: python -m pytest tests
|
run: python -m pytest tests --junitxml=test-results/pytest.xml
|
||||||
|
|
||||||
|
- name: Upload test results
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: python-${{ matrix.os }}-${{ matrix.python-version }}
|
||||||
|
path: test-results/
|
||||||
|
if-no-files-found: ignore
|
||||||
|
retention-days: 14
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
name: coverage gate (85%)
|
name: coverage gate (85%)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- uses: actions/setup-python@v6
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
@@ -61,21 +70,75 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install torch --index-url https://download.pytorch.org/whl/cpu
|
pip install torch --index-url https://download.pytorch.org/whl/cpu
|
||||||
pip install -r requirements-dev.txt aiohttp
|
pip install -r requirements-dev.txt
|
||||||
|
|
||||||
# fail_under = 85 lives in pyproject.toml [tool.coverage.report]
|
# fail_under = 85 lives in pyproject.toml [tool.coverage.report]
|
||||||
- name: Measure coverage
|
- name: Measure coverage
|
||||||
run: python -m pytest tests --cov=kikotools --cov-report=term-missing
|
run: python -m pytest tests --cov=kikotools --cov-report=term-missing --cov-report=html --cov-report=xml
|
||||||
|
|
||||||
|
- name: Upload coverage reports
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: python-coverage
|
||||||
|
path: |
|
||||||
|
htmlcov/
|
||||||
|
coverage.xml
|
||||||
|
if-no-files-found: ignore
|
||||||
|
retention-days: 14
|
||||||
|
|
||||||
js-check:
|
js-check:
|
||||||
name: frontend syntax
|
name: frontend syntax
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
# No JS unit tests yet; at least make sure every module parses
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: "24"
|
||||||
|
|
||||||
|
# Check every shipped module, including files without behavioral tests.
|
||||||
- name: Check web/*.js parse as ES modules
|
- name: Check web/*.js parse as ES modules
|
||||||
run: |
|
run: |
|
||||||
for f in web/*.js; do
|
for f in web/*.js; do
|
||||||
node --input-type=module --check < "$f" || { echo "Syntax error in $f"; exit 1; }
|
node --input-type=module --check < "$f" || { echo "Syntax error in $f"; exit 1; }
|
||||||
done
|
done
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
name: frontend workflows and coverage
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 15
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
- uses: actions/setup-python@v6
|
||||||
|
with:
|
||||||
|
python-version: "3.12"
|
||||||
|
cache: pip
|
||||||
|
cache-dependency-path: requirements-dev.txt
|
||||||
|
- name: Install Python test dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install torch --index-url https://download.pytorch.org/whl/cpu
|
||||||
|
pip install -r requirements-dev.txt
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: "24"
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: tools/testing/package-lock.json
|
||||||
|
- run: npm ci --prefix tools/testing --ignore-scripts
|
||||||
|
- run: npx --prefix tools/testing playwright install --with-deps chromium firefox webkit
|
||||||
|
- name: JavaScript regressions, Chromium workflows, and coverage gate
|
||||||
|
run: npm run --prefix tools/testing test:coverage
|
||||||
|
- name: Firefox and WebKit workflows
|
||||||
|
run: npm run --prefix tools/testing test:browser -- --project firefox --project webkit
|
||||||
|
- name: Upload frontend reports
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: frontend-test-reports
|
||||||
|
path: |
|
||||||
|
tools/testing/test-results/
|
||||||
|
coverage/js/
|
||||||
|
!coverage/js/raw/
|
||||||
|
if-no-files-found: ignore
|
||||||
|
retention-days: 14
|
||||||
|
|||||||
+11
@@ -164,3 +164,14 @@ experiments/
|
|||||||
# Gemini model cache
|
# Gemini model cache
|
||||||
.gemini_models_cache.json
|
.gemini_models_cache.json
|
||||||
referance/
|
referance/
|
||||||
|
|
||||||
|
# Runtime state written inside the package (repo is symlinked into custom_nodes)
|
||||||
|
kikotools/tools/local_image_loader/config.json
|
||||||
|
kikotools/tools/local_image_loader/selections.json
|
||||||
|
gemini_config.json
|
||||||
|
|
||||||
|
# Frontend test tooling and reports
|
||||||
|
node_modules/
|
||||||
|
coverage/
|
||||||
|
playwright-report/
|
||||||
|
test-results/
|
||||||
|
|||||||
+20
-3
@@ -4,10 +4,9 @@
|
|||||||
repos:
|
repos:
|
||||||
# Python code formatting with Black
|
# Python code formatting with Black
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 25.1.0
|
rev: 26.10.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
language_version: python3.10
|
|
||||||
args: ['--line-length=88'] # Match CI configuration
|
args: ['--line-length=88'] # Match CI configuration
|
||||||
|
|
||||||
# Python linting with flake8
|
# Python linting with flake8
|
||||||
@@ -61,9 +60,27 @@ repos:
|
|||||||
args: ['--baseline', '.secrets.baseline']
|
args: ['--baseline', '.secrets.baseline']
|
||||||
exclude: '^(tests/|\.git/)'
|
exclude: '^(tests/|\.git/)'
|
||||||
|
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: python-regressions
|
||||||
|
name: Python regression suite
|
||||||
|
entry: python -m pytest tests
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
|
stages: [pre-push]
|
||||||
|
- id: frontend-regressions
|
||||||
|
name: JavaScript regression suite
|
||||||
|
entry: npm test --prefix tools/testing
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
|
stages: [pre-push]
|
||||||
|
|
||||||
# Configuration for specific hooks
|
# Configuration for specific hooks
|
||||||
|
default_stages: [pre-commit]
|
||||||
default_language_version:
|
default_language_version:
|
||||||
python: python3.10
|
python: python3
|
||||||
|
|
||||||
# Run hooks on all files by default
|
# Run hooks on all files by default
|
||||||
fail_fast: false
|
fail_fast: false
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# Repository Guidelines
|
||||||
|
|
||||||
|
## Project Structure & Module Organization
|
||||||
|
|
||||||
|
`kikotools/tools/<tool>/logic.py` contains reusable logic; `node.py` defines the
|
||||||
|
ComfyUI node. Shared classes live in `kikotools/base/`. Register nodes in
|
||||||
|
`kikotools/__init__.py`; the root `__init__.py` exposes the plugin and API routes.
|
||||||
|
`web/` contains browser extensions. Tests live in `tests/unit/`, `tests/js/`, and
|
||||||
|
`tests/browser/`. Examples are in `examples/`.
|
||||||
|
|
||||||
|
## Development Commands
|
||||||
|
|
||||||
|
Install Python dependencies with `python -m pip install -r requirements-dev.txt`.
|
||||||
|
Run `python -m pytest tests` or `make test` for the complete Python suite.
|
||||||
|
Use `python -m pytest tests --cov=kikotools` for the 85% statement/branch gate.
|
||||||
|
Format with `black .`; use `flake8 .` for lint findings.
|
||||||
|
|
||||||
|
Frontend tooling needs Node.js 24 and `npm ci --prefix tools/testing
|
||||||
|
--ignore-scripts`. Run `npm test --prefix tools/testing` for JavaScript tests,
|
||||||
|
`npm run --prefix tools/testing test:coverage` for coverage and Chromium workflows,
|
||||||
|
and `npm run --prefix tools/testing test:browser` for all browser projects.
|
||||||
|
See `TESTING.md` for browser installation, environment overrides, and artifacts.
|
||||||
|
|
||||||
|
## Coding Style & Naming
|
||||||
|
|
||||||
|
Use four-space Python indentation and Black's 88-character formatting.
|
||||||
|
Use `snake_case` for Python functions/modules, `PascalCase` for classes, and
|
||||||
|
`UPPER_CASE` for constants. Keep node interfaces separate from logic. Preserve
|
||||||
|
existing ComfyUI lifecycle hooks when extending widgets and clean up timers,
|
||||||
|
listeners, and observers when nodes are removed.
|
||||||
|
|
||||||
|
## Testing Guidelines
|
||||||
|
|
||||||
|
Write regression tests first and verify failure before implementing fixes.
|
||||||
|
Name Python tests `test_*.py` and JavaScript tests `*.test.mjs`; put browser
|
||||||
|
workflows in `tests/browser/*.spec.mjs`. Test behavior and persistence, including
|
||||||
|
failure recovery. Keep fixtures disposable and external services mocked.
|
||||||
|
Never lower coverage floors to make a change pass.
|
||||||
|
|
||||||
|
## Commits & Pull Requests
|
||||||
|
|
||||||
|
Use Conventional Commits, such as `fix(local_image_loader): preserve error
|
||||||
|
status`. Link the tracked issue, describe observable behavior, and report the
|
||||||
|
commands and results used for validation. Include screenshots for visual changes.
|
||||||
|
Required checks must pass before merging. Keep credentials and runtime files out
|
||||||
|
of commits; restart ComfyUI after installing Python changes.
|
||||||
+4
-1
@@ -357,9 +357,12 @@ Brief description of changes.
|
|||||||
|
|
||||||
### Review Process
|
### Review Process
|
||||||
|
|
||||||
|
See [TESTING.md](TESTING.md) for automated suites, coverage gates, required merge
|
||||||
|
checks, and the remaining ComfyUI/GPU/service boundaries.
|
||||||
|
|
||||||
1. **Automated Checks**: CI runs tests and quality checks
|
1. **Automated Checks**: CI runs tests and quality checks
|
||||||
2. **Code Review**: Maintainer reviews code and provides feedback
|
2. **Code Review**: Maintainer reviews code and provides feedback
|
||||||
3. **Testing**: Manual testing in ComfyUI environment
|
3. **Testing**: Run relevant automated suites; use live ComfyUI checks for host, GPU, service, or visual changes
|
||||||
4. **Merge**: After approval, changes are merged to main
|
4. **Merge**: After approval, changes are merged to main
|
||||||
|
|
||||||
## 🎨 Code Style Guidelines
|
## 🎨 Code Style Guidelines
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# ComfyUI-KikoTools Development Makefile
|
# ComfyUI-KikoTools Development Makefile
|
||||||
|
|
||||||
.PHONY: help install test test-fast lint format type-check quality-check clean setup dev-test release-test
|
.PHONY: coverage frontend-test browser-test frontend-coverage help install test test-fast lint format type-check quality-check clean setup dev-test release-test
|
||||||
|
|
||||||
# Python and virtual environment setup
|
# Python and virtual environment setup
|
||||||
PYTHON := python3
|
PYTHON := python3
|
||||||
@@ -34,7 +34,11 @@ help:
|
|||||||
@echo " quality-check - Run all quality checks"
|
@echo " quality-check - Run all quality checks"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Testing:"
|
@echo "Testing:"
|
||||||
@echo " test - Run comprehensive tests"
|
@echo " test - Run the complete pytest suite"
|
||||||
|
@echo " coverage - Python statement/branch coverage (85% gate)"
|
||||||
|
@echo " frontend-test - JavaScript regression tests"
|
||||||
|
@echo " browser-test - Extension workflows in four browser configurations"
|
||||||
|
@echo " frontend-coverage - JavaScript tests, browser tests, and coverage gate"
|
||||||
@echo " test-fast - Run core functionality tests"
|
@echo " test-fast - Run core functionality tests"
|
||||||
@echo " dev-test - Quick development test"
|
@echo " dev-test - Quick development test"
|
||||||
@echo " release-test - Full release validation"
|
@echo " release-test - Full release validation"
|
||||||
@@ -120,13 +124,20 @@ test-fast: $(VENV_DIR)
|
|||||||
print('🎉 All core tests passed!'); \
|
print('🎉 All core tests passed!'); \
|
||||||
"
|
"
|
||||||
|
|
||||||
test: test-fast
|
test: $(VENV_DIR)
|
||||||
@echo "Running comprehensive test suite..."
|
@$(PYTHON_CMD) -m pytest tests
|
||||||
@echo "✅ Test case 1: 512×512 → 1024×1024 (scale: 2.0)"
|
|
||||||
@echo "✅ Test case 2: 1024×1024 → 1536×1536 (scale: 1.5)"
|
coverage: $(VENV_DIR)
|
||||||
@echo "✅ Test case 3: 832×1216 → 1272×1864 (scale: 1.53)"
|
@$(PYTHON_CMD) -m pytest tests --cov=kikotools --cov-report=term-missing --cov-report=html
|
||||||
@echo "✅ Error handling test passed"
|
|
||||||
@echo "🎉 All comprehensive tests passed!"
|
frontend-test:
|
||||||
|
npm test --prefix tools/testing
|
||||||
|
|
||||||
|
browser-test:
|
||||||
|
npm run --prefix tools/testing test:browser
|
||||||
|
|
||||||
|
frontend-coverage:
|
||||||
|
npm run --prefix tools/testing test:coverage
|
||||||
|
|
||||||
release-test: quality-check test
|
release-test: quality-check test
|
||||||
@echo "Running release validation..."
|
@echo "Running release validation..."
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ Advanced parameter management tools adapted from [comfyui-essentials-nodes](http
|
|||||||
|------|-------------|----------|
|
|------|-------------|----------|
|
||||||
| [🎛️ Flux Sampler Params](#️-flux-sampler-params) | FLUX-optimized parameter generator with batch support | 🧰 xyz-helpers |
|
| [🎛️ Flux Sampler Params](#️-flux-sampler-params) | FLUX-optimized parameter generator with batch support | 🧰 xyz-helpers |
|
||||||
| [📁 LoRA Folder Batch](#-lora-folder-batch) | Batch process multiple LoRAs from folders | 🧰 xyz-helpers |
|
| [📁 LoRA Folder Batch](#-lora-folder-batch) | Batch process multiple LoRAs from folders | 🧰 xyz-helpers |
|
||||||
|
| [🔁 Checkpoint Folder Iterator](#-checkpoint-folder-iterator) | Load one checkpoint per queued run from a folder | 🧰 xyz-helpers |
|
||||||
|
| [🧩 Model Compare Sheet](#-model-compare-sheet) | Save each run's image and rebuild a labeled contact sheet | 🧰 xyz-helpers |
|
||||||
| [📊 Plot Parameters](#-plot-parameters) | Visualize parameter effects with graphs | 🧰 xyz-helpers |
|
| [📊 Plot Parameters](#-plot-parameters) | Visualize parameter effects with graphs | 🧰 xyz-helpers |
|
||||||
| [🎯 Sampler Select Helper](#-sampler-select-helper) | Intelligent sampler selection with recommendations | 🧰 xyz-helpers |
|
| [🎯 Sampler Select Helper](#-sampler-select-helper) | Intelligent sampler selection with recommendations | 🧰 xyz-helpers |
|
||||||
| [📅 Scheduler Select Helper](#-scheduler-select-helper) | Optimal scheduler selection for samplers | 🧰 xyz-helpers |
|
| [📅 Scheduler Select Helper](#-scheduler-select-helper) | Optimal scheduler selection for samplers | 🧰 xyz-helpers |
|
||||||
@@ -301,6 +303,28 @@ Automated batch processing for multiple LoRA models from folders.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
#### 🔁 Checkpoint Folder Iterator
|
||||||
|
Run the same prompt through every checkpoint in a folder, one model per queued run.
|
||||||
|
|
||||||
|
- **folder**: relative to `models/checkpoints`, or an absolute path anywhere on disk; regex include/exclude filters
|
||||||
|
- **index** with `control_after_generate`: set 0 + *increment*, then queue a batch count equal to the checkpoint count
|
||||||
|
- Queuing past the last checkpoint fails that run with a clear message instead of wrapping around, so the finished sweep is never restarted or archived by accident
|
||||||
|
- Outputs MODEL/CLIP/VAE for the indexed file plus `ckpt_name`, `label`, `index`, `count`
|
||||||
|
- Only one checkpoint is loaded at a time, so large folders do not exhaust RAM
|
||||||
|
|
||||||
|
#### 🧩 Model Compare Sheet
|
||||||
|
Output node that pairs with Checkpoint Folder Iterator.
|
||||||
|
|
||||||
|
- Saves each run's image(s) to `output/model_compare/<run_name>/<NN>_<label>.png`
|
||||||
|
- Rebuilds `grid.png` from every tile saved so far, each labeled with its filename
|
||||||
|
- `columns`, `tile_width`, `font_size` control the layout; the grid is also returned as IMAGE
|
||||||
|
- The node preview (and anything else that reads it) gets `grid_preview.png`, at most 1024 px wide; `grid.png` keeps full resolution
|
||||||
|
- After the last queued run the preview shows the complete sheet
|
||||||
|
- Wire Project File Path into `run_name` for `project/date/sweep` folders
|
||||||
|
- A run at index 0 moves tiles already in the folder to `<run_name>_<timestamp>`, so an interrupted sweep never leaks into the new grid
|
||||||
|
- Rerunning a nonzero index replaces its complete batch, even when the label or batch size changes; other indexes are preserved
|
||||||
|
- Replacement PNGs are fully written before existing tiles are changed; a failed tile write preserves the prior tiles and grid
|
||||||
|
|
||||||
#### 📊 Plot Parameters
|
#### 📊 Plot Parameters
|
||||||
Visual analysis tool for understanding parameter relationships and effects.
|
Visual analysis tool for understanding parameter relationships and effects.
|
||||||
|
|
||||||
@@ -539,7 +563,7 @@ Time: 150.0ms
|
|||||||
### 🔧 Architecture Highlights
|
### 🔧 Architecture Highlights
|
||||||
|
|
||||||
- **Modular Design**: Each tool is self-contained and independently testable
|
- **Modular Design**: Each tool is self-contained and independently testable
|
||||||
- **Test-Driven Development**: 100% test coverage with comprehensive unit tests
|
- **Test-Driven Development**: Regression tests for Python logic, JavaScript extensions, and browser workflows
|
||||||
- **Clean Interfaces**: Standardized input/output patterns across all tools
|
- **Clean Interfaces**: Standardized input/output patterns across all tools
|
||||||
- **Separation of Concerns**: Clear distinction between logic, UI, and integration layers
|
- **Separation of Concerns**: Clear distinction between logic, UI, and integration layers
|
||||||
- **SOLID Principles**: Extensible architecture following software engineering best practices
|
- **SOLID Principles**: Extensible architecture following software engineering best practices
|
||||||
@@ -1003,8 +1027,8 @@ Following **Test-Driven Development (TDD)**:
|
|||||||
# Test structure
|
# Test structure
|
||||||
tests/
|
tests/
|
||||||
├── unit/ # Individual component tests
|
├── unit/ # Individual component tests
|
||||||
├── integration/ # ComfyUI workflow tests
|
├── js/ # Extension and coverage-gate regression tests
|
||||||
└── fixtures/ # Test data and workflows
|
└── browser/ # Browser workflows and disposable host fixtures
|
||||||
```
|
```
|
||||||
|
|
||||||
### Adding New Tools
|
### Adding New Tools
|
||||||
@@ -1064,10 +1088,10 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|||||||
- **Presets**: 26 curated resolution presets
|
- **Presets**: 26 curated resolution presets
|
||||||
- **Interactive Features**: 8+ (swap buttons, history UI, popup viewers, parameter visualization)
|
- **Interactive Features**: 8+ (swap buttons, history UI, popup viewers, parameter visualization)
|
||||||
- **AI Integration**: Gemini API with 40+ model support
|
- **AI Integration**: Gemini API with 40+ model support
|
||||||
- **Test Coverage**: 100% (470+ comprehensive tests)
|
- **Test Coverage**: Enforced 85% Python statement/branch coverage and per-file frontend coverage floors
|
||||||
- **Python Version**: 3.8+
|
- **Python Version**: 3.8+
|
||||||
- **ComfyUI Compatibility**: Latest
|
- **ComfyUI Compatibility**: Latest
|
||||||
- **Dependencies**: Minimal (PyTorch, NumPy, Pillow, google-generativeai for Gemini)
|
- **Dependencies**: Minimal (PyTorch, NumPy, Pillow, google-genai for Gemini)
|
||||||
|
|
||||||
## 🙏 Attribution
|
## 🙏 Attribution
|
||||||
|
|
||||||
@@ -1093,3 +1117,8 @@ All adaptations maintain compatibility while adding new features and optimizatio
|
|||||||
[⭐ Star this repo](https://github.com/ComfyAssets/ComfyUI-KikoTools) • [🐛 Report Bug](https://github.com/ComfyAssets/ComfyUI-KikoTools/issues) • [💡 Request Feature](https://github.com/ComfyAssets/ComfyUI-KikoTools/issues)
|
[⭐ Star this repo](https://github.com/ComfyAssets/ComfyUI-KikoTools) • [🐛 Report Bug](https://github.com/ComfyAssets/ComfyUI-KikoTools/issues) • [💡 Request Feature](https://github.com/ComfyAssets/ComfyUI-KikoTools/issues)
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
## Automated testing
|
||||||
|
|
||||||
|
See [TESTING.md](TESTING.md) for Python and JavaScript tests, cross-browser
|
||||||
|
workflows, coverage gates, CI reports, and required merge checks.
|
||||||
|
|||||||
+92
@@ -0,0 +1,92 @@
|
|||||||
|
# Testing and merge confidence
|
||||||
|
|
||||||
|
Use regression tests before fixing a bug. Confirm that the test fails on the
|
||||||
|
original implementation, then run the relevant suites after the fix.
|
||||||
|
|
||||||
|
## What runs
|
||||||
|
|
||||||
|
| Layer | Real components | Replaced boundaries |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Python | Tool logic, tensors, image files, API validation | ComfyUI services and external models where needed |
|
||||||
|
| JavaScript | Production extension hooks and callback behavior | Minimal host objects; controlled timers for focused regressions |
|
||||||
|
| Browser | All shipped extension imports and lifecycle registration; real plugin startup, HTTP routes, PNG thumbnails, selection persistence, and image loading | ComfyUI graph/widgets/settings/event interfaces and its saved-image serving endpoint |
|
||||||
|
|
||||||
|
Browser workflows cover swaps, local image browsing/selection, pagination,
|
||||||
|
sorting, hidden folders, directory autocomplete, saved paths,
|
||||||
|
denied paths and network recovery, display output, seed persistence/cleanup, and
|
||||||
|
workflow timing, autocomplete insertion, and saved-image previews. They run in Chromium, Firefox, WebKit, and touch Chromium.
|
||||||
|
The harness binds to localhost and writes configuration, selections, and fixture
|
||||||
|
images only inside a temporary directory. External browser requests fail tests;
|
||||||
|
custom-word downloads are disabled in the fixture. No credentials, model
|
||||||
|
weights, running ComfyUI, or GPU are required.
|
||||||
|
|
||||||
|
## Run locally
|
||||||
|
|
||||||
|
Use Python 3.10–3.13 and Node.js 24. Install the CPU PyTorch wheel on Linux if you
|
||||||
|
do not need CUDA, then install the development dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
|
||||||
|
python -m pip install -r requirements-dev.txt
|
||||||
|
python -m pytest tests
|
||||||
|
python -m pytest tests --cov=kikotools --cov-report=term-missing
|
||||||
|
npm ci --prefix tools/testing --ignore-scripts
|
||||||
|
npx --prefix tools/testing playwright install --with-deps chromium firefox webkit
|
||||||
|
npm test --prefix tools/testing
|
||||||
|
npm run --prefix tools/testing test:coverage
|
||||||
|
npm run --prefix tools/testing test:browser -- --project firefox --project webkit
|
||||||
|
```
|
||||||
|
|
||||||
|
`make test` runs the full pytest suite and propagates failures. `make coverage`,
|
||||||
|
`make frontend-test`, `make browser-test`, and `make frontend-coverage` provide
|
||||||
|
shortcuts. The Python Make targets use the existing virtual-environment setup.
|
||||||
|
Install local commit and push hooks with `pre-commit install --hook-type
|
||||||
|
pre-commit --hook-type pre-push`. The push hooks run Python and JavaScript
|
||||||
|
regressions; CI additionally runs all browser workflows and coverage gates.
|
||||||
|
For a quick browser check, use `test:browser -- --project chromium`.
|
||||||
|
`KIKO_TEST_PYTHON` selects a Python executable with the development dependencies;
|
||||||
|
`KIKO_TEST_PORT` changes the default port 8766. Servers are never reused.
|
||||||
|
Unsupported Linux distributions may lack WebKit libraries; Ubuntu CI validates
|
||||||
|
all engines.
|
||||||
|
|
||||||
|
## Coverage and diagnosis
|
||||||
|
|
||||||
|
Python CI checks all twelve Python/OS combinations and enforces 85% combined
|
||||||
|
statement/branch coverage. Every production `web/*.js` file appears in frontend
|
||||||
|
coverage, including code without behavioral coverage. V8 unit coverage and
|
||||||
|
Chromium desktop/touch coverage are merged through c8. The committed per-file
|
||||||
|
floors are an honest starting point, not a claim that every feature is tested.
|
||||||
|
|
||||||
|
`npm run --prefix tools/testing coverage:update` reruns the suites and raises
|
||||||
|
floors with two percentage points of runtime allowance. It cannot lower existing
|
||||||
|
floors; new source files require 80% line coverage when added with this command.
|
||||||
|
Missing measurements, missing baselines, and per-file regressions fail CI.
|
||||||
|
|
||||||
|
CI artifacts include Python JUnit results, Python HTML/XML coverage, and
|
||||||
|
`frontend-test-reports` with frontend HTML coverage and browser failure traces
|
||||||
|
and screenshots. Open traces using Playwright's `show-trace` command. Local
|
||||||
|
frontend coverage is at `coverage/js/index.html`.
|
||||||
|
|
||||||
|
Real ComfyUI/LiteGraph compatibility, GPU execution, cloud inference, network
|
||||||
|
model downloads, and visual design still need targeted live checks when changed.
|
||||||
|
The browser host is a test double; these workflows do not run the real ComfyUI
|
||||||
|
frontend or certify every node's UI. Type checking and security jobs retain their
|
||||||
|
existing advisory behavior.
|
||||||
|
|
||||||
|
## Required merge checks
|
||||||
|
|
||||||
|
The manifest in `.github/branch-protection.json` requires all Python matrix jobs,
|
||||||
|
Python coverage, frontend syntax, frontend workflows/coverage, and the existing
|
||||||
|
`code-quality` job (including Black and fatal lint checks). Administrators follow
|
||||||
|
the same checks and branches must be current with main. No extra human approval
|
||||||
|
is required. Workflows run on every pull request without path filters.
|
||||||
|
|
||||||
|
After the checks pass, an administrator applies and verifies the manifest:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
gh api --method PUT repos/ComfyAssets/ComfyUI-KikoTools/branches/main/protection \
|
||||||
|
--input .github/branch-protection.json
|
||||||
|
gh api repos/ComfyAssets/ComfyUI-KikoTools/branches/main/protection/required_status_checks
|
||||||
|
```
|
||||||
|
|
||||||
|
Keep the manifest synchronized with job names when changing CI.
|
||||||
@@ -21,7 +21,7 @@ Get your free Gemini API key from [Google AI Studio](https://makersuite.google.c
|
|||||||
### 2. Install Dependencies
|
### 2. Install Dependencies
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install google-generativeai
|
pip install google-genai
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Configure API Key
|
### 3. Configure API Key
|
||||||
@@ -204,6 +204,6 @@ Errors are displayed in the prompt output for easy debugging.
|
|||||||
- Verify API key is valid
|
- Verify API key is valid
|
||||||
- Image might be too large (resize if needed)
|
- Image might be too large (resize if needed)
|
||||||
|
|
||||||
**Import error for google-generativeai**:
|
**Import error for google-genai**:
|
||||||
- Run `pip install google-generativeai` in your ComfyUI environment
|
- Run `pip install google-genai` in your ComfyUI environment
|
||||||
- Restart ComfyUI after installation
|
- Restart ComfyUI after installation
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from .tools.batch_list_converter import (
|
|||||||
LatentListToLatentBatchNode,
|
LatentListToLatentBatchNode,
|
||||||
)
|
)
|
||||||
from .tools.batch_prompts import BatchPromptsNode
|
from .tools.batch_prompts import BatchPromptsNode
|
||||||
|
from .tools.checkpoint_folder_iterator import CheckpointFolderIteratorNode
|
||||||
from .tools.display_any import DisplayAnyNode
|
from .tools.display_any import DisplayAnyNode
|
||||||
from .tools.display_text import DisplayTextNode
|
from .tools.display_text import DisplayTextNode
|
||||||
from .tools.embedding_autocomplete import KikoEmbeddingAutocomplete
|
from .tools.embedding_autocomplete import KikoEmbeddingAutocomplete
|
||||||
@@ -23,6 +24,7 @@ from .tools.kiko_workflow_timer import KikoWorkflowTimerNode
|
|||||||
from .tools.kiko_save_image import KikoSaveImageNode
|
from .tools.kiko_save_image import KikoSaveImageNode
|
||||||
from .tools.local_image_loader import LocalImageLoaderNode
|
from .tools.local_image_loader import LocalImageLoaderNode
|
||||||
from .tools.project_file_path import ProjectFilePathNode
|
from .tools.project_file_path import ProjectFilePathNode
|
||||||
|
from .tools.model_compare_sheet import ModelCompareSheetNode
|
||||||
from .tools.model_downloader import ModelDownloaderNode
|
from .tools.model_downloader import ModelDownloaderNode
|
||||||
from .tools.resolution_calculator import ResolutionCalculatorNode
|
from .tools.resolution_calculator import ResolutionCalculatorNode
|
||||||
from .tools.sampler_combo import SamplerComboCompactNode, SamplerComboNode
|
from .tools.sampler_combo import SamplerComboCompactNode, SamplerComboNode
|
||||||
@@ -69,6 +71,8 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
"FluxSamplerParams": FluxSamplerParamsNode,
|
"FluxSamplerParams": FluxSamplerParamsNode,
|
||||||
"PlotParameters+": PlotParametersNode,
|
"PlotParameters+": PlotParametersNode,
|
||||||
"LoRAFolderBatch": LoRAFolderBatchNode,
|
"LoRAFolderBatch": LoRAFolderBatchNode,
|
||||||
|
"CheckpointFolderIterator": CheckpointFolderIteratorNode,
|
||||||
|
"ModelCompareSheet": ModelCompareSheetNode,
|
||||||
"WidthHeightToVec2": WidthHeightToVec2Node,
|
"WidthHeightToVec2": WidthHeightToVec2Node,
|
||||||
"KikoWorkflowTimer": KikoWorkflowTimerNode,
|
"KikoWorkflowTimer": KikoWorkflowTimerNode,
|
||||||
"KikoProjectFilePath": ProjectFilePathNode,
|
"KikoProjectFilePath": ProjectFilePathNode,
|
||||||
@@ -105,6 +109,8 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
|||||||
"FluxSamplerParams": "Flux Sampler Parameters",
|
"FluxSamplerParams": "Flux Sampler Parameters",
|
||||||
"PlotParameters+": "Plot Parameters",
|
"PlotParameters+": "Plot Parameters",
|
||||||
"LoRAFolderBatch": "LoRA Folder Batch",
|
"LoRAFolderBatch": "LoRA Folder Batch",
|
||||||
|
"CheckpointFolderIterator": "Checkpoint Folder Iterator",
|
||||||
|
"ModelCompareSheet": "Model Compare Sheet",
|
||||||
"WidthHeightToVec2": "Width Height to VEC2",
|
"WidthHeightToVec2": "Width Height to VEC2",
|
||||||
"KikoWorkflowTimer": "Workflow Timer",
|
"KikoWorkflowTimer": "Workflow Timer",
|
||||||
"KikoProjectFilePath": "Project File Path",
|
"KikoProjectFilePath": "Project File Path",
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
"""Scan ComfyUI model folders (loras, checkpoints, ...) for .safetensors files."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
from typing import Dict, List, Optional, Tuple
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def get_model_roots(folder_key: str) -> List[str]:
|
||||||
|
"""Return every configured root directory for a folder_paths key."""
|
||||||
|
try:
|
||||||
|
import folder_paths
|
||||||
|
|
||||||
|
entry = folder_paths.folder_names_and_paths.get(folder_key)
|
||||||
|
return list(entry[0]) if entry else []
|
||||||
|
except (ImportError, AttributeError, IndexError, TypeError):
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def is_within(path: str, root: str) -> bool:
|
||||||
|
"""True if realpath `path` equals or is inside realpath `root`."""
|
||||||
|
try:
|
||||||
|
real_path, real_root = os.path.realpath(path), os.path.realpath(root)
|
||||||
|
return os.path.commonpath([real_path, real_root]) == real_root
|
||||||
|
except ValueError: # different drives or mixed absolute/relative
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_scan_targets(
|
||||||
|
folder_path: str, folder_key: str
|
||||||
|
) -> List[Tuple[str, Optional[str]]]:
|
||||||
|
"""
|
||||||
|
Resolve a folder setting to (directory, base_root) pairs to scan.
|
||||||
|
|
||||||
|
base_root is the model root the directory lives in, or None when the
|
||||||
|
directory is an absolute path outside every known root.
|
||||||
|
"""
|
||||||
|
roots = get_model_roots(folder_key)
|
||||||
|
|
||||||
|
if os.path.isabs(folder_path):
|
||||||
|
base = next((r for r in roots if is_within(folder_path, r)), None)
|
||||||
|
return [(folder_path, base)]
|
||||||
|
|
||||||
|
targets = []
|
||||||
|
for root in roots:
|
||||||
|
candidate = os.path.join(root, folder_path)
|
||||||
|
if not is_within(candidate, root):
|
||||||
|
logger.warning(f"Folder escapes the {folder_key} directory: {folder_path}")
|
||||||
|
continue
|
||||||
|
targets.append((candidate, root))
|
||||||
|
return targets
|
||||||
|
|
||||||
|
|
||||||
|
def scan_model_entries(folder_path: str, folder_key: str) -> List[Tuple[str, str]]:
|
||||||
|
"""Return naturally sorted (relative_name, absolute_path) for every .safetensors."""
|
||||||
|
entries: Dict[str, str] = {}
|
||||||
|
for directory, base in resolve_scan_targets(folder_path, folder_key):
|
||||||
|
if not os.path.isdir(directory):
|
||||||
|
continue
|
||||||
|
for root, _, files in os.walk(directory):
|
||||||
|
for file in files:
|
||||||
|
if not file.endswith(".safetensors"):
|
||||||
|
continue
|
||||||
|
full = os.path.join(root, file)
|
||||||
|
try:
|
||||||
|
rel = os.path.relpath(full, base or directory)
|
||||||
|
except ValueError:
|
||||||
|
rel = os.path.relpath(full, directory)
|
||||||
|
entries.setdefault(rel.replace("\\", "/"), full)
|
||||||
|
return [(name, entries[name]) for name in natural_sort(list(entries))]
|
||||||
|
|
||||||
|
|
||||||
|
def natural_sort(items: List[str]) -> List[str]:
|
||||||
|
"""Sort strings so embedded numbers compare numerically (v2 < v10)."""
|
||||||
|
|
||||||
|
def natural_key(text):
|
||||||
|
parts = []
|
||||||
|
for part in re.split(r"(\d+)", text):
|
||||||
|
if not part:
|
||||||
|
continue
|
||||||
|
parts.append((0, int(part)) if part.isdigit() else (1, part.lower()))
|
||||||
|
return parts
|
||||||
|
|
||||||
|
return sorted(items, key=natural_key)
|
||||||
|
|
||||||
|
|
||||||
|
def filter_by_pattern(
|
||||||
|
names: List[str], include_pattern: str = "", exclude_pattern: str = ""
|
||||||
|
) -> List[str]:
|
||||||
|
"""Keep names matching include_pattern (if set) and not exclude_pattern (if set)."""
|
||||||
|
filtered = list(names)
|
||||||
|
if include_pattern:
|
||||||
|
try:
|
||||||
|
include_re = re.compile(include_pattern)
|
||||||
|
filtered = [f for f in filtered if include_re.search(f)]
|
||||||
|
except re.error as e:
|
||||||
|
logger.error(f"Invalid include pattern: {e}")
|
||||||
|
if exclude_pattern:
|
||||||
|
try:
|
||||||
|
exclude_re = re.compile(exclude_pattern)
|
||||||
|
filtered = [f for f in filtered if not exclude_re.search(f)]
|
||||||
|
except re.error as e:
|
||||||
|
logger.error(f"Invalid exclude pattern: {e}")
|
||||||
|
return filtered
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
"""Checkpoint Folder Iterator module."""
|
||||||
|
|
||||||
|
from .node import CheckpointFolderIteratorNode
|
||||||
|
|
||||||
|
__all__ = ["CheckpointFolderIteratorNode"]
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
"""Logic for the Checkpoint Folder Iterator node."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from typing import List, Sequence, Tuple, TypeVar
|
||||||
|
|
||||||
|
from ...base.model_folders import filter_by_pattern, scan_model_entries
|
||||||
|
|
||||||
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
|
||||||
|
def list_checkpoint_entries(
|
||||||
|
folder_path: str, include_pattern: str = "", exclude_pattern: str = ""
|
||||||
|
) -> List[Tuple[str, str]]:
|
||||||
|
"""(name, absolute_path) pairs for every checkpoint, filtered, in natural order.
|
||||||
|
|
||||||
|
The absolute path is what gets loaded, so folders outside the configured
|
||||||
|
checkpoints roots work too; the name is relative to the root (or to the
|
||||||
|
folder itself when it lives outside every root) and is used for labels.
|
||||||
|
"""
|
||||||
|
entries = scan_model_entries(folder_path, "checkpoints")
|
||||||
|
names = [name for name, _ in entries]
|
||||||
|
kept = set(filter_by_pattern(names, include_pattern, exclude_pattern))
|
||||||
|
return [(name, path) for name, path in entries if name in kept]
|
||||||
|
|
||||||
|
|
||||||
|
def list_checkpoints(
|
||||||
|
folder_path: str, include_pattern: str = "", exclude_pattern: str = ""
|
||||||
|
) -> List[str]:
|
||||||
|
"""Checkpoint names (relative to the checkpoints roots) in natural order."""
|
||||||
|
entries = list_checkpoint_entries(folder_path, include_pattern, exclude_pattern)
|
||||||
|
return [name for name, _ in entries]
|
||||||
|
|
||||||
|
|
||||||
|
def pick_checkpoint(items: Sequence[T], index: int) -> T:
|
||||||
|
"""Return items[index], or raise when the sweep has run past the end.
|
||||||
|
|
||||||
|
Wrapping would silently restart the sweep (and, downstream, archive the
|
||||||
|
grid that just finished), so an over-queued run fails loudly instead.
|
||||||
|
"""
|
||||||
|
if not items:
|
||||||
|
raise ValueError("No checkpoints found")
|
||||||
|
if not 0 <= index < len(items):
|
||||||
|
raise ValueError(
|
||||||
|
f"Index {index} is past the end: only {len(items)} checkpoints matched. "
|
||||||
|
"The sweep is complete; reset index to 0 to start a new one."
|
||||||
|
)
|
||||||
|
return items[index]
|
||||||
|
|
||||||
|
|
||||||
|
def label_for(ckpt_name: str) -> str:
|
||||||
|
"""Label drawn under a tile for this checkpoint. Default: the file stem."""
|
||||||
|
return os.path.splitext(os.path.basename(ckpt_name))[0]
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
"""Checkpoint Folder Iterator node for ComfyUI."""
|
||||||
|
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
|
from ...base.base_node import ComfyAssetsBaseNode
|
||||||
|
from .logic import label_for, list_checkpoint_entries, pick_checkpoint
|
||||||
|
|
||||||
|
|
||||||
|
class CheckpointFolderIteratorNode(ComfyAssetsBaseNode):
|
||||||
|
"""
|
||||||
|
Load one checkpoint from a folder per queued run.
|
||||||
|
|
||||||
|
Set index to 0 with "increment" and queue as many runs as there are
|
||||||
|
checkpoints: each run loads the next file, so only one model is in
|
||||||
|
memory at a time. A run past the last checkpoint fails with a clear
|
||||||
|
error rather than wrapping around, so over-queuing never restarts the
|
||||||
|
sweep. Pairs with Model Compare Sheet to build a labeled grid.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(cls):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"folder": (
|
||||||
|
"STRING",
|
||||||
|
{
|
||||||
|
"default": ".",
|
||||||
|
"multiline": False,
|
||||||
|
"tooltip": "Folder relative to models/checkpoints (or absolute)",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"index": (
|
||||||
|
"INT",
|
||||||
|
{
|
||||||
|
"default": 0,
|
||||||
|
"min": 0,
|
||||||
|
"max": 9999,
|
||||||
|
"control_after_generate": True,
|
||||||
|
"tooltip": "Which checkpoint to load; errors past the end",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"optional": {
|
||||||
|
"include_pattern": (
|
||||||
|
"STRING",
|
||||||
|
{"default": "", "tooltip": "Regex to include (empty = all)"},
|
||||||
|
),
|
||||||
|
"exclude_pattern": (
|
||||||
|
"STRING",
|
||||||
|
{"default": "", "tooltip": "Regex to exclude (empty = none)"},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TYPES = ("MODEL", "CLIP", "VAE", "STRING", "STRING", "INT", "INT")
|
||||||
|
RETURN_NAMES = ("model", "clip", "vae", "ckpt_name", "label", "index", "count")
|
||||||
|
FUNCTION = "load"
|
||||||
|
CATEGORY = "🫶 ComfyAssets/🧰 xyz-helpers"
|
||||||
|
|
||||||
|
def load(
|
||||||
|
self,
|
||||||
|
folder: str,
|
||||||
|
index: int,
|
||||||
|
include_pattern: str = "",
|
||||||
|
exclude_pattern: str = "",
|
||||||
|
) -> Tuple[object, object, object, str, str, int, int]:
|
||||||
|
import folder_paths
|
||||||
|
import comfy.sd
|
||||||
|
|
||||||
|
entries = list_checkpoint_entries(folder, include_pattern, exclude_pattern)
|
||||||
|
ckpt_name, ckpt_path = pick_checkpoint(entries, index)
|
||||||
|
self.log_info(f"Loading {index + 1}/{len(entries)}: {ckpt_name}")
|
||||||
|
|
||||||
|
model, clip, vae = comfy.sd.load_checkpoint_guess_config(
|
||||||
|
ckpt_path,
|
||||||
|
output_vae=True,
|
||||||
|
output_clip=True,
|
||||||
|
embedding_directory=folder_paths.get_folder_paths("embeddings"),
|
||||||
|
)[:3]
|
||||||
|
return model, clip, vae, ckpt_name, label_for(ckpt_name), index, len(entries)
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
{
|
|
||||||
"models": [
|
|
||||||
"gemini-2.5-pro",
|
|
||||||
"gemini-2.5-flash",
|
|
||||||
"gemini-2.5-flash-lite",
|
|
||||||
"gemini-2.5-pro-preview-03-25",
|
|
||||||
"gemini-2.5-flash-preview-05-20",
|
|
||||||
"gemini-2.5-pro-preview-05-06",
|
|
||||||
"gemini-2.5-pro-preview-06-05",
|
|
||||||
"gemini-2.5-flash-lite-preview-06-17",
|
|
||||||
"gemini-2.0-flash",
|
|
||||||
"gemini-2.0-flash-001",
|
|
||||||
"gemini-2.0-flash-lite-001",
|
|
||||||
"gemini-2.0-flash-lite",
|
|
||||||
"gemini-2.5-flash-preview-tts",
|
|
||||||
"gemini-2.5-pro-preview-tts",
|
|
||||||
"gemini-2.0-flash-preview-image-generation",
|
|
||||||
"gemini-2.0-flash-exp",
|
|
||||||
"gemini-2.0-flash-exp-image-generation",
|
|
||||||
"gemini-2.0-flash-lite-preview-02-05",
|
|
||||||
"gemini-2.0-flash-lite-preview",
|
|
||||||
"gemini-2.0-pro-exp",
|
|
||||||
"gemini-2.0-pro-exp-02-05",
|
|
||||||
"learnlm-2.0-flash-experimental",
|
|
||||||
"gemini-1.5-pro-latest",
|
|
||||||
"gemini-1.5-pro-002",
|
|
||||||
"gemini-1.5-pro",
|
|
||||||
"gemini-1.5-flash-latest",
|
|
||||||
"gemini-1.5-flash",
|
|
||||||
"gemini-1.5-flash-002",
|
|
||||||
"gemini-1.5-flash-8b",
|
|
||||||
"gemini-1.5-flash-8b-001",
|
|
||||||
"gemini-1.5-flash-8b-latest",
|
|
||||||
"gemini-2.0-flash-thinking-exp-01-21",
|
|
||||||
"gemini-2.0-flash-thinking-exp",
|
|
||||||
"gemini-2.0-flash-thinking-exp-1219",
|
|
||||||
"gemma-3-1b-it",
|
|
||||||
"gemma-3-4b-it",
|
|
||||||
"gemma-3-12b-it",
|
|
||||||
"gemma-3-27b-it",
|
|
||||||
"gemma-3n-e4b-it",
|
|
||||||
"gemma-3n-e2b-it",
|
|
||||||
"gemini-exp-1206"
|
|
||||||
],
|
|
||||||
"descriptions": {
|
|
||||||
"gemini-1.5-pro-latest": "Gemini 1.5 Pro Latest",
|
|
||||||
"gemini-1.5-pro-002": "Gemini 1.5 Pro 002",
|
|
||||||
"gemini-1.5-pro": "Gemini 1.5 Pro",
|
|
||||||
"gemini-1.5-flash-latest": "Gemini 1.5 Flash Latest",
|
|
||||||
"gemini-1.5-flash": "Gemini 1.5 Flash",
|
|
||||||
"gemini-1.5-flash-002": "Gemini 1.5 Flash 002",
|
|
||||||
"gemini-1.5-flash-8b": "Gemini 1.5 Flash-8B",
|
|
||||||
"gemini-1.5-flash-8b-001": "Gemini 1.5 Flash-8B 001",
|
|
||||||
"gemini-1.5-flash-8b-latest": "Gemini 1.5 Flash-8B Latest",
|
|
||||||
"gemini-2.5-pro-preview-03-25": "Gemini 2.5 Pro Preview 03-25",
|
|
||||||
"gemini-2.5-flash-preview-05-20": "Gemini 2.5 Flash Preview 05-20",
|
|
||||||
"gemini-2.5-flash": "Gemini 2.5 Flash",
|
|
||||||
"gemini-2.5-flash-lite-preview-06-17": "Gemini 2.5 Flash-Lite Preview 06-17",
|
|
||||||
"gemini-2.5-pro-preview-05-06": "Gemini 2.5 Pro Preview 05-06",
|
|
||||||
"gemini-2.5-pro-preview-06-05": "Gemini 2.5 Pro Preview",
|
|
||||||
"gemini-2.5-pro": "Gemini 2.5 Pro",
|
|
||||||
"gemini-2.0-flash-exp": "Gemini 2.0 Flash Experimental",
|
|
||||||
"gemini-2.0-flash": "Gemini 2.0 Flash",
|
|
||||||
"gemini-2.0-flash-001": "Gemini 2.0 Flash 001",
|
|
||||||
"gemini-2.0-flash-exp-image-generation": "Gemini 2.0 Flash (Image Generation) Experimental",
|
|
||||||
"gemini-2.0-flash-lite-001": "Gemini 2.0 Flash-Lite 001",
|
|
||||||
"gemini-2.0-flash-lite": "Gemini 2.0 Flash-Lite",
|
|
||||||
"gemini-2.0-flash-preview-image-generation": "Gemini 2.0 Flash Preview Image Generation",
|
|
||||||
"gemini-2.0-flash-lite-preview-02-05": "Gemini 2.0 Flash-Lite Preview 02-05",
|
|
||||||
"gemini-2.0-flash-lite-preview": "Gemini 2.0 Flash-Lite Preview",
|
|
||||||
"gemini-2.0-pro-exp": "Gemini 2.0 Pro Experimental",
|
|
||||||
"gemini-2.0-pro-exp-02-05": "Gemini 2.0 Pro Experimental 02-05",
|
|
||||||
"gemini-exp-1206": "Gemini Experimental 1206",
|
|
||||||
"gemini-2.0-flash-thinking-exp-01-21": "Gemini 2.5 Flash Preview 05-20",
|
|
||||||
"gemini-2.0-flash-thinking-exp": "Gemini 2.5 Flash Preview 05-20",
|
|
||||||
"gemini-2.0-flash-thinking-exp-1219": "Gemini 2.5 Flash Preview 05-20",
|
|
||||||
"gemini-2.5-flash-preview-tts": "Gemini 2.5 Flash Preview TTS",
|
|
||||||
"gemini-2.5-pro-preview-tts": "Gemini 2.5 Pro Preview TTS",
|
|
||||||
"learnlm-2.0-flash-experimental": "LearnLM 2.0 Flash Experimental",
|
|
||||||
"gemma-3-1b-it": "Gemma 3 1B",
|
|
||||||
"gemma-3-4b-it": "Gemma 3 4B",
|
|
||||||
"gemma-3-12b-it": "Gemma 3 12B",
|
|
||||||
"gemma-3-27b-it": "Gemma 3 27B",
|
|
||||||
"gemma-3n-e4b-it": "Gemma 3n E4B",
|
|
||||||
"gemma-3n-e2b-it": "Gemma 3n E2B",
|
|
||||||
"gemini-2.5-flash-lite": "Gemini 2.5 Flash-Lite"
|
|
||||||
},
|
|
||||||
"timestamp": 1754568195.1098156
|
|
||||||
}
|
|
||||||
@@ -115,30 +115,24 @@ def analyze_image_with_gemini(
|
|||||||
else:
|
else:
|
||||||
system_prompt = PROMPT_TEMPLATES.get(prompt_type, PROMPT_TEMPLATES["flux"])
|
system_prompt = PROMPT_TEMPLATES.get(prompt_type, PROMPT_TEMPLATES["flux"])
|
||||||
|
|
||||||
# Here we would normally make the API call to Gemini
|
|
||||||
# For now, we'll import the google-generativeai library
|
|
||||||
try:
|
try:
|
||||||
import google.generativeai as genai
|
from google import genai
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return (
|
return (
|
||||||
"",
|
"",
|
||||||
"google-generativeai library not installed. Please run: pip install google-generativeai",
|
"google-genai library not installed. Please run: pip install google-genai",
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Configure Gemini
|
client = genai.Client(api_key=api_key)
|
||||||
genai.configure(api_key=api_key)
|
|
||||||
|
|
||||||
# Create model
|
response = client.models.generate_content(
|
||||||
model = genai.GenerativeModel(model_name)
|
model=model_name,
|
||||||
|
contents=[
|
||||||
# Generate content
|
|
||||||
response = model.generate_content(
|
|
||||||
[
|
|
||||||
system_prompt,
|
system_prompt,
|
||||||
pil_image,
|
pil_image,
|
||||||
"Analyze this image and generate an appropriate prompt according to the instructions.",
|
"Analyze this image and generate an appropriate prompt according to the instructions.",
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Extract text from response
|
# Extract text from response
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ def _fetch_models_from_api(
|
|||||||
Tuple of (model_names_list, model_descriptions_dict)
|
Tuple of (model_names_list, model_descriptions_dict)
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
import google.generativeai as genai
|
from google import genai
|
||||||
except ImportError:
|
except ImportError:
|
||||||
if not silent:
|
if not silent:
|
||||||
logger.error("google-generativeai not installed")
|
logger.error("google-genai not installed")
|
||||||
return [], {}
|
return [], {}
|
||||||
|
|
||||||
# Get API key
|
# Get API key
|
||||||
@@ -77,15 +77,15 @@ def _fetch_models_from_api(
|
|||||||
return [], {}
|
return [], {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
genai.configure(api_key=api_key)
|
client = genai.Client(api_key=api_key)
|
||||||
|
|
||||||
models = []
|
models = []
|
||||||
descriptions = {}
|
descriptions = {}
|
||||||
|
|
||||||
# Fetch all models
|
# Fetch all models
|
||||||
for model in genai.list_models():
|
for model in client.models.list():
|
||||||
# Only include models that support generateContent
|
# Only include models that support generateContent
|
||||||
if "generateContent" in model.supported_generation_methods:
|
if "generateContent" in (model.supported_actions or []):
|
||||||
# Remove "models/" prefix from name
|
# Remove "models/" prefix from name
|
||||||
model_name = model.name.replace("models/", "")
|
model_name = model.name.replace("models/", "")
|
||||||
models.append(model_name)
|
models.append(model_name)
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ Supports multiple prompt formats:
|
|||||||
- Video: Motion and temporal descriptions for video generation
|
- Video: Motion and temporal descriptions for video generation
|
||||||
|
|
||||||
Requires Gemini API key (set GEMINI_API_KEY env var or provide in node).
|
Requires Gemini API key (set GEMINI_API_KEY env var or provide in node).
|
||||||
Install: pip install google-generativeai
|
Install: pip install google-genai
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def generate_prompt(
|
def generate_prompt(
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"last_path": "/home/vito/ai-apps/ComfyUI/output/vids",
|
|
||||||
"saved_paths": [
|
|
||||||
"/home/vito/ai-apps/ComfyUI-3.12/output/2025-05-01",
|
|
||||||
"/home/vito/ai-apps/ComfyUI-3.12/output/",
|
|
||||||
"/home/vito/Downloads/vito",
|
|
||||||
"/home/vito/ai-apps/ComfyUI/output/2025-06-08",
|
|
||||||
"/home/vito/ai-apps/ComfyUI/output",
|
|
||||||
"/home/vito/Downloads",
|
|
||||||
"/home/vito/Downloads/images"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
{
|
|
||||||
"57": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI-3.12/output/2025-05-01/HiDream_00001_.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"58": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI-3.12/output/CharacterName_00016_.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"18": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI/output/vids/KikoSave_00005.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"445": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI/output/ComfyUI_00002_.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"23": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI/output/Z_Image_Char/Image_00098_.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"69": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/Downloads/KikoSave_00086.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"52": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI/output/kiko/XXX/images/kiko_00038_.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"38": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/Downloads/vito/IMG_20160422_163419.jpg"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"170": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI/output/Z_Image_Char/Image_00326_.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"214": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI/output/Z_Image_Char/Image_00329_.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"299": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/Downloads/images/KikoSave_00016.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"527": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/Downloads/ComfyUI_temp_sktzg_00012_.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"522": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/Downloads/KikoSave_00086.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"517": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI/output/vids/KikoSave_00005.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"144": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI/output/2025-04-24/ComfyUI_00002_.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"569": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI/output/vids/KikoSave_00008.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"136": {
|
|
||||||
"image": {
|
|
||||||
"path": "/home/vito/ai-apps/ComfyUI/output/vids/KikoSave_00005.png"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
"""Model Compare Sheet module."""
|
||||||
|
|
||||||
|
from .node import ModelCompareSheetNode
|
||||||
|
|
||||||
|
__all__ = ["ModelCompareSheetNode"]
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
"""Logic for the Model Compare Sheet node: tile files on disk into a labeled grid."""
|
||||||
|
|
||||||
|
import math
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
from datetime import datetime
|
||||||
|
from typing import List, Optional, Tuple
|
||||||
|
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
|
from ...base.model_folders import is_within, natural_sort
|
||||||
|
|
||||||
|
GRID_FILENAME = "grid.png"
|
||||||
|
PREVIEW_FILENAME = "grid_preview.png"
|
||||||
|
PREVIEW_WIDTH = 1024
|
||||||
|
BACKGROUND = (28, 28, 28)
|
||||||
|
LABEL_COLOR = (235, 235, 235)
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_run_dir(output_dir: str, run_name: str) -> str:
|
||||||
|
"""Directory for one compare run, always strictly inside output/model_compare.
|
||||||
|
|
||||||
|
run_name may be nested ("project/date/sweep"). Every segment must be a plain
|
||||||
|
name: no empty, "." or ".." parts, on either separator, and the resolved
|
||||||
|
path must stay below model_compare even after symlinks are followed.
|
||||||
|
"""
|
||||||
|
parts = re.split(r"[\\/]", run_name)
|
||||||
|
if not run_name or os.path.isabs(run_name) or ":" in run_name:
|
||||||
|
raise ValueError(f"Invalid run_name: {run_name!r}")
|
||||||
|
if any(part in ("", ".", "..") for part in parts):
|
||||||
|
raise ValueError(f"Invalid run_name: {run_name!r}")
|
||||||
|
base = os.path.join(output_dir, "model_compare")
|
||||||
|
run_dir = os.path.join(base, *parts)
|
||||||
|
if not is_within(run_dir, base) or os.path.realpath(run_dir) == os.path.realpath(
|
||||||
|
base
|
||||||
|
):
|
||||||
|
raise ValueError(f"Invalid run_name: {run_name!r}")
|
||||||
|
return run_dir
|
||||||
|
|
||||||
|
|
||||||
|
def tile_filename(index: int, label: str, batch_index: int, batch_size: int) -> str:
|
||||||
|
"""'03_label.png', or '03_label_2.png' for the second image of a batch."""
|
||||||
|
safe = re.sub(r"[^A-Za-z0-9._-]+", "_", label)
|
||||||
|
suffix = f"_{batch_index + 1}" if batch_size > 1 else ""
|
||||||
|
return f"{index:02d}_{safe}{suffix}.png"
|
||||||
|
|
||||||
|
|
||||||
|
def label_from_filename(filename: str) -> str:
|
||||||
|
stem = os.path.splitext(os.path.basename(filename))[0]
|
||||||
|
return re.sub(r"^\d+_", "", stem)
|
||||||
|
|
||||||
|
|
||||||
|
def list_tiles(run_dir: str) -> List[str]:
|
||||||
|
"""PNG tiles in a run directory in natural order, excluding the grid itself."""
|
||||||
|
names = [
|
||||||
|
f
|
||||||
|
for f in os.listdir(run_dir)
|
||||||
|
if f.lower().endswith(".png")
|
||||||
|
and f not in (GRID_FILENAME, PREVIEW_FILENAME)
|
||||||
|
and os.path.isfile(os.path.join(run_dir, f))
|
||||||
|
]
|
||||||
|
return [os.path.join(run_dir, f) for f in natural_sort(names)]
|
||||||
|
|
||||||
|
|
||||||
|
def replace_index_tiles(
|
||||||
|
run_dir: str, index: int, staged_dir: str, names: List[str]
|
||||||
|
) -> None:
|
||||||
|
"""Publish one index's staged tiles, restoring old files on a rename failure."""
|
||||||
|
previous_dir = os.path.join(staged_dir, "previous")
|
||||||
|
os.mkdir(previous_dir)
|
||||||
|
prefix = f"{index:02d}_"
|
||||||
|
old_tiles = [
|
||||||
|
path
|
||||||
|
for path in list_tiles(run_dir)
|
||||||
|
if os.path.basename(path).startswith(prefix)
|
||||||
|
]
|
||||||
|
moved: List[Tuple[str, str]] = []
|
||||||
|
published: List[str] = []
|
||||||
|
try:
|
||||||
|
for path in old_tiles:
|
||||||
|
backup = os.path.join(previous_dir, os.path.basename(path) + ".previous")
|
||||||
|
os.replace(path, backup)
|
||||||
|
moved.append((path, backup))
|
||||||
|
for name in names:
|
||||||
|
destination = os.path.join(run_dir, name)
|
||||||
|
os.replace(os.path.join(staged_dir, name + ".tmp"), destination)
|
||||||
|
published.append(destination)
|
||||||
|
except OSError:
|
||||||
|
for path in published:
|
||||||
|
os.remove(path)
|
||||||
|
for original, backup in reversed(moved):
|
||||||
|
os.replace(backup, original)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def archive_previous_sweep(run_dir: str) -> Optional[str]:
|
||||||
|
"""Rename a run folder that already holds tiles to '<run_dir>_<timestamp>'.
|
||||||
|
|
||||||
|
Called when a sweep starts over (index 0) so stale tiles from an
|
||||||
|
interrupted sweep never end up in the new grid. Returns the archive path,
|
||||||
|
or None when there was nothing to archive.
|
||||||
|
"""
|
||||||
|
if not os.path.isdir(run_dir) or not list_tiles(run_dir):
|
||||||
|
return None
|
||||||
|
stamp = datetime.fromtimestamp(os.path.getmtime(run_dir)).strftime("%Y%m%d-%H%M%S")
|
||||||
|
archive = f"{run_dir}_{stamp}"
|
||||||
|
n = 1
|
||||||
|
while os.path.exists(archive):
|
||||||
|
n += 1
|
||||||
|
archive = f"{run_dir}_{stamp}_{n}"
|
||||||
|
os.rename(run_dir, archive)
|
||||||
|
return archive
|
||||||
|
|
||||||
|
|
||||||
|
def _font(font_size: int) -> ImageFont.ImageFont:
|
||||||
|
try:
|
||||||
|
return ImageFont.truetype("DejaVuSans.ttf", font_size)
|
||||||
|
except OSError:
|
||||||
|
return ImageFont.load_default(size=font_size)
|
||||||
|
|
||||||
|
|
||||||
|
def _fit_label(draw: ImageDraw.ImageDraw, text: str, font, max_width: int) -> str:
|
||||||
|
while text and draw.textlength(text, font=font) > max_width:
|
||||||
|
text = text[:-2] + "…" if len(text) > 1 else ""
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
def build_contact_sheet(
|
||||||
|
paths: List[str], columns: int, tile_width: int, font_size: int
|
||||||
|
) -> Image.Image:
|
||||||
|
"""Tile the images at `paths` into a grid with each file's label underneath."""
|
||||||
|
tiles = []
|
||||||
|
for path in paths:
|
||||||
|
with Image.open(path) as im:
|
||||||
|
im = im.convert("RGB")
|
||||||
|
tile_height = max(1, round(im.height * tile_width / im.width))
|
||||||
|
tiles.append((im.resize((tile_width, tile_height), Image.LANCZOS), path))
|
||||||
|
|
||||||
|
band = font_size * 2
|
||||||
|
cell_height = max(t.height for t, _ in tiles) + band
|
||||||
|
cols = min(len(tiles), columns)
|
||||||
|
rows = math.ceil(len(tiles) / cols)
|
||||||
|
sheet = Image.new("RGB", (cols * tile_width, rows * cell_height), BACKGROUND)
|
||||||
|
draw = ImageDraw.Draw(sheet)
|
||||||
|
font = _font(font_size)
|
||||||
|
|
||||||
|
for i, (tile, path) in enumerate(tiles):
|
||||||
|
x = (i % cols) * tile_width
|
||||||
|
y = (i // cols) * cell_height
|
||||||
|
sheet.paste(tile, (x, y))
|
||||||
|
label = _fit_label(draw, label_from_filename(path), font, tile_width - 8)
|
||||||
|
text_x = x + (tile_width - draw.textlength(label, font=font)) / 2
|
||||||
|
text_y = y + tile.height + (band - font_size) / 2
|
||||||
|
draw.text((text_x, text_y), label, fill=LABEL_COLOR, font=font)
|
||||||
|
return sheet
|
||||||
|
|
||||||
|
|
||||||
|
def preview_of(sheet: Image.Image) -> Image.Image:
|
||||||
|
"""A copy of the sheet no wider than PREVIEW_WIDTH, for the node preview and galleries."""
|
||||||
|
if sheet.width <= PREVIEW_WIDTH:
|
||||||
|
return sheet
|
||||||
|
height = max(1, round(sheet.height * PREVIEW_WIDTH / sheet.width))
|
||||||
|
return sheet.resize((PREVIEW_WIDTH, height), Image.LANCZOS)
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
"""Model Compare Sheet node for ComfyUI."""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from tempfile import TemporaryDirectory
|
||||||
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import torch
|
||||||
|
from PIL import Image
|
||||||
|
from PIL.PngImagePlugin import PngInfo
|
||||||
|
|
||||||
|
from ...base.base_node import ComfyAssetsBaseNode
|
||||||
|
from .logic import (
|
||||||
|
GRID_FILENAME,
|
||||||
|
PREVIEW_FILENAME,
|
||||||
|
archive_previous_sweep,
|
||||||
|
build_contact_sheet,
|
||||||
|
list_tiles,
|
||||||
|
preview_of,
|
||||||
|
replace_index_tiles,
|
||||||
|
resolve_run_dir,
|
||||||
|
tile_filename,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ModelCompareSheetNode(ComfyAssetsBaseNode):
|
||||||
|
"""
|
||||||
|
Save each run's image into output/model_compare/<run_name>/ and rebuild a
|
||||||
|
labeled contact sheet from every tile saved so far. Pair with Checkpoint
|
||||||
|
Folder Iterator: after the last queued run the grid holds every model.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(cls):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"images": ("IMAGE",),
|
||||||
|
"label": ("STRING", {"forceInput": True}),
|
||||||
|
"index": ("INT", {"forceInput": True}),
|
||||||
|
"run_name": (
|
||||||
|
"STRING",
|
||||||
|
{
|
||||||
|
"default": "illustrious",
|
||||||
|
"tooltip": "Subfolder of output/model_compare for this run",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
"columns": ("INT", {"default": 5, "min": 1, "max": 32}),
|
||||||
|
"tile_width": ("INT", {"default": 512, "min": 64, "max": 4096}),
|
||||||
|
"font_size": ("INT", {"default": 28, "min": 8, "max": 256}),
|
||||||
|
},
|
||||||
|
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TYPES = ("IMAGE",)
|
||||||
|
RETURN_NAMES = ("grid",)
|
||||||
|
FUNCTION = "collect"
|
||||||
|
OUTPUT_NODE = True
|
||||||
|
CATEGORY = "🫶 ComfyAssets/🧰 xyz-helpers"
|
||||||
|
|
||||||
|
def collect(
|
||||||
|
self,
|
||||||
|
images: torch.Tensor,
|
||||||
|
label: str,
|
||||||
|
index: int,
|
||||||
|
run_name: str,
|
||||||
|
columns: int,
|
||||||
|
tile_width: int,
|
||||||
|
font_size: int,
|
||||||
|
prompt: Optional[Dict] = None,
|
||||||
|
extra_pnginfo: Optional[Dict] = None,
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
import folder_paths
|
||||||
|
|
||||||
|
if images.shape[0] == 0:
|
||||||
|
raise ValueError("images must contain at least one image")
|
||||||
|
|
||||||
|
output_dir = folder_paths.get_output_directory()
|
||||||
|
run_dir = resolve_run_dir(output_dir, run_name)
|
||||||
|
metadata = PngInfo()
|
||||||
|
if prompt is not None:
|
||||||
|
metadata.add_text("prompt", json.dumps(prompt))
|
||||||
|
for key, value in (extra_pnginfo or {}).items():
|
||||||
|
metadata.add_text(key, json.dumps(value))
|
||||||
|
|
||||||
|
parent = os.path.dirname(run_dir)
|
||||||
|
os.makedirs(parent, exist_ok=True)
|
||||||
|
with TemporaryDirectory(prefix=".model-compare-", dir=parent) as staging:
|
||||||
|
names = []
|
||||||
|
for i, image in enumerate(images):
|
||||||
|
array = (image.cpu().numpy().clip(0, 1) * 255).round().astype(np.uint8)
|
||||||
|
name = tile_filename(index, label, i, images.shape[0])
|
||||||
|
with Image.fromarray(array) as tile:
|
||||||
|
tile.save(
|
||||||
|
os.path.join(staging, name + ".tmp"),
|
||||||
|
format="PNG",
|
||||||
|
pnginfo=metadata,
|
||||||
|
)
|
||||||
|
names.append(name)
|
||||||
|
if index == 0:
|
||||||
|
archived = archive_previous_sweep(run_dir)
|
||||||
|
if archived:
|
||||||
|
self.log_info(f"New sweep: previous tiles moved to {archived}")
|
||||||
|
os.makedirs(run_dir, exist_ok=True)
|
||||||
|
replace_index_tiles(run_dir, index, staging, names)
|
||||||
|
|
||||||
|
sheet = build_contact_sheet(list_tiles(run_dir), columns, tile_width, font_size)
|
||||||
|
sheet.save(os.path.join(run_dir, GRID_FILENAME))
|
||||||
|
preview_of(sheet).save(os.path.join(run_dir, PREVIEW_FILENAME))
|
||||||
|
self.log_info(f"Contact sheet: {run_dir}/{GRID_FILENAME}")
|
||||||
|
|
||||||
|
grid = torch.from_numpy(np.asarray(sheet).astype(np.float32) / 255.0)[None]
|
||||||
|
subfolder = os.path.relpath(run_dir, output_dir)
|
||||||
|
return {
|
||||||
|
"ui": {
|
||||||
|
"images": [
|
||||||
|
{
|
||||||
|
"filename": PREVIEW_FILENAME,
|
||||||
|
"subfolder": subfolder,
|
||||||
|
"type": "output",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"result": (grid,),
|
||||||
|
}
|
||||||
@@ -56,7 +56,6 @@ class ProjectFilePathNode(ComfyAssetsBaseNode):
|
|||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("STRING",)
|
RETURN_TYPES = ("STRING",)
|
||||||
RETURN_NAMES = ("path",)
|
|
||||||
FUNCTION = "generate_path"
|
FUNCTION = "generate_path"
|
||||||
CATEGORY = "🫶 ComfyAssets/🛠️ Utils"
|
CATEGORY = "🫶 ComfyAssets/🛠️ Utils"
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,16 @@
|
|||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from typing import List, Dict, Any, Optional, Tuple
|
from typing import List, Dict, Any, Tuple
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from ....base.model_folders import (
|
||||||
|
filter_by_pattern,
|
||||||
|
natural_sort,
|
||||||
|
resolve_scan_targets,
|
||||||
|
scan_model_entries,
|
||||||
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
MAX_STRENGTH_VALUES = 1000
|
MAX_STRENGTH_VALUES = 1000
|
||||||
@@ -40,66 +47,9 @@ def get_lora_folders() -> List[str]:
|
|||||||
return [".", "flux", "sdxl", "sd15"]
|
return [".", "flux", "sdxl", "sd15"]
|
||||||
|
|
||||||
|
|
||||||
def _get_lora_roots() -> List[str]:
|
|
||||||
"""Return every configured loras root directory (empty if unavailable)."""
|
|
||||||
try:
|
|
||||||
import folder_paths
|
|
||||||
|
|
||||||
entry = folder_paths.folder_names_and_paths.get("loras")
|
|
||||||
return list(entry[0]) if entry else []
|
|
||||||
except (ImportError, AttributeError, IndexError, TypeError):
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
def _is_within(path: str, root: str) -> bool:
|
|
||||||
"""True if realpath `path` equals or is inside realpath `root`."""
|
|
||||||
try:
|
|
||||||
real_path, real_root = os.path.realpath(path), os.path.realpath(root)
|
|
||||||
return os.path.commonpath([real_path, real_root]) == real_root
|
|
||||||
except ValueError: # different drives or mixed absolute/relative
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def _resolve_scan_targets(folder_path: str) -> List[Tuple[str, Optional[str]]]:
|
|
||||||
"""
|
|
||||||
Resolve a folder setting to (directory, base_root) pairs to scan.
|
|
||||||
|
|
||||||
base_root is the loras root the directory lives in, or None when the
|
|
||||||
directory is an absolute path outside every known root.
|
|
||||||
"""
|
|
||||||
roots = _get_lora_roots()
|
|
||||||
|
|
||||||
if os.path.isabs(folder_path):
|
|
||||||
base = next((r for r in roots if _is_within(folder_path, r)), None)
|
|
||||||
return [(folder_path, base)]
|
|
||||||
|
|
||||||
targets = []
|
|
||||||
for root in roots:
|
|
||||||
candidate = os.path.join(root, folder_path)
|
|
||||||
if not _is_within(candidate, root):
|
|
||||||
logger.warning(f"Folder escapes the loras directory: {folder_path}")
|
|
||||||
continue
|
|
||||||
targets.append((candidate, root))
|
|
||||||
return targets
|
|
||||||
|
|
||||||
|
|
||||||
def _scan_entries(folder_path: str) -> List[Tuple[str, str]]:
|
def _scan_entries(folder_path: str) -> List[Tuple[str, str]]:
|
||||||
"""Return (relative_name, absolute_path) for every .safetensors found."""
|
"""Return (relative_name, absolute_path) for every .safetensors found."""
|
||||||
entries: Dict[str, str] = {}
|
return scan_model_entries(folder_path, "loras")
|
||||||
for directory, base in _resolve_scan_targets(folder_path):
|
|
||||||
if not os.path.isdir(directory):
|
|
||||||
continue
|
|
||||||
for root, _, files in os.walk(directory):
|
|
||||||
for file in files:
|
|
||||||
if not file.endswith(".safetensors"):
|
|
||||||
continue
|
|
||||||
full = os.path.join(root, file)
|
|
||||||
try:
|
|
||||||
rel = os.path.relpath(full, base or directory)
|
|
||||||
except ValueError:
|
|
||||||
rel = os.path.relpath(full, directory)
|
|
||||||
entries.setdefault(rel.replace("\\", "/"), full)
|
|
||||||
return [(name, entries[name]) for name in natural_sort(list(entries))]
|
|
||||||
|
|
||||||
|
|
||||||
def scan_folder_for_loras(folder_path: str) -> List[str]:
|
def scan_folder_for_loras(folder_path: str) -> List[str]:
|
||||||
@@ -164,71 +114,11 @@ def sort_lora_files(lora_files: List[str], sort_order: str) -> List[str]:
|
|||||||
return lora_files
|
return lora_files
|
||||||
|
|
||||||
|
|
||||||
def natural_sort(items: List[str]) -> List[str]:
|
|
||||||
"""
|
|
||||||
Sort strings naturally, handling numbers properly.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
items: List of strings to sort
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Naturally sorted list
|
|
||||||
"""
|
|
||||||
|
|
||||||
def natural_key(text):
|
|
||||||
def atoi(text):
|
|
||||||
return int(text) if text.isdigit() else text
|
|
||||||
|
|
||||||
# Split on digits and filter out empty strings
|
|
||||||
parts = [atoi(c) for c in re.split(r"(\d+)", text) if c]
|
|
||||||
|
|
||||||
# Convert to tuple of (type_order, value) to ensure consistent comparison
|
|
||||||
# Integers get type_order 0, strings get type_order 1
|
|
||||||
typed_parts = []
|
|
||||||
for part in parts:
|
|
||||||
if isinstance(part, int):
|
|
||||||
typed_parts.append((0, part))
|
|
||||||
else:
|
|
||||||
typed_parts.append((1, part))
|
|
||||||
|
|
||||||
return typed_parts
|
|
||||||
|
|
||||||
return sorted(items, key=natural_key)
|
|
||||||
|
|
||||||
|
|
||||||
def filter_loras_by_pattern(
|
def filter_loras_by_pattern(
|
||||||
lora_files: List[str], include_pattern: str = "", exclude_pattern: str = ""
|
lora_files: List[str], include_pattern: str = "", exclude_pattern: str = ""
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
"""
|
"""Filter LoRA names by include/exclude regex (empty pattern = no filter)."""
|
||||||
Filter LoRA files by include/exclude patterns.
|
return filter_by_pattern(lora_files, include_pattern, exclude_pattern)
|
||||||
|
|
||||||
Args:
|
|
||||||
lora_files: List of LoRA filenames
|
|
||||||
include_pattern: Regex pattern to include (empty = include all)
|
|
||||||
exclude_pattern: Regex pattern to exclude (empty = exclude none)
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Filtered list of LoRA files
|
|
||||||
"""
|
|
||||||
filtered = lora_files.copy()
|
|
||||||
|
|
||||||
# Apply include pattern
|
|
||||||
if include_pattern:
|
|
||||||
try:
|
|
||||||
include_re = re.compile(include_pattern)
|
|
||||||
filtered = [f for f in filtered if include_re.search(f)]
|
|
||||||
except re.error as e:
|
|
||||||
logger.error(f"Invalid include pattern: {e}")
|
|
||||||
|
|
||||||
# Apply exclude pattern
|
|
||||||
if exclude_pattern:
|
|
||||||
try:
|
|
||||||
exclude_re = re.compile(exclude_pattern)
|
|
||||||
filtered = [f for f in filtered if not exclude_re.search(f)]
|
|
||||||
except re.error as e:
|
|
||||||
logger.error(f"Invalid exclude pattern: {e}")
|
|
||||||
|
|
||||||
return filtered
|
|
||||||
|
|
||||||
|
|
||||||
def _parse_finite(token: str, what: str, original: str) -> float:
|
def _parse_finite(token: str, what: str, original: str) -> float:
|
||||||
@@ -438,7 +328,7 @@ def validate_folder_path(folder_path: str) -> bool:
|
|||||||
|
|
||||||
return any(
|
return any(
|
||||||
os.path.isdir(directory)
|
os.path.isdir(directory)
|
||||||
for directory, _ in _resolve_scan_targets(folder_path)
|
for directory, _ in resolve_scan_targets(folder_path, "loras")
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|||||||
+8
-6
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
[project]
|
[project]
|
||||||
name = "kikotools"
|
name = "kikotools"
|
||||||
description = "Simple tools for ComfyUI"
|
description = "Simple tools for ComfyUI"
|
||||||
version = "1.0.28"
|
version = "1.1.2"
|
||||||
license = {text = "MIT"}
|
license = {text = "MIT"}
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
||||||
@@ -14,18 +14,19 @@ dev = [
|
|||||||
# Testing framework
|
# Testing framework
|
||||||
"pytest>=7.0.0",
|
"pytest>=7.0.0",
|
||||||
"pytest-cov>=4.0.0",
|
"pytest-cov>=4.0.0",
|
||||||
"pytest-mock>=3.10.0",
|
"pytest-mock>=3.15.1",
|
||||||
"pytest-asyncio>=0.21.0",
|
"pytest-asyncio>=0.21.0",
|
||||||
|
"aiohttp>=3.8.0",
|
||||||
# Code quality
|
# Code quality
|
||||||
"black>=23.0.0",
|
"black>=23.0.0",
|
||||||
"flake8>=6.0.0",
|
"flake8>=6.0.0",
|
||||||
"mypy>=1.0.0",
|
"mypy>=1.20.0",
|
||||||
# Development utilities
|
# Development utilities
|
||||||
"pre-commit>=3.0.0",
|
"pre-commit>=4.5.1",
|
||||||
# ComfyUI testing (mock dependencies for unit tests)
|
# ComfyUI testing (mock dependencies for unit tests)
|
||||||
"torch>=2.0.0",
|
"torch>=2.11.0",
|
||||||
"numpy>=1.24.0",
|
"numpy>=1.24.0",
|
||||||
"pillow>=9.0.0"
|
"pillow>=12.2.0"
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
@@ -71,6 +72,7 @@ files = ["kikotools"]
|
|||||||
exclude = ["tests"]
|
exclude = ["tests"]
|
||||||
|
|
||||||
[tool.coverage.run]
|
[tool.coverage.run]
|
||||||
|
branch = true
|
||||||
source = ["kikotools"]
|
source = ["kikotools"]
|
||||||
omit = ["*/tests/*", "*/__init__.py"]
|
omit = ["*/tests/*", "*/__init__.py"]
|
||||||
|
|
||||||
|
|||||||
@@ -3,18 +3,19 @@
|
|||||||
# Testing framework
|
# Testing framework
|
||||||
pytest>=7.0.0
|
pytest>=7.0.0
|
||||||
pytest-cov>=4.0.0
|
pytest-cov>=4.0.0
|
||||||
pytest-mock>=3.10.0
|
pytest-mock>=3.15.1
|
||||||
pytest-asyncio>=0.21.0
|
pytest-asyncio>=0.21.0
|
||||||
|
aiohttp>=3.8.0
|
||||||
|
|
||||||
# Code quality
|
# Code quality
|
||||||
black>=23.0.0
|
black>=23.0.0
|
||||||
flake8>=6.0.0
|
flake8>=6.0.0
|
||||||
mypy>=1.0.0
|
mypy>=1.20.0
|
||||||
|
|
||||||
# Development utilities
|
# Development utilities
|
||||||
pre-commit>=3.0.0
|
pre-commit>=4.5.1
|
||||||
|
|
||||||
# ComfyUI testing (mock dependencies for unit tests)
|
# ComfyUI testing (mock dependencies for unit tests)
|
||||||
torch>=2.0.0
|
torch>=2.11.0
|
||||||
numpy>=1.24.0
|
numpy>=1.24.0
|
||||||
pillow>=9.0.0
|
pillow>=12.2.0
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
# Runtime dependencies for ComfyUI-KikoTools
|
# Runtime dependencies for ComfyUI-KikoTools
|
||||||
|
|
||||||
# Gemini API integration (optional - only needed for Gemini Prompt node)
|
# Gemini API integration (optional - only needed for Gemini Prompt node)
|
||||||
google-generativeai
|
google-genai
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
// A test double for the ComfyUI host; extension implementations load unchanged.
|
||||||
|
const extensions = [];
|
||||||
|
const settings = new Map();
|
||||||
|
const nodes = new Map();
|
||||||
|
let nextId = 1;
|
||||||
|
function el(tag, props = {}, children = []) {
|
||||||
|
const element = document.createElement(tag);
|
||||||
|
for (const [name, value] of Object.entries(props)) {
|
||||||
|
if (name === 'style') Object.assign(element.style, value);
|
||||||
|
else if (name === 'parent') value.appendChild(element);
|
||||||
|
else element[name] = value;
|
||||||
|
}
|
||||||
|
element.append(...children);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
const app = {
|
||||||
|
registerExtension(extension) {
|
||||||
|
if (extensions.some(item => item.name === extension.name)) throw new Error(`Duplicate extension ${extension.name}`);
|
||||||
|
extensions.push(extension);
|
||||||
|
},
|
||||||
|
ui: { settings: {
|
||||||
|
addSetting(setting) { if (!settings.has(setting.id)) settings.set(setting.id, setting.defaultValue); },
|
||||||
|
getSettingValue: id => settings.get(id),
|
||||||
|
}, dialog: { show: text => { const dialog = el('div', { className: 'host-dialog', textContent: text }); document.body.append(dialog); } } },
|
||||||
|
graph: {
|
||||||
|
_nodes: [],
|
||||||
|
add(node) { this._nodes.push(node); nodes.set(String(node.id), node); },
|
||||||
|
getNodeById: id => nodes.get(String(id)),
|
||||||
|
setDirtyCanvas() {},
|
||||||
|
},
|
||||||
|
canvas: { selected_nodes: {}, centerOnNode(node) { app.centeredNode = node.id; } },
|
||||||
|
};
|
||||||
|
const api = new EventTarget();
|
||||||
|
api.fetchApi = (path, options) => fetch(path, options);
|
||||||
|
api.getEmbeddings = async () => [];
|
||||||
|
function widget(node, name, value, multiline = false) {
|
||||||
|
const inputEl = el(multiline ? 'textarea' : 'input', { 'ariaLabel': name });
|
||||||
|
const result = { name, inputEl, options: {}, callback() {}, onRemove() { inputEl.remove(); } };
|
||||||
|
Object.defineProperty(result, 'value', { get: () => inputEl.value, set: value => { inputEl.value = value; } });
|
||||||
|
result.value = value ?? '';
|
||||||
|
inputEl.addEventListener('change', () => result.callback(result.value, app.canvas, node, [0, 0], null));
|
||||||
|
node.widgets.push(result);
|
||||||
|
node.element.append(inputEl);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
const widgets = { STRING(node, name, data) { return { widget: widget(node, name, '', data[1]?.multiline) }; } };
|
||||||
|
class HostNode {
|
||||||
|
constructor(name, initial) {
|
||||||
|
this.id = nextId++;
|
||||||
|
this.type = name;
|
||||||
|
this.title = name;
|
||||||
|
this.widgets = [];
|
||||||
|
this.size = [500, 300];
|
||||||
|
this.pos = [0, 0];
|
||||||
|
this.flags = {};
|
||||||
|
this.inputs = [];
|
||||||
|
this.properties = {};
|
||||||
|
this.graph = app.graph;
|
||||||
|
this.element = el('section', { className: 'host-node' });
|
||||||
|
this.element.dataset.node = name;
|
||||||
|
this.domElement = this.element;
|
||||||
|
this.element.style.cssText = 'position:relative;width:min(800px,95vw);min-height:120px;margin:12px;border:1px solid #888;';
|
||||||
|
document.querySelector('#nodes').append(this.element);
|
||||||
|
for (const [key, value] of Object.entries(initial)) {
|
||||||
|
const entry = name === 'TextInput' && key === 'text'
|
||||||
|
? widgets.STRING(this, key, ['STRING', { multiline: true }], app).widget
|
||||||
|
: widget(this, key, value);
|
||||||
|
entry.value = value;
|
||||||
|
if (key === 'preset') entry.options.values = ['custom', '832×1216 - portrait', '1216×832 - landscape'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addDOMWidget(name, type, element) { this.element.append(element); const result = { name, element, onRemove: () => element.remove() }; this.widgets.push(result); return result; }
|
||||||
|
addWidget(type, name, value, callback, options = {}) {
|
||||||
|
if (type !== 'button') { const entry = widget(this, name, value); entry.callback = callback; return entry; }
|
||||||
|
const button = el('button', { textContent: name, onclick: () => callback() });
|
||||||
|
this.element.append(button);
|
||||||
|
const result = { type, name, value, callback, options, onRemove: () => button.remove() };
|
||||||
|
this.widgets.push(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
addCustomWidget(entry) { this.widgets.push(entry); if (entry.type === 'button') { const button = el('button', { textContent: entry.text, onclick: () => entry.callback() }); this.element.append(button); entry.onRemove = () => button.remove(); } return entry; }
|
||||||
|
setSize(size) { this.size = size; }
|
||||||
|
computeSize() { return this.size; }
|
||||||
|
onResize(size) { this.size = size; }
|
||||||
|
setDirtyCanvas() {}
|
||||||
|
configure(info) { this.properties = info.properties || {}; }
|
||||||
|
onNodeCreated() { this.created = true; }
|
||||||
|
onExecuted() { this.executions = (this.executions || 0) + 1; }
|
||||||
|
onRemoved() { this.removed = true; }
|
||||||
|
}
|
||||||
|
async function createNode(name, initial = {}) {
|
||||||
|
class Node extends HostNode {}
|
||||||
|
Node.category = 'ComfyAssets';
|
||||||
|
for (const extension of extensions) await extension.beforeRegisterNodeDef?.(Node, { name }, app);
|
||||||
|
const node = new Node(name, initial);
|
||||||
|
app.graph.add(node);
|
||||||
|
node.onNodeCreated();
|
||||||
|
return node.id;
|
||||||
|
}
|
||||||
|
function removeNode(id) {
|
||||||
|
const node = nodes.get(String(id));
|
||||||
|
node.onRemoved?.();
|
||||||
|
for (const entry of node.widgets) { entry.onRemoved?.(); entry.onRemove?.(); }
|
||||||
|
node.element.remove();
|
||||||
|
nodes.delete(String(id));
|
||||||
|
app.graph._nodes = app.graph._nodes.filter(item => item !== node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
window.kikoHost = { app, api, widgets, el, extensions, settings, nodes, createNode, removeNode,
|
||||||
|
emit: (name, detail) => api.dispatchEvent(new CustomEvent(name, { detail })) };
|
||||||
|
const manifest = await (await fetch('/__test__/state')).json();
|
||||||
|
for (const name of manifest.extensions) await import(`/extensions/kikotools/${name}`);
|
||||||
|
for (const extension of extensions) await extension.init?.(app);
|
||||||
|
for (const extension of extensions) await extension.setup?.(app);
|
||||||
|
window.kikoHost.ready = true;
|
||||||
|
document.body.dataset.ready = 'true';
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
"""Run actual node routes against disposable files and a minimal ComfyUI host."""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import asyncio
|
||||||
|
import importlib.util
|
||||||
|
import json
|
||||||
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import types
|
||||||
|
|
||||||
|
from aiohttp import web
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
REPOSITORY = Path(__file__).resolve().parents[2]
|
||||||
|
FIXTURES = Path(__file__).parent
|
||||||
|
|
||||||
|
|
||||||
|
def create_app(root: Path) -> web.Application:
|
||||||
|
"""Import the real plugin and replace only ComfyUI host services."""
|
||||||
|
app = web.Application()
|
||||||
|
routes = web.RouteTableDef()
|
||||||
|
server = types.ModuleType("server")
|
||||||
|
server.PromptServer = types.SimpleNamespace(
|
||||||
|
instance=types.SimpleNamespace(routes=routes, send_sync=lambda *args: None)
|
||||||
|
)
|
||||||
|
sys.modules["server"] = server
|
||||||
|
folder_paths = types.ModuleType("folder_paths")
|
||||||
|
folder_paths.base_path = str(root)
|
||||||
|
folder_paths.models_dir = str(root / "models")
|
||||||
|
folder_paths.folder_names_and_paths = {}
|
||||||
|
for kind in ("input", "output", "temp"):
|
||||||
|
directory = root / kind
|
||||||
|
directory.mkdir()
|
||||||
|
setattr(folder_paths, f"get_{kind}_directory", lambda path=directory: str(path))
|
||||||
|
folder_paths.get_filename_list = lambda kind: {
|
||||||
|
"embeddings": ["portraits/cat.pt", "landscapes/forest.safetensors"],
|
||||||
|
"loras": ["styles/ink.safetensors"],
|
||||||
|
}.get(kind, [])
|
||||||
|
folder_paths.get_folder_paths = lambda kind: [str(root / "models" / kind)]
|
||||||
|
sys.modules["folder_paths"] = folder_paths
|
||||||
|
spec = importlib.util.spec_from_file_location(
|
||||||
|
"kiko_browser_plugin", REPOSITORY / "__init__.py"
|
||||||
|
)
|
||||||
|
plugin = importlib.util.module_from_spec(spec)
|
||||||
|
sys.modules[spec.name] = plugin
|
||||||
|
spec.loader.exec_module(plugin)
|
||||||
|
loader = sys.modules["kiko_browser_plugin.kikotools.tools.local_image_loader.node"]
|
||||||
|
loader.CONFIG_FILE = str(root / "config.json")
|
||||||
|
loader.SELECTIONS_FILE = str(root / "selections.json")
|
||||||
|
|
||||||
|
def reset(extra_images: int = 0) -> None:
|
||||||
|
(root / "selections.json").unlink(missing_ok=True)
|
||||||
|
for kind in ("input", "output"):
|
||||||
|
shutil.rmtree(root / kind)
|
||||||
|
(root / kind).mkdir()
|
||||||
|
loader.save_config({"saved_paths": [], "last_path": str(root / "input")})
|
||||||
|
for path, color in [
|
||||||
|
("input/cat & dog.png", "red"),
|
||||||
|
("input/sub/forest.png", "green"),
|
||||||
|
("input/.hidden/hidden.png", "green"),
|
||||||
|
("outside/secret.png", "blue"),
|
||||||
|
]:
|
||||||
|
target = root / path
|
||||||
|
target.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
with Image.new("RGB", (16, 12), color) as image:
|
||||||
|
image.save(target)
|
||||||
|
|
||||||
|
for index in range(extra_images):
|
||||||
|
target = root / "input" / "bulk" / f"{index:04}.png"
|
||||||
|
target.parent.mkdir(exist_ok=True)
|
||||||
|
shutil.copyfile(root / "input" / "cat & dog.png", target)
|
||||||
|
|
||||||
|
@routes.post("/__test__/reset")
|
||||||
|
async def reset_route(request: web.Request) -> web.Response:
|
||||||
|
data = await request.json() if request.can_read_body else {}
|
||||||
|
extra_images = data.get("extra_images", 0)
|
||||||
|
if (
|
||||||
|
isinstance(extra_images, bool)
|
||||||
|
or not isinstance(extra_images, int)
|
||||||
|
or not 0 <= extra_images <= 60
|
||||||
|
):
|
||||||
|
raise web.HTTPBadRequest()
|
||||||
|
await asyncio.to_thread(reset, extra_images)
|
||||||
|
return web.json_response({"success": True})
|
||||||
|
|
||||||
|
@routes.get("/__test__/state")
|
||||||
|
async def state(request: web.Request) -> web.Response:
|
||||||
|
return web.json_response(
|
||||||
|
{
|
||||||
|
"input": str(root / "input"),
|
||||||
|
"outside": str(root / "outside"),
|
||||||
|
"selections": loader.load_selections(),
|
||||||
|
"config": loader.load_config(),
|
||||||
|
"nodes": sorted(plugin.NODE_CLASS_MAPPINGS),
|
||||||
|
"extensions": sorted(
|
||||||
|
path.name for path in (REPOSITORY / "web").glob("*.js")
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
@routes.post("/__test__/execute/{name}")
|
||||||
|
async def execute(request: web.Request) -> web.Response:
|
||||||
|
name = request.match_info["name"]
|
||||||
|
data = await request.json()
|
||||||
|
if name not in {
|
||||||
|
"DisplayAny",
|
||||||
|
"DisplayText",
|
||||||
|
"KikoLocalImageLoader",
|
||||||
|
"KikoSaveImage",
|
||||||
|
}:
|
||||||
|
raise web.HTTPNotFound()
|
||||||
|
if name == "KikoSaveImage":
|
||||||
|
data["images"] = loader.load_image_from_path(
|
||||||
|
str(root / "input" / "cat & dog.png")
|
||||||
|
)[0]
|
||||||
|
cls = plugin.NODE_CLASS_MAPPINGS[name]
|
||||||
|
result = await asyncio.to_thread(getattr(cls(), cls.FUNCTION), **data)
|
||||||
|
if name == "KikoLocalImageLoader":
|
||||||
|
tensor, info = result
|
||||||
|
return web.json_response(
|
||||||
|
{"shape": list(tensor.shape), "info": json.loads(info) if info else {}}
|
||||||
|
)
|
||||||
|
return web.json_response(result)
|
||||||
|
|
||||||
|
@routes.get("/__test__/")
|
||||||
|
async def index(request: web.Request) -> web.Response:
|
||||||
|
return web.Response(
|
||||||
|
text='<!doctype html><html><head><meta name="viewport" content="width=device-width, initial-scale=1"><title>KikoTools extension test host</title></head><body><main id="nodes"></main><script type="module" src="/__test__/host.mjs"></script></body></html>',
|
||||||
|
content_type="text/html",
|
||||||
|
)
|
||||||
|
|
||||||
|
@routes.get("/__test__/host.mjs")
|
||||||
|
async def host(request: web.Request) -> web.Response:
|
||||||
|
return web.FileResponse(FIXTURES / "host.mjs")
|
||||||
|
|
||||||
|
@routes.get("/scripts/{name}.js")
|
||||||
|
async def host_import(request: web.Request) -> web.Response:
|
||||||
|
exports = {
|
||||||
|
"app": "export const app = window.kikoHost.app;",
|
||||||
|
"api": "export const api = window.kikoHost.api;",
|
||||||
|
"widgets": "export const ComfyWidgets = window.kikoHost.widgets;",
|
||||||
|
"ui": "export const $el = window.kikoHost.el;",
|
||||||
|
}
|
||||||
|
if request.match_info["name"] not in exports:
|
||||||
|
raise web.HTTPNotFound()
|
||||||
|
return web.Response(
|
||||||
|
text=exports[request.match_info["name"]], content_type="text/javascript"
|
||||||
|
)
|
||||||
|
|
||||||
|
@routes.get("/view")
|
||||||
|
@routes.get("/api/view")
|
||||||
|
async def comfy_view(request: web.Request) -> web.Response:
|
||||||
|
directory = root / "output"
|
||||||
|
path = (
|
||||||
|
directory
|
||||||
|
/ request.query.get("subfolder", "")
|
||||||
|
/ request.query.get("filename", "")
|
||||||
|
).resolve()
|
||||||
|
if not path.is_relative_to(directory) or not path.is_file():
|
||||||
|
raise web.HTTPNotFound()
|
||||||
|
return web.FileResponse(path)
|
||||||
|
|
||||||
|
reset()
|
||||||
|
app.add_routes(routes)
|
||||||
|
app.router.add_static("/extensions/kikotools", REPOSITORY / "web")
|
||||||
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--port", type=int, default=8766)
|
||||||
|
args = parser.parse_args()
|
||||||
|
with tempfile.TemporaryDirectory(prefix="kiko-browser-") as directory:
|
||||||
|
web.run_app(
|
||||||
|
create_app(Path(directory).resolve()), host="127.0.0.1", port=args.port
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,285 @@
|
|||||||
|
import { test, expect } from '../../tools/testing/node_modules/@playwright/test/index.mjs';
|
||||||
|
import { isFixtureURL } from '../../tools/testing/network-policy.mjs';
|
||||||
|
import { startCoverage, saveCoverage } from '../../tools/testing/browser-coverage.mjs';
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page, request, context, browserName, baseURL }) => {
|
||||||
|
await startCoverage(page, browserName);
|
||||||
|
await expect(await request.post('/__test__/reset')).toBeOK();
|
||||||
|
page.errors = [];
|
||||||
|
page.on('pageerror', error => page.errors.push(error.message));
|
||||||
|
page.on('response', response => { if (response.status() >= 500) page.errors.push(`${response.status()} ${response.url()}`); });
|
||||||
|
await context.route('**/*', route => {
|
||||||
|
const url = new URL(route.request().url());
|
||||||
|
if (isFixtureURL(url.href, baseURL)) return route.continue();
|
||||||
|
page.errors.push(`Unexpected external request: ${url.origin}`);
|
||||||
|
return route.abort();
|
||||||
|
});
|
||||||
|
await page.addInitScript(() => localStorage.setItem('kikotools.embedding_autocomplete.settings', JSON.stringify({ showCustomWords: false, customWordsUrl: '' })));
|
||||||
|
});
|
||||||
|
test.afterEach(async ({ page, browserName }) => {
|
||||||
|
await saveCoverage(page, browserName);
|
||||||
|
expect(page.errors).toEqual([]);
|
||||||
|
});
|
||||||
|
async function openHost(page) {
|
||||||
|
await page.goto('/__test__/');
|
||||||
|
await expect(page.locator('body')).toHaveAttribute('data-ready', 'true');
|
||||||
|
}
|
||||||
|
async function createNode(page, name, values = {}) {
|
||||||
|
return page.evaluate(({ name, values }) => kikoHost.createNode(name, values), { name, values });
|
||||||
|
}
|
||||||
|
async function state(request) { return (await (await request.get('/__test__/state')).json()); }
|
||||||
|
|
||||||
|
test('plugin startup registers every frontend extension and exposes real autocomplete routes', async ({ page, request }) => {
|
||||||
|
await openHost(page);
|
||||||
|
const manifest = await state(request);
|
||||||
|
expect(manifest.nodes).toEqual(expect.arrayContaining(['DisplayAny', 'DisplayText', 'WidthHeightSelector', 'KikoLocalImageLoader', 'KikoSaveImage']));
|
||||||
|
const registered = await page.evaluate(() => kikoHost.extensions.map(extension => extension.name));
|
||||||
|
expect(registered).toHaveLength(manifest.extensions.length);
|
||||||
|
expect(new Set(registered).size).toBe(registered.length);
|
||||||
|
const embeddings = await (await request.get('/kikotools/autocomplete/embeddings')).json();
|
||||||
|
expect(embeddings).toContainEqual(expect.objectContaining({ name: 'cat', path: 'portraits/cat' }));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('actual swap handlers preserve preset values and custom dimensions', async ({ page }) => {
|
||||||
|
await openHost(page);
|
||||||
|
const id = await createNode(page, 'WidthHeightSelector', { preset: '832×1216 - portrait', width: 832, height: 1216 });
|
||||||
|
const swapped = await page.evaluate(id => {
|
||||||
|
const node = kikoHost.nodes.get(String(id));
|
||||||
|
node.onMouseDown({ canvasX: 475, canvasY: 140 });
|
||||||
|
return node.widgets.map(widget => widget.value);
|
||||||
|
}, id);
|
||||||
|
expect(swapped).toEqual(['1216×832 - landscape', '1216', '832']);
|
||||||
|
await createNode(page, 'EmptyLatentBatch', { preset: 'custom', width: 640, height: 960 });
|
||||||
|
await page.getByRole('button', { name: /Swap W/ }).click();
|
||||||
|
const latent = page.locator('[data-node="EmptyLatentBatch"]');
|
||||||
|
await expect(latent.getByLabel('width')).toHaveValue('960');
|
||||||
|
await expect(latent.getByLabel('height')).toHaveValue('640');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('local image selection persists and the real node loads the selected PNG tensor', async ({ page, request }) => {
|
||||||
|
await openHost(page);
|
||||||
|
const id = await createNode(page, 'KikoLocalImageLoader');
|
||||||
|
const image = page.getByAltText('cat & dog.png', { exact: true });
|
||||||
|
await expect(image).toBeVisible();
|
||||||
|
await expect.poll(() => image.evaluate(image => image.complete && image.naturalWidth > 0)).toBe(true);
|
||||||
|
const selected = page.waitForResponse(response => response.url().endsWith('/set_node_selection'));
|
||||||
|
await image.click();
|
||||||
|
expect((await selected).ok()).toBe(true);
|
||||||
|
const selectedPath = `${(await state(request)).input}/cat & dog.png`;
|
||||||
|
expect((await state(request)).selections[String(id)].image.path).toBe(selectedPath);
|
||||||
|
const executed = await request.post('/__test__/execute/KikoLocalImageLoader', { data: { unique_id: String(id) } });
|
||||||
|
await expect(executed).toBeOK();
|
||||||
|
expect((await executed.json()).shape).toEqual([1, 12, 16, 3]);
|
||||||
|
await page.reload();
|
||||||
|
await expect(page.locator('body')).toHaveAttribute('data-ready', 'true');
|
||||||
|
expect(await createNode(page, 'KikoLocalImageLoader')).toBe(id);
|
||||||
|
await expect(page.getByAltText('cat & dog.png', { exact: true })).toBeVisible();
|
||||||
|
expect((await state(request)).selections[String(id)].image.path).toBe(selectedPath);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('gallery navigates folders and saves and removes paths through the actual routes', async ({ page, request }) => {
|
||||||
|
await openHost(page);
|
||||||
|
await createNode(page, 'KikoLocalImageLoader');
|
||||||
|
await page.locator('.kiko-folder-name').filter({ hasText: /^sub$/ }).click();
|
||||||
|
await expect(page.getByAltText('forest.png', { exact: true })).toBeVisible();
|
||||||
|
await page.locator('.kiko-save-path').click();
|
||||||
|
await expect.poll(async () => (await state(request)).config.saved_paths).toHaveLength(1);
|
||||||
|
const saved = (await state(request)).config.saved_paths[0];
|
||||||
|
await page.reload();
|
||||||
|
await expect(page.locator('body')).toHaveAttribute('data-ready', 'true');
|
||||||
|
await createNode(page, 'KikoLocalImageLoader');
|
||||||
|
await expect(page.locator('.kiko-path-presets option')).toHaveCount(2);
|
||||||
|
await page.locator('.kiko-path-presets').selectOption(saved);
|
||||||
|
await page.locator('.kiko-delete-path').click();
|
||||||
|
await expect.poll(async () => (await state(request)).config.saved_paths).toEqual([]);
|
||||||
|
await page.locator('.kiko-up-folder').click();
|
||||||
|
await expect(page.getByAltText('cat & dog.png', { exact: true })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('gallery rejects disallowed folders and retries after a network error', async ({ page, request }) => {
|
||||||
|
await openHost(page);
|
||||||
|
const id = await createNode(page, 'KikoLocalImageLoader');
|
||||||
|
const info = await state(request);
|
||||||
|
await expect(page.getByAltText('cat & dog.png', { exact: true })).toBeVisible();
|
||||||
|
await page.locator('.kiko-path-input').fill(info.outside);
|
||||||
|
const denied = page.waitForResponse(response => response.url().includes('/images?'));
|
||||||
|
await page.locator('.kiko-browse').click();
|
||||||
|
expect((await denied).status()).toBe(403);
|
||||||
|
await expect(page.locator('.kiko-status-message')).toBeVisible();
|
||||||
|
const deniedSelection = await request.post('/kiko_local_image_loader/set_node_selection', { data: { node_id: id, path: `${info.outside}/secret.png`, type: 'image' } });
|
||||||
|
expect(deniedSelection.status()).toBe(403);
|
||||||
|
expect((await state(request)).selections).toEqual({});
|
||||||
|
await page.locator('.kiko-path-input').fill(info.input);
|
||||||
|
await page.route('**/kiko_local_image_loader/images?*', route => route.abort('failed'), { times: 1 });
|
||||||
|
await page.locator('.kiko-browse').click();
|
||||||
|
await expect(page.locator('.kiko-status-message')).toHaveText('Error loading directory');
|
||||||
|
await page.locator('.kiko-browse').click();
|
||||||
|
await expect(page.locator('.kiko-status-message')).toBeHidden();
|
||||||
|
await expect(page.getByAltText('cat & dog.png', { exact: true })).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('real display node output renders as text and replaces previous widgets', async ({ page, request }) => {
|
||||||
|
await openHost(page);
|
||||||
|
const id = await createNode(page, 'DisplayText');
|
||||||
|
const text = 'Positive prompt: <img src=x onerror="window.injected=true">\nNegative prompt: blur';
|
||||||
|
const response = await request.post('/__test__/execute/DisplayText', { data: { text } });
|
||||||
|
await expect(response).toBeOK();
|
||||||
|
const data = await response.json();
|
||||||
|
await page.evaluate(({ id, message }) => kikoHost.nodes.get(String(id)).onExecuted(message), { id, message: data.ui });
|
||||||
|
await expect(page.getByLabel('text_positive')).toHaveValue('<img src=x onerror="window.injected=true">');
|
||||||
|
await expect(page.getByLabel('text_negative')).toHaveValue('blur');
|
||||||
|
expect(await page.evaluate(() => window.injected)).toBeUndefined();
|
||||||
|
const next = await (await request.post('/__test__/execute/DisplayText', { data: { text: 'Replacement' } })).json();
|
||||||
|
await page.evaluate(({ id, message }) => kikoHost.nodes.get(String(id)).onExecuted(message), { id, message: next.ui });
|
||||||
|
await expect(page.locator('textarea')).toHaveCount(1);
|
||||||
|
await expect(page.getByLabel('text_display')).toHaveValue('Replacement');
|
||||||
|
await expect(page.getByLabel('text_display')).toHaveAttribute('readonly', '');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('seed history persists across reloads and removal clears its watcher', async ({ page }) => {
|
||||||
|
await openHost(page);
|
||||||
|
const id = await createNode(page, 'SeedHistory', { seed: 42 });
|
||||||
|
await page.getByRole('button', { name: /Generate/ }).click();
|
||||||
|
const saved = await page.evaluate(() => JSON.parse(localStorage.getItem('comfyui_kikotools_seed_history')));
|
||||||
|
expect(saved).toHaveLength(1);
|
||||||
|
expect(saved[0].seed).toBeGreaterThanOrEqual(0);
|
||||||
|
await page.reload();
|
||||||
|
await expect(page.locator('body')).toHaveAttribute('data-ready', 'true');
|
||||||
|
await createNode(page, 'SeedHistory', { seed: 42 });
|
||||||
|
expect(await page.evaluate(() => kikoHost.nodes.get('1').seedHistory[0].seed)).toBe(saved[0].seed);
|
||||||
|
await page.getByRole('button', { name: /Clear/ }).click();
|
||||||
|
expect(await page.evaluate(() => JSON.parse(localStorage.getItem('comfyui_kikotools_seed_history')))).toEqual([]);
|
||||||
|
await expect.poll(() => page.evaluate(() => Boolean(kikoHost.nodes.get('1').seedValueWatcher))).toBe(true);
|
||||||
|
expect(await page.evaluate(id => {
|
||||||
|
const node = kikoHost.removeNode(id);
|
||||||
|
return { watcher: node.seedValueWatcher, registered: window.seedHistoryNodes.includes(node), removed: node.removed };
|
||||||
|
}, id)).toEqual({ watcher: null, registered: false, removed: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('workflow timer responds to execution events and detaches removed nodes', async ({ page }) => {
|
||||||
|
await page.clock.install();
|
||||||
|
await openHost(page);
|
||||||
|
const id = await createNode(page, 'KikoWorkflowTimer');
|
||||||
|
await page.evaluate(() => kikoHost.emit('execution_start'));
|
||||||
|
await page.clock.runFor(1234);
|
||||||
|
await expect(page.locator('.kiko-timer-display')).not.toHaveText('00:00:000');
|
||||||
|
await page.evaluate(() => kikoHost.emit('execution_interrupted'));
|
||||||
|
await expect(page.locator('.kiko-timer-display')).not.toHaveClass(/running/);
|
||||||
|
const stopped = await page.locator('.kiko-timer-display').textContent();
|
||||||
|
await page.clock.runFor(500);
|
||||||
|
await expect(page.locator('.kiko-timer-display')).toHaveText(stopped);
|
||||||
|
expect(await page.evaluate(id => kikoHost.removeNode(id).removed, id)).toBe(true);
|
||||||
|
await page.evaluate(() => { kikoHost.emit('execution_start'); kikoHost.emit('executing', null); });
|
||||||
|
await expect(page.locator('.kiko-timer-display')).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('autocomplete inserts embedding paths from the real plugin endpoint and cleans up its widget', async ({ page }) => {
|
||||||
|
await openHost(page);
|
||||||
|
const id = await createNode(page, 'TextInput', { text: '' });
|
||||||
|
await expect.poll(() => page.evaluate(() => window.kikotools.autocomplete.embeddings.length)).toBe(2);
|
||||||
|
const prompt = page.getByLabel('text', { exact: true });
|
||||||
|
await prompt.fill('embedding:ca');
|
||||||
|
const suggestions = page.locator('.kikotools-autocomplete-suggestions');
|
||||||
|
await expect(suggestions).toBeVisible();
|
||||||
|
await expect(suggestions).toContainText('cat');
|
||||||
|
await prompt.press('ArrowDown');
|
||||||
|
await prompt.press('Enter');
|
||||||
|
await expect(prompt).toHaveValue(/embedding:portraits\/cat/);
|
||||||
|
await expect(suggestions).toBeHidden();
|
||||||
|
expect(await page.evaluate(id => {
|
||||||
|
const node = kikoHost.nodes.get(String(id));
|
||||||
|
const entry = node.widgets.find(widget => widget.name === 'text');
|
||||||
|
kikoHost.removeNode(id);
|
||||||
|
return window.kikotools.autocomplete.activeWidgets.has(entry);
|
||||||
|
}, id)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('real image save output opens a preview, closes, and reuses the viewer on execution', async ({ page, request }) => {
|
||||||
|
await openHost(page);
|
||||||
|
const id = await createNode(page, 'KikoSaveImage', { format: 'PNG', quality: 90 });
|
||||||
|
const response = await request.post('/__test__/execute/KikoSaveImage', { data: { filename_prefix: 'Browser image' } });
|
||||||
|
await expect(response).toBeOK();
|
||||||
|
const result = await response.json();
|
||||||
|
expect(result.ui.kiko_enhanced).toHaveLength(1);
|
||||||
|
const execute = () => page.evaluate(({ id, message }) => kikoHost.nodes.get(String(id)).onExecuted(message), { id, message: result.ui });
|
||||||
|
await execute();
|
||||||
|
const viewer = page.locator('kiko-image-viewer');
|
||||||
|
await expect(viewer).toBeVisible();
|
||||||
|
await expect(viewer.locator('img')).toHaveCount(1);
|
||||||
|
await expect.poll(() => viewer.locator('img').evaluate(image => image.complete && image.naturalWidth > 0)).toBe(true);
|
||||||
|
await viewer.getByTitle('Close', { exact: true }).click();
|
||||||
|
await expect(viewer).toBeHidden();
|
||||||
|
await execute();
|
||||||
|
await expect(viewer).toHaveCount(1);
|
||||||
|
await expect(viewer).toBeVisible();
|
||||||
|
await viewer.getByTitle('Minimize', { exact: true }).click();
|
||||||
|
await expect(viewer.locator('.kiko-viewer-container')).toBeHidden();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Display Any renders real multiline output and restores serialized values without duplicate widgets', async ({ page, request }) => {
|
||||||
|
await openHost(page);
|
||||||
|
const id = await createNode(page, 'DisplayAny');
|
||||||
|
const response = await request.post('/__test__/execute/DisplayAny', { data: { input: Array.from({ length: 45 }, (_, index) => `Line ${index}`).join('\n') } });
|
||||||
|
await expect(response).toBeOK();
|
||||||
|
const result = await response.json();
|
||||||
|
await page.evaluate(({ id, message }) => kikoHost.nodes.get(String(id)).onExecuted(message), { id, message: result.ui });
|
||||||
|
await expect(page.locator('textarea')).toHaveCount(3);
|
||||||
|
expect(await page.locator('textarea').evaluateAll(elements => elements.map(element => element.value).join('\n'))).toBe(result.ui.text[0]);
|
||||||
|
await page.evaluate(id => {
|
||||||
|
const node = kikoHost.nodes.get(String(id));
|
||||||
|
node.configure({ widgets_values: ['Restored value'] });
|
||||||
|
node.onConfigure();
|
||||||
|
}, id);
|
||||||
|
await expect(page.locator('textarea')).toHaveCount(1);
|
||||||
|
await expect(page.getByLabel('display_0')).toHaveValue('Restored value');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('gallery pagination sorting and hidden-folder controls use real directory pages', async ({ page, request }) => {
|
||||||
|
await expect(await request.post('/__test__/reset', { data: { extra_images: 52 } })).toBeOK();
|
||||||
|
await openHost(page);
|
||||||
|
await createNode(page, 'KikoLocalImageLoader');
|
||||||
|
const folder = name => page.locator('.kiko-folder-name').filter({ hasText: new RegExp(`^${name}$`) });
|
||||||
|
await expect(folder('sub')).toBeVisible();
|
||||||
|
await expect(folder('\\.hidden')).toHaveCount(0);
|
||||||
|
await page.locator('.kiko-hide-dot-folders').uncheck();
|
||||||
|
await expect(folder('\\.hidden')).toBeVisible();
|
||||||
|
await folder('bulk').click();
|
||||||
|
await expect(page.locator('.kiko-card-info-panel')).toHaveCount(50);
|
||||||
|
await expect(page.locator('.kiko-card-info-panel').first()).toHaveText('0000.png');
|
||||||
|
await page.locator('.kiko-sort-order').selectOption('desc');
|
||||||
|
await expect(page.locator('.kiko-card-info-panel').first()).toHaveText('0051.png');
|
||||||
|
await page.locator('.kiko-pagination').getByRole('button', { name: '2', exact: true }).click();
|
||||||
|
await expect(page.locator('.kiko-card-info-panel')).toHaveCount(2);
|
||||||
|
await expect(page.getByAltText('0000.png', { exact: true })).toBeVisible();
|
||||||
|
await page.locator('.kiko-pagination').getByRole('button', { name: '◀', exact: true }).click();
|
||||||
|
await expect(page.locator('.kiko-card-info-panel')).toHaveCount(50);
|
||||||
|
await page.locator('.kiko-pagination').getByRole('button', { name: '▶', exact: true }).click();
|
||||||
|
await expect(page.locator('.kiko-card-info-panel')).toHaveCount(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('gallery directory autocomplete handles keyboard selection escape and navigation', async ({ page, request }) => {
|
||||||
|
await openHost(page);
|
||||||
|
await createNode(page, 'KikoLocalImageLoader');
|
||||||
|
await expect(page.getByAltText('cat & dog.png', { exact: true })).toBeVisible();
|
||||||
|
const input = page.locator('.kiko-path-input');
|
||||||
|
const dropdown = page.locator('.kiko-autocomplete-dropdown');
|
||||||
|
const directory = (await state(request)).input;
|
||||||
|
await input.fill(`${directory}/su`);
|
||||||
|
await expect(dropdown).toBeVisible();
|
||||||
|
await expect(dropdown.locator('.folder-name')).toContainText('sub');
|
||||||
|
await input.press('ArrowDown');
|
||||||
|
await expect(dropdown.locator('.selected')).toHaveCount(1);
|
||||||
|
await input.press('ArrowUp');
|
||||||
|
await expect(dropdown.locator('.selected')).toHaveCount(0);
|
||||||
|
await input.press('Escape');
|
||||||
|
await expect(dropdown).toBeHidden();
|
||||||
|
await input.fill(`${directory}/su`);
|
||||||
|
await expect(dropdown).toBeVisible();
|
||||||
|
await input.press('ArrowDown');
|
||||||
|
await input.press('Tab');
|
||||||
|
await expect(input).toBeFocused();
|
||||||
|
await expect(input).toHaveValue(`${directory}/sub/`);
|
||||||
|
await expect(dropdown).toBeHidden();
|
||||||
|
await input.press('Enter');
|
||||||
|
await expect(page.getByAltText('forest.png', { exact: true })).toBeVisible();
|
||||||
|
});
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
const sourceRoot = join(process.cwd(), 'web');
|
||||||
|
import { checkCoverage } from '../../tools/testing/frontend-coverage.mjs';
|
||||||
|
const metrics = value => Object.fromEntries(['lines', 'branches', 'functions', 'statements'].map(key => [key, { pct: value }]));
|
||||||
|
const summary = { total: metrics(90), [join(sourceRoot, 'a.js')]: metrics(85) };
|
||||||
|
const baseline = { 'a.js': { lines: 80, branches: 80, functions: 80, statements: 80 } };
|
||||||
|
test('coverage gate accepts measured files at or above their reviewed floor', () => {
|
||||||
|
assert.deepEqual(checkCoverage(summary, baseline, sourceRoot, ['a.js']), []);
|
||||||
|
});
|
||||||
|
test('coverage gate rejects a regression even when the aggregate percentage is high', () => {
|
||||||
|
assert.match(checkCoverage({ ...summary, [join(sourceRoot, 'a.js')]: metrics(70) }, baseline, sourceRoot, ['a.js']).join('\n'), /a.js.*lines/);
|
||||||
|
});
|
||||||
|
test('coverage gate rejects absent source files and unreviewed new files', () => {
|
||||||
|
assert.match(checkCoverage({ total: metrics(100) }, baseline, sourceRoot, ['a.js']).join('\n'), /missing.*a.js/i);
|
||||||
|
assert.match(checkCoverage(summary, baseline, sourceRoot, ['a.js', 'new.js']).join('\n'), /baseline.*new.js/i);
|
||||||
|
});
|
||||||
|
test('coverage gate rejects invalid baselines and missing metrics', () => {
|
||||||
|
assert.throws(() => checkCoverage(summary, { 'a.js': { lines: -1 } }, sourceRoot, ['a.js']), /baseline/i);
|
||||||
|
assert.match(checkCoverage({ total: metrics(100), [join(sourceRoot, 'a.js')]: {} }, baseline, sourceRoot, ['a.js']).join('\n'), /lines/);
|
||||||
|
});
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import vm from 'node:vm';
|
||||||
|
|
||||||
|
function load(file, extra = {}) {
|
||||||
|
const extensions = [];
|
||||||
|
const timers = new Map();
|
||||||
|
const app = { registerExtension: extension => extensions.push(extension), canvas: {}, graph: { setDirtyCanvas() {} } };
|
||||||
|
const context = vm.createContext({
|
||||||
|
app, console: { log() {}, error() {} },
|
||||||
|
setTimeout: callback => { const id = Symbol(); timers.set(id, callback); return id; },
|
||||||
|
clearTimeout: id => timers.delete(id),
|
||||||
|
...extra,
|
||||||
|
});
|
||||||
|
const filename = fileURLToPath(new URL(`../../web/${file}`, import.meta.url));
|
||||||
|
vm.runInContext(readFileSync(filename, 'utf8').replace(/^import .*;\s*$/gm, match => match.replace(/[^\r\n]/g, ' ')), context, { filename });
|
||||||
|
return { extension: extensions[0], app, timers, context };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function dimensionNode(preset, options = ['custom', '832×1216 - portrait', '1216×832 - landscape']) {
|
||||||
|
const { extension, app } = load('width_height_swap.js');
|
||||||
|
let originalCreated = 0;
|
||||||
|
class Node {
|
||||||
|
constructor() {
|
||||||
|
this.originalPresetCalls = 0;
|
||||||
|
this.widgets = [
|
||||||
|
{ name: 'preset', value: preset, options: { values: options }, callback(value, canvas, node) { node.originalPresetCalls++; } },
|
||||||
|
{ name: 'width', value: 832 }, { name: 'height', value: 1216 },
|
||||||
|
];
|
||||||
|
this.graph = app.graph;
|
||||||
|
}
|
||||||
|
onNodeCreated() { originalCreated++; }
|
||||||
|
}
|
||||||
|
await extension.beforeRegisterNodeDef(Node, { name: 'WidthHeightSelector' }, app);
|
||||||
|
const node = new Node();
|
||||||
|
node.onNodeCreated();
|
||||||
|
assert.equal(originalCreated, 1);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
test('custom dimensions swap and callbacks receive the actual node', async () => {
|
||||||
|
const node = await dimensionNode('custom');
|
||||||
|
const calls = [];
|
||||||
|
for (const widget of node.widgets.slice(1)) widget.callback = (value, canvas, owner) => calls.push({ value, owner });
|
||||||
|
node.swapDimensions();
|
||||||
|
assert.deepEqual(node.widgets.map(widget => widget.value), ['custom', 1216, 832]);
|
||||||
|
assert.equal(calls.length, 2);
|
||||||
|
for (const call of calls) assert.equal(call.owner, node);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('formatted preset swaps to its matching landscape preset without throwing', async () => {
|
||||||
|
const node = await dimensionNode('832×1216 - portrait');
|
||||||
|
node.swapDimensions();
|
||||||
|
assert.deepEqual(node.widgets.map(widget => widget.value), ['1216×832 - landscape', 1216, 832]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a preset without a reverse switches to custom dimensions', async () => {
|
||||||
|
const node = await dimensionNode('832×1216 - portrait', ['custom', '832×1216 - portrait']);
|
||||||
|
node.swapDimensions();
|
||||||
|
assert.deepEqual(node.widgets.map(widget => widget.value), ['custom', 1216, 832]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('preset changes preserve original callbacks and update both dimensions', async () => {
|
||||||
|
const node = await dimensionNode('custom');
|
||||||
|
node.widgets[0].callback('1216×832 - landscape', {}, node);
|
||||||
|
assert.deepEqual(node.widgets.slice(1).map(widget => widget.value), [1216, 832]);
|
||||||
|
assert.equal(node.extractResolutionFromPreset('custom'), null);
|
||||||
|
assert.equal(node.originalPresetCalls, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('unrelated node definitions retain their lifecycle methods', async () => {
|
||||||
|
const { extension, app } = load('width_height_swap.js');
|
||||||
|
class Node { onNodeCreated() {} }
|
||||||
|
const original = Node.prototype.onNodeCreated;
|
||||||
|
await extension.beforeRegisterNodeDef(Node, { name: 'OtherNode' }, app);
|
||||||
|
assert.equal(Node.prototype.onNodeCreated, original);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Gemini repeated execution restores the user color and removal cancels its timer', async () => {
|
||||||
|
const { extension, app, timers } = load('gemini_prompt_ui.js');
|
||||||
|
let removed = 0;
|
||||||
|
class Node { onRemoved() { removed++; } }
|
||||||
|
await extension.beforeRegisterNodeDef(Node, { name: 'GeminiPrompt' }, app);
|
||||||
|
const node = new Node();
|
||||||
|
node.status = { value: 'Ready' };
|
||||||
|
node.bgcolor = '#123456';
|
||||||
|
node.onExecuted({});
|
||||||
|
node.onExecuted({ output: { prompt: ['Error: unavailable'] } });
|
||||||
|
assert.equal(timers.size, 1);
|
||||||
|
assert.equal(node.bgcolor, '#552222');
|
||||||
|
[...timers.values()][0]();
|
||||||
|
assert.equal(node.bgcolor, '#123456');
|
||||||
|
assert.equal(node.status.value, 'Ready');
|
||||||
|
timers.clear();
|
||||||
|
node.onExecuted({});
|
||||||
|
node.onRemoved();
|
||||||
|
assert.equal(timers.size, 0);
|
||||||
|
assert.equal(removed, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('execution following respects enablement and ignores missing nodes', async () => {
|
||||||
|
const settings = new Map();
|
||||||
|
const listeners = new Map();
|
||||||
|
const centered = [];
|
||||||
|
const extensions = [];
|
||||||
|
const node = { id: '7', type: 'DisplayAny', title: 'Display' };
|
||||||
|
const app = {
|
||||||
|
registerExtension: extension => extensions.push(extension),
|
||||||
|
ui: { settings: { addSetting: setting => settings.set(setting.id, setting.defaultValue), getSettingValue: id => settings.get(id) } },
|
||||||
|
graph: { _nodes: [node], getNodeById: id => id === node.id ? node : undefined },
|
||||||
|
canvas: { centerOnNode: node => centered.push(node) }, runningNodeId: '7',
|
||||||
|
};
|
||||||
|
load('kiko_follow_execution.js', { app, api: { addEventListener: (name, callback) => listeners.set(name, callback) } });
|
||||||
|
const extension = extensions[0];
|
||||||
|
await extension.init();
|
||||||
|
await extension.setup();
|
||||||
|
assert.equal(extension.getCanvasMenuItems().length, 0);
|
||||||
|
settings.set('kikotools.follow_execution.enabled', true);
|
||||||
|
settings.set('kikotools.follow_execution.auto_start', true);
|
||||||
|
listeners.get('execution_start')();
|
||||||
|
listeners.get('executing')({ detail: '7' });
|
||||||
|
listeners.get('executing')({ detail: 'missing' });
|
||||||
|
assert.deepEqual(centered, [node]);
|
||||||
|
settings.set('kikotools.follow_execution.enabled', false);
|
||||||
|
listeners.get('execution_start')();
|
||||||
|
listeners.get('executing')({ detail: '7' });
|
||||||
|
assert.equal(centered.length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test('gallery HTML escaping handles filenames and attribute delimiters', () => {
|
||||||
|
const { context } = load('kiko_local_image_loader.js', { document: { getElementById: () => ({}) } });
|
||||||
|
const escape = vm.runInContext('escapeHtml', context);
|
||||||
|
assert.equal(escape(null), '');
|
||||||
|
assert.equal(escape(`<img src="x" onerror='run()'>&`), '<img src="x" onerror='run()'>&');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('gallery HTTP errors preserve actionable server detail and handle non-JSON responses', async () => {
|
||||||
|
const { context } = load('kiko_local_image_loader.js', { document: { getElementById: () => ({}) } });
|
||||||
|
const describe = vm.runInContext('describeHttpError', context);
|
||||||
|
assert.equal(await describe({ status: 403, json: async () => ({ error: 'Choose an allowed root' }) }), 'Choose an allowed root');
|
||||||
|
assert.match(await describe({ status: 403, json: async () => { throw new Error('not JSON'); } }), /allowed folders/);
|
||||||
|
assert.match(await describe({ status: 400, json: async () => ({}) }), /Invalid path/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('gallery HTTP errors cover null bodies, message details, and generic status fallbacks', async () => {
|
||||||
|
const { context } = load('kiko_local_image_loader.js', { document: { getElementById: () => ({}) } });
|
||||||
|
const describe = vm.runInContext('describeHttpError', context);
|
||||||
|
for (const [status, body, expected] of [
|
||||||
|
[400, { error: 'Invalid directory' }, 'Invalid directory'],
|
||||||
|
[403, { message: 'Not an allowed root' }, 'Not an allowed root'],
|
||||||
|
[400, null, 'Invalid path or request'],
|
||||||
|
[500, { error: 'Storage unavailable' }, 'Storage unavailable'],
|
||||||
|
[404, { message: 'Missing image' }, 'Missing image'],
|
||||||
|
[502, null, 'Request failed (HTTP 502)'],
|
||||||
|
[503, {}, 'Request failed (HTTP 503)'],
|
||||||
|
]) assert.equal(await describe({ status, json: async () => body }), expected);
|
||||||
|
});
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { isFixtureURL } from '../../tools/testing/network-policy.mjs';
|
||||||
|
const base = 'http://127.0.0.1:8766';
|
||||||
|
test('the network guard allows the test origin and WebKit local blob URLs', () => {
|
||||||
|
assert.equal(isFixtureURL(`${base}/extensions/kikotools/display_any.js`, base), true);
|
||||||
|
assert.equal(isFixtureURL(`blob:${base}/local-script`, base), true);
|
||||||
|
});
|
||||||
|
test('the network guard denies external destinations and other localhost ports', () => {
|
||||||
|
for (const url of ['https://example.com/model', 'http://127.0.0.1:9000/private', 'blob:https://example.com/script', 'data:text/plain,fixture']) {
|
||||||
|
assert.equal(isFixtureURL(url, base), false, url);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
"""Ensure the documented test command actually invokes pytest and fails closed."""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import shlex
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
os.name == "nt" or not shutil.which("make"), reason="Requires POSIX make"
|
||||||
|
)
|
||||||
|
def test_make_test_runs_pytest_and_propagates_failure(tmp_path: Path) -> None:
|
||||||
|
recorder = tmp_path / "runner.py"
|
||||||
|
arguments = tmp_path / "arguments.json"
|
||||||
|
recorder.write_text(
|
||||||
|
"import json,sys\n"
|
||||||
|
f"with open({str(arguments)!r}, 'w') as output:\n"
|
||||||
|
" json.dump(sys.argv[1:], output)\n"
|
||||||
|
"sys.exit(7)\n",
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
result = subprocess.run(
|
||||||
|
[
|
||||||
|
"make",
|
||||||
|
"--no-print-directory",
|
||||||
|
"-o",
|
||||||
|
"venv",
|
||||||
|
"test",
|
||||||
|
f"PYTHON_CMD={shlex.join([sys.executable, str(recorder)])}",
|
||||||
|
],
|
||||||
|
cwd=Path(__file__).resolve().parents[1],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
assert json.loads(arguments.read_text()) == ["-m", "pytest", "tests"]
|
||||||
|
assert result.returncode != 0
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
"""Tests for the shared model-folder scanner."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
from kikotools.base.model_folders import scan_model_entries, natural_sort
|
||||||
|
|
||||||
|
|
||||||
|
def _touch(path):
|
||||||
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||||
|
with open(path, "w") as f:
|
||||||
|
f.write("x")
|
||||||
|
|
||||||
|
|
||||||
|
def _fake_folder_paths(key, *roots):
|
||||||
|
fp = MagicMock()
|
||||||
|
fp.folder_names_and_paths = {key: [list(roots)]}
|
||||||
|
return patch.dict(sys.modules, {"folder_paths": fp})
|
||||||
|
|
||||||
|
|
||||||
|
class TestScanModelEntries:
|
||||||
|
def test_scans_the_requested_folder_key(self, tmp_path):
|
||||||
|
ckpt = tmp_path / "checkpoints"
|
||||||
|
_touch(str(ckpt / "Illustrious" / "b_v2.safetensors"))
|
||||||
|
_touch(str(ckpt / "Illustrious" / "a_v10.safetensors"))
|
||||||
|
_touch(str(ckpt / "Illustrious" / "notes.md"))
|
||||||
|
with _fake_folder_paths("checkpoints", str(ckpt)):
|
||||||
|
entries = scan_model_entries("Illustrious", "checkpoints")
|
||||||
|
assert [name for name, _ in entries] == [
|
||||||
|
"Illustrious/a_v10.safetensors",
|
||||||
|
"Illustrious/b_v2.safetensors",
|
||||||
|
]
|
||||||
|
assert entries[0][1] == str(ckpt / "Illustrious" / "a_v10.safetensors")
|
||||||
|
|
||||||
|
def test_relative_folder_escaping_the_root_is_ignored(self, tmp_path):
|
||||||
|
ckpt = tmp_path / "checkpoints"
|
||||||
|
_touch(str(tmp_path / "outside" / "x.safetensors"))
|
||||||
|
with _fake_folder_paths("checkpoints", str(ckpt)):
|
||||||
|
assert scan_model_entries("../outside", "checkpoints") == []
|
||||||
|
|
||||||
|
def test_unknown_key_returns_empty(self, tmp_path):
|
||||||
|
with _fake_folder_paths("loras", str(tmp_path)):
|
||||||
|
assert scan_model_entries(".", "checkpoints") == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_natural_sort_orders_numbers_numerically():
|
||||||
|
assert natural_sort(["v10", "v2", "v1"]) == ["v1", "v2", "v10"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_natural_sort_ignores_case():
|
||||||
|
assert natural_sort(["IllustrijGEN3", "aij_v10", "Illustrijv21", "animij_v6"]) == [
|
||||||
|
"aij_v10",
|
||||||
|
"animij_v6",
|
||||||
|
"IllustrijGEN3",
|
||||||
|
"Illustrijv21",
|
||||||
|
]
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
"""Tests for Checkpoint Folder Iterator logic."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from kikotools.tools.checkpoint_folder_iterator.logic import (
|
||||||
|
label_for,
|
||||||
|
list_checkpoint_entries,
|
||||||
|
list_checkpoints,
|
||||||
|
pick_checkpoint,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _touch(path):
|
||||||
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||||
|
with open(path, "w") as f:
|
||||||
|
f.write("x")
|
||||||
|
|
||||||
|
|
||||||
|
def _fake_checkpoints(root):
|
||||||
|
fp = MagicMock()
|
||||||
|
fp.folder_names_and_paths = {"checkpoints": [[str(root)]]}
|
||||||
|
return patch.dict(sys.modules, {"folder_paths": fp})
|
||||||
|
|
||||||
|
|
||||||
|
class TestListCheckpoints:
|
||||||
|
def test_lists_safetensors_in_natural_order(self, tmp_path):
|
||||||
|
for name in ("illustrij_v20", "illustrij_v3", "ilustmix_v9"):
|
||||||
|
_touch(str(tmp_path / "Illustrious" / f"{name}.safetensors"))
|
||||||
|
_touch(str(tmp_path / "Illustrious" / "illustrij_v20.jpeg"))
|
||||||
|
with _fake_checkpoints(tmp_path):
|
||||||
|
names = list_checkpoints("Illustrious")
|
||||||
|
assert names == [
|
||||||
|
"Illustrious/illustrij_v3.safetensors",
|
||||||
|
"Illustrious/illustrij_v20.safetensors",
|
||||||
|
"Illustrious/ilustmix_v9.safetensors",
|
||||||
|
]
|
||||||
|
|
||||||
|
def test_include_and_exclude_patterns(self, tmp_path):
|
||||||
|
for name in ("a_v1", "a_v2", "b_v1"):
|
||||||
|
_touch(str(tmp_path / "X" / f"{name}.safetensors"))
|
||||||
|
with _fake_checkpoints(tmp_path):
|
||||||
|
names = list_checkpoints("X", include_pattern="^X/a_", exclude_pattern="v2")
|
||||||
|
assert names == ["X/a_v1.safetensors"]
|
||||||
|
|
||||||
|
|
||||||
|
class TestListCheckpointEntries:
|
||||||
|
def test_pairs_each_name_with_its_absolute_path(self, tmp_path):
|
||||||
|
_touch(str(tmp_path / "X" / "a_v1.safetensors"))
|
||||||
|
with _fake_checkpoints(tmp_path):
|
||||||
|
entries = list_checkpoint_entries("X")
|
||||||
|
assert entries == [
|
||||||
|
("X/a_v1.safetensors", str(tmp_path / "X" / "a_v1.safetensors"))
|
||||||
|
]
|
||||||
|
|
||||||
|
def test_patterns_apply_to_entries_too(self, tmp_path):
|
||||||
|
for name in ("a_v1", "a_v2", "b_v1"):
|
||||||
|
_touch(str(tmp_path / "X" / f"{name}.safetensors"))
|
||||||
|
with _fake_checkpoints(tmp_path):
|
||||||
|
entries = list_checkpoint_entries("X", "^X/a_", "v2")
|
||||||
|
assert [name for name, _ in entries] == ["X/a_v1.safetensors"]
|
||||||
|
|
||||||
|
def test_absolute_folder_outside_roots_keeps_real_paths(self, tmp_path):
|
||||||
|
root = tmp_path / "models" / "checkpoints"
|
||||||
|
elsewhere = tmp_path / "external_drive" / "ckpts"
|
||||||
|
_touch(str(elsewhere / "ext_v1.safetensors"))
|
||||||
|
with _fake_checkpoints(root):
|
||||||
|
entries = list_checkpoint_entries(str(elsewhere))
|
||||||
|
assert entries == [
|
||||||
|
("ext_v1.safetensors", str(elsewhere / "ext_v1.safetensors"))
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class TestPickCheckpoint:
|
||||||
|
def test_returns_the_indexed_item(self):
|
||||||
|
names = ["a", "b", "c"]
|
||||||
|
assert pick_checkpoint(names, 0) == "a"
|
||||||
|
assert pick_checkpoint(names, 2) == "c"
|
||||||
|
|
||||||
|
def test_index_past_the_end_raises_instead_of_wrapping(self):
|
||||||
|
with pytest.raises(ValueError, match="past the end.*3 checkpoints"):
|
||||||
|
pick_checkpoint(["a", "b", "c"], 3)
|
||||||
|
|
||||||
|
def test_negative_index_raises(self):
|
||||||
|
with pytest.raises(ValueError, match="past the end"):
|
||||||
|
pick_checkpoint(["a"], -1)
|
||||||
|
|
||||||
|
def test_empty_list_raises(self):
|
||||||
|
with pytest.raises(ValueError, match="No checkpoints"):
|
||||||
|
pick_checkpoint([], 0)
|
||||||
|
|
||||||
|
|
||||||
|
class TestLabelFor:
|
||||||
|
def test_default_label_is_the_file_stem(self):
|
||||||
|
assert label_for("Illustrious/illustrij_v20.safetensors") == "illustrij_v20"
|
||||||
|
assert label_for("Illustrious/reijlita/x_v1.safetensors") == "x_v1"
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
"""Tests for the Checkpoint Folder Iterator node."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from kikotools.tools.checkpoint_folder_iterator import CheckpointFolderIteratorNode
|
||||||
|
|
||||||
|
NODE = "kikotools.tools.checkpoint_folder_iterator.node"
|
||||||
|
ENTRIES = [
|
||||||
|
("X/a_v1.safetensors", "/models/checkpoints/X/a_v1.safetensors"),
|
||||||
|
("X/b_v2.safetensors", "/models/checkpoints/X/b_v2.safetensors"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _fake_comfy_modules():
|
||||||
|
fp = MagicMock()
|
||||||
|
fp.get_folder_paths = MagicMock(return_value=["/models/embeddings"])
|
||||||
|
comfy = MagicMock()
|
||||||
|
comfy.sd.load_checkpoint_guess_config = MagicMock(
|
||||||
|
return_value=("MODEL", "CLIP", "VAE", "extra")
|
||||||
|
)
|
||||||
|
return (
|
||||||
|
patch.dict(
|
||||||
|
sys.modules, {"folder_paths": fp, "comfy": comfy, "comfy.sd": comfy.sd}
|
||||||
|
),
|
||||||
|
fp,
|
||||||
|
comfy,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestCheckpointFolderIteratorNode:
|
||||||
|
def test_input_index_increments_after_generate(self):
|
||||||
|
index = CheckpointFolderIteratorNode.INPUT_TYPES()["required"]["index"]
|
||||||
|
assert index[0] == "INT"
|
||||||
|
assert index[1]["control_after_generate"] is True
|
||||||
|
|
||||||
|
def test_loads_the_indexed_checkpoint_from_its_scanned_path(self):
|
||||||
|
ctx, fp, comfy = _fake_comfy_modules()
|
||||||
|
with ctx, patch(f"{NODE}.list_checkpoint_entries", return_value=ENTRIES):
|
||||||
|
out = CheckpointFolderIteratorNode().load("X", 1, "", "")
|
||||||
|
comfy.sd.load_checkpoint_guess_config.assert_called_once()
|
||||||
|
assert comfy.sd.load_checkpoint_guess_config.call_args.args == (
|
||||||
|
"/models/checkpoints/X/b_v2.safetensors",
|
||||||
|
)
|
||||||
|
fp.get_full_path_or_raise.assert_not_called()
|
||||||
|
assert out == ("MODEL", "CLIP", "VAE", "X/b_v2.safetensors", "b_v2", 1, 2)
|
||||||
|
|
||||||
|
def test_absolute_folder_outside_models_dir_loads_by_real_path(self):
|
||||||
|
ctx, _, comfy = _fake_comfy_modules()
|
||||||
|
external = [("ext_v1.safetensors", "/mnt/drive/ckpts/ext_v1.safetensors")]
|
||||||
|
with ctx, patch(f"{NODE}.list_checkpoint_entries", return_value=external):
|
||||||
|
out = CheckpointFolderIteratorNode().load("/mnt/drive/ckpts", 0, "", "")
|
||||||
|
assert comfy.sd.load_checkpoint_guess_config.call_args.args == (
|
||||||
|
"/mnt/drive/ckpts/ext_v1.safetensors",
|
||||||
|
)
|
||||||
|
assert out[3:] == ("ext_v1.safetensors", "ext_v1", 0, 1)
|
||||||
|
|
||||||
|
def test_index_past_the_end_raises_instead_of_restarting(self):
|
||||||
|
ctx, _, comfy = _fake_comfy_modules()
|
||||||
|
with ctx, patch(f"{NODE}.list_checkpoint_entries", return_value=ENTRIES):
|
||||||
|
with pytest.raises(ValueError, match="past the end"):
|
||||||
|
CheckpointFolderIteratorNode().load("X", 2, "", "")
|
||||||
|
comfy.sd.load_checkpoint_guess_config.assert_not_called()
|
||||||
|
|
||||||
|
def test_empty_folder_raises_clear_error(self):
|
||||||
|
ctx, _, _ = _fake_comfy_modules()
|
||||||
|
with ctx, patch(f"{NODE}.list_checkpoint_entries", return_value=[]):
|
||||||
|
with pytest.raises(ValueError, match="No checkpoints"):
|
||||||
|
CheckpointFolderIteratorNode().load("Empty", 0, "", "")
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
"""Tests for Model Compare Sheet logic."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
from kikotools.tools.model_compare_sheet.logic import (
|
||||||
|
build_contact_sheet,
|
||||||
|
label_from_filename,
|
||||||
|
list_tiles,
|
||||||
|
resolve_run_dir,
|
||||||
|
tile_filename,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestResolveRunDir:
|
||||||
|
def test_run_dir_lives_under_model_compare(self, tmp_path):
|
||||||
|
assert resolve_run_dir(str(tmp_path), "illustrious") == os.path.join(
|
||||||
|
str(tmp_path), "model_compare", "illustrious"
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_nested_run_names_are_allowed(self, tmp_path):
|
||||||
|
assert resolve_run_dir(str(tmp_path), "proj/2026-10-15/sweep") == os.path.join(
|
||||||
|
str(tmp_path), "model_compare", "proj", "2026-10-15", "sweep"
|
||||||
|
)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"bad",
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"../escape",
|
||||||
|
"/abs/path",
|
||||||
|
"a/../../b",
|
||||||
|
"..\\escape",
|
||||||
|
"a\\..\\..\\b",
|
||||||
|
"C:\\abs",
|
||||||
|
".",
|
||||||
|
"./x",
|
||||||
|
"a/./b",
|
||||||
|
"a//b",
|
||||||
|
"x/..",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_rejects_names_that_leave_model_compare(self, tmp_path, bad):
|
||||||
|
with pytest.raises(ValueError, match="run_name"):
|
||||||
|
resolve_run_dir(str(tmp_path), bad)
|
||||||
|
|
||||||
|
def test_rejects_symlink_escape_into_another_output_folder(self, tmp_path):
|
||||||
|
base = tmp_path / "model_compare"
|
||||||
|
base.mkdir()
|
||||||
|
outside = tmp_path / "unrelated"
|
||||||
|
outside.mkdir()
|
||||||
|
try:
|
||||||
|
(base / "link").symlink_to(outside, target_is_directory=True)
|
||||||
|
except OSError as exc:
|
||||||
|
pytest.skip(f"Directory symlinks unavailable: {exc}")
|
||||||
|
with pytest.raises(ValueError, match="run_name"):
|
||||||
|
resolve_run_dir(str(tmp_path), "link/run")
|
||||||
|
|
||||||
|
|
||||||
|
class TestTileFilename:
|
||||||
|
def test_single_image_run(self):
|
||||||
|
assert tile_filename(3, "illustrij_v20", 0, 1) == "03_illustrij_v20.png"
|
||||||
|
|
||||||
|
def test_batch_gets_a_suffix(self):
|
||||||
|
assert tile_filename(3, "illustrij_v20", 1, 2) == "03_illustrij_v20_2.png"
|
||||||
|
|
||||||
|
def test_label_characters_are_sanitized(self):
|
||||||
|
assert tile_filename(0, "a/b:c d", 0, 1) == "00_a_b_c_d.png"
|
||||||
|
|
||||||
|
|
||||||
|
def test_label_from_filename_strips_index_and_extension():
|
||||||
|
assert label_from_filename("03_illustrij_v20.png") == "illustrij_v20"
|
||||||
|
assert label_from_filename("03_illustrij_v20_2.png") == "illustrij_v20_2"
|
||||||
|
assert label_from_filename("grid.png") == "grid"
|
||||||
|
|
||||||
|
|
||||||
|
def test_list_tiles_skips_grid_and_sorts_naturally(tmp_path):
|
||||||
|
for name in ("10_b.png", "2_a.png", "grid.png", "grid_preview.png", "notes.txt"):
|
||||||
|
(tmp_path / name).write_bytes(b"")
|
||||||
|
assert list_tiles(str(tmp_path)) == [
|
||||||
|
str(tmp_path / "2_a.png"),
|
||||||
|
str(tmp_path / "10_b.png"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class TestBuildContactSheet:
|
||||||
|
def _tiles(self, tmp_path, n, size=(100, 200)):
|
||||||
|
paths = []
|
||||||
|
for i in range(n):
|
||||||
|
p = tmp_path / f"{i:02d}_m{i}.png"
|
||||||
|
Image.new("RGB", size, (i * 40, 0, 0)).save(p)
|
||||||
|
paths.append(str(p))
|
||||||
|
return paths
|
||||||
|
|
||||||
|
def test_grid_dimensions_follow_columns_and_tile_width(self, tmp_path):
|
||||||
|
paths = self._tiles(tmp_path, 3)
|
||||||
|
sheet = build_contact_sheet(paths, columns=2, tile_width=50, font_size=10)
|
||||||
|
# 3 tiles in 2 columns = 2 rows; tiles scale to 50x100; label band 2*font
|
||||||
|
assert sheet.size == (100, 2 * (100 + 20))
|
||||||
|
|
||||||
|
def test_fewer_tiles_than_columns_shrinks_width(self, tmp_path):
|
||||||
|
paths = self._tiles(tmp_path, 1)
|
||||||
|
sheet = build_contact_sheet(paths, columns=5, tile_width=50, font_size=10)
|
||||||
|
assert sheet.size == (50, 100 + 20)
|
||||||
|
|
||||||
|
def test_label_band_is_drawn(self, tmp_path):
|
||||||
|
paths = self._tiles(tmp_path, 1)
|
||||||
|
sheet = build_contact_sheet(paths, columns=1, tile_width=50, font_size=10)
|
||||||
|
band = sheet.crop((0, 100, 50, 120))
|
||||||
|
assert len(band.getcolors(maxcolors=4096) or []) > 1
|
||||||
@@ -0,0 +1,329 @@
|
|||||||
|
"""Tests for the Model Compare Sheet node."""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import sys
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
import torch
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
from kikotools.tools.model_compare_sheet import ModelCompareSheetNode
|
||||||
|
|
||||||
|
|
||||||
|
def _fake_output_dir(path):
|
||||||
|
fp = MagicMock()
|
||||||
|
fp.get_output_directory = MagicMock(return_value=str(path))
|
||||||
|
return patch.dict(sys.modules, {"folder_paths": fp})
|
||||||
|
|
||||||
|
|
||||||
|
def _image(batch=1, h=64, w=32):
|
||||||
|
return torch.rand(batch, h, w, 3)
|
||||||
|
|
||||||
|
|
||||||
|
class TestModelCompareSheetNode:
|
||||||
|
def test_is_an_output_node(self):
|
||||||
|
assert ModelCompareSheetNode.OUTPUT_NODE is True
|
||||||
|
|
||||||
|
def test_saves_tile_and_grid_and_returns_grid(self, tmp_path):
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
out = ModelCompareSheetNode().collect(
|
||||||
|
_image(), "illustrij_v20", 3, "run1", 4, 32, 8
|
||||||
|
)
|
||||||
|
run_dir = tmp_path / "model_compare" / "run1"
|
||||||
|
assert (run_dir / "03_illustrij_v20.png").exists()
|
||||||
|
assert (run_dir / "grid.png").exists()
|
||||||
|
grid = out["result"][0]
|
||||||
|
assert grid.shape == (1, 64 + 16, 32, 3)
|
||||||
|
assert out["ui"]["images"][0]["filename"] == "grid_preview.png"
|
||||||
|
assert out["ui"]["images"][0]["subfolder"] == os.path.join(
|
||||||
|
"model_compare", "run1"
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_grid_grows_across_runs(self, tmp_path):
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
node = ModelCompareSheetNode()
|
||||||
|
node.collect(_image(), "a", 0, "run1", 4, 32, 8)
|
||||||
|
out = node.collect(_image(), "b", 1, "run1", 4, 32, 8)
|
||||||
|
assert out["result"][0].shape == (1, 64 + 16, 64, 3)
|
||||||
|
|
||||||
|
def test_batch_saves_every_image(self, tmp_path):
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
ModelCompareSheetNode().collect(_image(batch=2), "a", 0, "run1", 4, 32, 8)
|
||||||
|
run_dir = tmp_path / "model_compare" / "run1"
|
||||||
|
assert (run_dir / "00_a_1.png").exists()
|
||||||
|
assert (run_dir / "00_a_2.png").exists()
|
||||||
|
assert Image.open(run_dir / "grid.png").size == (64, 64 + 16)
|
||||||
|
|
||||||
|
def test_rerun_of_same_index_overwrites_instead_of_duplicating(self, tmp_path):
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
node = ModelCompareSheetNode()
|
||||||
|
node.collect(_image(), "a", 0, "run1", 4, 32, 8)
|
||||||
|
out = node.collect(_image(), "a", 0, "run1", 4, 32, 8)
|
||||||
|
assert out["result"][0].shape[2] == 32
|
||||||
|
|
||||||
|
|
||||||
|
class TestArchiveOnNewSweep:
|
||||||
|
def test_index_zero_archives_the_previous_sweep(self, tmp_path):
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
node = ModelCompareSheetNode()
|
||||||
|
node.collect(_image(), "a", 0, "run1", 4, 32, 8)
|
||||||
|
node.collect(_image(), "b", 1, "run1", 4, 32, 8)
|
||||||
|
out = node.collect(_image(), "c", 0, "run1", 4, 32, 8)
|
||||||
|
run_dir = tmp_path / "model_compare" / "run1"
|
||||||
|
assert sorted(p.name for p in run_dir.iterdir()) == [
|
||||||
|
"00_c.png",
|
||||||
|
"grid.png",
|
||||||
|
"grid_preview.png",
|
||||||
|
]
|
||||||
|
assert out["result"][0].shape[2] == 32
|
||||||
|
archived = [p for p in run_dir.parent.iterdir() if p.name.startswith("run1_")]
|
||||||
|
assert len(archived) == 1
|
||||||
|
assert sorted(p.name for p in archived[0].iterdir()) == [
|
||||||
|
"00_a.png",
|
||||||
|
"01_b.png",
|
||||||
|
"grid.png",
|
||||||
|
"grid_preview.png",
|
||||||
|
]
|
||||||
|
|
||||||
|
def test_nonzero_index_keeps_existing_tiles(self, tmp_path):
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
node = ModelCompareSheetNode()
|
||||||
|
node.collect(_image(), "a", 0, "run1", 4, 32, 8)
|
||||||
|
node.collect(_image(), "b", 3, "run1", 4, 32, 8)
|
||||||
|
run_dir = tmp_path / "model_compare" / "run1"
|
||||||
|
assert sorted(p.name for p in run_dir.iterdir()) == [
|
||||||
|
"00_a.png",
|
||||||
|
"03_b.png",
|
||||||
|
"grid.png",
|
||||||
|
"grid_preview.png",
|
||||||
|
]
|
||||||
|
|
||||||
|
def test_index_zero_on_empty_folder_archives_nothing(self, tmp_path):
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
ModelCompareSheetNode().collect(_image(), "a", 0, "run1", 4, 32, 8)
|
||||||
|
assert [p.name for p in (tmp_path / "model_compare").iterdir()] == ["run1"]
|
||||||
|
|
||||||
|
|
||||||
|
class TestPreview:
|
||||||
|
def test_ui_preview_is_downscaled_but_grid_and_output_stay_full_size(
|
||||||
|
self, tmp_path
|
||||||
|
):
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
out = ModelCompareSheetNode().collect(
|
||||||
|
_image(h=64, w=32), "a", 0, "run1", 1, 1200, 8
|
||||||
|
)
|
||||||
|
run_dir = tmp_path / "model_compare" / "run1"
|
||||||
|
assert Image.open(run_dir / "grid.png").size[0] == 1200
|
||||||
|
assert Image.open(run_dir / "grid_preview.png").size[0] == 1024
|
||||||
|
assert out["result"][0].shape[2] == 1200
|
||||||
|
assert out["ui"]["images"][0]["filename"] == "grid_preview.png"
|
||||||
|
|
||||||
|
def test_small_grid_preview_is_not_upscaled(self, tmp_path):
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
ModelCompareSheetNode().collect(_image(), "a", 0, "run1", 1, 32, 8)
|
||||||
|
run_dir = tmp_path / "model_compare" / "run1"
|
||||||
|
assert Image.open(run_dir / "grid_preview.png").size[0] == 32
|
||||||
|
|
||||||
|
|
||||||
|
class TestReplaceIndex:
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"old_batch, old_label, new_batch, new_label, expected",
|
||||||
|
[
|
||||||
|
(2, "a", 1, "a", ["01_a.png"]),
|
||||||
|
(1, "a", 1, "b", ["01_b.png"]),
|
||||||
|
(1, "a", 1, "A", ["01_A.png"]),
|
||||||
|
(2, "a", 3, "b", ["01_b_1.png", "01_b_2.png", "01_b_3.png"]),
|
||||||
|
(1, "a", 2, "a", ["01_a_1.png", "01_a_2.png"]),
|
||||||
|
(3, "a", 2, "a", ["01_a_1.png", "01_a_2.png"]),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_rerun_replaces_only_its_index(
|
||||||
|
self,
|
||||||
|
tmp_path: Path,
|
||||||
|
old_batch: int,
|
||||||
|
old_label: str,
|
||||||
|
new_batch: int,
|
||||||
|
new_label: str,
|
||||||
|
expected: list[str],
|
||||||
|
) -> None:
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
node = ModelCompareSheetNode()
|
||||||
|
node.collect(_image(), "first", 0, "run1", 8, 32, 8)
|
||||||
|
node.collect(_image(batch=old_batch), old_label, 1, "run1", 8, 32, 8)
|
||||||
|
node.collect(_image(), "neighbor", 10, "run1", 8, 32, 8)
|
||||||
|
run_dir = tmp_path / "model_compare" / "run1"
|
||||||
|
untouched = {
|
||||||
|
name: (run_dir / name).read_bytes()
|
||||||
|
for name in ("00_first.png", "10_neighbor.png")
|
||||||
|
}
|
||||||
|
(run_dir / "notes.txt").write_text("keep this note")
|
||||||
|
archived = run_dir.parent / "run1_archived"
|
||||||
|
archived.mkdir()
|
||||||
|
(archived / "01_a.png").write_bytes(b"archived tile")
|
||||||
|
result = node.collect(
|
||||||
|
torch.ones(new_batch, 64, 32, 3),
|
||||||
|
new_label,
|
||||||
|
1,
|
||||||
|
"run1",
|
||||||
|
8,
|
||||||
|
32,
|
||||||
|
8,
|
||||||
|
prompt={"model": "replacement"},
|
||||||
|
extra_pnginfo={"workflow": {"id": "retry"}},
|
||||||
|
)
|
||||||
|
assert sorted(path.name for path in run_dir.glob("01_*.png")) == expected
|
||||||
|
assert result["result"][0].shape == (1, 80, (new_batch + 2) * 32, 3)
|
||||||
|
assert sorted(path.name for path in run_dir.iterdir()) == sorted(
|
||||||
|
[
|
||||||
|
"00_first.png",
|
||||||
|
"10_neighbor.png",
|
||||||
|
"grid.png",
|
||||||
|
"grid_preview.png",
|
||||||
|
"notes.txt",
|
||||||
|
*expected,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
for name, data in untouched.items():
|
||||||
|
assert (run_dir / name).read_bytes() == data
|
||||||
|
assert (run_dir / "notes.txt").read_text() == "keep this note"
|
||||||
|
assert (archived / "01_a.png").read_bytes() == b"archived tile"
|
||||||
|
for name in expected:
|
||||||
|
with Image.open(run_dir / name) as image:
|
||||||
|
assert image.getpixel((0, 0)) == (255, 255, 255)
|
||||||
|
assert json.loads(image.info["prompt"]) == {"model": "replacement"}
|
||||||
|
assert json.loads(image.info["workflow"]) == {"id": "retry"}
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("index", [0, 1])
|
||||||
|
@pytest.mark.parametrize("failed_image", [1, 2])
|
||||||
|
def test_failed_tile_write_preserves_the_existing_batch_and_grid(
|
||||||
|
self, tmp_path: Path, index: int, failed_image: int
|
||||||
|
) -> None:
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
node = ModelCompareSheetNode()
|
||||||
|
node.collect(torch.zeros(2, 64, 32, 3), "same", index, "run1", 8, 32, 8)
|
||||||
|
base = tmp_path / "model_compare"
|
||||||
|
before = {
|
||||||
|
str(path.relative_to(base)): path.read_bytes()
|
||||||
|
for path in base.rglob("*")
|
||||||
|
if path.is_file()
|
||||||
|
}
|
||||||
|
original_save = Image.Image.save
|
||||||
|
tile_writes = 0
|
||||||
|
|
||||||
|
def fail_tile_write(image, path, *args, **kwargs):
|
||||||
|
nonlocal tile_writes
|
||||||
|
if Path(path).name.startswith(f"{index:02d}_"):
|
||||||
|
tile_writes += 1
|
||||||
|
if tile_writes == failed_image:
|
||||||
|
raise OSError("disk full")
|
||||||
|
return original_save(image, path, *args, **kwargs)
|
||||||
|
|
||||||
|
with patch.object(Image.Image, "save", new=fail_tile_write):
|
||||||
|
with pytest.raises(OSError, match="disk full"):
|
||||||
|
node.collect(
|
||||||
|
torch.ones(2, 64, 32, 3), "same", index, "run1", 8, 32, 8
|
||||||
|
)
|
||||||
|
assert {
|
||||||
|
str(path.relative_to(base)): path.read_bytes()
|
||||||
|
for path in base.rglob("*")
|
||||||
|
if path.is_file()
|
||||||
|
} == before
|
||||||
|
assert list(base.iterdir()) == [base / "run1"]
|
||||||
|
|
||||||
|
def test_empty_batch_does_not_remove_existing_tiles(self, tmp_path: Path) -> None:
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
node = ModelCompareSheetNode()
|
||||||
|
node.collect(_image(), "a", 1, "run1", 8, 32, 8)
|
||||||
|
run_dir = tmp_path / "model_compare" / "run1"
|
||||||
|
before = {path.name: path.read_bytes() for path in run_dir.iterdir()}
|
||||||
|
with pytest.raises(ValueError, match="at least one image"):
|
||||||
|
node.collect(torch.empty(0, 64, 32, 3), "b", 1, "run1", 8, 32, 8)
|
||||||
|
assert {path.name: path.read_bytes() for path in run_dir.iterdir()} == before
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("failed_image", [1, 2])
|
||||||
|
def test_failed_publication_restores_the_previous_batch(
|
||||||
|
self, tmp_path: Path, failed_image: int
|
||||||
|
) -> None:
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
node = ModelCompareSheetNode()
|
||||||
|
node.collect(torch.zeros(2, 64, 32, 3), "same", 1, "run1", 8, 32, 8)
|
||||||
|
base = tmp_path / "model_compare"
|
||||||
|
run_dir = base / "run1"
|
||||||
|
before = {
|
||||||
|
str(path.relative_to(base)): path.read_bytes()
|
||||||
|
for path in base.rglob("*")
|
||||||
|
if path.is_file()
|
||||||
|
}
|
||||||
|
original_replace = os.replace
|
||||||
|
published = 0
|
||||||
|
|
||||||
|
def fail_publication(source, destination):
|
||||||
|
nonlocal published
|
||||||
|
if (
|
||||||
|
Path(destination).parent == run_dir
|
||||||
|
and Path(source).parent.name != "previous"
|
||||||
|
):
|
||||||
|
published += 1
|
||||||
|
if published == failed_image:
|
||||||
|
raise OSError("publication failed")
|
||||||
|
return original_replace(source, destination)
|
||||||
|
|
||||||
|
with patch("os.replace", side_effect=fail_publication):
|
||||||
|
with pytest.raises(OSError, match="publication failed"):
|
||||||
|
node.collect(torch.ones(2, 64, 32, 3), "same", 1, "run1", 8, 32, 8)
|
||||||
|
assert {
|
||||||
|
str(path.relative_to(base)): path.read_bytes()
|
||||||
|
for path in base.rglob("*")
|
||||||
|
if path.is_file()
|
||||||
|
} == before
|
||||||
|
assert list(base.iterdir()) == [run_dir]
|
||||||
|
|
||||||
|
def test_rerun_preserves_directories_with_tile_like_names(
|
||||||
|
self, tmp_path: Path
|
||||||
|
) -> None:
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
node = ModelCompareSheetNode()
|
||||||
|
node.collect(_image(), "a", 1, "run1", 8, 32, 8)
|
||||||
|
run_dir = tmp_path / "model_compare" / "run1"
|
||||||
|
notes = run_dir / "01_notes.png"
|
||||||
|
notes.mkdir()
|
||||||
|
(notes / "notes.txt").write_text("keep this folder")
|
||||||
|
node.collect(_image(), "b", 1, "run1", 8, 32, 8)
|
||||||
|
assert (notes / "notes.txt").read_text() == "keep this folder"
|
||||||
|
assert (run_dir / "01_b.png").is_file()
|
||||||
|
assert not (run_dir / "01_a.png").exists()
|
||||||
|
|
||||||
|
def test_staging_does_not_expose_temporary_images_to_output_galleries(
|
||||||
|
self, tmp_path: Path
|
||||||
|
) -> None:
|
||||||
|
with _fake_output_dir(tmp_path):
|
||||||
|
node = ModelCompareSheetNode()
|
||||||
|
node.collect(_image(), "a", 1, "run1", 8, 32, 8)
|
||||||
|
base = tmp_path / "model_compare"
|
||||||
|
run_dir = base / "run1"
|
||||||
|
temporary_images = []
|
||||||
|
original_save = Image.Image.save
|
||||||
|
original_replace = os.replace
|
||||||
|
|
||||||
|
def observe_images() -> None:
|
||||||
|
temporary_images.extend(
|
||||||
|
path for path in base.rglob("*.png") if path.parent != run_dir
|
||||||
|
)
|
||||||
|
|
||||||
|
def save_and_observe(image, path, *args, **kwargs):
|
||||||
|
result = original_save(image, path, *args, **kwargs)
|
||||||
|
observe_images()
|
||||||
|
return result
|
||||||
|
|
||||||
|
def replace_and_observe(source, destination):
|
||||||
|
result = original_replace(source, destination)
|
||||||
|
observe_images()
|
||||||
|
return result
|
||||||
|
|
||||||
|
with patch.object(Image.Image, "save", new=save_and_observe):
|
||||||
|
with patch("os.replace", side_effect=replace_and_observe):
|
||||||
|
node.collect(_image(batch=2), "b", 1, "run1", 8, 32, 8)
|
||||||
|
assert temporary_images == []
|
||||||
@@ -187,10 +187,10 @@ class TestGeminiLogic:
|
|||||||
assert validate_prompt_type("") is False
|
assert validate_prompt_type("") is False
|
||||||
assert validate_prompt_type(None) is False
|
assert validate_prompt_type(None) is False
|
||||||
|
|
||||||
@pytest.mark.skip(reason="Requires google-generativeai library")
|
@pytest.mark.skip(reason="Requires google-genai library")
|
||||||
def test_analyze_image_with_gemini_success(self):
|
def test_analyze_image_with_gemini_success(self):
|
||||||
"""Test successful image analysis with Gemini."""
|
"""Test successful image analysis with Gemini."""
|
||||||
pass # Skipped as it requires google-generativeai
|
pass # Skipped as it requires google-genai
|
||||||
|
|
||||||
def test_analyze_image_no_api_key(self):
|
def test_analyze_image_no_api_key(self):
|
||||||
"""Test analysis without API key."""
|
"""Test analysis without API key."""
|
||||||
@@ -204,10 +204,10 @@ class TestGeminiLogic:
|
|||||||
assert result == ""
|
assert result == ""
|
||||||
assert "API key not found" in error
|
assert "API key not found" in error
|
||||||
|
|
||||||
@pytest.mark.skip(reason="Requires google-generativeai library")
|
@pytest.mark.skip(reason="Requires google-genai library")
|
||||||
def test_analyze_image_with_custom_prompt(self):
|
def test_analyze_image_with_custom_prompt(self):
|
||||||
"""Test analysis with custom prompt."""
|
"""Test analysis with custom prompt."""
|
||||||
pass # Skipped as it requires google-generativeai
|
pass # Skipped as it requires google-genai
|
||||||
|
|
||||||
|
|
||||||
class TestPromptTemplates:
|
class TestPromptTemplates:
|
||||||
|
|||||||
@@ -24,17 +24,22 @@ def cache_file(tmp_path, monkeypatch):
|
|||||||
|
|
||||||
def fake_genai(model_specs):
|
def fake_genai(model_specs):
|
||||||
genai = MagicMock()
|
genai = MagicMock()
|
||||||
genai.list_models.return_value = [
|
genai.Client.return_value.models.list.return_value = [
|
||||||
SimpleNamespace(
|
SimpleNamespace(
|
||||||
name=f"models/{name}",
|
name=f"models/{name}",
|
||||||
display_name=display,
|
display_name=display,
|
||||||
supported_generation_methods=methods,
|
supported_actions=methods,
|
||||||
)
|
)
|
||||||
for name, display, methods in model_specs
|
for name, display, methods in model_specs
|
||||||
]
|
]
|
||||||
return genai
|
return genai
|
||||||
|
|
||||||
|
|
||||||
|
def sdk_modules(genai):
|
||||||
|
"""sys.modules patch that makes `from google import genai` return genai."""
|
||||||
|
return {"google": MagicMock(genai=genai), "google.genai": genai}
|
||||||
|
|
||||||
|
|
||||||
class TestSortModels:
|
class TestSortModels:
|
||||||
def test_newer_versions_come_first(self):
|
def test_newer_versions_come_first(self):
|
||||||
result = models._sort_models(
|
result = models._sort_models(
|
||||||
@@ -111,27 +116,25 @@ class TestCache:
|
|||||||
|
|
||||||
class TestFetchModelsFromApi:
|
class TestFetchModelsFromApi:
|
||||||
def test_missing_sdk_returns_empty(self):
|
def test_missing_sdk_returns_empty(self):
|
||||||
with patch.dict(sys.modules, {"google.generativeai": None, "google": None}):
|
with patch.dict(sys.modules, {"google.genai": None, "google": None}):
|
||||||
assert models._fetch_models_from_api("k") == ([], {})
|
assert models._fetch_models_from_api("k") == ([], {})
|
||||||
|
|
||||||
def test_no_api_key_returns_empty(self):
|
def test_no_api_key_returns_empty(self):
|
||||||
genai = fake_genai([])
|
genai = fake_genai([])
|
||||||
google = MagicMock(generativeai=genai)
|
|
||||||
with (
|
with (
|
||||||
patch.dict(sys.modules, {"google": google, "google.generativeai": genai}),
|
patch.dict(sys.modules, sdk_modules(genai)),
|
||||||
patch.object(logic, "get_api_key", return_value=None),
|
patch.object(logic, "get_api_key", return_value=None),
|
||||||
):
|
):
|
||||||
assert models._fetch_models_from_api(None, silent=True) == ([], {})
|
assert models._fetch_models_from_api(None, silent=True) == ([], {})
|
||||||
|
|
||||||
def test_api_key_taken_from_logic_when_not_given(self):
|
def test_api_key_taken_from_logic_when_not_given(self):
|
||||||
genai = fake_genai([("gemini-2.5-pro", "Pro", ["generateContent"])])
|
genai = fake_genai([("gemini-2.5-pro", "Pro", ["generateContent"])])
|
||||||
google = MagicMock(generativeai=genai)
|
|
||||||
with (
|
with (
|
||||||
patch.dict(sys.modules, {"google": google, "google.generativeai": genai}),
|
patch.dict(sys.modules, sdk_modules(genai)),
|
||||||
patch.object(logic, "get_api_key", return_value="envkey"),
|
patch.object(logic, "get_api_key", return_value="envkey"),
|
||||||
):
|
):
|
||||||
names, _ = models._fetch_models_from_api(None)
|
names, _ = models._fetch_models_from_api(None)
|
||||||
genai.configure.assert_called_once_with(api_key="envkey")
|
genai.Client.assert_called_once_with(api_key="envkey")
|
||||||
assert names == ["gemini-2.5-pro"]
|
assert names == ["gemini-2.5-pro"]
|
||||||
|
|
||||||
def test_filters_to_generate_content_and_strips_prefix(self):
|
def test_filters_to_generate_content_and_strips_prefix(self):
|
||||||
@@ -142,17 +145,15 @@ class TestFetchModelsFromApi:
|
|||||||
("gemini-2.5-flash", "Flash", ["generateContent", "countTokens"]),
|
("gemini-2.5-flash", "Flash", ["generateContent", "countTokens"]),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
google = MagicMock(generativeai=genai)
|
with patch.dict(sys.modules, sdk_modules(genai)):
|
||||||
with patch.dict(sys.modules, {"google": google, "google.generativeai": genai}):
|
|
||||||
names, desc = models._fetch_models_from_api("k")
|
names, desc = models._fetch_models_from_api("k")
|
||||||
assert names == ["gemini-2.5-flash", "gemini-1.5-pro"]
|
assert names == ["gemini-2.5-flash", "gemini-1.5-pro"]
|
||||||
assert desc == {"gemini-1.5-pro": "Pro 1.5", "gemini-2.5-flash": "Flash"}
|
assert desc == {"gemini-1.5-pro": "Pro 1.5", "gemini-2.5-flash": "Flash"}
|
||||||
|
|
||||||
def test_api_error_returns_empty(self):
|
def test_api_error_returns_empty(self):
|
||||||
genai = MagicMock()
|
genai = MagicMock()
|
||||||
genai.list_models.side_effect = RuntimeError("boom")
|
genai.Client.return_value.models.list.side_effect = RuntimeError("boom")
|
||||||
google = MagicMock(generativeai=genai)
|
with patch.dict(sys.modules, sdk_modules(genai)):
|
||||||
with patch.dict(sys.modules, {"google": google, "google.generativeai": genai}):
|
|
||||||
assert models._fetch_models_from_api("k") == ([], {})
|
assert models._fetch_models_from_api("k") == ([], {})
|
||||||
|
|
||||||
|
|
||||||
@@ -205,20 +206,19 @@ class TestLogicExtra:
|
|||||||
|
|
||||||
def test_missing_sdk_reported(self):
|
def test_missing_sdk_reported(self):
|
||||||
img = np.zeros((1, 4, 4, 3), dtype=np.float32)
|
img = np.zeros((1, 4, 4, 3), dtype=np.float32)
|
||||||
with patch.dict(sys.modules, {"google.generativeai": None, "google": None}):
|
with patch.dict(sys.modules, {"google.genai": None, "google": None}):
|
||||||
out, err = logic.analyze_image_with_gemini(img, "flux", api_key="k")
|
out, err = logic.analyze_image_with_gemini(img, "flux", api_key="k")
|
||||||
assert out == "" and "not installed" in err
|
assert out == "" and "not installed" in err
|
||||||
|
|
||||||
def _run(self, response=None, error=None, **kwargs):
|
def _run(self, response=None, error=None, **kwargs):
|
||||||
genai = MagicMock()
|
genai = MagicMock()
|
||||||
model = genai.GenerativeModel.return_value
|
client_models = genai.Client.return_value.models
|
||||||
if error:
|
if error:
|
||||||
model.generate_content.side_effect = error
|
client_models.generate_content.side_effect = error
|
||||||
else:
|
else:
|
||||||
model.generate_content.return_value = response
|
client_models.generate_content.return_value = response
|
||||||
google = MagicMock(generativeai=genai)
|
|
||||||
img = np.zeros((1, 4, 4, 3), dtype=np.float32)
|
img = np.zeros((1, 4, 4, 3), dtype=np.float32)
|
||||||
with patch.dict(sys.modules, {"google": google, "google.generativeai": genai}):
|
with patch.dict(sys.modules, sdk_modules(genai)):
|
||||||
result = logic.analyze_image_with_gemini(img, "flux", api_key="k", **kwargs)
|
result = logic.analyze_image_with_gemini(img, "flux", api_key="k", **kwargs)
|
||||||
return result, genai
|
return result, genai
|
||||||
|
|
||||||
@@ -227,24 +227,28 @@ class TestLogicExtra:
|
|||||||
SimpleNamespace(text=" hello \n"), model_name="gemini-x"
|
SimpleNamespace(text=" hello \n"), model_name="gemini-x"
|
||||||
)
|
)
|
||||||
assert (out, err) == ("hello", None)
|
assert (out, err) == ("hello", None)
|
||||||
genai.configure.assert_called_once_with(api_key="k")
|
genai.Client.assert_called_once_with(api_key="k")
|
||||||
genai.GenerativeModel.assert_called_once_with("gemini-x")
|
call = genai.Client.return_value.models.generate_content.call_args
|
||||||
|
assert call.kwargs["model"] == "gemini-x"
|
||||||
|
|
||||||
def test_custom_prompt_is_sent_as_system_prompt(self):
|
def test_custom_prompt_is_sent_as_system_prompt(self):
|
||||||
(_, _), genai = self._run(SimpleNamespace(text="x"), custom_prompt="BE TERSE")
|
(_, _), genai = self._run(SimpleNamespace(text="x"), custom_prompt="BE TERSE")
|
||||||
sent = genai.GenerativeModel.return_value.generate_content.call_args[0][0]
|
sent = genai.Client.return_value.models.generate_content.call_args.kwargs[
|
||||||
|
"contents"
|
||||||
|
]
|
||||||
assert sent[0] == "BE TERSE"
|
assert sent[0] == "BE TERSE"
|
||||||
|
|
||||||
def test_unknown_prompt_type_falls_back_to_flux_template(self):
|
def test_unknown_prompt_type_falls_back_to_flux_template(self):
|
||||||
genai = MagicMock()
|
genai = MagicMock()
|
||||||
genai.GenerativeModel.return_value.generate_content.return_value = (
|
genai.Client.return_value.models.generate_content.return_value = (
|
||||||
SimpleNamespace(text="x")
|
SimpleNamespace(text="x")
|
||||||
)
|
)
|
||||||
google = MagicMock(generativeai=genai)
|
|
||||||
img = np.zeros((1, 4, 4, 3), dtype=np.float32)
|
img = np.zeros((1, 4, 4, 3), dtype=np.float32)
|
||||||
with patch.dict(sys.modules, {"google": google, "google.generativeai": genai}):
|
with patch.dict(sys.modules, sdk_modules(genai)):
|
||||||
logic.analyze_image_with_gemini(img, "nonsense", api_key="k")
|
logic.analyze_image_with_gemini(img, "nonsense", api_key="k")
|
||||||
sent = genai.GenerativeModel.return_value.generate_content.call_args[0][0]
|
sent = genai.Client.return_value.models.generate_content.call_args.kwargs[
|
||||||
|
"contents"
|
||||||
|
]
|
||||||
assert sent[0] == logic.PROMPT_TEMPLATES["flux"]
|
assert sent[0] == logic.PROMPT_TEMPLATES["flux"]
|
||||||
|
|
||||||
def test_empty_response(self):
|
def test_empty_response(self):
|
||||||
|
|||||||
@@ -138,7 +138,8 @@ class TestNode:
|
|||||||
|
|
||||||
def test_metadata(self):
|
def test_metadata(self):
|
||||||
assert ProjectFilePathNode.RETURN_TYPES == ("STRING",)
|
assert ProjectFilePathNode.RETURN_TYPES == ("STRING",)
|
||||||
assert ProjectFilePathNode.RETURN_NAMES == ("path",)
|
# No custom name: ComfyUI labels the output "STRING", like djz-nodes
|
||||||
|
assert not hasattr(ProjectFilePathNode, "RETURN_NAMES")
|
||||||
assert ProjectFilePathNode.CATEGORY == "🫶 ComfyAssets/🛠️ Utils"
|
assert ProjectFilePathNode.CATEGORY == "🫶 ComfyAssets/🛠️ Utils"
|
||||||
|
|
||||||
def test_generate_path(self):
|
def test_generate_path(self):
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { mkdirSync, writeFileSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { pathToFileURL } from 'node:url';
|
||||||
|
import { randomUUID } from 'node:crypto';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
const repositoryRoot = fileURLToPath(new URL('../../', import.meta.url));
|
||||||
|
|
||||||
|
export async function startCoverage(page, browserName) {
|
||||||
|
if (process.env.KIKO_JS_COVERAGE && browserName === 'chromium') {
|
||||||
|
await page.coverage.startJSCoverage({ resetOnNavigation: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export async function saveCoverage(page, browserName) {
|
||||||
|
if (!process.env.KIKO_JS_COVERAGE || browserName !== 'chromium') return;
|
||||||
|
const entries = await page.coverage.stopJSCoverage();
|
||||||
|
const result = [];
|
||||||
|
for (const entry of entries) {
|
||||||
|
const match = entry.url.match(/\/extensions\/kikotools\/([a-z0-9_-]+\.js)(?:\?.*)?$/i);
|
||||||
|
if (match) result.push({ ...entry, url: pathToFileURL(join(repositoryRoot, 'web', match[1])).href });
|
||||||
|
}
|
||||||
|
mkdirSync(process.env.KIKO_JS_COVERAGE, { recursive: true });
|
||||||
|
writeFileSync(join(process.env.KIKO_JS_COVERAGE, `browser-${randomUUID()}.json`), JSON.stringify({ result }));
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"display_any.js": {
|
||||||
|
"lines": 84,
|
||||||
|
"branches": 66,
|
||||||
|
"functions": 83,
|
||||||
|
"statements": 84
|
||||||
|
},
|
||||||
|
"display_text.js": {
|
||||||
|
"lines": 71,
|
||||||
|
"branches": 74,
|
||||||
|
"functions": 42,
|
||||||
|
"statements": 71
|
||||||
|
},
|
||||||
|
"empty_latent_batch_swap.js": {
|
||||||
|
"lines": 41,
|
||||||
|
"branches": 91,
|
||||||
|
"functions": 64,
|
||||||
|
"statements": 41
|
||||||
|
},
|
||||||
|
"gemini_prompt_ui.js": {
|
||||||
|
"lines": 52,
|
||||||
|
"branches": 85,
|
||||||
|
"functions": 42,
|
||||||
|
"statements": 52
|
||||||
|
},
|
||||||
|
"kikoEmbeddingAutocomplete.js": {
|
||||||
|
"lines": 44,
|
||||||
|
"branches": 43,
|
||||||
|
"functions": 59,
|
||||||
|
"statements": 44
|
||||||
|
},
|
||||||
|
"kiko_custom_colors.js": {
|
||||||
|
"lines": 46,
|
||||||
|
"branches": 98,
|
||||||
|
"functions": 8,
|
||||||
|
"statements": 46
|
||||||
|
},
|
||||||
|
"kiko_follow_execution.js": {
|
||||||
|
"lines": 60,
|
||||||
|
"branches": 79,
|
||||||
|
"functions": 73,
|
||||||
|
"statements": 60
|
||||||
|
},
|
||||||
|
"kiko_local_image_loader.js": {
|
||||||
|
"lines": 72,
|
||||||
|
"branches": 69,
|
||||||
|
"functions": 40,
|
||||||
|
"statements": 72
|
||||||
|
},
|
||||||
|
"kiko_save_image_ui.js": {
|
||||||
|
"lines": 66,
|
||||||
|
"branches": 49,
|
||||||
|
"functions": 57,
|
||||||
|
"statements": 66
|
||||||
|
},
|
||||||
|
"kiko_workflow_timer_ui.js": {
|
||||||
|
"lines": 44,
|
||||||
|
"branches": 73,
|
||||||
|
"functions": 34,
|
||||||
|
"statements": 44
|
||||||
|
},
|
||||||
|
"kikotools_extensions.js": {
|
||||||
|
"lines": 12,
|
||||||
|
"branches": 98,
|
||||||
|
"functions": 0,
|
||||||
|
"statements": 12
|
||||||
|
},
|
||||||
|
"seed_history_ui.js": {
|
||||||
|
"lines": 63,
|
||||||
|
"branches": 58,
|
||||||
|
"functions": 56,
|
||||||
|
"statements": 63
|
||||||
|
},
|
||||||
|
"width_height_swap.js": {
|
||||||
|
"lines": 60,
|
||||||
|
"branches": 79,
|
||||||
|
"functions": 73,
|
||||||
|
"statements": 60
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import { readFileSync, readdirSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
||||||
|
import { dirname, join, relative, resolve } from 'node:path';
|
||||||
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||||
|
import { spawnSync } from 'node:child_process';
|
||||||
|
const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
|
||||||
|
|
||||||
|
const metrics = ['lines', 'branches', 'functions', 'statements'];
|
||||||
|
export function checkCoverage(summary, baseline, sourceRoot, files) {
|
||||||
|
const failures = [];
|
||||||
|
for (const file of files) {
|
||||||
|
const floor = baseline[file];
|
||||||
|
if (!floor) { failures.push(`Missing baseline for ${file}`); continue; }
|
||||||
|
const measured = summary[join(sourceRoot, file)];
|
||||||
|
if (!measured) { failures.push(`Missing coverage for ${file}`); continue; }
|
||||||
|
for (const metric of metrics) {
|
||||||
|
if (!Number.isFinite(floor[metric]) || floor[metric] < 0 || floor[metric] > 100) {
|
||||||
|
throw new Error(`Invalid baseline for ${file}: ${metric}`);
|
||||||
|
}
|
||||||
|
if (!Number.isFinite(measured[metric]?.pct) || measured[metric].pct < floor[metric]) {
|
||||||
|
failures.push(`${file} ${metric}: ${measured[metric]?.pct ?? 'missing'} < ${floor[metric]}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
function run(args, env = {}) {
|
||||||
|
const result = spawnSync(process.execPath, args, { cwd: repositoryRoot, stdio: 'inherit',
|
||||||
|
env: { ...process.env, ...env } });
|
||||||
|
if (result.status !== 0) throw new Error(`Command failed (${result.status}): ${args.join(' ')}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const tools = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const reportRoot = join(repositoryRoot, 'coverage/js');
|
||||||
|
const raw = join(reportRoot, 'raw');
|
||||||
|
const sourceRoot = join(repositoryRoot, 'web');
|
||||||
|
const files = readdirSync(sourceRoot).filter(file => file.endsWith('.js')).sort();
|
||||||
|
rmSync(reportRoot, { recursive: true, force: true });
|
||||||
|
mkdirSync(raw, { recursive: true });
|
||||||
|
const tests = readdirSync(join(repositoryRoot, 'tests/js')).filter(file => file.endsWith('.test.mjs')).map(file => `tests/js/${file}`);
|
||||||
|
run(['--test', ...tests], { NODE_V8_COVERAGE: raw });
|
||||||
|
const playwright = join(tools, 'node_modules/@playwright/test/cli.js');
|
||||||
|
run([playwright, 'test', '--config', join(tools, 'playwright.config.mjs'),
|
||||||
|
'--project', 'chromium', '--project', 'touch'], { KIKO_JS_COVERAGE: raw });
|
||||||
|
run([join(tools, 'node_modules/c8/bin/c8.js'), 'report', '--all', '--src', sourceRoot,
|
||||||
|
'--include', 'web/*.js', '--temp-directory', raw, '--reports-dir', reportRoot,
|
||||||
|
'--reporter', 'text', '--reporter', 'json-summary', '--reporter', 'html']);
|
||||||
|
const summary = JSON.parse(readFileSync(join(reportRoot, 'coverage-summary.json'), 'utf8'));
|
||||||
|
const baselinePath = join(tools, 'frontend-coverage-baseline.json');
|
||||||
|
if (process.argv.includes('--update-baseline')) {
|
||||||
|
const previous = JSON.parse(readFileSync(baselinePath, 'utf8'));
|
||||||
|
const failures = checkCoverage(summary, previous, sourceRoot, files.filter(file => previous[file]));
|
||||||
|
if (failures.length) throw new Error(`Baseline updates cannot lower coverage:\n${failures.join('\n')}`);
|
||||||
|
const next = Object.fromEntries(files.map(file => {
|
||||||
|
const measured = summary[join(sourceRoot, file)];
|
||||||
|
if (!measured || metrics.some(metric => !Number.isFinite(measured[metric]?.pct))) {
|
||||||
|
throw new Error(`Missing coverage for ${file}`);
|
||||||
|
}
|
||||||
|
if (Object.keys(previous).length && !previous[file] && measured.lines.pct < 80) {
|
||||||
|
throw new Error(`New frontend files need at least 80% line coverage: ${file}`);
|
||||||
|
}
|
||||||
|
return [file, Object.fromEntries(metrics.map(metric => [metric, Math.max(previous[file]?.[metric] || 0, Math.floor(measured[metric].pct) - 2, 0)]))];
|
||||||
|
}));
|
||||||
|
writeFileSync(baselinePath, JSON.stringify(next, null, 2) + '\n');
|
||||||
|
} else {
|
||||||
|
const baseline = JSON.parse(readFileSync(baselinePath, 'utf8'));
|
||||||
|
const failures = checkCoverage(summary, baseline, sourceRoot, files);
|
||||||
|
if (failures.length) throw new Error(`Frontend coverage regressed:\n${failures.join('\n')}`);
|
||||||
|
}
|
||||||
|
console.log(`Frontend coverage passed for ${files.length} files. Report: ${relative(repositoryRoot, reportRoot)}/index.html`);
|
||||||
|
}
|
||||||
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||||
|
main().catch(error => { console.error(error.message); process.exitCode = 1; });
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export function isFixtureURL(raw, baseURL) {
|
||||||
|
const url = new URL(raw);
|
||||||
|
return url.origin === new URL(baseURL).origin && ['http:', 'https:', 'blob:'].includes(url.protocol);
|
||||||
|
}
|
||||||
Generated
+785
@@ -0,0 +1,785 @@
|
|||||||
|
{
|
||||||
|
"name": "kikotools-test-tools",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "kikotools-test-tools",
|
||||||
|
"devDependencies": {
|
||||||
|
"@playwright/test": "1.64.1",
|
||||||
|
"c8": "12.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=24"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@bcoe/v8-coverage": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@istanbuljs/schema": {
|
||||||
|
"version": "0.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz",
|
||||||
|
"integrity": "sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/resolve-uri": {
|
||||||
|
"version": "3.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
|
||||||
|
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/sourcemap-codec": {
|
||||||
|
"version": "1.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",
|
||||||
|
"integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/trace-mapping": {
|
||||||
|
"version": "0.3.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
|
||||||
|
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/resolve-uri": "^3.1.0",
|
||||||
|
"@jridgewell/sourcemap-codec": "^1.4.14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@playwright/test": {
|
||||||
|
"version": "1.64.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz",
|
||||||
|
"integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright": "1.64.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/istanbul-lib-coverage": {
|
||||||
|
"version": "2.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz",
|
||||||
|
"integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/ansi-regex": {
|
||||||
|
"version": "6.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz",
|
||||||
|
"integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ansi-styles": {
|
||||||
|
"version": "6.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz",
|
||||||
|
"integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/balanced-match": {
|
||||||
|
"version": "4.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
||||||
|
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": "18 || 20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/brace-expansion": {
|
||||||
|
"version": "5.0.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
|
||||||
|
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"balanced-match": "^4.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/c8": {
|
||||||
|
"version": "12.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/c8/-/c8-12.0.0.tgz",
|
||||||
|
"integrity": "sha512-4zpJvrd1nKWutnnKC2pXkFmb6iM1l+ffN//o1CzlTNwW7GSOs9a1xrLqkC48nU8oEkjmPZLPiwMsIaOvoF4Pqg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"@bcoe/v8-coverage": "^1.0.1",
|
||||||
|
"@istanbuljs/schema": "^0.1.3",
|
||||||
|
"find-up": "^5.0.0",
|
||||||
|
"foreground-child": "^3.1.1",
|
||||||
|
"istanbul-lib-coverage": "^3.2.0",
|
||||||
|
"istanbul-lib-report": "^3.0.1",
|
||||||
|
"istanbul-reports": "^3.1.6",
|
||||||
|
"test-exclude": "^8.0.0",
|
||||||
|
"v8-to-istanbul": "^9.0.0",
|
||||||
|
"yargs": "^18.0.0",
|
||||||
|
"yargs-parser": "^21.1.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"c8": "bin/c8.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || ^22.12.0 || >=23"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"monocart-coverage-reports": "^2"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"monocart-coverage-reports": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/cliui": {
|
||||||
|
"version": "9.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz",
|
||||||
|
"integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"string-width": "^7.2.0",
|
||||||
|
"strip-ansi": "^7.1.0",
|
||||||
|
"wrap-ansi": "^9.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/cliui/node_modules/string-width": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"emoji-regex": "^10.3.0",
|
||||||
|
"get-east-asian-width": "^1.0.0",
|
||||||
|
"strip-ansi": "^7.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/convert-source-map": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/cross-spawn": {
|
||||||
|
"version": "7.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||||
|
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"path-key": "^3.1.0",
|
||||||
|
"shebang-command": "^2.0.0",
|
||||||
|
"which": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/emoji-regex": {
|
||||||
|
"version": "10.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
||||||
|
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/escalade": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/find-up": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"locate-path": "^6.0.0",
|
||||||
|
"path-exists": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/foreground-child": {
|
||||||
|
"version": "3.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz",
|
||||||
|
"integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"cross-spawn": "^7.0.6",
|
||||||
|
"signal-exit": "^4.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/get-caller-file": {
|
||||||
|
"version": "2.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||||
|
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": "6.* || 8.* || >= 10.*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/get-east-asian-width": {
|
||||||
|
"version": "1.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz",
|
||||||
|
"integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/glob": {
|
||||||
|
"version": "13.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz",
|
||||||
|
"integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"minimatch": "^10.2.2",
|
||||||
|
"minipass": "^7.1.3",
|
||||||
|
"path-scurry": "^2.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "18 || 20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/has-flag": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/html-escaper": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/isexe": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
|
"node_modules/istanbul-lib-coverage": {
|
||||||
|
"version": "3.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz",
|
||||||
|
"integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/istanbul-lib-report": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"istanbul-lib-coverage": "^3.0.0",
|
||||||
|
"make-dir": "^4.0.0",
|
||||||
|
"supports-color": "^7.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/istanbul-reports": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"html-escaper": "^2.0.0",
|
||||||
|
"istanbul-lib-report": "^3.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/locate-path": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"p-locate": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lru-cache": {
|
||||||
|
"version": "11.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz",
|
||||||
|
"integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/make-dir": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"semver": "^7.5.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/minimatch": {
|
||||||
|
"version": "10.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
|
||||||
|
"integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"brace-expansion": "^5.0.8"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "18 || 20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/minipass": {
|
||||||
|
"version": "7.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
|
||||||
|
"integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16 || 14 >=14.17"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/p-limit": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"yocto-queue": "^0.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/p-locate": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"p-limit": "^3.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/path-exists": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/path-key": {
|
||||||
|
"version": "3.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||||
|
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/path-scurry": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"lru-cache": "^11.0.0",
|
||||||
|
"minipass": "^7.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "18 || 20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/playwright": {
|
||||||
|
"version": "1.64.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz",
|
||||||
|
"integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright-core": "1.64.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/playwright-core": {
|
||||||
|
"version": "1.64.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz",
|
||||||
|
"integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"playwright-core": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/semver": {
|
||||||
|
"version": "7.8.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||||
|
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"bin": {
|
||||||
|
"semver": "bin/semver.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/shebang-command": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"shebang-regex": "^3.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/shebang-regex": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/signal-exit": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/string-width": {
|
||||||
|
"version": "8.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz",
|
||||||
|
"integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"get-east-asian-width": "^1.5.0",
|
||||||
|
"strip-ansi": "^7.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/strip-ansi": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-regex": "^6.2.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/supports-color": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"has-flag": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/test-exclude": {
|
||||||
|
"version": "8.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-8.0.0.tgz",
|
||||||
|
"integrity": "sha512-ZOffsNrXYggvU1mDGHk54I96r26P8SyMjO5slMKSc7+IWmtB/MQKnEC2fP51imB3/pT6YK5cT5E8f+Dd9KdyOQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"@istanbuljs/schema": "^0.1.2",
|
||||||
|
"glob": "^13.0.6",
|
||||||
|
"minimatch": "^10.2.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/v8-to-istanbul": {
|
||||||
|
"version": "9.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz",
|
||||||
|
"integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/trace-mapping": "^0.3.12",
|
||||||
|
"@types/istanbul-lib-coverage": "^2.0.1",
|
||||||
|
"convert-source-map": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/which": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"isexe": "^2.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"node-which": "bin/node-which"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/wrap-ansi": {
|
||||||
|
"version": "9.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz",
|
||||||
|
"integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-styles": "^6.2.1",
|
||||||
|
"string-width": "^7.0.0",
|
||||||
|
"strip-ansi": "^7.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/wrap-ansi/node_modules/string-width": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"emoji-regex": "^10.3.0",
|
||||||
|
"get-east-asian-width": "^1.0.0",
|
||||||
|
"strip-ansi": "^7.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/y18n": {
|
||||||
|
"version": "5.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||||
|
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/yargs": {
|
||||||
|
"version": "18.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz",
|
||||||
|
"integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"cliui": "^9.0.1",
|
||||||
|
"escalade": "^3.1.1",
|
||||||
|
"get-caller-file": "^2.0.5",
|
||||||
|
"string-width": "^8.2.1",
|
||||||
|
"y18n": "^5.0.5",
|
||||||
|
"yargs-parser": "^22.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || ^22.12.0 || >=23"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/yargs-parser": {
|
||||||
|
"version": "21.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
|
||||||
|
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/yargs/node_modules/yargs-parser": {
|
||||||
|
"version": "22.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz",
|
||||||
|
"integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || ^22.12.0 || >=23"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/yocto-queue": {
|
||||||
|
"version": "0.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
||||||
|
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "kikotools-test-tools",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"engines": { "node": ">=24" },
|
||||||
|
"scripts": {
|
||||||
|
"test": "node --test ../../tests/js/*.test.mjs",
|
||||||
|
"test:browser": "playwright test --config playwright.config.mjs",
|
||||||
|
"test:coverage": "node frontend-coverage.mjs",
|
||||||
|
"coverage:update": "node frontend-coverage.mjs --update-baseline"
|
||||||
|
},
|
||||||
|
"devDependencies": { "@playwright/test": "1.64.1", "c8": "12.0.0" }
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
const repositoryRoot = fileURLToPath(new URL('../../', import.meta.url));
|
||||||
|
const port = Number(process.env.KIKO_TEST_PORT || 8766);
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: '../../tests/browser',
|
||||||
|
outputDir: './test-results',
|
||||||
|
workers: 1,
|
||||||
|
fullyParallel: false,
|
||||||
|
forbidOnly: Boolean(process.env.CI),
|
||||||
|
retries: 0,
|
||||||
|
reporter: 'list',
|
||||||
|
use: { baseURL: `http://127.0.0.1:${port}`, trace: 'retain-on-failure', screenshot: 'only-on-failure' },
|
||||||
|
webServer: {
|
||||||
|
command: `node tools/testing/start-browser-server.mjs --port ${port}`,
|
||||||
|
cwd: repositoryRoot,
|
||||||
|
url: `http://127.0.0.1:${port}/__test__/`,
|
||||||
|
reuseExistingServer: false,
|
||||||
|
gracefulShutdown: { signal: 'SIGTERM', timeout: 5000 },
|
||||||
|
},
|
||||||
|
projects: [
|
||||||
|
{ name: 'chromium', use: { browserName: 'chromium' } },
|
||||||
|
{ name: 'firefox', use: { browserName: 'firefox' } },
|
||||||
|
{ name: 'webkit', use: { browserName: 'webkit' } },
|
||||||
|
{ name: 'touch', use: { ...devices['Pixel 7'], browserName: 'chromium' } },
|
||||||
|
],
|
||||||
|
});
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
const child = spawn(process.env.KIKO_TEST_PYTHON || 'python',
|
||||||
|
['-m', 'tests.browser.server', ...process.argv.slice(2)], { stdio: 'inherit' });
|
||||||
|
child.on('error', error => { console.error(error.message); process.exitCode = 1; });
|
||||||
|
child.on('exit', code => { process.exitCode = code ?? 1; });
|
||||||
|
for (const signal of ['SIGTERM', 'SIGINT']) {
|
||||||
|
process.once(signal, () => child.kill(signal));
|
||||||
|
}
|
||||||
@@ -451,9 +451,8 @@ app.registerExtension({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Gallery -->
|
<!-- Gallery -->
|
||||||
<div class="kiko-cardholder">
|
<div class="kiko-status-message">Loading...</div>
|
||||||
<div class="kiko-status-message">Loading...</div>
|
<div class="kiko-cardholder"></div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Pagination -->
|
<!-- Pagination -->
|
||||||
<div class="kiko-pagination"></div>
|
<div class="kiko-pagination"></div>
|
||||||
|
|||||||
@@ -123,13 +123,13 @@ app.registerExtension({
|
|||||||
widthWidget.value = h;
|
widthWidget.value = h;
|
||||||
heightWidget.value = w;
|
heightWidget.value = w;
|
||||||
if (presetWidget.callback) {
|
if (presetWidget.callback) {
|
||||||
presetWidget.callback(swappedFormattedPreset, this, presetWidget);
|
presetWidget.callback(swappedFormattedPreset, app.canvas, this, [0, 0], null);
|
||||||
}
|
}
|
||||||
if (widthWidget.callback) {
|
if (widthWidget.callback) {
|
||||||
widthWidget.callback(h, this, widthWidget);
|
widthWidget.callback(h, app.canvas, this, [0, 0], null);
|
||||||
}
|
}
|
||||||
if (heightWidget.callback) {
|
if (heightWidget.callback) {
|
||||||
heightWidget.callback(w, this, heightWidget);
|
heightWidget.callback(w, app.canvas, this, [0, 0], null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Swapped preset doesn't exist, switch to custom and swap manual values
|
// Swapped preset doesn't exist, switch to custom and swap manual values
|
||||||
@@ -138,13 +138,13 @@ app.registerExtension({
|
|||||||
heightWidget.value = w;
|
heightWidget.value = w;
|
||||||
|
|
||||||
if (presetWidget.callback) {
|
if (presetWidget.callback) {
|
||||||
presetWidget.callback("custom", this, presetWidget);
|
presetWidget.callback("custom", app.canvas, this, [0, 0], null);
|
||||||
}
|
}
|
||||||
if (widthWidget.callback) {
|
if (widthWidget.callback) {
|
||||||
widthWidget.callback(h, this, widthWidget);
|
widthWidget.callback(h, app.canvas, this, [0, 0], null);
|
||||||
}
|
}
|
||||||
if (heightWidget.callback) {
|
if (heightWidget.callback) {
|
||||||
heightWidget.callback(w, this, heightWidget);
|
heightWidget.callback(w, app.canvas, this, [0, 0], null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -155,10 +155,10 @@ app.registerExtension({
|
|||||||
|
|
||||||
// Trigger widget change events
|
// Trigger widget change events
|
||||||
if (widthWidget.callback) {
|
if (widthWidget.callback) {
|
||||||
widthWidget.callback(widthWidget.value, this, widthWidget);
|
widthWidget.callback(widthWidget.value, app.canvas, this, [0, 0], null);
|
||||||
}
|
}
|
||||||
if (heightWidget.callback) {
|
if (heightWidget.callback) {
|
||||||
heightWidget.callback(heightWidget.value, this, heightWidget);
|
heightWidget.callback(heightWidget.value, app.canvas, this, [0, 0], null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user