mirror of
https://github.com/SoPat712/Speeder.git
synced 2026-08-19 11:52:31 -04:00
fix(import): report partial settings imports
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user