import { fireEvent, render, screen, waitFor } from '@testing-library/react' import Billing from './index' let currentBillingUrl: string | null = 'https://billing' let fetching = false let isManager = true let enableBilling = true const refetchMock = vi.fn() const openAsyncWindowMock = vi.fn() vi.mock('@/service/use-billing', () => ({ useBillingUrl: () => ({ data: currentBillingUrl, isFetching: fetching, refetch: refetchMock, }), })) vi.mock('@/hooks/use-async-window-open', () => ({ useAsyncWindowOpen: () => openAsyncWindowMock, })) vi.mock('@/context/app-context', () => ({ useAppContext: () => ({ isCurrentWorkspaceManager: isManager, }), })) vi.mock('@/context/provider-context', () => ({ useProviderContext: () => ({ enableBilling, }), })) vi.mock('../plan', () => ({ __esModule: true, default: ({ loc }: { loc: string }) =>
, })) describe('Billing', () => { beforeEach(() => { vi.clearAllMocks() currentBillingUrl = 'https://billing' fetching = false isManager = true enableBilling = true refetchMock.mockResolvedValue({ data: 'https://billing' }) }) it('hides the billing action when user is not manager or billing is disabled', () => { isManager = false render(