mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-09-28 04:21:15 +02:00
Compare commits
2 Commits
1.6.4
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e84a65b59d | ||
|
|
8a11eae28e |
@@ -45,32 +45,13 @@ async function initUpdateUI() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialButtonText = btn.textContent;
|
btn.onclick = () => {
|
||||||
const initialIconText = icon.textContent;
|
window.electronAPI.downloadUpdate();
|
||||||
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) => {
|
||||||
|
|||||||
63
test/unit/sendReport.test.js
Normal file
63
test/unit/sendReport.test.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
jest.mock("../../server/logger", () => ({
|
||||||
|
logger: {
|
||||||
|
info: jest.fn(),
|
||||||
|
warn: jest.fn(),
|
||||||
|
error: jest.fn(),
|
||||||
|
},
|
||||||
|
logDir: null,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const { sendReport } = require("../../app/sendReport");
|
||||||
|
|
||||||
|
describe("sendReport", () => {
|
||||||
|
const originalEnv = { ...process.env };
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
process.env.BUG_REPORT_URL = "";
|
||||||
|
process.env.BUG_REPORT_API_KEY = "";
|
||||||
|
global.fetch = jest.fn();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
process.env = originalEnv;
|
||||||
|
});
|
||||||
|
|
||||||
|
test("throws a clear error when backend bug report config is missing", async () => {
|
||||||
|
await expect(
|
||||||
|
sendReport({
|
||||||
|
title: "Bug title",
|
||||||
|
description: "Bug description",
|
||||||
|
includeLogs: "no",
|
||||||
|
}),
|
||||||
|
).rejects.toThrow(
|
||||||
|
"Bug report service is not configured. Missing BUG_REPORT_URL or BUG_REPORT_API_KEY on backend.",
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(global.fetch).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("sends request from backend when bug report config is present", async () => {
|
||||||
|
process.env.BUG_REPORT_URL = "https://example.com/report";
|
||||||
|
process.env.BUG_REPORT_API_KEY = "safe-test-key";
|
||||||
|
global.fetch.mockResolvedValue({ ok: true });
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
sendReport({
|
||||||
|
title: "Bug title",
|
||||||
|
description: "Bug description",
|
||||||
|
includeLogs: "no",
|
||||||
|
}),
|
||||||
|
).resolves.toBe(true);
|
||||||
|
|
||||||
|
expect(global.fetch).toHaveBeenCalledWith(
|
||||||
|
"https://example.com/report",
|
||||||
|
expect.objectContaining({
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"X-Api-Key": "safe-test-key",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user