Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(billing): make the hero Enterprise link scroll to its plan card (#119734)

posthog[bot]f2f88e056c40
diff --git a/frontend/src/scenes/billing/PlatformAddonComparison.test.tsx b/frontend/src/scenes/billing/PlatformAddonComparison.test.tsx
new file mode 100644
index 000000000000..45130b9521bb
--- /dev/null
+++ b/frontend/src/scenes/billing/PlatformAddonComparison.test.tsx
@@ -0,0 +1,51 @@
+/* oxlint-disable react-hooks/rules-of-hooks -- useMocks is a test helper, not a React hook */
+import '@testing-library/jest-dom'
+
+import { cleanup, render } from '@testing-library/react'
+import { Provider } from 'kea'
+import { expectLogic } from 'kea-test-utils'
+
+import { billingJson } from '~/mocks/fixtures/_billing'
+import { makeBillingWithPlatformAddons } from '~/mocks/fixtures/_billing_platform_addons'
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+import { BillingProductV2Type } from '~/types'
+
+import { billingLogic } from './billingLogic'
+import { PlatformAddonComparison } from './PlatformAddonComparison'
+
+describe('PlatformAddonComparison', () => {
+ const scrollIntoView = jest.fn()
+
+ beforeEach(async () => {
+ Object.defineProperty(HTMLElement.prototype, 'scrollIntoView', { configurable: true, value: scrollIntoView })
+ scrollIntoView.mockClear()
+ useMocks({ get: { '/api/billing': () => [200, makeBillingWithPlatformAddons(billingJson, 'trial-used')] } })
+ initKeaTests()
+ billingLogic.mount()
+ await expectLogic(billingLogic, () => billingLogic.actions.loadBilling()).toFinishAllListeners()
+ })
+
+ afterEach(() => {
+ cleanup()
+ delete (HTMLElement.prototype as Partial<HTMLElement>).scrollIntoView
+ })
+
+ it.each(['boost', 'scale', 'enterprise'])('scrolls to the %s plan card from the billing hero link', (type) => {
+ const platform = billingLogic.values.billing?.products.find(
+ (p) => p.type === 'platform_and_support'
+ ) as BillingProductV2Type
+ const { container } = render(
+ <Provider>
+ <PlatformAddonComparison product={platform} />
+ </Provider>
+ )
+ const card = container.querySelector(`[data-attr="billing-product-addon-${type}"]`)
+ expect(card).toBeInTheDocument()
+
+ billingLogic.actions.scrollToProduct(type)
+
+ expect(scrollIntoView).toHaveBeenCalledTimes(1)
+ expect(scrollIntoView.mock.contexts[0]).toBe(card)
+ })
+})
diff --git a/frontend/src/scenes/billing/PlatformAddonComparison.tsx b/frontend/src/scenes/billing/PlatformAddonComparison.tsx
index ee18f41a59ea..249c31ae533b 100644
--- a/frontend/src/scenes/billing/PlatformAddonComparison.tsx
+++ b/frontend/src/scenes/billing/PlatformAddonComparison.tsx
@@ -116,6 +116,7 @@ const PlanCard = ({
return (
<div
+ data-attr={`billing-product-addon-${addon.type}`}
className={clsx(
'flex flex-col gap-3 p-5 rounded bg-surface-secondary',
(addon.subscribed || isOnTrial) && 'ring-1 ring-accent'