Skip to content

Commit 64b10c6

Browse files
dante01yoonampagent
andcommitted
test(workspace): align retired flag coverage
Amp-Thread-ID: https://ampcode.com/threads/T-019fc8cd-b288-7161-a590-cd76d51212bf Co-authored-by: Amp <amp@ampcode.com>
1 parent b9fd355 commit 64b10c6

4 files changed

Lines changed: 6 additions & 109 deletions

File tree

browser_tests/tests/currentUserPopoverCredits.spec.ts

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { expect } from '@playwright/test'
22

33
import type { CloudSubscriptionStatusResponse } from '@/platform/cloud/subscription/composables/useSubscription'
44
import type { RemoteConfig } from '@/platform/remoteConfig/types'
5-
import type {
6-
BillingStatusResponse,
7-
WorkspaceWithRole
8-
} from '@/platform/workspace/api/workspaceApi'
5+
import type { WorkspaceWithRole } from '@/platform/workspace/api/workspaceApi'
96
import type { WorkspaceTokenResponse } from '@/platform/workspace/stores/workspaceAuthStore'
107
import type { operations } from '@/types/comfyRegistryTypes'
118
import { comfyPageFixture } from '@e2e/fixtures/ComfyPage'
@@ -54,20 +51,6 @@ const mockSubscriptionStatus: CloudSubscriptionStatusResponse = {
5451
end_date: FUTURE_DATE
5552
}
5653

57-
// The facade routes a Cloud personal workspace through `/api/billing/*`. The
58-
// cancelled-but-active state maps to `is_active: true`
59-
// with `subscription_status: 'canceled'`; a paid tier keeps "Add credits"
60-
// visible (free tier would swap it for "Upgrade to add credits").
61-
const mockBillingStatus: BillingStatusResponse = {
62-
is_active: true,
63-
subscription_status: 'canceled',
64-
subscription_tier: 'PRO',
65-
subscription_duration: 'MONTHLY',
66-
has_funds: true,
67-
cancel_at: FUTURE_DATE,
68-
renewal_date: FUTURE_DATE
69-
}
70-
7154
// ~6.3M credits — a 7-digit balance is what pushes the second action button out
7255
// of the popover before the fix.
7356
const mockBalance: CustomerBalanceResponse = {
@@ -126,31 +109,6 @@ const test = comfyPageFixture.extend({
126109
})
127110
)
128111

129-
// The popover sources its data from the workspace billing endpoints.
130-
await page.route('**/api/billing/status', (route) =>
131-
route.fulfill({
132-
status: 200,
133-
contentType: 'application/json',
134-
body: JSON.stringify(mockBillingStatus)
135-
})
136-
)
137-
138-
await page.route('**/api/billing/balance', (route) =>
139-
route.fulfill({
140-
status: 200,
141-
contentType: 'application/json',
142-
body: JSON.stringify(mockBalance)
143-
})
144-
)
145-
146-
await page.route('**/api/billing/plans', (route) =>
147-
route.fulfill({
148-
status: 200,
149-
contentType: 'application/json',
150-
body: JSON.stringify({ plans: [] })
151-
})
152-
)
153-
154112
await use(page)
155113
}
156114
})

browser_tests/tests/dialogs/creditsTile.spec.ts

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { Page, Request } from '@playwright/test'
44
import type { RemoteConfig } from '@/platform/remoteConfig/types'
55
import type {
66
BillingOpStatusResponse,
7-
BillingStatusResponse,
87
CreateTopupResponse
98
} from '@/platform/workspace/api/workspaceApi'
109

