Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(billing): pin the interval and crypto paths the panel exists to fix\n\nThe suite asserted purchasePlan was called with 'BASIC_MONTHLY' — the DEFAULT\ninterval — so it stayed green with buildPlanId(tier, billingInterval)\nhardcoded back to 'monthly', i.e. with the #5865 bug fully restored. Across\nthe whole diff "annual" and "yearly" appeared only in BillingPanel.tsx, never\nin a test. createCoinbaseChargeMock was declared and stubbed and never\nasserted on, so the crypto branch of handleUpgrade was unexecuted.\n\nTwo cases:\n\n- selecting Annual then Upgrade sends 'BASIC_YEARLY'\n- selecting crypto sends a Coinbase charge, opens its hostedUrl, does not\n touch the Stripe path, and leaves the Monthly button disabled — which also\n pins the interval coupling from the Codex P1, so the price on screen cannot\n disagree with the charge that was created\n\nRevert-checked separately: hardcoding buildPlanId(tier, 'monthly') fails the\nannual case on BASIC_YEARLY with the other nine still passing; disabling the\ncrypto branch fails the crypto case on createCoinbaseCharge never being\ncalled. No production code changed.\n

M3gA-Mind6173382d4416
diff --git a/app/src/components/settings/panels/BillingPanel.test.tsx b/app/src/components/settings/panels/BillingPanel.test.tsx
index eef3f411cc..9f8bfbc265 100644
--- a/app/src/components/settings/panels/BillingPanel.test.tsx
+++ b/app/src/components/settings/panels/BillingPanel.test.tsx
@@ -99,6 +99,50 @@ describe('<BillingPanel />', () => {
);
});
+ // The reason this PR exists: the interval toggle must reach `purchasePlan`.
+ // The monthly case above passes on the DEFAULT interval, so it stays green
+ // even if `buildPlanId(tier, billingInterval)` is hardcoded back to
+ // 'monthly' — i.e. even with the bug in #5865 fully restored. This is the
+ // case that fails when that happens.
+ it('upgrade after selecting Annual sends the yearly plan id', async () => {
+ render(<BillingPanel />);
+ await waitFor(() => expect(getCurrentPlanMock).toHaveBeenCalledTimes(1));
+
+ fireEvent.click(screen.getByRole('button', { name: 'Annual' }));
+
+ const upgradeButtons = await screen.findAllByRole('button', { name: 'Upgrade' });
+ fireEvent.click(upgradeButtons[0]);
+
+ await waitFor(() => expect(purchasePlanMock).toHaveBeenCalledTimes(1));
+ expect(purchasePlanMock).toHaveBeenCalledWith('BASIC_YEARLY');
+ });
+
+ // The crypto branch of `handleUpgrade` had no test at all: the mock was
+ // declared and stubbed but never asserted on, so the whole branch was
+ // unexecuted. Also pins the interval coupling from the Codex P1 — selecting
+ // crypto forces `annual`, so the price on screen matches the charge.
+ it('upgrade with crypto creates a Coinbase charge and opens the hosted URL', async () => {
+ render(<BillingPanel />);
+ await waitFor(() => expect(getCurrentPlanMock).toHaveBeenCalledTimes(1));
+
+ fireEvent.click(screen.getByRole('switch'));
+
+ const upgradeButtons = await screen.findAllByRole('button', { name: 'Upgrade' });
+ fireEvent.click(upgradeButtons[0]);
+
+ await waitFor(() => expect(createCoinbaseChargeMock).toHaveBeenCalledTimes(1));
+ expect(createCoinbaseChargeMock).toHaveBeenCalledWith('BASIC');
+ // Crypto must never go through the Stripe path.
+ expect(purchasePlanMock).not.toHaveBeenCalled();
+ await waitFor(() =>
+ expect(openUrlMock).toHaveBeenCalledWith('https://commerce.coinbase.com/test')
+ );
+ // Selecting crypto switches the interval to annual, so the monthly
+ // button is disabled and the displayed price cannot disagree with the
+ // charge that was created.
+ expect(screen.getByRole('button', { name: 'Monthly' })).toBeDisabled();
+ });
+
it('opens the billing dashboard when the user clicks the secondary button', async () => {
render(<BillingPanel />);