From 572bceecb08020065efa00e459620631d35e61c2 Mon Sep 17 00:00:00 2001 From: sudacode Date: Sat, 28 Mar 2026 15:24:35 -0700 Subject: [PATCH] fix: stabilize coverage and immersion tracker tests --- .../immersion-tracker/query-sessions.ts | 2 +- .../immersion-tracker/query-trends.ts | 2 +- src/main/runtime/setup-window-factory.test.ts | 31 +++++++++++++++---- src/main/runtime/setup-window-factory.ts | 14 +++++---- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/core/services/immersion-tracker/query-sessions.ts b/src/core/services/immersion-tracker/query-sessions.ts index afa346d7..beaef9c9 100644 --- a/src/core/services/immersion-tracker/query-sessions.ts +++ b/src/core/services/immersion-tracker/query-sessions.ts @@ -10,7 +10,7 @@ import { ACTIVE_SESSION_METRICS_CTE, subtractDbMs, toDbMs, toDbSeconds } from '. const THIRTY_DAYS_MS = '2592000000'; function localMidnightSecondsExpr(): string { - return `(CAST(strftime('%s', 'now', 'localtime') AS INTEGER) - CAST(strftime('%H', 'now', 'localtime') AS INTEGER) * 3600 - CAST(strftime('%M', 'now', 'localtime') AS INTEGER) * 60 - CAST(strftime('%S', 'now', 'localtime') AS INTEGER))`; + return `(CAST(strftime('%s', 'now') AS INTEGER) - CAST(strftime('%H', 'now', 'localtime') AS INTEGER) * 3600 - CAST(strftime('%M', 'now', 'localtime') AS INTEGER) * 60 - CAST(strftime('%S', 'now', 'localtime') AS INTEGER))`; } export function getSessionSummaries(db: DatabaseSync, limit = 50): SessionSummaryQueryRow[] { diff --git a/src/core/services/immersion-tracker/query-trends.ts b/src/core/services/immersion-tracker/query-trends.ts index fc01d726..71d3783a 100644 --- a/src/core/services/immersion-tracker/query-trends.ts +++ b/src/core/services/immersion-tracker/query-trends.ts @@ -131,7 +131,7 @@ function formatTrendLabel(value: number): string { } function localMidnightSecondsExpr(): string { - return `(CAST(strftime('%s', 'now', 'localtime') AS INTEGER) - CAST(strftime('%H', 'now', 'localtime') AS INTEGER) * 3600 - CAST(strftime('%M', 'now', 'localtime') AS INTEGER) * 60 - CAST(strftime('%S', 'now', 'localtime') AS INTEGER))`; + return `(CAST(strftime('%s', 'now') AS INTEGER) - CAST(strftime('%H', 'now', 'localtime') AS INTEGER) * 3600 - CAST(strftime('%M', 'now', 'localtime') AS INTEGER) * 60 - CAST(strftime('%S', 'now', 'localtime') AS INTEGER))`; } function getTrendSessionWordCount(session: Pick): number { diff --git a/src/main/runtime/setup-window-factory.test.ts b/src/main/runtime/setup-window-factory.test.ts index 74bdc6ac..31c8c53e 100644 --- a/src/main/runtime/setup-window-factory.test.ts +++ b/src/main/runtime/setup-window-factory.test.ts @@ -16,20 +16,21 @@ test('createCreateFirstRunSetupWindowHandler builds first-run setup window', () }); assert.deepEqual(createSetupWindow(), { id: 'first-run' }); - assert.deepEqual(options, { + const { resizable, minimizable, maximizable, ...firstRunWindowOptions } = options ?? {}; + assert.deepEqual(firstRunWindowOptions, { width: 480, height: 460, title: 'SubMiner Setup', show: true, autoHideMenuBar: true, - resizable: false, - minimizable: false, - maximizable: false, webPreferences: { nodeIntegration: false, contextIsolation: true, }, }); + assert.equal(resizable, false); + assert.equal(minimizable, false); + assert.equal(maximizable, false); }); test('createCreateJellyfinSetupWindowHandler builds jellyfin setup window', () => { @@ -42,7 +43,13 @@ test('createCreateJellyfinSetupWindowHandler builds jellyfin setup window', () = }); assert.deepEqual(createSetupWindow(), { id: 'jellyfin' }); - assert.deepEqual(options, { + const { + resizable: jellyfinResizable, + minimizable: jellyfinMinimizable, + maximizable: jellyfinMaximizable, + ...jellyfinWindowOptions + } = options ?? {}; + assert.deepEqual(jellyfinWindowOptions, { width: 520, height: 560, title: 'Jellyfin Setup', @@ -53,6 +60,9 @@ test('createCreateJellyfinSetupWindowHandler builds jellyfin setup window', () = contextIsolation: true, }, }); + assert.equal(jellyfinResizable, undefined); + assert.equal(jellyfinMinimizable, undefined); + assert.equal(jellyfinMaximizable, undefined); }); test('createCreateAnilistSetupWindowHandler builds anilist setup window', () => { @@ -65,7 +75,13 @@ test('createCreateAnilistSetupWindowHandler builds anilist setup window', () => }); assert.deepEqual(createSetupWindow(), { id: 'anilist' }); - assert.deepEqual(options, { + const { + resizable: anilistResizable, + minimizable: anilistMinimizable, + maximizable: anilistMaximizable, + ...anilistWindowOptions + } = options ?? {}; + assert.deepEqual(anilistWindowOptions, { width: 1000, height: 760, title: 'Anilist Setup', @@ -76,4 +92,7 @@ test('createCreateAnilistSetupWindowHandler builds anilist setup window', () => contextIsolation: true, }, }); + assert.equal(anilistResizable, undefined); + assert.equal(anilistMinimizable, undefined); + assert.equal(anilistMaximizable, undefined); }); diff --git a/src/main/runtime/setup-window-factory.ts b/src/main/runtime/setup-window-factory.ts index bdccd49e..ffae518d 100644 --- a/src/main/runtime/setup-window-factory.ts +++ b/src/main/runtime/setup-window-factory.ts @@ -11,21 +11,23 @@ function createSetupWindowHandler( deps: { createBrowserWindow: (options: Electron.BrowserWindowConstructorOptions) => TWindow }, config: SetupWindowConfig, ) { - return (): TWindow => - deps.createBrowserWindow({ + return (): TWindow => { + const options: Electron.BrowserWindowConstructorOptions = { width: config.width, height: config.height, title: config.title, show: true, autoHideMenuBar: true, - resizable: config.resizable, - minimizable: config.minimizable, - maximizable: config.maximizable, webPreferences: { nodeIntegration: false, contextIsolation: true, }, - }); + }; + if (config.resizable !== undefined) options.resizable = config.resizable; + if (config.minimizable !== undefined) options.minimizable = config.minimizable; + if (config.maximizable !== undefined) options.maximizable = config.maximizable; + return deps.createBrowserWindow(options); + }; } export function createCreateFirstRunSetupWindowHandler(deps: {