From 9cdb6f3a25b1d4b5cfa4e77186251ca74fc241bf Mon Sep 17 00:00:00 2001 From: Lizi Date: Sat, 14 Nov 2026 10:36:25 +0800 Subject: [PATCH] =?UTF-8?q?test(desktop):=20=E5=9B=BA=E5=AE=9A=E8=A7=92?= =?UTF-8?q?=E6=A0=87=E6=B5=8B=E8=AF=95=E4=BD=BF=E7=94=A8=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assisted-by: Cindy (https://cindy.app) Signed-off-by: Lizi --- .../main/__tests__/windowsBadgeIcon.test.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/main/__tests__/windowsBadgeIcon.test.ts b/apps/desktop/src/main/__tests__/windowsBadgeIcon.test.ts index aeb6e5c9c3..840a73ddb4 100644 --- a/apps/desktop/src/main/__tests__/windowsBadgeIcon.test.ts +++ b/apps/desktop/src/main/__tests__/windowsBadgeIcon.test.ts @@ -1,5 +1,6 @@ -import { createCanvas, loadImage } from '@napi-rs/canvas'; -import { describe, expect, it, vi } from 'vitest'; +import { fileURLToPath } from 'node:url'; +import { createCanvas, GlobalFonts, loadImage } from '@napi-rs/canvas'; +import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'; const { addRepresentation, icon } = vi.hoisted(() => { const addRepresentation = vi.fn(); @@ -10,6 +11,21 @@ vi.mock('electron', () => ({ nativeImage: { createEmpty: () => icon } })); import { createWindowsBadgeIcon, renderWindowsBadgePng } from '../windowsBadgeIcon'; describe('Windows numeric taskbar badge', () => { + let fixtureFont: ReturnType = null; + beforeAll(() => { + // Keep the PNG assertions independent of the runner's system-font fallback. + // This checks real badge rendering, not the Windows Segoe UI glyph shapes. + fixtureFont = GlobalFonts.registerFromPath( + fileURLToPath(new URL('../../../native/menubar/BarlowCondensed-SemiBold.ttf', import.meta.url)), + 'Segoe UI', + ); + expect(fixtureFont).not.toBeNull(); + }); + afterAll(() => { + // The native font collection is process-wide, including Vitest threads. + if (fixtureFont) GlobalFonts.remove(fixtureFont); + }); + it.each([1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 8])( 'renders exact physical dimensions at %s scale for the native Shell bridge', (scale) => {