@@ -198,7 +198,7 @@ describe("control UI routing", () => {
198198 expect ( window . location . hash ) . toBe ( "" ) ;
199199 } ) ;
200200
201- it ( "clears the current token when the gateway URL changes" , async ( ) => {
201+ it ( "keeps the current token when the gateway URL changes" , async ( ) => {
202202 const app = mountApp ( "/ui/overview#token=abc123" ) ;
203203 await app . updateComplete ;
204204
@@ -211,7 +211,35 @@ describe("control UI routing", () => {
211211 await app . updateComplete ;
212212
213213 expect ( app . settings . gatewayUrl ) . toBe ( "wss://other-gateway.example/openclaw" ) ;
214- expect ( app . settings . token ) . toBe ( "" ) ;
214+ expect ( app . settings . token ) . toBe ( "abc123" ) ;
215+ } ) ;
216+
217+ it ( "preserves a typed token while editing the gateway URL from overview" , async ( ) => {
218+ const app = mountApp ( "/ui/overview" ) ;
219+ await app . updateComplete ;
220+
221+ const tokenInput = app . querySelector < HTMLInputElement > (
222+ 'input[placeholder="OPENCLAW_GATEWAY_TOKEN"]' ,
223+ ) ;
224+ expect ( tokenInput ) . not . toBeNull ( ) ;
225+ tokenInput ! . value = "typed-token" ;
226+ tokenInput ! . dispatchEvent ( new Event ( "input" , { bubbles : true } ) ) ;
227+ await app . updateComplete ;
228+
229+ const gatewayUrlInput = app . querySelector < HTMLInputElement > (
230+ 'input[placeholder="ws://100.x.y.z:18789"]' ,
231+ ) ;
232+ expect ( gatewayUrlInput ) . not . toBeNull ( ) ;
233+ gatewayUrlInput ! . value = "wss://other-gateway.example/openclaw" ;
234+ gatewayUrlInput ! . dispatchEvent ( new Event ( "input" , { bubbles : true } ) ) ;
235+ await app . updateComplete ;
236+
237+ const nextTokenInput = app . querySelector < HTMLInputElement > (
238+ 'input[placeholder="OPENCLAW_GATEWAY_TOKEN"]' ,
239+ ) ;
240+ expect ( app . settings . gatewayUrl ) . toBe ( "wss://other-gateway.example/openclaw" ) ;
241+ expect ( app . settings . token ) . toBe ( "typed-token" ) ;
242+ expect ( nextTokenInput ?. value ) . toBe ( "typed-token" ) ;
215243 } ) ;
216244
217245 it ( "keeps a hash token pending until the gateway URL change is confirmed" , async ( ) => {
0 commit comments