import { render, screen } from '@testing-library/react' import * as React from 'react' import { beforeEach, describe, expect, it, vi } from 'vitest' vi.mock('@/app/components/plugins/install-plugin/install-from-github', () => ({ default: ({ updatePayload, onClose, onSuccess }: { updatePayload?: Record onClose: () => void onSuccess: () => void }) => (
{JSON.stringify(updatePayload)}
), })) describe('FromGitHub', () => { let FromGitHub: (typeof import('../from-github'))['default'] beforeEach(async () => { vi.clearAllMocks() const mod = await import('../from-github') FromGitHub = mod.default }) it('should render InstallFromGitHub with update payload', () => { const payload = { id: '1', owner: 'test', repo: 'plugin' } as never render() expect(screen.getByTestId('install-from-github')).toBeInTheDocument() expect(screen.getByTestId('update-payload')).toHaveTextContent(JSON.stringify(payload)) }) it('should call onCancel when close is triggered', () => { const mockOnCancel = vi.fn() render() screen.getByTestId('close-btn').click() expect(mockOnCancel).toHaveBeenCalled() }) it('should call onSave on success', () => { const mockOnSave = vi.fn() render() screen.getByTestId('success-btn').click() expect(mockOnSave).toHaveBeenCalled() }) })