Files
ComfyUI_frontend/src/utils/imageUtil.test.ts
pythongosssss 190bbf0ac2 feat: App mode - enable mask editor (#9876)
## Summary

Adds the ability for users to access mask editor from app mode

## Changes

- **What**: 
- add mask editor button to app mode load image
- extract parseImageWidgetValue for url + test

## Screenshots (if applicable)

<img width="303" height="232" alt="image"
src="https://github.com/user-attachments/assets/89afffda-d049-4ef4-ba13-bf483222b27c"
/>
<img width="959" height="715" alt="image"
src="https://github.com/user-attachments/assets/db19a327-e53b-4047-aa66-2cb6e889be1d"
/>
<img width="308" height="302" alt="image"
src="https://github.com/user-attachments/assets/efaf601a-c2d8-4098-a3aa-1b5bbb3aec1c"
/>

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-9876-feat-App-mode-enable-mask-editor-3226d73d365081d5982bf5e0e870f9b3)
by [Unito](https://www.unito.io)
2026-03-18 03:08:26 -07:00

58 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { parseImageWidgetValue } from './imageUtil'
describe('parseImageWidgetValue', () => {
it('parses a plain filename', () => {
expect(parseImageWidgetValue('example.png')).toEqual({
filename: 'example.png',
subfolder: '',
type: 'input'
})
})
it('parses filename with type suffix', () => {
expect(parseImageWidgetValue('example.png [output]')).toEqual({
filename: 'example.png',
subfolder: '',
type: 'output'
})
})
it('parses subfolder and filename', () => {
expect(parseImageWidgetValue('clipspace/mask-123.png')).toEqual({
filename: 'mask-123.png',
subfolder: 'clipspace',
type: 'input'
})
})
it('parses subfolder, filename, and type', () => {
expect(
parseImageWidgetValue(
'clipspace/clipspace-painted-masked-123.png [input]'
)
).toEqual({
filename: 'clipspace-painted-masked-123.png',
subfolder: 'clipspace',
type: 'input'
})
})
it('parses nested subfolders', () => {
expect(parseImageWidgetValue('a/b/c/image.png [temp]')).toEqual({
filename: 'image.png',
subfolder: 'a/b/c',
type: 'temp'
})
})
it('handles empty string', () => {
expect(parseImageWidgetValue('')).toEqual({
filename: '',
subfolder: '',
type: 'input'
})
})
})