mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
refactor(ui): reuse Control UI bootstrap path constant
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* @vitest-environment jsdom */
|
||||
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { CONTROL_UI_BOOTSTRAP_CONFIG_PATH } from "../../../../src/gateway/control-ui-contract.js";
|
||||
import { loadControlUiBootstrapConfig } from "./control-ui-bootstrap.ts";
|
||||
|
||||
describe("loadControlUiBootstrapConfig", () => {
|
||||
@@ -26,7 +27,7 @@ describe("loadControlUiBootstrapConfig", () => {
|
||||
await loadControlUiBootstrapConfig(state);
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
"/openclaw/__openclaw/control-ui-config.json",
|
||||
`/openclaw${CONTROL_UI_BOOTSTRAP_CONFIG_PATH}`,
|
||||
expect.objectContaining({ method: "GET" }),
|
||||
);
|
||||
expect(state.assistantName).toBe("Ops");
|
||||
@@ -50,7 +51,7 @@ describe("loadControlUiBootstrapConfig", () => {
|
||||
await loadControlUiBootstrapConfig(state);
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
"/__openclaw/control-ui-config.json",
|
||||
CONTROL_UI_BOOTSTRAP_CONFIG_PATH,
|
||||
expect.objectContaining({ method: "GET" }),
|
||||
);
|
||||
expect(state.assistantName).toBe("Assistant");
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import {
|
||||
CONTROL_UI_BOOTSTRAP_CONFIG_PATH,
|
||||
type ControlUiBootstrapConfig,
|
||||
} from "../../../../src/gateway/control-ui-contract.js";
|
||||
import { normalizeAssistantIdentity } from "../assistant-identity.ts";
|
||||
import { normalizeBasePath } from "../navigation.ts";
|
||||
|
||||
type ControlUiBootstrapConfig = {
|
||||
basePath?: string;
|
||||
assistantName?: string;
|
||||
assistantAvatar?: string;
|
||||
assistantAgentId?: string;
|
||||
};
|
||||
|
||||
export type ControlUiBootstrapState = {
|
||||
basePath: string;
|
||||
assistantName: string;
|
||||
@@ -25,8 +22,8 @@ export async function loadControlUiBootstrapConfig(state: ControlUiBootstrapStat
|
||||
|
||||
const basePath = normalizeBasePath(state.basePath ?? "");
|
||||
const url = basePath
|
||||
? `${basePath}/__openclaw/control-ui-config.json`
|
||||
: "/__openclaw/control-ui-config.json";
|
||||
? `${basePath}${CONTROL_UI_BOOTSTRAP_CONFIG_PATH}`
|
||||
: CONTROL_UI_BOOTSTRAP_CONFIG_PATH;
|
||||
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
|
||||
Reference in New Issue
Block a user