test: port Ink layout tests (157 passing, 21 known failures)

Translates flex, direction, wrap, align, justify, gap, padding,
margin, width-height, position, display, and overflow tests from
Ink. Adds trimLines mode and trailing-newline strip to test helper.
Fixes Box type for alignContent (space-between/around/evenly) and
alignSelf (stretch/baseline).

21 tests fail due to behavioral differences (overflow clipping,
percentage dimensions, relative position offsets, align-content
space-* variants). These represent real gaps to investigate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yunfei He
2026-05-25 21:24:31 +08:00
parent ffb5d69b0b
commit 22ecbe0f80
17 changed files with 2070 additions and 6 deletions
+18 -4
View File
@@ -18,8 +18,13 @@ export interface Terminal {
rawMode: RawModeState;
}
export interface LastFrameOptions {
raw?: boolean;
trimLines?: boolean;
}
export interface RenderResult {
lastFrame(this: void, opts?: { raw?: boolean }): string | undefined;
lastFrame(this: void, opts?: LastFrameOptions): string | undefined;
frames: string[];
stdin: {
write(data: string): Promise<void>;
@@ -53,7 +58,10 @@ export async function render(
const frames: string[] = [];
stdout.on("data", (chunk) => {
frames.push(chunk.toString());
let raw = chunk.toString();
// Debug-mode frame writer appends "\n"; strip it so frame height matches yoga layout
if (raw.endsWith("\n")) raw = raw.slice(0, -1);
frames.push(raw);
});
const app: TuiApp = createApp(component, options.props ?? undefined);
@@ -82,10 +90,16 @@ export async function render(
};
return {
lastFrame: (opts?: { raw?: boolean }) => {
lastFrame: (opts?: LastFrameOptions) => {
const f = frames.at(-1);
if (!f) return undefined;
return opts?.raw ? f : trimFrame(f);
if (opts?.raw) return f;
if (opts?.trimLines)
return f
.split("\n")
.map((l) => l.trimEnd())
.join("\n");
return trimFrame(f);
},
frames,
stdin: {