mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 12:55:16 -07:00
fix: rename Windows ZIPs and fix macOS manual update checks (#81)
This commit is contained in:
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { shouldFetchReleaseMetadataForPlatform } from './release-metadata-policy';
|
||||
|
||||
test('macOS release metadata fetch is skipped only when native updater is unsupported', () => {
|
||||
test('macOS automatic release metadata fetch is skipped when native updater is unsupported', () => {
|
||||
assert.equal(
|
||||
shouldFetchReleaseMetadataForPlatform('darwin', {
|
||||
available: false,
|
||||
@@ -28,6 +28,33 @@ test('macOS release metadata fetch is skipped only when native updater is unsupp
|
||||
);
|
||||
});
|
||||
|
||||
test('macOS manual checks fetch release metadata when native updater is unsupported', () => {
|
||||
const unsupportedUpdate = {
|
||||
available: false,
|
||||
version: '0.15.0-beta.4',
|
||||
canUpdate: false,
|
||||
};
|
||||
|
||||
assert.equal(
|
||||
shouldFetchReleaseMetadataForPlatform('darwin', unsupportedUpdate, {
|
||||
source: 'manual',
|
||||
}),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
shouldFetchReleaseMetadataForPlatform('darwin', unsupportedUpdate, {
|
||||
source: 'launcher',
|
||||
}),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
shouldFetchReleaseMetadataForPlatform('darwin', unsupportedUpdate, {
|
||||
source: 'automatic',
|
||||
}),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('non-macOS release metadata fetch is not gated by native updater support', () => {
|
||||
assert.equal(
|
||||
shouldFetchReleaseMetadataForPlatform('linux', {
|
||||
|
||||
@@ -4,12 +4,20 @@ type AppUpdateMetadata = {
|
||||
canUpdate?: boolean;
|
||||
};
|
||||
|
||||
type UpdateMetadataRequest = {
|
||||
source?: 'manual' | 'automatic' | 'launcher';
|
||||
};
|
||||
|
||||
export function shouldFetchReleaseMetadataForPlatform(
|
||||
platform: NodeJS.Platform,
|
||||
appUpdate: AppUpdateMetadata,
|
||||
request: UpdateMetadataRequest = {},
|
||||
): boolean {
|
||||
if (platform !== 'darwin') {
|
||||
return true;
|
||||
}
|
||||
return appUpdate.canUpdate !== false;
|
||||
if (appUpdate.canUpdate !== false) {
|
||||
return true;
|
||||
}
|
||||
return request.source === 'manual' || request.source === 'launcher';
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { shouldFetchReleaseMetadataForPlatform } from './release-metadata-policy';
|
||||
import { createUpdateService, type UpdateServiceDeps, type UpdateState } from './update-service';
|
||||
|
||||
function createDeps(overrides: Partial<UpdateServiceDeps> = {}) {
|
||||
@@ -362,6 +363,57 @@ test('manual prerelease update check uses prerelease release and launcher channe
|
||||
]);
|
||||
});
|
||||
|
||||
test('manual macOS prerelease check reports GitHub update when native updater is unsupported', async () => {
|
||||
const { deps, calls } = createDeps({
|
||||
getConfig: () => ({
|
||||
enabled: true,
|
||||
checkIntervalHours: 24,
|
||||
notificationType: 'system',
|
||||
channel: 'prerelease',
|
||||
}),
|
||||
getCurrentVersion: () => '0.15.0-beta.4',
|
||||
checkAppUpdate: async (channel) => {
|
||||
calls.push(`app:${channel}`);
|
||||
return {
|
||||
available: false,
|
||||
version: '0.15.0-beta.4',
|
||||
canUpdate: false,
|
||||
};
|
||||
},
|
||||
shouldFetchReleaseMetadata: ({ request, appUpdate }) =>
|
||||
shouldFetchReleaseMetadataForPlatform('darwin', appUpdate, request),
|
||||
fetchLatestStableRelease: async (channel) => {
|
||||
calls.push(`fetch:${channel}`);
|
||||
return {
|
||||
tag_name: 'v0.15.0-beta.5',
|
||||
prerelease: true,
|
||||
draft: false,
|
||||
assets: [],
|
||||
};
|
||||
},
|
||||
showUpdateAvailableDialog: async (version) => {
|
||||
calls.push(`available-dialog:${version}`);
|
||||
return 'update';
|
||||
},
|
||||
updateLauncher: async (_launcherPath, channel, release) => {
|
||||
calls.push(`launcher:${channel}:${release?.tag_name ?? 'none'}`);
|
||||
return { status: 'skipped' };
|
||||
},
|
||||
});
|
||||
const service = createUpdateService(deps);
|
||||
|
||||
const result = await service.checkForUpdates({ source: 'manual' });
|
||||
|
||||
assert.equal(result.status, 'update-available');
|
||||
assert.deepEqual(calls, [
|
||||
'app:prerelease',
|
||||
'fetch:prerelease',
|
||||
'available-dialog:0.15.0-beta.5',
|
||||
'launcher:prerelease:v0.15.0-beta.5',
|
||||
'manual-install:0.15.0-beta.5',
|
||||
]);
|
||||
});
|
||||
|
||||
test('manual update check keeps current prerelease builds on configured stable channel', async () => {
|
||||
const { deps, calls } = createDeps({
|
||||
getCurrentVersion: () => '0.15.0-beta.3',
|
||||
|
||||
Reference in New Issue
Block a user