fix: stop Site timers from running after a product is closed
The grade check and the layout preview run on short timers. When the item went to the cart inside that window, no product was open and both threw in the customer's browser, which also failed the browser tests intermittently. Each now returns when no product is open. The cart test waits for the empty state, which is painted on the next animation frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,8 @@ try{
|
||||
await waitFor(()=>site.eval(`location.pathname==='/carrinho' && getComputedStyle($('carr')).display!=='none' && getComputedStyle($('foco')).display==='none'`),'cart page');
|
||||
// Removing an item is one click and can be undone.
|
||||
await site.click('[data-rmi="0"]');
|
||||
// The empty state is painted on the next animation frame (site-steps.js).
|
||||
await waitFor(()=>site.eval(`!$('carrVazio').hidden||document.documentElement.hasAttribute('data-sem-itens')`),'empty cart state');
|
||||
assert.deepEqual(await site.eval(`({items:pedido.length,empty:!$('carrVazio').hidden||document.documentElement.hasAttribute('data-sem-itens'),undo:!$('desfazer').hidden})`),{items:0,empty:true,undo:true});
|
||||
await site.click('#desfazerBtn');
|
||||
assert.equal(await site.eval('pedido.length===1 && pedido[0].total===21.89 && $("desfazer").hidden'),true);
|
||||
|
||||
@@ -302,6 +302,8 @@ function previaAoVivo(){
|
||||
return;
|
||||
}
|
||||
tMont=setTimeout(()=>{
|
||||
// o produto pode ter sido fechado nesses 140 ms (item foi para o carrinho)
|
||||
if(!modo) return;
|
||||
const prontas=artes.filter(a=>a.cm>0 && a.cm<=larguraFilme() && a.src);
|
||||
const W=Math.round(300*ZOOMS[zoomI]);
|
||||
$('vArea').classList.toggle('ampliado', zoomI>0);
|
||||
|
||||
@@ -88,6 +88,8 @@ let tAval=null;
|
||||
function agendaAvaliacao(){
|
||||
clearTimeout(tAval);
|
||||
tAval=setTimeout(()=>{
|
||||
// o produto pode ter sido fechado nesses 220 ms (item foi para o carrinho)
|
||||
if(!modo) return;
|
||||
const r=avaliar();
|
||||
const el=$('aoVivo');
|
||||
if(!el) return;
|
||||
|
||||
Reference in New Issue
Block a user