37 lines
2.3 KiB
JavaScript
37 lines
2.3 KiB
JavaScript
import { test } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { referenceImageLimit, selectVideoReferences, resolveReferenceMentions, usesComposedFirstFrame } from '../app/utils/video-references.js'
|
|
import { videoReferenceError } from '../app/utils/video-reference-error.js'
|
|
|
|
const bound = [
|
|
{ name: '404宿舍', url: '/scene.png' },
|
|
{ name: '乔雨灵', url: '/girl.png' },
|
|
{ name: '乔雨', url: '/other.png' },
|
|
{ name: '无图道具', url: '' },
|
|
{ name: '重复图片', url: '/scene.png' },
|
|
]
|
|
test('native single-image limits and reference numbering stay separate from frame composition', () => {
|
|
const single = selectVideoReferences(bound, referenceImageLimit('LTX-2.3', 'localvideo'))
|
|
assert.deepEqual(single, [bound[0]])
|
|
const full = selectVideoReferences(bound, referenceImageLimit('MiniMax-H3', 'minimax'))
|
|
assert.deepEqual(full, bound.slice(0, 3))
|
|
const prompt = '@图片2乔雨灵 在 @图片1404宿舍 看向 @图片3乔雨。'
|
|
assert.equal(resolveReferenceMentions(prompt, single, bound), '@乔雨灵 在 @图片1404宿舍 看向 @乔雨。')
|
|
assert.equal(resolveReferenceMentions(prompt, full), prompt)
|
|
assert.equal(bound.length, 5)
|
|
})
|
|
test('single-image models and Wan 3 retain their actual limits', () => {
|
|
for (const model of ['LTX-2.3','LTX-2.3-Text-Preserve','Wan2.2-I2V']) assert.equal(usesComposedFirstFrame(model), true)
|
|
for (const model of ['MiniMax-H3','MiniMax-H3-VDN-H3','wan3.0-video']) assert.equal(usesComposedFirstFrame(model), false)
|
|
assert.equal(referenceImageLimit('LTX-2.3-Text-Preserve', 'localvideo'), 1)
|
|
assert.equal(referenceImageLimit('Wan2.2-I2V', 'localvideo'), 1)
|
|
assert.equal(referenceImageLimit('wan3.0-video', 'aliyun'), 10)
|
|
assert.equal(referenceImageLimit('MiniMax-H3-VDN-H3', 'localvideo'), 9)
|
|
})
|
|
test('historic task errors explain the limit without leaking raw provider details', () => {
|
|
const raw = 'API error 400: {"error":{"message":"LTX-2.3 requires 0-1 images","type":"bridge_error","code":400}}'
|
|
assert.match(videoReferenceError(raw), /LTX-2.3 最多支持 1 张参考图/)
|
|
assert.equal(videoReferenceError('API error 401: {"secret":"test"}'), '')
|
|
assert.equal(videoReferenceError('首帧模式只能提交 1 张图片,不能混用多张参考图'), '首帧模式只能提交 1 张图片,不能混用多张参考图')
|
|
})
|