From 7b7f4e26d2e30a8bcc2e5cd608de9edb3d20553d Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 14 Nov 2026 16:51:57 -0800 Subject: [PATCH] test(cloud): plan entry points open the plans dialog --- .../new-workspace/RunTargetCombobox.test.tsx | 22 +++++++++---------- .../orca-cloud-run-target-access.test.ts | 12 +++++----- .../VmBuildBillingBlocker.test.tsx | 7 +++--- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/renderer/src/components/new-workspace/RunTargetCombobox.test.tsx b/src/renderer/src/components/new-workspace/RunTargetCombobox.test.tsx index b2394bf5a51..36af85d395f 100644 --- a/src/renderer/src/components/new-workspace/RunTargetCombobox.test.tsx +++ b/src/renderer/src/components/new-workspace/RunTargetCombobox.test.tsx @@ -19,9 +19,9 @@ vi.mock('@/components/ui/popover', () => ({ PopoverContent: ({ children }: { children: React.ReactNode }) =>
{children}
})) -const openCloudConsole = vi.fn() -vi.mock('@/lib/orca-cloud/open-cloud-console', () => ({ - openCloudConsole: (source: string) => openCloudConsole(source) +const openPlansDialog = vi.fn() +vi.mock('@/components/billing/plans/plans-dialog-store', () => ({ + openPlansDialog: () => openPlansDialog() })) const hosts: ProjectHostSetupOption[] = [ @@ -101,7 +101,7 @@ function render( } beforeEach(() => { - openCloudConsole.mockClear() + openPlansDialog.mockClear() resetOrcaCloudBillingCache() container = document.createElement('div') document.body.appendChild(container) @@ -133,7 +133,7 @@ describe('RunTargetCombobox', () => { expect(activeText()).toContain('Orca Cloud') press('Enter') expect(onRecipeChange).toHaveBeenCalledWith('cloud') - expect(openCloudConsole).not.toHaveBeenCalled() + expect(openPlansDialog).not.toHaveBeenCalled() }) it('opens the plans page instead of building when there is no plan', () => { @@ -141,7 +141,7 @@ describe('RunTargetCombobox', () => { render({ state: 'no-plan', lapsed: false, canManageBilling: true }, onRecipeChange) press('ArrowDown') press('Enter') - expect(openCloudConsole).toHaveBeenCalledWith('billing') + expect(openPlansDialog).toHaveBeenCalledTimes(1) expect(onRecipeChange).not.toHaveBeenCalled() }) @@ -152,7 +152,7 @@ describe('RunTargetCombobox', () => { expect(container.textContent).not.toContain('Upgrade') press('ArrowDown') press('Enter') - expect(openCloudConsole).not.toHaveBeenCalled() + expect(openPlansDialog).not.toHaveBeenCalled() expect(onRecipeChange).not.toHaveBeenCalled() }) @@ -230,11 +230,11 @@ describe('RunTargetCombobox', () => { press('ArrowDown') press('Enter') expect(onRecipeChange).not.toHaveBeenCalled() - expect(openCloudConsole).not.toHaveBeenCalled() + expect(openPlansDialog).not.toHaveBeenCalled() await act(async () => answer(NO_PLAN)) - expect(openCloudConsole).toHaveBeenCalledWith('billing') + expect(openPlansDialog).toHaveBeenCalledTimes(1) expect(onRecipeChange).not.toHaveBeenCalled() }) @@ -247,7 +247,7 @@ describe('RunTargetCombobox', () => { await act(async () => answer(NO_PLAN)) - expect(openCloudConsole).not.toHaveBeenCalled() + expect(openPlansDialog).not.toHaveBeenCalled() }) it('does nothing when a member who cannot fix the block picks Orca Cloud', () => { @@ -261,7 +261,7 @@ describe('RunTargetCombobox', () => { ).toBe('true') press('Enter') expect(onRecipeChange).not.toHaveBeenCalled() - expect(openCloudConsole).not.toHaveBeenCalled() + expect(openPlansDialog).not.toHaveBeenCalled() }) it('jumps to the ends of the list with Home and End', () => { diff --git a/src/renderer/src/components/new-workspace/orca-cloud-run-target-access.test.ts b/src/renderer/src/components/new-workspace/orca-cloud-run-target-access.test.ts index de8944234fb..5413db64734 100644 --- a/src/renderer/src/components/new-workspace/orca-cloud-run-target-access.test.ts +++ b/src/renderer/src/components/new-workspace/orca-cloud-run-target-access.test.ts @@ -6,9 +6,9 @@ import { orcaCloudCanStart } from './orca-cloud-run-target-access' -const openCloudConsole = vi.fn() -vi.mock('@/lib/orca-cloud/open-cloud-console', () => ({ - openCloudConsole: (section: string) => openCloudConsole(section) +const openPlansDialog = vi.fn() +vi.mock('@/components/billing/plans/plans-dialog-store', () => ({ + openPlansDialog: () => openPlansDialog() })) function denied( @@ -29,7 +29,7 @@ function denied( describe('Orca Cloud run-target access by role', () => { beforeEach(() => { - openCloudConsole.mockReset() + openPlansDialog.mockReset() }) it('carries the role on no plan, so members are not sent to plans they cannot buy', () => { @@ -38,7 +38,7 @@ describe('Orca Cloud run-target access by role', () => { expect(owner).toEqual({ state: 'no-plan', lapsed: false, canManageBilling: true }) expect(member).toEqual({ state: 'no-plan', lapsed: true, canManageBilling: false }) expect(getOrcaCloudPick(member)).toEqual({ kind: 'blocked' }) - expect(openCloudConsole).not.toHaveBeenCalled() + expect(openPlansDialog).not.toHaveBeenCalled() }) it('sends an owner or admin to billing in the browser', () => { @@ -47,7 +47,7 @@ describe('Orca Cloud run-target access by role', () => { if (pick.kind === 'act') { pick.run() } - expect(openCloudConsole).toHaveBeenCalledWith('billing') + expect(openPlansDialog).toHaveBeenCalledTimes(1) }) it('blocks members at the spend cap and lets owners act', () => { diff --git a/src/renderer/src/components/worktree-creation/VmBuildBillingBlocker.test.tsx b/src/renderer/src/components/worktree-creation/VmBuildBillingBlocker.test.tsx index 19b6812df0b..6360810bb16 100644 --- a/src/renderer/src/components/worktree-creation/VmBuildBillingBlocker.test.tsx +++ b/src/renderer/src/components/worktree-creation/VmBuildBillingBlocker.test.tsx @@ -14,6 +14,7 @@ const setOverage = vi.fn<(args: { enabled: boolean; spendCapCents?: number }) => Promise>() const billingStatus = vi.fn<() => Promise>() vi.mock('@/lib/orca-cloud/open-cloud-console', () => ({ openCloudConsole: vi.fn() })) +vi.mock('@/components/billing/plans/plans-dialog-store', () => ({ openPlansDialog: vi.fn() })) const openPortal = vi.fn(() => Promise.resolve({ status: 'opened' as const })) @@ -147,8 +148,8 @@ describe('billing blocker on the creating sheet (JA-21)', () => { expect(onContinue).not.toHaveBeenCalled() }) - it('no plan: Compare plans opens billing in the browser, and returning re-checks once', async () => { - const { openCloudConsole } = await import('@/lib/orca-cloud/open-cloud-console') + it('no plan: Compare plans opens the plans dialog, and returning re-checks once', async () => { + const { openPlansDialog } = await import('@/components/billing/plans/plans-dialog-store') billingStatus.mockResolvedValue({ status: 'ok', entitlement: { ...sampleTeam, canStartSandbox: true } @@ -156,7 +157,7 @@ describe('billing blocker on the creating sheet (JA-21)', () => { const { onContinue } = renderBlocker('plan') expect(screen.getByRole('heading', { name: 'Choose a plan' })).toBeTruthy() fireEvent.click(screen.getByRole('button', { name: 'Compare plans' })) - expect(openCloudConsole).toHaveBeenCalledWith('billing') + expect(openPlansDialog).toHaveBeenCalledOnce() act(() => { window.dispatchEvent(new Event('focus')) })