feat: preserve capture-first screenshots in Drafts (Closes #615)
This commit is contained in:
1 parent
269916486c
commit
48e4344f28
7 files changed
+171
-42
No files matched your search
@@ -65,6 +65,7 @@ const second = captures.save({{title:'Second',body:'Two'}});
|
||||
let mismatch = '';
|
||||
try {{ captures.resume(first.id, 'alexander'); }} catch (error) {{ mismatch = error.message; }}
|
||||
const resumed = captures.resume(first.id, 'timmy');
|
||||
captures.completeResume(first.id);
|
||||
process.stdout.write(JSON.stringify({{mismatch,resumed,remaining:captures.list(),second}}));
|
||||
"""
|
||||
output = run_node(script)
|
||||
@@ -74,6 +75,52 @@ process.stdout.write(JSON.stringify({{mismatch,resumed,remaining:captures.list()
|
||||
assert [item["id"] for item in output["remaining"]] == [output["second"]["id"]]
|
||||
|
||||
|
||||
def test_unfiled_capture_durably_restores_screenshot_before_explicit_handoff_completion():
|
||||
script = f"""
|
||||
const createUnfiledCaptures = require({json.dumps(str(UNFILED))});
|
||||
const values = new Map();
|
||||
const blobs = new Map();
|
||||
const storage = {{getItem:k=>values.get(k)||null,setItem:(k,v)=>values.set(k,v)}};
|
||||
const attachmentStore = {{
|
||||
put: async (id, attachment) => blobs.set(id, attachment),
|
||||
get: async id => blobs.get(id) || null,
|
||||
delete: async id => blobs.delete(id),
|
||||
}};
|
||||
(async () => {{
|
||||
const captures = createUnfiledCaptures({{
|
||||
storage, attachmentStore, getCaptureLogin:()=>'timmy', getCurrentLogin:()=>'timmy',
|
||||
createId:()=>'capture-1', now:()=>42,
|
||||
}});
|
||||
const screenshot = {{filename:'phone.png',contentType:'image/png',blob:new Blob(['proof'],{{type:'image/png'}})}};
|
||||
const saved = await captures.save({{title:'Broken mobile layout',body:'At 320px',attachment:screenshot}});
|
||||
const listed = captures.list();
|
||||
const resumed = await captures.resume(saved.id, 'timmy');
|
||||
const beforeComplete = captures.list().length;
|
||||
await captures.completeResume(saved.id);
|
||||
process.stdout.write(JSON.stringify({{
|
||||
listed, beforeComplete, afterComplete:captures.list().length,
|
||||
resumed:{{title:resumed.title,body:resumed.body,filename:resumed.attachment.filename,
|
||||
contentType:resumed.attachment.contentType,size:resumed.attachment.blob.size}},
|
||||
blobRemoved:!blobs.has(saved.id),
|
||||
}}));
|
||||
}})().catch(error => {{ console.error(error); process.exit(1); }});
|
||||
"""
|
||||
output = run_node(script)
|
||||
|
||||
assert output["listed"][0]["hasAttachment"] is True
|
||||
assert "attachment" not in output["listed"][0]
|
||||
assert output["beforeComplete"] == 1
|
||||
assert output["afterComplete"] == 0
|
||||
assert output["blobRemoved"] is True
|
||||
assert output["resumed"] == {
|
||||
"title": "Broken mobile layout",
|
||||
"body": "At 320px",
|
||||
"filename": "phone.png",
|
||||
"contentType": "image/png",
|
||||
"size": 5,
|
||||
}
|
||||
|
||||
|
||||
def test_unfiled_capture_rejects_empty_or_identityless_records_without_writing():
|
||||
script = f"""
|
||||
const createUnfiledCaptures = require({json.dumps(str(UNFILED))});
|
||||
@@ -104,7 +151,12 @@ async def test_mobile_composer_exposes_cold_offline_save_and_account_safe_resume
|
||||
assert "createUnfiledCaptures({" in html
|
||||
assert "getCaptureLogin: () => String(lastContextSnapshot?.user?.login || '').trim()" in html
|
||||
assert "unfiledCaptures.save(captureDraft)" in html
|
||||
assert "unfiledCaptures.resume(item.capture_id, activeFlushLogin)" in html
|
||||
assert "await unfiledCaptures.resume(item.capture_id, activeFlushLogin)" in html
|
||||
assert "await createIssueAttachmentController.serialize()" in html
|
||||
assert "createUnfiledAttachmentStore()" in html
|
||||
assert "createIssueAttachmentController.restore(resumed.attachment)" in html
|
||||
assert "await unfiledCaptures.completeResume(resumedUnfiledCaptureId)" in html
|
||||
assert "item.hasAttachment ? ' · Screenshot attached' : ''" in html
|
||||
assert "issueCapture.saveDraft(resumed)" in html
|
||||
assert "item.kind === 'unfiled-issue'" in html
|
||||
assert '.create-issue-actions button { min-height:44px;' in html
|
||||
@@ -125,3 +177,6 @@ async def test_mobile_new_opens_capture_first_and_progressively_reveals_filing_f
|
||||
assert "qs('#file-new-issue').addEventListener('click'" in html
|
||||
assert '.create-issue-capture-actions button { min-height:44px;' in html
|
||||
assert '.create-issue-capture-actions[hidden] { display:none;' in html
|
||||
attachment = html.index('class="create-issue-attachment"')
|
||||
filing = html.index('class="create-issue-filing"')
|
||||
assert attachment < filing
|
||||
Reference in new issue
Block a user