@@ -548,6 +548,65 @@ describe("channelsAddCommand", () => {
548548 expectExternalChatEnabledConfigWrite ( ) ;
549549 } ) ;
550550
551+ it ( "uses setup-entry snapshots when an already loaded channel plugin has no setup adapter" , async ( ) => {
552+ configMocks . readConfigFileSnapshot . mockResolvedValue ( { ...baseConfigSnapshot } ) ;
553+ setActivePluginRegistry (
554+ createTestRegistry ( [
555+ {
556+ pluginId : "telegram" ,
557+ plugin : createChannelTestPluginBase ( { id : "telegram" , label : "Telegram" } ) ,
558+ source : "test" ,
559+ } ,
560+ ] ) ,
561+ ) ;
562+ vi . mocked ( loadChannelSetupPluginRegistrySnapshotForChannel ) . mockReturnValue (
563+ createTestRegistry ( [
564+ {
565+ pluginId : "telegram" ,
566+ plugin : {
567+ ...createChannelTestPluginBase ( { id : "telegram" , label : "Telegram" } ) ,
568+ setup : {
569+ applyAccountConfig : ( { cfg, input } ) => ( {
570+ ...cfg ,
571+ channels : {
572+ ...cfg . channels ,
573+ telegram : {
574+ enabled : true ,
575+ botToken : input . token ,
576+ } ,
577+ } ,
578+ } ) ,
579+ } ,
580+ } ,
581+ source : "test" ,
582+ } ,
583+ ] ) ,
584+ ) ;
585+
586+ await channelsAddCommand (
587+ {
588+ channel : "telegram" ,
589+ token : "123456:token" ,
590+ } ,
591+ runtime ,
592+ { hasFlags : true } ,
593+ ) ;
594+
595+ expect ( loadChannelSetupPluginRegistrySnapshotForChannel ) . toHaveBeenCalledTimes ( 1 ) ;
596+ expect ( configMocks . writeConfigFile ) . toHaveBeenCalledWith (
597+ expect . objectContaining ( {
598+ channels : expect . objectContaining ( {
599+ telegram : expect . objectContaining ( {
600+ enabled : true ,
601+ botToken : "123456:token" ,
602+ } ) ,
603+ } ) ,
604+ } ) ,
605+ ) ;
606+ expect ( runtime . error ) . not . toHaveBeenCalledWith ( "Channel telegram does not support add." ) ;
607+ expect ( runtime . exit ) . not . toHaveBeenCalled ( ) ;
608+ } ) ;
609+
551610 it ( "falls back from untrusted workspace catalog shadows when adding by alias" , async ( ) => {
552611 configMocks . readConfigFileSnapshot . mockResolvedValue ( { ...baseConfigSnapshot } ) ;
553612 setActivePluginRegistry ( createTestRegistry ( ) ) ;
0 commit comments