diff --git a/src/shared/chat-message-content.test.ts b/src/shared/chat-message-content.test.ts index 50e41f82642..7c35516f903 100644 --- a/src/shared/chat-message-content.test.ts +++ b/src/shared/chat-message-content.test.ts @@ -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(); diff --git a/src/shared/net/ip.test.ts b/src/shared/net/ip.test.ts index 8ff070383ae..2322a106c9d 100644 --- a/src/shared/net/ip.test.ts +++ b/src/shared/net/ip.test.ts @@ -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); diff --git a/src/shared/text/join-segments.test.ts b/src/shared/text/join-segments.test.ts index 8da5c4644a7..67fdacb14dd 100644 --- a/src/shared/text/join-segments.test.ts +++ b/src/shared/text/join-segments.test.ts @@ -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 "); + }); });