@@ -136,24 +136,21 @@ describe("loadConfigForInstall", () => {
136136 hookMutation : { mode : "allowed" } ,
137137 pluginMutation : { mode : "allowed" } ,
138138 } ) ;
139- } ) ;
140-
141- it ( "returns valid source config unchanged" , async ( ) => {
142- const cfg = { plugins : { } } as OpenClawConfig ;
143- readConfigFileSnapshotMock . mockResolvedValue (
144- makeSnapshot ( {
145- valid : true ,
146- sourceConfig : cfg ,
147- config : cfg ,
148- issues : [ ] ,
149- } ) ,
150- ) ;
151-
152- const result = await loadConfigForInstall ( discordNpmRequest ) ;
153139 expect ( result . config ) . toBe ( cfg ) ;
154140 } ) ;
155141
156- it ( "falls back to snapshot config for explicit bundled-plugin reinstall when issues match the known upgrade failure" , async ( ) => {
142+ it . each ( [
143+ { path : "channels.discord" , message : "unknown channel id: discord" } ,
144+ { path : "channels.discord" , message : "invalid config for plugin discord: must be object" } ,
145+ {
146+ path : "channels.discord.accounts.work" ,
147+ message : "invalid config for plugin discord: must be object" ,
148+ } ,
149+ {
150+ path : "channels.other-channel" ,
151+ message : "invalid config for plugin discord: must be object" ,
152+ } ,
153+ ] ) ( "recovers requested-plugin upgrade issue $path: $message" , async ( issue ) => {
157154 const snapshotCfg = {
158155 plugins : { installs : { discord : { source : "path" , installPath : "/gone" } } } ,
159156 } as unknown as OpenClawConfig ;
@@ -162,7 +159,7 @@ describe("loadConfigForInstall", () => {
162159 parsed : { plugins : { installs : { discord : { } } } } ,
163160 config : snapshotCfg ,
164161 issues : [
165- { path : "channels.discord" , message : "unknown channel id: discord" } ,
162+ issue ,
166163 { path : "plugins.load.paths" , message : "plugin: plugin path not found: /gone" } ,
167164 ] ,
168165 } ) ,
@@ -179,40 +176,6 @@ describe("loadConfigForInstall", () => {
179176 } ) ;
180177 } ) ;
181178
182- it ( "allows versioned npm:-prefixed bundled-plugin reinstall recovery" , async ( ) => {
183- const snapshotCfg = {
184- plugins : { installs : { discord : { source : "path" , installPath : "/gone" } } } ,
185- } as unknown as OpenClawConfig ;
186- readConfigFileSnapshotMock . mockResolvedValue (
187- makeSnapshot ( {
188- parsed : { plugins : { installs : { discord : { } } } } ,
189- config : snapshotCfg ,
190- issues : [
191- { path : "channels.discord" , message : "unknown channel id: discord" } ,
192- { path : "plugins.load.paths" , message : "plugin: plugin path not found: /gone" } ,
193- ] ,
194- } ) ,
195- ) ;
196-
197- const request = resolvePluginInstallRequestContext ( {
198- rawSpec :
"npm:@openclaw/[email protected] " , 199- } ) ;
200- if ( ! request . ok ) {
201- throw new Error ( request . error ) ;
202- }
203-
204- expect ( request . request . bundledPluginId ) . toBe ( "discord" ) ;
205- expect ( request . request . allowInvalidConfigRecovery ) . toBe ( true ) ;
206- const result = await loadConfigForInstall ( request . request ) ;
207- expect ( result ) . toEqual ( {
208- config : snapshotCfg ,
209- baseHash : "abc" ,
210- writeOptions : installWriteOptions ,
211- hookMutation : { mode : "allowed" } ,
212- pluginMutation : { mode : "allowed" } ,
213- } ) ;
214- } ) ;
215-
216179 it . each ( [ "file:@openclaw/discord" , "FILE:@openclaw/discord" ] ) (
217180 "does not treat %s as an official plugin recovery request" ,
218181 ( rawSpec ) => {
@@ -238,49 +201,50 @@ describe("loadConfigForInstall", () => {
238201 expect ( request . request . installKind ) . toBe ( "plugin" ) ;
239202 } ) ;
240203
241- it ( "allows versioned official npm spec reinstall recovery" , async ( ) => {
242- const snapshotCfg = {
243- plugins : {
244- installs : { discord : { source : "npm" , installPath : "/gone" } } ,
245- load : { paths : [ "/gone" , "/keep" ] } ,
246- } ,
247- channels : { discord : { token : "preserve-me" } } ,
248- } as unknown as OpenClawConfig ;
249- readConfigFileSnapshotMock . mockResolvedValue (
250- makeSnapshot ( {
251- parsed : { plugins : { installs : { discord : { } } , load : { paths : [ "/gone" , "/keep" ] } } } ,
252- config : snapshotCfg ,
253- issues : [
254- { path : "channels.discord" , message : "unknown channel id: discord" } ,
255- { path : "plugins.load.paths" , message : "plugin: plugin path not found: /gone" } ,
256- ] ,
257- } ) ,
258- ) ;
259-
260- const request = resolvePluginInstallRequestContext ( {
261- rawSpec :
"@openclaw/[email protected] " , 262- } ) ;
263- if ( ! request . ok ) {
264- throw new Error ( request . error ) ;
265- }
266-
267- expect ( request . request . bundledPluginId ) . toBe ( "discord" ) ;
268- expect ( request . request . allowInvalidConfigRecovery ) . toBe ( true ) ;
269- const result = await loadConfigForInstall ( request . request ) ;
270- expect ( result ) . toEqual ( {
271- config : {
204+ it . each ( [ "@openclaw/[email protected] " , "npm:@openclaw/[email protected] " ] ) ( 205+ "allows versioned official reinstall recovery for %s" ,
206+ async ( rawSpec ) => {
207+ const snapshotCfg = {
272208 plugins : {
273209 installs : { discord : { source : "npm" , installPath : "/gone" } } ,
274- load : { paths : [ "/keep" ] } ,
210+ load : { paths : [ "/gone" , "/ keep"] } ,
275211 } ,
276212 channels : { discord : { token : "preserve-me" } } ,
277- } ,
278- baseHash : "abc" ,
279- writeOptions : installWriteOptions ,
280- hookMutation : { mode : "allowed" } ,
281- pluginMutation : { mode : "allowed" } ,
282- } ) ;
283- } ) ;
213+ } as unknown as OpenClawConfig ;
214+ readConfigFileSnapshotMock . mockResolvedValue (
215+ makeSnapshot ( {
216+ parsed : { plugins : { installs : { discord : { } } , load : { paths : [ "/gone" , "/keep" ] } } } ,
217+ config : snapshotCfg ,
218+ issues : [
219+ { path : "channels.discord" , message : "unknown channel id: discord" } ,
220+ { path : "plugins.load.paths" , message : "plugin: plugin path not found: /gone" } ,
221+ ] ,
222+ } ) ,
223+ ) ;
224+
225+ const request = resolvePluginInstallRequestContext ( { rawSpec } ) ;
226+ if ( ! request . ok ) {
227+ throw new Error ( request . error ) ;
228+ }
229+
230+ expect ( request . request . bundledPluginId ) . toBe ( "discord" ) ;
231+ expect ( request . request . allowInvalidConfigRecovery ) . toBe ( true ) ;
232+ const result = await loadConfigForInstall ( request . request ) ;
233+ expect ( result ) . toEqual ( {
234+ config : {
235+ plugins : {
236+ installs : { discord : { source : "npm" , installPath : "/gone" } } ,
237+ load : { paths : [ "/keep" ] } ,
238+ } ,
239+ channels : { discord : { token : "preserve-me" } } ,
240+ } ,
241+ baseHash : "abc" ,
242+ writeOptions : installWriteOptions ,
243+ hookMutation : { mode : "allowed" } ,
244+ pluginMutation : { mode : "allowed" } ,
245+ } ) ;
246+ } ,
247+ ) ;
284248
285249 it ( "uses the canonical plugin install record to own a stale recovery load path" , async ( ) => {
286250 const snapshotCfg = {
@@ -916,10 +880,28 @@ describe("loadConfigForInstall", () => {
916880 } ,
917881 ) ;
918882
919- it ( "rejects unrelated invalid config even during bundled-plugin reinstall recovery" , async ( ) => {
883+ it . each ( [
884+ { path : "models.default" , message : "invalid model ref" } ,
885+ { path : "channels.discord" , message : "invalid config for plugin telegram: must be object" } ,
886+ {
887+ path : "channels.discord" ,
888+ message : "invalid config for plugin discord-extra: must be object" ,
889+ } ,
890+ { path : "channels.discord" , message : "must be object" } ,
891+ {
892+ path : "plugins.entries.discord.config" ,
893+ message : "invalid config for plugin discord: must be object" ,
894+ } ,
895+ ] ) ( "rejects unrelated issue $path: $message during plugin recovery" , async ( issue ) => {
920896 readConfigFileSnapshotMock . mockResolvedValue (
921897 makeSnapshot ( {
922- issues : [ { path : "models.default" , message : "invalid model ref" } ] ,
898+ issues : [
899+ {
900+ path : "channels.discord" ,
901+ message : "invalid config for plugin discord: must be object" ,
902+ } ,
903+ issue ,
904+ ] ,
923905 } ) ,
924906 ) ;
925907
0 commit comments