feat(tasks): add keyboard index and productivity dashboard improvements
Build and publish container images / images (push) Successful in 9m29s
Release container images / release (push) Successful in 18s

This commit is contained in:
Anya Tokugawa committed 2026-11-10 07:12:15 +09:00
1 parent 02edb51b8a
commit 667776e43f
44 files changed
+1224 -138

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
window.addEventListener('load',async()=>{
const wait=async fn=>{for(let n=0;n<120;n++){if(fn())return;await new Promise(r=>setTimeout(r,50));}throw Error('Timed out: '+fn);};
const assert=(ok,msg)=>{if(!ok)throw Error(msg);},key=(k,ctrl=false)=>document.activeElement.dispatchEvent(new KeyboardEvent('keydown',{key:k,ctrlKey:ctrl,bubbles:true,cancelable:true}));
const rows=()=>[...document.querySelectorAll('.task-index-grid tbody tr')],selected=()=>document.querySelector('.task-index-grid tr[aria-selected=true]'),api='/_/api/v1/extension/organizer.tasks/';
try{
const grid=document.querySelector('.task-index-grid'),form=document.querySelector('.task-index-filter'),filter=form.querySelector('input'),sort=form.querySelector('select');
const ready=()=>grid.getAttribute('aria-busy')!=='true';
await wait(()=>ready()&&rows().length===3&&document.querySelectorAll('.task-index-projects button').length===4);
grid.focus();key('o');assert(document.activeElement===sort,'o did not focus sort');sort.value='title';sort.dispatchEvent(new Event('change'));await wait(ready);key('Escape');
rows()[0].click();const first=selected().dataset.task;key('j');assert(selected().dataset.task!==first,'j failed');key('k');assert(selected().dataset.task===first,'k failed');assert(rows()[0].querySelector('strong'),'Markdown subject lost');
key('l');assert(document.activeElement===filter,'l did not focus limit');filter.value='~s Beta ~doing';form.requestSubmit();await wait(()=>ready()&&rows().length===1);const beta=selected().dataset.task;
filter.focus();key('d');let item=await fetch(api+'items/'+beta).then(r=>r.json());assert(item.item.status==='doing','Shortcut fired while typing');
const changed=await fetch(api+'items/'+beta,{method:'PUT',headers:{'Content-Type':'application/json','If-Match':'"'+item.item.version+'"'},body:JSON.stringify({...item.item,notes:'Changed in another client'})});assert(changed.ok,'Concurrent update fixture failed');
key('Escape');key('d');await wait(()=>document.querySelector('#tasks-status').textContent.includes('別の画面で更新'));
item=await fetch(api+'items/'+beta).then(r=>r.json());assert(item.item.status==='doing'&&item.item.notes==='Changed in another client','Stale completion overwrote another client');
form.requestSubmit();await wait(ready);key('d');await wait(()=>ready()&&rows().length===0);item=await fetch(api+'items/'+beta).then(r=>r.json());assert(item.item.status==='done'&&item.item.notes==='Changed in another client','d did not preserve full task data');
filter.value='~unknown';form.requestSubmit();await wait(()=>ready()&&document.querySelector('#tasks-status').textContent.includes('不正'));assert(form.querySelector('input').value==='~unknown','Invalid filter lost');
filter.value='~active';form.requestSubmit();await wait(()=>ready()&&rows().length===2);grid.focus();key('j',true);await wait(()=>ready()&&rows().length===1);assert(document.querySelector('.task-index-projects [aria-current=true]').dataset.project==='none','Ctrl+j did not switch project');
key('k',true);await wait(()=>ready()&&rows().length===2);key('O');await wait(ready);assert(rows()[0].textContent.includes('Gamma'),'Reverse sort failed');
grid.focus();key('?');const help=document.querySelector('.task-index-help');assert(help.open,'Help missing');const previous=selected().dataset.task;key('j');assert(selected().dataset.task===previous,'Shortcut fired through modal');help.querySelector('button').click();
key('m');await wait(()=>document.querySelector('#tasks-dialog').open&&document.querySelector('#tasks-form [name=page_path]'));key('j');assert(selected().dataset.task===previous,'Shortcut fired through editor');document.querySelector('#tasks-close').click();
const projectButton=[...document.querySelectorAll('.task-index-projects button')].find(b=>b.dataset.project&&b.dataset.project!=='none');projectButton.click();await wait(ready);const project=projectButton.dataset.project;grid.focus();key('c');
await wait(()=>document.querySelector('#tasks-dialog').open&&document.querySelector('#tasks-form [name=project_uuid]')?.value===project);const title=document.querySelector('#tasks-form [name=title]');title.value='Created from index';title.dispatchEvent(new Event('input',{bubbles:true}));document.querySelector('#tasks-form').requestSubmit();await wait(()=>!document.querySelector('#tasks-dialog').open&&ready()&&rows().some(row=>row.textContent.includes('Created from index')));
rows().find(row=>row.textContent.includes('Created from index')).click();const created=selected().dataset.task;key('w');await wait(()=>document.querySelector('#tasks-status').textContent.includes('関連Wikiページはありません'));
key('s');await wait(()=>document.querySelector('#tasks-focus').dataset.state==='running');const session=await fetch(api+'focus').then(r=>r.json());assert(session.item.task_uuid===created,'Pomodoro attached to wrong task');
assert(document.documentElement.scrollWidth<=innerWidth+2,'Page overflow');assert(!document.querySelector('#tasks-list input'),'Index must not be an inline form');
document.body.dataset.vimReady='true';
}catch(e){const p=document.createElement('pre');p.id='error';p.textContent=e.stack;document.body.append(p);}
});