fix: align model availability and retail pricing controls
This commit is contained in:
1 parent
af505c5596
commit
813b406da4
9 files changed
+130
-47
No files matched your search
@@ -1,9 +1,21 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { nextTick, ref } from 'vue'
|
||||
import { buildModelCatalog, providerCapabilityLabel, setGroupSelection, summarizeModelCatalog } from '../src/services/model-catalog.ts'
|
||||
import { buildModelCatalog, providerCapabilityLabel, routeReadinessLabel, routeReadinessReason, setGroupSelection, summarizeModelCatalog } from '../src/services/model-catalog.ts'
|
||||
import { usePagination } from '../src/composables/usePagination.ts'
|
||||
|
||||
test('deferred integration overrides pricing and readiness across model entry points', () => {
|
||||
const ready = {pricingConfigured:true,billingReady:true,executionReady:true}
|
||||
const deferred = {...ready,integrationDeferred:true}
|
||||
assert.equal(routeReadinessLabel(ready),'可调用')
|
||||
assert.equal(routeReadinessLabel(deferred),'暂不接入')
|
||||
assert.match(routeReadinessReason(deferred),/本期暂不接入/)
|
||||
assert.equal(routeReadinessLabel({...ready,pricingConfigured:false}),'报价待核实')
|
||||
assert.equal(routeReadinessLabel({...ready,billingReady:false}),'用量计费待核实')
|
||||
assert.equal(routeReadinessLabel({...ready,executionReady:false}),'执行接口待接入')
|
||||
assert.equal(routeReadinessLabel({...ready,status:'disabled'}),'已停用')
|
||||
})
|
||||
|
||||
test('catalog summary distinguishes published models, ready models, ready routes, and missing prices', () => {
|
||||
const definitions = [
|
||||
'available', 'legacy-ready', 'no-routes', 'pricing-only', 'billing-only',
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { calculateTokenRetailPricing, groupDiscountLabel, modelStandardPriceLabel, platformPriceLabel, standardPriceLabel } from '../src/services/pricing.ts'
|
||||
import { calculateTokenRetailPricing, editRetailAmounts, groupDiscountLabel, modelStandardPriceLabel, platformPriceLabel, standardPriceLabel } from '../src/services/pricing.ts'
|
||||
|
||||
test('admin editing fixed prices preserves source and billing metadata without another discount or conversion', () => {
|
||||
const original = {price:0.4032, unit:'CNY / image', discount:5.6, exchangeRate:7.2, standardPrice:{price:0.1,unit:'USD / image'}, taskBilling:{mode:'fixed'}, evidence:'confirmed'}
|
||||
const saved = editRetailAmounts(original, original.unit, {price:0.48384,input:'',output:'',cachedInput:'',imageInput:''})
|
||||
assert.deepEqual(saved, {...original,price:0.48384})
|
||||
assert.equal(original.price,0.4032)
|
||||
assert.equal(platformPriceLabel(saved),'平台售价 ¥0.48384 / 张(单张请求)')
|
||||
})
|
||||
|
||||
test('admin token editing preserves image-input rate and removes incompatible fixed price', () => {
|
||||
const saved = editRetailAmounts({price:1,taskBilling:{mode:'openai-image-tokens'}}, 'CNY / 1M tokens', {price:'',input:20.16,output:'120.96',cachedInput:0,imageInput:'32.256'})
|
||||
assert.deepEqual(saved, {unit:'CNY / 1M tokens',input:20.16,output:120.96,cachedInput:0,imageInput:32.256,taskBilling:{mode:'openai-image-tokens'}})
|
||||
assert.equal(editRetailAmounts(undefined,'CNY / image',{price:1e-8,input:'',output:'',cachedInput:'',imageInput:''}).price,1e-8)
|
||||
for (const price of [-1,NaN,Infinity,1000001,0.000000001]) assert.throws(()=>editRetailAmounts(undefined,'CNY / image',{price,input:'',output:'',cachedInput:'',imageInput:''}),/人民币价格/)
|
||||
assert.throws(()=>editRetailAmounts(undefined,'USD / image',{price:1,input:'',output:'',cachedInput:'',imageInput:''}),/人民币计费单位/)
|
||||
})
|
||||
|
||||
test('fixed-unit pricing shows platform task price without inventing a standard price or discount', () => {
|
||||
const tripo = { price: 1.44, unit: 'CNY / task', upstreamCredits: 20, exchangeRate: 7.2, priceSource: 'Tripo 官方', standardPrice: { price: 0.2, unit: 'USD / task', credits: 20 } }
|
||||
|
||||
Reference in new issue
Block a user