Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions src/composables/billing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export interface BalanceInfo {
cloudCreditBalanceMicros?: number
/** Server-suggested top-up that covers a negative balance; null otherwise. */
suggestedTopupAmountCents?: number | null
/** Served `low_balance`. Absent when the balance response omits it. */
lowBalance?: boolean
}

/** Whether the billing portal opened, and why not when it did not. */
Expand Down
29 changes: 25 additions & 4 deletions src/composables/useFeatureFlags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,12 @@ describe('useFeatureFlags', () => {
})

describe.for([
{ flag: 'unifiedBillingSettingsEnabled' as const },
{ flag: 'autoTopUpEnabled' as const }
])('$flag', ({ flag }) => {
{
flag: 'unifiedBillingSettingsEnabled' as const,
offCloudTrue: true
},
{ flag: 'autoTopUpEnabled' as const, offCloudTrue: false }
])('$flag', ({ flag, offCloudTrue }) => {
afterEach(() => {
vi.mocked(distributionTypes).isCloud = false
})
Expand All @@ -397,7 +400,25 @@ describe('useFeatureFlags', () => {
expected: false
},
{ case: 'true on cloud', cloud: true, value: true, expected: true },
{ case: 'true off cloud', cloud: false, value: true, expected: false }
{
case: 'missing off cloud',
cloud: false,
value: undefined,
expected: false
},
{ case: 'false off cloud', cloud: false, value: false, expected: false },
{
case: 'malformed off cloud',
cloud: false,
value: 'true',
expected: false
},
{
case: 'true off cloud',
cloud: false,
value: true,
expected: offCloudTrue
}
])('is $expected when $case', ({ cloud, value, expected }) => {
vi.mocked(distributionTypes).isCloud = cloud
vi.mocked(api.getServerFeature).mockReturnValue(value)
Expand Down
2 changes: 0 additions & 2 deletions src/composables/useFeatureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ export function useFeatureFlags() {
return this.billingSdkSubscriptionEnabled && this.unifiedCloudAuthEnabled
},
get unifiedBillingSettingsEnabled() {
if (!isCloud) return false

return resolveStrictBooleanFlag(
ServerFeatureFlag.UNIFIED_BILLING_SETTINGS,
remoteConfig.value.unified_billing_settings
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -3698,6 +3698,10 @@
"addCredits": "Add credits",
"dismiss": "Dismiss"
},
"lowCredits": {
"title": "Credits are low",
"localBody": "You have {credits} credits left. Add credits to keep running Partner Nodes."
},
"ending": {
"title": "Your Team plan ends on {date}",
"body": "You won't be charged again. Members keep full access until then. Resume your plan to keep your team's shared credits.",
Expand Down
24 changes: 23 additions & 1 deletion src/platform/settings/composables/useSettingUI.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ describe('useSettingUI', () => {
})
})

it('shows only Plan & Credits in the local Workspace group', () => {
it('keeps Plan & Credits on local when unified billing settings is off', () => {
env.state.isCloud = false
vi.mocked(useFeatureFlags().flags).unifiedBillingSettingsEnabled = false
vi.mocked(useFeatureFlags().flags).partnerNodeGovernanceEnabled = true
const { findPanelByKey, navGroups } = useSettingUI()
const workspaceItems = navGroups.value
.find((group) => group.title === 'Workspace')
Expand All @@ -261,6 +264,25 @@ describe('useSettingUI', () => {
expect(workspaceItems).toEqual([
{ id: 'workspace', label: 'PlanCredits' }
])
expect(findPanelByKey('workspace')?.props).toEqual({
section: 'planCredits'
})
expect(findPanelByKey('workspace-members')).toBeNull()
expect(findPanelByKey('workspace-allowlist')).toBeNull()
})

it('mounts the Billing tab on local when unified billing settings is on', () => {
env.state.isCloud = false
const flags = vi.mocked(useFeatureFlags().flags)
flags.unifiedBillingSettingsEnabled = true
flags.partnerNodeGovernanceEnabled = true
const { findPanelByKey, navGroups } = useSettingUI('workspace')
const workspaceItems = navGroups.value
.find((group) => group.title === 'Workspace')
?.items.map(({ id, label }) => ({ id, label }))

expect(workspaceItems).toEqual([{ id: 'workspace', label: 'Billing' }])
expect(findPanelByKey('workspace')?.props).toBeUndefined()
expect(findPanelByKey('workspace-members')).toBeNull()
expect(findPanelByKey('workspace-allowlist')).toBeNull()
})
Expand Down
Loading
Loading