mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
This pull request adds persistent filter and sort settings to the template library, allowing users' filter choices and sort preferences to be saved and restored across sessions. The main changes include integrating the settings store with the template filtering composable, updating the schema and core settings, and ensuring filter changes are saved efficiently. **Template Library Filter Persistence:** * [`src/composables/useTemplateFiltering.ts`](diffhunk://#diff-a1ec9d65962033526942cbcabeac8538ef3cd723e2e9e889cf668ccf6270d167L1-R32): The filter state (`selectedModels`, `selectedUseCases`, `selectedRunsOn`, and `sortBy`) is now initialized from the settings store and changes are persisted back using debounced watchers. This ensures user preferences are saved and restored. [[1]](diffhunk://#diff-a1ec9d65962033526942cbcabeac8538ef3cd723e2e9e889cf668ccf6270d167L1-R32) [[2]](diffhunk://#diff-a1ec9d65962033526942cbcabeac8538ef3cd723e2e9e889cf668ccf6270d167R259-R291) * [`src/platform/settings/constants/coreSettings.ts`](diffhunk://#diff-9fb7e2cdcdc60a92bdb54698fb49909bd2a84a50ffb69e2b60529a948eeb9756R1056-R1083): Added new hidden settings for template filter selections and sort preference, with sensible defaults. * [`src/schemas/apiSchema.ts`](diffhunk://#diff-b769532e74f826ca909951c0c34331b9246efb3f6901ff95a856ecf01ad826beR504-R514): Updated the settings schema to include the new template filter and sort settings, ensuring type safety and validation. **Default Behavior Adjustment:** * [`src/composables/useTemplateFiltering.ts`](diffhunk://#diff-a1ec9d65962033526942cbcabeac8538ef3cd723e2e9e889cf668ccf6270d167L200-R209): Changed the default sort order when clearing filters to `'newest'` to match the new default in settings. https://github.com/user-attachments/assets/259e87e6-20b3-4c91-b1bf-4b7d70649878 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6657-Persist-template-filters-2a86d73d3650818ca46fda23a6528391) by [Unito](https://www.unito.io)
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
Refer to the specific guides for more detailed information on each testing type.