Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 对齐取消成功的账期日期

liugaoweid10733f494f2
diff --git a/apps/desktop/src/renderer/features/billing/BillingPage.tsx b/apps/desktop/src/renderer/features/billing/BillingPage.tsx
index 7438334ef3..40beeb0452 100644
--- a/apps/desktop/src/renderer/features/billing/BillingPage.tsx
+++ b/apps/desktop/src/renderer/features/billing/BillingPage.tsx
@@ -482,9 +482,10 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null
const canceled = await billingApi.cancelCurrentSubscription();
setCurrentSubscription(canceled);
setSubscriptionError(false);
+ const canceledPeriodEndAt = formatBillingDate(canceled.currentPeriodEndAt, billingLocale);
toast.success(
- periodEndAt
- ? t('billing.settings.subscriptionCard.cancelSuccess', { date: periodEndAt })
+ canceledPeriodEndAt
+ ? t('billing.settings.subscriptionCard.cancelSuccess', { date: canceledPeriodEndAt })
: t('billing.settings.subscriptionCard.cancelSuccessWithoutDate'),
);
} catch (error) {
@@ -497,7 +498,14 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null
} finally {
setCancelingSubscription(false);
}
- }, [cancelingSubscription, confirm, currentPlanFacts?.periodEndAt, currentSubscription, t]);
+ }, [
+ billingLocale,
+ cancelingSubscription,
+ confirm,
+ currentPlanFacts?.periodEndAt,
+ currentSubscription,
+ t,
+ ]);
// UI candidates only. The quote is the authority on whether a target is
// actually reachable; this filter just avoids offering obviously invalid
diff --git a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx
index e0163d5cea..a2fafd1247 100644
--- a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx
+++ b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx
@@ -1181,6 +1181,7 @@ describe('BillingPage plan change', () => {
const billing = install(billingMocks());
billing.cancelCurrentSubscription.mockResolvedValue({
...activeSubscription(),
+ currentPeriodEndAt: '2026-09-01T00:00:00.000Z',
cancelAtPeriodEnd: true,
});
uiMocks.confirm.mockResolvedValueOnce(true);
@@ -1196,7 +1197,9 @@ describe('BillingPage plan change', () => {
}),
);
expect(billing.getBalance).toHaveBeenCalledTimes(1);
- expect(uiMocks.toastSuccess).toHaveBeenCalledTimes(1);
+ expect(uiMocks.toastSuccess).toHaveBeenCalledWith(
+ expect.stringContaining('"date":"Sep 1, 2026"'),
+ );
expect(
screen.getByText((text) => text.startsWith('billing.settings.subscriptionCard.endsAt')),
).toBeTruthy();