[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
82
infrastructure/config/uiFonts.test.ts
Normal file
82
infrastructure/config/uiFonts.test.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
DEFAULT_UI_FONT_ID,
|
||||
detectUiPlatform,
|
||||
UI_FONTS,
|
||||
withWindowsEmojiFallback,
|
||||
WINDOWS_FLAG_EMOJI_FONT,
|
||||
WINDOWS_UI_EMOJI_FONTS,
|
||||
withUiCjkFallback,
|
||||
} from './uiFonts';
|
||||
|
||||
describe('detectUiPlatform', () => {
|
||||
it('detects Windows user agents', () => {
|
||||
assert.equal(
|
||||
detectUiPlatform('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'),
|
||||
'win32',
|
||||
);
|
||||
});
|
||||
|
||||
it('detects macOS user agents', () => {
|
||||
assert.equal(
|
||||
detectUiPlatform('Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/537.36'),
|
||||
'darwin',
|
||||
);
|
||||
});
|
||||
|
||||
it('falls back to linux for other platforms', () => {
|
||||
assert.equal(
|
||||
detectUiPlatform('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36'),
|
||||
'linux',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('withWindowsEmojiFallback', () => {
|
||||
const sampleFamily = '"Space Grotesk", system-ui, sans-serif';
|
||||
|
||||
it('prepends bundled flag font and Windows emoji fonts for host labels', () => {
|
||||
const stack = withWindowsEmojiFallback(sampleFamily, 'win32');
|
||||
assert.ok(stack.startsWith(WINDOWS_UI_EMOJI_FONTS));
|
||||
assert.match(stack, /Noto Color Emoji Flags/);
|
||||
assert.match(stack, /Space Grotesk/);
|
||||
});
|
||||
|
||||
it('includes the bundled flag font before Segoe UI Emoji on Windows', () => {
|
||||
const stack = withWindowsEmojiFallback(sampleFamily, 'win32');
|
||||
const flagIndex = stack.indexOf(WINDOWS_FLAG_EMOJI_FONT);
|
||||
const segoeIndex = stack.indexOf('Segoe UI Emoji');
|
||||
assert.ok(flagIndex >= 0);
|
||||
assert.ok(segoeIndex >= 0);
|
||||
assert.ok(flagIndex < segoeIndex);
|
||||
});
|
||||
|
||||
it('keeps the stack unchanged on non-Windows platforms', () => {
|
||||
assert.equal(withWindowsEmojiFallback(sampleFamily, 'darwin'), sampleFamily);
|
||||
assert.equal(withWindowsEmojiFallback(sampleFamily, 'linux'), sampleFamily);
|
||||
});
|
||||
|
||||
it('does not double-prepend when emoji fonts are already present', () => {
|
||||
const alreadyPrefixed = `${WINDOWS_UI_EMOJI_FONTS}, ${sampleFamily}`;
|
||||
assert.equal(withWindowsEmojiFallback(alreadyPrefixed, 'win32'), alreadyPrefixed);
|
||||
});
|
||||
});
|
||||
|
||||
describe('withUiCjkFallback', () => {
|
||||
it('still appends CJK fallbacks for UI font stacks', () => {
|
||||
const stack = withUiCjkFallback('"Space Grotesk", system-ui');
|
||||
assert.match(stack, /PingFang SC/);
|
||||
assert.match(stack, /Space Grotesk/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('default UI font', () => {
|
||||
it('uses Mona Sans while keeping Chinese fallbacks in the stack', () => {
|
||||
const defaultFont = UI_FONTS.find((font) => font.id === DEFAULT_UI_FONT_ID);
|
||||
assert.equal(DEFAULT_UI_FONT_ID, 'mona-sans');
|
||||
assert.equal(defaultFont?.name, 'Mona Sans');
|
||||
assert.match(defaultFont?.family ?? '', /Mona Sans/);
|
||||
assert.match(defaultFont?.family ?? '', /PingFang SC/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user