feat: the folder can download as the order arrives, and removes cancelled orders' files
All checks were successful
Build and deploy / Validate source (push) Successful in 14s
Build and deploy / Integration suite on a real stack (push) Successful in 5m5s
Build and deploy / Secret scan and release gate (push) Successful in 11s
Build and deploy / Publish images (push) Successful in 1m23s

Integrações gets "Baixar ao chegar" next to "Baixar na Fila". On arrival the
file (the generated print file, or the final once approved) goes into a
Recebidos folder inside the chosen one and moves up when the order enters
the queue. Files of orders cancelled, deleted or sent back for correction,
and files replaced by another final, leave the folder.

The launch reset now restarts order numbers at #1 by itself: the worker's
role may set the orders' number sequence, and nothing else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-16 15:07:29 -03:00
parent b83e60ef0c
commit 4a2ce72764
9 changed files with 244 additions and 63 deletions

View File

@@ -184,7 +184,12 @@ try{
window.showDirectoryPicker=async()=>window.picked;FOLDER.mode='folder';renderIntegrations();
[...document.querySelectorAll('#folder-card button')].find(b=>b.textContent==='Escolher pasta').click();})()`);
await waitFor(()=>kanban.eval('folderActive()&&!FOLDER.busy'),'folder chosen');
const savedFiles=()=>kanban.eval(`(async()=>{const out=[];for await(const [name] of window.picked.entries())out.push(name);return out;})()`);
// Downloaded as the order arrives, into Recebidos; up to the folder at the queue.
await waitFor(()=>kanban.eval(`!!document.querySelector('#folder-card select')`),'download timing choice');
await kanban.eval(`(()=>{const s=document.querySelector('#folder-card select');s.value='rec';s.dispatchEvent(new Event('change'));})()`);
await waitFor(()=>kanban.eval(`FOLDER.when==='rec'&&!FOLDER.busy`),'download on arrival');
const savedFiles=(sub)=>kanban.eval(`(async()=>{const dir=${sub?`await window.picked.getDirectoryHandle(${JSON.stringify(sub)},{create:true})`:'window.picked'};
const out=[];for await(const [name,h] of dir.entries())if(h.kind==='file')out.push(name);return out;})()`);
// Open the order's panel from its card, then click the real transition
// buttons there, including the rerender after each move.
await kanban.click('[data-tab="board"]');
@@ -205,6 +210,11 @@ try{
await kanban.fill(`[data-order="${oid}"] input[placeholder="Nota da revisão"]`,'Browser test final file');
await kanban.eval(`(()=>{const check=document.querySelector('[data-order="${oid}"] [data-confirm]');check.click();check.closest('form').requestSubmit();})()`);
await waitFor(()=>kanban.eval(`board.orders.find(o=>o.id==='${oid}').version===2`),'final file approval');
// Approved before the queue: already on this computer, in Recebidos.
const early='pedido-'+await kanban.eval(`board.orders.find(o=>o.id==='${oid}').number`)+'-item-1';
await kanban.eval('syncFolder(true)');
await waitFor(async()=>(await savedFiles('Recebidos')).some(n=>n.startsWith(early)&&!n.endsWith('.baixando')),'final file saved in Recebidos',45000);
assert.equal((await savedFiles()).some(n=>n.startsWith(early)),false);
}
await waitFor(()=>kanban.eval(`!!document.querySelector('[data-order="${oid}"] [data-move="${state}"]')`),'move to '+title);
await kanban.click(`[data-order="${oid}"] [data-move="${state}"]`);
@@ -217,6 +227,14 @@ try{
// down: only once the round ends must no half-written file be left.
await waitFor(()=>kanban.eval('!FOLDER.busy'),'folder round finished',60000);
assert.equal((await savedFiles()).some(n=>n.endsWith('.baixando')),false);
assert.equal((await savedFiles('Recebidos')).some(n=>n.startsWith(prefix)),false);
// A file whose order was deleted leaves the folder.
await kanban.eval(`(async()=>{const f=await window.picked.getFileHandle('pedido-0-item-1-excluido.png',{create:true});
const w=await f.createWritable();await w.write('x');await w.close();
FOLDER.saved.set(crypto.randomUUID(),{order:crypto.randomUUID(),item:1,name:'pedido-0-item-1-excluido.png',place:'queue'});})()`);
await waitFor(()=>kanban.eval('!FOLDER.busy'),'folder idle',60000);
await kanban.eval('syncFolder(true)');
await waitFor(async()=>!(await savedFiles()).includes('pedido-0-item-1-excluido.png'),'deleted order file removed',30000);
}
}
// Undo a mistaken move from the panel: one stage back with an internal reason.