mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 04:46:07 -08:00
test: cut low-value tests, rewrite the rest around behavior, parallelize lanes (#285)
This commit is contained in:
1 parent
4b6842d034
commit
b48083ddd8
368 files changed
+18045
-60331
No files matched your search
@@ -3,7 +3,6 @@ import assert from 'node:assert/strict';
|
||||
import {
|
||||
configureAutoUpdater,
|
||||
createElectronAppUpdater,
|
||||
isKnownLinuxPackageManagedAppImage,
|
||||
isNativeUpdaterSupported,
|
||||
resolveMacAppBundlePath,
|
||||
type ElectronAutoUpdaterLike,
|
||||
@@ -308,14 +307,6 @@ test('linux native updater is unsupported for package-managed AppImage installs'
|
||||
]);
|
||||
});
|
||||
|
||||
test('known Linux package-managed AppImage detection follows the canonical AUR path', () => {
|
||||
assert.equal(isKnownLinuxPackageManagedAppImage('/opt/SubMiner/SubMiner.AppImage'), true);
|
||||
assert.equal(
|
||||
isKnownLinuxPackageManagedAppImage('/home/tester/.local/bin/SubMiner.AppImage'),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('windows native updater is supported for packaged builds', async () => {
|
||||
const supported = await isNativeUpdaterSupported({
|
||||
platform: 'win32',
|
||||
|
||||
@@ -1,67 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createCurlFetch, createElectronNetFetch, createGlobalFetch } from './fetch-adapter';
|
||||
import type { FetchResponseLike } from './release-assets';
|
||||
|
||||
test('createElectronNetFetch delegates updater requests to Electron net.fetch', async () => {
|
||||
const calls: Array<{ url: string; init?: Record<string, unknown> }> = [];
|
||||
const response: FetchResponseLike = {
|
||||
ok: true,
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
json: async () => ({ ok: true }),
|
||||
text: async () => 'ok',
|
||||
arrayBuffer: async () => new ArrayBuffer(0),
|
||||
};
|
||||
|
||||
const fetch = createElectronNetFetch({
|
||||
fetch: async (url, init) => {
|
||||
calls.push({ url, init });
|
||||
return response;
|
||||
},
|
||||
});
|
||||
|
||||
const result = await fetch('https://api.github.com/repos/ksyasuda/SubMiner/releases', {
|
||||
headers: { 'User-Agent': 'SubMiner updater' },
|
||||
});
|
||||
|
||||
assert.equal(result, response);
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
url: 'https://api.github.com/repos/ksyasuda/SubMiner/releases',
|
||||
init: { headers: { 'User-Agent': 'SubMiner updater' } },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('createGlobalFetch delegates updater requests to main-process fetch', async () => {
|
||||
const calls: Array<{ url: string; init?: RequestInit }> = [];
|
||||
const response: FetchResponseLike = {
|
||||
ok: true,
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
json: async () => ({ ok: true }),
|
||||
text: async () => 'ok',
|
||||
arrayBuffer: async () => new ArrayBuffer(0),
|
||||
};
|
||||
|
||||
const fetch = createGlobalFetch(async (url, init) => {
|
||||
calls.push({ url, init });
|
||||
return response;
|
||||
});
|
||||
|
||||
const result = await fetch('https://api.github.com/repos/ksyasuda/SubMiner/releases', {
|
||||
headers: { 'User-Agent': 'SubMiner updater' },
|
||||
});
|
||||
|
||||
assert.equal(result, response);
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
url: 'https://api.github.com/repos/ksyasuda/SubMiner/releases',
|
||||
init: { headers: { 'User-Agent': 'SubMiner updater' } } as RequestInit,
|
||||
},
|
||||
]);
|
||||
});
|
||||
import { createCurlFetch } from './fetch-adapter';
|
||||
|
||||
test('createCurlFetch requests updater metadata without Electron networking', async () => {
|
||||
const calls: Array<{
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
createUpdateDialogPresenter,
|
||||
showManualUpdateRequiredDialog,
|
||||
type ShowMessageBox,
|
||||
} from './update-dialogs';
|
||||
import { createUpdateDialogPresenter, type ShowMessageBox } from './update-dialogs';
|
||||
|
||||
test('update dialog presenter focuses app and yields the run loop before showing macOS dialogs', async () => {
|
||||
const calls: string[] = [];
|
||||
@@ -169,26 +165,3 @@ test('update dialog presenter still shows macOS dialog when yielding fails', asy
|
||||
|
||||
assert.deepEqual(calls, ['focus', 'yield', 'dialog:SubMiner is up to date (v0.14.0)']);
|
||||
});
|
||||
|
||||
test('manual update required dialog explains that automatic install is unavailable', async () => {
|
||||
let shown:
|
||||
| {
|
||||
type?: string;
|
||||
title?: string;
|
||||
message: string;
|
||||
detail?: string;
|
||||
buttons?: string[];
|
||||
}
|
||||
| undefined;
|
||||
const showMessageBox: ShowMessageBox = async (options) => {
|
||||
shown = options;
|
||||
return { response: 0 };
|
||||
};
|
||||
|
||||
await showManualUpdateRequiredDialog(showMessageBox, '0.15.0-beta.1');
|
||||
|
||||
assert.equal(shown?.type, 'warning');
|
||||
assert.equal(shown?.message, 'Manual install required');
|
||||
assert.match(shown?.detail ?? '', /SubMiner v0\.15\.0-beta\.1 is available/);
|
||||
assert.match(shown?.detail ?? '', /cannot install app updates automatically/);
|
||||
});
|
||||
Reference in new issue
Block a user