Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/composables/node/useNodePricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,20 +966,20 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
displayPrice: pixversePricingCalculator
},
RecraftCreativeUpscaleNode: {
displayPrice: '$0.25/Run'
displayPrice: '$0.36/Run'
},
RecraftCrispUpscaleNode: {
displayPrice: '$0.004/Run'
displayPrice: '$0.006/Run'
},
RecraftGenerateColorFromImageNode: {
displayPrice: (node: LGraphNode): string => {
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.04 x n/Run'
if (!nWidget) return '$0.057 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.04 * n).toFixed(2)
const cost = (0.057 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -988,10 +988,10 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.04 x n/Run'
if (!nWidget) return '$0.057 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.04 * n).toFixed(2)
const cost = (0.057 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -1000,10 +1000,10 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.08 x n/Run'
if (!nWidget) return '$0.11 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.08 * n).toFixed(2)
const cost = (0.11 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -1012,10 +1012,10 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.04 x n/Run'
if (!nWidget) return '$0.057 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.04 * n).toFixed(2)
const cost = (0.057 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -1024,28 +1024,28 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.04 x n/Run'
if (!nWidget) return '$0.057 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.04 * n).toFixed(2)
const cost = (0.057 * n).toFixed(2)
return `$${cost}/Run`
}
},
RecraftRemoveBackgroundNode: {
displayPrice: '$0.01/Run'
displayPrice: '$0.014/Run'
},
RecraftReplaceBackgroundNode: {
displayPrice: '$0.04/Run'
displayPrice: '$0.057/Run'
},
RecraftTextToImageNode: {
displayPrice: (node: LGraphNode): string => {
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.04 x n/Run'
if (!nWidget) return '$0.057 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.04 * n).toFixed(2)
const cost = (0.057 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -1054,10 +1054,10 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.08 x n/Run'
if (!nWidget) return '$0.11 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.08 * n).toFixed(2)
const cost = (0.11 * n).toFixed(2)
return `$${cost}/Run`
}
},
Expand All @@ -1066,10 +1066,10 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
const nWidget = node.widgets?.find(
(w) => w.name === 'n'
) as IComboWidget
if (!nWidget) return '$0.01 x n/Run'
if (!nWidget) return '$0.014 x n/Run'

const n = Number(nWidget.value) || 1
const cost = (0.01 * n).toFixed(2)
const cost = (0.014 * n).toFixed(3)
return `$${cost}/Run`
}
},
Expand Down
14 changes: 7 additions & 7 deletions tests-ui/tests/composables/node/useNodePricing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.12/Run') // 0.04 * 3
expect(price).toBe('$0.17/Run') // 0.057 * 3
})

it('should calculate dynamic pricing for RecraftTextToVectorNode based on n value', () => {
Expand All @@ -1214,15 +1214,15 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.16/Run') // 0.08 * 2
expect(price).toBe('$0.22/Run') // 0.11 * 2
})

it('should fall back to static display when n widget is missing', () => {
const { getNodeDisplayPrice } = useNodePricing()
const node = createMockNode('RecraftTextToImageNode', [])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.04 x n/Run')
expect(price).toBe('$0.057 x n/Run')
})

it('should handle edge case when n value is 1', () => {
Expand All @@ -1232,7 +1232,7 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.04/Run') // 0.04 * 1
expect(price).toBe('$0.06/Run') // 0.057 * 1
})
})
})
Expand Down Expand Up @@ -1312,7 +1312,7 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.12/Run') // 0.04 * 3
expect(price).toBe('$0.17/Run') // 0.057 * 3
})

it('should calculate dynamic pricing for RecraftVectorizeImageNode', () => {
Expand All @@ -1322,7 +1322,7 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.05/Run') // 0.01 * 5
expect(price).toBe('$0.070/Run') // 0.014 * 5
})

it('should calculate dynamic pricing for RecraftGenerateVectorImageNode', () => {
Expand All @@ -1332,7 +1332,7 @@ describe('useNodePricing', () => {
])

const price = getNodeDisplayPrice(node)
expect(price).toBe('$0.16/Run') // 0.08 * 2
expect(price).toBe('$0.22/Run') // 0.11 * 2
})
})

Expand Down