mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-03 07:18:03 +01:00
test(extension): move the Consolas font-stack check into sidebar-ux (#2287)
The standalone file read extension sources without importing product code, which the test-of-test ratchet rejects; sidebar-ux already owns the sidepanel.css structural checks. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
1187917af3
commit
45f08ae92a
2 files changed
+21
-26
No files matched your search
@@ -983,3 +983,24 @@ describe('cookie import button (sidebar)', () => {
|
||||
expect(js).toContain('cookie-picker');
|
||||
});
|
||||
});
|
||||
|
||||
// #2287 (@tomfluff): xterm sizes its cell from the first font that resolves.
|
||||
// On Windows none of the Mac/Linux monospace fonts exist, so Malgun Gothic won
|
||||
// and every Latin glyph sat in a double-wide cell. Consolas ships with every
|
||||
// Windows install and must come before the CJK fallbacks in both stacks.
|
||||
describe('sidebar mono font stacks put a Windows Latin monospace before the CJK fallbacks (#2287)', () => {
|
||||
const stacks: Record<string, string | undefined> = {
|
||||
'sidepanel-terminal.js fontFamily': fs.readFileSync(path.join(ROOT, '..', 'extension', 'sidepanel-terminal.js'), 'utf-8').match(/fontFamily:\s*'([^']+)'/)?.[1],
|
||||
'sidepanel.css --font-mono': fs.readFileSync(path.join(ROOT, '..', 'extension', 'sidepanel.css'), 'utf-8').match(/--font-mono:\s*([^;]+);/)?.[1],
|
||||
};
|
||||
for (const [name, stack] of Object.entries(stacks)) {
|
||||
test(name, () => {
|
||||
expect(stack).toBeDefined();
|
||||
const fonts = stack!.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, ''));
|
||||
const consolas = fonts.indexOf('Consolas');
|
||||
expect(consolas).toBeGreaterThanOrEqual(0);
|
||||
for (const cjk of ['Noto Sans Mono CJK KR', 'Malgun Gothic']) expect(fonts.indexOf(cjk)).toBeGreaterThan(consolas);
|
||||
expect(fonts.at(-1)).toBe('monospace');
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,26 +0,0 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
|
||||
// #2287 (@tomfluff): xterm sizes its cell from the first font that resolves.
|
||||
// On Windows none of the Mac/Linux monospace fonts exist, so Malgun Gothic won
|
||||
// and every Latin glyph sat in a double-wide cell. Consolas ships with every
|
||||
// Windows install and must come before the CJK fallbacks in both stacks.
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const stacks = {
|
||||
'extension/sidepanel-terminal.js': fs.readFileSync(path.join(ROOT, 'extension/sidepanel-terminal.js'), 'utf8').match(/fontFamily:\s*'([^']+)'/)?.[1],
|
||||
'extension/sidepanel.css': fs.readFileSync(path.join(ROOT, 'extension/sidepanel.css'), 'utf8').match(/--font-mono:\s*([^;]+);/)?.[1],
|
||||
};
|
||||
|
||||
describe('sidebar mono font stacks put a Windows Latin monospace before the CJK fallbacks (#2287)', () => {
|
||||
for (const [file, stack] of Object.entries(stacks)) {
|
||||
test(file, () => {
|
||||
expect(stack).toBeDefined();
|
||||
const fonts = stack!.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, ''));
|
||||
const consolas = fonts.indexOf('Consolas');
|
||||
expect(consolas).toBeGreaterThanOrEqual(0);
|
||||
for (const cjk of ['Noto Sans Mono CJK KR', 'Malgun Gothic']) expect(fonts.indexOf(cjk)).toBeGreaterThan(consolas);
|
||||
expect(fonts.at(-1)).toBe('monospace');
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user