From c84ff4daf4081ed7bc2125e703450cb7f242d304 Mon Sep 17 00:00:00 2001 From: Dryice Liu Date: Sat, 18 Jul 2026 16:34:35 +0800 Subject: [PATCH] test(settings): cover code block preview wrapping Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- web/app/(utility)/settings/appearance/page.tsx | 5 +++-- web/tests/appearance-settings-page.test.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/web/app/(utility)/settings/appearance/page.tsx b/web/app/(utility)/settings/appearance/page.tsx index b885e13da..74f39c837 100644 --- a/web/app/(utility)/settings/appearance/page.tsx +++ b/web/app/(utility)/settings/appearance/page.tsx @@ -34,8 +34,9 @@ const CODE_BLOCK_PREVIEW_SNIPPET = `def fibonacci(n): return result -# Print the first 10 numbers in the sequence -print(f"fibonacci(10) = {fibonacci(10)}") +# Build a deliberately long summary so the wrapping preference is easy to see +summary = f"First twenty Fibonacci values rendered with the selected syntax theme, line-number setting, and wrapping preference: {', '.join(str(value) for value in fibonacci(20))}" +print(summary) `; const RichCodeBlockPreview = dynamic( diff --git a/web/tests/appearance-settings-page.test.ts b/web/tests/appearance-settings-page.test.ts index ab23b6464..7dda1d9f3 100644 --- a/web/tests/appearance-settings-page.test.ts +++ b/web/tests/appearance-settings-page.test.ts @@ -71,3 +71,15 @@ test("appearance settings page: exposes every registered code block theme option assert.ok(CODE_BLOCK_THEME_OPTIONS.length > 0); assert.match(source, /CODE_BLOCK_THEME_OPTIONS\.map/); }); + +test("appearance settings page: preview includes a line long enough to demonstrate wrapping", () => { + const source = readAppearancePage(); + const previewSource = + source.match(/const CODE_BLOCK_PREVIEW_SNIPPET = `([\s\S]*?)`;/)?.[1] ?? ""; + + assert.ok(previewSource, "The fixed Python preview snippet should exist"); + assert.ok( + previewSource.split("\n").some((line) => line.length >= 120), + "The preview needs a 120+ character line so Wrap long lines has a visible effect", + ); +});