feat(coding): add model tools and device packages

This commit is contained in:
brother7 committed 2026-09-02 18:46:21 +08:00
1 parent 841273b433
commit 664b8823a0
60 files changed
+3847 -2068

No files matched your search

+36 -6
View File
@@ -75,6 +75,36 @@ describe('My Plugins', () => {
],
};
it('separates official and device-installed packages without a visible install picker', () => {
const setEnabled = vi.fn();
const uninstall = vi.fn();
render(<MemoryRouter><MyPluginsView
library={{ ...library, items: [library.items[0]] }} installations={{}} state="ready"
pending={{}} onRefresh={vi.fn()} onInstall={vi.fn()} onUpdate={vi.fn()}
onInstallBeta={vi.fn()} onUninstall={vi.fn()} onRemove={vi.fn()} onReacquire={vi.fn()}
deviceIndex={{ schemaVersion: 1, generation: 2, packages: [{
schemaVersion: 1, packageId: 'pi-web-search', displayName: 'Pi Web Search',
resolvedVersion: '1.2.3',
source: { kind: 'npm', requested: 'npm:pi-web-search', resolved: 'npm:pi-web-search@1.2.3' },
kind: 'mixed', skillEntries: [{ id: 'pi-web-search', entryPath: 'skills/search/SKILL.md' }],
extensionEntries: ['extensions/search.ts'], enabled: true, confirmedExecutableCode: true,
installedAt: '2026-09-02T00:00:00.000Z',
}] }} deviceState="ready" devicePending={{}}
onDeviceRefresh={vi.fn()} onDeviceSetEnabled={setEnabled} onDeviceUninstall={uninstall}
/></MemoryRouter>);
expect(screen.getByRole('heading', { name: '官方插件' })).toBeVisible();
expect(screen.getByRole('heading', { name: '本机安装' })).toBeVisible();
expect(screen.getByText('Pi Web Search')).toBeVisible();
expect(screen.getByText(/完整桌面权限/)).toBeVisible();
expect(screen.queryByRole('textbox', { name: /包|路径|source/i })).not.toBeInTheDocument();
expect(screen.getByText(/在对话中/)).toBeVisible();
fireEvent.click(screen.getByRole('button', { name: '停用 Pi Web Search' }));
fireEvent.click(screen.getByRole('button', { name: '移除本机包 Pi Web Search' }));
expect(setEnabled).toHaveBeenCalledWith('pi-web-search', false);
expect(uninstall).toHaveBeenCalledWith('pi-web-search');
});
it('shows update/remove/reacquire and project/partner actions without chaining them', () => {
const onUpdate = vi.fn();
const onRemove = vi.fn();
@@ -132,8 +162,8 @@ describe('My Plugins', () => {
it('shows acquired code-owned bundled Plugins as supplied without device download actions', () => {
const bundled = {
...library.items[0],
pluginId: 'makelore.web-search',
title: '联网搜索',
pluginId: 'makelore.game-resource',
title: '游戏资源生成',
stableVersion: '1.0.0',
betaVersion: null,
};
@@ -145,10 +175,10 @@ describe('My Plugins', () => {
expect(screen.getByText('随 MakeLore 提供')).toBeVisible();
expect(screen.queryByText('尚未下载到设备')).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '下载联网搜索' })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '更新联网搜索' })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '删除设备上的联网搜索' })).not.toBeInTheDocument();
expect(screen.getByRole('button', { name: '移除联网搜索' })).toBeVisible();
expect(screen.queryByRole('button', { name: '下载游戏资源生成' })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '更新游戏资源生成' })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '删除设备上的游戏资源生成' })).not.toBeInTheDocument();
expect(screen.getByRole('button', { name: '移除游戏资源生成' })).toBeVisible();
expect(screen.getByRole('link', { name: '启用到项目' })).toBeVisible();
});