mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
7fe004d852
* feat: show build identity in About screens * chore: leave root changelog to release automation * fix: translate Control UI About build details
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
// Control UI tests cover public assets behavior.
|
|
import { describe, expect, it } from "vitest";
|
|
import { controlUiPublicAssetPath, inferControlUiPublicAssetPath } from "./public-assets.ts";
|
|
|
|
describe("controlUiPublicAssetPath", () => {
|
|
it("resolves root-mounted public assets from the URL root", () => {
|
|
expect(controlUiPublicAssetPath("favicon.svg", "")).toBe("/favicon.svg");
|
|
expect(controlUiPublicAssetPath("manifest.webmanifest", null)).toBe("/manifest.webmanifest");
|
|
});
|
|
|
|
it("resolves base-mounted public assets under the configured base path", () => {
|
|
expect(controlUiPublicAssetPath("favicon.svg", "/ui")).toBe("/ui/favicon.svg");
|
|
expect(controlUiPublicAssetPath("sw.js", "/apps/openclaw/")).toBe("/apps/openclaw/sw.js");
|
|
});
|
|
});
|
|
|
|
describe("inferControlUiPublicAssetPath", () => {
|
|
it("uses the root for known nested routes without a configured base path", () => {
|
|
expect(
|
|
inferControlUiPublicAssetPath("manifest.webmanifest", { pathname: "/skills/workshop" }),
|
|
).toBe("/manifest.webmanifest");
|
|
});
|
|
|
|
it("infers base-mounted assets from nested routes", () => {
|
|
expect(inferControlUiPublicAssetPath("sw.js", { pathname: "/openclaw/skills/workshop" })).toBe(
|
|
"/openclaw/sw.js",
|
|
);
|
|
});
|
|
|
|
it("keeps an about mount root distinct from the settings About route", () => {
|
|
expect(inferControlUiPublicAssetPath("sw.js", { pathname: "/about/" })).toBe("/about/sw.js");
|
|
});
|
|
|
|
it("prefers an explicit base path over pathname inference", () => {
|
|
expect(
|
|
inferControlUiPublicAssetPath("apple-touch-icon.png", {
|
|
basePath: "/control/",
|
|
pathname: "/skills/workshop",
|
|
}),
|
|
).toBe("/control/apple-touch-icon.png");
|
|
});
|
|
});
|