mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 22:07:26 +00:00
test(commands): trim dashboard setup resets and dedupe bind cases
This commit is contained in:
@@ -58,13 +58,13 @@ function mockSnapshot(token = "abc") {
|
||||
describe("dashboardCommand", () => {
|
||||
beforeEach(() => {
|
||||
resetRuntime();
|
||||
readConfigFileSnapshotMock.mockReset();
|
||||
resolveGatewayPortMock.mockReset();
|
||||
resolveControlUiLinksMock.mockReset();
|
||||
detectBrowserOpenSupportMock.mockReset();
|
||||
openUrlMock.mockReset();
|
||||
formatControlUiSshHintMock.mockReset();
|
||||
copyToClipboardMock.mockReset();
|
||||
readConfigFileSnapshotMock.mockClear();
|
||||
resolveGatewayPortMock.mockClear();
|
||||
resolveControlUiLinksMock.mockClear();
|
||||
detectBrowserOpenSupportMock.mockClear();
|
||||
openUrlMock.mockClear();
|
||||
formatControlUiSshHintMock.mockClear();
|
||||
copyToClipboardMock.mockClear();
|
||||
});
|
||||
|
||||
it("opens and copies the dashboard link by default", async () => {
|
||||
|
||||
@@ -63,30 +63,20 @@ function mockSnapshot(params?: {
|
||||
|
||||
describe("dashboardCommand bind selection", () => {
|
||||
beforeEach(() => {
|
||||
mocks.readConfigFileSnapshot.mockReset();
|
||||
mocks.resolveGatewayPort.mockReset();
|
||||
mocks.resolveControlUiLinks.mockReset();
|
||||
mocks.copyToClipboard.mockReset();
|
||||
runtime.log.mockReset();
|
||||
runtime.error.mockReset();
|
||||
runtime.exit.mockReset();
|
||||
mocks.readConfigFileSnapshot.mockClear();
|
||||
mocks.resolveGatewayPort.mockClear();
|
||||
mocks.resolveControlUiLinks.mockClear();
|
||||
mocks.copyToClipboard.mockClear();
|
||||
runtime.log.mockClear();
|
||||
runtime.error.mockClear();
|
||||
runtime.exit.mockClear();
|
||||
});
|
||||
|
||||
it("maps lan bind to loopback for dashboard URLs", async () => {
|
||||
mockSnapshot({ bind: "lan" });
|
||||
|
||||
await dashboardCommand(runtime, { noOpen: true });
|
||||
|
||||
expect(mocks.resolveControlUiLinks).toHaveBeenCalledWith({
|
||||
port: 18789,
|
||||
bind: "loopback",
|
||||
customBindHost: undefined,
|
||||
basePath: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("defaults to loopback when bind is unset", async () => {
|
||||
mockSnapshot();
|
||||
it.each([
|
||||
{ label: "maps lan bind to loopback", snapshot: { bind: "lan" as const } },
|
||||
{ label: "defaults unset bind to loopback", snapshot: undefined },
|
||||
])("$label for dashboard URLs", async ({ snapshot }) => {
|
||||
mockSnapshot(snapshot);
|
||||
|
||||
await dashboardCommand(runtime, { noOpen: true });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user