mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-20 12:11:28 -07:00
- Return status from `openYomitanSettings` and show user-facing warning when external read-only profile mode blocks settings - Thread `yomitanSession` through settings runtime/opener deps so settings window uses the active session - Expand tests for session forwarding and external profile path propagation - Move AniList setup/token/CLI docs into the AniList section in configuration docs
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { createOpenYomitanSettingsHandler } from './yomitan-settings-opener';
|
|
|
|
test('yomitan opener warns when extension cannot be loaded', async () => {
|
|
const logs: string[] = [];
|
|
const openSettings = createOpenYomitanSettingsHandler({
|
|
ensureYomitanExtensionLoaded: async () => null,
|
|
openYomitanSettingsWindow: () => {
|
|
throw new Error('should not open');
|
|
},
|
|
getExistingWindow: () => null,
|
|
setWindow: () => {},
|
|
logWarn: (message) => logs.push(message),
|
|
logError: () => logs.push('error'),
|
|
});
|
|
|
|
openSettings();
|
|
await Promise.resolve();
|
|
await Promise.resolve();
|
|
assert.ok(logs.includes('Unable to open Yomitan settings: extension failed to load.'));
|
|
});
|
|
|
|
test('yomitan opener opens settings window when extension is available', async () => {
|
|
let opened = false;
|
|
const yomitanSession = { id: 'session' };
|
|
const openSettings = createOpenYomitanSettingsHandler({
|
|
ensureYomitanExtensionLoaded: async () => ({ id: 'ext' }),
|
|
openYomitanSettingsWindow: ({ yomitanSession: forwardedSession }) => {
|
|
opened = (forwardedSession as { id: string } | null)?.id === 'session';
|
|
},
|
|
getExistingWindow: () => null,
|
|
setWindow: () => {},
|
|
getYomitanSession: () => yomitanSession,
|
|
logWarn: () => {},
|
|
logError: () => {},
|
|
});
|
|
|
|
openSettings();
|
|
await Promise.resolve();
|
|
await Promise.resolve();
|
|
assert.equal(opened, true);
|
|
});
|