test(commands): trim dashboard setup resets and dedupe bind cases

This commit is contained in:
Peter Steinberger
2026-02-22 00:28:12 +00:00
parent 076c5ebaef
commit 2fd57cec0b
2 changed files with 19 additions and 29 deletions

View File

@@ -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 () => {

View File

@@ -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 });