fix: local updates for PR #4873

Co-authored-by: Hisleren <Hisleren@users.noreply.github.com>
This commit is contained in:
Gustavo Madeira Santana
2026-01-30 16:11:10 -05:00
committed by Gustavo Madeira Santana
parent 201d7fa956
commit e5a95b5b66
6 changed files with 173 additions and 8 deletions

View File

@@ -1,6 +1,11 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { openUrl, resolveBrowserOpenCommand, resolveControlUiLinks } from "./onboard-helpers.js";
import {
normalizeGatewayTokenInput,
openUrl,
resolveBrowserOpenCommand,
resolveControlUiLinks,
} from "./onboard-helpers.js";
const mocks = vi.hoisted(() => ({
runCommandWithTimeout: vi.fn(async () => ({
@@ -103,3 +108,18 @@ describe("resolveControlUiLinks", () => {
expect(links.wsUrl).toBe("ws://127.0.0.1:18789");
});
});
describe("normalizeGatewayTokenInput", () => {
it("returns empty string for undefined or null", () => {
expect(normalizeGatewayTokenInput(undefined)).toBe("");
expect(normalizeGatewayTokenInput(null)).toBe("");
});
it("trims string input", () => {
expect(normalizeGatewayTokenInput(" token ")).toBe("token");
});
it("coerces non-string input to string", () => {
expect(normalizeGatewayTokenInput(123)).toBe("123");
});
});