mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-27 12:55:20 -07:00
Fix Windows mpv logging and add log export (#88)
This commit is contained in:
+108
-4
@@ -63,7 +63,6 @@ test('loads defaults when config is missing', () => {
|
||||
assert.deepEqual(config.ankiConnect.tags, ['SubMiner']);
|
||||
assert.equal(config.ankiConnect.media.audioPadding, 0);
|
||||
assert.equal(config.anilist.enabled, false);
|
||||
assert.equal(config.anilist.characterDictionary.enabled, false);
|
||||
assert.equal(config.subtitleStyle.nameMatchImagesEnabled, false);
|
||||
assert.equal(config.anilist.characterDictionary.refreshTtlHours, 168);
|
||||
assert.equal(config.anilist.characterDictionary.maxLoaded, 3);
|
||||
@@ -96,7 +95,6 @@ test('loads defaults when config is missing', () => {
|
||||
assert.equal(config.startupWarmups.subtitleDictionaries, true);
|
||||
assert.equal(config.startupWarmups.jellyfinRemoteSession, false);
|
||||
assert.equal(config.shortcuts.markAudioCard, 'CommandOrControl+Shift+A');
|
||||
assert.equal('openCharacterDictionary' in config.shortcuts, false);
|
||||
assert.equal(config.shortcuts.openCharacterDictionaryManager, 'CommandOrControl+D');
|
||||
assert.equal(config.shortcuts.toggleSubtitleSidebar, 'Backslash');
|
||||
assert.equal(config.discordPresence.enabled, true);
|
||||
@@ -825,7 +823,6 @@ test('parses anilist.characterDictionary config with clamping and enum validatio
|
||||
const config = service.getConfig();
|
||||
const warnings = service.getWarnings();
|
||||
|
||||
assert.equal(config.anilist.characterDictionary.enabled, true);
|
||||
assert.equal(config.anilist.characterDictionary.refreshTtlHours, 1);
|
||||
assert.equal(config.anilist.characterDictionary.maxLoaded, 20);
|
||||
assert.equal(config.anilist.characterDictionary.evictionPolicy, 'delete');
|
||||
@@ -1462,6 +1459,50 @@ test('accepts valid logging.level', () => {
|
||||
assert.equal(config.logging.level, 'warn');
|
||||
});
|
||||
|
||||
test('accepts valid logging.rotation', () => {
|
||||
const dir = makeTempDir();
|
||||
fs.writeFileSync(
|
||||
path.join(dir, 'config.jsonc'),
|
||||
`{
|
||||
"logging": {
|
||||
"rotation": 14
|
||||
}
|
||||
}`,
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
const service = new ConfigService(dir);
|
||||
const config = service.getConfig();
|
||||
|
||||
assert.equal(config.logging.rotation, 14);
|
||||
});
|
||||
|
||||
test('accepts valid logging file toggles', () => {
|
||||
const dir = makeTempDir();
|
||||
fs.writeFileSync(
|
||||
path.join(dir, 'config.jsonc'),
|
||||
`{
|
||||
"logging": {
|
||||
"files": {
|
||||
"app": false,
|
||||
"launcher": true,
|
||||
"mpv": true
|
||||
}
|
||||
}
|
||||
}`,
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
const service = new ConfigService(dir);
|
||||
const config = service.getConfig();
|
||||
|
||||
assert.deepEqual(config.logging.files, {
|
||||
app: false,
|
||||
launcher: true,
|
||||
mpv: true,
|
||||
});
|
||||
});
|
||||
|
||||
test('falls back for invalid logging.level and reports warning', () => {
|
||||
const dir = makeTempDir();
|
||||
fs.writeFileSync(
|
||||
@@ -1482,6 +1523,68 @@ test('falls back for invalid logging.level and reports warning', () => {
|
||||
assert.ok(warnings.some((warning) => warning.path === 'logging.level'));
|
||||
});
|
||||
|
||||
test('falls back for invalid logging.rotation and reports warning', () => {
|
||||
const dir = makeTempDir();
|
||||
fs.writeFileSync(
|
||||
path.join(dir, 'config.jsonc'),
|
||||
`{
|
||||
"logging": {
|
||||
"rotation": 0
|
||||
}
|
||||
}`,
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
const service = new ConfigService(dir);
|
||||
const config = service.getConfig();
|
||||
const warnings = service.getWarnings();
|
||||
|
||||
assert.equal(config.logging.rotation, DEFAULT_CONFIG.logging.rotation);
|
||||
assert.ok(warnings.some((warning) => warning.path === 'logging.rotation'));
|
||||
});
|
||||
|
||||
test('falls back for invalid logging file toggles and reports warning', () => {
|
||||
const dir = makeTempDir();
|
||||
fs.writeFileSync(
|
||||
path.join(dir, 'config.jsonc'),
|
||||
`{
|
||||
"logging": {
|
||||
"files": {
|
||||
"mpv": "yes"
|
||||
}
|
||||
}
|
||||
}`,
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
const service = new ConfigService(dir);
|
||||
const config = service.getConfig();
|
||||
const warnings = service.getWarnings();
|
||||
|
||||
assert.equal(config.logging.files.mpv, DEFAULT_CONFIG.logging.files.mpv);
|
||||
assert.ok(warnings.some((warning) => warning.path === 'logging.files.mpv'));
|
||||
});
|
||||
|
||||
test('falls back for invalid logging files object and reports warning', () => {
|
||||
const dir = makeTempDir();
|
||||
fs.writeFileSync(
|
||||
path.join(dir, 'config.jsonc'),
|
||||
`{
|
||||
"logging": {
|
||||
"files": false
|
||||
}
|
||||
}`,
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
const service = new ConfigService(dir);
|
||||
const config = service.getConfig();
|
||||
const warnings = service.getWarnings();
|
||||
|
||||
assert.deepEqual(config.logging.files, DEFAULT_CONFIG.logging.files);
|
||||
assert.ok(warnings.some((warning) => warning.path === 'logging.files'));
|
||||
});
|
||||
|
||||
test('warns and ignores unknown top-level config keys', () => {
|
||||
const dir = makeTempDir();
|
||||
fs.writeFileSync(
|
||||
@@ -2518,6 +2621,7 @@ test('template generator includes known keys', () => {
|
||||
assert.doesNotMatch(output, /"clientVersion":/);
|
||||
assert.doesNotMatch(output, /"youtubeSubgen":/);
|
||||
assert.match(output, /"characterDictionary":\s*\{/);
|
||||
assert.doesNotMatch(output, /"characterDictionary":\s*\{\s*"enabled":/);
|
||||
assert.match(output, /"preserveLineBreaks": false/);
|
||||
assert.match(output, /"knownWords"\s*:\s*\{/);
|
||||
assert.match(output, /"knownWordColor": "#a6da95"/);
|
||||
@@ -2527,7 +2631,7 @@ test('template generator includes known keys', () => {
|
||||
assert.match(output, /auto-generated from src\/config\/definitions.ts/);
|
||||
assert.match(
|
||||
output,
|
||||
/"level": "info",? \/\/ Minimum log level for runtime logging\. Values: debug \| info \| warn \| error/,
|
||||
/"level": "warn",? \/\/ Minimum log level for runtime logging\. Values: debug \| info \| warn \| error/,
|
||||
);
|
||||
assert.match(
|
||||
output,
|
||||
|
||||
Reference in New Issue
Block a user