@@ -108,6 +108,54 @@ describe("applyPluginAutoEnable core", () => {
108108 ] ) ;
109109 } ) ;
110110
111+ it ( "keeps configured channel candidates when plugin config is already present" , ( ) => {
112+ const result = applyPluginAutoEnable ( {
113+ config : {
114+ channels : {
115+ discord : {
116+ enabled : true ,
117+ accounts : { default : { token : "redacted" } } ,
118+ } ,
119+ } ,
120+ plugins : {
121+ entries : {
122+ discord : { config : { } } ,
123+ } ,
124+ } ,
125+ } ,
126+ env,
127+ manifestRegistry : makeRegistry ( [ { id : "discord" , channels : [ "discord" ] , origin : "global" } ] ) ,
128+ } ) ;
129+
130+ expect ( result . config . plugins ?. entries ?. discord ) . toEqual ( { config : { } , enabled : true } ) ;
131+ expect ( result . changes ) . toContain ( "Discord configured, enabled automatically." ) ;
132+ } ) ;
133+
134+ it ( "keeps configured channel candidates under a material plugin allowlist" , ( ) => {
135+ const candidates = detectPluginAutoEnableCandidates ( {
136+ config : {
137+ channels : { discord : { token : "redacted" } } ,
138+ plugins : {
139+ allow : [ "existing" ] ,
140+ entries : {
141+ existing : { enabled : true } ,
142+ } ,
143+ } ,
144+ } ,
145+ env,
146+ manifestRegistry : makeRegistry ( [
147+ { id : "discord" , channels : [ "discord" ] , origin : "global" } ,
148+ { id : "existing" , channels : [ ] , origin : "global" } ,
149+ ] ) ,
150+ } ) ;
151+
152+ expect ( candidates ) . toContainEqual ( {
153+ pluginId : "discord" ,
154+ kind : "channel-configured" ,
155+ channelId : "discord" ,
156+ } ) ;
157+ } ) ;
158+
111159 it ( "reuses policy-compatible current manifest registry when runtime config differs" , ( ) => {
112160 const manifestRegistry = makeRegistry ( [ { id : "custom-chat" , channels : [ "custom-chat" ] } ] ) ;
113161 const snapshotConfig : OpenClawConfig = { plugins : { allow : [ "existing" ] } } ;
@@ -1272,7 +1320,7 @@ describe("applyPluginAutoEnable core", () => {
12721320 const result = applyPluginAutoEnable ( {
12731321 config : {
12741322 channels : { slack : { botToken : "x" } } ,
1275- plugins : { entries : { slack : { enabled : false } } } ,
1323+ plugins : { entries : { slack : { enabled : false , config : { } } } } ,
12761324 } ,
12771325 env,
12781326 } ) ;
0 commit comments