fix(accounts): refresh status before enabling accounts
Validate Real-Debrid, Mega-Debrid, and Debrid-Link accounts silently before exposing a newly enabled account to active downloads. Keep the row toggle optimistic, skip network checks while disabling, persist direct account-check results, and avoid the browser-login race for an already authenticated Real-Debrid web session.
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
pruneAccountRowSelection,
|
||||
resolveAccountUsername,
|
||||
resolveVisibleAccountKind,
|
||||
runAccountEnableRefresh,
|
||||
sortAccountServices
|
||||
} from "../src/renderer/account-ui";
|
||||
import * as accountUi from "../src/renderer/account-ui";
|
||||
@@ -134,3 +135,27 @@ describe("account usernames", () => {
|
||||
expect(resolveAccountUsername("", undefined)).toBe("—");
|
||||
});
|
||||
});
|
||||
|
||||
describe("account activation refresh", () => {
|
||||
it("checks an account before enabling it", async () => {
|
||||
const events: string[] = [];
|
||||
|
||||
await runAccountEnableRefresh(
|
||||
async () => { events.push("check"); },
|
||||
async () => { events.push("persist"); }
|
||||
);
|
||||
|
||||
expect(events).toEqual(["check", "persist"]);
|
||||
});
|
||||
|
||||
it("does not check an account while disabling it", async () => {
|
||||
const events: string[] = [];
|
||||
|
||||
await runAccountEnableRefresh(
|
||||
undefined,
|
||||
async () => { events.push("persist"); }
|
||||
);
|
||||
|
||||
expect(events).toEqual(["persist"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user