/** * @vitest-environment jsdom */ import React from 'react'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { cleanup, render, screen, waitFor } from '@testing-library/react'; const mockRouter = { push: vi.fn(), replace: vi.fn(), }; const getQuoteMock = vi.fn(); const listQuoteVersionsMock = vi.fn(); const getQuoteApprovalSettingsMock = vi.fn(); const getAllClientsForBillingMock = vi.fn(); const getAllContactsMock = vi.fn(); vi.mock('next/navigation', () => ({ useRouter: () => mockRouter, })); vi.mock('@alga-psa/ui/lib/i18n/client', () => ({ useTranslation: () => ({ t: (key: string, opts?: any) => { let value: string = typeof opts === 'string' ? opts : (opts?.defaultValue ?? key); if (opts && typeof opts === 'object') { for (const [k, v] of Object.entries(opts)) { if (k === 'defaultValue') continue; value = value.split(`{{${k}}}`).join(String(v)); } } return value; }, i18n: { language: 'en' }, }), useFormatters: () => ({ formatCurrency: (amount: number) => `$${Number(amount).toFixed(2)}`, formatDate: (date: unknown) => String(date), formatNumber: (value: number) => String(value), }), })); vi.mock('@radix-ui/themes', () => ({ Card: ({ children }: { children: React.ReactNode }) =>
{children}
, Box: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock('@alga-psa/ui/components/Alert', () => ({ Alert: ({ children }: { children: React.ReactNode }) =>
{children}
, AlertTitle: ({ children }: { children: React.ReactNode }) =>
{children}
, AlertDescription: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock('@alga-psa/ui/components/TextArea', () => ({ TextArea: (props: React.TextareaHTMLAttributes) =>