feat: add audited work records and controlled digest retries
Build and publish container images / images (push) Successful in 12m27s
Build and publish container images / images (push) Successful in 12m27s
This commit is contained in:
1 parent
6e0aecdfb3
commit
e65ca56f92
33 files changed
+2262
-114
No files matched your search
+28
@@ -0,0 +1,28 @@
|
||||
(async()=>{
|
||||
const assert=(ok,msg)=>{if(!ok)throw Error(msg);},delay=ms=>new Promise(r=>setTimeout(r,ms));
|
||||
const wait=async check=>{for(let n=0;n<240;n++){if(check())return;await delay(25);}throw Error('Timed out: '+check);};
|
||||
const frame=document.createElement('iframe');frame.style='display:block;width:100%;height:100vh;border:0';document.body.append(frame);
|
||||
try{
|
||||
await new Promise(resolve=>{frame.onload=resolve;frame.src='/-/sys/config?panel=organizer';});
|
||||
const w=frame.contentWindow,d=frame.contentDocument;await wait(()=>d.querySelector('#task-digest-history details'));
|
||||
const root=d.getElementById('task-digest-history'),details=root.querySelector('details');
|
||||
assert(!details.open,'History not lazy');assert(!w.performance.getEntriesByType('resource').some(x=>x.name.includes('/digest-history')),'History eagerly fetched');
|
||||
details.open=true;await wait(()=>root.querySelector('.digest-retry form'));
|
||||
const form=root.querySelector('.digest-retry form'),ack=form.querySelector('input');
|
||||
assert(ack.required&&!ack.checked,'Uncertain delivery must require confirmation');assert(!form.checkValidity(),'Unchecked acknowledgment valid');ack.checked=true;
|
||||
const original=w.fetch,requests=[];let lose=true;
|
||||
w.fetch=async(url,options)=>{if(String(url).endsWith('/digest-history/retry')){requests.push(JSON.parse(options.body));const response=await original(url,options);if(lose){lose=false;await response.text();throw new TypeError('Simulated lost response');}return response;}return original(url,options);};
|
||||
form.requestSubmit();await wait(()=>root.querySelector('[role=status]').textContent&&!form.querySelector('button').disabled);
|
||||
assert(root.contains(form),'Lost response removed retry controls');form.requestSubmit();
|
||||
await wait(()=>!root.querySelector('.digest-retry form')&&!root.querySelector('.productivity-controls button').disabled);
|
||||
assert(requests.length===2&&requests[0].request_id===requests[1].request_id,'Retry generated a second request ID');
|
||||
assert(root.querySelectorAll('tbody tr').length===2,'Duplicate attempt created');
|
||||
const tick=await fetch('/fixture/tick',{method:'POST'});assert(tick.ok,'Worker failed');
|
||||
root.querySelector('.productivity-controls button').click();await wait(()=>root.querySelector('.digest-retry form'));
|
||||
assert(root.querySelector('.digest-retry input').required,'Sent retry must require confirmation');
|
||||
assert(root.textContent.includes('メールサーバー受付済み')||root.textContent.includes('Accepted by mail server'),'Sent status missing');
|
||||
assert(!root.textContent.includes('reader@example.test'),'Recipient leaked in history');
|
||||
assert(d.documentElement.scrollWidth<=w.innerWidth,'Settings overflow viewport');
|
||||
details.scrollIntoView({block:'start'});document.body.dataset.vimReady='1';
|
||||
}catch(error){const out=document.createElement('pre');out.id='error';out.textContent=error.stack;document.body.append(out);}
|
||||
})();
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
(async()=>{
|
||||
const assert=(ok,msg)=>{if(!ok)throw Error(msg);},delay=ms=>new Promise(r=>setTimeout(r,ms));
|
||||
const wait=async check=>{for(let n=0;n<200;n++){if(check())return;await delay(25);}throw Error('Timed out: '+check);};
|
||||
const frame=document.createElement('iframe');frame.style='display:block;width:100%;height:100vh;border:0';document.body.append(frame);
|
||||
try{
|
||||
await new Promise(resolve=>{frame.onload=resolve;frame.src='/v/plan/dashboard';});
|
||||
await wait(()=>frame.contentDocument.querySelector('.productivity-table tbody tr'));
|
||||
const reportTable=frame.contentDocument.querySelector('.productivity-table');
|
||||
assert(reportTable.querySelectorAll('thead th').length===4,'Project aggregate table missing');
|
||||
assert(reportTable.querySelector('tbody tr').lastElementChild.textContent==='1.00','Project duration incorrect');
|
||||
const historyLink=frame.contentDocument.querySelector('a[href="/v/plan/tasks/work"]');assert(historyLink,'Dashboard history link missing');
|
||||
await new Promise(resolve=>{frame.onload=resolve;historyLink.click();});
|
||||
const w=frame.contentWindow,d=frame.contentDocument;
|
||||
await wait(()=>d.querySelector('.work-history-table tbody button'));
|
||||
assert(d.documentElement.scrollWidth<=w.innerWidth,'History overflows viewport');
|
||||
d.querySelector('.work-history-table tbody button').click();
|
||||
let form=d.querySelector('.work-history-edit');assert(form,'Inline correction missing');
|
||||
const inputs=form.querySelectorAll('input');inputs[2].value='Browser correction';
|
||||
form.requestSubmit();await wait(()=>!d.querySelector('.work-history-edit')&&!d.getElementById('work-history-list').inert);
|
||||
d.querySelector('#work-history-list details').open=true;await wait(()=>d.querySelector('#work-history-list details strong'));
|
||||
assert(d.querySelector('#work-history-list details').textContent.includes('Browser correction'),'Audit missing');
|
||||
const originalFetch=w.fetch;w.fetch=async(url,options)=>options?.method==='POST'?new w.Response(JSON.stringify({error:'conflict'}),{status:412}):originalFetch(url,options);
|
||||
d.querySelector('.work-history-table tbody button').click();form=d.querySelector('.work-history-edit');form.querySelector('input[type=text]').value='Retain my input';form.requestSubmit();
|
||||
await wait(()=>form.querySelector('[role=status]').textContent);assert(form.querySelector('input[type=text]').value==='Retain my input','Conflict discarded input');
|
||||
w.fetch=originalFetch;w.confirm=()=>true;form.querySelector('button[type=button]').click();
|
||||
d.querySelectorAll('.work-history-table tbody tr:first-child button')[1].click();form=d.querySelector('.work-history-edit');form.querySelector('input').value='Browser cancellation';form.requestSubmit();await wait(()=>!d.querySelector('.work-history-edit')&&!d.getElementById('work-history-list').inert);
|
||||
assert(!d.querySelector('.work-history-table tbody tr:first-child button'),'Cancelled work remains editable');
|
||||
d.querySelector('#work-history-list details').open=true;await wait(()=>d.querySelector('#work-history-list details strong'));
|
||||
assert(d.querySelector('#work-history-list details').textContent.includes('Browser cancellation'),'Cancellation audit missing');
|
||||
const report=await (await fetch('/_/api/v1/extension/organizer.tasks/report')).json();assert(report.days.every(day=>day.work_ms===0),'Cancelled time remains in report');
|
||||
assert(d.documentElement.scrollWidth<=w.innerWidth,'Expanded history overflows viewport');
|
||||
document.body.dataset.vimReady='1';
|
||||
}catch(error){const out=document.createElement('pre');out.id='error';out.textContent=error.stack;document.body.append(out);}
|
||||
})();
|
||||
Reference in new issue
Block a user