feat: preserve speed history and improve account setup

This commit is contained in:
Sucukdeluxe
2026-08-09 14:59:52 +02:00
parent 403051e3cf
commit 29bdf589eb
13 changed files with 279 additions and 132 deletions
+14
View File
@@ -0,0 +1,14 @@
import { describe, expect, it } from "vitest";
import { matchesAccountModeFilter } from "../src/renderer/account-ui";
describe("account mode filter", () => {
it("shows only API options for the API filter", () => {
expect(matchesAccountModeFilter({ modeLabel: "API" }, "api")).toBe(true);
expect(matchesAccountModeFilter({ modeLabel: "Web-Login" }, "api")).toBe(false);
});
it("shows Web-Login options for the Web filter", () => {
expect(matchesAccountModeFilter({ modeLabel: "Web-Login" }, "web")).toBe(true);
expect(matchesAccountModeFilter({ modeLabel: "API" }, "web")).toBe(false);
});
});
+22
View File
@@ -0,0 +1,22 @@
import { describe, expect, it } from "vitest";
import { updateDownloadSpeedHistory } from "../src/renderer/download-speed-state";
describe("download speed history", () => {
it("keeps the smoothed display and history across successive updates", () => {
const first = updateDownloadSpeedHistory({ history: [], display: 0 }, 100, 10);
const second = updateDownloadSpeedHistory(first, 100, 10);
expect(second.display).toBeGreaterThan(first.display);
expect(second.history).toHaveLength(2);
expect(second.history[0]).toBe(first.display);
});
it("keeps only the configured number of samples", () => {
let state = { history: [] as number[], display: 0 };
for (let index = 0; index < 5; index += 1) {
state = updateDownloadSpeedHistory(state, index + 1, 3);
}
expect(state.history).toHaveLength(3);
});
});