Skip to content

Commit eea9ef7

Browse files
committed
fix(ui): keep server-only locale config out of browser test helpers
1 parent 7f691b9 commit eea9ef7

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

‎ui/config/control-ui-locales.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import { en } from "../src/i18n/locales/en.ts";
1111

1212
const localeModulePrefix = "virtual:openclaw-control-ui-locale/";
1313
const resolvedLocaleModulePrefix = `\0${localeModulePrefix}`;
14-
const i18nAssetsDir = fileURLToPath(new URL("../src/i18n/.i18n/", import.meta.url));
14+
// Vitest rewrites new URL(relative, import.meta.url) to browser self.location.
15+
const i18nAssetsDir = path.resolve(
16+
path.dirname(fileURLToPath(import.meta.url)),
17+
"../src/i18n/.i18n",
18+
);
1519
const locales = new Set(CONTROL_UI_LOCALE_ENTRIES.map(({ locale }) => locale));
1620

1721
export function controlUiLocaleModulesPlugin(): Plugin {

‎ui/src/test-helpers/control-ui-e2e.ts‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ import type { Locator, Page } from "playwright";
1010
import type { ViteDevServer } from "vite";
1111
import { PROTOCOL_VERSION } from "../../../packages/gateway-protocol/src/version.js";
1212
import { CONTROL_UI_BOOTSTRAP_CONFIG_PATH } from "../../../src/gateway/control-ui-contract.js";
13-
import { controlUiLocaleModulesPlugin } from "../../config/control-ui-locales.ts";
14-
import {
15-
controlUiBrowserOnlySharedModuleAliases,
16-
resolveExternalPackageAliasesForVite,
17-
resolveSourcePackageAliasesForVite,
18-
resolveTsconfigPathAliasesForVite,
19-
} from "../../vite.config.ts";
2013
import type { ControlUiBuildInfo } from "../build-info.ts";
2114

2215
export function controlUiSessionPath(sessionKey: string, basePath = ""): string {
@@ -313,7 +306,22 @@ export async function startControlUiE2eServer(
313306
buildId: "e2e",
314307
},
315308
): Promise<ControlUiE2eServer> {
316-
const { createServer } = await import("vite");
309+
// Shared browser fixtures import this helper; load filesystem-bound Vite
310+
// configuration only when its Node-owned development server actually starts.
311+
const [
312+
{ createServer },
313+
{ controlUiLocaleModulesPlugin },
314+
{
315+
controlUiBrowserOnlySharedModuleAliases,
316+
resolveExternalPackageAliasesForVite,
317+
resolveSourcePackageAliasesForVite,
318+
resolveTsconfigPathAliasesForVite,
319+
},
320+
] = await Promise.all([
321+
import("vite"),
322+
import("../../config/control-ui-locales.ts"),
323+
import("../../vite.config.ts"),
324+
]);
317325
const repoRoot = resolveRepoRoot();
318326
const uiRoot = path.join(repoRoot, "ui");
319327
const port = await resolveAvailableLoopbackPort();

0 commit comments

Comments
 (0)