fix(import): report partial settings imports

This commit is contained in:
2026-07-31 22:36:12 -04:00
parent 2fa7d8963a
commit e083fdcafe
3 changed files with 18 additions and 6 deletions
+1 -1
View File
@@ -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
+5 -4
View File
@@ -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();
+12 -1
View File
@@ -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();