mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 00:55:16 -07:00
1145e131da
- Remove CSS properties absent from subsequent subtitle style updates - Broadcast subtitle:set clear when media path changes - Preserve launcher lifecycle ownership for already-managed overlay apps - Clamp negative autoplay current time to zero - Reject blank subminerBinaryPath values via parseNonEmptyString - Log and rethrow legacy config migration errors instead of swallowing - Normalize modifier aliases (e.g. CommandOrControl) in keybinding display
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
function readMainSource(): string {
|
|
return fs.readFileSync(path.join(process.cwd(), 'src/main.ts'), 'utf8');
|
|
}
|
|
|
|
test('manual watched session action starts immersion tracker before marking watched', () => {
|
|
const source = readMainSource();
|
|
const actionBlock = source.match(
|
|
/markActiveVideoWatched:\s*async\s*\(\)\s*=>\s*\{(?<body>[\s\S]*?)\}\s*,/,
|
|
)?.groups?.body;
|
|
|
|
assert.ok(actionBlock);
|
|
assert.match(actionBlock, /ensureImmersionTrackerStarted\(\);/);
|
|
assert.ok(
|
|
actionBlock.indexOf('ensureImmersionTrackerStarted();') <
|
|
actionBlock.indexOf('markActiveVideoWatched()'),
|
|
);
|
|
});
|
|
|
|
test('media path changes clear rendered subtitle state', () => {
|
|
const source = readMainSource();
|
|
const actionBlock = source.match(
|
|
/updateCurrentMediaPath:\s*\(path\)\s*=>\s*\{(?<body>[\s\S]*?)autoplayReadyGate\.invalidatePendingAutoplayReadyFallbacks\(\);/,
|
|
)?.groups?.body;
|
|
|
|
assert.ok(actionBlock);
|
|
assert.match(actionBlock, /appState\.currentSubText = '';/);
|
|
assert.match(actionBlock, /appState\.currentSubAssText = '';/);
|
|
assert.match(actionBlock, /appState\.currentSubtitleData = null;/);
|
|
assert.match(actionBlock, /broadcastToOverlayWindows\('subtitle:set',/);
|
|
assert.ok(
|
|
actionBlock.indexOf('appState.currentSubtitleData = null;') <
|
|
actionBlock.indexOf("broadcastToOverlayWindows('subtitle:set'"),
|
|
);
|
|
});
|
|
|
|
test('main process uses one shared mpv plugin runtime config helper', () => {
|
|
const source = readMainSource();
|
|
assert.match(source, /function getMpvPluginRuntimeConfig\(\)/);
|
|
assert.equal((source.match(/socketPath: appState\.mpvSocketPath/g) ?? []).length, 1);
|
|
assert.equal(
|
|
(source.match(/binaryPath: getResolvedConfig\(\)\.mpv\.subminerBinaryPath/g) ?? []).length,
|
|
0,
|
|
);
|
|
});
|