/**
 * Skills 路由单元测试
 */
import { describe, it, expect } from 'vitest';
describe('skills route validation', () => {
    it('requires agentId for list', () => {
        const validateListRequest = (body) => {
            if (!body.agentId)
                return { valid: false, error: 'agentId is required' };
            return { valid: true };
        };
        expect(validateListRequest({}).valid).toBe(false);
        expect(validateListRequest({ agentId: 'agent-1' }).valid).toBe(true);
    });
    it('requires agentId and skillId for get', () => {
        const validateGetRequest = (body) => {
            if (!body.agentId || !body.skillId)
                return { valid: false, error: 'agentId and skillId are required' };
            return { valid: true };
        };
        expect(validateGetRequest({}).valid).toBe(false);
        expect(validateGetRequest({ agentId: 'agent-1', skillId: 'skill-1' }).valid).toBe(true);
    });
    it('normalizes skill name', () => {
        const normalizeSkillName = (name) => name ? String(name).trim() : undefined;
        expect(normalizeSkillName('  test-skill  ')).toBe('test-skill');
        expect(normalizeSkillName('')).toBe(undefined);
    });
    it('normalizes apps', () => {
        const normalizeApps = (apps) => {
            if (!apps)
                return [];
            if (typeof apps === 'string')
                return apps.split(',').map(s => s.trim()).filter(Boolean);
            if (Array.isArray(apps))
                return apps.filter(s => typeof s === 'string').map(s => String(s).trim()).filter(Boolean);
            return [];
        };
        expect(normalizeApps('claude,opencode')).toEqual(['claude', 'opencode']);
        expect(normalizeApps(['claude', 'opencode'])).toEqual(['claude', 'opencode']);
    });
    it('allows supported per-tool toggle app ids', () => {
        const isSupportedToggleAppId = (appId) => ['acode', 'claudecode', 'opencode'].includes(appId);
        expect(isSupportedToggleAppId('acode')).toBe(true);
        expect(isSupportedToggleAppId('claudecode')).toBe(true);
        expect(isSupportedToggleAppId('opencode')).toBe(true);
        expect(isSupportedToggleAppId('codex')).toBe(false);
        expect(isSupportedToggleAppId('openclaw')).toBe(false);
    });
});
