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.deepEqual(calls, ['secondary']);
|
||||||
assert.equal(client.currentSecondarySubText, '');
|
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,
|
shouldClearAppStateStatsServerOnStop,
|
||||||
} from './stats-server-runtime';
|
} 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(
|
assert.equal(
|
||||||
isSelfOwnedBackgroundStatsDaemonState({ pid: process.pid, port: 6969, startedAtMs: 1 }),
|
isSelfOwnedBackgroundStatsDaemonState({ pid: process.pid, port: 6969, startedAtMs: 1 }),
|
||||||
true,
|
true,
|
||||||
|
|||||||
@@ -18,3 +18,26 @@ test('runSupportAssetUpdatesForLauncherResult logs support-asset errors and pres
|
|||||||
assert.equal(result, launcherResult);
|
assert.equal(result, launcherResult);
|
||||||
assert.deepEqual(warnings, ['Support asset update failed after launcher update:archive failed']);
|
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({
|
return runSupportAssetUpdatesForLauncherResult({
|
||||||
launcherResult,
|
launcherResult,
|
||||||
|
assetDescription: 'Support asset update',
|
||||||
updateSupportAssets: () =>
|
updateSupportAssets: () =>
|
||||||
updateSupportAssetsFromRelease({
|
updateSupportAssetsFromRelease({
|
||||||
release,
|
release,
|
||||||
|
|||||||
@@ -3,16 +3,18 @@ export async function runSupportAssetUpdatesForLauncherResult<
|
|||||||
TSupportResult extends { status: string; command?: string; message?: string },
|
TSupportResult extends { status: string; command?: string; message?: string },
|
||||||
>(options: {
|
>(options: {
|
||||||
launcherResult: TLauncherResult;
|
launcherResult: TLauncherResult;
|
||||||
|
assetDescription?: string;
|
||||||
updateSupportAssets: () => Promise<TSupportResult[]>;
|
updateSupportAssets: () => Promise<TSupportResult[]>;
|
||||||
logWarn: (message: string, details?: unknown) => void;
|
logWarn: (message: string, details?: unknown) => void;
|
||||||
}): Promise<TLauncherResult> {
|
}): Promise<TLauncherResult> {
|
||||||
|
const assetDescription = options.assetDescription ?? 'Support asset update';
|
||||||
try {
|
try {
|
||||||
const supportResults = await options.updateSupportAssets();
|
const supportResults = await options.updateSupportAssets();
|
||||||
for (const result of supportResults) {
|
for (const result of supportResults) {
|
||||||
if (result.status === 'protected' && result.command) {
|
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') {
|
} 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) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user