fix: unlock map controls after stale save
This commit is contained in:
parent
9772d7e043
commit
cfa6e70c13
@ -58,7 +58,7 @@ export default function useLocationMapDraftActions({
|
|||||||
if (!isCurrentScope()) return;
|
if (!isCurrentScope()) return;
|
||||||
toast.error("Create map failed", getApiErrorMessage(error, "Failed to create map"));
|
toast.error("Create map failed", getApiErrorMessage(error, "Failed to create map"));
|
||||||
} finally {
|
} finally {
|
||||||
endSaving();
|
if (isCurrentScope()) endSaving();
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, isCurrentScope,
|
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, isCurrentScope,
|
||||||
@ -78,7 +78,7 @@ export default function useLocationMapDraftActions({
|
|||||||
if (!isCurrentScope()) return;
|
if (!isCurrentScope()) return;
|
||||||
toast.error("Create map failed", getApiErrorMessage(error, "Failed to create map from zones"));
|
toast.error("Create map failed", getApiErrorMessage(error, "Failed to create map from zones"));
|
||||||
} finally {
|
} finally {
|
||||||
endSaving();
|
if (isCurrentScope()) endSaving();
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, isCurrentScope,
|
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, isCurrentScope,
|
||||||
@ -100,7 +100,7 @@ export default function useLocationMapDraftActions({
|
|||||||
if (!isCurrentScope()) return;
|
if (!isCurrentScope()) return;
|
||||||
toast.error("Save draft failed", getApiErrorMessage(error, "Failed to save map draft"));
|
toast.error("Save draft failed", getApiErrorMessage(error, "Failed to save map draft"));
|
||||||
} finally {
|
} finally {
|
||||||
endSaving();
|
if (isCurrentScope()) endSaving();
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, isCurrentScope, locationId,
|
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, isCurrentScope, locationId,
|
||||||
@ -137,7 +137,7 @@ export default function useLocationMapDraftActions({
|
|||||||
const message = getApiErrorMessage(error, "Failed to publish map");
|
const message = getApiErrorMessage(error, "Failed to publish map");
|
||||||
toast.error("Publish failed", savedPendingDraft ? `${message}. Draft changes were saved.` : message);
|
toast.error("Publish failed", savedPendingDraft ? `${message}. Draft changes were saved.` : message);
|
||||||
} finally {
|
} finally {
|
||||||
endSaving();
|
if (isCurrentScope()) endSaving();
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, hasUnsavedChanges, isCurrentScope,
|
activeHouseholdId, applyDraftResponse, beginSaving, endSaving, hasUnsavedChanges, isCurrentScope,
|
||||||
|
|||||||
@ -88,6 +88,8 @@ export default function useLocationMapDraftState({
|
|||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setLoadError(null);
|
setLoadError(null);
|
||||||
|
setSaving(false);
|
||||||
|
setSavingAction(null);
|
||||||
setFilters({ ...DEFAULT_MAP_FILTERS });
|
setFilters({ ...DEFAULT_MAP_FILTERS });
|
||||||
setLayersOpen(false);
|
setLayersOpen(false);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -702,12 +702,14 @@ test("ignores stale map save responses after switching locations", async ({ page
|
|||||||
|
|
||||||
await expect(page.getByRole("button", { name: "Map area Ontario Produce" })).toBeVisible();
|
await expect(page.getByRole("button", { name: "Map area Ontario Produce" })).toBeVisible();
|
||||||
await expect(page.locator(".location-map-title span")).toHaveText("Ontario");
|
await expect(page.locator(".location-map-title span")).toHaveText("Ontario");
|
||||||
|
await expect(page.getByRole("button", { name: "Edit Draft" })).toBeEnabled();
|
||||||
|
|
||||||
releaseSaveResponse();
|
releaseSaveResponse();
|
||||||
await saveResponded;
|
await saveResponded;
|
||||||
|
|
||||||
await expect(page.getByRole("button", { name: "Map area Ontario Produce" })).toBeVisible();
|
await expect(page.getByRole("button", { name: "Map area Ontario Produce" })).toBeVisible();
|
||||||
await expect(page.locator(".location-map-title span")).toHaveText("Ontario");
|
await expect(page.locator(".location-map-title span")).toHaveText("Ontario");
|
||||||
|
await expect(page.getByRole("button", { name: "Edit Draft" })).toBeEnabled();
|
||||||
await expect(page.getByRole("button", { name: "Map area Saved Eastvale Bakery" })).toHaveCount(0);
|
await expect(page.getByRole("button", { name: "Map area Saved Eastvale Bakery" })).toHaveCount(0);
|
||||||
await expect(page.getByText("Saved draft")).toHaveCount(0);
|
await expect(page.getByText("Saved draft")).toHaveCount(0);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user