feat(plugin-inventory): offline bundle and pnpm plugin install for the desktop
Adds an install surface to the plugin-inventory gateway: availableBundles lists the curated offline-installable optional bundles (AVAILABLE_BUNDLES); install composes an offline bundle into the profile's dsh.profile.bundles, or for a registry spec runs pnpm against the writable profile via the bundled Node and a vendored pnpm (gated behind the dshAllowPluginInstall context flag, set only by the desktop boot); uninstall removes a bundle layer. The reconcile logic from `dsh plugin add` moves into app-boot as shared helpers. The desktop vendored pnpm into the harness and sets the allow-install env; the plugin-list SPA gains an installable-bundles section. Tests cover the guard, install helpers, and the SPA section at 100% host coverage. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -13,10 +13,18 @@ afterEach(cleanup)
|
||||
type Snapshot = Awaited<ReturnType<PluginInventorySettingsTabInjected['list']>>
|
||||
const t = ((key: PluginInventoryLocaleKey): string => en[key]) as PluginInventorySettingsTabProps['t']
|
||||
|
||||
function props(list: PluginInventorySettingsTabInjected['list']): PluginInventorySettingsTabProps {
|
||||
function props(
|
||||
list: PluginInventorySettingsTabInjected['list'],
|
||||
bundles: PluginInventorySettingsTabInjected['availableBundles'] = async () => ({ available: [] }),
|
||||
install: PluginInventorySettingsTabInjected['install'] = async () => ({ ok: true as const, restartRequired: true }),
|
||||
uninstall: PluginInventorySettingsTabInjected['uninstall'] = async () => ({ ok: true as const, restartRequired: true }),
|
||||
): PluginInventorySettingsTabProps {
|
||||
return {
|
||||
t,
|
||||
list,
|
||||
availableBundles: bundles,
|
||||
install,
|
||||
uninstall,
|
||||
} as PluginInventorySettingsTabProps
|
||||
}
|
||||
|
||||
@@ -153,4 +161,29 @@ describe('PluginInventorySettingsTab', () => {
|
||||
pendingFailure.unmount()
|
||||
await act(async () => { deferredFailure.reject(new Error('late failure')) })
|
||||
})
|
||||
|
||||
it('renders the installable bundles with install and uninstall actions', async () => {
|
||||
const install = vi.fn<PluginInventorySettingsTabInjected['install']>(async () => ({ ok: true, restartRequired: true }))
|
||||
const uninstall = vi.fn<PluginInventorySettingsTabInjected['uninstall']>(async () => ({ ok: true, restartRequired: true }))
|
||||
const bundles: PluginInventorySettingsTabInjected['availableBundles'] = async () => ({
|
||||
available: [
|
||||
{ name: '@deepseek-ai/dsh-new-bundle', installed: false },
|
||||
{ name: '@deepseek-ai/dsh-installed-bundle', installed: true },
|
||||
],
|
||||
})
|
||||
render(<PluginInventorySettingsTab {...props(async () => SNAPSHOT, bundles, install, uninstall)} />)
|
||||
|
||||
expect(await screen.findByText(en.available)).toBeTruthy()
|
||||
expect(screen.getByText('@deepseek-ai/dsh-new-bundle')).toBeTruthy()
|
||||
expect(screen.getByText('@deepseek-ai/dsh-installed-bundle')).toBeTruthy()
|
||||
|
||||
// Install a not-installed bundle.
|
||||
fireEvent.click(screen.getByRole('button', { name: en.install }))
|
||||
expect(install).toHaveBeenCalledWith({ type: 'bundle', name: '@deepseek-ai/dsh-new-bundle' })
|
||||
expect(await screen.findByText(en.restartRequired)).toBeTruthy()
|
||||
|
||||
// Uninstall an installed bundle.
|
||||
fireEvent.click(screen.getByRole('button', { name: en.uninstall }))
|
||||
expect(uninstall).toHaveBeenCalledWith('@deepseek-ai/dsh-installed-bundle')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user