@@ -11,6 +11,10 @@ vi.mock("../channels/plugins/index.js", () => ({
1111 listChannelPlugins : ( ) => activeChannelPlugins ,
1212 getLoadedChannelPlugin : ( id : string ) => activeChannelPlugins . find ( ( plugin ) => plugin . id === id ) ,
1313 getChannelPlugin : ( id : string ) => activeChannelPlugins . find ( ( plugin ) => plugin . id === id ) ,
14+ normalizeChannelId : ( value : string ) => {
15+ const normalized = value . trim ( ) . toLowerCase ( ) ;
16+ return normalized === "wa" || normalized === "whatsapp" ? "whatsapp" : null ;
17+ } ,
1418} ) ) ;
1519
1620vi . mock ( "../channels/plugins/read-only.js" , ( ) => ( {
@@ -25,12 +29,18 @@ async function formatLocalStatusSummary(
2529 cfg : unknown ,
2630 options ?: {
2731 sourceConfig ?: unknown ;
32+ channel ?: string ;
2833 } ,
2934) {
3035 const lines = await formatConfigChannelsStatusLines (
3136 cfg as never ,
3237 { mode : "local" } ,
33- options ?. sourceConfig ? { sourceConfig : options . sourceConfig as never } : undefined ,
38+ options
39+ ? {
40+ ...( options . sourceConfig ? { sourceConfig : options . sourceConfig as never } : { } ) ,
41+ ...( options . channel !== undefined ? { channel : options . channel } : { } ) ,
42+ }
43+ : undefined ,
3444 ) ;
3545 return lines . join ( "\n" ) ;
3646}
@@ -193,6 +203,68 @@ function requireReadOnlyPluginListCall(): unknown[] {
193203}
194204
195205describe ( "config-only channels status output" , ( ) => {
206+ it . each ( [
207+ {
208+ label : "unregistered external channels" ,
209+ channel : "token-only" ,
210+ included : [ "TokenOnly" ] ,
211+ excluded : [ "WhatsApp" ] ,
212+ } ,
213+ {
214+ label : "case-insensitive external channels" ,
215+ channel : "TOKEN-ONLY" ,
216+ included : [ "TokenOnly" ] ,
217+ excluded : [ "WhatsApp" ] ,
218+ } ,
219+ {
220+ label : "bundled channel aliases" ,
221+ channel : "wa" ,
222+ included : [ "WhatsApp" ] ,
223+ excluded : [ "TokenOnly" ] ,
224+ } ,
225+ {
226+ label : "unknown channels" ,
227+ channel : "missing-channel" ,
228+ included : [ ] ,
229+ excluded : [ "TokenOnly" , "WhatsApp" ] ,
230+ } ,
231+ {
232+ label : "no channel filter" ,
233+ channel : undefined ,
234+ included : [ "TokenOnly" , "WhatsApp" ] ,
235+ excluded : [ ] ,
236+ } ,
237+ {
238+ label : "blank channel filters" ,
239+ channel : " " ,
240+ included : [ "TokenOnly" , "WhatsApp" ] ,
241+ excluded : [ ] ,
242+ } ,
243+ ] ) (
244+ "preserves exact config-only status filtering for $label" ,
245+ async ( { channel, included, excluded } ) => {
246+ activeChannelPlugins . splice (
247+ 0 ,
248+ activeChannelPlugins . length ,
249+ makeUnavailableTokenPlugin ( ) ,
250+ makeIndeterminateLinkPlugin ( ) ,
251+ ) ;
252+
253+ const summary = await formatLocalStatusSummary (
254+ { channels : { "token-only" : { } , whatsapp : { } } } ,
255+ { channel } ,
256+ ) ;
257+
258+ expect ( summary ) . toContain ( "Gateway not reachable; showing config-only status." ) ;
259+ for ( const label of included ) {
260+ expect ( summary ) . toContain ( label ) ;
261+ }
262+ for ( const label of excluded ) {
263+ expect ( summary ) . not . toContain ( label ) ;
264+ }
265+ } ,
266+ ) ;
267+
196268 it ( "uses setup fallback plugins so configured external channels can be shown" , async ( ) => {
197269 registerSingleTestPlugin ( "token-only" , makeUnavailableTokenPlugin ( ) ) ;
198270 listReadOnlyChannelPluginsForConfig . mockClear ( ) ;
0 commit comments