feat: consolidate plugin navigation

This commit is contained in:
inman
2026-08-31 16:30:17 +08:00
parent 38f85f6b5e
commit b3f4166f21
12 changed files with 227 additions and 69 deletions

View File

@@ -92,7 +92,9 @@ describe('My Plugins', () => {
expect(onRemove).toHaveBeenCalledWith('makelore.notes');
fireEvent.click(screen.getByRole('button', { name: '重新免费获取旧插件' }));
expect(onReacquire).toHaveBeenCalledWith('makelore.removed');
expect(screen.getAllByRole('link', { name: '启用到项目' }).length).toBeGreaterThan(0);
const projectLinks = screen.getAllByRole('link', { name: '启用到项目' });
expect(projectLinks.length).toBeGreaterThan(0);
expect(projectLinks[0]).toHaveAttribute('href', '/project-config?resource=plugins');
expect(screen.getAllByRole('link', { name: '分配给伙伴' }).length).toBeGreaterThan(0);
expect(screen.getByText('运行已暂停')).toBeVisible();
expect(screen.getByText('已退役,移除后不可重新获取')).toBeVisible();
@@ -129,6 +131,17 @@ describe('My Plugins', () => {
expect(screen.getByRole('link', { name: '分配给伙伴' })).toBeVisible();
});
it('renders as the account/device tab inside the unified plugin hub', () => {
render(<MemoryRouter><MyPluginsView
embedded library={{ ...library, items: [] }} 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()}
/></MemoryRouter>);
expect(screen.getByRole('heading', { name: '我的插件', level: 2 })).toBeVisible();
expect(screen.getByTestId('my-plugins-page').tagName).toBe('SECTION');
});
it('updates an installed Beta package only through the explicit Beta action', () => {
const onUpdate = vi.fn();
const onInstallBeta = vi.fn();

View File

@@ -92,4 +92,14 @@ describe('Project Plugin Center', () => {
fireEvent.click(screen.getByRole('button', { name: '从项目禁用保留插件 makelore.removed' }));
expect(onSetEnabled).toHaveBeenCalledWith('makelore.removed', false);
});
it('embeds project enablement in configuration and returns to Agent assignment explicitly', () => {
const onManageAgents = vi.fn();
render(<MemoryRouter><ProjectPluginsView embedded projectName="Demo" projection={projection()} dataService={null} pending={{}} agentNames={{}} onRefresh={vi.fn()} onSetEnabled={vi.fn()} onConfigure={vi.fn()} onReset={vi.fn()} onRemoveCollection={vi.fn()} onRemoveProject={vi.fn()} onManageAgents={onManageAgents} /></MemoryRouter>);
expect(screen.getByTestId('project-plugins-page').tagName).toBe('SECTION');
expect(screen.queryByRole('heading', { name: '项目插件' })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '分配给伙伴' }));
expect(onManageAgents).toHaveBeenCalledTimes(1);
});
});