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.