- Compress responses: page scripts and styles once (brotli or gzip, in memory) and cached immutable; pages and API JSON gzipped as they stream - Service worker serves content-named assets cache-first - Load the models modal's data when it opens (cached in localStorage) instead of shipping the model catalog in every conversation page - Lazy-load the Tiptap composer and memoize thread messages - Import lucide icons directly; twui 0.1.4 drops by-name icons from Button - bun run start builds the pages minified before serving Co-Authored-By: Claude Opus 5.5 <[email protected]>
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import pickContentEncoding from "./pick-content-encoding";
|
|
|
|
describe("pickContentEncoding", () => {
|
|
test("prefers brotli", () => {
|
|
expect(pickContentEncoding({ accept_encoding: "gzip, deflate, br, zstd" })).toBe("br");
|
|
});
|
|
|
|
test("falls back to gzip", () => {
|
|
expect(pickContentEncoding({ accept_encoding: "gzip, deflate" })).toBe("gzip");
|
|
expect(pickContentEncoding({ accept_encoding: "*", offer: ["gzip"] })).toBe("gzip");
|
|
});
|
|
|
|
test("only offers what the caller can produce", () => {
|
|
expect(pickContentEncoding({ accept_encoding: "br, gzip", offer: ["gzip"] })).toBe("gzip");
|
|
expect(pickContentEncoding({ accept_encoding: "br", offer: ["gzip"] })).toBe(null);
|
|
});
|
|
|
|
test("is none without a supported coding", () => {
|
|
expect(pickContentEncoding({ accept_encoding: "identity" })).toBe(null);
|
|
expect(pickContentEncoding({ accept_encoding: "" })).toBe(null);
|
|
expect(pickContentEncoding({ accept_encoding: null })).toBe(null);
|
|
});
|
|
|
|
test("skips refused codings", () => {
|
|
expect(pickContentEncoding({ accept_encoding: "br;q=0, gzip;q=0.8" })).toBe("gzip");
|
|
expect(pickContentEncoding({ accept_encoding: "br;q=0.0, gzip;q=0" })).toBe(null);
|
|
});
|
|
});
|