mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-25 13:22:36 +08:00
- ab_sdk 0.2:新增 points、downloader(自 module/downloader/base.py 迁入)、 llm(自 providers/base.py 迁入)、notify、search、tasks 契约与 secret_field();原路径保留重新导出 - module/plugin/host:进程级扩展注册表,内置 qB/aria2/mock 与各通知渠道以 core 身份登记;DownloadClient、NotificationManager、LLM 注册表、搜索站点 均改为按 id 从注册表解析 - 插件定时任务随插件加载/重载/停用同步进调度器,失败计入熔断 - 插件变更后重建通知渠道、清理 LLM 解析器缓存;下载器客户端缓存键包含 Provider 登记项,插件重载后自动换新 - /api/v1/plugins:总览(schema + 掩码配置)、启停、配置(按模型校验)、 allow_unsigned、Provider 列表;/config 读写同样掩码/还原插件秘密字段 - WebUI:设置页「插件」卡片与 JSON Schema 表单;下载器与通知下拉框并入插件 Provider;插件保存后刷新 config store 的 plugins 段,避免全局保存覆盖 - 修复:/search/provider 读取导入时的站点快照,新站点需重启才出现 - 文档:开发者指南 → 插件开发 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EoBUPFw7Ty1epuPESdELs1
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
/**
|
|
* Contract tests for apiPlugins against backend/src/module/api/plugins.py.
|
|
*/
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import { createAxiosMock } from '@/test/mocks/axios';
|
|
|
|
import { apiPlugins } from '@/api/plugins';
|
|
import { axios } from '@/utils/axios';
|
|
|
|
vi.mock('@/utils/axios', () => ({ axios: createAxiosMock() }));
|
|
|
|
const overview = { allow_unsigned: false, plugins: [] };
|
|
|
|
describe('Plugins API contract (path + HTTP method)', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it('should GET api/v1/plugins when listing', async () => {
|
|
(axios.get as any).mockResolvedValue({ data: overview });
|
|
expect(await apiPlugins.list()).toEqual(overview);
|
|
expect(axios.get).toHaveBeenCalledWith('api/v1/plugins');
|
|
});
|
|
|
|
it('should PUT api/v1/plugins/:id with an encoded id', async () => {
|
|
(axios.put as any).mockResolvedValue({ data: overview });
|
|
await apiPlugins.update('my plugin', { enabled: true });
|
|
expect(axios.put).toHaveBeenCalledWith('api/v1/plugins/my%20plugin', {
|
|
enabled: true,
|
|
});
|
|
});
|
|
|
|
it('should PUT api/v1/plugins/settings with allow_unsigned', async () => {
|
|
(axios.put as any).mockResolvedValue({ data: overview });
|
|
await apiPlugins.updateSettings(true);
|
|
expect(axios.put).toHaveBeenCalledWith('api/v1/plugins/settings', {
|
|
allow_unsigned: true,
|
|
});
|
|
});
|
|
|
|
it('should GET api/v1/plugins/providers', async () => {
|
|
(axios.get as any).mockResolvedValue({ data: {} });
|
|
await apiPlugins.providers();
|
|
expect(axios.get).toHaveBeenCalledWith('api/v1/plugins/providers');
|
|
});
|
|
});
|