@@ -12,6 +12,24 @@ function appBundledPluginRoot(pluginId: string): string {
|
12 | 12 | return bundledPluginRootAt(APP_ROOT, pluginId); |
13 | 13 | } |
14 | 14 | |
| 15 | +function requireExpectedPluginId(params: { expectedPluginId?: string }): string { |
| 16 | +if (!params.expectedPluginId) { |
| 17 | +throw new Error("Expected npm install params to include expectedPluginId"); |
| 18 | +} |
| 19 | +return params.expectedPluginId; |
| 20 | +} |
| 21 | + |
| 22 | +function requirePluginPackageName( |
| 23 | +plugins: Array<{ pluginId: string; packageName: string }>, |
| 24 | +pluginId: string, |
| 25 | +): string { |
| 26 | +const plugin = plugins.find((candidate) => candidate.pluginId === pluginId); |
| 27 | +if (!plugin) { |
| 28 | +throw new Error(`Expected plugin fixture ${pluginId}`); |
| 29 | +} |
| 30 | +return plugin.packageName; |
| 31 | +} |
| 32 | + |
15 | 33 | const installPluginFromNpmSpecMock = vi.fn(); |
16 | 34 | const installPluginFromMarketplaceMock = vi.fn(); |
17 | 35 | const installPluginFromClawHubMock = vi.fn(); |
@@ -872,12 +890,12 @@ describe("updateNpmInstalledPlugins", () => {
|
872 | 890 | } |
873 | 891 | installPluginFromNpmSpecMock.mockImplementation( |
874 | 892 | (params: { expectedPluginId?: string; spec: string }) => { |
875 | | -const pluginId = params.expectedPluginId!; |
| 893 | +const pluginId = requireExpectedPluginId(params); |
876 | 894 | for (const { pluginId: installedPluginId } of plugins) { |
877 | 895 | fs.rmSync(peerLinkPath(installedPluginId), { recursive: true, force: true }); |
878 | 896 | } |
879 | 897 | linkPeer(pluginId); |
880 | | -const packageName = plugins.find((plugin) => plugin.pluginId === pluginId)!.packageName; |
| 898 | +const packageName = requirePluginPackageName(plugins, pluginId); |
881 | 899 | return Promise.resolve( |
882 | 900 | createSuccessfulNpmUpdateResult({ |
883 | 901 | pluginId, |
|