fix: stabilize coverage and immersion tracker tests

This commit is contained in:
2026-03-28 15:24:35 -07:00
parent baf2553f57
commit 572bceecb0
4 changed files with 35 additions and 14 deletions

View File

@@ -10,7 +10,7 @@ import { ACTIVE_SESSION_METRICS_CTE, subtractDbMs, toDbMs, toDbSeconds } from '.
const THIRTY_DAYS_MS = '2592000000'; const THIRTY_DAYS_MS = '2592000000';
function localMidnightSecondsExpr(): 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))`;
} }
export function getSessionSummaries(db: DatabaseSync, limit = 50): SessionSummaryQueryRow[] { export function getSessionSummaries(db: DatabaseSync, limit = 50): SessionSummaryQueryRow[] {

View File

@@ -131,7 +131,7 @@ function formatTrendLabel(value: number): string {
} }
function localMidnightSecondsExpr(): 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<TrendSessionMetricRow, 'tokensSeen'>): number { function getTrendSessionWordCount(session: Pick<TrendSessionMetricRow, 'tokensSeen'>): number {

View File

@@ -16,20 +16,21 @@ test('createCreateFirstRunSetupWindowHandler builds first-run setup window', ()
}); });
assert.deepEqual(createSetupWindow(), { id: 'first-run' }); assert.deepEqual(createSetupWindow(), { id: 'first-run' });
assert.deepEqual(options, { const { resizable, minimizable, maximizable, ...firstRunWindowOptions } = options ?? {};
assert.deepEqual(firstRunWindowOptions, {
width: 480, width: 480,
height: 460, height: 460,
title: 'SubMiner Setup', title: 'SubMiner Setup',
show: true, show: true,
autoHideMenuBar: true, autoHideMenuBar: true,
resizable: false,
minimizable: false,
maximizable: false,
webPreferences: { webPreferences: {
nodeIntegration: false, nodeIntegration: false,
contextIsolation: true, contextIsolation: true,
}, },
}); });
assert.equal(resizable, false);
assert.equal(minimizable, false);
assert.equal(maximizable, false);
}); });
test('createCreateJellyfinSetupWindowHandler builds jellyfin setup window', () => { test('createCreateJellyfinSetupWindowHandler builds jellyfin setup window', () => {
@@ -42,7 +43,13 @@ test('createCreateJellyfinSetupWindowHandler builds jellyfin setup window', () =
}); });
assert.deepEqual(createSetupWindow(), { id: 'jellyfin' }); assert.deepEqual(createSetupWindow(), { id: 'jellyfin' });
assert.deepEqual(options, { const {
resizable: jellyfinResizable,
minimizable: jellyfinMinimizable,
maximizable: jellyfinMaximizable,
...jellyfinWindowOptions
} = options ?? {};
assert.deepEqual(jellyfinWindowOptions, {
width: 520, width: 520,
height: 560, height: 560,
title: 'Jellyfin Setup', title: 'Jellyfin Setup',
@@ -53,6 +60,9 @@ test('createCreateJellyfinSetupWindowHandler builds jellyfin setup window', () =
contextIsolation: true, contextIsolation: true,
}, },
}); });
assert.equal(jellyfinResizable, undefined);
assert.equal(jellyfinMinimizable, undefined);
assert.equal(jellyfinMaximizable, undefined);
}); });
test('createCreateAnilistSetupWindowHandler builds anilist setup window', () => { test('createCreateAnilistSetupWindowHandler builds anilist setup window', () => {
@@ -65,7 +75,13 @@ test('createCreateAnilistSetupWindowHandler builds anilist setup window', () =>
}); });
assert.deepEqual(createSetupWindow(), { id: 'anilist' }); assert.deepEqual(createSetupWindow(), { id: 'anilist' });
assert.deepEqual(options, { const {
resizable: anilistResizable,
minimizable: anilistMinimizable,
maximizable: anilistMaximizable,
...anilistWindowOptions
} = options ?? {};
assert.deepEqual(anilistWindowOptions, {
width: 1000, width: 1000,
height: 760, height: 760,
title: 'Anilist Setup', title: 'Anilist Setup',
@@ -76,4 +92,7 @@ test('createCreateAnilistSetupWindowHandler builds anilist setup window', () =>
contextIsolation: true, contextIsolation: true,
}, },
}); });
assert.equal(anilistResizable, undefined);
assert.equal(anilistMinimizable, undefined);
assert.equal(anilistMaximizable, undefined);
}); });

View File

@@ -11,21 +11,23 @@ function createSetupWindowHandler<TWindow>(
deps: { createBrowserWindow: (options: Electron.BrowserWindowConstructorOptions) => TWindow }, deps: { createBrowserWindow: (options: Electron.BrowserWindowConstructorOptions) => TWindow },
config: SetupWindowConfig, config: SetupWindowConfig,
) { ) {
return (): TWindow => return (): TWindow => {
deps.createBrowserWindow({ const options: Electron.BrowserWindowConstructorOptions = {
width: config.width, width: config.width,
height: config.height, height: config.height,
title: config.title, title: config.title,
show: true, show: true,
autoHideMenuBar: true, autoHideMenuBar: true,
resizable: config.resizable,
minimizable: config.minimizable,
maximizable: config.maximizable,
webPreferences: { webPreferences: {
nodeIntegration: false, nodeIntegration: false,
contextIsolation: true, 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<TWindow>(deps: { export function createCreateFirstRunSetupWindowHandler<TWindow>(deps: {