Repository navigation
test(core): isolate local font fallback from system discovery - #5360
user-github-me wants to merge 1 commit into
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Test-only change, and it does what it says. The fixture now lives in the suite's temp dir instead of the real user font directory, and locateSystemFontVariants is stubbed per test with restoreAllMocks in afterEach, so the macOS system_profiler path can no longer eat the 5s test budget or leave a stray file in ~/Library/Fonts. I checked that systemFamilyFaceRules in deterministicFonts.ts goes through locateSystemFontVariants(lookupFamily) and then readFileSync(variant.path), so returning the temp path still exercises the real embed path. The two new call assertions make both cases stronger: the failed authored-link case now proves the locator is never consulted, not just that the bytes are missing. The file is unchanged on main since the PR base, so it is still relevant.
— Rames
The local-fallback case in
deterministicFonts-googleSubsets.test.tswrites a fake font into the user's font directory and discovers it through the real system-font locator. On macOS that invokessystem_profiler, whose five-second timeout can consume the test's own five-second deadline. The unchanged suite reproduces this locally with 22 passes and one timeout.Keep the font fixture in the suite's temporary directory and stub only the system-font lookup with a typed result. Restore the spy after every test. The existing assertion still checks that the compiler embeds the fixture bytes, and the failed authored-link case now explicitly verifies that the system locator is not called.
Validation: all 23 tests in this file, all 258 font tests, and the full 4,401-test core suite pass. Disabling local fallback and ignoring the authored-link restriction each fail the intended assertion, confirming the isolated tests still detect both regressions. Workspace build, core typecheck, repository lint, formatting, comment checks, test reachability, and the normal pre-commit hooks pass. Production font resolution is unchanged.