mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-31 08:25:35 +00:00
Merge origin/main into feat/channel-monitor-v2-ops-ui
Resolves three conflicts, all of the "both branches appended to the same block" shape. Every one is resolved as a union of both sides; nothing from either parent is dropped. - handler/admin/setting_handler_update.go: keep ChannelMonitorHideThroughput (V2) alongside GrokDefaultTextModel / GrokCrossClientModelMapEnabled / GrokDefaultBaseURLMode (#5408). UpdateSettings writes every key on each save, so dropping either side would reset those settings to zero values. - service/domain_constants.go: keep SettingKeyChannelMonitorHideThroughput and the three SettingKeyGrok* constants. - repository/migrations_runner.go: keep the 195 checksum rule (V2) and the 218/219/220 rules (#5408).
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
BILLING_MODE_IMAGE,
|
||||
BILLING_MODE_TOKEN,
|
||||
BILLING_MODE_VIDEO,
|
||||
getDisplayBillingMode,
|
||||
isImageUsage
|
||||
} from '../billingMode'
|
||||
|
||||
describe('billingMode helpers', () => {
|
||||
it('prefers explicit video mode over image_count', () => {
|
||||
expect(
|
||||
getDisplayBillingMode({ image_count: 1, billing_mode: BILLING_MODE_VIDEO })
|
||||
).toBe(BILLING_MODE_VIDEO)
|
||||
expect(isImageUsage({ image_count: 1, billing_mode: BILLING_MODE_VIDEO })).toBe(false)
|
||||
})
|
||||
|
||||
it('infers image when image_count set and mode missing', () => {
|
||||
expect(getDisplayBillingMode({ image_count: 2, billing_mode: null })).toBe(BILLING_MODE_IMAGE)
|
||||
})
|
||||
|
||||
it('keeps token mode even with image_count', () => {
|
||||
expect(
|
||||
getDisplayBillingMode({ image_count: 1, billing_mode: BILLING_MODE_TOKEN })
|
||||
).toBe(BILLING_MODE_TOKEN)
|
||||
})
|
||||
})
|
||||
@@ -32,6 +32,10 @@ export function isImageUsage(row: Pick<ImageBillingRow, 'image_count' | 'billing
|
||||
}
|
||||
|
||||
export function getDisplayBillingMode(row: Pick<ImageBillingRow, 'billing_mode' | 'image_count'> | null | undefined): string | null | undefined {
|
||||
// Explicit video/token modes always win over image_count heuristics.
|
||||
if (row?.billing_mode === BILLING_MODE_VIDEO || row?.billing_mode === BILLING_MODE_TOKEN) {
|
||||
return row.billing_mode
|
||||
}
|
||||
if ((row?.image_count ?? 0) > 0 && !row?.billing_mode) {
|
||||
return BILLING_MODE_IMAGE
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user