mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-09-27 20:11:15 +02:00
Compare commits
4 Commits
9975b2b583
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d09cf1b5d | ||
|
|
c80d65483a | ||
|
|
d11c0f9839 | ||
|
|
1e0b2affee |
10
.gitignore
vendored
10
.gitignore
vendored
@@ -13,8 +13,14 @@
|
|||||||
config/config.dev.json
|
config/config.dev.json
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
/.idea
|
.idea/
|
||||||
/.vscode
|
.vscode/
|
||||||
|
.zed/
|
||||||
|
|
||||||
|
# OS generated files
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
# Linux executable
|
# Linux executable
|
||||||
ffmpeg
|
ffmpeg
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ async function downloadUpdate() {
|
|||||||
await autoUpdater.downloadUpdate();
|
await autoUpdater.downloadUpdate();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("Download failed:", err.message);
|
logger.error("Download failed:", err.message);
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "freedom-loader",
|
"name": "freedom-loader",
|
||||||
"desktopName": "com.masteracnolo.freedomloader",
|
"desktopName": "com.masteracnolo.freedomloader",
|
||||||
"productName": "Freedom Loader",
|
"productName": "Freedom Loader",
|
||||||
"version": "1.6.4-preview",
|
"version": "1.6.4",
|
||||||
"author": "MasterAcnolo <MasterAcnolo@users.noreply.github.com>",
|
"author": "MasterAcnolo <MasterAcnolo@users.noreply.github.com>",
|
||||||
"description": "Free and open-source GUI for yt-dlp — download video and audio from hundreds of platforms",
|
"description": "Free and open-source GUI for yt-dlp — download video and audio from hundreds of platforms",
|
||||||
"homepage": "https://masteracnolo.github.io/Freedom-Loader-Site/",
|
"homepage": "https://masteracnolo.github.io/Freedom-Loader-Site/",
|
||||||
|
|||||||
@@ -45,13 +45,31 @@ async function initUpdateUI() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
btn.onclick = () => {
|
const initialButtonText = btn.textContent;
|
||||||
window.electronAPI.downloadUpdate();
|
const initialIconText = icon.textContent;
|
||||||
|
const initialTitleText = title.textContent;
|
||||||
|
const initialSubText = sub.textContent;
|
||||||
|
|
||||||
|
btn.onclick = async () => {
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
btn.textContent = "Downloading...";
|
btn.textContent = "Downloading...";
|
||||||
icon.textContent = "download";
|
icon.textContent = "download";
|
||||||
title.textContent = "Downloading update";
|
title.textContent = "Downloading update";
|
||||||
progressWrap.style.display = "flex";
|
progressWrap.style.display = "flex";
|
||||||
|
|
||||||
|
try {
|
||||||
|
await window.electronAPI.downloadUpdate();
|
||||||
|
} catch {
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.textContent = initialButtonText;
|
||||||
|
icon.textContent = initialIconText;
|
||||||
|
title.textContent = initialTitleText;
|
||||||
|
sub.textContent = initialSubText;
|
||||||
|
progressWrap.style.display = "none";
|
||||||
|
progressFill.style.width = "0%";
|
||||||
|
progressPct.textContent = "0%";
|
||||||
|
progressEta.textContent = "";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.electronAPI.onDownloadProgress((progress) => {
|
window.electronAPI.onDownloadProgress((progress) => {
|
||||||
|
|||||||
53
test/unit/autoUpdater.test.js
Normal file
53
test/unit/autoUpdater.test.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
const mockDownloadUpdate = jest.fn();
|
||||||
|
const mockCheckForUpdates = jest.fn();
|
||||||
|
const mockOn = jest.fn();
|
||||||
|
const mockQuitAndInstall = jest.fn();
|
||||||
|
|
||||||
|
jest.mock("electron-updater", () => ({
|
||||||
|
autoUpdater: {
|
||||||
|
autoDownload: true,
|
||||||
|
autoInstallOnAppQuit: true,
|
||||||
|
on: mockOn,
|
||||||
|
checkForUpdates: mockCheckForUpdates,
|
||||||
|
downloadUpdate: mockDownloadUpdate,
|
||||||
|
quitAndInstall: mockQuitAndInstall,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
jest.mock("electron", () => ({
|
||||||
|
app: {
|
||||||
|
isPackaged: true,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const mockLoggerError = jest.fn();
|
||||||
|
jest.mock("../../server/logger", () => ({
|
||||||
|
logger: {
|
||||||
|
info: jest.fn(),
|
||||||
|
warn: jest.fn(),
|
||||||
|
error: mockLoggerError,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const { downloadUpdate } = require("../../app/autoUpdater");
|
||||||
|
|
||||||
|
describe("autoUpdater.downloadUpdate", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("resolves when electron-updater download succeeds", async () => {
|
||||||
|
mockDownloadUpdate.mockResolvedValue(undefined);
|
||||||
|
|
||||||
|
await expect(downloadUpdate()).resolves.toBeUndefined();
|
||||||
|
expect(mockDownloadUpdate).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("rejects when electron-updater download fails", async () => {
|
||||||
|
const error = new Error("network down");
|
||||||
|
mockDownloadUpdate.mockRejectedValue(error);
|
||||||
|
|
||||||
|
await expect(downloadUpdate()).rejects.toThrow("network down");
|
||||||
|
expect(mockLoggerError).toHaveBeenCalledWith("Download failed:", "network down");
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user