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

@@ -36,6 +36,8 @@ test.describe('Plugin Marketplace', () => {
});
await page.getByTestId('sidebar-nav-plugin-marketplace').click();
await expect(page.getByTestId('sidebar-nav-my-plugins')).toHaveCount(0);
await expect(page.getByTestId('sidebar-nav-project-plugins')).toHaveCount(0);
await expect(page.getByTestId('plugin-marketplace-page')).toBeVisible();
await expect(page.getByRole('heading', { name: '灵感笔记' })).toBeVisible();
await page.getByRole('searchbox', { name: '搜索插件' }).fill('笔记');
@@ -116,6 +118,10 @@ test.describe('Plugin Marketplace', () => {
return response;
}
if (requestPath === '/api/auth/me') return result({ success: true, moduleAccess: { programming: true } });
if (requestPath.startsWith('/api/coding/plugin-marketplace/catalog')) return result({
items: [], nextCursor: null, total: 0, catalogGeneration: 1,
etag: '"plugins-1-tp-none"', pricingVersionId: null, stale: false, fetchedAt: 1,
});
if (requestPath === '/api/coding/plugin-marketplace/library') return result(projection());
if (requestPath === '/api/coding/plugin-marketplace/install/makelore.notes/beta' && method === 'POST') {
installedChannel = 'beta';
@@ -149,7 +155,8 @@ test.describe('Plugin Marketplace', () => {
await programmingOption.click();
await expect(page.getByTestId('main-layout')).toBeVisible();
await page.keyboard.press('Escape');
await page.getByTestId('sidebar-nav-my-plugins').click();
await page.getByTestId('sidebar-nav-plugin-marketplace').click();
await page.getByRole('tab', { name: '我的插件' }).click();
await expect(page.getByTestId('my-plugins-page')).toBeVisible();
await expect.poll(async () => app.evaluate(() => (
((globalThis as typeof globalThis & { __marketplaceE2E?: { requests: string[] } }).__marketplaceE2E?.requests ?? [])

View File

@@ -51,8 +51,12 @@ test.describe('Project Plugin Center', () => {
});
});
await page.getByTestId('sidebar-nav-project-plugins').click();
await page.getByTestId('resource-card-plugins').click();
await expect(page.getByTestId('project-plugins-page')).toBeVisible();
await page.getByTestId('project-plugins-page').getByRole('button', { name: '刷新' }).click();
await expect.poll(async () => app.evaluate(() => (
(globalThis as typeof globalThis & { __projectPluginE2E?: { localProjectId: string } }).__projectPluginE2E?.localProjectId
))).toBeTruthy();
await expect(page.getByText('当前包含,不按单次调用扣点')).toBeVisible();
const localProjectId = await app.evaluate(() => (
(globalThis as typeof globalThis & { __projectPluginE2E?: { localProjectId: string } }).__projectPluginE2E?.localProjectId

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);
});
});