CLS: #packages-static uit de layout (visueel verborgen) en metrisch gelijke terugvalfont voor JetBrains Mono; test erbij

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 08:16:41 +01:00
co-authored by Claude Sonnet 5.5
parent 43c76c80ad
commit d6a3acdd47
4 changed files with 49 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
const root = resolve(__dirname, '../..');
const read = (file: string) => readFileSync(resolve(root, file), 'utf8');
/**
* Guards against layout shifts (CLS) at start-up: the static packages list that the CMS host may inject above #root
* is removed by main.tsx, so it must not take any space, and the code line needs a metric-compatible font fallback.
*/
describe('layout stability at start-up', () => {
it('takes the injected #packages-static list out of the layout in index.html', () => {
const html = read('index.html');
const rule = html.match(/#packages-static\s*\{([^}]*)\}/);
expect(rule).not.toBeNull();
expect(rule?.[1]).toMatch(/position:\s*absolute/);
expect(rule?.[1]).toMatch(/clip:/);
});
it('gives the mono font a metric-compatible fallback', () => {
expect(read('src/index.css')).toMatch(/font-family:\s*'JetBrains Mono Fallback'/);
expect(read('tailwind.config.ts')).toMatch(/'JetBrains Mono',\s*'JetBrains Mono Fallback'/);
});
});