@@ -23,6 +23,103 @@ function migrateLegacyConfig(raw: unknown): {
2323}
2424
2525describe ( "legacy migrate provider-shaped config" , ( ) => {
26+ const legacyTts = {
27+ provider : "edge" ,
28+ enabled : true ,
29+ providers : { custom : { voice : "legacy" } } ,
30+ } ;
31+ const voiceAndEnabledMigrations = [ "tts.speaker-selection-keys" , "tts.enabled-auto-mode" ] ;
32+
33+ it . each < { name : string ; path : string ; value : unknown ; expected : string [ ] } > ( [
34+ {
35+ name : "root TTS" ,
36+ path : "tts" ,
37+ value : legacyTts ,
38+ expected : [ "tts.providers-generic-shape" , ...voiceAndEnabledMigrations ] ,
39+ } ,
40+ {
41+ name : "legacy agent list" ,
42+ path : "agents" ,
43+ value : { list : [ { tts : legacyTts } ] } ,
44+ expected : voiceAndEnabledMigrations ,
45+ } ,
46+ {
47+ name : "agent defaults and keyed entries" ,
48+ path : "agents" ,
49+ value : { defaults : { tts : legacyTts } , entries : { main : { tts : legacyTts } } } ,
50+ expected : [ ] ,
51+ } ,
52+ {
53+ name : "channel root" ,
54+ path : "channels" ,
55+ value : { slack : { tts : legacyTts } } ,
56+ expected : voiceAndEnabledMigrations ,
57+ } ,
58+ {
59+ name : "channel accounts" ,
60+ path : "channels" ,
61+ value : { slack : { accounts : { work : { tts : legacyTts } } } } ,
62+ expected : voiceAndEnabledMigrations ,
63+ } ,
64+ {
65+ name : "Discord root and account roots" ,
66+ path : "channels" ,
67+ value : { " Discord " : { tts : legacyTts , accounts : { work : { tts : legacyTts } } } } ,
68+ expected : [ ] ,
69+ } ,
70+ {
71+ name : "Discord voice" ,
72+ path : "channels" ,
73+ value : { discord : { voice : { tts : legacyTts } } } ,
74+ expected : voiceAndEnabledMigrations ,
75+ } ,
76+ {
77+ name : "Discord account voice" ,
78+ path : "channels" ,
79+ value : {
80+ discord : {
81+ accounts : { work : { voice : { tts : legacyTts } } } ,
82+ } ,
83+ } ,
84+ expected : voiceAndEnabledMigrations ,
85+ } ,
86+ {
87+ name : "blocked channel and account keys" ,
88+ path : "channels" ,
89+ value : {
90+ constructor : { tts : legacyTts } ,
91+ slack : { accounts : { prototype : { tts : legacyTts } } } ,
92+ } ,
93+ expected : [ ] ,
94+ } ,
95+ {
96+ name : "voice-call plugin" ,
97+ path : "plugins.entries" ,
98+ value : { "voice-call" : { config : { tts : legacyTts } } } ,
99+ expected : [ "tts.providers-generic-shape" , ...voiceAndEnabledMigrations ] ,
100+ } ,
101+ {
102+ name : "other plugins" ,
103+ path : "plugins.entries" ,
104+ value : { custom : { config : { tts : legacyTts } } } ,
105+ expected : [ ] ,
106+ } ,
107+ {
108+ name : "malformed scopes" ,
109+ path : "channels" ,
110+ value : { slack : { tts : [ ] , voice : false , accounts : { work : null } } , discord : 1 } ,
111+ expected : [ ] ,
112+ } ,
113+ ] ) ( "previews only supported migrations for $name" , ( { path, value, expected } ) => {
114+ const detected = LEGACY_CONFIG_MIGRATIONS_RUNTIME_TTS . filter ( ( migration ) =>
115+ migration . legacyRules ?. some (
116+ ( rule ) => rule . path . join ( "." ) === path && rule . match ?.( value , { } ) ,
117+ ) ,
118+ ) . map ( ( migration ) => migration . id ) ;
119+
120+ expect ( detected ) . toEqual ( expected ) ;
121+ } ) ;
122+
26123 it ( "moves legacy realtime Talk selectors into talk.realtime without treating speech config as runtime fallback" , ( ) => {
27124 const changes : string [ ] = [ ] ;
28125 const migrated = normalizeLegacyTalkConfig (
@@ -189,6 +286,7 @@ describe("legacy migrate provider-shaped config", () => {
189286 } ,
190287 } ,
191288 } ) ;
289+ expect ( migrateLegacyConfig ( res . config ) ) . toEqual ( { config : null , changes : [ ] } ) ;
192290 } ) ;
193291
194292 it ( "routes legacy messages.tts.realtime voice to talk.realtime.speakerVoice" , ( ) => {
0 commit comments