@@ -288,6 +288,102 @@ describe('PluginController (e2e)', () => {
288288 expect ( res . json ( ) . pluginType ) . toBe ( 'platform' )
289289 } )
290290
291+ it ( 'GET /plugins/config-schema/:plugin-name (i18n - French)' , async ( ) => {
292+ // Mock the language setting to French
293+ const originalLang = ( pluginsService as any ) . configService . ui . lang ;
294+ ( pluginsService as any ) . configService . ui . lang = 'fr'
295+
296+ const res = await app . inject ( {
297+ method : 'GET' ,
298+ path : '/plugins/config-schema/homebridge-mock-plugin' ,
299+ headers : {
300+ authorization,
301+ } ,
302+ } )
303+
304+ expect ( res . statusCode ) . toBe ( 200 )
305+ expect ( res . json ( ) . pluginAlias ) . toBe ( 'ExampleHomebridgePlugin' )
306+ expect ( res . json ( ) . pluginType ) . toBe ( 'platform' )
307+ // Verify French translation is loaded
308+ expect ( res . json ( ) . schema . properties . name . title ) . toBe ( 'Nom' )
309+ expect ( res . json ( ) . schema . properties . name . default ) . toBe ( 'Exemple de plateforme dynamique' )
310+
311+ // Restore original language
312+ ; ( pluginsService as any ) . configService . ui . lang = originalLang
313+ } )
314+
315+ it ( 'GET /plugins/config-schema/:plugin-name (i18n - German)' , async ( ) => {
316+ // Mock the language setting to German
317+ const originalLang = ( pluginsService as any ) . configService . ui . lang ;
318+ ( pluginsService as any ) . configService . ui . lang = 'de'
319+
320+ const res = await app . inject ( {
321+ method : 'GET' ,
322+ path : '/plugins/config-schema/homebridge-mock-plugin' ,
323+ headers : {
324+ authorization,
325+ } ,
326+ } )
327+
328+ expect ( res . statusCode ) . toBe ( 200 )
329+ expect ( res . json ( ) . pluginAlias ) . toBe ( 'ExampleHomebridgePlugin' )
330+ expect ( res . json ( ) . pluginType ) . toBe ( 'platform' )
331+ // Verify German translation is loaded
332+ expect ( res . json ( ) . schema . properties . name . title ) . toBe ( 'Name' )
333+ expect ( res . json ( ) . schema . properties . name . default ) . toBe ( 'Beispiel Dynamische Plattform' )
334+
335+ // Restore original language
336+ ; ( pluginsService as any ) . configService . ui . lang = originalLang
337+ } )
338+
339+ it ( 'GET /plugins/config-schema/:plugin-name (i18n - fallback to base for unsupported language)' , async ( ) => {
340+ // Mock the language setting to a language that doesn't have a translation
341+ const originalLang = ( pluginsService as any ) . configService . ui . lang ;
342+ ( pluginsService as any ) . configService . ui . lang = 'es'
343+
344+ const res = await app . inject ( {
345+ method : 'GET' ,
346+ path : '/plugins/config-schema/homebridge-mock-plugin' ,
347+ headers : {
348+ authorization,
349+ } ,
350+ } )
351+
352+ expect ( res . statusCode ) . toBe ( 200 )
353+ expect ( res . json ( ) . pluginAlias ) . toBe ( 'ExampleHomebridgePlugin' )
354+ expect ( res . json ( ) . pluginType ) . toBe ( 'platform' )
355+ // Verify base English schema is loaded as fallback
356+ expect ( res . json ( ) . schema . properties . name . title ) . toBe ( 'Name' )
357+ expect ( res . json ( ) . schema . properties . name . default ) . toBe ( 'Example Dynamic Platform' )
358+
359+ // Restore original language
360+ ; ( pluginsService as any ) . configService . ui . lang = originalLang
361+ } )
362+
363+ it ( 'GET /plugins/config-schema/:plugin-name (i18n - English explicitly)' , async ( ) => {
364+ // Mock the language setting to English (should skip i18n directory)
365+ const originalLang = ( pluginsService as any ) . configService . ui . lang ;
366+ ( pluginsService as any ) . configService . ui . lang = 'en'
367+
368+ const res = await app . inject ( {
369+ method : 'GET' ,
370+ path : '/plugins/config-schema/homebridge-mock-plugin' ,
371+ headers : {
372+ authorization,
373+ } ,
374+ } )
375+
376+ expect ( res . statusCode ) . toBe ( 200 )
377+ expect ( res . json ( ) . pluginAlias ) . toBe ( 'ExampleHomebridgePlugin' )
378+ expect ( res . json ( ) . pluginType ) . toBe ( 'platform' )
379+ // Verify base English schema is loaded (not from i18n directory)
380+ expect ( res . json ( ) . schema . properties . name . title ) . toBe ( 'Name' )
381+ expect ( res . json ( ) . schema . properties . name . default ) . toBe ( 'Example Dynamic Platform' )
382+
383+ // Restore original language
384+ ; ( pluginsService as any ) . configService . ui . lang = originalLang
385+ } )
386+
291387 it ( 'GET /plugins/changelog/:plugin-name' , async ( ) => {
292388 const res = await app . inject ( {
293389 method : 'GET' ,
0 commit comments