fix: harden account rotation and active download recovery
Apply account enablement changes optimistically and persist rapid toggles sequentially without losing clicks. Refresh Mega-Debrid API and Web account pools during active downloads, isolate per-account cancellation budgets, rotate within the same conversion attempt, and keep pause, stop, resume, reset, and no-account gates consistent. Use the native Electron clipboard under Remote Desktop and make support bundle export bounded, redacted, responsive, guarded, visible, and atomic. Add end-to-end regressions for live account switching, persisted partial recovery, support export, native copy, availability preservation, and the 500 ms telemetry cadence.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
SerialTaskQueue,
|
||||
setAccountTargetEnabled,
|
||||
type AccountToggleTarget
|
||||
} from "../src/renderer/account-toggle-queue";
|
||||
|
||||
describe("account toggle queue", () => {
|
||||
it("keeps every rapid mutation and persists them in click order", async () => {
|
||||
const queue = new SerialTaskQueue();
|
||||
const calls: number[] = [];
|
||||
const first = queue.enqueue(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 15));
|
||||
calls.push(1);
|
||||
});
|
||||
const second = queue.enqueue(async () => {
|
||||
calls.push(2);
|
||||
});
|
||||
const third = queue.enqueue(async () => {
|
||||
calls.push(3);
|
||||
});
|
||||
|
||||
await Promise.all([first, second, third]);
|
||||
|
||||
expect(calls).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
it("continues after a failed mutation", async () => {
|
||||
const queue = new SerialTaskQueue();
|
||||
const calls: number[] = [];
|
||||
const failed = queue.enqueue(async () => {
|
||||
calls.push(1);
|
||||
throw new Error("failed");
|
||||
});
|
||||
const recovered = queue.enqueue(async () => {
|
||||
calls.push(2);
|
||||
});
|
||||
|
||||
await expect(failed).rejects.toThrow("failed");
|
||||
await recovered;
|
||||
|
||||
expect(calls).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
it("combines rapid Mega-Debrid Web activations without losing earlier clicks", () => {
|
||||
const accountIds = ["web-1", "web-2", "web-3"];
|
||||
let settings = {
|
||||
disabledProviders: [],
|
||||
debridLinkDisabledKeyIds: [],
|
||||
megaDebridApiDisabledAccountIds: [],
|
||||
megaDebridWebDisabledAccountIds: [...accountIds],
|
||||
megaDebridDisabledAccountIds: [...accountIds]
|
||||
};
|
||||
|
||||
for (const accountId of accountIds) {
|
||||
const target: AccountToggleTarget = { kind: "mega-web", accountId };
|
||||
settings = setAccountTargetEnabled(settings, target, true);
|
||||
}
|
||||
|
||||
expect(settings.megaDebridWebDisabledAccountIds).toEqual([]);
|
||||
expect(settings.megaDebridDisabledAccountIds).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user