test(settings): cover code block preview wrapping

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Dryice Liu
2026-07-18 16:34:35 +08:00
parent 2bd9ce1538
commit c84ff4daf4
2 changed files with 15 additions and 2 deletions

View File

@@ -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(

View File

@@ -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",
);
});