Files
DeepTutor/web/tests/reading-split.test.ts
Bingxi Zhao (Frank) 7c6bcfaef7 release: v1.5.14
Immersive Reading, self-configuration, and a two-way IMA library.

- Immersive Reading: a new capability that opens a document beside the
  thread. New reading engine (PDF pages / slides / page-sized sections),
  five reading tools, a deterministic locate pre-pass that grounds the
  turn without a second LLM call, /api/v1/reading, and a reader pane with
  selection, highlights, notes, and export to an annotated PDF or Markdown.
- Setup capability: inspect the install, apply a setting, install a
  parsing engine, or request a credential from a chat turn. New settings
  spec table; a candidate value is probed before it is committed, and API
  keys never enter the model's context.
- Tencent IMA: pipeline split into transport/envelope/models/sources/
  notes/media/inventory, an additive capability with five tools, and
  connected libraries that can finally be enumerated (bounded listings
  are reported as a lower bound).
- Retrieval: supports_rag_retrieval() replaces is_connected_kb() for the
  "can I sweep this?" question, so linked / lightrag_server / ima sources
  stop being silently dropped from every book.
- Notebooks: their own console at /notebook, per-notebook locks and atomic
  writes, copy / move / export routes, damaged files surfaced instead of
  dropped, and renaming a record no longer clears its knowledge-base link.
- Settings persistence: one lock and one atomic replace shared by every
  writer of interface.json; the PUT endpoints stop writing the
  defaults-merged view back to disk.

Release notes: assets/releases/ver1-5-14.md
2026-08-19 17:34:52 +08:00

67 lines
2.4 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import {
CHAT_MIN_PX,
READER_MAX_PX,
READER_MIN_PX,
clampReaderWidth,
parseStoredWidth,
} from "../lib/reading-split";
test("keeps a reasonable width untouched", () => {
assert.equal(clampReaderWidth(900, 1380), 900);
assert.equal(clampReaderWidth(600, 1380), 600);
});
test("never lets the reader get too narrow to read", () => {
assert.equal(clampReaderWidth(50, 1380), READER_MIN_PX);
assert.equal(clampReaderWidth(0, 1380), READER_MIN_PX);
assert.equal(clampReaderWidth(-400, 1380), READER_MIN_PX);
});
test("always leaves the conversation a usable column", () => {
const available = 1380;
const widest = clampReaderWidth(99999, available);
assert.equal(available - widest, CHAT_MIN_PX);
});
test("respects the absolute ceiling on a very wide display", () => {
// 4000 - 380 = 3620, but no reader needs to be wider than READER_MAX_PX.
assert.equal(clampReaderWidth(99999, 4000), READER_MAX_PX);
});
test("on a narrow container the reader floor wins over the chat floor", () => {
// 600 - 380 = 220, below the reader minimum. Overflowing slightly beats a
// 220px reader; below `lg` the split does not exist at all.
assert.equal(clampReaderWidth(500, 600), READER_MIN_PX);
});
test("an unknown container falls back to the absolute bounds", () => {
// Server render, or a measurement taken before layout. The CSS carries its
// own percentage ceiling for exactly this case.
assert.equal(clampReaderWidth(99999, 0), READER_MAX_PX);
assert.equal(clampReaderWidth(900, 0), 900);
assert.equal(clampReaderWidth(10, -1), READER_MIN_PX);
});
test("nonsense input degrades to the minimum rather than NaN", () => {
assert.equal(clampReaderWidth(Number.NaN, 1380), READER_MIN_PX);
assert.equal(clampReaderWidth(Number.POSITIVE_INFINITY, 1380), READER_MIN_PX);
});
test("always returns a whole pixel", () => {
assert.equal(clampReaderWidth(700.6, 1380), 701);
assert.ok(Number.isInteger(clampReaderWidth(612.4, 1380)));
});
test("parseStoredWidth accepts a stored number and rejects junk", () => {
assert.equal(parseStoredWidth("820"), 820);
assert.equal(parseStoredWidth("820.5"), 820.5);
assert.equal(parseStoredWidth(null), null);
assert.equal(parseStoredWidth(""), null);
assert.equal(parseStoredWidth("wide"), null);
assert.equal(parseStoredWidth("0"), null);
assert.equal(parseStoredWidth("-500"), null);
assert.equal(parseStoredWidth("Infinity"), null);
});