LCOV - code coverage report
Current view: top level - src/renderer/extensions/vueNodes/widgets/components/form/dropdown - shared.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 12 12
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { t } from '@/i18n'
       2              : import type { AssetSortOption } from '@/platform/assets/types/filterTypes'
       3              : import { sortAssets } from '@/platform/assets/utils/assetSortUtils'
       4              : 
       5              : import type { FormDropdownItem, SortOption } from './types'
       6              : 
       7              : /**
       8              :  * Marker class for the dropdown's sub-popover panels (Sort / Ownership /
       9              :  * Base-model). Those panels teleport to `document.body`, so they render outside
      10              :  * the menu's DOM subtree; the outside-press dismiss logic uses this class to
      11              :  * recognize a press inside them as still "inside" the dropdown.
      12              :  */
      13          847 : export const DROPDOWN_PANEL_CLASS = 'comfy-form-dropdown-panel'
      14              : 
      15           10 : export async function defaultSearcher(
      16              :   query: string,
      17              :   items: readonly FormDropdownItem[]
      18              : ) {
      19           10 :   if (query.trim() === '') return items
      20            1 :   const words = query.trim().toLowerCase().split(' ')
      21            1 :   return items.filter((item) => {
      22            1 :     const name = item.name.toLowerCase()
      23            1 :     const label = item.label?.toLowerCase() ?? ''
      24            1 :     return words.every((word) => name.includes(word) || label.includes(word))
      25              :   })
      26              : }
      27              : 
      28              : /**
      29              :  * Create a SortOption that delegates to the shared sortAssets utility
      30              :  */
      31          394 : function createSortOption(
      32              :   id: AssetSortOption,
      33              :   name: string
      34              : ): SortOption<AssetSortOption> {
      35          394 :   return {
      36              :     id,
      37              :     name,
      38              :     sorter: ({ items }) => sortAssets(items, id)
      39              :   }
      40              : }
      41              : 
      42          197 : export function getDefaultSortOptions(): SortOption<AssetSortOption>[] {
      43          197 :   return [
      44              :     createSortOption('default', t('assetBrowser.sortUnsorted')),
      45              :     createSortOption('name-asc', t('assetBrowser.sortAZ'))
      46              :   ]
      47              : }
        

Generated by: LCOV version 2.0-1