import { describe, expect, it, vi } from 'vitest' import { fireEvent, render, screen } from '@testing-library/react' vi.mock('../../app-plugins/usePluginRegistry', () => ({ usePluginRegistry: () => ({ plugins: [], refresh: vi.fn() }), })) vi.mock('../../hooks/useApi', () => ({ api: { get: vi.fn().mockResolvedValue({}), post: vi.fn() }, apiRequest: vi.fn(), })) vi.mock('../AppPluginMarketplaceSection', () => ({ AppPluginMarketplaceSection: () =>
marketplace-catalogs
, })) import { PluginCenterModal } from './PluginCenterModal' describe('PluginCenterModal', () => { it('opens on Installed and switches to Discover', () => { render( {}} />) expect(screen.getByRole('heading', { name: 'Plugin Center' })).toBeTruthy() expect(screen.getByRole('tab', { name: 'Installed' }).getAttribute('aria-selected')).toBe('true') expect(screen.getByText('Third-party', { selector: 'h4' })).toBeTruthy() fireEvent.click(screen.getByRole('tab', { name: 'Discover' })) expect(screen.getByRole('tab', { name: 'Discover' }).getAttribute('aria-selected')).toBe('true') expect(screen.getByText('marketplace-catalogs')).toBeTruthy() }) it('closes from the header button', () => { const onClose = vi.fn() render() fireEvent.click(screen.getAllByRole('button', { name: 'Close' })[0]) expect(onClose).toHaveBeenCalled() }) it('opens the inspect-first Add plugin dialog', () => { render( {}} />) fireEvent.click(screen.getByRole('button', { name: 'Add plugin' })) expect(screen.getByRole('heading', { name: 'Add plugin' })).toBeTruthy() expect(screen.getByLabelText('Plugin source path')).toBeTruthy() }) })