fix(settings): restore archive password list
Load the stored archive password list through a dedicated trusted IPC channel when extraction settings are opened. Preserve write-only drafts across settings and account updates, guard unsaved edits against late responses, and invalidate stale loads during backup imports. Prepare version 2.0.46 with public release notes.
This commit is contained in:
@@ -103,4 +103,19 @@ Backup-Passphrase=${echoedPassphrase}`;
|
||||
expect((controller as unknown as { manager: { applyDebridAccountStatuses: ReturnType<typeof vi.fn> } }).manager.applyDebridAccountStatuses)
|
||||
.toHaveBeenCalledWith([expect.objectContaining({ accountId, valid: true })]);
|
||||
});
|
||||
|
||||
it("returns the stored archive password list only through the explicit accessor", () => {
|
||||
const passwords = "fixture-archive-password-one\nfixture-archive-password-two";
|
||||
const controller = createController({ ...defaultSettings(), archivePasswordList: passwords });
|
||||
|
||||
const result = controller.getArchivePasswordList();
|
||||
|
||||
expect(result).toEqual({ passwords });
|
||||
expect((controller as unknown as { audit: ReturnType<typeof vi.fn> }).audit).toHaveBeenCalledWith(
|
||||
"INFO",
|
||||
"Archiv-Passwortliste explizit angezeigt",
|
||||
{ entryCount: 2 }
|
||||
);
|
||||
expect(JSON.stringify((controller as unknown as { audit: ReturnType<typeof vi.fn> }).audit.mock.calls)).not.toContain(passwords);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -97,4 +97,16 @@ describe("account preload contract", () => {
|
||||
);
|
||||
expect(result).toEqual({ secret: "fixture-revealed-secret-7gH8" });
|
||||
});
|
||||
|
||||
it("loads the stored archive password list only through its dedicated channel", async () => {
|
||||
const passwords = "fixture-archive-one\nfixture-archive-two";
|
||||
electron.invoke.mockResolvedValueOnce({ passwords });
|
||||
|
||||
const result = await (electron.api as ElectronApi & {
|
||||
getArchivePasswordList: () => Promise<{ passwords: string }>;
|
||||
}).getArchivePasswordList();
|
||||
|
||||
expect(electron.invoke).toHaveBeenCalledWith(IPC_CHANNELS.GET_ARCHIVE_PASSWORD_LIST);
|
||||
expect(result).toEqual({ passwords });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,4 +39,12 @@ describe("renderer settings validation", () => {
|
||||
expect(validateRendererSettingsUpdate({ columnOrderVersion: undefined }, current)).toEqual({});
|
||||
expect(() => validateRendererSettingsUpdate({ obsoleteSetting: true }, current)).toThrow("Settings-Payload ist ungültig");
|
||||
});
|
||||
|
||||
it("keeps archive passwords out of general renderer settings", () => {
|
||||
const password = "fixture-renderer-hidden-archive-password";
|
||||
const projected = createRendererSettings({ ...defaultSettings(), archivePasswordList: password });
|
||||
|
||||
expect(projected.archivePasswordListConfigured).toBe(true);
|
||||
expect(JSON.stringify(projected)).not.toContain(password);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1124,6 +1124,38 @@ describe("account workspace", () => {
|
||||
});
|
||||
|
||||
describe("settings App integration", () => {
|
||||
it("loads and preserves the stored archive password list in the extraction section", () => {
|
||||
const revealBlock = sourceBlock(appSource, "const showToast", "const clearImportQueueFocusListener");
|
||||
const applyBlock = sourceBlock(appSource, "const applyPersistedSettings", "const syncLiveProviderUsageSettings");
|
||||
const mainSource = readFileSync(new URL("../src/main/main.ts", import.meta.url), "utf8");
|
||||
|
||||
expect(revealBlock).toContain("window.rd.getArchivePasswordList()");
|
||||
expect(revealBlock).toContain('settingsSubTab !== "extract"');
|
||||
expect(appSource).toContain("setSettingsDraft((current) => createSettingsDraft(state.settings, current))");
|
||||
expect(appSource).toContain("setSettingsDraft((current) => createSettingsDraft(next.settings, current))");
|
||||
expect(applyBlock).toContain("setSettingsDraft((current) => createSettingsDraft(result, preserveWriteOnlyValues ? current : undefined))");
|
||||
expect(mainSource).toContain("handleTrusted(IPC_CHANNELS.GET_ARCHIVE_PASSWORD_LIST");
|
||||
});
|
||||
|
||||
it("persists an edited archive password list before unrelated account mutations", () => {
|
||||
const editBlock = sourceBlock(appSource, "const onSaveAccountEditDialog", "const onSaveAccountDialog");
|
||||
const createBlock = sourceBlock(appSource, "const onSaveAccountDialog", "const onResetAccountDailyUsage");
|
||||
const deleteKeyBlock = sourceBlock(appSource, "const onRemoveDebridLinkKey", "const onToggleAccountEnabled");
|
||||
const deleteRowsBlock = sourceBlock(appSource, "const removeAccountTableRows", "const checkAccountsActive");
|
||||
|
||||
expect(editBlock.indexOf("await persistDraftSettings()")).toBeLessThan(editBlock.indexOf("window.rd.replaceAccount"));
|
||||
expect(createBlock.indexOf("await persistDraftSettings()")).toBeLessThan(createBlock.indexOf("window.rd.createAccount"));
|
||||
expect(deleteKeyBlock.indexOf("await persistDraftSettings()")).toBeLessThan(deleteKeyBlock.indexOf("window.rd.deleteAccount"));
|
||||
expect(deleteRowsBlock.indexOf("await persistDraftSettings()")).toBeLessThan(deleteRowsBlock.indexOf("window.rd.deleteAccount"));
|
||||
});
|
||||
|
||||
it("invalidates an archive password reveal before applying imported settings", () => {
|
||||
const applyBlock = sourceBlock(appSource, "const applyPersistedSettings", "const syncLiveProviderUsageSettings");
|
||||
|
||||
expect(applyBlock).toContain("archivePasswordLoadGenerationRef.current += 1");
|
||||
expect(applyBlock.indexOf("archivePasswordLoadGenerationRef.current += 1")).toBeLessThan(applyBlock.indexOf("setSettingsDraft"));
|
||||
});
|
||||
|
||||
it("enables an account by clearing both its row-level and provider-level locks", () => {
|
||||
expect(buildScopedAccountEnabledState(
|
||||
["debridlink", "linksnappy"],
|
||||
|
||||
@@ -213,6 +213,20 @@ describe("visual fixtures", () => {
|
||||
expect((await api.getSnapshot()).settings.animatePackageDisclosure).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps a configured archive password list stateful in the isolated renderer", async () => {
|
||||
const dense = createVisualFixture("dense");
|
||||
const api = createVisualElectronApi(dense, "?archive-passwords=configured");
|
||||
|
||||
expect(await api.getArchivePasswordList()).toEqual({
|
||||
passwords: "visual-archive-password-one\nvisual-archive-password-two"
|
||||
});
|
||||
expect((await api.getSnapshot()).settings.archivePasswordListConfigured).toBe(true);
|
||||
|
||||
await api.updateSettings({ archivePasswordList: "updated-visual-password" });
|
||||
|
||||
expect(await api.getArchivePasswordList()).toEqual({ passwords: "updated-visual-password" });
|
||||
});
|
||||
|
||||
it("boots the dense query once and waits for both visible package names", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const harness = createTestVisualBootstrap(
|
||||
|
||||
@@ -15,6 +15,10 @@ export function createVisualElectronApi(
|
||||
const searchParams = new URLSearchParams(search);
|
||||
const historyState = searchParams.get("history-state");
|
||||
if (searchParams.get("animations") === "off") fixture.snapshot.settings.animatePackageDisclosure = false;
|
||||
let archivePasswordList = searchParams.get("archive-passwords") === "configured"
|
||||
? "visual-archive-password-one\nvisual-archive-password-two"
|
||||
: fixture.snapshot.settings.archivePasswordListConfigured ? "visual-archive-password" : "";
|
||||
fixture.snapshot.settings.archivePasswordListConfigured = archivePasswordList.length > 0;
|
||||
let historyRequestCount = 0;
|
||||
const stateUpdateListeners = new Set<Parameters<ElectronApi["onStateUpdate"]>[0]>();
|
||||
const emitStateUpdate = (): void => {
|
||||
@@ -23,6 +27,10 @@ export function createVisualElectronApi(
|
||||
};
|
||||
const updateSettings = (settings: RendererSettingsUpdate): RendererSettings => {
|
||||
const { archivePasswordList: _archivePasswordList, notifyUrl: _notifyUrl, ...safe } = settings;
|
||||
if (typeof _archivePasswordList === "string") {
|
||||
archivePasswordList = _archivePasswordList;
|
||||
fixture.snapshot.settings.archivePasswordListConfigured = archivePasswordList.trim().length > 0;
|
||||
}
|
||||
Object.assign(fixture.snapshot.settings, safe);
|
||||
emitStateUpdate();
|
||||
return clone(fixture.snapshot.settings);
|
||||
@@ -30,6 +38,7 @@ export function createVisualElectronApi(
|
||||
|
||||
return {
|
||||
getSnapshot: async () => clone(fixture.snapshot),
|
||||
getArchivePasswordList: async () => ({ passwords: archivePasswordList }),
|
||||
getVersion: async () => "2.0.12",
|
||||
checkUpdates: async () => clone(fixture.update),
|
||||
installUpdate: async () => ({ started: true, message: "Visual update gestartet" }),
|
||||
|
||||
Reference in New Issue
Block a user