@@ -6,6 +6,8 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest";
66import { importCustomThemeFromUrl } from "../app/custom-theme.ts" ;
77import {
88 canRunPlaywrightChromium ,
9+ controlUiBundledGatewayUrl ,
10+ controlUiBundledSettingsStorageKey ,
911 installMockGateway ,
1012 resolvePlaywrightChromiumExecutablePath ,
1113 startControlUiE2eServer ,
@@ -27,11 +29,13 @@ const uiProofArtifactDir = path.join(
2729 "control-ui-e2e" ,
2830 "appearance-settings-defaults" ,
2931) ;
30- const settingsStorageKey = "openclaw.control.settings.v1:ws://127.0.0.1:18789" ;
31-
3232let browser : Browser ;
3333let server : ControlUiE2eServer ;
3434
35+ function settingsStorageKey ( ) : string {
36+ return controlUiBundledSettingsStorageKey ( server . baseUrl ) ;
37+ }
38+
3539function configResponse ( prefs : Record < string , unknown > , hash : string ) {
3640 const config = { ui : { prefs } } ;
3741 return {
@@ -110,7 +114,7 @@ async function readPersistedSettings(page: Page): Promise<Record<string, unknown
110114 return page . evaluate ( ( key ) => {
111115 const raw = localStorage . getItem ( key ) ;
112116 return raw ? ( JSON . parse ( raw ) as Record < string , unknown > ) : { } ;
113- } , settingsStorageKey ) ;
117+ } , settingsStorageKey ( ) ) ;
114118}
115119
116120async function readThemeImportRaceState ( page : Page ) {
@@ -169,20 +173,23 @@ describeControlUiE2e("Control UI Appearance defaults mocked Gateway E2E", () =>
169173 serviceWorkers : "block" ,
170174 viewport : { height : 1000 , width : 1440 } ,
171175 } ) ;
172- await context . addInitScript ( ( key ) => {
173- const seedKey = "openclaw.control-ui-e2e.appearance-defaults-seeded" ;
174- if ( sessionStorage . getItem ( seedKey ) === "1" ) {
175- return ;
176- }
177- sessionStorage . setItem ( seedKey , "1" ) ;
178- localStorage . setItem (
179- key ,
180- JSON . stringify ( {
181- gatewayUrl : "ws://127.0.0.1:18789" ,
182- textScale : 110 ,
183- } ) ,
184- ) ;
185- } , settingsStorageKey ) ;
176+ await context . addInitScript (
177+ ( { gatewayUrl, key } ) => {
178+ const seedKey = "openclaw.control-ui-e2e.appearance-defaults-seeded" ;
179+ if ( sessionStorage . getItem ( seedKey ) === "1" ) {
180+ return ;
181+ }
182+ sessionStorage . setItem ( seedKey , "1" ) ;
183+ localStorage . setItem (
184+ key ,
185+ JSON . stringify ( {
186+ gatewayUrl,
187+ textScale : 110 ,
188+ } ) ,
189+ ) ;
190+ } ,
191+ { gatewayUrl : controlUiBundledGatewayUrl ( server . baseUrl ) , key : settingsStorageKey ( ) } ,
192+ ) ;
186193 const page = await context . newPage ( ) ;
187194 const initialPrefs : Record < string , unknown > = {
188195 chatSendShortcut : "modifier-enter" ,
@@ -501,17 +508,21 @@ describeControlUiE2e("Control UI Appearance defaults mocked Gateway E2E", () =>
501508 viewport : { height : 1000 , width : 1440 } ,
502509 } ) ;
503510 await context . addInitScript (
504- ( { key, theme } ) => {
511+ ( { gatewayUrl , key, theme } ) => {
505512 localStorage . setItem (
506513 key ,
507514 JSON . stringify ( {
508515 customTheme : theme ,
509- gatewayUrl : "ws://127.0.0.1:18789" ,
516+ gatewayUrl,
510517 theme : "custom" ,
511518 } ) ,
512519 ) ;
513520 } ,
514- { key : settingsStorageKey , theme : existingTheme } ,
521+ {
522+ gatewayUrl : controlUiBundledGatewayUrl ( server . baseUrl ) ,
523+ key : settingsStorageKey ( ) ,
524+ theme : existingTheme ,
525+ } ,
515526 ) ;
516527 const page = await context . newPage ( ) ;
517528 const gateway = await installMockGateway ( page , {
0 commit comments