import type { ReactNode } from 'react' import type { AdminEventDetailData } from './types' import { cleanup, fireEvent, render, screen } from '@testing-library/react' import { afterEach, describe, expect, it, vi } from 'vitest' import AdminEventLifecycleActions from './AdminEventLifecycleActions' vi.mock('@/components/formElements/Button', () => ({ default: ({ children, onClick, to }: { children: ReactNode; onClick?: () => void; to?: string }) => ( ), })) const baseEvent = { id: 'event-1', status: 'pending_review', adminApprovedAt: null, bookedCount: 0, } as AdminEventDetailData afterEach(cleanup) describe('AdminEventLifecycleActions', () => { it('exposes approve/reject/force-publish for pending_review events', () => { const onApprove = vi.fn() const onOpenReject = vi.fn() const onForcePublish = vi.fn() render( ) fireEvent.click(screen.getByRole('button', { name: 'تأیید و انتشار' })) fireEvent.click(screen.getByRole('button', { name: 'رد' })) fireEvent.click(screen.getByRole('button', { name: 'انتشار فوری' })) expect(onApprove).toHaveBeenCalledTimes(1) expect(onOpenReject).toHaveBeenCalledTimes(1) expect(onForcePublish).toHaveBeenCalledTimes(1) }) it('exposes complete/cancel for published events and hides reject', () => { render( ) expect(screen.getByRole('button', { name: 'پایان' })).toBeTruthy() expect(screen.getByRole('button', { name: 'لغو' })).toBeTruthy() expect(screen.queryByRole('button', { name: 'رد' })).toBeNull() expect(screen.queryByRole('button', { name: 'حذف' })).toBeNull() }) })