Files
makelore/tests/unit/agent-creation-dialog.test.tsx

61 lines
2.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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(<AgentCreationDialog
open
onOpenChange={vi.fn()}
agent={agent}
modelOptions={[{
key: JSON.stringify(['account-a', 'model-a']),
accountId: 'account-a',
modelId: 'model-a',
label: 'Account A / Model A',
availableThinkingLevels: null,
}]}
skills={[{
id: 'data-service',
name: 'Data Service',
description: 'Project data tools',
available: false,
effective: false,
}]}
onUpdate={onUpdate}
/>);
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'] }),
));
});
});