修复(充值弹层): max 档不再提示可补差升档
- 状态卡原先无条件显示「可同周期补差升档」,已是最高档时并无更高档位可升 - 父组件按启用目录计算 hasUpgradePath(存在 rank 更高的档位),无升级路径时只保留「周期切换需等到期后」 - 补 max 档与 plus 档的对照断言
This commit is contained in:
@@ -291,6 +291,7 @@ describe('PlatformProfileRechargeModal', () => {
|
||||
screen.getByRole('button', { name: 'Plus 年付 当前套餐' }),
|
||||
).toHaveProperty('disabled', true);
|
||||
expect(screen.getByText('当前 Plus · 年付')).toBeTruthy();
|
||||
expect(screen.getAllByText(/可同周期补差升档/).length).toBeGreaterThan(0);
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'Max 年付 补差升级' }));
|
||||
|
||||
@@ -307,6 +308,39 @@ describe('PlatformProfileRechargeModal', () => {
|
||||
expect(onSubmitMembershipCheckout).toHaveBeenCalledWith('max', 'yearly');
|
||||
});
|
||||
|
||||
test('已是最高的 max 档不再提示可补差升档', () => {
|
||||
render(
|
||||
<PlatformProfileRechargeModal
|
||||
center={{
|
||||
mudPointBalance: buildMudPointBalance(8_650),
|
||||
membership: buildActiveMembership('max', 'yearly'),
|
||||
pointProducts: buildPointProducts(),
|
||||
membershipPlans: [STARTER_PLAN, PLUS_PLAN, MAX_PLAN],
|
||||
latestOrder: null,
|
||||
hasPointsRecharged: true,
|
||||
}}
|
||||
isLoading={false}
|
||||
error={null}
|
||||
submittingProductId={null}
|
||||
nativePayment={null}
|
||||
membershipQuote={null}
|
||||
isLoadingMembershipQuote={false}
|
||||
membershipQuoteError={null}
|
||||
onClose={vi.fn()}
|
||||
onRetry={vi.fn()}
|
||||
onBuy={vi.fn()}
|
||||
onRequestMembershipQuote={vi.fn()}
|
||||
onSubmitMembershipCheckout={vi.fn()}
|
||||
onConfirmNativePayment={vi.fn()}
|
||||
onCloseNativePayment={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByText('当前 Max · 年付')).toBeTruthy();
|
||||
expect(screen.queryByText(/可同周期补差升档/)).toBeNull();
|
||||
expect(screen.getByText('周期切换需等到期后')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('keeps an active member as member when their current plan is disabled', async () => {
|
||||
const user = userEvent.setup();
|
||||
const onRequestMembershipQuote = vi.fn();
|
||||
|
||||
@@ -594,9 +594,12 @@ function PlatformRechargeTabNav({
|
||||
function PlatformMembershipStatusCard({
|
||||
membership,
|
||||
currentPlan,
|
||||
hasUpgradePath,
|
||||
}: {
|
||||
membership: ProfileMembership;
|
||||
currentPlan: ProfileMembershipPlanRecord | null;
|
||||
/** 是否存在更高档位可补差升级;已是最高的 max 档时为 false。 */
|
||||
hasUpgradePath: boolean;
|
||||
}) {
|
||||
const planTitle = currentPlan?.title ?? '会员';
|
||||
const cycleLabel = membership.cycleKind === 'yearly' ? '年付' : '月付';
|
||||
@@ -620,9 +623,15 @@ function PlatformMembershipStatusCard({
|
||||
</div>
|
||||
</div>
|
||||
<div className="shrink-0 text-right text-[10px] font-semibold text-[var(--platform-text-soft)]">
|
||||
可同周期补差升档
|
||||
<br />
|
||||
周期切换需等到期后
|
||||
{hasUpgradePath ? (
|
||||
<>
|
||||
可同周期补差升档
|
||||
<br />
|
||||
周期切换需等到期后
|
||||
</>
|
||||
) : (
|
||||
'周期切换需等到期后'
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -1362,6 +1371,13 @@ export function PlatformProfileRechargeModal({
|
||||
) ?? null,
|
||||
[center?.membershipPlans, membership?.plan],
|
||||
);
|
||||
// 已是最高的 max 档时没有可升级目标,状态卡不应再提示「可同周期补差升档」。
|
||||
const hasUpgradePath = useMemo(
|
||||
() =>
|
||||
currentPlanRecord !== null &&
|
||||
membershipPlans.some((plan) => plan.rank > currentPlanRecord.rank),
|
||||
[currentPlanRecord, membershipPlans],
|
||||
);
|
||||
const [activeTab, setActiveTab] =
|
||||
useState<PlatformProfileRechargeTab>('subscription');
|
||||
const [cycleKind, setCycleKind] =
|
||||
@@ -1488,6 +1504,7 @@ export function PlatformProfileRechargeModal({
|
||||
<PlatformMembershipStatusCard
|
||||
membership={membership}
|
||||
currentPlan={currentPlanRecord}
|
||||
hasUpgradePath={hasUpgradePath}
|
||||
/>
|
||||
) : null}
|
||||
<PlatformMembershipCycleSwitch
|
||||
|
||||
Reference in New Issue
Block a user