feat(config): add configuration window (#70)

This commit is contained in:
2026-05-21 04:16:21 -07:00
committed by GitHub
parent a54f03f0cd
commit dc52bc2fba
287 changed files with 14507 additions and 8134 deletions
+23
View File
@@ -3,6 +3,7 @@ import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import { DEFAULT_CONFIG } from './config';
import { RuntimeOptionsManager } from './runtime-options';
test('SM-012 runtime options path does not use JSON serialize-clone helpers', () => {
@@ -59,3 +60,25 @@ test('RuntimeOptionsManager returns detached effective Anki config copies', () =
assert.deepEqual(baseConfig.tags, ['SubMiner']);
assert.equal(baseConfig.behavior.autoUpdateNewCards, true);
});
test('RuntimeOptionsManager keeps known-word and n+1 annotation toggles separate', () => {
const baseConfig = structuredClone(DEFAULT_CONFIG.ankiConnect);
const patches: unknown[] = [];
const manager = new RuntimeOptionsManager(() => structuredClone(baseConfig), {
applyAnkiPatch: (patch) => {
patches.push(patch);
},
onOptionsChanged: () => undefined,
});
assert.equal(
manager.setOptionValue('subtitle.annotation.knownWords.highlightEnabled', true).ok,
true,
);
assert.equal(manager.setOptionValue('subtitle.annotation.nPlusOne', true).ok, true);
const effective = manager.getEffectiveAnkiConnectConfig();
assert.equal(effective.knownWords?.highlightEnabled, true);
assert.equal(effective.nPlusOne?.enabled, true);
assert.deepEqual(patches, []);
});