Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

test(settings): cover code block preview wrapping

Dryice Liuc84ff4daf408
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",
+ );
+});