Files
OmniRoute/tests/unit/web-session-provider-link-6316.test.ts
Diego Rodrigues de Sa e Souza 92715c8f2c Release v3.8.46
Release v3.8.46. Full changelog: CHANGELOG.md → [3.8.46]. Contributor attribution in the CHANGELOG entries.
2026-07-07 13:14:06 -03:00

26 lines
1.1 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
// #6316: the web-session credential guide shows an "Open {host}" link to the
// provider site. The host is derived from the provider's website URL via
// getProviderWebsiteHost — a full URL collapses to its host, a bare/invalid
// string falls back to itself, and an empty value yields null (no link).
const { getProviderWebsiteHost } = await import(
"../../src/app/(dashboard)/dashboard/providers/[id]/components/WebSessionCredentialGuide.tsx"
);
test("#6316: full URL collapses to host", () => {
assert.equal(getProviderWebsiteHost("https://chat.qwen.ai/path?x=1"), "chat.qwen.ai");
assert.equal(getProviderWebsiteHost("https://www.kimi.com"), "www.kimi.com");
});
test("#6316: bare/invalid string falls back to itself", () => {
assert.equal(getProviderWebsiteHost("kimi.com"), "kimi.com");
assert.equal(getProviderWebsiteHost("not a url"), "not a url");
});
test("#6316: empty/undefined yields null (no link rendered)", () => {
assert.equal(getProviderWebsiteHost(undefined), null);
assert.equal(getProviderWebsiteHost(""), null);
});