mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-12 03:13:39 -07:00
test: address runtime nitpick coverage
This commit is contained in:
@@ -16,3 +16,13 @@ test('setMpvCurrentSecondarySubText uses client setter when available', () => {
|
||||
assert.deepEqual(calls, ['secondary']);
|
||||
assert.equal(client.currentSecondarySubText, '');
|
||||
});
|
||||
|
||||
test('setMpvCurrentSecondarySubText updates client property when setter is unavailable', () => {
|
||||
const client = {
|
||||
currentSecondarySubText: '',
|
||||
};
|
||||
|
||||
setMpvCurrentSecondarySubText(client, 'secondary');
|
||||
|
||||
assert.equal(client.currentSecondarySubText, 'secondary');
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
shouldClearAppStateStatsServerOnStop,
|
||||
} from './stats-server-runtime';
|
||||
|
||||
test('background stats daemon state owned by the current process is stale for stop flow', () => {
|
||||
test('detects self-owned background stats daemon state', () => {
|
||||
assert.equal(
|
||||
isSelfOwnedBackgroundStatsDaemonState({ pid: process.pid, port: 6969, startedAtMs: 1 }),
|
||||
true,
|
||||
|
||||
@@ -18,3 +18,26 @@ test('runSupportAssetUpdatesForLauncherResult logs support-asset errors and pres
|
||||
assert.equal(result, launcherResult);
|
||||
assert.deepEqual(warnings, ['Support asset update failed after launcher update:archive failed']);
|
||||
});
|
||||
|
||||
test('runSupportAssetUpdatesForLauncherResult uses support asset description in skip warnings', async () => {
|
||||
const warnings: string[] = [];
|
||||
const launcherResult = { status: 'updated' } as const;
|
||||
|
||||
const result = await runSupportAssetUpdatesForLauncherResult({
|
||||
launcherResult,
|
||||
assetDescription: 'Support asset update',
|
||||
updateSupportAssets: async () => [
|
||||
{ status: 'protected', command: 'install-theme' },
|
||||
{ status: 'hash-mismatch', message: 'checksum failed' },
|
||||
],
|
||||
logWarn: (message) => {
|
||||
warnings.push(message);
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(result, launcherResult);
|
||||
assert.deepEqual(warnings, [
|
||||
'Support asset update requires manual command: install-theme',
|
||||
'Support asset update skipped: checksum failed',
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -82,6 +82,7 @@ export function createUpdateServiceRuntime(deps: UpdateServiceRuntimeDeps): {
|
||||
});
|
||||
return runSupportAssetUpdatesForLauncherResult({
|
||||
launcherResult,
|
||||
assetDescription: 'Support asset update',
|
||||
updateSupportAssets: () =>
|
||||
updateSupportAssetsFromRelease({
|
||||
release,
|
||||
|
||||
@@ -3,16 +3,18 @@ export async function runSupportAssetUpdatesForLauncherResult<
|
||||
TSupportResult extends { status: string; command?: string; message?: string },
|
||||
>(options: {
|
||||
launcherResult: TLauncherResult;
|
||||
assetDescription?: string;
|
||||
updateSupportAssets: () => Promise<TSupportResult[]>;
|
||||
logWarn: (message: string, details?: unknown) => void;
|
||||
}): Promise<TLauncherResult> {
|
||||
const assetDescription = options.assetDescription ?? 'Support asset update';
|
||||
try {
|
||||
const supportResults = await options.updateSupportAssets();
|
||||
for (const result of supportResults) {
|
||||
if (result.status === 'protected' && result.command) {
|
||||
options.logWarn(`Rofi theme update requires manual command: ${result.command}`);
|
||||
options.logWarn(`${assetDescription} requires manual command: ${result.command}`);
|
||||
} else if (result.status === 'hash-mismatch' || result.status === 'missing-asset') {
|
||||
options.logWarn(`Rofi theme update skipped: ${result.message ?? result.status}`);
|
||||
options.logWarn(`${assetDescription} skipped: ${result.message ?? result.status}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user