diff --git a/e2e/journeys/parts/edit-undo.mjs b/e2e/journeys/parts/edit-undo.mjs index da99e35..cc2efef 100644 --- a/e2e/journeys/parts/edit-undo.mjs +++ b/e2e/journeys/parts/edit-undo.mjs @@ -107,7 +107,7 @@ const undoExpires = { /** @type {{ id: string, title: string, entryPoint: string, run: (ctx: Ctx) => Promise }} */ const undoFails = { id: "an-undo-whose-write-fails-keeps-the-saved-values-and-offers-undo-again", - title: "when the write of an Undo fails the saved values stay stored, a toast says how many changes could not be undone, Undo is offered again for the rows left, and the retry writes the previous values back", + title: "when the write of an Undo fails the saved values stay stored, a toast says the changes could not be undone, Undo is offered again for the rows left, and the retry writes the previous values back", entryPoint: "PUT /api/database/browse/edit answering 500 after a save", async run(ctx) { const tab = await shopTab(ctx, "products", "eu"); @@ -129,14 +129,14 @@ const undoFails = { const saved = await storedRow(ctx, "products", "eu_sku_lamp", "eu"); failing = true; await tab.click({ role: "button", name: "Undo" }); - const toast = await settle(() => tab.page.locator("body").innerText(), (content) => /couldn.t be undone/.test(content)); + const toast = await settle(() => tab.page.locator("body").innerText(), (content) => /Couldn.t undo the changes/.test(content)); const lamp = await storedRow(ctx, "products", "eu_sku_lamp", "eu"); const chair = await storedRow(ctx, "products", "eu_sku_chair", "eu"); const offered = await tab.visible({ role: "button", name: "Undo" }); const lampCell = await cellState(tab, "eu_sku_lamp", "name"); await ctx.verify("the undo is refused", [ check("the save wrote both names", saved.name === "Reading lamp", saved.name), - check("the toast says 2 changes couldn't be undone", /2 changes couldn.t be undone/.test(toast), toast.replace(/\s+/g, " ").slice(-300)), + check("the toast says the changes couldn't be undone", /Couldn.t undo the changes/.test(toast), toast.replace(/\s+/g, " ").slice(-300)), check("the run stopped at the first failing write", refused === 1, refused), check("the saved names stay stored", lamp.name === "Reading lamp" && chair.name === "Armchair", [lamp.name, chair.name]), check("the grid shows the saved name, nothing struck", lampCell.text === "Reading lamp" && lampCell.struck === "", lampCell), diff --git a/frontend-vue/app/build/data/useStagedSave.ts b/frontend-vue/app/build/data/useStagedSave.ts index a2cb9f9..26fbc5e 100644 --- a/frontend-vue/app/build/data/useStagedSave.ts +++ b/frontend-vue/app/build/data/useStagedSave.ts @@ -241,8 +241,11 @@ export function useStagedSave(options: StagedSaveOptions) { // The rows the failure left keep their undo, for a retry. if (here) show({ ...current, state: 'saved', changes: left }, UNDO_WINDOW_MS) + const wholly = restored.length === 0 && gone.length === 0 presentError(outcome.error, { - fallbackKey: 'dms_database.data.save.undo_partial', + fallbackKey: wholly + ? 'dms_database.data.save.undo_failed' + : 'dms_database.data.save.undo_partial', params: { count: left.length + gone.length }, }) } else if (here) {