Merge Critical Corrections plan 005: the browser test owns its machine
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 5m30s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m12s
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 5m30s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m12s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ const chrome=spawn(process.env.CHROME_BIN||'/usr/bin/google-chrome-stable',[
|
||||
const pause=ms=>new Promise(r=>setTimeout(r,ms));
|
||||
let stderr='';chrome.stderr.on('data',data=>stderr+=data.toString());
|
||||
const clients=[];
|
||||
let kanban,testMachine;
|
||||
async function waitFor(fn,description,timeout=30000){const end=Date.now()+timeout;while(Date.now()<end){if(await fn())return;await pause(200);}throw new Error('Timeout: '+description);}
|
||||
class Page {
|
||||
constructor(ws){this.ws=ws;this.next=0;this.pending=new Map();this.errors=[];
|
||||
@@ -157,12 +158,16 @@ try{
|
||||
const qid=await site.eval('localStorage.getItem("dtf-quote")');
|
||||
// The server charged what the Site showed.
|
||||
assert.equal(await site.eval(`dtfApi('/quotes/'+${JSON.stringify(qid)}).then(q=>q.approved.items[0].total_cents)`),itemCents);
|
||||
const kanban=await page(kanbanOrigin);
|
||||
kanban=await page(kanbanOrigin);
|
||||
await kanban.fill('#email',process.env.OPERATOR_EMAIL||'operator@example.test');
|
||||
await kanban.fill('#password',process.env.OPERATOR_PASSWORD||'local-operator-only');
|
||||
await kanban.eval('document.getElementById("login").requestSubmit()');
|
||||
// Quotes live in their own tab; an automatic approval is listed as such.
|
||||
await waitFor(()=>kanban.eval('!document.getElementById("app").hidden'),'Kanban sign-in');
|
||||
// The test makes its own machine, so it runs on a fresh database and on its own.
|
||||
testMachine=await kanban.eval(`api('/machines',{name:'Browser test '+Date.now(),products:['textil']}).then(r=>r.id)`);
|
||||
await kanban.eval('load(true)');
|
||||
await waitFor(()=>kanban.eval(`board.machines.some(m=>m.id===${JSON.stringify(testMachine)})`),'test machine on the board');
|
||||
assert.equal(await kanban.eval('sessionStorage.getItem("dtf-operator")'),null);
|
||||
assert.equal(await kanban.eval('document.getElementById("password").value'),'');
|
||||
await kanban.click('[data-tab="site"]');
|
||||
@@ -222,9 +227,9 @@ try{
|
||||
await waitFor(()=>kanban.eval(`!!document.querySelector('[data-order="${oid}"] [data-move]')`),'order panel');
|
||||
// The Prumo report is on the card before the designer opens the file.
|
||||
await waitFor(()=>kanban.eval(`!!document.querySelector('[data-order="${oid}"] .prumo')`),'Prumo report');
|
||||
// No machine at payment (Dropstar, 2026-11-05): the pull chooses one.
|
||||
await waitFor(()=>kanban.eval(`board.machines.some(m=>m.active&&m.products.includes('textil'))`),'a textile machine');
|
||||
const machineId=await kanban.eval(`board.machines.find(m=>m.active&&m.products.includes('textil')).id`);
|
||||
// No machine at payment (Dropstar, 2026-11-05): the pull chooses one. It is
|
||||
// the machine this test made after sign-in.
|
||||
const machineId=testMachine;
|
||||
await kanban.eval(`(()=>{const s=document.querySelector('[data-order="${oid}"] select[aria-label="Máquina do pedido"]');
|
||||
s.value=${JSON.stringify(machineId)};s.dispatchEvent(new Event('change',{bubbles:true}));})()`);
|
||||
await waitFor(()=>kanban.eval(`board.orders.find(o=>o.id==='${oid}').machine?.id===${JSON.stringify(machineId)}`),'machine chosen');
|
||||
@@ -368,4 +373,10 @@ try{
|
||||
console.log('Screenshots: output/local/site.png and output/local/kanban.png');
|
||||
console.log('PASS: filename XSS escaping with CSP bypassed, no stored operator password, logout clears browser file blobs.');
|
||||
}catch(error){console.error(error);if(stderr)console.error(stderr.slice(-1500));process.exitCode=1;}
|
||||
finally{for(const p of clients)p.ws.close();chrome.kill();}
|
||||
finally{
|
||||
if(testMachine&&kanban){
|
||||
try{await kanban.eval(`api('/machines/'+${JSON.stringify(testMachine)}+'/delete',{})`);}
|
||||
catch(e){console.error('Could not delete the test machine '+testMachine+':',e.message||e);}
|
||||
}
|
||||
for(const p of clients)p.ws.close();chrome.kill();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user