mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-18 00:21:41 -07:00
fix(linux): auto-install managed plugin copy; include in asset updates (#127)
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { resolveDefaultNotificationIconPath } from './notification';
|
||||
|
||||
test('default notification icon resolves packaged SubMiner asset when no per-notification icon is provided', () => {
|
||||
const path = resolveDefaultNotificationIconPath({
|
||||
platform: 'linux',
|
||||
resourcesPath: '/opt/SubMiner/resources',
|
||||
appPath: '/opt/SubMiner/resources/app.asar',
|
||||
dirname: '/opt/SubMiner/resources/app.asar/dist/core/utils',
|
||||
cwd: '/opt/SubMiner',
|
||||
joinPath: (...parts) => parts.join('/'),
|
||||
fileExists: (candidate) => candidate === '/opt/SubMiner/resources/assets/SubMiner.png',
|
||||
});
|
||||
|
||||
assert.equal(path, '/opt/SubMiner/resources/assets/SubMiner.png');
|
||||
});
|
||||
|
||||
test('default notification icon prefers the square app icon when bundled images are available', () => {
|
||||
const path = resolveDefaultNotificationIconPath({
|
||||
platform: 'linux',
|
||||
resourcesPath: '/opt/SubMiner/resources',
|
||||
appPath: '/opt/SubMiner/resources/app.asar',
|
||||
dirname: '/opt/SubMiner/resources/app.asar/dist/core/utils',
|
||||
cwd: '/opt/SubMiner',
|
||||
joinPath: (...parts) => parts.join('/'),
|
||||
fileExists: (candidate) =>
|
||||
candidate === '/opt/SubMiner/resources/assets/SubMiner.png' ||
|
||||
candidate === '/opt/SubMiner/resources/assets/SubMiner-square.png',
|
||||
});
|
||||
|
||||
assert.equal(path, '/opt/SubMiner/resources/assets/SubMiner-square.png');
|
||||
});
|
||||
|
||||
test('default notification icon avoids macOS tray template assets', () => {
|
||||
const seen: string[] = [];
|
||||
const path = resolveDefaultNotificationIconPath({
|
||||
platform: 'darwin',
|
||||
resourcesPath: '/Applications/SubMiner.app/Contents/Resources',
|
||||
appPath: '/Applications/SubMiner.app/Contents/Resources/app.asar',
|
||||
dirname: '/Applications/SubMiner.app/Contents/Resources/app.asar/dist/core/utils',
|
||||
cwd: '/Applications/SubMiner.app/Contents/Resources',
|
||||
joinPath: (...parts) => parts.join('/'),
|
||||
fileExists: (candidate) => {
|
||||
seen.push(candidate);
|
||||
return candidate.endsWith('/assets/SubMiner-square.png');
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(path, '/Applications/SubMiner.app/Contents/Resources/assets/SubMiner-square.png');
|
||||
assert.equal(
|
||||
seen.some((candidate) => candidate.includes('SubMinerTemplate')),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('default notification icon resolves cwd fallback through injected deps', () => {
|
||||
const resolvedPath = resolveDefaultNotificationIconPath({
|
||||
platform: 'linux',
|
||||
resourcesPath: '/missing/resources',
|
||||
appPath: '/missing/app',
|
||||
dirname: '/missing/dist/core/utils',
|
||||
cwd: '/portable/SubMiner',
|
||||
joinPath: (...parts) => parts.join('/'),
|
||||
fileExists: (candidate) => candidate === '/portable/SubMiner/assets/SubMiner-square.png',
|
||||
});
|
||||
|
||||
assert.equal(resolvedPath, '/portable/SubMiner/assets/SubMiner-square.png');
|
||||
});
|
||||
Reference in New Issue
Block a user