Merge branch 'main' into ui/dashboard-v2.1

This commit is contained in:
Val Alexander
2026-03-13 16:46:37 -05:00
committed by GitHub
3 changed files with 28 additions and 0 deletions

View File

@@ -18,6 +18,19 @@ describe("shared/chat-message-content", () => {
).toBe("");
});
it("only considers the first content block even if later blocks have text", () => {
expect(
extractFirstTextBlock({
content: [null, { text: "later" }],
}),
).toBeUndefined();
expect(
extractFirstTextBlock({
content: [{ type: "image" }, { text: "later" }],
}),
).toBeUndefined();
});
it("returns undefined for missing, empty, or non-text content", () => {
expect(extractFirstTextBlock(null)).toBeUndefined();
expect(extractFirstTextBlock({ content: [] })).toBeUndefined();

View File

@@ -14,6 +14,7 @@ import {
isRfc1918Ipv4Address,
normalizeIpAddress,
parseCanonicalIpAddress,
parseLooseIpAddress,
} from "./ip.js";
describe("shared ip helpers", () => {
@@ -30,6 +31,8 @@ describe("shared ip helpers", () => {
expect(isIpInCidr("10.43.0.59", "10.42.0.0/24")).toBe(false);
expect(isIpInCidr("2001:db8::1234", "2001:db8::/32")).toBe(true);
expect(isIpInCidr("2001:db9::1234", "2001:db8::/32")).toBe(false);
expect(isIpInCidr("::ffff:127.0.0.1", "127.0.0.1")).toBe(true);
expect(isIpInCidr("127.0.0.1", "::ffff:127.0.0.2")).toBe(false);
});
it("extracts embedded IPv4 for transition prefixes", () => {
@@ -67,6 +70,12 @@ describe("shared ip helpers", () => {
expect(isLoopbackIpAddress("198.18.0.1")).toBe(false);
});
it("parses loose legacy IPv4 literals that canonical parsing rejects", () => {
expect(parseCanonicalIpAddress("0177.0.0.1")).toBeUndefined();
expect(parseLooseIpAddress("0177.0.0.1")?.toString()).toBe("127.0.0.1");
expect(parseLooseIpAddress("[::1]")?.toString()).toBe("::1");
});
it("classifies RFC1918 and carrier-grade-nat IPv4 ranges", () => {
expect(isRfc1918Ipv4Address("10.42.0.59")).toBe(true);
expect(isRfc1918Ipv4Address("100.64.0.1")).toBe(false);

View File

@@ -13,6 +13,8 @@ describe("concatOptionalTextSegments", () => {
it("falls back to whichever side is present and honors custom separators", () => {
expect(concatOptionalTextSegments({ left: "A" })).toBe("A");
expect(concatOptionalTextSegments({ right: "B" })).toBe("B");
expect(concatOptionalTextSegments({ left: "", right: "B" })).toBe("B");
expect(concatOptionalTextSegments({ left: "" })).toBe("");
expect(concatOptionalTextSegments({ left: "A", right: "B", separator: " | " })).toBe("A | B");
});
});
@@ -36,4 +38,8 @@ describe("joinPresentTextSegments", () => {
"A | B",
);
});
it("preserves segment whitespace when trim is disabled", () => {
expect(joinPresentTextSegments(["A", " B "], { separator: "|" })).toBe("A| B ");
});
});