mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-31 05:19:53 +00:00
* refactor layout store utils * [refactor] use nullish coalescing in getOr helper - addresses @DrJKL's suggestion Replaces manual undefined/null checks with more concise ?? operator for cleaner code that achieves the same functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * [refactor] improve Y.Map typing for better type safety - addresses @DrJKL's typing suggestions - Use Y.Map<NodeLayout[keyof NodeLayout]> instead of Y.Map<unknown> - Provides compile-time type safety for stored values - Improves IntelliSense and prevents type mismatches - Updates mappers, store, tests, and helper functions consistently - No runtime changes, pure TypeScript improvement 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * [refactor] address @arjansingh code quality feedback - Remove AI-generated refactoring comment that adds no value - Reorganize tests with nested describe blocks for better readability - Group related test cases by function for easier scanning 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * [refactor] move makeLinkSegmentKey to layoutUtils - addresses @arjansingh's file organization feedback - Move string concatenation function from layoutMath.ts to new layoutUtils.ts - Keep layoutMath.ts focused on pure geometric calculations - Create dedicated layoutUtils.ts for general layout utilities - Update imports in store and create separate test file - Improves module cohesion and clarity of purpose 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * [cleanup] remove leftover AI refactoring comments - Remove "Constants moved to utils" and "Node layout mapping moved to utils" - Clean up extra blank lines from previous refactoring - Keep meaningful organizational comments like "Helper methods" 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * [cleanup] remove unnecessary import aliases Remove pointInBoundsUtil/boundsIntersectUtil aliases as there are no naming conflicts. Use direct function names for cleaner code. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * [refactor] improve Y.Map typing with named NodeLayoutMap type - addresses @DrJKL's performance and type safety suggestions - Create named NodeLayoutMap type for TypeScript performance optimization - Improve getOr function with proper key constraints and type safety - Update all Y.Map<NodeLayout[keyof NodeLayout]> usages to use NodeLayoutMap - Remove manual type assertions in favor of generic key constraints - Clean up unused imports and fix formatting issues * [cleanup] remove explanatory comment per @DrJKL's preference * don't wait for dialog close button to be stable --------- Co-authored-by: Claude <noreply@anthropic.com>
ComfyUI Frontend Testing Guide
This guide provides an overview of testing approaches used in the ComfyUI Frontend codebase. These guides are meant to document any particularities or nuances of writing tests in this codebase, rather than being a comprehensive guide to testing in general. By reading these guides first, you may save yourself some time when encountering issues.
Testing Documentation
Documentation for unit tests is organized into three guides:
- Component Testing - How to test Vue components
- Unit Testing - How to test utility functions, composables, and other non-component code
- Store Testing - How to test Pinia stores specifically
Testing Structure
The ComfyUI Frontend project uses a mixed approach to unit test organization:
- Component Tests: Located directly alongside their components with a
.spec.tsextension - Unit Tests: Located in the
tests-ui/tests/directory - Store Tests: Located in the
tests-ui/tests/store/directory - Browser Tests: These are located in the
browser_tests/directory. There is a dedicated README in thebrowser_tests/directory, so it will not be covered here.
Test Frameworks and Libraries
Our tests use the following frameworks and libraries:
- Vitest - Test runner and assertion library
- @vue/test-utils - Vue component testing utilities
- Pinia - For store testing
Getting Started
To run the tests locally:
# Run unit tests
pnpm test:unit
# Run unit tests in watch mode
pnpm test:unit:dev
# Run component tests with browser-native environment
pnpm test:component
Refer to the specific guides for more detailed information on each testing type.