@@ -29,8 +28,8 @@ import {
2928
* shared `comfyPage` fixture can't boot (it expects the OSS devtools backend).
3029
* Instead this drives a raw page: mock Firebase auth + every boot endpoint so
3130
* the cloud app initializes against fully stubbed data. The facade routes a
32-
* personal workspace through the workspace `/api/billing/*` endpoints (mocked
33-
* with an active Pro subscription). The tile
31+
* personal workspace through the legacy `/customers/*` endpoints (mocked with
32+
* an active Pro subscription). The tile
3433
* should then render its total / progress bar / monthly+additional breakdown /
3534
* add-credits.
3635
*/
@@ -42,8 +41,6 @@ const jsonRoute = (body: unknown) => ({
4241
body: JSON.stringify(body)
4342
})
4443

45-
// Legacy `/customers/balance` and workspace `/api/billing/balance` share the
46-
// same response shape, so one body fulfills both endpoints.
4744
const balanceRoute = (balance: {
4845
amount: number
4946
monthly: number
@@ -60,14 +57,6 @@ const balanceRoute = (balance: {
6057
// 6000 -> 12,660 total; 5000 -> 10,550 monthly remaining; 1000 -> 2,110 extra.
6158
const DEFAULT_BALANCE = { amount: 6000, monthly: 5000, prepaid: 1000 }
6259

63-
const mockBillingStatus: BillingStatusResponse = {
64-
is_active: true,
65-
subscription_tier: 'PRO',
66-
subscription_duration: 'MONTHLY',
67-
renewal_date: '2099-02-20T12:00:00Z',
68-
has_funds: true
69-
}
70-
7160
async function mockCloudBoot(page: Page, billingControlEnabled = true) {
7261
// Frontend-origin boot endpoints (proxied to the backend in production).
7362
// `/api/features` is the remote-config source for the billing UX rollout.
@@ -125,7 +114,7 @@ async function mockCloudBoot(page: Page, billingControlEnabled = true) {
125114
)
126115
)
127116

128-
// Legacy billing (flag-off path, api.comfy.org/customers/*).
117+
// Legacy account billing (api.comfy.org/customers/*).
129118
await page.route('**/customers/cloud-subscription-status', (r) =>
130119
r.fulfill(
131120
jsonRoute({
@@ -140,32 +129,16 @@ async function mockCloudBoot(page: Page, billingControlEnabled = true) {
140129
await page.route('**/customers/balance', (r) =>
141130
r.fulfill(balanceRoute(DEFAULT_BALANCE))
142131
)
143-
144-
// Workspace billing (flag-on path) — a personal workspace now routes through
145-
// `/api/billing/*`.
146-
await page.route('**/api/billing/status', (r) =>
147-
r.fulfill(jsonRoute(mockBillingStatus))
148-
)
149-
await page.route('**/api/billing/balance', (r) =>
150-
r.fulfill(balanceRoute(DEFAULT_BALANCE))
151-
)
152-
await page.route('**/api/billing/plans', (r) =>
153-
r.fulfill(jsonRoute({ plans: [] }))
154-
)
155132
}
156133

157134
async function mockBalance(
158135
page: Page,
159136
balance: { amount: number; monthly: number; prepaid: number }
160137
) {
161138
await page.unroute('**/customers/balance')
162-
await page.unroute('**/api/billing/balance')
163139
await page.route('**/customers/balance', (r) =>
164140
r.fulfill(balanceRoute(balance))
165141
)
166-
await page.route('**/api/billing/balance', (r) =>
167-
r.fulfill(balanceRoute(balance))
168-
)
169142
}
170143

171144
async function openSettings(page: Page) {

src/platform/auth/session/useSessionCookie.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ describe('useSessionCookie', () => {
200200
expect(finalHeaders.get('Authorization')).toBe('Bearer firebase-user-a')
201201
})
202202

203-
it('does not let strict Firebase creation join a weaker request', async () => {
203+
it('lets strict creation join an in-flight Firebase request on Cloud', async () => {
204204
mockGetAuthHeader.mockResolvedValue(null)
205205
mockGetIdToken.mockResolvedValue('firebase-id-token')
206206
vi.mocked(globalThis.fetch).mockResolvedValue(
@@ -218,6 +218,7 @@ describe('useSessionCookie', () => {
218218
vi.mocked(globalThis.fetch).mock.calls[0][1]?.headers
219219
)
220220
expect(headers.get('Authorization')).toBe('Bearer firebase-id-token')
221+
expect(mockGetAuthHeader).not.toHaveBeenCalled()
221222
})
222223

223224
it('serializes session deletion after an in-flight creation', async () => {

src/platform/settings/composables/useSettingUI.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { Component } from 'vue'
33
import { useI18n } from 'vue-i18n'
44

55
import { useCurrentUser } from '@/composables/auth/useCurrentUser'
6-
import { useBillingContext } from '@/composables/billing/useBillingContext'
76
import { useFeatureFlags } from '@/composables/useFeatureFlags'
87
import { useVueFeatureFlags } from '@/composables/useVueFeatureFlags'
98
import { isCloud, isDesktop } from '@/platform/distribution/types'
@@ -58,7 +57,6 @@ export function useSettingUI(
5857

5958
const { flags } = useFeatureFlags()
6059
const { shouldRenderVueNodes } = useVueFeatureFlags()
61-
const { isActiveSubscription, type: billingType } = useBillingContext()
6260
const { workspaceRole } = useWorkspaceUI()
6361

6462
const settingRoot = computed<SettingTreeNode>(() => {
@@ -139,33 +137,6 @@ export function useSettingUI(
139137
)
140138
}
141139

142-
const subscriptionPanel: SettingPanelItem | null =
143-
!isCloud || !window.__CONFIG__?.subscription_required
144-
? null
145-
: {
146-
node: {
147-
key: 'subscription',
148-
label: 'PlanCredits',
149-
children: []
150-
},
151-
component: defineAsyncComponent(
152-
() =>
153-
import('@/platform/cloud/subscription/components/SubscriptionPanel.vue')
154-
)
155-
}
156-
157-
const shouldShowPlanCreditsPanel = computed(() => {
158-
if (!subscriptionPanel) return false
159-
return isActiveSubscription.value
160-
})
161-
162-
const shouldShowLegacyPlanCreditsPanel = computed(
163-
() =>
164-
isLoggedIn.value &&
165-
billingType.value === 'legacy' &&
166-
shouldShowPlanCreditsPanel.value
167-
)
168-
169140
const userPanel: SettingPanelItem = {
170141
node: {
171142
key: 'user',
@@ -303,9 +274,6 @@ export function useSettingUI(
303274
keybindingPanel,
304275
extensionPanel,
305276
...(isDesktop ? [serverConfigPanel] : []),
306-
...(shouldShowPlanCreditsPanel.value && subscriptionPanel
307-
? [subscriptionPanel]
308-
: []),
309277
...(shouldShowSecretsPanel.value ? [secretsPanel] : [])
310278
].filter((panel) => panel !== null && panel.component)
311279
)
@@ -396,9 +364,6 @@ export function useSettingUI(
396364
label: 'Account',
397365
children: [
398366
userPanel.node,
399-
...(shouldShowLegacyPlanCreditsPanel.value && subscriptionPanel
400-
? [subscriptionPanel.node]
401-
: []),
402367
...(shouldShowSecretsPanel.value ? [secretsPanel.node] : []),
403368
...(isLoggedIn.value &&
404369
!(isCloud && window.__CONFIG__?.subscription_required)

0 commit comments

Comments
 (0)