mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-13 09:00:16 +00:00
OpenAIVideoSora2 Frontend pricing (#5958)
test: update OpenAIVideoSora2 tests to use `size` instead of `resolution` Refactored all OpenAIVideoSora2 test cases in useNodePricing.test.ts to align with the updated node logic that replaces the `resolution` widget with `size`. Adjusted validation, pricing, and error message expectations accordingly. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5958-Update-OpenAIVideoSora2-tests-for-new-size-based-pricing-logic-2856d73d365081c9919dd256cce40492) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -301,7 +301,117 @@ describe('useNodePricing', () => {
|
||||
expect(price).toBe('$0.04-0.12/Run (varies with size & quality)')
|
||||
})
|
||||
})
|
||||
// ============================== OpenAIVideoSora2 ==============================
|
||||
describe('dynamic pricing - OpenAIVideoSora2', () => {
|
||||
it('should require model, duration & size when widgets are missing', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
const node = createMockNode('OpenAIVideoSora2', [])
|
||||
expect(getNodeDisplayPrice(node)).toBe('Set model, duration & size')
|
||||
})
|
||||
|
||||
it('should require duration when duration is invalid or zero', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
const nodeNaN = createMockNode('OpenAIVideoSora2', [
|
||||
{ name: 'model', value: 'sora-2-pro' },
|
||||
{ name: 'duration', value: 'oops' },
|
||||
{ name: 'size', value: '720x1280' }
|
||||
])
|
||||
expect(getNodeDisplayPrice(nodeNaN)).toBe('Set duration (4/8/12)')
|
||||
|
||||
const nodeZero = createMockNode('OpenAIVideoSora2', [
|
||||
{ name: 'model', value: 'sora-2-pro' },
|
||||
{ name: 'duration', value: 0 },
|
||||
{ name: 'size', value: '720x1280' }
|
||||
])
|
||||
expect(getNodeDisplayPrice(nodeZero)).toBe('Set duration (4/8/12)')
|
||||
})
|
||||
|
||||
it('should require size when size is missing', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
const node = createMockNode('OpenAIVideoSora2', [
|
||||
{ name: 'model', value: 'sora-2-pro' },
|
||||
{ name: 'duration', value: 8 }
|
||||
])
|
||||
expect(getNodeDisplayPrice(node)).toBe(
|
||||
'Set size (720x1280, 1280x720, 1024x1792, 1792x1024)'
|
||||
)
|
||||
})
|
||||
|
||||
it('should compute pricing for sora-2-pro with 1024x1792', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
const node = createMockNode('OpenAIVideoSora2', [
|
||||
{ name: 'model', value: 'sora-2-pro' },
|
||||
{ name: 'duration', value: 8 },
|
||||
{ name: 'size', value: '1024x1792' }
|
||||
])
|
||||
expect(getNodeDisplayPrice(node)).toBe('$4.00/Run') // 0.5 * 8
|
||||
})
|
||||
|
||||
it('should compute pricing for sora-2-pro with 720x1280', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
const node = createMockNode('OpenAIVideoSora2', [
|
||||
{ name: 'model', value: 'sora-2-pro' },
|
||||
{ name: 'duration', value: 12 },
|
||||
{ name: 'size', value: '720x1280' }
|
||||
])
|
||||
expect(getNodeDisplayPrice(node)).toBe('$3.60/Run') // 0.3 * 12
|
||||
})
|
||||
|
||||
it('should reject unsupported size for sora-2-pro', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
const node = createMockNode('OpenAIVideoSora2', [
|
||||
{ name: 'model', value: 'sora-2-pro' },
|
||||
{ name: 'duration', value: 8 },
|
||||
{ name: 'size', value: '640x640' }
|
||||
])
|
||||
expect(getNodeDisplayPrice(node)).toBe(
|
||||
'Size must be 720x1280, 1280x720, 1024x1792, or 1792x1024'
|
||||
)
|
||||
})
|
||||
|
||||
it('should compute pricing for sora-2 (720x1280 only)', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
const node = createMockNode('OpenAIVideoSora2', [
|
||||
{ name: 'model', value: 'sora-2' },
|
||||
{ name: 'duration', value: 10 },
|
||||
{ name: 'size', value: '720x1280' }
|
||||
])
|
||||
expect(getNodeDisplayPrice(node)).toBe('$1.00/Run') // 0.1 * 10
|
||||
})
|
||||
|
||||
it('should reject non-720 sizes for sora-2', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
const node = createMockNode('OpenAIVideoSora2', [
|
||||
{ name: 'model', value: 'sora-2' },
|
||||
{ name: 'duration', value: 8 },
|
||||
{ name: 'size', value: '1024x1792' }
|
||||
])
|
||||
expect(getNodeDisplayPrice(node)).toBe(
|
||||
'sora-2 supports only 720x1280 or 1280x720'
|
||||
)
|
||||
})
|
||||
it('should accept duration_s alias for duration', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
const node = createMockNode('OpenAIVideoSora2', [
|
||||
{ name: 'model', value: 'sora-2-pro' },
|
||||
{ name: 'duration_s', value: 4 },
|
||||
{ name: 'size', value: '1792x1024' }
|
||||
])
|
||||
expect(getNodeDisplayPrice(node)).toBe('$2.00/Run') // 0.5 * 4
|
||||
})
|
||||
|
||||
it('should be case-insensitive for model and size', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
const node = createMockNode('OpenAIVideoSora2', [
|
||||
{ name: 'model', value: 'SoRa-2-PrO' },
|
||||
{ name: 'duration', value: 12 },
|
||||
{ name: 'size', value: '1280x720' }
|
||||
])
|
||||
expect(getNodeDisplayPrice(node)).toBe('$3.60/Run') // 0.3 * 12
|
||||
})
|
||||
})
|
||||
|
||||
// ============================== MinimaxHailuoVideoNode ==============================
|
||||
describe('dynamic pricing - MinimaxHailuoVideoNode', () => {
|
||||
it('should return $0.28 for 6s duration and 768P resolution', () => {
|
||||
const { getNodeDisplayPrice } = useNodePricing()
|
||||
|
||||
Reference in New Issue
Block a user