diff --git a/IMPLEMENTATION_PLAN.md b/IMPLEMENTATION_PLAN.md index 563276e..25e272d 100644 --- a/IMPLEMENTATION_PLAN.md +++ b/IMPLEMENTATION_PLAN.md @@ -18,7 +18,7 @@ Constraints: local commits only; no push; no browser testing; one commit per fea ## Settings safety and validation - [x] Confirm before Restore Defaults removes preferences and remembered data. -- [ ] Report partial imports accurately when custom icons cannot be restored. +- [x] Report partial imports accurately when custom icons cannot be restored. - [ ] Reject malformed slash-prefixed regular expressions before saving site rules. ## Extension lifecycle and copy diff --git a/extension/options/import-export.js b/extension/options/import-export.js index 79c8756..83c571a 100644 --- a/extension/options/import-export.js +++ b/extension/options/import-export.js @@ -215,14 +215,15 @@ function importSettings() { importLocalSettings(scopedLocalSettings, function (localError) { if (localError) { showStatus( - "Error: Failed to save local extension data - " + - localError.message, + "Settings imported, but custom icons could not be updated - " + + localError.message + + ". Reloading...", true ); - return; + } else { + showStatus("Settings imported successfully. Reloading..."); } - showStatus("Settings imported successfully. Reloading..."); setTimeout(function () { if (typeof restore_options === "function") { restore_options(); diff --git a/tests/importExport.spec.js b/tests/importExport.spec.js index 283c37f..4d72607 100644 --- a/tests/importExport.spec.js +++ b/tests/importExport.spec.js @@ -137,9 +137,14 @@ describe("options/import-export.js", () => { expect(backup.localSettings.lucideTagsCacheV1At).toBeUndefined(); }); - it("imports wrapped backups, restores local data, and refreshes the options page", async () => { + it("reports partial success and refreshes when custom icons fail to import", async () => { const { chrome } = bootImportExport(); window.restore_options = vi.fn(); + chrome.storage.local.set.mockImplementationOnce(function(_items, callback) { + chrome.runtime.lastError = { message: "icon quota exceeded" }; + callback(); + chrome.runtime.lastError = null; + }); const realCreateElement = document.createElement.bind(document); const fakeInput = realCreateElement("input"); @@ -197,6 +202,12 @@ describe("options/import-export.js", () => { { rememberSpeed: true, enabled: false }, expect.any(Function) ); + expect(document.querySelector("#status").textContent).toContain( + "Settings imported, but custom icons could not be updated" + ); + expect(document.querySelector("#status").textContent).toContain( + "icon quota exceeded" + ); vi.advanceTimersByTime(500); expect(window.restore_options).toHaveBeenCalled();