feat: add GitHub skill installation support
- Implemented functionality to install skills from GitHub URLs. - Updated API to handle new installation requests from GitHub. - Enhanced UI to allow users to input GitHub skill URLs for installation. - Added translations for new GitHub installation features in English, Thai, and Chinese. - Created tests for the new skill installation service and API routes to ensure proper functionality.
This commit is contained in:
53
tests/skills-api.test.ts
Normal file
53
tests/skills-api.test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
// @vitest-environment node
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
hostApiFetch: vi.fn(),
|
||||
gatewayRpc: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../src/lib/host-api', () => ({
|
||||
hostApiFetch: mocks.hostApiFetch,
|
||||
}));
|
||||
|
||||
vi.mock('../src/lib/gateway-client', () => ({
|
||||
gatewayRpc: mocks.gatewayRpc,
|
||||
}));
|
||||
|
||||
import { apiGetSkillsDir, apiInstallSkill } from '../src/lib/skills-api';
|
||||
|
||||
describe('skills api helpers', () => {
|
||||
beforeEach(() => {
|
||||
mocks.hostApiFetch.mockReset();
|
||||
mocks.gatewayRpc.mockReset();
|
||||
});
|
||||
|
||||
it('falls back to ~/.openclaw/skills when the host path request fails', async () => {
|
||||
mocks.hostApiFetch.mockRejectedValue(new Error('offline'));
|
||||
|
||||
await expect(apiGetSkillsDir()).resolves.toBe('~/.openclaw/skills');
|
||||
});
|
||||
|
||||
it('posts unified install requests to /api/skills/install', async () => {
|
||||
mocks.hostApiFetch.mockResolvedValue({
|
||||
success: true,
|
||||
slug: 'minimax-xlsx',
|
||||
baseDir: 'C:/Users/Administrator/.openclaw/skills/minimax-xlsx',
|
||||
source: 'github-url',
|
||||
enabled: true,
|
||||
});
|
||||
|
||||
await expect(apiInstallSkill({
|
||||
kind: 'github-url',
|
||||
url: 'https://github.com/MiniMax-AI/skills/blob/main/skills/minimax-xlsx/SKILL.md',
|
||||
})).resolves.toMatchObject({
|
||||
success: true,
|
||||
slug: 'minimax-xlsx',
|
||||
source: 'github-url',
|
||||
});
|
||||
|
||||
expect(mocks.hostApiFetch).toHaveBeenCalledWith('/api/skills/install', expect.objectContaining({
|
||||
method: 'POST',
|
||||
}));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user