From a501f3778e26f72f883eb4029fd30f78ee5e2466 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 18 Mar 2026 11:08:37 +0000 Subject: [PATCH] test plugin install diagnostics for EPERM failures Co-authored-by: Haze --- tests/unit/plugin-install.test.ts | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/unit/plugin-install.test.ts b/tests/unit/plugin-install.test.ts index 4903ad7..1f74a54 100644 --- a/tests/unit/plugin-install.test.ts +++ b/tests/unit/plugin-install.test.ts @@ -151,4 +151,38 @@ describe('plugin installer diagnostics', () => { }), ); }); + + it('logs EPERM diagnostics with source and target paths', async () => { + setPlatform('win32'); + mockHomedir.mockReturnValue('C:\\Users\\test'); + + const sourceDir = 'C:\\Program Files\\ClawX\\resources\\openclaw-plugins\\wecom'; + const sourceManifestSuffix = 'Program Files\\ClawX\\resources\\openclaw-plugins\\wecom\\openclaw.plugin.json'; + + mockExistsSync.mockImplementation((input: string) => String(input).includes(sourceManifestSuffix)); + mockCpSync.mockImplementation(() => { + const error = new Error('access denied') as NodeJS.ErrnoException; + error.code = 'EPERM'; + throw error; + }); + + const { ensurePluginInstalled } = await import('@electron/utils/plugin-install'); + const result = ensurePluginInstalled('wecom', [sourceDir], 'WeCom'); + + expect(result.installed).toBe(false); + expect(result.warning).toBe('Failed to install bundled WeCom plugin mirror'); + + expect(mockLoggerWarn).toHaveBeenCalledWith( + '[plugin] Bundled mirror install failed for WeCom', + expect.objectContaining({ + sourceDir, + targetDir: expect.stringContaining('.openclaw/extensions/wecom'), + platform: 'win32', + attempts: [ + expect.objectContaining({ attempt: 1, code: 'EPERM' }), + expect.objectContaining({ attempt: 2, code: 'EPERM' }), + ], + }), + ); + }); });