mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-23 06:10:32 +00:00
Backport of #12069 to `cloud/1.44` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-12122-backport-cloud-1-44-fix-handle-annotated-output-media-paths-in-missing-media-scan-35d6d73d36508174bfc1f2590edd1a03) by [Unito](https://www.unito.io) Co-authored-by: jaeone94 <89377375+jaeone94@users.noreply.github.com>
81 lines
2.5 KiB
TypeScript
81 lines
2.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
getAnnotatedMediaPathTypeForDetection,
|
|
getMediaPathDetectionNames,
|
|
normalizeAnnotatedMediaPathForDetection
|
|
} from './mediaPathDetectionUtil'
|
|
|
|
describe('normalizeAnnotatedMediaPathForDetection', () => {
|
|
it.each([
|
|
['photo.png [input]', 'photo.png'],
|
|
['result.png [output]', 'result.png'],
|
|
['photo.png [input]', 'photo.png'],
|
|
['with spaces.png [output]', 'with spaces.png'],
|
|
['nested/folder/video.mp4 [output]', 'nested/folder/video.mp4']
|
|
])('strips Core-style annotation from %s', (value, expected) => {
|
|
expect(normalizeAnnotatedMediaPathForDetection(value)).toBe(expected)
|
|
})
|
|
|
|
it.each([
|
|
['photo.png[input]', 'photo.png'],
|
|
['result.png[output]', 'result.png'],
|
|
['with spaces.png [output]', 'with spaces.png']
|
|
])('strips Cloud compact annotation from %s', (value, expected) => {
|
|
expect(
|
|
normalizeAnnotatedMediaPathForDetection(value, {
|
|
allowCompactSuffix: true
|
|
})
|
|
).toBe(expected)
|
|
})
|
|
|
|
it('does not strip compact annotations in Core mode', () => {
|
|
expect(normalizeAnnotatedMediaPathForDetection('photo.png[input]')).toBe(
|
|
'photo.png[input]'
|
|
)
|
|
})
|
|
|
|
it.each(['photo.png [draft]', 'photo [output] copy.png', 'photo.png', ''])(
|
|
'leaves non-matching values unchanged: %s',
|
|
(value) => {
|
|
expect(normalizeAnnotatedMediaPathForDetection(value)).toBe(value)
|
|
}
|
|
)
|
|
})
|
|
|
|
describe('getMediaPathDetectionNames', () => {
|
|
it('returns raw and normalized names when an annotation is stripped', () => {
|
|
expect(getMediaPathDetectionNames('photo.png [input]')).toEqual([
|
|
'photo.png [input]',
|
|
'photo.png'
|
|
])
|
|
})
|
|
|
|
it('returns only the raw name when no annotation is stripped', () => {
|
|
expect(getMediaPathDetectionNames('photo.png')).toEqual(['photo.png'])
|
|
})
|
|
})
|
|
|
|
describe('getAnnotatedMediaPathTypeForDetection', () => {
|
|
it.each([
|
|
['photo.png [input]', 'input'],
|
|
['photo.png [output]', 'output']
|
|
])('returns the Core-style annotation type from %s', (value, expected) => {
|
|
expect(getAnnotatedMediaPathTypeForDetection(value)).toBe(expected)
|
|
})
|
|
|
|
it('returns the compact annotation type in Cloud mode', () => {
|
|
expect(
|
|
getAnnotatedMediaPathTypeForDetection('photo.png[output]', {
|
|
allowCompactSuffix: true
|
|
})
|
|
).toBe('output')
|
|
})
|
|
|
|
it('returns undefined when no supported annotation is present', () => {
|
|
expect(getAnnotatedMediaPathTypeForDetection('photo.png [draft]')).toBe(
|
|
undefined
|
|
)
|
|
})
|
|
})
|