From c3c56a7f21e1d83b8189a61d51422be645c272b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Fri, 2 Oct 2026 17:07:46 -0300 Subject: [PATCH] fix: keep the payment confirmation on screen; only a new checkout drops a paid quote bc1fb60 forgot the paid quote as soon as the confirmation showed, so the next refresh of the page (the cart emptying) found no quote and replaced "Pagamento confirmado" with "Nenhum pedido aguardando pagamento". The confirmation keeps its quote again; the paid one is dropped only when the customer asks to pay a cart identical to it, which then becomes a new order. The browser test waits for the confirmation, and checks no "Pedido #" is shown, instead of catching the momentary "Pedido #N criado" line. Co-Authored-By: Claude Opus 5.5 --- tests/browser_test.mjs | 4 +++- web/checkout.js | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/browser_test.mjs b/tests/browser_test.mjs index 9b0eb65..a2648aa 100644 --- a/tests/browser_test.mjs +++ b/tests/browser_test.mjs @@ -151,7 +151,9 @@ try{ await site.eval('window.dtfCheckout()'); await waitFor(async()=> (await site.text()).includes('Total validado no servidor:'),'approved quote displayed'); await site.eval('[...document.querySelectorAll("button")].find(x=>x.textContent==="Criar pedido de teste").click()'); - await waitFor(async()=> (await site.text()).includes('Pedido #'),'test payment'); + // The customer is shown a confirmation, never the order's sequential number. + await waitFor(async()=> (await site.text()).includes('Pagamento confirmado'),'test payment'); + assert.equal((await site.text()).includes('Pedido #'),false); await kanban.click('#refresh'); await waitFor(()=>kanban.eval(`board.orders.some(o=>o.quote_id===${JSON.stringify(qid)})`),'paid card'); const oid=await kanban.eval(`board.orders.find(o=>o.quote_id===${JSON.stringify(qid)}).id`); diff --git a/web/checkout.js b/web/checkout.js index 293348f..30e3025 100644 --- a/web/checkout.js +++ b/web/checkout.js @@ -326,7 +326,9 @@ await ready; const quote=await api('/quotes/'+shownId); if(version!==refreshVersion || draftId!==shownId) return; - // Asked to pay a cart identical to one already paid: that is a new order. + // Asked to pay a cart identical to one already paid (the same test + // repeated): that is a new order, never the paid one shown again. The + // confirmation itself keeps its quote, so it stays on screen. if (go && quote.status==='paid') { forgetDraft(); return window.dtfCheckout(); } if (!naPagina()) { message(''); vaiPara(PAGAMENTO); return; } shownCart=cartSnapshot(); @@ -419,9 +421,6 @@ } function confirmado(quote) { clearInterval(waitTimer); - // Paid: the next cart is a new order, even one identical to this (the same - // test repeated), never this quote shown again as already paid. - forgetDraft(); const box=node('div',null,'confirmado'); const titulo=node('h4','Pagamento confirmado'); titulo.insertAdjacentHTML('afterbegin', icone('okCirculo'));