feat: add plugin marketplace renderer
This commit is contained in:
1 parent
8b6824a8ba
commit
97c9ad1aad
27 files changed
+1585
-23
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import {
|
||||
acquireMarketplacePlugin,
|
||||
installMarketplacePlugin,
|
||||
readMarketplaceCatalog,
|
||||
removeMarketplacePlugin,
|
||||
updateMarketplacePlugin,
|
||||
} from '@/lib/plugin-marketplace';
|
||||
|
||||
const catalog = {
|
||||
items: [], nextCursor: null, total: 0, catalogGeneration: 1,
|
||||
etag: '"plugins-1-tp-none"', pricingVersionId: null, stale: false, fetchedAt: 1,
|
||||
};
|
||||
const library = { library: { items: [], total: 0, stale: false, fetchedAt: 1 }, installations: [] };
|
||||
const installation = { status: 'installed', pluginId: 'makelore.notes', releaseId: 'release-1', version: '1.0.0' };
|
||||
|
||||
describe('Renderer plugin Marketplace client', () => {
|
||||
it('uses only the bounded catalog query contract', async () => {
|
||||
const fetcher = vi.fn().mockResolvedValue(catalog);
|
||||
await expect(readMarketplaceCatalog({ query: 'notes', category: 'productivity', featured: true, limit: 24 }, fetcher)).resolves.toEqual(catalog);
|
||||
expect(fetcher).toHaveBeenCalledWith('/api/coding/plugin-marketplace/catalog?query=notes&category=productivity&featured=true&limit=24');
|
||||
});
|
||||
|
||||
it('keeps acquire, install, update, and remove as four independent requests', async () => {
|
||||
const fetcher = vi.fn()
|
||||
.mockResolvedValueOnce(library)
|
||||
.mockResolvedValueOnce(installation)
|
||||
.mockResolvedValueOnce(installation)
|
||||
.mockResolvedValueOnce(library);
|
||||
|
||||
await acquireMarketplacePlugin('makelore.notes', fetcher);
|
||||
await installMarketplacePlugin('makelore.notes', fetcher);
|
||||
await updateMarketplacePlugin('makelore.notes', fetcher);
|
||||
await removeMarketplacePlugin('makelore.notes', fetcher);
|
||||
|
||||
expect(fetcher.mock.calls).toEqual([
|
||||
['/api/coding/plugin-marketplace/library/makelore.notes', { method: 'PUT', body: '{}' }],
|
||||
['/api/coding/plugin-marketplace/install/makelore.notes', { method: 'POST', body: '{}' }],
|
||||
['/api/coding/plugin-marketplace/update/makelore.notes', { method: 'POST', body: '{}' }],
|
||||
['/api/coding/plugin-marketplace/library/makelore.notes', { method: 'DELETE', body: '{}' }],
|
||||
]);
|
||||
expect(JSON.stringify(fetcher.mock.calls)).not.toMatch(/account|admission|releaseId|path/i);
|
||||
});
|
||||
|
||||
it('rejects invalid plugin identifiers before calling Main', async () => {
|
||||
const fetcher = vi.fn();
|
||||
await expect(acquireMarketplacePlugin('../escape', fetcher)).rejects.toThrow('plugin id');
|
||||
expect(fetcher).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user