Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

test(fonts): scope code font regression to explicit preference

tianma-ifea1b45d98feb
diff --git a/apps/web/src/components/settings/PreferenceCard.test.mjs b/apps/web/src/components/settings/PreferenceCard.test.mjs
index f90bb08f..5ad8a20e 100644
--- a/apps/web/src/components/settings/PreferenceCard.test.mjs
+++ b/apps/web/src/components/settings/PreferenceCard.test.mjs
@@ -28,11 +28,26 @@ describe("editor body font preference", () => {
expect(editorFonts).toContain("html[data-ui-font]");
expect(editorFonts).toContain("html[data-ui-font]:not([data-editor-body-font]) .edgeever-editor[data-editor-theme=\"default\"] .ProseMirror");
expect(editorFonts).toContain("html[data-ui-font] .edgeever-public-share");
- expect(editorFonts).not.toContain(".edgeever-code-source");
for (const fileName of ["kai.woff2", "kai-screen.woff2", "fangsong.woff2", "song.woff2", "zhi-song.woff2", "hei.woff2", "source-serif-4-regular.woff2", "OFL-lxgw-wenkai.txt", "OFL-zhuque-fangsong.txt", "OFL-source-han-serif.txt", "OFL-source-serif-4.txt", "IPA-lxgw-neo-zhi-song.txt"]) {
expect(existsSync(new URL(`../../assets/fonts/editor-body/${fileName}`, import.meta.url))).toBe(true);
}
});
+
+ test("scopes code source fonts to the explicit code font preference", () => {
+ const editorFonts = readFileSync(new URL("../../styles/editor-body-fonts.css", import.meta.url), "utf8");
+ const rules = [...editorFonts.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/([^{}]+)\{([^{}]*)\}/g)];
+ const codeSourceRules = rules.filter(([, selectors]) => selectors.includes(".edgeever-code-source"));
+
+ expect(codeSourceRules.length).toBeGreaterThan(0);
+ for (const [, selectors, declarations] of codeSourceRules) {
+ // Split between selectors, retaining commas inside :is(...).
+ for (const selector of selectors.trim().split(/,\s*(?=html)/)) {
+ expect(selector).toStartWith("html[data-editor-code-font] ");
+ }
+ expect(declarations).toMatch(/font-family:\s*var\(--editor-code-font-family\)/);
+ expect(declarations).not.toContain("--editor-body-font-family");
+ }
+ });
});
describe("appearance preference", () => {