mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-01 06:22:44 -08:00
pretty
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { runStartupBootstrapRuntime } from "./startup";
|
||||
import { CliArgs } from "../../cli/args";
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { runStartupBootstrapRuntime } from './startup';
|
||||
import { CliArgs } from '../../cli/args';
|
||||
|
||||
function makeArgs(overrides: Partial<CliArgs> = {}): CliArgs {
|
||||
return {
|
||||
@@ -51,136 +51,127 @@ function makeArgs(overrides: Partial<CliArgs> = {}): CliArgs {
|
||||
};
|
||||
}
|
||||
|
||||
test("runStartupBootstrapRuntime configures startup state and starts lifecycle", () => {
|
||||
test('runStartupBootstrapRuntime configures startup state and starts lifecycle', () => {
|
||||
const calls: string[] = [];
|
||||
const args = makeArgs({
|
||||
logLevel: "debug",
|
||||
socketPath: "/tmp/custom.sock",
|
||||
logLevel: 'debug',
|
||||
socketPath: '/tmp/custom.sock',
|
||||
texthookerPort: 9001,
|
||||
backend: "x11",
|
||||
backend: 'x11',
|
||||
autoStartOverlay: true,
|
||||
texthooker: true,
|
||||
});
|
||||
|
||||
const result = runStartupBootstrapRuntime({
|
||||
argv: ["node", "main.ts", "--log-level", "debug"],
|
||||
argv: ['node', 'main.ts', '--log-level', 'debug'],
|
||||
parseArgs: () => args,
|
||||
setLogLevel: (level, source) => calls.push(`setLog:${level}:${source}`),
|
||||
forceX11Backend: () => calls.push("forceX11"),
|
||||
enforceUnsupportedWaylandMode: () => calls.push("enforceWayland"),
|
||||
getDefaultSocketPath: () => "/tmp/default.sock",
|
||||
forceX11Backend: () => calls.push('forceX11'),
|
||||
enforceUnsupportedWaylandMode: () => calls.push('enforceWayland'),
|
||||
getDefaultSocketPath: () => '/tmp/default.sock',
|
||||
defaultTexthookerPort: 5174,
|
||||
runGenerateConfigFlow: () => false,
|
||||
startAppLifecycle: () => calls.push("startLifecycle"),
|
||||
startAppLifecycle: () => calls.push('startLifecycle'),
|
||||
});
|
||||
|
||||
assert.equal(result.initialArgs, args);
|
||||
assert.equal(result.mpvSocketPath, "/tmp/custom.sock");
|
||||
assert.equal(result.mpvSocketPath, '/tmp/custom.sock');
|
||||
assert.equal(result.texthookerPort, 9001);
|
||||
assert.equal(result.backendOverride, "x11");
|
||||
assert.equal(result.backendOverride, 'x11');
|
||||
assert.equal(result.autoStartOverlay, true);
|
||||
assert.equal(result.texthookerOnlyMode, true);
|
||||
assert.deepEqual(calls, [
|
||||
"setLog:debug:cli",
|
||||
"forceX11",
|
||||
"enforceWayland",
|
||||
"startLifecycle",
|
||||
]);
|
||||
assert.deepEqual(calls, ['setLog:debug:cli', 'forceX11', 'enforceWayland', 'startLifecycle']);
|
||||
});
|
||||
|
||||
test("runStartupBootstrapRuntime keeps log-level precedence for repeated calls", () => {
|
||||
test('runStartupBootstrapRuntime keeps log-level precedence for repeated calls', () => {
|
||||
const calls: string[] = [];
|
||||
const args = makeArgs({
|
||||
logLevel: "warn",
|
||||
logLevel: 'warn',
|
||||
});
|
||||
|
||||
runStartupBootstrapRuntime({
|
||||
argv: ["node", "main.ts", "--log-level", "warn"],
|
||||
argv: ['node', 'main.ts', '--log-level', 'warn'],
|
||||
parseArgs: () => args,
|
||||
setLogLevel: (level, source) => calls.push(`setLog:${level}:${source}`),
|
||||
forceX11Backend: () => calls.push("forceX11"),
|
||||
enforceUnsupportedWaylandMode: () => calls.push("enforceWayland"),
|
||||
getDefaultSocketPath: () => "/tmp/default.sock",
|
||||
forceX11Backend: () => calls.push('forceX11'),
|
||||
enforceUnsupportedWaylandMode: () => calls.push('enforceWayland'),
|
||||
getDefaultSocketPath: () => '/tmp/default.sock',
|
||||
defaultTexthookerPort: 5174,
|
||||
runGenerateConfigFlow: () => false,
|
||||
startAppLifecycle: () => calls.push("startLifecycle"),
|
||||
startAppLifecycle: () => calls.push('startLifecycle'),
|
||||
});
|
||||
|
||||
assert.deepEqual(calls.slice(0, 3), [
|
||||
"setLog:warn:cli",
|
||||
"forceX11",
|
||||
"enforceWayland",
|
||||
]);
|
||||
assert.deepEqual(calls.slice(0, 3), ['setLog:warn:cli', 'forceX11', 'enforceWayland']);
|
||||
});
|
||||
|
||||
test("runStartupBootstrapRuntime remains lifecycle-stable with Jellyfin CLI flags", () => {
|
||||
test('runStartupBootstrapRuntime remains lifecycle-stable with Jellyfin CLI flags', () => {
|
||||
const calls: string[] = [];
|
||||
const args = makeArgs({
|
||||
jellyfin: true,
|
||||
jellyfinLibraries: true,
|
||||
socketPath: "/tmp/stable.sock",
|
||||
socketPath: '/tmp/stable.sock',
|
||||
texthookerPort: 8888,
|
||||
});
|
||||
|
||||
const result = runStartupBootstrapRuntime({
|
||||
argv: ["node", "main.ts", "--jellyfin", "--jellyfin-libraries"],
|
||||
argv: ['node', 'main.ts', '--jellyfin', '--jellyfin-libraries'],
|
||||
parseArgs: () => args,
|
||||
setLogLevel: (level, source) => calls.push(`setLog:${level}:${source}`),
|
||||
forceX11Backend: () => calls.push("forceX11"),
|
||||
enforceUnsupportedWaylandMode: () => calls.push("enforceWayland"),
|
||||
getDefaultSocketPath: () => "/tmp/default.sock",
|
||||
forceX11Backend: () => calls.push('forceX11'),
|
||||
enforceUnsupportedWaylandMode: () => calls.push('enforceWayland'),
|
||||
getDefaultSocketPath: () => '/tmp/default.sock',
|
||||
defaultTexthookerPort: 5174,
|
||||
runGenerateConfigFlow: () => false,
|
||||
startAppLifecycle: () => calls.push("startLifecycle"),
|
||||
startAppLifecycle: () => calls.push('startLifecycle'),
|
||||
});
|
||||
|
||||
assert.equal(result.mpvSocketPath, "/tmp/stable.sock");
|
||||
assert.equal(result.mpvSocketPath, '/tmp/stable.sock');
|
||||
assert.equal(result.texthookerPort, 8888);
|
||||
assert.equal(result.backendOverride, null);
|
||||
assert.equal(result.autoStartOverlay, false);
|
||||
assert.equal(result.texthookerOnlyMode, false);
|
||||
assert.deepEqual(calls, ["forceX11", "enforceWayland", "startLifecycle"]);
|
||||
assert.deepEqual(calls, ['forceX11', 'enforceWayland', 'startLifecycle']);
|
||||
});
|
||||
|
||||
test("runStartupBootstrapRuntime keeps --debug separate from log verbosity", () => {
|
||||
test('runStartupBootstrapRuntime keeps --debug separate from log verbosity', () => {
|
||||
const calls: string[] = [];
|
||||
const args = makeArgs({
|
||||
debug: true,
|
||||
});
|
||||
|
||||
runStartupBootstrapRuntime({
|
||||
argv: ["node", "main.ts", "--debug"],
|
||||
argv: ['node', 'main.ts', '--debug'],
|
||||
parseArgs: () => args,
|
||||
setLogLevel: (level, source) => calls.push(`setLog:${level}:${source}`),
|
||||
forceX11Backend: () => calls.push("forceX11"),
|
||||
enforceUnsupportedWaylandMode: () => calls.push("enforceWayland"),
|
||||
getDefaultSocketPath: () => "/tmp/default.sock",
|
||||
forceX11Backend: () => calls.push('forceX11'),
|
||||
enforceUnsupportedWaylandMode: () => calls.push('enforceWayland'),
|
||||
getDefaultSocketPath: () => '/tmp/default.sock',
|
||||
defaultTexthookerPort: 5174,
|
||||
runGenerateConfigFlow: () => false,
|
||||
startAppLifecycle: () => calls.push("startLifecycle"),
|
||||
startAppLifecycle: () => calls.push('startLifecycle'),
|
||||
});
|
||||
|
||||
assert.deepEqual(calls, ["forceX11", "enforceWayland", "startLifecycle"]);
|
||||
assert.deepEqual(calls, ['forceX11', 'enforceWayland', 'startLifecycle']);
|
||||
});
|
||||
|
||||
test("runStartupBootstrapRuntime skips lifecycle when generate-config flow handled", () => {
|
||||
test('runStartupBootstrapRuntime skips lifecycle when generate-config flow handled', () => {
|
||||
const calls: string[] = [];
|
||||
const args = makeArgs({ generateConfig: true, logLevel: "warn" });
|
||||
const args = makeArgs({ generateConfig: true, logLevel: 'warn' });
|
||||
|
||||
const result = runStartupBootstrapRuntime({
|
||||
argv: ["node", "main.ts", "--generate-config"],
|
||||
argv: ['node', 'main.ts', '--generate-config'],
|
||||
parseArgs: () => args,
|
||||
setLogLevel: (level, source) => calls.push(`setLog:${level}:${source}`),
|
||||
forceX11Backend: () => calls.push("forceX11"),
|
||||
enforceUnsupportedWaylandMode: () => calls.push("enforceWayland"),
|
||||
getDefaultSocketPath: () => "/tmp/default.sock",
|
||||
forceX11Backend: () => calls.push('forceX11'),
|
||||
enforceUnsupportedWaylandMode: () => calls.push('enforceWayland'),
|
||||
getDefaultSocketPath: () => '/tmp/default.sock',
|
||||
defaultTexthookerPort: 5174,
|
||||
runGenerateConfigFlow: () => true,
|
||||
startAppLifecycle: () => calls.push("startLifecycle"),
|
||||
startAppLifecycle: () => calls.push('startLifecycle'),
|
||||
});
|
||||
|
||||
assert.equal(result.mpvSocketPath, "/tmp/default.sock");
|
||||
assert.equal(result.mpvSocketPath, '/tmp/default.sock');
|
||||
assert.equal(result.texthookerPort, 5174);
|
||||
assert.equal(result.backendOverride, null);
|
||||
assert.deepEqual(calls, ["setLog:warn:cli", "forceX11", "enforceWayland"]);
|
||||
assert.deepEqual(calls, ['setLog:warn:cli', 'forceX11', 'enforceWayland']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user