mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-15 08:12:53 -07:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4cb0dbfaad | |||
|
801cdcafca
|
@@ -0,0 +1,4 @@
|
||||
type: internal
|
||||
area: tests
|
||||
|
||||
- Removed stale Yomitan vendor source-inspection assertions for changes that were not shipped.
|
||||
@@ -1,5 +1,5 @@
|
||||
const DOCS_HOSTNAME = 'https://docs.subminer.moe';
|
||||
const PLAUSIBLE_PROXY_HOSTNAME = 'https://worker.subminer.moe';
|
||||
const PLAUSIBLE_PROXY_HOSTNAME = 'https://worker.sudacode.com';
|
||||
const PLAUSIBLE_SITE_SCRIPT_PATH = '/js/pa-h28Pn9ppgTJRmiSJlyPT6.js';
|
||||
const PLAUSIBLE_ENDPOINT = `${PLAUSIBLE_PROXY_HOSTNAME}/api/event`;
|
||||
const PLAUSIBLE_INIT_SCRIPT = [
|
||||
|
||||
@@ -11,7 +11,7 @@ const docsPackageContents = readFileSync(docsPackagePath, 'utf8');
|
||||
test('docs site loads the docs.subminer.moe Plausible script through the analytics proxy', () => {
|
||||
expect(docsConfigContents).toContain("const DOCS_HOSTNAME = 'https://docs.subminer.moe'");
|
||||
expect(docsConfigContents).toContain(
|
||||
"const PLAUSIBLE_PROXY_HOSTNAME = 'https://worker.subminer.moe'",
|
||||
"const PLAUSIBLE_PROXY_HOSTNAME = 'https://worker.sudacode.com'",
|
||||
);
|
||||
expect(docsConfigContents).toContain(
|
||||
"const PLAUSIBLE_SITE_SCRIPT_PATH = '/js/pa-h28Pn9ppgTJRmiSJlyPT6.js'",
|
||||
|
||||
@@ -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[] = [];
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user