Files
OmniRoute/tests/unit/provider-onboarding-href.test.ts
KooshaPari 0e0ca7e26b fix(dashboard): use connection.id (UUID) not connection.provider (category) in onboarding wizard href (issue #6144) (#6166)
refactor(dashboard): extract tested buildProviderDetailsHref helper for onboarding wizard (#6166). Behavioral #6144 fix already on tip via #6145; this lands the tested-helper hardening. Thanks @KooshaPari. Integrated into release/v3.8.45.
2026-07-05 05:37:42 -03:00

37 lines
1.6 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { buildProviderDetailsHref } from "../../src/app/(dashboard)/dashboard/providers/components/onboarding/providerOnboardingHref";
test("buildProviderDetailsHref uses the server-assigned connection UUID", () => {
const href = buildProviderDetailsHref({
id: "9f3c1a4d-1c2b-4a3c-8def-0123456789ab",
});
assert.equal(
href,
"/dashboard/providers/9f3c1a4d-1c2b-4a3c-8def-0123456789ab"
);
});
test("buildProviderDetailsHref does not leak the provider category into the URL", () => {
// Regression for issue #6144: previously the wizard used
// `connection.provider` ("openai-compatible") as the URL slug, which 404'd
// on /dashboard/providers/[id] because that route is keyed by UUID.
const href = buildProviderDetailsHref({
id: "9f3c1a4d-1c2b-4a3c-8def-0123456789ab",
provider: "openai-compatible",
});
assert.notEqual(href, "/dashboard/providers/openai-compatible");
assert.match(href ?? "", /\/dashboard\/providers\/[0-9a-f-]+$/);
});
test("buildProviderDetailsHref returns null when no id is available", () => {
assert.equal(buildProviderDetailsHref(null), null);
assert.equal(buildProviderDetailsHref(undefined), null);
assert.equal(buildProviderDetailsHref({ id: "" }), null);
assert.equal(buildProviderDetailsHref({ id: " " }), null);
});
test("buildProviderDetailsHref percent-encodes unusual ids", () => {
const href = buildProviderDetailsHref({ id: "abc/123 def" });
assert.equal(href, "/dashboard/providers/abc%2F123%20def");
});