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:
2026-04-03 22:04:52 -07:00
parent 864f4124ae
commit e4137d9760
10 changed files with 224 additions and 33 deletions

View File

@@ -125,6 +125,12 @@ function titleOverlapScore(expectedTitle: string, candidateTitle: string): numbe
if (!expected || !candidate) return 0;
if (candidate.includes(expected)) return 120;
if (
candidate.split(' ').length >= 2 &&
` ${expected} `.includes(` ${candidate} `)
) {
return 90;
}
const expectedTokens = tokenizeMatchWords(expectedTitle);
if (expectedTokens.length === 0) return 0;
@@ -339,6 +345,12 @@ function isSeasonDirectoryName(value: string): boolean {
return /^(?:season|s)[\s._-]*\d{1,2}$/i.test(value.trim());
}
function isEpisodeOnlyBaseName(value: string): boolean {
return /^(?:[Ss]\d{1,2}[Ee]\d{1,3}|[Ee][Pp]?[\s._-]*\d{1,3}|\d{1,3})(?:$|[\s._-])/.test(
value.trim(),
);
}
function inferTitleFromPath(mediaPath: string): string {
const directory = path.dirname(mediaPath);
const segments = directory.split(/[\\/]+/).filter((segment) => segment.length > 0);
@@ -445,8 +457,11 @@ export function inferAniSkipMetadataForFile(
}
const baseName = path.basename(mediaPath, path.extname(mediaPath));
const cleanedBaseName = cleanupTitle(baseName);
const pathTitle = inferTitleFromPath(mediaPath);
const fallbackTitle = pathTitle || cleanupTitle(baseName) || baseName;
const fallbackTitle = isEpisodeOnlyBaseName(baseName)
? pathTitle || cleanedBaseName || baseName
: cleanedBaseName || pathTitle || baseName;
return {
title: fallbackTitle,
season: detectSeasonFromNameOrDir(mediaPath),