From 4cb0dbfaad0046407822c2f0105a88f8c8bc0733 Mon Sep 17 00:00:00 2001 From: sudacode Date: Fri, 15 May 2026 03:06:05 -0700 Subject: [PATCH] Remove vendor source-inspection tests from yomitan-settings (#67) --- .../remove-yomitan-vendor-test-assertions.md | 4 ++ src/core/services/yomitan-settings.test.ts | 56 ------------------- src/renderer/handlers/keyboard.test.ts | 1 + 3 files changed, 5 insertions(+), 56 deletions(-) create mode 100644 changes/remove-yomitan-vendor-test-assertions.md diff --git a/changes/remove-yomitan-vendor-test-assertions.md b/changes/remove-yomitan-vendor-test-assertions.md new file mode 100644 index 00000000..85f1529d --- /dev/null +++ b/changes/remove-yomitan-vendor-test-assertions.md @@ -0,0 +1,4 @@ +type: internal +area: tests + +- Removed stale Yomitan vendor source-inspection assertions for changes that were not shipped. diff --git a/src/core/services/yomitan-settings.test.ts b/src/core/services/yomitan-settings.test.ts index 7fd9a608..a438939b 100644 --- a/src/core/services/yomitan-settings.test.ts +++ b/src/core/services/yomitan-settings.test.ts @@ -1,5 +1,4 @@ import assert from 'node:assert/strict'; -import { readFileSync } from 'node:fs'; import test from 'node:test'; import { @@ -9,19 +8,6 @@ import { showYomitanSettingsWindow, } from './yomitan-settings'; -function assertGuardedBySubminerSettingsSafe(source: string, call: string): void { - const callIndex = source.indexOf(call); - assert.notEqual(callIndex, -1, `missing call: ${call}`); - - const beforeCall = source.slice(0, callIndex); - const guardIndex = beforeCall.lastIndexOf('if (!subminerSettingsSafe) {'); - const blockCloseIndex = beforeCall.lastIndexOf('\n }'); - assert.ok( - guardIndex > blockCloseIndex, - `${call} must be inside its own !subminerSettingsSafe startup guard`, - ); -} - test('yomitan settings window removes default app menu quit action', () => { const calls: string[] = []; @@ -40,48 +26,6 @@ test('yomitan settings URL disables the embedded popup preview', () => { ); }); -test('vendored Yomitan settings safe mode skips heavy startup controllers', () => { - const source = readFileSync( - 'vendor/subminer-yomitan/ext/js/pages/settings/settings-main.js', - 'utf8', - ); - - assert.match(source, /subminer-settings-safe/); - assertGuardedBySubminerSettingsSafe(source, 'popupPreviewController.prepare()'); - assertGuardedBySubminerSettingsSafe(source, 'persistentStorageController.prepare()'); - assertGuardedBySubminerSettingsSafe(source, 'storageController.prepare()'); - assertGuardedBySubminerSettingsSafe(source, 'dictionaryController.prepare()'); - assertGuardedBySubminerSettingsSafe(source, 'ankiController.prepare()'); - assert.match(source, /if \(!subminerSettingsSafe\)[\s\S]*new AnkiDeckGeneratorController/); - assert.match(source, /if \(!subminerSettingsSafe\)[\s\S]*new SecondarySearchDictionaryController/); - assert.match(source, /if \(!subminerSettingsSafe\)[\s\S]*new SortFrequencyDictionaryController/); -}); - -test('vendored Yomitan settings caches dictionary metadata requests', () => { - const source = readFileSync( - 'vendor/subminer-yomitan/ext/js/pages/settings/settings-controller.js', - 'utf8', - ); - - assert.match(source, /_dictionaryInfoPromise/); - assert.match(source, /_dictionaryInfoCache/); - assert.match(source, /databaseUpdated/); - assert.match( - source, - /this\._dictionaryInfoPromise = this\._application\.api\.getDictionaryInfo\(\)/, - ); -}); - -test('vendored Yomitan Anki settings reuses SettingsController dictionary metadata cache', () => { - const source = readFileSync( - 'vendor/subminer-yomitan/ext/js/pages/settings/anki-controller.js', - 'utf8', - ); - - assert.match(source, /this\._settingsController\.getDictionaryInfo\(\)/); - assert.doesNotMatch(source, /this\._application\.api\.getDictionaryInfo\(\)/); -}); - test('showYomitanSettingsWindow restores, repaints, shows, and focuses an existing window', () => { const calls: string[] = []; diff --git a/src/renderer/handlers/keyboard.test.ts b/src/renderer/handlers/keyboard.test.ts index ca26f4e5..0147002c 100644 --- a/src/renderer/handlers/keyboard.test.ts +++ b/src/renderer/handlers/keyboard.test.ts @@ -575,6 +575,7 @@ test('numeric selection ignores non-digit keys instead of falling through to oth testGlobals.commandEvents.some((event) => event.type === 'forwardKeyDown'), false, ); + testGlobals.dispatchKeydown({ key: 'Escape', code: 'Escape' }); } finally { testGlobals.restore(); }