Refine task editor layout and personal reminder defaults
This commit is contained in:
1 parent
8fd0b6ec8b
commit
a6bf3dfe41
14 files changed
+263
-26
No files matched your search
+25
-2
@@ -1,6 +1,29 @@
|
||||
window.addEventListener('load',async()=>{const wait=async(fn)=>{for(let i=0;i<120;i++){if(fn())return;await new Promise(r=>setTimeout(r,100));}throw Error('Timed out: '+fn.toString());};const fill=(n,value)=>{n.value=value;n.dispatchEvent(new Event('input',{bubbles:true}));};try{
|
||||
const path=location.pathname;
|
||||
if(path==='/v/plan/contacts'){
|
||||
if(path==='/v/plan/task/-/new'){
|
||||
const api='/_/api/v1/extension/organizer.tasks/',dialog=document.querySelector('#tasks-dialog'),form=document.querySelector('#tasks-form');
|
||||
const input=name=>form.querySelector('[name="'+name+'"]');
|
||||
await wait(()=>input('page_path'));if(input('notify_due').checked||input('notify_planned').checked)throw Error('Initial defaults not off');
|
||||
document.querySelector('#tasks-close').click();
|
||||
const prefs=await fetch(api+'preferences').then(r=>r.json());const saved=await fetch(api+'preferences',{method:'PUT',headers:{'Content-Type':'application/json'},body:JSON.stringify({...prefs.preferences,notify_due:true,notify_planned:true,reminder_time:'10:35'})});if(!saved.ok)throw Error('Preferences save failed');
|
||||
document.querySelector('#tasks-new').click();await wait(()=>input('page_path'));
|
||||
if(input('notify_due').checked||input('notify_planned').checked)throw Error('Undated task enabled reminders');
|
||||
fill(input('title'),'タスク編集のレイアウト確認');fill(input('notes'),'主要項目を左右に整理。日付と通知をまとめて設定します。');
|
||||
fill(input('planned_on'),'2030-01-01');fill(input('due_on'),'2030-01-02');
|
||||
if(!input('notify_due').checked||!input('notify_planned').checked||input('reminder_time').value!=='10:35')throw Error('Dated defaults missing');
|
||||
input('notify_due').click();fill(input('due_on'),'2030-01-03');if(input('notify_due').checked)throw Error('Explicit reminder choice overwritten');
|
||||
for(const [key,value] of [['status','doing'],['bucket','backlog'],['complexity','4']]){const radio=form.querySelector('[name="'+key+'"][value="'+value+'"]');if(radio.type!=='radio')throw Error('Not a native radio group');radio.click();if(form.querySelectorAll('[name="'+key+'"]:checked').length!==1)throw Error('Multiple radio choices');}
|
||||
fill(input('estimate_minutes'),'90');form.requestSubmit();await wait(()=>!dialog.open);
|
||||
const items=await fetch(api+'items?q='+encodeURIComponent('レイアウト確認')).then(r=>r.json());const task=items.items[0];
|
||||
if(task.status!=='doing'||task.bucket!=='backlog'||task.complexity!==4||!task.notify_planned||task.notify_due||task.reminder_time!=='10:35')throw Error('Editor fields not persisted');
|
||||
await wait(()=>document.querySelector('[data-task-id="'+task.uuid+'"] [data-action=detail]'));document.querySelector('[data-task-id="'+task.uuid+'"] [data-action=detail]').click();await wait(()=>input('page_path'));
|
||||
if(input('notify_due').checked)throw Error('Defaults changed existing task');
|
||||
if(form.querySelector('.task-editor-advanced').open)throw Error('Advanced section should start collapsed');
|
||||
const fields=document.querySelector('#tasks-fields'),rect=dialog.getBoundingClientRect();
|
||||
if(rect.width>innerWidth+1||rect.height>innerHeight+1||fields.scrollWidth>fields.clientWidth+1)throw Error('Editor overflow');
|
||||
if(innerWidth>=1000){const left=form.querySelector('.task-editor-main').getBoundingClientRect(),right=form.querySelector('.task-editor-plan').getBoundingClientRect();if(right.left<=left.right||Math.abs(right.top-left.top)>2)throw Error('Editor is not two columns');if(fields.scrollHeight>fields.clientHeight+2)throw Error('Desktop editor needs scrolling: '+fields.scrollHeight+'/'+fields.clientHeight);}
|
||||
if(innerWidth<760&&form.querySelector('.task-editor-plan').getBoundingClientRect().top<form.querySelector('.task-editor-main').getBoundingClientRect().bottom)throw Error('Mobile columns overlap');
|
||||
}else if(path==='/v/plan/contacts'){
|
||||
await wait(()=>document.querySelector('#contacts-controls button'));document.querySelector('#contacts-controls button').click();fill(document.querySelector('[name=name]'),'ブラウザ連絡先');fill(document.querySelector('[name=emails]'),'browser@example.invalid');fill(document.querySelector('[name=notes]'),'Non-public notes');document.querySelector('#contact-editor form').requestSubmit();await wait(()=>document.querySelector('#contacts-list button')?.textContent.includes('ブラウザ'));const r=await fetch('/_/api/v1/extension/organizer.contacts/items?q=browser').then(r=>r.json());if(r.items.length!==1)throw Error('Contact save missing');
|
||||
fill(document.querySelector('[name=name]'),'変更後');document.querySelector('#contact-editor form').requestSubmit();await wait(()=>document.querySelector('#contacts-list button')?.textContent.includes('変更後'));
|
||||
await wait(()=>document.querySelector('.contact-history'));document.querySelector('.contact-history').open=true;await wait(()=>document.querySelectorAll('.contact-history-row').length===2);document.querySelectorAll('.contact-history-row')[1].querySelector('button').click();await wait(()=>document.querySelector('.contact-history pre').textContent.includes('ブラウザ連絡先'));
|
||||
@@ -8,7 +31,7 @@ window.addEventListener('load',async()=>{const wait=async(fn)=>{for(let i=0;i<12
|
||||
const exported=await fetch('/_/api/v1/extension/organizer.contacts/export.vcf').then(r=>r.text());if(!exported.includes('ブラウザ連絡先'))throw Error('Export missing');
|
||||
document.querySelector('#tasks-dav-open').click();await wait(()=>document.querySelector('#tasks-dav-dialog').open);const dav=document.querySelector('#tasks-dav-dialog');if(getComputedStyle(dav.querySelector('.dav-compat-toggle')).display!=='none')throw Error('CalDAV-only compatibility visible');fill(dav.querySelector('form>input'),'Browser contact client');dav.querySelector('form').requestSubmit();await wait(()=>!dav.querySelector('section').hidden);const credentials=await fetch('/_/api/v1/caldav-credentials').then(r=>r.json());if(credentials.items.length!==1||credentials.items[0].scope!=='contacts')throw Error('Wrong credential scope');dav.querySelector('tbody button').click();await wait(()=>!dav.querySelector('tbody button'));dav.querySelector('header button').click();
|
||||
}else if(path==='/-/sys/config'){
|
||||
await wait(()=>document.querySelector('[name=due_days]'));fill(document.querySelector('[name=due_days]'),'2');document.querySelector('.productivity-settings').requestSubmit();await wait(()=>document.querySelector('#productivity-status').textContent.includes('保存'));const d=await fetch('/_/api/v1/extension/organizer.tasks/preferences').then(r=>r.json());if(d.preferences.due_days!==2)throw Error('Preferences missing');
|
||||
await wait(()=>document.querySelector('[name=due_days]'));fill(document.querySelector('[name=due_days]'),'2');document.querySelector('[name=notify_due]').click();document.querySelector('[name=notify_planned]').click();fill(document.querySelector('[name=reminder_time]'),'08:45');document.querySelector('.productivity-settings').requestSubmit();await wait(()=>document.querySelector('#productivity-status').textContent.includes('保存'));const d=await fetch('/_/api/v1/extension/organizer.tasks/preferences').then(r=>r.json());if(d.preferences.due_days!==2||!d.preferences.notify_due||!d.preferences.notify_planned||d.preferences.reminder_time!=='08:45'||!d.defaults.notify_due||d.defaults.notify_planned)throw Error('Preferences missing');
|
||||
}else if(path==='/v/plan/dashboard'){
|
||||
await wait(()=>document.querySelectorAll('.productivity-day').length>300);if(!document.querySelector('.productivity-day[data-level="2"]'))throw Error('Seven-point completion missing');
|
||||
if(document.querySelectorAll('[data-widget]').length!==6)throw Error('Widget registry missing');
|
||||
|
||||
Reference in new issue
Block a user