Files
SubMiner/src/preload-settings.test.ts
T
sudacode e18ccfe288 feat(stats): add Hide Kana filter and fix vocabulary exclusion matching
- Remove overlay mining image toast; OSD card notifications no longer flash a frame screenshot
- Add Hide Kana toggle to frequency rank table to filter kana-only headwords
- Fix vocab exclusions to deduplicate and match token variants (e.g. ない / 無い) under one exclusion entry
- Skip cover image fetching when the overview tab is inactive
2026-06-06 01:50:15 -07:00

55 lines
2.0 KiB
TypeScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
test('settings preload stays sandbox-compatible by avoiding local runtime imports', () => {
const source = fs.readFileSync(path.join(process.cwd(), 'src', 'preload-settings.ts'), 'utf8');
assert.doesNotMatch(source, /from\s+['"]\.\/shared\/ipc\/contracts(?:\.(?:js|ts))?['"]/);
});
test('settings preload exposes Anki lookup helpers', () => {
const source = fs.readFileSync(path.join(process.cwd(), 'src', 'preload-settings.ts'), 'utf8');
for (const method of [
'getAnkiDeckNames',
'getAnkiDeckFieldNames',
'getAnkiDeckModelNames',
'getAnkiModelNames',
'getAnkiModelFieldNames',
'getYomitanAnkiDeckName',
]) {
assert.match(source, new RegExp(`${method}:`));
}
});
test('overlay preload buffers only latest subtitle state until renderer listener registration', () => {
const source = fs.readFileSync(path.join(process.cwd(), 'src', 'preload.ts'), 'utf8');
assert.match(
source,
/const onSubtitleSetEvent =\s*createLatestValueIpcListenerWithPayload<SubtitleData>\(\s*IPC_CHANNELS\.event\.subtitleSet,/,
);
assert.match(source, /onSubtitle:\s*\(callback:[\s\S]+?onSubtitleSetEvent\(callback\);/);
});
test('overlay preload does not expose the old mining image toast IPC path', () => {
const source = fs.readFileSync(path.join(process.cwd(), 'src', 'preload.ts'), 'utf8');
assert.doesNotMatch(source, /MiningImagePayload|onMiningImage|IPC_CHANNELS\.event\.miningImage/);
});
test('overlay preload exposes queued pointer recovery requests', () => {
const source = fs.readFileSync(path.join(process.cwd(), 'src', 'preload.ts'), 'utf8');
assert.match(
source,
/const onOverlayPointerRecoveryRequestEvent =\s*createQueuedIpcListener\(\s*IPC_CHANNELS\.event\.overlayPointerRecoveryRequest,/,
);
assert.match(
source,
/onOverlayPointerRecoveryRequested:\s*onOverlayPointerRecoveryRequestEvent,/,
);
});