agent-ecosystem/test/main/services/extensions/SkillScaffoldService.test.ts
iliya 4b4dccd13d feat: add skills management features and integrate skills API
- Introduced skills catalog management with functionalities to list, get details, preview, and apply skill changes.
- Implemented IPC handlers for skills-related actions, enhancing communication between renderer and main processes.
- Updated the UI to include a dedicated Skills panel within the extension store, improving user access to skills management.
- Added new constants and types for skills API integration, ensuring a structured approach to skills handling.
- Enhanced state management to support skills loading, error handling, and detail fetching.
2026-03-11 21:46:56 +02:00

39 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { SkillScaffoldService } from '@main/services/extensions/skills/SkillScaffoldService';
import { SkillRootsResolver } from '@main/services/extensions/skills/SkillRootsResolver';
describe('SkillScaffoldService', () => {
it('normalizes valid relative draft file paths', () => {
const service = new SkillScaffoldService();
const files = service.normalizeDraftFiles([
{ relativePath: 'scripts/../scripts/run.sh', content: 'echo hi' },
]);
expect(files[0]?.relativePath).toBe('scripts/run.sh');
});
it('rejects path traversal in draft file paths', () => {
const service = new SkillScaffoldService();
expect(() =>
service.normalizeDraftFiles([{ relativePath: '../escape.txt', content: 'nope' }])
).toThrow('Invalid relative path');
});
it('rejects existing skill ids outside the selected root', async () => {
const resolver = new SkillRootsResolver();
const service = new SkillScaffoldService(resolver);
await expect(
service.resolveUpsertTarget(
'project',
'claude',
'/tmp/demo-project',
'valid-name',
'/tmp/another-project/.claude/skills/foreign'
)
).rejects.toThrow('outside the allowed root');
});
});