import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import { describe, expect, it, vi } from 'vitest'; import { AgentCreationDialog } from '@/components/coding/AgentCreationDialog'; import type { CodingProjectAgent } from '@/types/coding-project'; const agent: CodingProjectAgent = { id: 'builder', avatarId: 'avatar-01', roleName: '实现者', name: 'Builder', builtIn: false, enabled: true, model: { accountId: 'account-a', modelId: 'model-a', thinkingLevel: 'medium' }, modelResolution: 'resolved', skillIds: ['data-service'], responsibility: { mission: 'Implement changes', owns: [], boundaries: [], collaborators: [], principles: [], }, prompt: '', archivedAt: null, pinned: false, createdAt: '2026-08-27T00:00:00Z', updatedAt: '2026-08-27T00:00:00Z', }; describe('AgentCreationDialog plugin Skill availability', () => { it('shows a retained disabled assignment as unavailable and persists it unchanged', async () => { const onUpdate = vi.fn(async () => undefined); render(); const checkbox = screen.getByRole('checkbox', { name: '绑定技能:Data Service' }); expect(checkbox).toBeChecked(); expect(checkbox).toBeDisabled(); expect(screen.getByText('插件未启用;现有分配会保留,但当前不可用。')).toBeVisible(); fireEvent.click(screen.getByRole('button', { name: '保存智能体' })); await waitFor(() => expect(onUpdate).toHaveBeenCalledWith( expect.objectContaining({ skillIds: ['data-service'] }), )); }); });