mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-09 04:19:27 -07:00
fix: stabilize coverage and immersion tracker tests
This commit is contained in:
@@ -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[] {
|
||||
|
||||
@@ -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<TrendSessionMetricRow, 'tokensSeen'>): number {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -11,21 +11,23 @@ function createSetupWindowHandler<TWindow>(
|
||||
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<TWindow>(deps: {
|
||||
|
||||
Reference in New Issue
Block a user