Skip to content

Commit df57e5b

Browse files
dante01yoonampagent
andcommitted
fix: limit past-due cancellation to supported status
Amp-Thread-ID: https://ampcode.com/threads/T-01a001d5-47e3-720d-8e82-82c45995251e Co-authored-by: Amp <amp@ampcode.com>
1 parent d7433d3 commit df57e5b

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

src/platform/workspace/composables/useWorkspaceMenuItems.test.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,29 @@ describe('useWorkspaceMenuItems', () => {
116116
)
117117
})
118118

119-
it.for(['payment_failed', 'paused'])(
120-
'allows cancellation while a %s plan needs payment recovery',
121-
(billingStatus) => {
122-
state.billingStatus = billingStatus
123-
state.canManageSubscriptionLifecycle = true
124-
state.isActiveSubscription = false
125-
126-
const { menuItems } = useWorkspaceMenuItems()
127-
128-
expect(menuItems.value.map((item) => item.label)).toContain(
129-
'subscription.cancelPlan'
130-
)
131-
}
132-
)
119+
it('allows cancellation while a payment_failed plan needs payment recovery', () => {
120+
state.billingStatus = 'payment_failed'
121+
state.canManageSubscriptionLifecycle = true
122+
state.isActiveSubscription = false
123+
124+
const { menuItems } = useWorkspaceMenuItems()
125+
126+
expect(menuItems.value.map((item) => item.label)).toContain(
127+
'subscription.cancelPlan'
128+
)
129+
})
130+
131+
it('withholds cancellation while a plan is paused', () => {
132+
state.billingStatus = 'paused'
133+
state.canManageSubscriptionLifecycle = true
134+
state.isActiveSubscription = false
135+
136+
const { menuItems } = useWorkspaceMenuItems()
137+
138+
expect(menuItems.value.map((item) => item.label)).not.toContain(
139+
'subscription.cancelPlan'
140+
)
141+
})
133142

134143
it('rechecks eligibility before opening the cancellation dialog', () => {
135144
state.canManageSubscriptionLifecycle = true

src/platform/workspace/composables/useWorkspaceMenuItems.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ export function useWorkspaceMenuItems() {
6666
() =>
6767
permissions.value.canManageSubscriptionLifecycle &&
6868
(isActiveSubscription.value ||
69-
billingStatus.value === 'payment_failed' ||
70-
billingStatus.value === 'paused') &&
69+
billingStatus.value === 'payment_failed') &&
7170
!isSubscriptionCancelled.value &&
7271
!isFreeTier.value
7372
)

0 commit comments

Comments
 (0)