Close popup automatically after a successful save

This commit is contained in:
justin committed 2026-09-02 16:53:22 -07:00
1 parent b2082d0624
commit 646a106e93
4 files changed
+39 -1

No files matched your search

+5
View File
@@ -74,6 +74,11 @@ function loadPopupScript({ initialSettings } = {}) {
);
const savedCalls = [];
window.__closeCalled = false;
window.close = () => {
window.__closeCalled = true;
};
window.chrome = {
storage: {
sync: {
+28
View File
@@ -133,3 +133,31 @@ test("unchecking a toggle and saving persists it as false", async () => {
assert.strictEqual(savedCalls[0].skipCredits, false);
assert.strictEqual(savedCalls[0].skipIntro, true);
});
test("closes the popup shortly after a successful save", async () => {
const { window } = loadPopupScript();
await wait(20);
window.document.getElementById("saveBtn").click();
await wait(50);
assert.strictEqual(window.__closeCalled, false, "should not close instantly, so the Saved message is visible");
await wait(700);
assert.strictEqual(window.__closeCalled, true, "should close shortly after saving");
});
test("does not close the popup when the save is rejected for a blank custom URL", async () => {
const { window } = loadPopupScript();
await wait(20);
const urlPreset = window.document.getElementById("urlPreset");
urlPreset.value = "custom";
urlPreset.dispatchEvent(new window.Event("change"));
window.document.getElementById("customUrl").value = " ";
window.document.getElementById("saveBtn").click();
await wait(700);
assert.strictEqual(window.__closeCalled, false);
});