mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-10 04:19:25 -07:00
fix: stabilize failing test regressions across src and launcher lanes
- Fix log pruning cutoff math using BigInt `mtimeNs` to avoid Bun mtime precision loss - Fix stats CLI lifetime rebuild timestamp units in tests and log output; add `formatLoggedNumber` guard - Use `performance.now()` in subtitle sidebar auto-follow to isolate from test time injection - Harden renderer global cleanup tests with descriptor save/restore instead of assuming globals absent - Isolate `node:http` fallback in stats-server test with stub and assertion - Fix AniSkip fallback title: cleaned basename beats generic parent dirs; episode-only filenames still prefer series directory
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import http from 'node:http';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { createStatsApp, startStatsServer } from '../stats-server.js';
|
||||
@@ -1172,7 +1173,23 @@ describe('stats server API routes', () => {
|
||||
|
||||
const bun = globalThis as typeof globalThis & BunRuntime;
|
||||
const originalServe = bun.Bun.serve;
|
||||
const originalCreateServer = http.createServer;
|
||||
let listenedWith: { port: number; hostname: string } | null = null;
|
||||
let closeCalls = 0;
|
||||
bun.Bun.serve = undefined;
|
||||
(
|
||||
http as typeof http & {
|
||||
createServer: typeof http.createServer;
|
||||
}
|
||||
).createServer = (() =>
|
||||
({
|
||||
listen: (port: number, hostname: string) => {
|
||||
listenedWith = { port, hostname };
|
||||
},
|
||||
close: () => {
|
||||
closeCalls += 1;
|
||||
},
|
||||
}) as unknown as ReturnType<typeof http.createServer>) as typeof http.createServer;
|
||||
|
||||
try {
|
||||
const server = startStatsServer({
|
||||
@@ -1181,9 +1198,16 @@ describe('stats server API routes', () => {
|
||||
tracker: createMockTracker(),
|
||||
});
|
||||
|
||||
assert.deepEqual(listenedWith, { port: 0, hostname: '127.0.0.1' });
|
||||
server.close();
|
||||
assert.equal(closeCalls, 1);
|
||||
} finally {
|
||||
bun.Bun.serve = originalServe;
|
||||
(
|
||||
http as typeof http & {
|
||||
createServer: typeof http.createServer;
|
||||
}
|
||||
).createServer = originalCreateServer;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user