Skip to content

Commit 31d9d5a

Browse files
committed
test(tui): enforce bridge frozen-row invariants
1 parent 5d34aaf commit 31d9d5a

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

‎src/tui/markdown-rows.test.ts‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ describe("markdown transcript rows", () => {
414414
text: `${frozen}\n\nx`,
415415
});
416416
await h.renderOnce();
417-
const { frozenNode } = splitMarkdownNodes(shell);
417+
const { frozenNode, liveNode } = splitMarkdownNodes(shell);
418418
const descriptor = defined(
419419
Object.getOwnPropertyDescriptor(
420420
MarkdownRenderable.prototype,
@@ -435,11 +435,16 @@ describe("markdown transcript rows", () => {
435435
for (let i = 0; i < size; i += 1) {
436436
bridge.handle({ type: "assistant.delta", text: "x" });
437437
await h.renderOnce();
438-
expect(splitMarkdownNodes(shell).frozenNode).toBe(frozenNode);
438+
const current = splitMarkdownNodes(shell);
439+
expect(current.frozenNode).toBe(frozenNode);
440+
expect(current.liveNode).toBe(liveNode);
441+
expect(current.liveNode.streaming).toBe(true);
439442
}
440-
expect(splitMarkdownNodes(shell).liveNode.content).toBe(
441-
"x".repeat(size + 1),
442-
);
443+
const current = splitMarkdownNodes(shell);
444+
expect(current.frozenNode).toBe(frozenNode);
445+
expect(current.liveNode).toBe(liveNode);
446+
expect(current.liveNode.content).toBe("x".repeat(size + 1));
447+
expect(current.liveNode.streaming).toBe(true);
443448
} finally {
444449
Reflect.deleteProperty(frozenNode, "content");
445450
}
@@ -452,12 +457,8 @@ describe("markdown transcript rows", () => {
452457

453458
const n = await measure(20);
454459
const twoN = await measure(40);
455-
const ratio = (twoN.chars + 1) / (n.chars + 1);
456-
const headingTransitions = 0;
457-
const maxAssignments = headingTransitions + 1;
458-
expect(ratio).toBeLessThan(3);
459-
expect(n.assignments).toBeLessThanOrEqual(maxAssignments);
460-
expect(twoN.assignments).toBeLessThanOrEqual(maxAssignments);
460+
expect(n).toEqual({ assignments: 0, chars: 0 });
461+
expect(twoN).toEqual({ assignments: 0, chars: 0 });
461462
}, WIDE);
462463
});
463464

0 commit comments

Comments
 (0)