import { render, screen } from '@testing-library/react' import { CloudAnalyticsRuntime } from '../cloud-analytics-runtime' const mockState = vi.hoisted(() => ({ pathname: '/signin' })) vi.mock('@/next/navigation', () => ({ usePathname: () => mockState.pathname, })) vi.mock('../cookieyes-consent-bridge', () => ({ CookieYesConsentBridge: () => , })) vi.mock('@/app/components/base/amplitude', () => ({ default: ({ active }: { active: boolean }) => ( ), })) vi.mock('@/app/components/external-attribution-recorder', () => ({ default: () => , })) describe('CloudAnalyticsRuntime', () => { beforeEach(() => { mockState.pathname = '/signin' }) it('keeps consent active across first-party Cloud routes', () => { const { rerender } = render() expect(screen.getByTestId('cookieyes-consent-bridge')).toBeInTheDocument() expect(screen.getByTestId('external-attribution-recorder')).toBeInTheDocument() expect(screen.getByTestId('amplitude-provider')).toHaveAttribute('data-active', 'true') mockState.pathname = '/integrations' rerender() expect(screen.getByTestId('amplitude-provider')).toHaveAttribute('data-active', 'true') }) it('opts Amplitude out after a client transition into a share route', () => { const { rerender } = render() mockState.pathname = '/workflow/token' rerender() expect(screen.getByTestId('amplitude-provider')).toHaveAttribute('data-active', 'false') }) })