From c5db1375de7f6a6f66cabee445b7f75e2f154c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Wed, 30 Sep 2026 14:55:19 -0300 Subject: [PATCH] test: reload only after the cart is saved, instead of after 800 ms The browser suite reloaded the page a fixed 800 ms after the last field was typed. The cart save waits for typing to stop and writes the files to the browser's storage, so under load the reload came first and the cart was not recovered ("persistent cart recovery", and once "Inspected target navigated or closed"). It now waits until the cart is in storage. Co-Authored-By: Claude Opus 5.5 --- tests/browser_test.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/browser_test.mjs b/tests/browser_test.mjs index 2751901..06e3f29 100644 --- a/tests/browser_test.mjs +++ b/tests/browser_test.mjs @@ -79,7 +79,12 @@ try{ await site.fill('#fCnpj','11222333000181'); await site.fill('#fZap','11999999999'); await site.fill('#fMail','local-browser@example.test'); - await pause(800); + // Reload only once the cart is in the browser's storage: the save waits for + // typing to stop and writes the files, so a fixed pause raced it. + await waitFor(()=>site.eval(`new Promise(done=>{const open=indexedDB.open('dtf-local-cart',1); + open.onerror=()=>done(false); + open.onsuccess=()=>{const all=open.result.transaction('cart').objectStore('cart').getAll(); + all.onsuccess=()=>done(all.result.some(v=>v.items?.length===1));all.onerror=()=>done(false);};})`),'cart saved in the browser'); await site.call('Page.reload'); await waitFor(()=>site.eval('typeof pedido!=="undefined" && pedido.length===1'),'persistent cart recovery'); // Reloading a product page reopens that product; the cart is its own page.