fix: replace retained task drafts with current input
Test and release pages-cli / linux (push) Successful in 10s
Test and release pages-cli / macos (push) Skipped

This commit is contained in:
Anya Tokugawa committed 2026-11-08 18:48:44 +09:00
1 parent e22af6a0ec
commit bd54b5f06a
7 files changed
+121 -16

No files matched your search

+10 -4
View File
@@ -11,6 +11,7 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
binary=str(Path(sys.argv[1]).resolve())
token='synthetic_session_'+('x'*40)
seen=[]
captures=[]
class Handler(BaseHTTPRequestHandler):
def log_message(self,*args):pass
def do_POST(self):
@@ -20,6 +21,8 @@ class Handler(BaseHTTPRequestHandler):
elif self.path=='/_/api/v1/extension/organizer.tasks/capture':
if self.headers.get('Authorization')!='Bearer '+token:self.send_error(401);return
item=json.loads(body)
captures.append(item.copy())
if item.get('wiki_prefix')=='/rejected':self.reply({'error':'invalid'},422);return
if item.get('wiki_body') != 'Message-ID: <smoke@example.invalid>\n\nPRIVATE BODY':self.send_error(422);return
item.pop('wiki_body');self.reply({'item':item,'page_path':'/private/mail/synthetic'})
else:self.send_error(404)
@@ -29,8 +32,8 @@ class Handler(BaseHTTPRequestHandler):
if self.path.startswith('/_/api/v1/extension/organizer.contacts/items?'):
self.reply({'items':[{'name':'Synthetic Person','emails':['person@example.invalid'],'organization':'Test'}]})
else:self.reply({'items':[{'uuid':'synthetic-task','title':'Packaged CLI task','status':'todo'}]})
def reply(self,value):
self.send_response(200);self.send_header('Content-Type','application/json');self.end_headers();self.wfile.write(json.dumps(value).encode())
def reply(self,value,status=200):
self.send_response(status);self.send_header('Content-Type','application/json');self.end_headers();self.wfile.write(json.dumps(value).encode())
server=ThreadingHTTPServer(('127.0.0.1',0),Handler)
thread=threading.Thread(target=server.serve_forever,daemon=True);thread.start()
@@ -46,15 +49,18 @@ try:
run('login',stdin='synthetic-password\n')
if 'Packaged CLI task' not in run('task','list'):raise AssertionError('Task missing')
mail='Subject: Mail task\r\nMessage-ID: <smoke@example.invalid>\r\nContent-Type: text/plain\r\n\r\nPRIVATE BODY'
captured=run('task','from-mail',stdin=mail)
run('task','from-mail','--wiki-prefix','/rejected',stdin=mail,success=False)
captured=run('task','from-mail','--wiki-prefix','/private/mail',stdin=mail)
if len(captures)!=2 or captures[0]['request_id']!=captures[1]['request_id'] or captures[1]['wiki_prefix']!='/private/mail':raise AssertionError('Retained draft was not overwritten under the same request ID')
if 'Mail task' not in captured or 'PRIVATE BODY' in captured:raise AssertionError('Mail privacy')
contact=run('contacts','query','--neomutt','--','--name')
if 'person@example.invalid\tSynthetic Person\tTest' not in contact:raise AssertionError('NeoMutt query')
run('shell',stdin='pwd\nexit\n')
profile=Path(root)/'pages-cli/sessions/default.json'
if json.loads(profile.read_text()).get('task_outbox'):raise AssertionError('Successful replacement remains pending')
if profile.stat().st_mode&0o077:raise AssertionError('Credential permissions')
profile.chmod(0o644);run('task','list',success=False);profile.chmod(0o600)
run('logout')
if not seen:raise AssertionError('No HTTP request')
print('Packaged CLI: configure/login/task-list/mail-capture/neomutt-query/shell/permissions/logout passed')
print('Packaged CLI: configure/login/task-list/mail-capture/draft-overwrite/neomutt-query/shell/permissions/logout passed')
finally:server.shutdown();server.server_close();thread.join()