Update: harden control UI asset handling in update flow (#10146)

* Update: harden control UI asset handling in update flow

* fix: harden update doctor entrypoint guard (#10146) (thanks @gumadeiras)
This commit is contained in:
Gustavo Madeira Santana
2026-02-06 01:14:00 -05:00
committed by GitHub
parent 50e687d17d
commit c75275f109
9 changed files with 424 additions and 15 deletions

View File

@@ -3,7 +3,9 @@ import os from "node:os";
import path from "node:path";
import { describe, expect, it } from "vitest";
import {
resolveControlUiDistIndexHealth,
resolveControlUiDistIndexPath,
resolveControlUiDistIndexPathForRoot,
resolveControlUiRepoRoot,
resolveControlUiRootOverrideSync,
resolveControlUiRootSync,
@@ -190,4 +192,33 @@ describe("control UI assets helpers", () => {
await fs.rm(tmp, { recursive: true, force: true });
}
});
it("reports health for existing control-ui assets at a known root", async () => {
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-ui-"));
try {
const indexPath = resolveControlUiDistIndexPathForRoot(tmp);
await fs.mkdir(path.dirname(indexPath), { recursive: true });
await fs.writeFile(indexPath, "<html></html>\n");
await expect(resolveControlUiDistIndexHealth({ root: tmp })).resolves.toEqual({
indexPath,
exists: true,
});
} finally {
await fs.rm(tmp, { recursive: true, force: true });
}
});
it("reports health for missing control-ui assets at a known root", async () => {
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-ui-"));
try {
const indexPath = resolveControlUiDistIndexPathForRoot(tmp);
await expect(resolveControlUiDistIndexHealth({ root: tmp })).resolves.toEqual({
indexPath,
exists: false,
});
} finally {
await fs.rm(tmp, { recursive: true, force: true });
}
});
});